1
votes

Its reading the first 3 address's right and the last one wrong...Ignore the rubbish code I'm noob I just can't figure out why the 4th address no matter what even if i use the same address as one of the others returns the wrong value...

procedure ReadFirstCard(Address: Integer);
var
Handle,i,a,b,c : Integer;
begin
GetWindowThreadProcessId(FindWindow(nil, PAnsiChar(Client)), @ProcessId);
Handle := OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId);
ReadProcessMemory(Handle, Ptr(Address), @NewValue, Data, CardRead);
CloseHandle(Handle);
end;

procedure ReadFirstCardSuit(Address2: Integer);
var
Handle,i,a,b,c : Integer;
begin
GetWindowThreadProcessId(FindWindow(nil, PAnsiChar(Client)), @ProcessId);
Handle := OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId);
ReadProcessMemory(Handle, Ptr(Address2), @NewValue2, Data2, CardRead2);
CloseHandle(Handle);
end;

procedure ReadSecondCard(Address3: Integer);
var
Handle,i,a,b,c : Integer;
begin
GetWindowThreadProcessId(FindWindow(nil, PAnsiChar(Client)), @ProcessId);
Handle := OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId);
ReadProcessMemory(Handle, Ptr(Address3), @NewValue3, Data3, CardRead3);
CloseHandle(Handle);
end;

procedure ReadSecondCardSuit(Address4: Integer);
var
Handle,i,a,b,c : Integer;
begin
GetWindowThreadProcessId(FindWindow(nil, PAnsiChar(Client)), @ProcessId);
Handle := OpenProcess(PROCESS_ALL_ACCESS, False, ProcessId);
ReadProcessMemory(Handle, Ptr(Address4), @NewValue4, Data4, CardRead4);
CloseHandle(Handle);
end;
1

1 Answers

4
votes

Since the only thing different about the fourth function is that it uses Data4 for the size instead of Data1 through Data3, it seems that Data4 must not have the correct value for the number of bytes to copy from the target process. Make sure NewValue4 is big enough to receive the entire result, too.

You're not checking the return values of any of those API functions, so if they're failing, you'd never know it. Make sure that OpenProcess returns a valid handle, and make sure ReadProcessMemory returns non-zero. If they don't, call GetLastError to find out why.