Skip to content

Commit df0685c

Browse files
committed
fix
1 parent e00e063 commit df0685c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

main.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <Windows.h>
22
#include <iostream>
33

4+
#define SLEEP_TIME 1000
5+
46
typedef void(__stdcall* TrueSleep)(DWORD);
57

68
TrueSleep oSleep;
@@ -15,9 +17,9 @@ void __stdcall MySleep(DWORD dwMilliseconds)
1517

1618
bool HookIAT(const char* module_name, const char* func_name, void* new_func, void** old_func)
1719
{
18-
DWORD module_base = (DWORD)GetModuleHandleA(NULL);
20+
uintptr_t module_base = (uintptr_t)GetModuleHandleA(NULL);
1921
IMAGE_DOS_HEADER* dos_header = (IMAGE_DOS_HEADER*)module_base;
20-
IMAGE_NT_HEADERS32* pe_header = (IMAGE_NT_HEADERS32*)(module_base + dos_header->e_lfanew);
22+
IMAGE_NT_HEADERS* pe_header = (IMAGE_NT_HEADERS*)(module_base + dos_header->e_lfanew);
2123

2224
if (pe_header->Signature != IMAGE_NT_SIGNATURE)
2325
return false;
@@ -35,8 +37,8 @@ bool HookIAT(const char* module_name, const char* func_name, void* new_func, voi
3537
if (!import_descriptor[i].FirstThunk || !import_descriptor[i].OriginalFirstThunk)
3638
return false;
3739

38-
IMAGE_THUNK_DATA32* thunk = (IMAGE_THUNK_DATA32*)(module_base + import_descriptor[i].FirstThunk);
39-
IMAGE_THUNK_DATA32* orig_thunk = (IMAGE_THUNK_DATA32*)(module_base + import_descriptor[i].OriginalFirstThunk);
40+
IMAGE_THUNK_DATA* thunk = (IMAGE_THUNK_DATA*)(module_base + import_descriptor[i].FirstThunk);
41+
IMAGE_THUNK_DATA* orig_thunk = (IMAGE_THUNK_DATA*)(module_base + import_descriptor[i].OriginalFirstThunk);
4042

4143
for (; orig_thunk->u1.Function != 0; ++thunk, ++orig_thunk)
4244
{
@@ -56,7 +58,7 @@ bool HookIAT(const char* module_name, const char* func_name, void* new_func, voi
5658
return false;
5759

5860
*old_func = (void*)thunk->u1.Function;
59-
thunk->u1.Function = (DWORD)new_func;
61+
thunk->u1.Function = (uintptr_t)new_func;
6062

6163
if (VirtualProtect(mbi.BaseAddress, mbi.RegionSize, mbi.Protect, &junk))
6264
return true;
@@ -72,6 +74,8 @@ int main()
7274
else
7375
{
7476
printf("[+] old_addr = 0x%p, new_addr = 0x%p\n", oSleep, &MySleep);
75-
Sleep(1000);
77+
Sleep(SLEEP_TIME);
7678
}
79+
80+
system("pause");
7781
}

0 commit comments

Comments
 (0)