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 


Cheat Engine Base Module Address

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Winter_Snake
How do I cheat?
Reputation: 0

Joined: 22 Jul 2019
Posts: 8

PostPosted: Fri Jul 26, 2019 4:55 pm    Post subject: Cheat Engine Base Module Address Reply with quote

I've noticed two inconsistencies between my C++ doe and cheat engine.

To start with, I am working on OpenRA - Red Alert. At this moment, cycling through the modules either doesn't return the right address or doesn't find the module at all.

1) Not returning the right base module address --
Using Cheat Engine, getAddress('RedAlert.exe') show's the address at [0x00DD0000] However, my code returns [0x0083000].

Code:

uintptr_t ProcMem::GetModuleStartAddress(const char* module_name)
{
   uintptr_t address = 0;

   HANDLE snapshot_handle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, this->processID);

   if (snapshot_handle != INVALID_HANDLE_VALUE)
   {
      MODULEENTRY32 module_entry;
      module_entry.dwSize = sizeof(module_entry);

      if (Module32First(snapshot_handle, &module_entry))
      {
         do
         {
            if (!_stricmp(module_entry.szModule, module_name))
            {
               address = (uintptr_t)module_entry.modBaseAddr;
               break;
            }
         } while (Module32Next(snapshot_handle, &module_entry));
      }
   }
   CloseHandle(snapshot_handle);
   return address;
}

(And here's how I am calling it)
Code:

   uintptr_t raCashMEM = raMEM.GetModuleStartAddress("RedAlert.exe");

   std::cout << (void*)raCashMEM << std::endl;


2) Module doesn't exist at all.
Another base module found in the game is a module "soft_oal.dll", however, std::cout'ing the failed modules that don't match (using the previous code) shows no mention of a soft_oal.dll existing/being found. Therefore the function returns a 0. The dll exists for sure, I can see it in the bin of the game.
Code:
uintptr_t raCashMEM = raMEM.GetModuleStartAddress("soft_oal.dll");


Any help with these two issues would be great.



7xHxCKT - Imgur.png
 Description:
Problem 2
 Filesize:  19.62 KB
 Viewed:  1539 Time(s)

7xHxCKT - Imgur.png



EMVBu5C - Imgur.png
 Description:
Problem 1
 Filesize:  23.63 KB
 Viewed:  1539 Time(s)

EMVBu5C - Imgur.png


Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 149

Joined: 25 Jan 2006
Posts: 7731
Location: 127.0.0.1

PostPosted: Sat Jul 27, 2019 12:09 am    Post subject: Reply with quote

Your app is printing the local address of the variable holding the value due to how you are printing it.

Try this instead:

Code:
printf_s("%08X\r\n", raCashMEM);

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Winter_Snake
How do I cheat?
Reputation: 0

Joined: 22 Jul 2019
Posts: 8

PostPosted: Sat Jul 27, 2019 9:51 am    Post subject: Reply with quote

That still results in the wrong address.
Cheat Engine shows [0x002f0000] where as the print statement returns [0x00390000]

EDIT:
Quickly tested it, both my std::cout and your printf_s resulted in the same address being printed.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 149

Joined: 25 Jan 2006
Posts: 7731
Location: 127.0.0.1

PostPosted: Sat Jul 27, 2019 7:56 pm    Post subject: Reply with quote

Assuming the target is 32bit, you should only need to use: 'TH32CS_SNAPMODULE' with CreateToolhelp32Snapshot.
Next, make sure your application is compiled as 32bit and not 64bit.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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