Hi,
I just started doing some coding with memory. And have to say it's still very difficult.
My first goal is to "simply" read the current logged in characters' name. To do so, I understand you need the WoW base address + the rebased playername offset (now: 0x9BE820). Correct so far?
First off i created a new function in my project to get the base-address from module WoW.exe.
Code:
function TForm2.GetModuleBaseAddress(ProcessID: Cardinal; MName: String): Pointer;
var
Modules : Array of HMODULE;
cbNeeded, i : Cardinal;
ModuleInfo : TModuleInfo;
ModuleName : Array[0..MAX_PATH] of Char;
PHandle : THandle;
begin
Result := nil;
SetLength(Modules, 1024);
PHandle := OpenProcess(PROCESS_QUERY_INFORMATION + PROCESS_VM_READ, False, ProcessID);
if (PHandle <> 0) then
begin
EnumProcessModules(PHandle, @Modules[0], 1024 * SizeOf(HMODULE), cbNeeded);
SetLength(Modules, cbNeeded div SizeOf(HMODULE));
for i := 0 to Length(Modules) - 1 do
begin
GetModuleBaseName(PHandle, Modules[i], ModuleName, SizeOf(ModuleName));
GetModuleInformation(PHandle, Modules[i], @ModuleInfo, SizeOf(ModuleInfo));
Result := ModuleInfo.lpBaseOfDll;
CloseHandle(PHandle);
Exit;
end;
end;
end;
So I assume the starting point of the playername can be retrieved by calling the function like this. (Edit1.text holds the WoW-pid)
Code:
procedure TForm2.btnTestClick(Sender: TObject);
var
Address: DWord;
Pidhandle: Integer;
BytesRead: DWord;
buf: array of AnsiChar;
begin
//CHARACTER NAME START ADDRESS
Address := Integer(GetModuleBaseAddress(StrToInt(Edit1.Text), '')) + Integer($9BE820);
end;
Is this correct so far? Or am i doing something wrong
If correct, how do I actually read the value from the running process in Delphi?
Any help would be greatly appreciated!
thanks,
Joost