3.3.7.2的winapiex中没有找到_WinAPI_ProcessGetLoadedModules函数
如题,之前3.3.6.1找不到_WinAPI_EnumProcessModules升级后,又找不到_WinAPI_ProcessGetLoadedModules函数了 本帖最后由 netegg 于 2011-9-3 23:54 编辑
Func _WinAPI_EnumProcessModules($PID = 0)
If Not $PID Then
$PID = _WinAPI_GetCurrentProcessID()
If Not $PID Then
Return SetError(1, 0, 0)
EndIf
EndIf
Local $hProcess, $tPtr, $Access, $Count, $Ret, $Result = 0
If _WinAPI_GetVersion() < '6.0' Then
$Access = 0x00000410
Else
$Access = 0x00001010
EndIf
$hProcess = DllCall('kernel32.dll', 'ptr', 'OpenProcess', 'dword', $Access, 'int', 0, 'dword', $PID)
If (@error) Or (Not $hProcess) Then
Return SetError(1, 0, 0)
EndIf
Do
$Ret = DllCall(@SystemDir & '\psapi.dll', 'int', 'EnumProcessModules', 'ptr', $hProcess, 'ptr', 0, 'dword', 0, 'dword*', 0)
If (@error) Or (Not $Ret) Then
ExitLoop
EndIf
If @AutoItX64 Then
$Count = $Ret / 8
Else
$Count = $Ret / 4
EndIf
$tPtr = DllStructCreate('ptr[' & $Count & ']')
If Not IsDllStruct($tPtr) Then
ExitLoop
EndIf
$Ret = DllCall(@SystemDir & '\psapi.dll', 'int', 'EnumProcessModules', 'ptr', $hProcess, 'ptr', DllStructGetPtr($tPtr), 'dword', DllStructGetSize($tPtr), 'dword*', 0)
If (@error) Or (Not $Ret) Then
ExitLoop
EndIf
$Result = 1
Until 1
_WinAPI_CloseHandle($hProcess)
If Not $Result Then
Return SetError(1, 0, 0)
EndIf
Dim $Result[$Count + 1] = [[$Count]]
For $i = 1 To $Count
$Result[$i] = DllStructGetData($tPtr, 1, $i)
$Result[$i] = _WinAPI_GetModuleFileName($Result[$i])
Next
Return $Result
EndFunc ;==>_WinAPI_EnumProcessModules
好像不对,那个loaded*好像没见过 回复 2# netegg
在汉化的winapiex中看到的 有这么个函数。
; #FUNCTION#;===============================================================================
;
; Name...........: _WinAPI_ProcessGetLoadedModules
; Description ...: Returns an array containing the full path of the loaded modules
; Syntax.........: _WinAPI_ProcessGetLoadedModules($iPID)
; Parameters ....:
; Return values .: Success - An array with all the paths
; : Failure - -1 and @error=1 if the specified process couldn't be opened.
; Author ........: Andreas Karlsson (monoceres) & ProgAndy
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......; No
;
;;==========================================================================================
Func _WinAPI_ProcessGetLoadedModules($iPID)
Local $tModulesStruct = DllStructCreate("hwnd ")
Local $SIZEOFHWND = DllStructGetSize($tModulesStruct) / 200
Local $hProcess = _WinAPI_OpenProcess(BitOR(0x400, 0x10), False, $iPID)
If Not $hProcess Then Return SetError(1, 0, -1)
Local $Ret = DllCall("Psapi.dll", "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($tModulesStruct), "dword", DllStructGetSize($tModulesStruct), "dword*", "")
If $Ret > DllStructGetSize($tModulesStruct) Then
$tModulesStruct = DllStructCreate("hwnd [" & $Ret / $SIZEOFHWND & "]")
$Ret = DllCall("Psapi.dll", "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($tModulesStruct), "dword", $Ret, "dword*", "")
EndIf
Local $aReturn[$Ret / $SIZEOFHWND]
For $i = 0 To UBound($aReturn) - 1
$Ret = DllCall("Psapi.dll", "dword", "GetModuleFileNameExW", "ptr", $hProcess, "ptr", DllStructGetData($tModulesStruct, 1, $i + 1), "wstr", "", "dword", 65536)
$aReturn[$i] = $Ret
Next
_WinAPI_CloseHandle($hProcess)
Return $aReturn
EndFunc ;==>_WinAPI_ProcessGetLoadedModules
页:
[1]