Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef void (*editVar)();
- editVar edVar = reinterpret_cast<editVar>(0x004010D1);
- BYTE* _orig = new BYTE (5);
- void hEditVar()
- {
- int _val = 0;
- int __stack[2];
- __asm pop eax
- __asm mov __stack, eax
- __asm pop eax
- __asm mov __stack+1, eax
- __asm pop eax
- __asm mov _val, eax
- __asm push __stack
- __asm push __stack+1
- __asm push eax
- printf("Yeap, it is hooked, your value is: %d", _val);
- while(true){}
- }
- editVar hEdVar = &hEditVar;
- int DllThread()
- {
- printf("\nMyHookedFun = inAppTest.dll [0x%x]", (int)hEdVar);
- DWORD oldProtect;
- VirtualProtect(edVar, 5, PAGE_EXECUTE_READWRITE, &oldProtect);
- memcpy(_orig, edVar, 5);
- printf("\nOriginal bytes: ");
- for (int i = 0; i != sizeof(_orig) + 1; i++)
- printf("%x ", _orig[i]);
- int* newAddr = (int*) malloc(sizeof(int));
- *newAddr = (int)hEdVar - (int)edVar - 5;
- *reinterpret_cast<int*>(edVar) = 0x0E9;
- memcpy((int*)((int)edVar + 1), newAddr, 4);
- printf("\nNew bytes: ");
- for (int i = 0; i != sizeof(_orig) + 1; i++)
- printf("%x ", reinterpret_cast<BYTE*>(edVar)[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement