mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 15:11:31 +00:00
[idd] win32: use wait result constants
Use the documented Win32 wait constants throughout the pipe, clipboard, and input workers instead of local numeric aliases. Select the WDK NT-status definitions before including Windows headers. Include wudfwdm.h privately in the affected translation units so UMDF 2 provides NTSTATUS without exposing WDF headers through LGCommon's public interface to the desktop Helper.
This commit is contained in:
@@ -18,13 +18,16 @@
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <ntstatus.h>
|
||||
|
||||
#include "CClipboardChannel.h"
|
||||
|
||||
#include <wudfwdm.h>
|
||||
|
||||
#include "CClipboardRing.h"
|
||||
#include "CDebug.h"
|
||||
|
||||
#include <new>
|
||||
#include <ntstatus.h>
|
||||
#include <string.h>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -562,9 +565,9 @@ void CClipboardChannel::Thread()
|
||||
{
|
||||
const DWORD result = WaitForMultipleObjects(
|
||||
ARRAYSIZE(events), events, FALSE, POLL_MS);
|
||||
if (result == WAIT_FIRST_OBJECT_VALUE)
|
||||
if (result == WAIT_OBJECT_0)
|
||||
break;
|
||||
if (result != WAIT_FIRST_OBJECT_VALUE + 1 && result != WAIT_TIMEOUT)
|
||||
if (result != WAIT_OBJECT_0 + 1 && result != WAIT_TIMEOUT)
|
||||
{
|
||||
const DWORD error = GetLastError();
|
||||
DEBUG_ERROR_HR(error,
|
||||
|
||||
@@ -18,8 +18,12 @@
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <ntstatus.h>
|
||||
|
||||
#include "CPipeEndpoint.h"
|
||||
|
||||
#include <wudfwdm.h>
|
||||
|
||||
#include "CDebug.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -32,7 +36,6 @@ const DWORD CPipeEndpoint::SERVER_RETRY_MS = 1000;
|
||||
const DWORD CPipeEndpoint::AUTHENTICATION_TIMEOUT_MS = 2000;
|
||||
const DWORD CPipeEndpoint::AUTHORIZATION_POLL_MS = 1000;
|
||||
const DWORD CPipeEndpoint::WRITE_TIMEOUT_MS = 250;
|
||||
const DWORD CPipeEndpoint::WAIT_FIRST_OBJECT_VALUE = 0;
|
||||
|
||||
bool CPipeEndpoint::IsDisconnectedError(DWORD error)
|
||||
{
|
||||
@@ -66,14 +69,14 @@ CPipeEndpoint::PipeIoResult CPipeEndpoint::WaitForOverlapped(
|
||||
return PipeIoResult::Error;
|
||||
}
|
||||
|
||||
if (waitResult == WAIT_FIRST_OBJECT_VALUE + 1)
|
||||
if (waitResult == WAIT_OBJECT_0 + 1)
|
||||
{
|
||||
CancelIoEx(pipe, overlapped);
|
||||
GetOverlappedResult(pipe, overlapped, transferred, TRUE);
|
||||
return PipeIoResult::Stopped;
|
||||
}
|
||||
|
||||
if (waitResult != WAIT_FIRST_OBJECT_VALUE)
|
||||
if (waitResult != WAIT_OBJECT_0)
|
||||
{
|
||||
DEBUG_ERROR_HR(GetLastError(), "Failed to wait for named pipe I/O");
|
||||
CancelIoEx(pipe, overlapped);
|
||||
@@ -86,7 +89,7 @@ CPipeEndpoint::PipeIoResult CPipeEndpoint::WaitForOverlapped(
|
||||
|
||||
const DWORD error = GetLastError();
|
||||
if (error == ERROR_OPERATION_ABORTED &&
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_FIRST_OBJECT_VALUE)
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_OBJECT_0)
|
||||
return PipeIoResult::Stopped;
|
||||
|
||||
if (IsDisconnectedError(error))
|
||||
@@ -117,7 +120,7 @@ CPipeEndpoint::PipeIoResult CPipeEndpoint::ReadMessage(
|
||||
pipe, ioEvent, &overlapped, bytesRead, timeoutMs);
|
||||
|
||||
if (error == ERROR_OPERATION_ABORTED &&
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_FIRST_OBJECT_VALUE)
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_OBJECT_0)
|
||||
return PipeIoResult::Stopped;
|
||||
|
||||
if (IsDisconnectedError(error))
|
||||
@@ -158,7 +161,7 @@ CPipeEndpoint::PipeIoResult CPipeEndpoint::WriteMessage(
|
||||
result = PipeIoResult::Disconnected;
|
||||
else if (error == ERROR_OPERATION_ABORTED &&
|
||||
WaitForSingleObject(m_stopEvent, 0) ==
|
||||
WAIT_FIRST_OBJECT_VALUE)
|
||||
WAIT_OBJECT_0)
|
||||
result = PipeIoResult::Stopped;
|
||||
else
|
||||
{
|
||||
@@ -457,7 +460,7 @@ void CPipeEndpoint::RunServer()
|
||||
}
|
||||
|
||||
if (!IsRunning() ||
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_FIRST_OBJECT_VALUE)
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
bool authenticated = false;
|
||||
@@ -508,7 +511,7 @@ void CPipeEndpoint::RunServer()
|
||||
}
|
||||
|
||||
if (!IsRunning() ||
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_FIRST_OBJECT_VALUE ||
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_OBJECT_0 ||
|
||||
(m_handler && !m_handler->PipeClientStillAuthorized(pipe)))
|
||||
{
|
||||
if (authenticated && m_handler)
|
||||
@@ -617,7 +620,7 @@ void CPipeEndpoint::RunClient()
|
||||
}
|
||||
|
||||
if (!IsRunning() ||
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_FIRST_OBJECT_VALUE)
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
CloseHandle(pipe);
|
||||
break;
|
||||
@@ -650,7 +653,7 @@ void CPipeEndpoint::RunClient()
|
||||
}
|
||||
|
||||
if (!IsRunning() ||
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_FIRST_OBJECT_VALUE)
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
CloseHandle(pipe);
|
||||
break;
|
||||
@@ -726,7 +729,7 @@ bool CPipeEndpoint::ReadMessages(HANDLE pipe)
|
||||
}
|
||||
|
||||
if (!IsRunning() ||
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_FIRST_OBJECT_VALUE)
|
||||
WaitForSingleObject(m_stopEvent, 0) == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
if (m_handler && !m_handler->PipeClientStillAuthorized(pipe))
|
||||
|
||||
@@ -126,7 +126,6 @@ private:
|
||||
static const DWORD AUTHENTICATION_TIMEOUT_MS;
|
||||
static const DWORD AUTHORIZATION_POLL_MS;
|
||||
static const DWORD WRITE_TIMEOUT_MS;
|
||||
static const DWORD WAIT_FIRST_OBJECT_VALUE;
|
||||
|
||||
static bool IsDisconnectedError(_In_ DWORD error);
|
||||
PipeIoResult WaitForOverlapped(
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>UMDF_USING_NTSTATUS;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/EHsc /D_ATL_NO_WIN_SUPPORT %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir);$(SolutionDir)..\common\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
|
||||
Reference in New Issue
Block a user