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 


Determining Static Range

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
lucidity
Advanced Cheater
Reputation: 0

Joined: 16 Feb 2011
Posts: 91

PostPosted: Thu Jul 19, 2012 10:36 am    Post subject: Determining Static Range Reply with quote

How can you programmatically check to see if an address is static with WINAPI?

I know you can get a module or process' total memory size, but can't find a way to determine what the last static address is, or what the size of statically-allocated memory is for a given process or determine if a specific address is within static memory.

Obviously I could open CE and see if it is green, but I want to understand how to accomplish this. I thought there was a similar post on this forum but couldn't find this information anywhere on the web - kept finding answers on how to tell how much *YOUR* program is using, but not a 3rd party program at runtime Sad

_________________
» Antec Twelve Hundred Full Tower » EVGA E760 CLASSIFIED » EVGA GeForce GTX 580 SuperClocked 1536MB » i7-980XE » CORSAIR DOMINATOR 6GB PC3 12800 DDR3 » OS: Intel X25-M SSD » Game Storage: Raid-0 2 x WD VelociRaptor 10000 RPM » CE Cache Drive: 500GB WD Caviar » Power Supply: OCZ Z Series Gold 1000W
Back to top
View user's profile Send private message
Pingo
Grandmaster Cheater
Reputation: 8

Joined: 12 Jul 2007
Posts: 571

PostPosted: Thu Jul 19, 2012 7:13 pm    Post subject: Reply with quote

This might work
Code:
        bool IsStatic(int Addy, string ProccessName)
        {
            System.Diagnostics.Process[] P = System.Diagnostics.Process.GetProcessesByName(ProccessName);
            if (P.Length == 0) return false;
            foreach (System.Diagnostics.ProcessModule M in P[0].Modules)
            {
                if (Addy >= M.BaseAddress.ToInt32() & Addy <= M.BaseAddress.ToInt32() + M.ModuleMemorySize)
                    return true;
            }
            return false;
        }


Loop the modules, if the address you're checking is between Base and Base+Size, its static

If you wish to return the module name and offset
Code:
        string RetStatic(int Addy, string ProccessName)
        {
            System.Diagnostics.Process[] P = System.Diagnostics.Process.GetProcessesByName(ProccessName);
            if (P.Length == 0) return Addy.ToString("X");
            foreach (System.Diagnostics.ProcessModule M in P[0].Modules)
            {
                if (Addy >= M.BaseAddress.ToInt32() & Addy <= M.BaseAddress.ToInt32() + M.ModuleMemorySize)
                    return M.ModuleName + "+" + (Addy - M.BaseAddress.ToInt32()).ToString("X");
            }
            return Addy.ToString("X");
        }

_________________
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