Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix if the hook is not called at the start of the process, the hook may fail #144

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c029e71
fix if the hook is not called at the start of the process, the hook m…
sonyps5201314 Sep 4, 2020
1b652fc
The code format is adapted to the Detours code style
sonyps5201314 Sep 6, 2020
08e1e1c
The code format is adapted to the Detours code style
sonyps5201314 Sep 7, 2020
cfa9dfc
Added notes on usage precautions to DetourUpdateAllOtherThreads
sonyps5201314 Sep 15, 2020
b536f10
sync from mhook: Add comment and assert for FindProcess (fix #26)
sonyps5201314 Oct 20, 2020
cde95a8
Use virtual memory to replace heap memory for internal memory managem…
sonyps5201314 Oct 20, 2020
1fe5b0e
Refine the code
sonyps5201314 Oct 21, 2020
961977a
make Memory-management-APIs can avoid Use-after-free, Double-free and…
sonyps5201314 Oct 25, 2020
2da209b
refine the code
sonyps5201314 Jan 25, 2021
e5ce233
The code format is adapted to the Detours code style
sonyps5201314 Jan 25, 2021
9d41534
Fix a warning in code analysis
sonyps5201314 Jan 28, 2021
0a56e18
Merge branch 'master' into fix_maybe_can_not_hook_functions_not_at_th…
sonyps5201314 Mar 5, 2021
0e0a3a0
fix build
sonyps5201314 Mar 6, 2021
cf68032
Merge branch 'master' into fix_maybe_can_not_hook_functions_not_at_th…
sonyps5201314 Apr 14, 2021
e8eb6b7
Fix an assertion error
sonyps5201314 Nov 20, 2021
f47dbd9
Merge branch 'microsoft:master' into fix_maybe_can_not_hook_functions…
sonyps5201314 Nov 20, 2021
a408615
Merge branch 'master' into fix_maybe_can_not_hook_functions_not_at_th…
sonyps5201314 Jul 30, 2022
3d2d13b
Maintenance: Fix incorrect SAL annotation found by latest MSVC Analysis
sonyps5201314 Aug 1, 2022
e138422
Merge branch 'master' into fix_maybe_can_not_hook_functions_not_at_th…
sonyps5201314 Aug 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/creatwth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,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 @@ -1177,7 +1177,7 @@ VOID CALLBACK DetourFinishHelperProcess(_In_ HWND,

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

Expand Down Expand Up @@ -1251,7 +1251,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);
bgianfo marked this conversation as resolved.
Show resolved Hide resolved
if (Helper == NULL) {
goto Cleanup;
}
Expand Down Expand Up @@ -1316,7 +1316,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 @@ -1326,7 +1326,7 @@ static
VOID WINAPI FreeExeHelper(PDETOUR_EXE_HELPER *pHelper)
{
if (*pHelper != NULL) {
delete[] (PBYTE)*pHelper;
DetourDestroyObjectArray((PBYTE&)*pHelper);
*pHelper = NULL;
}
}
Expand Down
Loading