int myprintf (
const char *format,
...
)
{
return 0;
}
int main()
{
printf("a\n");
char * target_function = (char *)&printf;
DWORD old_target_function_protect = 0;
BOOL succeeded = ::VirtualProtect(reinterpret_cast<void*>(target_function),
32,
PAGE_EXECUTE_READWRITE,
&old_target_function_protect);
if (!succeeded) {
return -1;
}
*target_function = 0xE9;
char * newfuc = (char*)&myprintf;
int offset = newfuc - target_function - 5;
memcpy(target_function + 1, &offset, 4);
succeeded = ::VirtualProtect(reinterpret_cast<void*>(target_function),
32,
old_target_function_protect,
&old_target_function_protect);
printf("aa\n");
return 0;
}
win32的hook
最新推荐文章于 2024-07-15 23:08:41 发布