return ret;\r
}\r
\r
-STDMETHODIMP_(BOOL) CWMProvider::\r
-WmReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,\r
- LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)\r
-{\r
- BOOL ret;\r
-\r
- if (lpOverlapped == NULL) {\r
- EnterCriticalSection(&m_CritSecRead);\r
- ReadFile(hFile, lpBuffer, nNumberOfBytesToRead,\r
- lpNumberOfBytesRead, &m_OverlapRead);\r
- ret = GetOverlappedResult(&m_OverlapRead, lpNumberOfBytesRead, TRUE);\r
- LeaveCriticalSection(&m_CritSecRead);\r
- } else {\r
- ret = ReadFile(hFile, lpBuffer, nNumberOfBytesToRead,\r
- lpNumberOfBytesRead, lpOverlapped);\r
- }\r
-\r
- return ret;\r
-}\r
-\r
-STDMETHODIMP_(BOOL) CWMProvider::\r
-WmWriteFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberIfBytesToWrite,\r
- LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)\r
-{\r
- BOOL ret;\r
-\r
- if (lpOverlapped == NULL) {\r
- EnterCriticalSection(&m_CritSecWrite);\r
- WriteFile(hFile, lpBuffer, nNumberIfBytesToWrite,\r
- lpNumberOfBytesWritten, &m_OverlapWrite);\r
- ret = GetOverlappedResult(&m_OverlapWrite, lpNumberOfBytesWritten, TRUE);\r
- LeaveCriticalSection(&m_CritSecWrite);\r
- } else {\r
- ret = WriteFile(hFile, lpBuffer, nNumberIfBytesToWrite,\r
- lpNumberOfBytesWritten, lpOverlapped);\r
- }\r
-\r
- return ret;\r
-}\r
-\r
STDMETHODIMP CWMProvider::\r
Register(WM_REGISTER *pAttributes, UINT64 *pId)\r
{\r
Send(WM_MAD *pMad, OVERLAPPED *pOverlapped)\r
{\r
DWORD bytes;\r
+ HRESULT hr;\r
\r
- if (WmWriteFile(m_hFile, pMad, (DWORD) sizeof(WM_MAD) + pMad->Length,\r
- &bytes, pOverlapped)) {\r
- return NOERROR;\r
+ bytes = (DWORD) sizeof(WM_MAD) + pMad->Length;\r
+ if (pOverlapped == NULL) {\r
+ EnterCriticalSection(&m_CritSecWrite);\r
+ WriteFile(m_hFile, pMad, bytes, &bytes, &m_OverlapWrite);\r
+ hr = GetOverlappedResult(&m_OverlapWrite, &bytes, TRUE);\r
+ LeaveCriticalSection(&m_CritSecWrite);\r
} else {\r
- return HRESULT_FROM_WIN32(GetLastError());\r
+ if (WriteFile(m_hFile, pMad, bytes, &bytes, pOverlapped)) {\r
+ hr = NOERROR;\r
+ } else {\r
+ hr = HRESULT_FROM_WIN32(GetLastError());\r
+ }\r
}\r
+\r
+ return hr;\r
}\r
\r
STDMETHODIMP CWMProvider::\r
Receive(WM_MAD *pMad, SIZE_T BufferSize, OVERLAPPED *pOverlapped)\r
{\r
DWORD bytes;\r
+ HRESULT hr;\r
\r
- if (WmReadFile(m_hFile, pMad, (DWORD) BufferSize, &bytes, pOverlapped)) {\r
- return NOERROR;\r
+ if (pOverlapped == NULL) {\r
+ EnterCriticalSection(&m_CritSecRead);\r
+ ReadFile(m_hFile, pMad, (DWORD) BufferSize, &bytes, &m_OverlapRead);\r
+ hr = GetOverlappedResult(&m_OverlapRead, &bytes, TRUE);\r
+ LeaveCriticalSection(&m_CritSecRead);\r
} else {\r
- return HRESULT_FROM_WIN32(GetLastError());\r
+ if (ReadFile(m_hFile, pMad, (DWORD) BufferSize, &bytes, pOverlapped)) {\r
+ hr = NOERROR;\r
+ } else {\r
+ hr = HRESULT_FROM_WIN32(GetLastError());\r
+ }\r
}\r
+\r
+ return hr;\r
}\r
LPVOID lpOutBuffer, DWORD nOutBufferSize,\r
LPDWORD lpBytesReturned,\r
LPOVERLAPPED lpOverlapped);\r
- STDMETHODIMP_(BOOL) WmReadFile(HANDLE hFile, LPVOID lpBuffer,\r
- DWORD nNumberOfBytesToRead,\r
- LPDWORD lpNumberOfBytesRead,\r
- LPOVERLAPPED lpOverlapped);\r
- STDMETHODIMP_(BOOL) WmWriteFile(HANDLE hFile, LPVOID lpBuffer,\r
- DWORD nNumberIfBytesToWrite,\r
- LPDWORD lpNumberOfBytesWritten,\r
- LPOVERLAPPED lpOverlapped);\r
\r
OVERLAPPED m_OverlapWrite;\r
OVERLAPPED m_OverlapRead;\r