SendIpcMessage() issue on Windows 7(32/64bit)
Posted: Thu Oct 20, 2016 6:57 am
I've found a SendIpeMessage() bug on Windows 7(32/64bit). I'm using madCodeHook v3.1.13
In a hook dll, I call SendIpcMessage() like this:
This code is called in NtCreateFile hook function.
I've omitted error handling for clarity, but SendIpcMessage() returns 'true' here.
And in a exe file, the callback function is like this:
So, the debug messages should print this way:
On Windows XP, 8.1, 10 the debug messages print as expected.
But on Windows 7, the debug messages print in a weird order like this:
In other words, SendIpcMessage() does not wait for the callback function to complete. It returns immediately 'true'.
I've omitted answer buffer manipulation here for clarity, but the answer buffer is intact when I write something in a callback function.
Is this a bug?
In a hook dll, I call SendIpcMessage() like this:
Code: Select all
OutputDebugString(L"IPC Start");
SendIpcMessage("MyIpcName", (void*)&requestMessage[0], requestMessage.size(), &responseBuffer[0], sizeof(responseBuffer), 5 * 1000, false);
OutputDebugString(L"IPC End");
I've omitted error handling for clarity, but SendIpcMessage() returns 'true' here.
And in a exe file, the callback function is like this:
Code: Select all
static void WINAPI IpcCallback(LPCSTR pIpc, LPCVOID pMessageBuf, DWORD dwMessageLen, LPVOID pAnswerBuf, DWORD dwAnswerLen) {
OutputDebugString(L"IpcCallback() Start");
Sleep(500);
OutputDebugString(L"IpcCallback() End");
}
Code: Select all
IPC Start
IpcCallback() Start
IpcCallback() End
IPC End
But on Windows 7, the debug messages print in a weird order like this:
Code: Select all
IPC Start
IPC End
IpcCallback() Start
/* and 500ms later... */
IpcCallback() End
I've omitted answer buffer manipulation here for clarity, but the answer buffer is intact when I write something in a callback function.
Is this a bug?