How to find out base address (in C++)?
do you need it for addresses to be stable?
THNXOR.
How to find out base address (in C++)?
do you need it for addresses to be stable?
THNXOR.
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.
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?
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++
Okay, is it possible to find baseaddress with Cheatengine? pros cons?
(Using orwell's DevC++)
Edit:
nvm, got it to work with:
(They said to use intptr_t instead of int at stackoverflow).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; }
Bye.
Last edited by Xleniz; 06-27-2013 at 04:48 PM.
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).
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.
Last edited by Xleniz; 06-27-2013 at 10:01 PM.
Hurray, I googled that EnumProcessModules wont read 32bit processes on 64bit system,
so I did EnumProcessModulesEx
Returns 750 exp.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; }
Yaay.