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

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
Base address
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Base address

  1. #1

    Base address

    How to find out base address (in C++)?

    do you need it for addresses to be stable?

    THNXOR.

  2. #2
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    I would advise you to find out what the base address is, before trying to understand how to find it. My best understanding at the minute is this:

    When you run a program, it is allocated memory by the operating system. The operating system looks at the size of the executable, and allocates an amount of memory for the exe itself, plus whatever DLL or other files it might use. It then rounds the allocated memory to the nearest page (4096 bytes?) or somewhere around that region. The process itself is initialised as the program is fully loaded into memory, and the RAM for the purpose of storing variables is then allocated. The base address is the offset between the start of this area of variable storage memory, and the start of the memory the process is allocated. The processes memory can be found using the window handle. So, to find the base address dynamically... Well, you'd need a function which will do this. Depending on which libraries you wish to use, this could be incredibly simple. If you were to use .NET, for instance, you could create a System.Diagnostics.Process object, link it to the Tibia process, and it has a method Process.MainModule.BaseAddress (the main module being the main thread, I believe). I will at this point advise you that if you use C++ with .NET, you will be mocked.

    Perhaps this thread will be of interest to you. Alternatively this stack overflow question has some good answers.

  3. #3
    Thanks, I tried psapi functions before,
    and Im getting error
    [Error] cast from 'HMODULE {aka HINSTANCE__*}' to 'DWORD {aka long unsigned int}' loses precision [-fpermissive]

    before using function.
    what is problem?

  4. #4
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    the last 2 posts of this thread have possible implementations: http://tpforums.org/forum/threads/55...mory-addresses

    at my post specifically, I successfully compiled with VS2010 C++

  5. #5
    Okay, is it possible to find baseaddress with Cheatengine? pros cons?
    (Using orwell's DevC++)

    Edit:
    nvm, got it to work with:
    Code:
    int get_baseaddress(HANDLE pHandle)
    {
    	int i_start = 0x00100000;
    	MEMORY_BASIC_INFORMATION lpBuffer;
    	DWORD dwLength = sizeof(MEMORY_BASIC_INFORMATION);
    
    	do
    	{
    	VirtualQueryEx(pHandle, (void*)i_start, &lpBuffer, dwLength);
    	i_start += 0x10000;
    	} 
    	while (lpBuffer.AllocationProtect != 0x80 && i_start < 0x01000000);
    		if (lpBuffer.AllocationProtect == 0x80)
    		{
    		return (intptr_t)lpBuffer.AllocationBase;
    		}
    	return 0; 
    }
    (They said to use intptr_t instead of int at stackoverflow).

    Bye.
    Last edited by Xleniz; 06-27-2013 at 04:48 PM.

  6. #6
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    Quote Originally Posted by Xleniz View Post
    Okay, is it possible to find baseaddress with Cheatengine? pros cons?
    (Using orwell's DevC++)

    Edit:
    nvm, got it to work with:
    Code:
    int get_baseaddress(HANDLE pHandle)
    {
    	int i_start = 0x00100000;
    	MEMORY_BASIC_INFORMATION lpBuffer;
    	DWORD dwLength = sizeof(MEMORY_BASIC_INFORMATION);
    
    	do
    	{
    	VirtualQueryEx(pHandle, (void*)i_start, &lpBuffer, dwLength);
    	i_start += 0x10000;
    	} 
    	while (lpBuffer.AllocationProtect != 0x80 && i_start < 0x01000000);
    		if (lpBuffer.AllocationProtect == 0x80)
    		{
    		return (intptr_t)lpBuffer.AllocationBase;
    		}
    	return 0; 
    }
    (They said to use intptr_t instead of int at stackoverflow).

    Bye.
    Well done for working this one out, sorry I didn't reply sooner I fell asleep (I got really bad hay fever so yeah call me lazy or whatever, I feel like shit constantly atm).

    The base address isn't something which you can find with CheatEngine, unless you intend to run CheatEngine as part of your bot and enter it manually every time. It's not particularly good. Thanks to ASLR, the base address changes dynamically each time you restart the Tibia client. However, it does not change (I believe) if you have two clients running (e.g if first client is 0x1234, your second client will also be 0x1234, but the handle will change).

  7. #7
    If I have XPOS address from cheat engine, and add to base address, nothing will happen, cus address changes. How to find real XPOS address?
    Thanks for reply and information:[

  8. #8
    Senior Member
    Join Date
    Jan 2008
    Location
    Cambridge, England
    Posts
    725
    Quote Originally Posted by Xleniz View Post
    If I have XPOS address from cheat engine, and add to base address, nothing will happen, cus address changes. How to find real XPOS address?
    Thanks for reply and information:[
    The reason is probably because your address is wrong (I think).

    The address I know of is 0x553038. Try reading 0x3BE1E0 also if it doesn't work, it's the address of your exp, and I'm more certain it is correct!

    Did you watch one of the videos on how to find addresses in cheat engine? If not, they can be found in the Tutorials section of the forum. There are 3 videos there, they could help you a lot
    Last edited by XtrmJash; 06-27-2013 at 09:08 PM.

  9. #9
    Quote Originally Posted by XtrmJash View Post
    The reason is probably because your address is wrong (I think).

    The address I know of is 0x553038. Try reading 0x3BE1E0 also if it doesn't work, it's the address of your exp, and I'm more certain it is correct!

    Did you watch one of the videos on how to find addresses in cheat engine? If not, they can be found in the Tutorials section of the forum. There are 3 videos there, they could help you a lot
    On exp address it says 0.
    Base address 0x23fc40.

    this sounds correct?

    maybe its the
    dwBase = (intptr_t)hModules[i];
    that gives problem. intptr_t = same as DWORD?

    edit: tried DWORD64, but if I set DWORD64 on all variables, it gives error.........
    Last edited by Xleniz; 06-27-2013 at 10:01 PM.

  10. #10
    Hurray, I googled that EnumProcessModules wont read 32bit processes on 64bit system,
    so I did EnumProcessModulesEx

    Code:
    DWORD64 GetModuleBase(HANDLE hProc, string &sModuleName) 
    { 
       HMODULE *hModules; 
       char szBuf[50]; 
       DWORD cModules; 
       DWORD64 dwBase = -1; 
       //------ 
    
       EnumProcessModulesEx(hProc, hModules, 0, &cModules, LIST_MODULES_ALL); 
       hModules = new HMODULE[cModules/sizeof(HMODULE)]; 
    
       if(EnumProcessModules(hProc, hModules, cModules/sizeof(HMODULE), &cModules)) { 
          for(int i = 0; i < cModules/sizeof(HMODULE); i++) { 
             if(GetModuleBaseName(hProc, hModules[i], szBuf, sizeof(szBuf))) { 
                if(sModuleName.compare(szBuf) == 0) { 
                   dwBase = (DWORD64)hModules[i]; 
                   break; 
                } 
             } 
          } 
       } 
    
       delete[] hModules; 
    
       return dwBase; 
    }
    Returns 750 exp.
    Yaay.

Posting Permissions

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