Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Original Code:
- // dllmain.cpp : Defines the entry point for the DLL application.
- #include <Windows.h>
- #include "MinHook.h"
- #include "PatternScan.h"
- typedef int(*origSum)(int x, int y);
- DWORD AddressOfSum = NULL;
- uintptr_t base = NULL;
- origSum oSum = (origSum)AddressOfSum;
- //Another Version:
- //DWORD AddressOfSumWithOffset = (DWORD)base + 0xFFFFFFFF; No offset yet - check x64dbg later...
- int hookedSum(int x, int y)
- {
- x += 500;
- y += 500;
- return oSum(x ,y);
- }
- DWORD WINAPI MainThread(LPVOID lpParam)
- {
- base = (uintptr_t)GetModuleHandle(NULL); //Grabs base address of host executable
- return 0;
- }
- BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
- {
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- AddressOfSum = FindPattern("testhook.exe", "89 54 24 10 89 4C 24 08 55");
- if (MH_Initialize() != MH_OK) return 1;
- if (MH_CreateHook((LPVOID)oSum, &hookedSum, NULL) != MH_OK) return 1;
- if (MH_EnableHook((LPVOID)oSum) != MH_OK) return 1;
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- //Didn't add MinHook uninitalize code yet...
- break;
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement