Well i am trying to create a codecave... this is my first time trying. i have injected the dll successfully in the target but my custom codecave is not getting called
Code:
#include <Windows.h>
__declspec(naked) void codecave()
{
__asm
{
PUSHAD
PUSHFD
}
MessageBox(NULL, "ROCK", "THE", MB_ICONINFORMATION);
__asm
{
POPFD
POPAD
ret
}
}
__declspec(naked) void *shortcut(const byte *dst)
{
__asm{
jmp dst
}
}
void CreatRoute(byte *src, const byte *dst)
{
DWORD oldProtection;
VirtualProtect(src, sizeof(dst), PAGE_EXECUTE_READWRITE, &oldProtection);
memcpy((byte*)shortcut(dst), src, sizeof(dst));
VirtualProtect(src, sizeof(dst), oldProtection, &oldProtection);
}
BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
MessageBox(NULL, "DLL loaded!", "MyDLL", MB_ICONINFORMATION);
CreatRoute((BYTE*)0x00E54D20, (BYTE*)codecave);
break;
case DLL_PROCESS_DETACH:
MessageBox(NULL, "DLL unloaded!", "MyDLL", MB_ICONINFORMATION);
break;
default:
break;
}
return TRUE;
}