Skip to content

Commit

Permalink
fix if the hook is not called at the start of the process, the hook m…
Browse files Browse the repository at this point in the history
…ay fail
  • Loading branch information
sonyps5201314 committed Sep 4, 2020
1 parent 8298cdc commit b492481
Show file tree
Hide file tree
Showing 7 changed files with 534 additions and 49 deletions.
2 changes: 1 addition & 1 deletion samples/common.mak
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CLIB=/MT
!ENDIF

AFLAGS=/nologo /Zi /c /Fl
CFLAGS=/nologo /Zi $(CLIB) /Gm- /W4 /WX /we4777 /we4800 /Od
CFLAGS=/nologo /Zi $(CLIB) /Gm- /W4 /WX /we4777 /we4800 /Od /D__AUTO_CREATE_DETOUR_HEAP__

!IF $(DETOURS_SOURCE_BROWSING)==1
CFLAGS=$(CFLAGS) /FR
Expand Down
10 changes: 5 additions & 5 deletions src/creatwth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ VOID CALLBACK DetourFinishHelperProcess(_In_ HWND,
goto Cleanup;
}

rlpDlls = new NOTHROW LPCSTR [s_pHelper->nDlls];
rlpDlls = DetourCreateObjectArray<LPCSTR>(s_pHelper->nDlls);
cSize = s_pHelper->cb - sizeof(DETOUR_EXE_HELPER);
for (DWORD n = 0; n < s_pHelper->nDlls; n++) {
size_t cchDest = 0;
Expand All @@ -1047,7 +1047,7 @@ VOID CALLBACK DetourFinishHelperProcess(_In_ HWND,

Cleanup:
if (rlpDlls != NULL) {
delete[] rlpDlls;
DetourDestroyObjectArray(rlpDlls);
rlpDlls = NULL;
}

Expand Down Expand Up @@ -1124,7 +1124,7 @@ BOOL WINAPI AllocExeHelper(_Out_ PDETOUR_EXE_HELPER *pHelper,
cSize += (DWORD)cchDest + 1;
}

Helper = (PDETOUR_EXE_HELPER) new NOTHROW BYTE[sizeof(DETOUR_EXE_HELPER) + cSize];
Helper = (PDETOUR_EXE_HELPER)DetourCreateObjectArray<BYTE>(sizeof(DETOUR_EXE_HELPER) + cSize);
if (Helper == NULL) {
goto Cleanup;
}
Expand Down Expand Up @@ -1189,7 +1189,7 @@ BOOL WINAPI AllocExeHelper(_Out_ PDETOUR_EXE_HELPER *pHelper,

Cleanup:
if (Helper != NULL) {
delete[] (PBYTE)Helper;
DetourDestroyObjectArray((PBYTE)Helper);
Helper = NULL;
}
return Result;
Expand All @@ -1199,7 +1199,7 @@ static
VOID WINAPI FreeExeHelper(PDETOUR_EXE_HELPER *pHelper)
{
if (*pHelper != NULL) {
delete[] (PBYTE)*pHelper;
DetourDestroyObjectArray((PBYTE)*pHelper);
*pHelper = NULL;
}
}
Expand Down
Loading

0 comments on commit b492481

Please sign in to comment.