Trouble getting ModuleBaseAddress menu

Shout-Out

User Tag List

Results 1 to 6 of 6
  1. #1
    Amrok's Avatar Banned
    Reputation
    4
    Join Date
    Apr 2009
    Posts
    59
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trouble getting ModuleBaseAddress

    Hi, i'd like to get the ModuleBaseAddress of WoW MainModule in C++

    i'm using this function:
    Code:
    BaseAddr = GetModuleBaseAddress(PROC_ID, "Wow.exe");
    cout << "WoW MainModule located at: " << BaseAddr << endl;
    
    DWORD CMemory::GetModuleBaseAddress(DWORD iProcId, char* DLLName)
    {
      HANDLE hSnap;
      MODULEENTRY32 xModule;
      hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, iProcId);
      xModule.dwSize = sizeof(xModule);
      if (Module32First(hSnap, &xModule))
      {
        while (Module32Next(hSnap, &xModule))
        {
            if (strcmp((char*)xModule.szModule, DLLName) == 0)
            {
    			CloseHandle(hSnap);
    			return (DWORD)xModule.modBaseAddr;
            }
        }
      }
      CloseHandle(hSnap);
      return 0;
    }
    I'm opening the process with debug rights:
    Code:
    PROC_HANDLE = OpenProcess(PROCESS_ALL_ACCESS, false, PROC_ID);
    But the function above always returns 0... Probably i've got some info lack... Please help!
    Last edited by Amrok; 07-16-2011 at 06:49 PM.

    Trouble getting ModuleBaseAddress
  2. #2
    _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)
    Why are you casting MODULEENTRY32::szModule to char*? This makes me think you are using the unicode version of the library. Obviously strcmp will fail then.
    Might I suggest using _tcsicmp and wrapping your string literals with the TEXT macro instead.
    Edit:
    You are also never checking the first module.

  3. #3
    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 _Mike View Post
    Why are you casting MODULEENTRY32::szModule to char*? This makes me think you are using the unicode version of the library. Obviously strcmp will fail then.
    Might I suggest using _tcsicmp and wrapping your string literals with the TEXT macro instead.
    Edit:
    You are also never checking the first module.
    You're better off just using Unicode everywhere imo if your app is Windows-only. Microsoft have started releasing all their new APIs in wide variants only because the ANSI APIs are all more or less deprecated.

    EDIT:

    PROCESS_ALL_ACCESS requires the SeDebugPrivilege I think... Can't remember. Much easier to just specify the actual flags that you need (and also more 'correct').

    Also, you're not checking the handle returned by CreateToolhelp32Snapshot for validity.
    Last edited by Cypher; 07-17-2011 at 06:17 AM.

  4. #4
    _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 Cypher View Post
    PROCESS_ALL_ACCESS requires the SeDebugPrivilege I think... Can't remember. Much easier to just specify the actual flags that you need (and also more 'correct').
    As far as I know SeDebug is only needed when the target process is owned by another account which has a higher "security level" (I don't know the proper word for it) than yours, or if it has set a more restrictive ACL than windows supplies by default. Which wow used to do btw, but doesn't anymore. Maybe that's what you were referring to?
    I always assume potential malware when I see a wow hack or bot requiring to be run as administrator. There's no need for them to have access to my entire system just for wow.
    Maybe for a general purpose application, like an in-game overlay or something, SeDebug might be needed. But even then, in most cases not.
    Agreed on specific flags though. I seem to remember someone, probably you, saying that the value and/or size of PROCESS_ALL_ACCESS had changed between windows versions.
    Also, you're not checking the handle returned by CreateToolhelp32Snapshot for validity.
    Currently that's not an issue because Module32First checks if the handle is valid before attempting to use it. But I doubt the OP knew that, so we'll blame it on sloppy coding
    Also this might change in future API versions, so yes; Always check return values.

  5. #5
    Amrok's Avatar Banned
    Reputation
    4
    Join Date
    Apr 2009
    Posts
    59
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fixed it.

    Can be closed.

  6. #6
    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 _Mike View Post
    As far as I know SeDebug is only needed when the target process is owned by another account which has a higher "security level" (I don't know the proper word for it) than yours, or if it has set a more restrictive ACL than windows supplies by default. Which wow used to do btw, but doesn't anymore. Maybe that's what you were referring to?
    I always assume potential malware when I see a wow hack or bot requiring to be run as administrator. There's no need for them to have access to my entire system just for wow.
    Maybe for a general purpose application, like an in-game overlay or something, SeDebug might be needed. But even then, in most cases not.
    Agreed on specific flags though. I seem to remember someone, probably you, saying that the value and/or size of PROCESS_ALL_ACCESS had changed between windows versions.

    Currently that's not an issue because Module32First checks if the handle is valid before attempting to use it. But I doubt the OP knew that, so we'll blame it on sloppy coding
    Also this might change in future API versions, so yes; Always check return values.
    Right right, I keep forgetting WoW doesn't modify its ACLs anymore. That was indeed what I was referring to.

    Also yeah, it was probably me who said that the flag had changed sizes. It caused a lot of problems for the copy-pasters who updated their SDK but weren't setting the WINVER macros accordingly. So their program was compiled only for Vista+ (with the new flag).

    P.S. I knew it didn't really matter because Module32First checks regardless, but I still consider it sloppy.

Similar Threads

  1. Having Trouble Getting Model Edits to Appear ingame
    By Cradin in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 04-02-2009, 08:40 PM
  2. [HELP] Having trouble getting poeple to connect! (Can Tip)
    By Hostilex12345 in forum World of Warcraft Emulator Servers
    Replies: 12
    Last Post: 03-26-2008, 04:46 AM
  3. Trouble getting MAPS? Download them here!
    By jordana in forum WoW EMU Guides & Tutorials
    Replies: 4
    Last Post: 02-13-2008, 09:27 PM
  4. Trouble getting MAPS? Download them here!
    By jordana in forum WoW EMU Guides & Tutorials
    Replies: 0
    Last Post: 02-13-2008, 12:35 PM
All times are GMT -5. The time now is 06:46 AM. 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