endlesslove_1998

NomadMemory.au3

Apr 22nd, 2017
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 22.50 KB | None | 0 0
  1. #include-once
  2. #region _Memory
  3. ;==================================================================================
  4. ; AutoIt Version:   3.1.127 (beta)
  5. ; Language:   English
  6. ; Platform:   All Windows
  7. ; Author:         Nomad
  8. ; Requirements:  These functions will only work with beta.
  9. ;==================================================================================
  10. ; Credits:  wOuter - These functions are based on his original _Mem() functions.
  11. ;         But they are easier to comprehend and more reliable.  These
  12. ;         functions are in no way a direct copy of his functions.  His
  13. ;         functions only provided a foundation from which these evolved.
  14. ;==================================================================================
  15. ;
  16. ; Functions:
  17. ;
  18. ;==================================================================================
  19. ; Function:   _MemoryOpen($iv_Pid[, $iv_DesiredAccess[, $iv_InheritHandle]])
  20. ; Description:    Opens a process and enables all possible access rights to the
  21. ;               process.  The Process ID of the process is used to specify which
  22. ;               process to open.  You must call this function before calling
  23. ;               _MemoryClose(), _MemoryRead(), or _MemoryWrite().
  24. ; Parameter(s):  $iv_Pid - The Process ID of the program you want to open.
  25. ;               $iv_DesiredAccess - (optional) Set to 0x1F0FFF by default, which
  26. ;                              enables all possible access rights to the
  27. ;                              process specified by the Process ID.
  28. ;               $iv_InheritHandle - (optional) If this value is TRUE, all processes
  29. ;                              created by this process will inherit the access
  30. ;                              handle.  Set to 1 (TRUE) by default.  Set to 0
  31. ;                              if you want it FALSE.
  32. ; Requirement(s):   None.
  33. ; Return Value(s):  On Success - Returns an array containing the Dll handle and an
  34. ;                         open handle to the specified process.
  35. ;               On Failure - Returns 0
  36. ;               @Error - 0 = No error.
  37. ;                      1 = Invalid $iv_Pid.
  38. ;                      2 = Failed to open Kernel32.dll.
  39. ;                      3 = Failed to open the specified process.
  40. ; Author(s):        Nomad
  41. ; Note(s):
  42. ;==================================================================================
  43. Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $iv_InheritHandle = 1)
  44.  
  45.     If Not ProcessExists($iv_Pid) Then
  46.         SetError(1)
  47.         Return 0
  48.     EndIf
  49.  
  50.     Local $ah_Handle[2] = [DllOpen('kernel32.dll')]
  51.  
  52.     If @Error Then
  53.         SetError(2)
  54.         Return 0
  55.     EndIf
  56.  
  57.     Local $av_OpenProcess = DllCall($ah_Handle[0], 'int', 'OpenProcess', 'int', $iv_DesiredAccess, 'int', $iv_InheritHandle, 'int', $iv_Pid)
  58.  
  59.     If @Error Then
  60.         DllClose($ah_Handle[0])
  61.         SetError(3)
  62.         Return 0
  63.     EndIf
  64.  
  65.     $ah_Handle[1] = $av_OpenProcess[0]
  66.  
  67.     Return $ah_Handle
  68.  
  69. EndFunc
  70.  
  71. ;==================================================================================
  72. ; Function:   _MemoryRead($iv_Address, $ah_Handle[, $sv_Type])
  73. ; Description:    Reads the value located in the memory address specified.
  74. ; Parameter(s):  $iv_Address - The memory address you want to read from. It must
  75. ;                          be in hex format (0x00000000).
  76. ;               $ah_Handle - An array containing the Dll handle and the handle
  77. ;                         of the open process as returned by _MemoryOpen().
  78. ;               $sv_Type - (optional) The "Type" of value you intend to read.
  79. ;                        This is set to 'dword'(32bit(4byte) signed integer)
  80. ;                        by default.  See the help file for DllStructCreate
  81. ;                        for all types.  An example: If you want to read a
  82. ;                        word that is 15 characters in length, you would use
  83. ;                        'char[16]' since a 'char' is 8 bits (1 byte) in size.
  84. ; Return Value(s):  On Success - Returns the value located at the specified address.
  85. ;               On Failure - Returns 0
  86. ;               @Error - 0 = No error.
  87. ;                      1 = Invalid $ah_Handle.
  88. ;                      2 = $sv_Type was not a string.
  89. ;                      3 = $sv_Type is an unknown data type.
  90. ;                      4 = Failed to allocate the memory needed for the DllStructure.
  91. ;                      5 = Error allocating memory for $sv_Type.
  92. ;                      6 = Failed to read from the specified process.
  93. ; Author(s):        Nomad
  94. ; Note(s):      Values returned are in Decimal format, unless specified as a
  95. ;               'char' type, then they are returned in ASCII format.  Also note
  96. ;               that size ('char[size]') for all 'char' types should be 1
  97. ;               greater than the actual size.
  98. ;==================================================================================
  99. Func _MemoryRead($iv_Address, $ah_Handle, $sv_Type = 'dword')
  100.  
  101.     If Not IsArray($ah_Handle) Then
  102.         SetError(1)
  103.         Return 0
  104.     EndIf
  105.  
  106.     Local $v_Buffer = DllStructCreate($sv_Type)
  107.  
  108.     If @Error Then
  109.         SetError(@Error + 1)
  110.         Return 0
  111.     EndIf
  112.  
  113.     DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
  114.  
  115.     If Not @Error Then
  116.         Local $v_Value = DllStructGetData($v_Buffer, 1)
  117.         Return $v_Value
  118.     Else
  119.         SetError(6)
  120.         Return 0
  121.     EndIf
  122.  
  123. EndFunc
  124.  
  125. ;==================================================================================
  126. ; Function:   _MemoryWrite($iv_Address, $ah_Handle, $v_Data[, $sv_Type])
  127. ; Description:    Writes data to the specified memory address.
  128. ; Parameter(s):  $iv_Address - The memory address which you want to write to.
  129. ;                          It must be in hex format (0x00000000).
  130. ;               $ah_Handle - An array containing the Dll handle and the handle
  131. ;                         of the open process as returned by _MemoryOpen().
  132. ;               $v_Data - The data to be written.
  133. ;               $sv_Type - (optional) The "Type" of value you intend to write.
  134. ;                        This is set to 'dword'(32bit(4byte) signed integer)
  135. ;                        by default.  See the help file for DllStructCreate
  136. ;                        for all types.  An example: If you want to write a
  137. ;                        word that is 15 characters in length, you would use
  138. ;                        'char[16]' since a 'char' is 8 bits (1 byte) in size.
  139. ; Return Value(s):  On Success - Returns 1
  140. ;               On Failure - Returns 0
  141. ;               @Error - 0 = No error.
  142. ;                      1 = Invalid $ah_Handle.
  143. ;                      2 = $sv_Type was not a string.
  144. ;                      3 = $sv_Type is an unknown data type.
  145. ;                      4 = Failed to allocate the memory needed for the DllStructure.
  146. ;                      5 = Error allocating memory for $sv_Type.
  147. ;                      6 = $v_Data is not in the proper format to be used with the
  148. ;                         "Type" selected for $sv_Type, or it is out of range.
  149. ;                      7 = Failed to write to the specified process.
  150. ; Author(s):        Nomad
  151. ; Note(s):      Values sent must be in Decimal format, unless specified as a
  152. ;               'char' type, then they must be in ASCII format.  Also note
  153. ;               that size ('char[size]') for all 'char' types should be 1
  154. ;               greater than the actual size.
  155. ;==================================================================================
  156. Func _MemoryWrite($iv_Address, $ah_Handle, $v_Data, $sv_Type = 'dword')
  157.  
  158.     If Not IsArray($ah_Handle) Then
  159.         SetError(1)
  160.         Return 0
  161.     EndIf
  162.  
  163.     Local $v_Buffer = DllStructCreate($sv_Type)
  164.  
  165.     If @Error Then
  166.         SetError(@Error + 1)
  167.         Return 0
  168.     Else
  169.         DllStructSetData($v_Buffer, 1, $v_Data)
  170.         If @Error Then
  171.             SetError(6)
  172.             Return 0
  173.         EndIf
  174.     EndIf
  175.  
  176.     DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
  177.  
  178.     If Not @Error Then
  179.         Return 1
  180.     Else
  181.         SetError(7)
  182.         Return 0
  183.     EndIf
  184.  
  185. EndFunc
  186.  
  187. ;==================================================================================
  188. ; Function:   _MemoryClose($ah_Handle)
  189. ; Description:    Closes the process handle opened by using _MemoryOpen().
  190. ; Parameter(s):  $ah_Handle - An array containing the Dll handle and the handle
  191. ;                         of the open process as returned by _MemoryOpen().
  192. ; Return Value(s):  On Success - Returns 1
  193. ;               On Failure - Returns 0
  194. ;               @Error - 0 = No error.
  195. ;                      1 = Invalid $ah_Handle.
  196. ;                      2 = Unable to close the process handle.
  197. ; Author(s):        Nomad
  198. ; Note(s):
  199. ;==================================================================================
  200. Func _MemoryClose($ah_Handle)
  201.  
  202.     If Not IsArray($ah_Handle) Then
  203.         SetError(1)
  204.         Return 0
  205.     EndIf
  206.  
  207.     DllCall($ah_Handle[0], 'int', 'CloseHandle', 'int', $ah_Handle[1])
  208.     If Not @Error Then
  209.         DllClose($ah_Handle[0])
  210.         Return 1
  211.     Else
  212.         DllClose($ah_Handle[0])
  213.         SetError(2)
  214.         Return 0
  215.     EndIf
  216.  
  217. EndFunc
  218.  
  219.  
  220.  
  221. ;=================================================================================================
  222. ; Function:   _MemoryPointerRead ($iv_Address, $ah_Handle, $av_Offset[, $sv_Type])
  223. ; Description:    Reads a chain of pointers and returns an array containing the destination
  224. ;               address and the data at the address.
  225. ; Parameter(s):  $iv_Address - The static memory address you want to start at. It must be in
  226. ;                          hex format (0x00000000).
  227. ;               $ah_Handle - An array containing the Dll handle and the handle of the open
  228. ;                         process as returned by _MemoryOpen().
  229. ;               $av_Offset - An array of offsets for the pointers.  Each pointer must have an
  230. ;                         offset.  If there is no offset for a pointer, enter 0 for that
  231. ;                         array dimension.
  232. ;               $sv_Type - (optional) The "Type" of data you intend to read at the destination
  233. ;                         address.  This is set to 'dword'(32bit(4byte) signed integer) by
  234. ;                         default.  See the help file for DllStructCreate for all types.
  235. ; Requirement(s):   The $ah_Handle returned from _MemoryOpen.
  236. ; Return Value(s):  On Success - Returns an array containing the destination address and the value
  237. ;                         located at the address.
  238. ;               On Failure - Returns 0
  239. ;               @Error - 0 = No error.
  240. ;                      1 = $av_Offset is not an array.
  241. ;                      2 = Invalid $ah_Handle.
  242. ;                      3 = $sv_Type is not a string.
  243. ;                      4 = $sv_Type is an unknown data type.
  244. ;                      5 = Failed to allocate the memory needed for the DllStructure.
  245. ;                      6 = Error allocating memory for $sv_Type.
  246. ;                      7 = Failed to read from the specified process.
  247. ; Author(s):        Nomad
  248. ; Note(s):      Values returned are in Decimal format, unless a 'char' type is selected.
  249. ;               Set $av_Offset like this:
  250. ;               $av_Offset[0] = NULL (not used)
  251. ;               $av_Offset[1] = Offset for pointer 1 (all offsets must be in Decimal)
  252. ;               $av_Offset[2] = Offset for pointer 2
  253. ;               etc...
  254. ;               (The number of array dimensions determines the number of pointers)
  255. ;=================================================================================================
  256. Func _MemoryPointerRead($iv_Address, $ah_Handle, $av_Offset, $sv_Type = 'dword')
  257.  
  258.     If IsArray($av_Offset) Then
  259.         If IsArray($ah_Handle) Then
  260.             Local $iv_PointerCount = UBound($av_Offset) - 1
  261.         Else
  262.             SetError(2)
  263.             Return 0
  264.         EndIf
  265.     Else
  266.         SetError(1)
  267.         Return 0
  268.     EndIf
  269.  
  270.     Local $iv_Data[2], $i
  271.     Local $v_Buffer = DllStructCreate('dword')
  272.  
  273.     For $i = 0 To $iv_PointerCount
  274.  
  275.         If $i = $iv_PointerCount Then
  276.             $v_Buffer = DllStructCreate($sv_Type)
  277.             If @error Then
  278.                 SetError(@error + 2)
  279.                 Return 0
  280.             EndIf
  281.  
  282.             $iv_Address = '0x' & Hex($iv_Data[1] + $av_Offset[$i])
  283.             DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
  284.             If @error Then
  285.                 SetError(7)
  286.                 Return 0
  287.             EndIf
  288.  
  289.             $iv_Data[1] = DllStructGetData($v_Buffer, 1)
  290.  
  291.         ElseIf $i = 0 Then
  292.             DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
  293.             If @error Then
  294.                 SetError(7)
  295.                 Return 0
  296.             EndIf
  297.  
  298.             $iv_Data[1] = DllStructGetData($v_Buffer, 1)
  299.  
  300.         Else
  301.             $iv_Address = '0x' & Hex($iv_Data[1] + $av_Offset[$i])
  302.             DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
  303.             If @error Then
  304.                 SetError(7)
  305.                 Return 0
  306.             EndIf
  307.  
  308.             $iv_Data[1] = DllStructGetData($v_Buffer, 1)
  309.  
  310.         EndIf
  311.  
  312.     Next
  313.  
  314.     $iv_Data[0] = $iv_Address
  315.  
  316.     Return $iv_Data
  317.  
  318. EndFunc   ;==>_MemoryPointerRead
  319.  
  320.  
  321.  
  322. ;=================================================================================================
  323. ; Function:         _MemoryPointerWrite ($iv_Address, $ah_Handle, $av_Offset, $v_Data[, $sv_Type])
  324. ; Description:      Reads a chain of pointers and writes the data to the destination address.
  325. ; Parameter(s):     $iv_Address - The static memory address you want to start at. It must be in
  326. ;                                 hex format (0x00000000).
  327. ;                   $ah_Handle - An array containing the Dll handle and the handle of the open
  328. ;                                process as returned by _MemoryOpen().
  329. ;                   $av_Offset - An array of offsets for the pointers.  Each pointer must have an
  330. ;                                offset.  If there is no offset for a pointer, enter 0 for that
  331. ;                                array dimension.
  332. ;                   $v_Data - The data to be written.
  333. ;                   $sv_Type - (optional) The "Type" of data you intend to write at the destination
  334. ;                                address.  This is set to 'dword'(32bit(4byte) signed integer) by
  335. ;                                default.  See the help file for DllStructCreate for all types.
  336. ; Requirement(s):   The $ah_Handle returned from _MemoryOpen.
  337. ; Return Value(s):  On Success - Returns the destination address.
  338. ;                   On Failure - Returns 0.
  339. ;                   @Error - 0 = No error.
  340. ;                            1 = $av_Offset is not an array.
  341. ;                            2 = Invalid $ah_Handle.
  342. ;                            3 = Failed to read from the specified process.
  343. ;                            4 = $sv_Type is not a string.
  344. ;                            5 = $sv_Type is an unknown data type.
  345. ;                            6 = Failed to allocate the memory needed for the DllStructure.
  346. ;                            7 = Error allocating memory for $sv_Type.
  347. ;                            8 = $v_Data is not in the proper format to be used with the
  348. ;                                "Type" selected for $sv_Type, or it is out of range.
  349. ;                            9 = Failed to write to the specified process.
  350. ; Author(s):        Nomad
  351. ; Note(s):          Data written is in Decimal format, unless a 'char' type is selected.
  352. ;                   Set $av_Offset like this:
  353. ;                   $av_Offset[0] = NULL (not used, doesn't matter what's entered)
  354. ;                   $av_Offset[1] = Offset for pointer 1 (all offsets must be in Decimal)
  355. ;                   $av_Offset[2] = Offset for pointer 2
  356. ;                   etc...
  357. ;                   (The number of array dimensions determines the number of pointers)
  358. ;=================================================================================================
  359.  
  360. Func _MemoryPointerWrite ($iv_Address, $ah_Handle, $av_Offset, $v_Data, $sv_Type = 'dword')
  361.  
  362.     If IsArray($av_Offset) Then
  363.         If IsArray($ah_Handle) Then
  364.             Local $iv_PointerCount = UBound($av_Offset) - 1
  365.         Else
  366.             SetError(2)
  367.             Return 0
  368.         EndIf
  369.     Else
  370.         SetError(1)
  371.         Return 0
  372.     EndIf
  373.  
  374.     Local $iv_StructData, $i
  375.     Local $v_Buffer = DllStructCreate('dword')
  376.  
  377.     For $i = 0 to $iv_PointerCount
  378.         If $i = $iv_PointerCount Then
  379.             $v_Buffer = DllStructCreate($sv_Type)
  380.             If @Error Then
  381.                 SetError(@Error + 3)
  382.                 Return 0
  383.             EndIf
  384.  
  385.             DllStructSetData($v_Buffer, 1, $v_Data)
  386.             If @Error Then
  387.                 SetError(8)
  388.                 Return 0
  389.             EndIf
  390.  
  391.             $iv_Address = '0x' & hex($iv_StructData + $av_Offset[$i])
  392.             DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
  393.             If @Error Then
  394.                 SetError(9)
  395.                 Return 0
  396.             Else
  397.                 Return $iv_Address
  398.             EndIf
  399.         ElseIf $i = 0 Then
  400.             DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
  401.             If @Error Then
  402.                 SetError(3)
  403.                 Return 0
  404.             EndIf
  405.  
  406.             $iv_StructData = DllStructGetData($v_Buffer, 1)
  407.  
  408.         Else
  409.             $iv_Address = '0x' & hex($iv_StructData + $av_Offset[$i])
  410.             DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
  411.             If @Error Then
  412.                 SetError(3)
  413.                 Return 0
  414.             EndIf
  415.  
  416.             $iv_StructData = DllStructGetData($v_Buffer, 1)
  417.  
  418.         EndIf
  419.     Next
  420.  
  421. EndFunc
  422.  
  423.  
  424. ;===================================================================================================
  425.  
  426. ; Function........:  _MemoryGetBaseAddress($ah_Handle, $iHD)
  427. ;
  428. ; Description.....:  Reads the 'Allocation Base' from the open process.
  429. ;
  430. ; Parameter(s)....:  $ah_Handle - An array containing the Dll handle and the handle of the open
  431. ;                               process as returned by _MemoryOpen().
  432. ;                    $iHD - Return type:
  433. ;                       |0 = Hex (Default)
  434. ;                       |1 = Dec
  435. ;
  436. ; Requirement(s)..:  A valid process ID.
  437. ;
  438. ; Return Value(s).:  On Success - Returns the 'allocation Base' address and sets @Error to 0.
  439. ;                    On Failure - Returns 0 and sets @Error to:
  440. ;                  |1 = Invalid $ah_Handle.
  441. ;                  |2 = Failed to find correct allocation address.
  442. ;                  |3 = Failed to read from the specified process.
  443. ;
  444. ; Author(s).......:  Nomad. Szhlopp.
  445. ; URL.............:  http://www.autoitscript.com/forum/index.php?showtopic=78834
  446. ; Note(s).........:  Go to Www.CheatEngine.org for the latest version of CheatEngine.
  447. ;===================================================================================================
  448.  
  449. Func _MemoryGetBaseAddress($ah_Handle, $iHexDec = 0)
  450.  
  451.     Local $iv_Address = 0x00100000
  452.     Local $v_Buffer = DllStructCreate('dword;dword;dword;dword;dword;dword;dword')
  453.     Local $vData
  454.     Local $vType
  455.  
  456.     If Not IsArray($ah_Handle) Then
  457.         SetError(1)
  458.         Return 0
  459.     EndIf
  460.  
  461.  
  462.     DllCall($ah_Handle[0], 'int', 'VirtualQueryEx', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer))
  463.  
  464.     If Not @Error Then
  465.  
  466.         $vData = Hex(DllStructGetData($v_Buffer, 2))
  467.         $vType = Hex(DllStructGetData($v_Buffer, 3))
  468.  
  469.         While $vType <> "00000080"
  470.             DllCall($ah_Handle[0], 'int', 'VirtualQueryEx', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer))
  471.             $vData = Hex(DllStructGetData($v_Buffer, 2))
  472.             $vType = Hex(DllStructGetData($v_Buffer, 3))
  473.             If Hex($iv_Address) = "01000000" Then ExitLoop
  474.             $iv_Address += 65536
  475.  
  476.         WEnd
  477.  
  478.         If $vType = "00000080" Then
  479.             SetError(0)
  480.             If $iHexDec = 1 Then
  481.                 Return Dec($vData)
  482.             Else
  483.                 Return $vData
  484.             EndIf
  485.  
  486.         Else
  487.             SetError(2)
  488.             Return 0
  489.         EndIf
  490.  
  491.     Else
  492.         SetError(3)
  493.         Return 0
  494.     EndIf
  495.  
  496. EndFunc   ;==>_MemoryGetBaseAddress
  497. Func _MemoryModuleGetBaseAddress($iPID, $sModule)
  498.     If Not ProcessExists($iPID) Then Return SetError(1, 0, 0)
  499.  
  500.     If Not IsString($sModule) Then Return SetError(2, 0, 0)
  501.  
  502.     Local   $PSAPI = DllOpen("psapi.dll")
  503.  
  504.     ;Get Process Handle
  505.     Local   $hProcess
  506.     Local   $PERMISSION = BitOR(0x0002, 0x0400, 0x0008, 0x0010, 0x0020) ; CREATE_THREAD, QUERY_INFORMATION, VM_OPERATION, VM_READ, VM_WRITE
  507.  
  508.     If $iPID > 0 Then
  509.         Local $hProcess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $PERMISSION, "int", 0, "dword", $iPID)
  510.         If $hProcess[0] Then
  511.             $hProcess = $hProcess[0]
  512.         EndIf
  513.     EndIf
  514.  
  515.     ;EnumProcessModules
  516.     Local   $Modules = DllStructCreate("ptr[1024]")
  517.     Local   $aCall = DllCall($PSAPI, "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($Modules), "dword", DllStructGetSize($Modules), "dword*", 0)
  518.     If $aCall[4] > 0 Then
  519.         Local   $iModnum = $aCall[4] / 4
  520.         Local   $aTemp
  521.         For $i = 1 To $iModnum
  522.             $aTemp =  DllCall($PSAPI, "dword", "GetModuleBaseNameW", "ptr", $hProcess, "ptr", Ptr(DllStructGetData($Modules, 1, $i)), "wstr", "", "dword", 260)
  523.             If $aTemp[3] = $sModule Then
  524.                 DllClose($PSAPI)
  525.                 Return Ptr(DllStructGetData($Modules, 1, $i))
  526.             EndIf
  527.         Next
  528.     EndIf
  529.  
  530.     DllClose($PSAPI)
  531.     Return SetError(-1, 0, 0)
  532.  
  533. EndFunc
  534. #EndRegion
Advertisement
Add Comment
Please, Sign In to add comment