My wife is trying to get me back in this game -- but I can't imagine playing without my lua unlocker.. needing a little nudge in the right direction.
Thus far I've been able to --
Load WoW image in Ida pro.
Find the relative addr of function I'd like to patch to return 1
Inject dll via Manual Mapping
Injected dll fails to patch relativeaddr+baseimage via writeprocessmemory inside DLLMain -- writing the bytes 0xb8,0x01,0x00,0x00,0x00,0xc3 (move eax 1; ret
Any help is greatly appreciated!
Code:
const DWORD_PTR offset = 0x1332980;
void patch()
{
auto id = GetCurrentProcessId();
auto baseAddr = GetProcessBaseAddress(id);
auto funcAddr = baseAddr + offset;
//log the addresses
std::stringstream sstream;
sstream << std::hex << baseAddr;
auto baseAddrStr = sstream.str();
std::stringstream sstream2;
sstream2 << std::hex << funcAddr;
auto funcAddrStr = sstream2.str();
std::ofstream log;
log.open("patchProc.log");
log << "Image Base: 0x" << baseAddrStr << endl;
log << "Function Addr: 0x" << funcAddrStr << endl;
auto* processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
if(processHandle) {
BYTE patchBytes[] = { 0xb8,0x01,0x00,0x00,0x00,0xc3 }; //mov eax 1; ret;
if (WriteProcessMemory(processHandle, reinterpret_cast<void*>(funcAddr), &patchBytes, sizeof patchBytes, nullptr)) {
log << "Wrote process memory successfully!" << endl;
}
else {
log << "Unable to write process memory. Returned false." << endl;
}
CloseHandle(processHandle);
}
log.close();
}
BOOL APIENTRY DllMain( HMODULE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
patch();
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
default:
break;
}
return TRUE;
}