12 Star 15 Fork 0

nagist / MetaHook

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
OEPHook.cpp 844 Bytes
一键复制 编辑 原始数据 按行查看 历史
NagiCode@gmail.com 提交于 2014-04-16 02:55 . No commit message
#include <windows.h>
#include "Detours\detours.h"
typedef int (CALLBACK *fnWinMain)(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
void HookOEP(void)
{
HMODULE hGameModule = GetModuleHandle(NULL);
PBYTE PEHead = (PBYTE)hGameModule;
PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)hGameModule;
PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS)&PEHead[pDosHeader->e_lfanew];
fnWinMain pWinMain = (fnWinMain)&PEHead[pNTHeader->OptionalHeader.AddressOfEntryPoint];
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach((void**)&pWinMain, WinMain);
DetourTransactionCommit();
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
{
HookOEP();
}
}
return TRUE;
}
C++
1
https://gitee.com/nagist/MetaHook.git
git@gitee.com:nagist/MetaHook.git
nagist
MetaHook
MetaHook
master

搜索帮助