Mam problem z odczytaniem base address z 64bitowego procesu.
Normalnie stosuję tą funkcję:
function GetModuleBaseAddress2(PID: Cardinal; MName: String): dword_ptr;
var
Snap: THandle;
M32: TModuleEntry32;
begin
Snap := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,PID);
if (Snap = 0) then
Exit;
if Module32First(Snap, M32) then begin
repeat
if MName = M32.szModule then begin
Result := Cardinal(M32.modBaseAddr);
Break;
end;
until not Module32Next(Snap, M32);
end;
end;
Niestety przy procesie 64 bitowym nie jest spełniony warunek " if Module32First(Snap, M32)" i funkcja nic nie zwraca.
Próbowałem także z
function 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); //Getting the enumeration of modules
//EnumProcessModulesEx(
SetLength(Modules, cbNeeded div SizeOf(HMODULE)); //Setting the number of modules
for i := 0 to Length(Modules) - 1 do //Start the bucle
begin
GetModuleBaseName(PHandle, Modules[i], ModuleName, SizeOf(ModuleName)); //Getting the name of module
if AnsiCompareText(MName, ModuleName) = 0 then //If the module name match with the name of module we are looking for...
begin
GetModuleInformation(PHandle, Modules[i], @ModuleInfo, SizeOf(ModuleInfo)); //Get the information of module
Result := ModuleInfo.lpBaseOfDll; //Return the information we want (The image base address)
CloseHandle(PHandle);
Exit;
end;
end;
end;
end;
Także nie działa.
Dokładnie chodzi o grę Shadow of Mordor. Przy innych grach, których używałem do odczytania base address wszystko działa, niestety przy tej poległem i nie mogę rozgryźć problemu