Need help with KDMemory reading

05/20/2014 21:16 LiveLong23#1
Hi i have tried this au3 file and seems to me that it dont work or i didnt make script to work :(. Its first time for me to work with memory so i need a bit help

i get "@error:15, @extended:1" error

here is my script

Code:
#AutoIt3Wrapper_UseX64=y ; 64 Bit application

#RequireAdmin
#include "KDMemory.au3"

If @AutoItX64 == 0 Then
    MsgBox(48, "Error", "Unsupported system")
    Exit
EndIf

Const $processName = "AlefClient.exe", $moduleName = $processName
Const $baseOffset = 0x0055D834
Const $offsets[5] = [0x72c, 0x18c, 0x48, 0x6c0, 0x25c]

$processId = ProcessExists($processName)
If $processId == 0 Then
    MsgBox(48, "Error", "'" & $processName & "' is not running!")
Else
    $handles = _KDMemory_OpenProcess($processId)
    If @error Then
        MsgBox(48, "Error", "Can't open '" & $processName & "'!" & @CRLF & "@error: " & @error)
    Else
        $baseAddress = _KDMemory_GetModuleBaseAddress($handles, $moduleName, 0, 0) + $baseOffset
        If @error Then
            MsgBox(48, "Error", "Can't get ModuleBaseAddress ('" & $moduleName & "')!" & @CRLF & "@error: " & @error & ", @extended: " & @extended)
        Else
			; test
			MsgBox(0, "Module base address", $baseAddress) ; returns 0x000000000095d834

            $memoryData = _KDMemory_ReadProcessMemory($handles, $baseAddress, "DWORD", $offsets)
            If @error Then
                MsgBox(48, "Error", "Can't read memory!" & @CRLF & "@error: " & @error & ", @extended: " & @extended)
            Else
                MsgBox(64, "Info", "Address: " & $memoryData[0] & @CRLF & "Value: " & $memoryData[1])
            EndIf
        EndIf
        _KDMemory_CloseHandles($handles)
    EndIf
EndIf

CE scan
<CheatEntry>
<ID>11</ID>
<Description>"pointerscan result"</Description>
<Color>80000008</Color>
<VariableType>4 Bytes</VariableType>
<Address>"AlefClient.exe"+0055D834</Address>
<Offsets>
<Offset>72C</Offset>
<Offset>18C</Offset>
<Offset>48</Offset>
<Offset>6C0</Offset>
<Offset>25C</Offset>
</Offsets>
</CheatEntry>

Is maybe problem here $moduleName = "AlefClient.exe" because this game not use module like Aion as i saw on this forum

EDIT:
Im running windows 7 64 bit, tried compile app like 64 bit and run as admin still no sucess, but in CE it show right value and its 4byte

"AlefClient.exe"+0055D834
offsets: 72C, 18C, 48, 6C0, 25C

And process name AlefClient.exe *32

EDIT 2 UPDATED CODE + pic

Here is image with all running

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

Code:
#RequireAdmin
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include "KDMemory.au3"

GUICreate("Form 1", 195, 235)
GUICtrlCreateGroup("Current hp", 8, 8, 177, 53)
$mobHP = GUICtrlCreateInput("", 15, 32, 161, 21, $ES_READONLY)
GUICtrlCreateGroup("Status", 8, 74, 177, 53)
$gameStatus = GUICtrlCreateInput("Game is not running.", 15, 98, 161, 21, $ES_READONLY)
GUISetState()

Global $processName = "AlefClient.exe", $handles = 0, $address = 0
Global $baseOffsetMobHp = 0x0055D834
Global $offsetsHP[5] = [0x72c, 0x18c, 0x48, 0x6c0, 0x25c]

While Sleep(10)
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch

	; is game running
    $processId = ProcessExists($processName)
    If $processId == 0 Then
        If IsArray($handles) Then
            GUICtrlSetData($gameStatus, "Game is not running.")
            _KDMemory_CloseHandles($handles)
            $handles = 0
            $address = 0
        EndIf
        ContinueLoop
    EndIf

	; opens memory
	If $handles == 0 Then
		$handles = _KDMemory_OpenProcess($processId)
        If @error Then
            If MsgBox(52, "Error", "Can't open " & $processName & "! @error: " & @error & @CRLF & "Continue?") == 6 Then
                $handles = 0
                ContinueLoop
            Else
                Exit
            EndIf
        Else
            GUICtrlSetData($gameStatus, "Game is running (PID = " & $processId & ").")
        EndIf
    EndIf

	If $address == 0 Then
        $address = _KDMemory_GetModuleBaseAddress($handles, $processName) + $baseOffsetMobHp
        If @error Then
            If MsgBox(52, "Error", "Can't get ModuleBaseAddress! @error: " & @error & ", @extended: " & @extended & @CRLF & "Continue?") == 6 Then
                $address = 0
                ContinueLoop
            Else
                Exit
            EndIf
        EndIf
    EndIf

	; read memory from process
	$memoryData = _KDMemory_ReadProcessMemory($handles, $address, "DWORD", $offsetsHP)
    If Not @error Then
        If GUICtrlRead($mobHP) <> $memoryData[1] Then GUICtrlSetData($mobHP, $memoryData[1])
    EndIf

WEnd
05/22/2014 17:48 KDeluxe#2
Quote:
Originally Posted by LiveLong23 View Post
i get "@error:15, @extended:1" error
This error (@error) indicates the function failed while trying to get the pointer at the first offset (@extended). This information should be enough to google a solution.
You could even find the error without any information from the script. You just don't know how CE works. The error has nothing to do with my UDF, it works fine.

Quote:
Originally Posted by LiveLong23 View Post
Code:
Const $offsets[5] = [0x72c, 0x18c, 0x48, 0x6c0, 0x25c]
Seems to be correct, right? No! Can you find the error? No? I'll give you a hint: the first offset is the last offset and the last offset is the first offset.

Quote:
Originally Posted by LiveLong23 View Post
And process name AlefClient.exe *32
"*32" indicates that the process is a 32 bit process. You should compile your script as a 32 bit application for compatibility reasons.

05/22/2014 18:23 LiveLong23#3
Still error i tried 64 32 bit compiled or not compiled all ways and here is result

Here is pic of error [Only registered and activated users can see links. Click Here To Register...]

I found how to run it, because game must run under sanbox, first i run the game sandboxed and then compiled 32 bit script and now works.