Loading Offsets out of a string

06/27/2010 11:28 xManuelax#1
Hi

I have a short question, I hope you guys have an answer for me

I have this sourcecode (delphi) :

Code:
Function GetMaxHP : Integer;
var
WndHandle, Pid, Pidhandle : integer;
Written: Cardinal;
begin
  WndHandle := FindWindow(nil,Pchar(Wintitle));
GetWindowThreadProcessId(WndHandle,@Pid);
Pidhandle := OpenProcess(PROCESS_ALL_ACCESS,False,Pid);
ReadProcessMemory(Pidhandle, ptr(BaseAddr), @MaxHPPointer, Data, written);
MaxHPPointer := MaxHPPointer +$032;
ReadProcessMemory(Pidhandle, ptr(MaxHPPointer), @MaxHPPointer2, Data, written);
MaxHPPointer2 := MaxHPPointer2 + [B]maxhpoffset[/B];
ReadProcessMemory(Pidhandle, ptr(MaxHPPointer2), @MaxHP, Data, written);
closehandle(Pidhandle);
Result := MaxHP;
end;
is there any way to load the maxhpoffset out of s string? Or do I have to make it static , like this :

Code:
Function GetMaxHP : Integer;
var
WndHandle, Pid, Pidhandle : integer;
Written: Cardinal;
begin
  WndHandle := FindWindow(nil,Pchar(Wintitle));
GetWindowThreadProcessId(WndHandle,@Pid);
Pidhandle := OpenProcess(PROCESS_ALL_ACCESS,False,Pid);
ReadProcessMemory(Pidhandle, ptr(BaseAddr), @MaxHPPointer, Data, written);
MaxHPPointer := MaxHPPointer +$032;
ReadProcessMemory(Pidhandle, ptr(MaxHPPointer), @MaxHPPointer2, Data, written);
MaxHPPointer2 := MaxHPPointer2 + [B]$33C[/B];
ReadProcessMemory(Pidhandle, ptr(MaxHPPointer2), @MaxHP, Data, written);
closehandle(Pidhandle);
Result := MaxHP;
end;

I tried

MaxHPPointer2 := MaxHPPointer2 + strtoint(maxhpoffset);

maxhpoffset was a string , containing $33C, but strtoint converted it to a decimal address without the ''$'' at the beginning of the offset, which I need to be able to add the offsets.

Any Ideas how I can load maxhpoffset out of a string?
06/27/2010 12:10 Chaosduckman#2
Sry, I canīt Delphi but at C++ is a function for it.
It calls replace (). And will pass with the dot operator. (dot operator = Punkt Operator?!^^) (String.replace ())
06/27/2010 12:22 xManuelax#3
Hm, thank you but I need a delphi way of dooing it :(
06/27/2010 12:25 Chaosduckman#4
[Only registered and activated users can see links. Click Here To Register...] :D