有木有大佬帮忙封装一段C++代码
void SetCompleteHook(BYTE head,DWORD offset,...) // OK
{
DWORD OldProtect;
VirtualProtect((void*)offset,5,PAGE_EXECUTE_READWRITE,&OldProtect);
if(head != 0xFF)
{
*(BYTE*)(offset) = head;
}
DWORD* function = &offset+1;
*(DWORD*)(offset+1) = (*function)-(offset+5);
VirtualProtect((void*)offset,5,OldProtect,&OldProtect);
}
1.直接嵌入式,2.用微软的detours hook库多方便啊 <火山程序 类型 = "通常" 版本 = 1 />
方法 SetCompleteHook <公开 静态 @禁止流程检查 = 真>
参数 head <类型 = 字节>
参数 offset <类型 = 变整数>
{
@ DWORD OldProtect;
@ VirtualProtect((void*)@<offset>,5,PAGE_EXECUTE_READWRITE,&OldProtect);
@ if(@<head> != 0xFF){
@ *(BYTE*)(@<offset>) = @<head>;
@ }
@ DWORD* function = &(DWORD)@<offset>+1;
@ *(DWORD*)(@<offset>+1) = (*function)-(@<offset>+5);
@ VirtualProtect((void*)@<offset>,5,OldProtect,&OldProtect);
}
页:
[1]