diff --git a/idd/LGCommon/CClipboardChannel.cpp b/idd/LGCommon/CClipboardChannel.cpp index 3e25429e..3124a882 100644 --- a/idd/LGCommon/CClipboardChannel.cpp +++ b/idd/LGCommon/CClipboardChannel.cpp @@ -18,13 +18,16 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "CClipboardChannel.h" +#include + #include "CClipboardRing.h" #include "CDebug.h" #include -#include #include #include #include @@ -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, diff --git a/idd/LGCommon/CPipeEndpoint.cpp b/idd/LGCommon/CPipeEndpoint.cpp index 0e7182a1..388cc1b1 100644 --- a/idd/LGCommon/CPipeEndpoint.cpp +++ b/idd/LGCommon/CPipeEndpoint.cpp @@ -18,8 +18,12 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "CPipeEndpoint.h" +#include + #include "CDebug.h" #include @@ -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)) diff --git a/idd/LGCommon/CPipeEndpoint.h b/idd/LGCommon/CPipeEndpoint.h index 3345d12b..9817f8c3 100644 --- a/idd/LGCommon/CPipeEndpoint.h +++ b/idd/LGCommon/CPipeEndpoint.h @@ -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( diff --git a/idd/LGCommon/LGCommon.vcxproj b/idd/LGCommon/LGCommon.vcxproj index c0a5bcd2..df5265ca 100644 --- a/idd/LGCommon/LGCommon.vcxproj +++ b/idd/LGCommon/LGCommon.vcxproj @@ -59,7 +59,7 @@ MultiThreaded - _ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + UMDF_USING_NTSTATUS;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) /EHsc /D_ATL_NO_WIN_SUPPORT %(AdditionalOptions) $(ProjectDir);$(SolutionDir)..\common\include;%(AdditionalIncludeDirectories) diff --git a/idd/LGIdd/LGIdd.vcxproj b/idd/LGIdd/LGIdd.vcxproj index 30e89d46..01d80236 100644 --- a/idd/LGIdd/LGIdd.vcxproj +++ b/idd/LGIdd/LGIdd.vcxproj @@ -280,6 +280,11 @@ $([MSBuild]::NormalizeDirectory('$(LGDriverSolutionDir)$(LGBaseConfiguration)')) /sw2084 + + + UMDF_USING_NTSTATUS;%(PreprocessorDefinitions) + + true diff --git a/idd/LGIdd/ipc/CInputPipeServer.cpp b/idd/LGIdd/ipc/CInputPipeServer.cpp index 7ac00909..d2eb1f7e 100644 --- a/idd/LGIdd/ipc/CInputPipeServer.cpp +++ b/idd/LGIdd/ipc/CInputPipeServer.cpp @@ -18,8 +18,12 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "ipc/CInputPipeServer.h" +#include + #include "config/CSettings.h" #include "CDebug.h" #include "CSRWLock.h" @@ -29,8 +33,6 @@ CInputPipeServer g_inputPipeServer; -static constexpr DWORD WAIT_FIRST_OBJECT_VALUE = 0; - bool CInputPipeServer::Init() { DeInit(); @@ -564,9 +566,9 @@ void CInputPipeServer::Thread() { const DWORD wait = WaitForMultipleObjects( _countof(handles), handles, FALSE, INFINITE); - if (wait == WAIT_FIRST_OBJECT_VALUE) + if (wait == WAIT_OBJECT_0) break; - if (wait != WAIT_FIRST_OBJECT_VALUE + 1) + if (wait != WAIT_OBJECT_0 + 1) { DEBUG_ERROR_HR(GetLastError(), "LGInput sender wait failed"); break; diff --git a/idd/LGIdd/transport/lgmp/CLGMPClipboardTransport.cpp b/idd/LGIdd/transport/lgmp/CLGMPClipboardTransport.cpp index db935308..0c110fba 100644 --- a/idd/LGIdd/transport/lgmp/CLGMPClipboardTransport.cpp +++ b/idd/LGIdd/transport/lgmp/CLGMPClipboardTransport.cpp @@ -18,8 +18,12 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "transport/lgmp/CLGMPClipboardTransport.h" +#include + #include "CDebug.h" #include "Seq.h" #include "transport/lgmp/CLGMPHost.h" @@ -29,8 +33,6 @@ namespace { - static constexpr DWORD WAIT_FIRST_OBJECT_VALUE = 0; - static_assert(sizeof(LGMPStreamDescriptor) == sizeof(KVMFRStreamDescriptor), "LGMP and KVMFR stream descriptor sizes differ"); @@ -1899,14 +1901,14 @@ void CLGMPClipboardTransport::Thread() const HANDLE handles[] = { m_stopEvent, m_wakeEvent }; const DWORD wait = WaitForMultipleObjects( _countof(handles), handles, FALSE, timeout); - if (wait == WAIT_FIRST_OBJECT_VALUE) + if (wait == WAIT_OBJECT_0) break; - if (wait == WAIT_FIRST_OBJECT_VALUE + 1) + if (wait == WAIT_OBJECT_0 + 1) { lgmpStreamPollActivity(&streamPoll); continue; } - if (wait != WAIT_FIRST_OBJECT_VALUE + 1 && wait != WAIT_TIMEOUT) + if (wait != WAIT_OBJECT_0 + 1 && wait != WAIT_TIMEOUT) { DEBUG_ERROR_HR(GetLastError(), "LGMP clipboard worker wait failed"); diff --git a/idd/LGIdd/transport/lgmp/CLGMPInputTransport.cpp b/idd/LGIdd/transport/lgmp/CLGMPInputTransport.cpp index 9ff995fe..256cffb6 100644 --- a/idd/LGIdd/transport/lgmp/CLGMPInputTransport.cpp +++ b/idd/LGIdd/transport/lgmp/CLGMPInputTransport.cpp @@ -18,8 +18,12 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "transport/lgmp/CLGMPInputTransport.h" +#include + #include "config/CSettings.h" #include "transport/lgmp/CLGMPHost.h" #include "Atomic.h" @@ -53,8 +57,6 @@ static constexpr int32_t MAX_MOUSE_WHEEL = INT8_MAX * MAX_SPLIT_REPORTS; static constexpr int32_t MIN_MOUSE_WHEEL = -INT8_MAX * MAX_SPLIT_REPORTS; -static constexpr DWORD WAIT_FIRST_OBJECT_VALUE = 0; - static bool IsZero(const void * data, size_t size) { const uint8_t * byte = static_cast(data); @@ -446,7 +448,7 @@ bool CLGMPInputTransport::Start(IInputTarget& target) const DWORD state = WaitForSingleObject(m_thread, 0); if (state == WAIT_TIMEOUT) return true; - if (state != WAIT_FIRST_OBJECT_VALUE) + if (state != WAIT_OBJECT_0) { DEBUG_ERROR_HR(GetLastError(), "Failed to inspect LGMP input worker"); @@ -1006,12 +1008,12 @@ void CLGMPInputTransport::Thread() const DWORD wait = WaitForMultipleObjects( _countof(waitHandles), waitHandles, FALSE, INFINITE); - if (wait == WAIT_FIRST_OBJECT_VALUE) + if (wait == WAIT_OBJECT_0) { failed = Atomic::Load(m_statusFailed, std::memory_order_acquire); break; } - if (wait != WAIT_FIRST_OBJECT_VALUE + 1) + if (wait != WAIT_OBJECT_0 + 1) { DEBUG_ERROR_HR(GetLastError(), "LGMP input worker wait failed"); failed = true;