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#] Wrong address returned by ProcessModule.BaseAddress

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
TomsonTom
How do I cheat?
Reputation: 0

Joined: 28 Sep 2010
Posts: 2
Location: JBC, Czech Republic

PostPosted: Tue Sep 28, 2010 1:09 pm    Post subject: [C#] Wrong address returned by ProcessModule.BaseAddress Reply with quote

Hello,

I'm trying to read and write process memory, but I've got 64bit Windows 7. I need to know the base address to edit the pointers, however in Windows 7 base addresses always changes (in most applications) and so I cannot rely on 0x400000.

The thing is: How to get the base address of a process?

(For example I want to get a final address of LFS.exe+0x054D32C, but I need to know the base address of LFS.exe process.)

I used this:
Code:
ProcessModule myProcessModule;
ProcessModuleCollection myProcessModuleCollection = hProcess.Modules;
myProcessModule = hProcess.MainModule;

int text_addr1 = 0x054D32C;
int text_addr2 = (int)myProcessModule.BaseAddress;
IntPtr text_addr = (IntPtr)(text_addr1 + text_addr2);

Where hProcess is the game process.

It should work, however myProcessModule.BaseAddress always returns 0x400000, although it isn't correct! The Cheat Engine somehow can get the real base address, because it works. But C# always returns the same base address, which (unfortunately) always changes on Windows 7.

Can anyone help me?

Thanks!
Back to top
View user's profile Send private message
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 893

PostPosted: Tue Sep 28, 2010 3:53 pm    Post subject: Reply with quote

I'm not a C# coder, but I think you need to show us how you're setting up hProcess. Try looking at the other members in myProcessModule - i.e., FileName - you might not even be looking at the correct module.

Cheers,
adude
Back to top
View user's profile Send private message
TomsonTom
How do I cheat?
Reputation: 0

Joined: 28 Sep 2010
Posts: 2
Location: JBC, Czech Republic

PostPosted: Tue Sep 28, 2010 4:36 pm    Post subject: Reply with quote

The fact is that the address it returns is correct. My bad. Smile

You can lock this thread.
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: Tue Sep 28, 2010 7:48 pm    Post subject: Reply with quote

Locked per-request.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    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