Ich versuche aus einem Prozess die Modulbase und die Länge durch eine Funktion, die ich bekommen habe, herauszufinden. Auf meinem Notebook habe ich Windows7, auf meinem alten Rechner XP. Die FUnktion sieht so aus:
Spoiler anzeigen
Func _GetModuleBaseByName($pid, $module)
Local $hSnapshot, $me32, $bFound, $baseAddress[3]
$me32 = DllStructCreate("int;int;int;int;int;int;int;int;char[256];char[260]")
DllStructSetData($me32,1,DllStructGetSize($me32))
$hSnapshot = DllCall("kernel32.dll","hwnd","CreateToolhelp32Snapshot","int",8,"int",$pid)
If $hSnapshot[0] = -1 Then Return 0
$bFound = DllCall("kernel32.dll","int","Module32First","hwnd",$hSnapshot[0],"ptr",DllStructGetPtr($me32))
If $bFound[0] Then
Do
If StringLower(DllStructGetData($me32,9)) = StringLower($module) Then
$baseAddress[1] = DllStructGetData($me32,6)
$baseAddress[2] = DllStructGetData($me32,7)
ExitLoop
EndIf
$bFound = DllCall("kernel32.dll","int","Module32Next","hwnd",$hSnapshot[0],"ptr",DllStructGetPtr($me32))
Until Not $bFound[0]
EndIf
DllCall("kernel32.dll","int","CloseHandle","int",$hSnapshot[0])
Return $baseAddress
EndFunc
Das Problem: Unter Win7 wird nichts returned. Unter XP mit genau demselben Code funktioniert es.
Unter Win7 scheitert die Funktion an diesem DLL Call
$bFound = DllCall("kernel32.dll","int","Module32First","hwnd",$hSnapshot[0],"ptr",DllStructGetPtr($me32))
[/autoit]
Denn $bFound[0] ist gleich 0 und nicht 1.
Was ist das Problem unter Win7. Kann man die Funktion irgendwie so umschreiben, dass sie sowohl unter Win7 als auch noch unter Vista und XP läuft?