Help with reading memory with offsets from game

11/18/2013 19:37 mlukac89#1
As title say
I have next problem, i have base pointer + adress for solitaire on windows xp 32 bit

but when i enter it in script it returns me 0, but when i start computer and reload cheat engine it shows exact values from game

here is code

Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <NomadMemory.au3>

$GUI = GUICreate("Test memory", 230, 57, 344, 300)
$score = GUICtrlCreateLabel("Curent score : ", 10, 6, 70, 17)
$displayScore = GUICtrlCreateLabel("", 80, 6, 98, 17)
$gameRunning = GUICtrlCreateLabel("", 8, 30, 134, 17)
GUISetState(@SW_SHOW)

$PID = ProcessExists("sol.exe")
$address = 0x000A9510 ; adress for score

Dim $offset[2] = [0, 0x30] ; offset

#cs
<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
  <CheatEntries>
    <CheatEntry>
      <ID>11</ID>
      <Description>"pointerscan result"</Description>
      <Color>80000008</Color>
      <VariableType>4 Bytes</VariableType>
      <Address>"sol.exe"+00007170</Address>
      <Offsets>
        <Offset>30</Offset>
      </Offsets>
    </CheatEntry>
  </CheatEntries>
</CheatTable>
#ce

_checkprocess()

While 1

	_getscore()

	$nMsg = GUIGetMsg()

	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch
WEnd

Func _getscore()

	$memOpen = _MemoryOpen($PID)
	$val = _MemoryRead($address, $memOpen, 'dword') ; for this it returns me 16798882
	$val2 = _MemoryPointerRead($address, $memOpen, $offset[1]) ; for this returns me 0

	ConsoleWrite($val & @CRLF & $val2)

	;GUICtrlSetData($displayScore, $val)

	_MemoryClose($memOpen)

EndFunc

Func _checkprocess()
	If $PID = 1 Then
		GUICtrlSetData($gameRunning, "Game is running")
	ElseIf $PID = 0 Then
		GUICtrlSetData($gameRunning, "Game is not running")
	EndIf
EndFunc
11/18/2013 19:40 alpines#2
Because _MemoryPointerRead returns an array where the last entry contains the value you want.
Code:
$aPointerValues = _MemoryPointerRead(...)

MsgBox(64, "", $aPointerValues[UBound($aPointerValues) - 1])
11/18/2013 19:44 Paraly#3
try this

Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <NomadMemory.au3>

$GUI = GUICreate("Test memory", 230, 57, 344, 300)
$score = GUICtrlCreateLabel("Curent score : ", 10, 6, 70, 17)
$displayScore = GUICtrlCreateLabel("", 80, 6, 98, 17)
$gameRunning = GUICtrlCreateLabel("", 8, 30, 134, 17)
GUISetState(@SW_SHOW)

$PID = ProcessExists("sol.exe")
$address = 0x000A9510 ; adress for score

Dim $offset[1] = [ 0x30] ; offset

#cs
<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
  <CheatEntries>
    <CheatEntry>
      <ID>11</ID>
      <Description>"pointerscan result"</Description>
      <Color>80000008</Color>
      <VariableType>4 Bytes</VariableType>
      <Address>"sol.exe"+00007170</Address>
      <Offsets>
        <Offset>30</Offset>
      </Offsets>
    </CheatEntry>
  </CheatEntries>
</CheatTable>
#ce

_checkprocess()

While 1

	_getscore()

	$nMsg = GUIGetMsg()

	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch
WEnd

Func _calc_offset()
	$address = 0x000A9510
	$var = 0
	do
		$address = _MemoryRead($address, $memOpen) + $offset[$var]
		$var = $var + 1
	until $var = UBound($offset)
EndFunc

Func _getscore()

	$memOpen = _MemoryOpen($PID)
	_calc_offset()
	$val = _MemoryRead($address, $memOpen, 'dword') ; for this it returns me 16798882
	$val2 = _MemoryPointerRead($address, $memOpen, $offset[1]) ; for this returns me 0

	ConsoleWrite($val & @CRLF & $val2)

	;GUICtrlSetData($displayScore, $val)

	_MemoryClose($memOpen)

EndFunc

Func _checkprocess()
	If $PID = 1 Then
		GUICtrlSetData($gameRunning, "Game is running")
	ElseIf $PID = 0 Then
		GUICtrlSetData($gameRunning, "Game is not running")
	EndIf
EndFunc
11/18/2013 19:45 mlukac89#4
ah with that code my program just open and close it wont stay opened

maybe i have wrong NomadMemory ?

here it is


i get this error

C:\Documents and Settings\tea\Desktop\solitaire memory hack\test.au3 (65) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$val2 = _MemoryPointerRead($address, $memOpen, $offset[1])
$val2 = _MemoryPointerRead($address, $memOpen, ^ ERROR
11/18/2013 20:07 alpines#5
Because $offset is one size big and you request the 2nd entry.
By the way the first entry has to be zero. So $offsets[2] [0, offset] would be correct.
11/18/2013 20:21 mlukac89#6
thx for that but i know for arrays and it is like that i fixed it now but im still on 0 result idk what to do anymore :(
11/19/2013 18:40 berkay2578#7
It's sol.exe+7170 not 0xA9510..
11/19/2013 19:42 BladeTiger12#8
Try that:

Include by KDeluxe: [Only registered and activated users can see links. Click Here To Register...]

Code:
;#AutoIt3Wrapper_UseX64=y ;For 64Bit Process Memory
#RequireAdmin
#include <KDMemory.au3>

Local $pID, $hHandle, $iBase, $mName, $iStatAddr
Dim $iOffsets[1] = [ 0x30 ]

$iStatAddr = 0x00007170

$mName = "sol.exe"

$pID = ProcessExists($mName)

$hHandle = _KDMemory_OpenProcess($pID)

$iBase = _KDMemory_GetModuleBaseAddress($hHandle, $mName) + $iStatAddr

$iRead = _KDMemory_ReadProcessMemory($hHandle, $iBase, 'DWORD', $iOffsets)
11/19/2013 22:11 KDeluxe#9
11/20/2013 00:08 mlukac89#10
@BladeTiger12
your code return me FALSE

@KDeluxe
your code give me this error

[Only registered and activated users can see links. Click Here To Register...]
11/20/2013 13:01 KDeluxe#11
The [Only registered and activated users can see links. Click Here To Register...] call fails, but you need a similar function to get the module address. The address is "sol.exe"+00007170 and not 000A9510. The module address is not static for Solitaire.
11/20/2013 13:56 mlukac89#12
ok but how do i implement that "sol.exe"+0007170 in script to show me current score ?
11/20/2013 15:07 KDeluxe#13
Quote:
Originally Posted by KDeluxe View Post
But
Quote:
Originally Posted by KDeluxe View Post
The [Only registered and activated users can see links. Click Here To Register...] call fails
I can't help you because I don't know what error occurs. Replace the _KDMemory_GetModuleBaseAddress() function in the KDMemory.au3 with
The MsgBox will show you the error. I need the @error code and the @extended code.
11/20/2013 15:34 mlukac89#14
I replaced that code you gived me in KDMemory.au3

and now msg box says

Can't get ModuleBaseAdress! @error:21 @extended:6
11/20/2013 16:48 KDeluxe#15
[Only registered and activated users can see links. Click Here To Register...]

Try it with another access right. Replace
Code:
$handles = _KDMemory_OpenProcess($processId)
with
Code:
$handles = _KDMemory_OpenProcess($processId, 0, 0x001F0FFF)