[AutoIT] Subscript used on non-accessible variable.

02/19/2020 01:59 b0sted#1
Hi,
I have a problem :/

Here is my code:
Code:
#RequireAdmin
#include "KDMemory.au3"

Const $processName = "s4c.exe", $moduleName = $processName
Const $baseOffset = 0x017293C0
Const $offsets[7] = [0x684, 0xF4, 0xE0, 0x3C, 0x0, 0x17C, 0xFC]

$processId = ProcessExists($processName)
$handles = _KDMemory_OpenProcess($processId)
$baseAddress = _KDMemory_GetModuleBaseAddress($handles, $moduleName) + $baseOffset

$memoryData = _KDMemory_ReadProcessMemory($handles, $baseAddress, "FLOAT", $offsets)
MsgBox(64, 'Result', 'Value: ' & $memoryData[1])
_KDMemory_CloseHandles($handles)
I receive this error after running the code: Subscript used on non-accessible variable.
02/19/2020 04:09 elmarcia#2
$memoryData isn't assigned with an array because some error is happening, so you need to see whats wrong first, you can log the error code with @error, maybe your offsets are wrong, it may happen if you forgot to reverse the order that you get in cheat engine.

Const $offsets[7] = [0xFC,0x17C,0x0,0x3C,0xE0,0xF4,0x684]
02/19/2020 13:28 b0sted#3
Quote:
Originally Posted by elmarcia View Post
$memoryData isn't assigned with an array because some error is happening, so you need to see whats wrong first, you can log the error code with @error, maybe your offsets are wrong, it may happen if you forgot to reverse the order that you get in cheat engine.

Const $offsets[7] = [0xFC,0x17C,0x0,0x3C,0xE0,0xF4,0x684]
I changed the order of the offsets, but its still not working.
I added an error-if, my code looks like this now:

Code:
#RequireAdmin
#include "KDMemory.au3"

Const $processName = "S4Client.exe", $moduleName = $processName
Const $baseOffset = 0x017293C0
Const $offsets[7] = [0xFC,0x17C,0x0,0x3C,0xE0,0xF4,0x684]

$processId = ProcessExists($processName)
$handles = _KDMemory_OpenProcess($processId)
$baseAddress = _KDMemory_GetModuleBaseAddress($handles, $moduleName) + $baseOffset

$memoryData = _KDMemory_ReadProcessMemory($handles, $baseAddress, "FLOAT", $offsets)
if(@error) Then
MsgBox(48, "Error", "Can't read memory!" & @CRLF & "@error: " & @error & ", @extended: " & @extended)
Else
MsgBox(64, 'Result', 'Value: ' & $memoryData[0])
_KDMemory_CloseHandles($handles)
EndIf
And my Cheat Engine Entry looks like this:
[Only registered and activated users can see links. Click Here To Register...]

This is the error-code now:
[Only registered and activated users can see links. Click Here To Register...]
02/20/2020 16:11 elmarcia#4
It should work, check your pointer path to see if its working.
Check individual addresses to see if they point to where they should.
Check your base address.

Ex:
Code:
$res = _KDMemory_ReadProcessMemory($handles,$baseAddress,"int")
;Should be *147142408‬ -> 8C53708 (from cheat engine window bottom address)

msgbox(0,"base address points to",$res[0])
$next_addr = $res[0]
for $i = 0 to ubound($offsets) - 1
$next =  _KDMemory_ReadProcessMemory($handles,$next_addr + $offsets[$i],"int")
msgbox(0,"next address points to","0x"&hex($next[0],8))
$next_addr = $next[0]
next
05/17/2020 18:29 0N1K4G3#5
I don't recommend KDMemory, use normal Memory instead, if you don't know how just pm me or reply i'll help you when i see ur message