Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Error reading address [Help]
Results 1 to 7 of 7

Thread: Error reading address [Help]

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    21

    Question Error reading address [Help]

    Hello, I made a simple code and I can not get the mana / health of the character.
    I'll post the code:

    Code:
    unit uPrincipal;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, PsApi;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        lbHealth: TLabel;
        lbMana: TLabel;
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      Offset: Integer;
      PH: THandle;
      PID, Thid: Dword;
      TibiaH: THandle;
    implementation
    {$R *.dfm}
    uses uAddress;
    
    {  Função para pegar a base do endereço }
    function GetTibiaBaseAddress(ProcessID: Cardinal): 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)
    		    );
    		  if AnsiCompareText('Tibia.exe', ModuleName) = 0 then
    		    begin
    			  GetModuleInformation(PHandle, Modules[i], @ModuleInfo, SizeOf
    				  (ModuleInfo));
    			  Result := ModuleInfo.lpBaseOfDll;
    			  CloseHandle(PHandle);
    			  Exit;
    		    end;
    	    end;
        end;
    end;
    
    {  Função para ler os endereços de memoria }
    function ReadInteger(Address: Integer): Integer;
    var
      value: Integer;
      ler: Dword;
    begin
      Thid := GetWindowThreadProcessId(TibiaH, @PID);
      PH := OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID);
      ReadProcessMemory(PH, Ptr(Address), @value, 4, ler);
      Result := value;
    end;
    
    { Função para pegar o ProcessID }
    function ProcessID: Integer;
    begin
      TibiaH := FindWindow('TibiaClient', nil);
      Thid := GetWindowThreadProcessId(TibiaH, @PID);
      PH := OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID);
      Result := PID;
    end;
    
    //Função para ler o health do player.
    function PlayerHealth: Integer;
    var
      HP: Integer;
      uXor: Integer;
    begin
      Offset := Integer(GetTibiaBaseAddress(ProcessID));
      HP := ReadInteger((adrMyHP + Offset) - $400000);
      uXor := ReadInteger((adrXOR + Offset) - $400000);
      Result := HP xor uXor;
    end;
    
    //Função para ler a mana do player.
    function PlayerMana: Integer;
    var
      Mana: Integer;
      uXor: Integer;
    begin
      Offset := Integer(GetTibiaBaseAddress(ProcessID));
      Mana := ReadInteger((adrMyMana + Offset) - $400000);
      uXor := ReadInteger((adrXOR + Offset) - $400000);
      Result := Mana xor uXor;
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      lbHealth.Caption := 'Health: ' + IntToStr(PlayerHealth);
      lbMana.Caption := 'Mana: ' + IntToStr(PlayerMana);
    end;
    
    end.
    The addresses used were:

    Code:
    adrXor = $57E1D0;
    adrMyHP = $713000;
    adrMyMana = $57E224;
    Who can help me understand where I am going wrong. Thank you!
    I took also the source of one of NeoBot Cloner to study, to see if I can decipher this error.
    Last edited by kevox2; 07-05-2013 at 11:18 AM. Reason: Add the tag [Code]

  2. #2
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    Hi mate, stick it inside [.CODE] tags, and I'll take a look.

  3. #3
    Junior Member
    Join Date
    Jul 2011
    Posts
    21
    Oh, sorry me.
    Edited !

  4. #4
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    Hi mate, first things first your addresses are wrong (for 10.02), these are correct:

    Code:
    HP: 0x553000
    MP: 0x3BE224
    XOR: 0x3BE1D0
    The best way to judge if an address is in the right "scope" is to look at the address. There is a structure stored in Tibias memory which is always in a similar location, and for the last 30+ versions of Tibia it has always been at 0x3BE~~~, so the MP, XOR, CID, and a few other values will always be in this location. The HP is an exception, not sure why.

    You may wish to read the experience address first, as it does not require XOR, if so, the address is 0x3BE1E0.

    Let me know if these addresses work, if not I will see if I can work it out, though delphi is definitely not my strong point :P

    I'll also say this now, as it could potentially save a lot of hassle. If it's easy for you to do so you should definitely code in English. If it's difficult or you feel it makes programming more of a task than a hobby, then don't, but if you are able to and you don't mind, it will make it a lot easier for saps like me to help you :P
    Last edited by XtrmJash; 07-05-2013 at 12:05 PM.

  5. #5
    Junior Member
    Join Date
    Jul 2011
    Posts
    21
    I think it's something about the functions that are wrong because the returned value is zero, as both health and mana even experience.
    If you can show me the functions to get the memory address of the tibia in C++ for min not much difference since I know a little C++.
    Hugs.

  6. #6
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    Quote Originally Posted by kevox2 View Post
    I think it's something about the functions that are wrong because the returned value is zero, as both health and mana even experience.
    If you can show me the functions to get the memory address of the tibia in C++ for min not much difference since I know a little C++.
    Hugs.
    Take a look here for a simple bit of C++ which will read memory. Note that it does not get the base address automatically, and you must ensure you are obtaining the base address of the main module, not the process, or you will read bad values...

  7. #7
    Junior Member
    Join Date
    Jul 2011
    Posts
    21
    The code delphi managed to solve ... functioned normally here, picked up other addresses
    But I will take a look at the C++, it is always good to learn

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •