#include <Windows.h>
#include <iostream>
DWORD retaddie = 0x003814AC;
void MakeJump(BYTE* paddress, DWORD yourfunction, DWORD dwlen);
DWORD base = (DWORD) GetModuleHandleA("Test Programming Ideas.exe");
DWORD dwjmpback = base + 0x114B1;
void MakeJump(BYTE* paddress, DWORD yourfunction, DWORD dwlen)
{
DWORD dwOldProtect, dwBkup, dwRelAddr;
// give the paged memory read/write permissions
VirtualProtect(paddress, dwlen, PAGE_EXECUTE_READWRITE, &dwOldProtect);
// calculate the distance between our address and our target location
// and subtract the 5bytes, which is the size of the jmp
// (0xE9 0xAA 0xBB 0xCC 0xDD) = 5 bytes
dwRelAddr = (DWORD) (yourfunction - (DWORD) paddress) - 5;
// overwrite the byte at pAddress with the jmp opcode (0xE9)
*paddress = 0xE9;
// overwrite the next 4 bytes (which is the size of a DWORD)
// with the dwRelAddr
* ((DWORD*) (paddress + 0x1)) = dwRelAddr;
// overwrite the remaining bytes with the NOP opcode (0x90)
// NOP opcode = No OPeration
for(DWORD x = 0x5; x < dwlen; x++) *(paddress + x) = 0x90;
// restore the paged memory permissions saved in dwOldProtect
VirtualProtect(paddress, dwlen, dwOldProtect, &dwBkup);
return;
}
_declspec (naked) void jumpfunc()
{
_asm
{
push 0
push 0
push 0
push 0
call MessageBoxA
push 56
push 200
call Beep
push 3E8h
JMP [dwjmpback]
}
}
BOOL _stdcall DllMain(HINSTANCE hInst, DWORD msg, LPVOID reserved)
{
char buffer[10];
switch (msg)
{
case DLL_PROCESS_ATTACH:
sprintf(buffer, "%X", (base));
MessageBoxA(0, buffer, "POINT OF DATA OPERATION", MB_OK);
MakeJump((BYTE*)(base + 0x114AC), (DWORD)jumpfunc, 5);
break;
}
}
CPU Disasm Address Hex dump Command Comments 003414A2 |> /B8 01000000 MOV EAX,1 003414A7 |. |85C0 TEST EAX,EAX 003414A9 |. |74 29 JE SHORT 003414D4 003414AB |. |68 30783400 PUSH OFFSET 00347830 ; /_Val = "Still Looping." 003414B0 |. |A1 CCA23400 MOV EAX,DWORD PTR DS:[<&MSVCP100D.?cout@ ; | 003414B5 |. |50 PUSH EAX ; |_Ostr 003414B6 |. |E8 80FCFFFF CALL 0034113B ; \std::operator<<<std::char_traits<char> > 003414BB |. |83C4 08 ADD ESP,8 003414BE |. |8BF4 MOV ESI,ESP 003414C0 |68 E8030000 PUSH 3E8 003414C5 |. |FF15 1CA23400 CALL DWORD PTR DS:[<&KERNEL32.Sleep>] 003414CB |. |3BF4 CMP ESI,ESP 003414CD |. |E8 AFFCFFFF CALL 00341181 ; [_RTC_CheckEsp 003414D2 |.^\EB CE JMP SHORT 003414A2
)MakeJump((BYTE*)(base + 0x114C0), (DWORD)jumpfunc, 0x5);
_asm
{
push 0
push 0
push 0
push 0
call dword ptr[MessageBoxA]
push 56
push 200
call dword ptr[Beep]
push 3E8h
JMP dwjmpback
}