【发布时间】:2011-12-26 18:07:12
【问题描述】:
我正在尝试热修补内存中的 exe,源可用,但我这样做是为了学习。 (所以请不要让 cmets 建议我修改原始源或使用 detours 或任何其他库)
以下是我遇到问题的功能。
vm_t* VM_Create( const char *module, intptr_t (*systemCalls)(intptr_t *), vmInterpret_t interpret )
{
MessageBox(NULL, L"Oh snap! We hooked VM_Create!", L"Success!", MB_OK);
return NULL;
}
void Hook_VM_Create(void)
{
DWORD dwBackup;
VirtualProtect((void*)0x00477C3E, 7, PAGE_EXECUTE_READWRITE, &dwBackup);
//Patch the original VM_Create to jump to our detoured one.
BYTE *jmp = (BYTE*)malloc(5);
uint32_t offset = 0x00477C3E - (uint32_t)&VM_Create; //find the offset of the original function from our own
memset((void*)jmp, 0xE9, 1);
memcpy((void*)(jmp+1), &offset, sizeof(offset));
memcpy((void*)0x00477C3E, jmp, 5);
free(jmp);
}
我有一个要调用的函数 VM_Create,而不是原始函数。我还没有写过蹦床,所以它崩溃了(如预期的那样)。但是,没有弹出消息框,表明我已经绕道了原始 VM 创建到我自己的。我相信这是我覆盖原始指令的方式。
【问题讨论】:
标签: c winapi assembly reverse-engineering