Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


c++ get part of Base Address

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
neowrs
Newbie cheater
Reputation: 0

Joined: 07 Oct 2015
Posts: 15

PostPosted: Wed Oct 07, 2015 5:15 pm    Post subject: c++ get part of Base Address Reply with quote

always Base Address = client.exe+address
so it's impossible to get the address without client.exe
example client.exe+EAF4 = 0126587 and i need only EAF4
Back to top
View user's profile Send private message
aasi888
How do I cheat?
Reputation: 0

Joined: 29 Jul 2009
Posts: 6

PostPosted: Thu Oct 08, 2015 10:46 am    Post subject: Reply with quote

I'm stuck in same spot.


Example:
"Wow.exe"+00B91590


How I get the hex value of "Wow.exe" in c++?

What is the "Wow.exe" even called? Kinda hard to search when I don't know what it's called Smile
Reading from dynamic memory address is working fine though.

PS Not using DLL injects.
Back to top
View user's profile Send private message
STN
I post too much
Reputation: 43

Joined: 09 Nov 2005
Posts: 2676

PostPosted: Thu Oct 08, 2015 11:28 am    Post subject: Reply with quote

Read this

http://forum.cheatengine.org/viewtopic.php?t=584674

This way you will get "hex" value of wow.exe or client.exe or whatever you prefer.

_________________
Cheat Requests/Tables- Fearless Cheat Engine
https://fearlessrevolution.com
Back to top
View user's profile Send private message
neowrs
Newbie cheater
Reputation: 0

Joined: 07 Oct 2015
Posts: 15

PostPosted: Thu Oct 15, 2015 4:53 pm    Post subject: Reply with quote

aasi888 wrote:
I'm stuck in same spot.


Example:
"Wow.exe"+00B91590


How I get the hex value of "Wow.exe" in c++?

What is the "Wow.exe" even called? Kinda hard to search when I don't know what it's called Smile
Reading from dynamic memory address is working fine though.

PS Not using DLL injects.


try
DWORD ady = 0xB91590;
HMODULE wow= GetModuleHandle(TEXT("Wow.exe"));
ady = (DWORD)wow+ady;

STN wrote:
Read this



This way you will get "hex" value of wow.exe or client.exe or whatever you prefer.

i don't need to the hex i need to remove the hex of the address
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Oct 17, 2015 7:42 pm    Post subject: Reply with quote

GetModuleHandle does not work like that unless you are injected into the process.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
aasi888
How do I cheat?
Reputation: 0

Joined: 29 Jul 2009
Posts: 6

PostPosted: Sun Oct 18, 2015 9:04 am    Post subject: Reply with quote

I tried searching for several pages and found a function that seems to get the modulebase address. However I'm not able to calculate correct starting address with module base + static adress. Is the problem in the module base function or am I calculating it wrong?

The Start_address (see picture) should be "0EAEEE10", but my code gets it wrong: "1d91590".

"Wow.exe"+00B91590 -> 0EAEEE10
"ModuleBase"+static_BaseAddress -> Start_address
See picture for clarification.

Full prints that my code gives:
Code:
exe_name:         Wow.exe
Process_ID:       5248
ModuleBase:       1200000
Start_address:    1d91590


Here is the full code. It will print all the relevant things to your screen as long as you have correctly entered the SETTINGS.

Code:

#include <windows.h>
#include <TlHelp32.h>
#include <iostream>
   
//SETTINGS -----------------
   LPCSTR window_name = "World of Warcraft"; //<- MAKE SURE it matches the window name
   LPSTR exe_name = "Wow.exe";
   DWORD Process_ID=0;      //User defined pid. Leave as "0" to automaticly find it.
//END OF SETTINGS -----------------

DWORD GetModuleBase(LPSTR lpModuleName, DWORD procId)
{
   MODULEENTRY32 lpModuleEntry = {0};
   HANDLE hSnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, procId );
   if(!hSnapShot)
     return NULL;
   lpModuleEntry.dwSize = sizeof(lpModuleEntry);
   BOOL bModule = Module32First( hSnapShot, &lpModuleEntry );
   while(bModule)
   {
     if(!strcmp( lpModuleEntry.szModule, lpModuleName ) )
     {
       CloseHandle( hSnapShot );
       return (DWORD)lpModuleEntry.modBaseAddr;
     }
     bModule = Module32Next( hSnapShot, &lpModuleEntry );
   }
   CloseHandle( hSnapShot );
   return NULL;
}

int main()
{
   system("cls");
   //Get process id
   if (Process_ID==0)      //If user left "Process_ID" as "0" then we need to find it
   {
   HWND hGameWindow = FindWindow(NULL,window_name);
   GetWindowThreadProcessId( hGameWindow, &Process_ID );
   }
   //Search module base
   DWORD ModuleBase = GetModuleBase(exe_name,Process_ID);      //exe name, Process ID
   DWORD static_BaseAddress = {0x00B91590};
   DWORD Start_address = ModuleBase + static_BaseAddress;

   //Prints for debugging
   std::cout << "exe_name:         " << std::hex << exe_name << std::endl;
   std::cout << "Process_ID:       " << std::dec << Process_ID << std::endl;
   std::cout << "ModuleBase:       " <<std::hex << ModuleBase << std::endl;
   std::cout << "Start_address:    " <<std::hex << Start_address << std::endl;
   std::cout << std::endl;
   system("PAUSE");
   return(0);
}




In short: Is te problem in my calculation or in the function? How do I fix this?



1.png
 Description:
 Filesize:  15.92 KB
 Viewed:  15412 Time(s)

1.png


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25796
Location: The netherlands

PostPosted: Sun Oct 18, 2015 9:38 am    Post subject: Reply with quote

the pointerscreen misses one calculation displayed due to screen size limitation, but this is what it would show (in reverse)

assuming wow.exe is at 00400000
Code:

[00400000+00b91590]=[00f91590]  -  [00f91590]->0e91d2d0
[0e91d2d0+710]=[0E91D9E0]  - [0E91D9E0] ->1d764c50
[1d764c50+1c]=[1d764c6c] - [1d764c6c] -> 2c04c934
[2c04c934+a4]=[2C04C9D8]  [2C04C9D8]-> 20560db8
[20560db8+1a8]=[20560F60]  [20560F60]->215fe07c
215fe07c+1f8=215FE274

_________________
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
View user's profile Send private message MSN Messenger
aasi888
How do I cheat?
Reputation: 0

Joined: 29 Jul 2009
Posts: 6

PostPosted: Sun Oct 25, 2015 2:47 pm    Post subject: Reply with quote

Thanks alot!
I didn't realize that I had to use readprocessmemory after adding the first two:
"ModuleBase"+static_BaseAddress

Now It's working. Thanks!
Back to top
View user's profile Send private message
hey
How do I cheat?
Reputation: 0

Joined: 04 Nov 2015
Posts: 4

PostPosted: Wed Nov 04, 2015 12:08 pm    Post subject: Reply with quote

With this code I get for ModuleBase 0. Code find PID and displays it correctly, but ModuleBase is 0.
Back to top
View user's profile Send private message
aasi888
How do I cheat?
Reputation: 0

Joined: 29 Jul 2009
Posts: 6

PostPosted: Sat Nov 07, 2015 10:33 am    Post subject: Reply with quote

hey wrote:
With this code I get for ModuleBase 0. Code find PID and displays it correctly, but ModuleBase is 0.


Its 32bit program? Cause mine is 32bit.
Did you change the window name and exe name to match? I think they are case sensitive:
Code:
LPCSTR window_name = "Untitled - Notepad"; //<- MAKE SURE it matches the window name
LPSTR exe_name = "notepad.exe";


PS I haven't tested this with notepad myself, but instead with another program.
Back to top
View user's profile Send private message
hey
How do I cheat?
Reputation: 0

Joined: 04 Nov 2015
Posts: 4

PostPosted: Wed Nov 11, 2015 2:39 am    Post subject: Reply with quote

I am using 64 bit windows, can that be a problem?

EDIT:
Can you update your code with Dark Byte's suggestion?



problem.png
 Description:
 Filesize:  54.97 KB
 Viewed:  14776 Time(s)

problem.png


Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites