Guest User

Untitled

a guest
Jul 19th, 2019
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Func _ProcessGetModuleBase($ivPID, $svModuleName)
  3.     $ivPID = ProcessExists($ivPID)
  4.  
  5.     If Not $ivPID Then Return(SetError(1, 0, 0)); Process does not exist
  6.  
  7.     Local $TH32CS_SNAPMODULE = 0x00000008
  8.     Local $sMODULEENTRY32Struct = "dword Size;" & _
  9.                             "dword 32ModuleID;" & _
  10.                             "dword 32ProcessID;" & _
  11.                             "dword GlblcntUsage;" & _
  12.                             "dword ProccntUsage;" & _
  13.                             "ptr modBaseAddr;" & _
  14.                             "dword modBaseSize;" & _
  15.                             "hwnd hModule;" & _
  16.                             "char Module[255];" & _
  17.                             "char ExePath[260]"
  18.  
  19.     Local $hvSnapShot = DllCall("Kernel32.dll", "hwnd", "CreateToolhelp32Snapshot", "dword", $TH32CS_SNAPMODULE, "dword", $ivPID)
  20.     If Not $hvSnapShot[0] Then Return(SetError(2, 0, 0)); Could not create snapshot?
  21.  
  22.     Local $stMODULEENTRY32 = DllStructCreate($sMODULEENTRY32Struct)
  23.     DllStructSetData($stMODULEENTRY32, "Size", DllStructGetSize($stMODULEENTRY32))
  24.  
  25.     Local $ivState = DllCall("Kernel32.dll", "int", "Module32First", "hwnd", $hvSnapShot[0], "long_ptr", DllStructGetPtr($stMODULEENTRY32))
  26. ;~     If Not $ivState[0] Then Return(SetError(3, _WinAPI_CloseHandle($hvSnapShot[0]), 0)); Could not enumerate first module in list?
  27.     Local $ivRet = 0
  28.     Local $svModule
  29.  
  30.     Do
  31.         $ivRet = DllStructGetData($stMODULEENTRY32, "modBaseAddr")
  32.         $svModule = DllStructGetData($stMODULEENTRY32, "Module")
  33.         If $svModule = $svModuleName Then ExitLoop
  34.         $ivState = DllCall("Kernel32.dll", "int", "Module32Next", "hwnd", $hvSnapShot[0], "long_ptr", DllStructGetPtr($stMODULEENTRY32))
  35.         Sleep(1)
  36.     Until Not $ivState[0]
  37.  
  38.     _WinAPI_CloseHandle($hvSnapShot[0])
  39.  
  40.     Return $ivRet
  41. EndFunc
RAW Paste Data