how to bring up the hp in delphi?

06/11/2012 02:17 marcelo380#1
How can we make delphi read through the hp of char pointers
?

:mad::confused:
06/11/2012 02:53 Sᴡoosh#2
Code:
function THostchar.HP: TBounds;
var
  HP, HPM: Cardinal;
  eax, written, Base: cardinal;
begin

  ReadProcessMemory(Self.Handle, ptr(self.Offsets.Addresses_base_Address), @eax, 4, written);
  ReadProcessMemory(Self.Handle, ptr(eax + $1C), @eax, 4, written);
  ReadProcessMemory(Self.Handle, ptr(eax + self.Offsets.Structural_Character), @Base, 4, written);
  ReadProcessMemory(Self.Handle, ptr(Base + self.Offsets.Character_HP), @HP, 4, written);
  ReadProcessMemory(Self.Handle, ptr(Base + self.Offsets.Character_Max_HP), @HPM, 4, written);

  result.Current := HP;
  result.Max := HPM;
  Try
  result.Percent := Round((HP / HPM) * 100);
  except
  result.Percent := 0;
  End;

end;
06/11/2012 03:24 marcelo380#3
what's wrong in my code? :confused:
thank you!



Code:
var
  H, TI, PI, W, rw: DWORD;
  eax, written, Base: cardinal;
  HP, HPM: DWORD;
begin
      H := FindWindow(nil, 'Element Client');
  if (H <= 0) then
    exit;
  try
  ReadProcessMemory(Self.Handle, ptr($00B3B24C), @eax, 4, written);   //BASE
 ReadProcessMemory(Self.Handle, ptr(eax + $1C), @eax, 4, written);
  ReadProcessMemory(Self.Handle, ptr(eax + $34), @Base, 4, written);
  ReadProcessMemory(Self.Handle, ptr(Base + $494), @HP, 4, written);   //pointer HP
  ReadProcessMemory(Self.Handle, ptr(Base + $4DC), @HPM, 4, written);  //Pointer Hp Max

  label1.Caption := IntToStr(HP);
  label2.Caption := IntToStr(HPM);


  finally

  end;
06/11/2012 11:13 Shareen#4
Try to finish the attempted usage of H (H := FindWindow(nil, 'Element Client');), instead of using Self.Handle as process handle.

You know, something like...
H := FindWindow(nil, 'Element Client');
GetWindowThreadProcessId(H, @ProcessId);
GameHandle := OpenProcess(PROCESS_VM_READ, False, ProcessId);

where ProcessId is of type Integer;

Then use GameHandle instead of Self.Handle.

When using OpenProcess, check below link for access rights other than PROCESS_VM_READ:
[Only registered and activated users can see links. Click Here To Register...]
06/11/2012 13:34 marcelo380#5
It was more or less like this:
Quote:
var
H, TI, PI, W, rw, GameHandle: DWORD;
eax, written, Base: cardinal;
HP, HPM: DWORD;
ProcessId: Integer;

begin
H := FindWindow(nil, 'Element Client');
GetWindowThreadProcessId(H, @ProcessId);
GameHandle := OpenProcess(PROCESS_VM_READ, False, ProcessId);
if (H <= 0) then
exit;
try
ReadProcessMemory(GameHandle, ptr($00B3B24C), @eax, 4, written); //BASE
ReadProcessMemory(GameHandle, ptr(eax + $1C), @eax, 4, written);
ReadProcessMemory(GameHandle, ptr(eax + $34), @Base, 4, written);
ReadProcessMemory(GameHandle, ptr(Base + $494), @HP, 4, written); //pointer HP
ReadProcessMemory(GameHandle, ptr(Base + $4DC), @HPM, 4, written); //Pointer Hp Max

label1.Caption := IntToStr(HP);
label2.Caption := IntToStr(HPM);


finally

end;
is something wrong?
Sorry but I am beginner hacks! :(
06/11/2012 15:41 Shareen#6
Yes, something is wrong.
I'm sorry, but in the effort to reply quickly I made a mistake in the post above.
By no means did I plan to place a smilie face after "(nil, 'Element Client')". It was in fact intended to look like this:
Code:
(H := FindWindow(nil, 'Element Client');
I humbly apologize and I want to ensure you, that no winking was in fact implied at any point.

As for your code, it works.
Problem is either UAC or wrong window name. Make sure you run this thing of yours as administrator and recheck that game window doesn't happen to be named, I don't know, "Perfect World International" or something along those lines.
06/11/2012 17:34 marcelo380#7
It worked!
Thanks to everyone who helped me