| View previous topic :: View next topic |
| Author |
Message |
Tomi20 How do I cheat?
Reputation: 0
Joined: 17 Jul 2013 Posts: 6 Location: Poland
|
Posted: Wed Jul 17, 2013 8:59 am Post subject: [C++] Read the BaseAddress of an .dll file. |
|
|
Hello!
I'm trying to write a console application that will display my current position in minecraft. I have three memory addresses like: OpenAL64.dll+2FD00 (the addresses are pointers), and now my question in CE the addresses are displayed and when I write only the "OpenAL64.dll" in the add memory window displays a memory address, but when i Do it in Visual Studio 2012 in C++ there is a too big value or this value equals 0.
This Code displays 0 to the console...
| Code: | hWnd = FindWindow("SunAwtFrame", NULL);
GetWindowThreadProcessId(hWnd, &dwID);
DWORD address = (DWORD)GetModuleHandle("OpenAL64.dll");
printf("%x", address); |
I searched up google over two days and I found nothing..
Please help me
Thanks in advance.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25823 Location: The netherlands
|
Posted: Wed Jul 17, 2013 9:21 am Post subject: |
|
|
CreateToolhelp32Snapshot and Module32First/module32next is one of the easiest methods to find the base address of a module
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Tomi20 How do I cheat?
Reputation: 0
Joined: 17 Jul 2013 Posts: 6 Location: Poland
|
Posted: Wed Jul 17, 2013 10:28 am Post subject: |
|
|
Ok, nice I see an address.. i Think the address isn't valid..
Screen Shot:
http\//db.tt/ErWR31rm
replace \ with :
And my code:
| Code: |
MODULEENTRY32 mModule;
hWnd = FindWindow("SunAwtFrame", NULL);
GetWindowThreadProcessId(hWnd, &dwID);
HANDLE hTool = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwID);
bool isSuccess = Module32First(hTool, &mModule);
printf(" Is success? %d, address : %x, name : %s \n", isSuccess, mModule.modBaseAddr, mModule.szModule);
|
Whan I'm Doing wrong
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Jul 17, 2013 11:00 am Post subject: |
|
|
You must set the dwSize member inside of MODULEENTRY32 before you can call Module32First for it to work properly.
mModule.dwSize = sizeof( MODULEENTRY32 );
bool isSuccess = Module32First(hTool, &mModule);
Along with that you need to loop Module32Next afterward to keep stepping through the snapshot to find the specific module you are looking for.
_________________
- Retired. |
|
| Back to top |
|
 |
Tomi20 How do I cheat?
Reputation: 0
Joined: 17 Jul 2013 Posts: 6 Location: Poland
|
Posted: Wed Jul 17, 2013 11:36 am Post subject: |
|
|
I changed my code, and now i have the address of OpenAL64.dll, but the address is still wrong.. CE has got an other value.
That's my code:
| Code: | MODULEENTRY32 mModule;
hWnd = FindWindow("SunAwtFrame", NULL);
GetWindowThreadProcessId(hWnd, &dwID);
HANDLE hTool = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwID);
mModule.dwSize = sizeof( MODULEENTRY32 );
Module32First(hTool, &mModule);
do{
printf("Address : %x, name : %s \n", mModule.modBaseAddr, mModule.szModule);
}while(Module32Next(hTool, &mModule));
|
In my console application the address of OpenAL64.dll is EDE20000 and in CE "OpenAL64.dll" -> 300905A4D
Do I'm everything wrong?
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25823 Location: The netherlands
|
Posted: Wed Jul 17, 2013 12:09 pm Post subject: |
|
|
Yes
In cheat engine open the memory view window , press ctrl+g and fill in OpenAL64.dl, that will bring you to the address of the module start
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Tomi20 How do I cheat?
Reputation: 0
Joined: 17 Jul 2013 Posts: 6 Location: Poland
|
Posted: Wed Jul 17, 2013 12:37 pm Post subject: |
|
|
Aha, alright!
But why In C++ from the left in hex are three letters skipped?
CE Memory Viewer -> 7FEEDE20000
C++ -> EDE20000
That's why I can't read the memory!
@Edit: How can I get the whole address?
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25823 Location: The netherlands
|
Posted: Wed Jul 17, 2013 1:33 pm Post subject: |
|
|
Multiple reasons
1: %x doesn't do 64-bit values, use %llx
2: you store the address in a DWORD instead of d a QWORD or PTR_UINT
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Tomi20 How do I cheat?
Reputation: 0
Joined: 17 Jul 2013 Posts: 6 Location: Poland
|
Posted: Wed Jul 17, 2013 1:44 pm Post subject: |
|
|
Thanks!! You're a genius!
Topic can be closed.
|
|
| Back to top |
|
 |
|