[Memory read] Baseadresse mit Script rausfinden?

03/17/2012 15:58 jacky919#16
Poste mal die Implementierung der _MemoryModuleGetBaseAddress Funktion.
03/17/2012 16:02 Masterscripter#17
Code:
Func _MemoryModuleGetBaseAddress($iPID, $sModule)
    If Not ProcessExists($iPID) Then Return SetError(1, 0, 0)

    If Not IsString($sModule) Then Return SetError(2, 0, 0)

    Local   $PSAPI = DllOpen("psapi.dll")

    ;Get Process Handle
    Local   $hProcess
    Local   $PERMISSION = BitOR(0x0002, 0x0400, 0x0008, 0x0010, 0x0020) ; CREATE_THREAD, QUERY_INFORMATION, VM_OPERATION, VM_READ, VM_WRITE

    If $iPID > 0 Then
        Local $hProcess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $PERMISSION, "int", 0, "dword", $iPID)
        If $hProcess[0] Then
            $hProcess = $hProcess[0]
        EndIf
    EndIf

    ;EnumProcessModules
    Local   $Modules = DllStructCreate("ptr[1024]")
    Local   $aCall = DllCall($PSAPI, "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($Modules), "dword", DllStructGetSize($Modules), "dword*", 0)
    If $aCall[4] > 0 Then
        Local   $iModnum = $aCall[4] / 4
        Local   $aTemp
        For $i = 1 To $iModnum
            $aTemp =  DllCall($PSAPI, "dword", "GetModuleBaseNameW", "ptr", $hProcess, "ptr", Ptr(DllStructGetData($Modules, 1, $i)), "wstr", "", "dword", 260)
            If $aTemp[3] = $sModule Then
                DllClose($PSAPI)
                Return Ptr(DllStructGetData($Modules, 1, $i))
            EndIf
        Next
    EndIf

    DllClose($PSAPI)
    Return SetError(-1, 0, 0)

EndFunc
03/17/2012 16:08 jacky919#18
Was ist denn @error nach dem Aufruf der Funktion?
03/17/2012 16:12 Masterscripter#19
Wenn beim Öffnen des Prozesses kein Fehler auftritt, dann macht er weiter. Das bedeutet das. Also wenn jetzt beispielsweise der Prozess noch nicht gestartet wurde, dann liest er auch nicht, weil eben ein Fehler aufgetreteten ist. Und wenn der Prozess vorhanden ist und kein Fehler auftritt, dann macht er weiter.
03/17/2012 16:16 jacky919#20
Nein ich meine:
PHP Code:
#RequireAdmin
#include <NoMadMemory.au3>

HotKeySet("{F1}""_Read")

$PID ProcessExists("aion.bin")
If 
$PID 0 Then
    $Handle 
_MemoryOpen($PID)
    
$Address _MemoryModuleGetBaseAddress(ProcessExists("aion.bin"), "Game.dll")
    
MsgBox(0"error", @error)
    
$Address "0x" Hex($Address Dec("9C01C"))
    
Dim $Offset[2] = [0,0x4]
Else
    Exit
EndIf

While 
True
    Sleep
(10)
WEnd

Func _Read
()
    
$Read _PointerRead($Address$Handle$Offset"float")
    
MsgBox(0""$Read[1])
EndFunc 
03/17/2012 16:20 Masterscripter#21
Code:
MsgBox(0, "error", @error)
Das steht doch garnich in meinem Script.
03/17/2012 16:22 jacky919#22
Deswegen sollst du es ja ausprobieren und mir sagen was ausgegeben wird ;)
03/17/2012 16:53 Masterscripter#23
Okay habs ausprobiert und dann kommt die Meldung:

"Error"

und in der Msgbox steht -1
03/17/2012 17:06 jacky919#24
Das Modul scheint nicht gefunden worden zu sein.

Code:
Func _MemoryModuleGetBaseAddress($iPID, $sModule)
    If Not ProcessExists($iPID) Then Return SetError(1, 0, 0)

    If Not IsString($sModule) Then Return SetError(2, 0, 0)

    Local   $PSAPI = DllOpen("psapi.dll")

    ;Get Process Handle
    Local   $hProcess
    Local   $PERMISSION = BitOR(0x0002, 0x0400, 0x0008, 0x0010, 0x0020) ; CREATE_THREAD, QUERY_INFORMATION, VM_OPERATION, VM_READ, VM_WRITE

    If $iPID > 0 Then
        Local $hProcess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $PERMISSION, "int", 0, "dword", $iPID)
        If $hProcess[0] Then
            $hProcess = $hProcess[0]
        EndIf
        MsgBox(0, "process", "Process Handle = " & $hProcess[0])
    EndIf

    ;EnumProcessModules
    Local   $Modules = DllStructCreate("ptr[1024]")
    Local   $aCall = DllCall($PSAPI, "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($Modules), "dword", DllStructGetSize($Modules), "dword*", 0)
    If $aCall[4] > 0 Then
        Local   $iModnum = $aCall[4] / 4
        Local   $aTemp
        $sModules = ""
        For $i = 1 To $iModnum
            $aTemp =  DllCall($PSAPI, "dword", "GetModuleBaseNameW", "ptr", $hProcess, "ptr", Ptr(DllStructGetData($Modules, 1, $i)), "wstr", "", "dword", 260)
            $sModules &= $aTemp[3] &  @crlf
            If $aTemp[3] = $sModule Then
                DllClose($PSAPI)
                Return Ptr(DllStructGetData($Modules, 1, $i))
            EndIf
        Next
        MsgBox(0, "modules", $sModules)
    EndIf

    DllClose($PSAPI)
    Return SetError(-1, 0, 0)

EndFunc
Guck mal was so ausgegeben wird und ob auch dein Modul ausgegeben wird.
03/17/2012 17:10 Masterscripter#25
Okay. Tut mir leid, aber ich weiß nicht genau was ich jetzt machen soll. Wie meinst du das?
03/17/2012 17:12 jacky919#26
Ich habe ein wenig was an der _MemoryModuleGetBaseAddress verändert. Probier sie mal aus und berichte ir von den Ausgaben :)
03/17/2012 17:16 Masterscripter#27
Hmm also jetzt kommt ne Fehlermeldung:

[Only registered and activated users can see links. Click Here To Register...]

Uploaded with [Only registered and activated users can see links. Click Here To Register...]
03/17/2012 17:24 jacky919#28
Dann haben wir unseren Schuldigen gefunden :)
PHP Code:
Local $hProcess DllCall("kernel32.dll""ptr""OpenProcess""dword"$PERMISSION"int"0"dword"$iPID
DllCall sollte ein Array zurückgeben. Das erste Element ist der Rückgabewert der Funktion, die mit DllCall aufgerufen wurde. Folglich, davon ausgegangen, dass nicht auf das erste Element zugegriffen werden kann, ist etwas schief gegangen.
03/17/2012 17:34 Masterscripter#29
Hmm okay. Und was nun? Gibt es irgendeine andere Möglichkeit?
03/17/2012 18:05 jacky919#30
Lass dir mal @error nach dem Aufruf ausgeben.