Anyone able to tell me what in my (I know its ugly :>) code is wrong? For some reason my wow keeps just closing when I use it.
Code:
void lua_dostring(string lstring, Process* proc)
{
DWORD_PTR lstring_mem = proc->AllocateMemory(0x300);
DWORD_PTR codecave = proc->AllocateMemory(0x1024);
proc->WriteMemString(lstring_mem, lstring);
proc->WriteMemString(codecave, "\xB9"); // MOV ecx,
proc->WriteMemDWORD(codecave+1, lstring_mem + lstring.length() - 1);
proc->WriteMemString(codecave+5, "\xB8"); // MOV eax
proc->WriteMemDWORD(codecave+6, lstring_mem); // Address of the string to execute
proc->WriteMemString(codecave+11, "\x6A"); // push
proc->WriteMemString(codecave+12, zerostring); // 0
proc->WriteMemString(codecave+13, "\x50\x50\xB8"); // push eax -> push eax -> mov eax
proc->WriteMemDWORD(codecave+16, 0x49AAB0); // Function-address
proc->WriteMemString(codecave+20, "\xFF\xD0\x83\xC4\xC\xC3"); // call eax -> add esp, 0xC -> retn
proc->Suspend();
proc->CreateThread(codecave);
proc->WaitForThread();
proc->Resume();
proc->FreeMemory(lstring_mem);
proc->FreeMemory(codecave);
}
The funny thing is wow often exits when I suspend its thread or create the RemoteThread. This never happens with any other application.
Here is my implementation of those functions:
Code:
bool Process::Suspend()
{
if(SuspendThread(thread_handle) > 0)
return false;
return true;
}
bool Process::Resume()
{
if(ResumeThread(thread_handle) > 1)
return false;
return true;
}
void Process::CreateThread(DWORD_PTR address, LPVOID param)
{
RemoteThread = CreateRemoteThread(process_handle, NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(address), 0, 0, NULL);
}
void Process::WaitForThread()
{
WaitForSingleObject(RemoteThread, INFINITE);
};
Maybe someone is able to point me to my mistake. Thanks.