Prinzipiell hab ich meine Funktion fertig, nur gibt es einen Fehler den ich nicht erkenne:
Wenn man bei $iMode 2 angibt, gibt es einen Error beim StringRegExp, dass es kein Array ist, obwohl ich es mir mit _ArrayDisplay anschauen kann.
Any thoughts?
#include-once
#include <Array.au3>
; #FUNCTION# ====================================================================================================================
; Name...........: _ProcessGetModules
; Description....: Retrieves the currently loaded modules in the target process.
; Syntax.........: _ProcessGetModules($iPID, $iMode)
; Parameters.....: $iPID - The PID of the target process.
; $iMode - 1: Retrieves an array with the fullpath of the modules.
; 2: Retrieves an array with the modules only.
; Return values..: Success - An array with the loaded modules.
; Failure - Empty array
; Author.........: [email='pinguin94@autoit.de'][/email]
; Modified.......: -
; Remarks........: Array.au3 needed
; Related........: None
; Link...........: None
; Example........: No
; ===============================================================================================================================
Func _ProcessGetModules($iPID, $iMode = 1)
Local $aModules[1], $aTemp
Local $Kernel32 = DllOpen("kernel32.dll")
Local $PsAPI = DllOpen("psapi.dll")
Local $hOpen = DllCall($Kernel32, "hwnd", "OpenProcess", "int", BitOR(0x0400, 0x0010), "int", 0, "int", $iPID)
$hOpen = $hOpen[0]
Local $Struct = DllStructCreate("int[1024]")
$aEnum = DllCall($PsAPI, "int", "EnumProcessModules", "hwnd", $hOpen, "ptr", DllStructGetPtr($Struct), "int", DllStructGetSize($Struct), "int*", 0)
$iMax = $aEnum[4] / 4
For $i = 1 To $iMax
$aTemp = DllCall($PsAPI, "int", "GetModuleFileNameEx", "hwnd", $hOpen, "int", DllStructGetData($Struct, 1, $i), "str", "", "int", 2048)
If $aTemp[3] > "" Then
Switch $iMode
Case 1
_ArrayAdd($aModules, $aTemp[3])
Case 2
$RegExp = StringRegExp($aTemp[3], "\\(\w*).dll", 3) ;Soll alle .dll filtern <-- Error!
_ArrayAdd($aModules, $RegExp[0] & ".dll")
EndSwitch
EndIf
Next
DLLCall($Kernel32, "int", "CloseHandle", "int",$hOpen)
DllClose($Kernel32)
DllClose($PsAPI)
Return $aModules
EndFunc
Verbesserungen an der Funktion nehm ich gerne an, die werden direkt umgesetzt.
Vielleicht braucht die Funktion ja wer, damit kann man super Task Manager programmieren, der direkt schaut, welche module geladen sind!
MfG