i'm hooking GetQueuedCompletionStatus
function with code below:
// hook code
typedef BOOL (__stdcall * MyGetQueuedCompletionStatus)(
_In_ HANDLE CompletionPort,
_Out_ LPDWORD lpNumberOfBytes,
_Out_ PULONG_PTR lpCompletionKey,
_Out_ LPOVERLAPPED *lpOverlapped,
_In_ DWORD dwMilliseconds
);
static BOOL __stdcall OwnGetQueuedCompletionStatus(
__in HANDLE CompletionPort,
__out LPDWORD lpNumberOfBytesTransferred,
__out PULONG_PTR lpCompletionKey,
__out LPOVERLAPPED *lpOverlapped,
__in DWORD dwMilliseconds
);
int hook()
{
LPVOID fnOrigGetQueuedCompletionStatus = ::GetProcAddress(LoadLibrary("kernel32.dll"), "GetQueuedCompletionStatus");
DWORD dwOsErr = cHookMgr.Hook(&nHookId, (LPVOID*)&(Information::Instance().pTrampolineGetQueuedCompletionStatus), fnOrigGetQueuedCompletionStatus, OwnGetQueuedCompletionStatus);
}
static BOOL __stdcall OwnGetQueuedCompletionStatus(
__in HANDLE CompletionPort,
__out LPDWORD lpNumberOfBytesTransferred,
__out PULONG_PTR lpCompletionKey,
__out LPOVERLAPPED *lpOverlapped,
__in DWORD dwMilliseconds
)
{
return Information::Instance().pTrampolineGetQueuedCompletionStatus(CompletionPort, lpNumberOfBytesTransferred, lpCompletionKey, lpOverlapped, dwMilliseconds);
}
As you can see, fake function does nothing but i always have crashes when hooking app use it:
Problem Event Name: BEX64
Application Name: MainServer.exe
Application Timestamp: 575f98b7
Fault Module Name: test64.dll_unloaded
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 585af544
Exception Offset: 00000000000025a0
Exception Code: c0000005 Exception Data: 0000000000000008
Other hooked functions work well. How can i fix that?