Finding the BaseAddress when ASLR is enabled menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    ptr51's Avatar Private
    Reputation
    1
    Join Date
    Dec 2010
    Posts
    2
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Finding the BaseAddress when ASLR is enabled

    Ok so first a sanity check that i got all this right.

    It works like this: (correct me if im wrong, trying to make sure i got this right)

    1. The offsets found by people in http://www.mmowned.com/forums/world-...mp-thread.html
    labeld "not rebased" means that they are offsets grabbed from IDA and has a 0x400000 offset added. So you need to subtract 0x4000000 to rebase it to 0x0 for it to be usable.

    2. On older versions of windows, ASLR is not used and you just add 0x1000 to a base 0x0 offset in order to skip the PE header and it should fly.

    3. On windows versions where ASLR is used, you need to get this dynamic offset somehow and rebase the addresses with that.

    And now the question:
    How do you get the dynamic ASLR offset using c++/win32? i cant for the life of me find it anywhere on this forum.

    Using .NET there seems to be just to use the ProcessModule.BaseAddress function, but what would be the equalent Win32 api way of doing it?

    Some ppl says GetModuleHandle could get you this value if you load the module into your address space, i cant find a sample but i figure its ment to be like this:

    LoadLibrary("D:\\games\\World of Warcraft_\\Wow.exe");
    HMODULE baseAddress = GetModuleHandle("D:\\games\\World of Warcraft_\\Wow.exe");

    While that works the returned handle of GetModuleHandle seems no good. It does return and works allright, but if i compare it to the value i get when i run a C# ProcessModule.BaseAddress app, its not the same.

    Finding the BaseAddress when ASLR is enabled
  2. #2
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're injected:
    GetModuleHandle(NULL);

    If you're external:
    CreateToolHelp32Snapshot and Module32First/Module32Next

    P.S. The reason the call to GetModuleHandle is broken is probably because you're calling LoadLibrary on WoW... Why would you do that??

  3. #3
    Azzie2k8's Avatar Member
    Reputation
    11
    Join Date
    Apr 2009
    Posts
    190
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it is 0x400000

    That code here is actually from someone else, if someone knows who it was I will credit him ASAP but I am using it and it works. btw not the best style but wth

    Code:
    #include <iostream>
    static class Base
    {
    private: static DWORD GetModuleBaseAddress(DWORD,WCHAR*);
    public: static DWORD Rebase(DWORD);
    }Bas;
    
    DWORD Base::Rebase(DWORD Offset)
    {
    	DWORD ret =(Offset + GetModuleBaseAddress(GetCurrentProcessId(),L"wow.exe"));
    	return ret;
    }
    
    DWORD Base::GetModuleBaseAddress(DWORD iProcId, WCHAR* DLLName)
    {
    	HANDLE hSnap; // Process snapshot handle.
    	MODULEENTRY32 xModule; // Module information structure.
    	hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, iProcId); // Creates a module
    	xModule.dwSize = sizeof(MODULEENTRY32); // Needed for Module32First/Next to work.
    
    	if (Module32First(hSnap, &xModule)) // Gets the first module.
    	{
    		if (lstrcmpi (xModule.szModule, DLLName) == 0) // If this is the module we want...
    		{
    			CloseHandle(hSnap); // Free the handle.
    			return (DWORD)xModule.modBaseAddr; // return the base address.
    		}
    
    		while (Module32Next(hSnap, &xModule)) // Loops through the rest of the modules.
    		{
    			if (lstrcmpi (xModule.szModule, DLLName) == 0) // If this is the module we want...
    			{
    				CloseHandle(hSnap); // Free the handle.
    
    				return (DWORD)xModule.modBaseAddr; // return the base address.
    
    			}
    		}
    	}
    
    	CloseHandle(hSnap); // Free the handle.
    
    	return 0; // If the result of the function is 0, it didn't find the base address.
    }

  4. #4
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Azzie2k8 View Post
    I think it is 0x400000

    That code here is actually from someone else, if someone knows who it was I will credit him ASAP but I am using it and it works. btw not the best style but wth

    Code:
    #include <iostream>
    static class Base
    {
    private: static DWORD GetModuleBaseAddress(DWORD,WCHAR*);
    public: static DWORD Rebase(DWORD);
    }Bas;
    
    DWORD Base::Rebase(DWORD Offset)
    {
    	DWORD ret =(Offset + GetModuleBaseAddress(GetCurrentProcessId(),L"wow.exe"));
    	return ret;
    }
    
    DWORD Base::GetModuleBaseAddress(DWORD iProcId, WCHAR* DLLName)
    {
    	HANDLE hSnap; // Process snapshot handle.
    	MODULEENTRY32 xModule; // Module information structure.
    	hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, iProcId); // Creates a module
    	xModule.dwSize = sizeof(MODULEENTRY32); // Needed for Module32First/Next to work.
    
    	if (Module32First(hSnap, &xModule)) // Gets the first module.
    	{
    		if (lstrcmpi (xModule.szModule, DLLName) == 0) // If this is the module we want...
    		{
    			CloseHandle(hSnap); // Free the handle.
    			return (DWORD)xModule.modBaseAddr; // return the base address.
    		}
    
    		while (Module32Next(hSnap, &xModule)) // Loops through the rest of the modules.
    		{
    			if (lstrcmpi (xModule.szModule, DLLName) == 0) // If this is the module we want...
    			{
    				CloseHandle(hSnap); // Free the handle.
    
    				return (DWORD)xModule.modBaseAddr; // return the base address.
    
    			}
    		}
    	}
    
    	CloseHandle(hSnap); // Free the handle.
    
    	return 0; // If the result of the function is 0, it didn't find the base address.
    }
    I feel like my IQ went down just by reading that.

  5. #5
    Azzie2k8's Avatar Member
    Reputation
    11
    Join Date
    Apr 2009
    Posts
    190
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Cypher View Post
    I feel like my IQ went down just by reading that.
    mind explaining ? I am not using it anymore since I am injected but what is so wrong about it ? I mean okay it was a temporary class implementation but the GetModuleBaseAddress function should still work. Calling this from inside is not that smart ofc but still I feel like GetModuleBaseAddress is okay if you are out of process ?
    Last edited by Azzie2k8; 12-16-2010 at 07:28 AM.

  6. #6
    ptr51's Avatar Private
    Reputation
    1
    Join Date
    Dec 2010
    Posts
    2
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks both of you for your help, this was what i was looking for.

  7. #7
    jjaa's Avatar Contributor
    Reputation
    245
    Join Date
    Dec 2006
    Posts
    562
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In C# injected, you can do:

    Code:
    Process.GetCurrentProcess().MainModule.BaseAddress
    out of process, it should be the same api (without the current process function obviously).

  8. #8
    dook123's Avatar Active Member
    Reputation
    21
    Join Date
    Oct 2008
    Posts
    115
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by jjaa View Post
    In C# injected, you can do:

    Code:
    Process.GetCurrentProcess().MainModule.BaseAddress
    out of process, it should be the same api (without the current process function obviously).
    Excellent . Is there any reading on why this changed? Or anyone with a quick answer?
    ------------------------------
    If not me than who?

  9. #9
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by dook123 View Post
    Excellent . Is there any reading on why this changed? Or anyone with a quick answer?
    Why what changed? Do you mean why you can't use GetCurrentProcess() if you're not injected? Isn't that obvious?

  10. #10
    dook123's Avatar Active Member
    Reputation
    21
    Join Date
    Oct 2008
    Posts
    115
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by _Mike View Post
    Why what changed? Do you mean why you can't use GetCurrentProcess() if you're not injected? Isn't that obvious?
    Sorry, no I should have explained myself. That is obvious. What I dont know is why we suddenly have offsets that are rebased or whatever. Was it static before and now needs the base offset in memory and why did it change if anyone knows?
    ------------------------------
    If not me than who?

  11. #11
    mnbvc's Avatar Banned
    Reputation
    120
    Join Date
    Jul 2009
    Posts
    273
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by dook123 View Post
    Sorry, no I should have explained myself. That is obvious. What I dont know is why we suddenly have offsets that are rebased or whatever. Was it static before and now needs the base offset in memory and why did it change if anyone knows?
    i guess nobody knows...

  12. #12
    dook123's Avatar Active Member
    Reputation
    21
    Join Date
    Oct 2008
    Posts
    115
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by mnbvc View Post
    i guess nobody knows...
    Correct as usual
    ------------------------------
    If not me than who?

  13. #13
    Robske's Avatar Contributor
    Reputation
    305
    Join Date
    May 2007
    Posts
    1,062
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think he's asking why Blizzard opted to use ASLR.

    meh
    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding
    "I cried a little earlier when I had to poop" - Sku

  14. #14
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let's see, ASLR is a simple compile-time switch that costs Blizzard almost nothing, and which makes life harder for most of the clueless bot writers (ie, almost everybody).

    No... no idea why they'd want to do that at all. :confused:
    Don't believe everything you think.

  15. #15
    Robske's Avatar Contributor
    Reputation
    305
    Join Date
    May 2007
    Posts
    1,062
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by amadmonk View Post
    Let's see, ASLR is a simple compile-time switch that costs Blizzard almost nothing, and which makes life harder for most of the clueless bot writers (ie, almost everybody).

    No... no idea why they'd want to do that at all. :confused:
    There's addition and stuff, so scary!
    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding
    "I cried a little earlier when I had to poop" - Sku

Page 1 of 2 12 LastLast

Similar Threads

  1. where is that guide to finding the memory-address which Enables model editing
    By mikesanders in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 07-12-2007, 11:19 PM
  2. Cannot find the files to edit :(
    By Rekro in forum WoW ME Questions and Requests
    Replies: 6
    Last Post: 01-01-2007, 06:07 PM
  3. Finding the .blp-files to Striker's Set
    By Violence in forum World of Warcraft General
    Replies: 0
    Last Post: 10-04-2006, 06:02 PM
  4. Find The Flag Carrier In WSG
    By impulse102 in forum World of Warcraft Exploits
    Replies: 20
    Last Post: 07-29-2006, 12:48 PM
  5. kill the enemy when not in PVP
    By Warto in forum World of Warcraft Exploits
    Replies: 0
    Last Post: 06-11-2006, 07:44 PM
All times are GMT -5. The time now is 02:23 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search