Autoit  _MemoryModuleGetBaseAddress menu

Shout-Out

User Tag List

Results 1 to 2 of 2
  1. #1
    insomniac420's Avatar Private
    Reputation
    1
    Join Date
    Feb 2014
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Autoit _MemoryModuleGetBaseAddress

    Well guys this is my first post here i hope i get a good answer And i think i need to use WinAPI GetModuleHandle but i have tried several types of methods and keep getting error results.
    So i have no problem in getting a executables PID and then getting its l2.bin base address this works fine, but i cannot seem to get the address of the Module "NWindow.dll"

    Code:
    #RequireAdmin
    SetPrivilege("SeDebugPrivilege", 1)
    
     $PID = WinGetProcess("Lineage*II * ")
     $ModuleName="L2.bin"
     $ModuleBaseAddress=_MemoryModuleGetBaseAddress($PID, $ModuleName)
     ToolTip("ModuleBaseAddress= "&$ModuleBaseAddress) ; This gives a correct base address for a .exe or .bin
     Sleep(2000)
    
     ;Do I need a new PID or Handle? To get the base address of this .dll the PID from the .exe doesn't work
     $ModuleName="NWindow.dll"
     $ModuleBaseAddress=_MemoryModuleGetBaseAddress($PID, $ModuleName)
     ToolTip("ModuleBaseAddress= "&$ModuleBaseAddress);This read 0 always its incorrect
     Sleep(2000)
     ;I think the Module "NWindow.dll" is loaded within itself and not within the "Lineage*II * "  I may be wrong
     Exit
    
    
    
    #region                                                                         MemoryModuleGetBaseAddress
    
    	Func _MemoryModuleGetBaseAddress($iPID, $sModule)
    	If Not ProcessExists($iPID) Then Return SetError(1, 0, 0)
    	If Not IsString($sModule) Then Return SetError(2, 0, 0)
    	Local   $PSAPI = DllOpen("psapi.dll")
    	;Get Process Handle
    
    	Local   $hProcess
    	Local   $PERMISSION = BitOR(0x0002, 0x0400, 0x0008, 0x0010, 0x0020) ; CREATE_THREAD, QUERY_INFORMATION, VM_OPERATION, VM_READ, VM_WRITE
    	If $iPID > 0 Then
    		Local $hProcess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $PERMISSION, "int", 0, "dword", $iPID)
    		If $hProcess[0] Then
    			$hProcess = $hProcess[0]
    		EndIf
    	EndIf
    	;EnumProcessModules
    	Local   $Modules = DllStructCreate("ptr[1024]")
    	Local   $aCall = DllCall($PSAPI, "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($Modules), "dword", DllStructGetSize($Modules), "dword*", 0)
    	If $aCall[4] > 0 Then
    		Local   $iModnum = $aCall[4] / 4
    		Local   $aTemp
    		For $i = 1 To $iModnum
    			$aTemp =  DllCall($PSAPI, "dword", "GetModuleBaseNameW", "ptr", $hProcess, "ptr", Ptr(DllStructGetData($Modules, 1, $i)), "wstr", "", "dword", 260)
    			If $aTemp[3] = $sModule Then
    				DllClose($PSAPI)
    				Return Ptr(DllStructGetData($Modules, 1, $i))
    			EndIf
    		Next
    	EndIf
    	DllClose($PSAPI)
    	Return SetError(-1, 0, 0)
    EndFunc
    
    #endregion
    
    
    ;==================================================================================
    ; Function:   SetPrivilege( $privilege, $bEnable )
    ; Description:    Enables (or disables) the $privilege on the current process
    ;                   (Probably) requires administrator privileges to run
    ;
    ; Author(s):        Larry (from autoitscript.com's Forum)
    ; Notes(s):
    ; http://www.autoitscript.com/forum/index.ph...st&p=223999
    ;==================================================================================
    
    Func SetPrivilege( $privilege, $bEnable )
        Const $TOKEN_ADJUST_PRIVILEGES = 0x0020
        Const $TOKEN_QUERY = 0x0008
        Const $SE_PRIVILEGE_ENABLED = 0x0002
        Local $hToken, $SP_auxret, $SP_ret, $hCurrProcess, $nTokens, $nTokenIndex, $priv
        $nTokens = 1
        $LUID = DLLStructCreate("dword;int")
        If IsArray($privilege) Then    $nTokens = UBound($privilege)
        $TOKEN_PRIVILEGES = DLLStructCreate("dword;dword[" & (3 * $nTokens) & "]")
        $NEWTOKEN_PRIVILEGES = DLLStructCreate("dword;dword[" & (3 * $nTokens) & "]")
        $hCurrProcess = DLLCall("kernel32.dll","hwnd","GetCurrentProcess")
        $SP_auxret = DLLCall("advapi32.dll","int","OpenProcessToken","hwnd",$hCurrProcess[0],   _
                "int",BitOR($TOKEN_ADJUST_PRIVILEGES,$TOKEN_QUERY),"int*",0)
        If $SP_auxret[0] Then
            $hToken = $SP_auxret[3]
            DLLStructSetData($TOKEN_PRIVILEGES,1,1)
            $nTokenIndex = 1
            While $nTokenIndex <= $nTokens
                If IsArray($privilege) Then
                    $priv = $privilege[$nTokenIndex-1]
                Else
                    $priv = $privilege
                EndIf
                $ret = DLLCall("advapi32.dll","int","LookupPrivilegeValue","str","","str",$priv,   _
                        "ptr",DLLStructGetPtr($LUID))
                If $ret[0] Then
                    If $bEnable Then
                        DLLStructSetData($TOKEN_PRIVILEGES,2,$SE_PRIVILEGE_ENABLED,(3 * $nTokenIndex))
                    Else
                        DLLStructSetData($TOKEN_PRIVILEGES,2,0,(3 * $nTokenIndex))
                    EndIf
                    DLLStructSetData($TOKEN_PRIVILEGES,2,DllStructGetData($LUID,1),(3 * ($nTokenIndex-1)) + 1)
                    DLLStructSetData($TOKEN_PRIVILEGES,2,DllStructGetData($LUID,2),(3 * ($nTokenIndex-1)) + 2)
                    DLLStructSetData($LUID,1,0)
                    DLLStructSetData($LUID,2,0)
                EndIf
                $nTokenIndex += 1
            WEnd
            $ret = DLLCall("advapi32.dll","int","AdjustTokenPrivileges","hwnd",$hToken,"int",0,   _
                    "ptr",DllStructGetPtr($TOKEN_PRIVILEGES),"int",DllStructGetSize($NEWTOKEN_PRIVILEGES),   _
                    "ptr",DllStructGetPtr($NEWTOKEN_PRIVILEGES),"int*",0)
            $f = DLLCall("kernel32.dll","int","GetLastError")
        EndIf
        $NEWTOKEN_PRIVILEGES=0
        $TOKEN_PRIVILEGES=0
        $LUID=0
        If $SP_auxret[0] = 0 Then Return 0
        $SP_auxret = DLLCall("kernel32.dll","int","CloseHandle","hwnd",$hToken)
        If Not $ret[0] And Not $SP_auxret[0] Then Return 0
        return $ret[0]
    EndFunc   ;==>SetPrivilege

    Thank you for your time patience and help, no Trolls please.
    Last edited by insomniac420; 02-26-2014 at 06:15 PM.

    Autoit  _MemoryModuleGetBaseAddress
  2. #2
    berlinermauer's Avatar Master Sergeant
    Reputation
    3
    Join Date
    Mar 2010
    Posts
    89
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If i remember correctly, GetModuleHandle will only work, if you are in the process (which you are not, because you are using OpenProcess etc.
    Your Code should be fine, did you check the l2.bin using "ProcessExplorer" or something, if that dll is really there? Maybe it's case sensitive and you are doing it wrong?
    Maybe breakpoint after "If $aTemp[3] = $sModule Then" or before. Let it print out all modules, and you will see

Similar Threads

  1. AutoIT
    By ashkanesla in forum World of Warcraft Bots and Programs
    Replies: 5
    Last Post: 08-31-2006, 12:43 PM
  2. [Autoit help]Modify hotkey to rightclick(fishbot)
    By darknavi in forum World of Warcraft General
    Replies: 4
    Last Post: 07-01-2006, 09:31 PM
  3. No fall dmg (autoIT)
    By KuRIoS in forum World of Warcraft Exploits
    Replies: 6
    Last Post: 06-19-2006, 12:22 PM
  4. autoIT question
    By Vel0city in forum World of Warcraft General
    Replies: 3
    Last Post: 06-18-2006, 02:54 PM
  5. AutoIt Macro for WoW AFK Bot
    By Matt in forum World of Warcraft Bots and Programs
    Replies: 8
    Last Post: 04-06-2006, 06:01 AM
All times are GMT -5. The time now is 10:44 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