Question About Autoit WriteAndRead Memory Data

05/22/2013 18:55 Chriko2502#1
Hi out there,

hope u can help me :) and also hopefully this is the right section....

I wanted to make an easy to use script/programm for people to display a lot of stuff from GW2, like memory adresses, their values, etc...

i tried to translate my c++ code into Autoit, because i think more people will understand this and i didn't want to make my complete source public...

but i failed @ memory writing and reading
See Source... I dindt know why i will not work -.- patterns and so on are ok...

Hope u can help me at the start with reading and writing memory with Autoit so that i can finish my work. One example (perhaps with attached code) would be nice!

THX Chriko2502
05/23/2013 00:10 sitapea1337#2
For memory reading in Autoit - use for example NomadMemory. There are others as well - just try them out.
05/23/2013 08:25 Chriko2502#3
Quote:
Originally Posted by sitapea1337 View Post
For memory reading in Autoit - use for example NomadMemory. There are others as well - just try them out.
Yeah i tried but it didnt work and i dont know why :( Look @ attached files...
Whats wrong?!

Code:
Global Const $aProcessname = "gw2.exe"

Global Const $BasePattern = "\xD9\x85\x78\xFF\xFF\xFF\xD8\x65\xCC\x8B\x15"
Global Const $BaseMask = "xxxxxxxxxxx"
Global Const $BaseOffset = 0x11

Global $HPID =_MemoryOpen(ProcessExists($aProcessname))
Global $Base = _MemoryScanEx($HPID,$BasePattern,$BaseMask) + 0x104 - 0x400000

Global Const $Offset_PosX[4] = [Dec("44"), Dec("1C"), Dec("5C"), Dec("B4")]
Global Const $Offset_PosY[4] = [Dec("44"), Dec("1C"), Dec("5C"), Dec("B8")]
Global Const $Offset_PosZ[4] = [Dec("44"), Dec("1C"), Dec("88"), Dec("D8")]

Global Const $Offset_Speed[4] = [Dec("44"), Dec("1C"), Dec("5C"), Dec("114")]


MsgBox(0, "Basepointer", StringFormat("%x", $Base))


$ValueCoordX = _MemoryPointerRead ((0x400000 + $Base), $HPID, $Offset_PosX, "float")
MsgBox(0, "$ValueCoordX: ", "$ValueCoordX: " + $ValueCoordX)


$SpeedValue = 100
_MemoryPointerWrite ((0x400000 + $Base), $HPID, $Offset_Speed, $SpeedValue, "float")
05/23/2013 10:38 buFFy!#4
NomadMemory.au3:

Code:
$ProcessId = ProcessExists("Gw2.exe")
$hProcess = _MemoryOpen($ProcessId)

$val = _MemoryRead($address, $hProcess,  'dword')
_MemoryWrite($address, $hProcess, $val + 1000, 'dword')

_MemoryClose($hProcess)
I wouldn't use the pointer functions. Rather write your own ReadPtrChain

For finding patterns you can use this function.
I'm not the author of this function, thus the credits go to "Luzifer42" !

Code:
Func FindPattern($ah_Handle, $pattern, $after = False, $iv_addrStart = 0x00400000, $iv_addrEnd = 0X00FFFFFF, $step = 51200)
	If Not IsArray($ah_Handle) Then
		SetError(1)
		Return -1
	EndIf
	$pattern = StringRegExpReplace($pattern, "[^0123456789ABCDEFabcdef.]", "")
	If StringLen($pattern) = 0 Then
		SetError(2)
		Return -2
	EndIf
	For $addr = $iv_addrStart To $iv_addrEnd Step $step - (StringLen($pattern) / 2)
		StringRegExp(_MemoryRead($addr, $ah_Handle, "byte[" & $step & "]"), $pattern, 1, 2)
		If Not @error Then
			If $after Then
				Return StringFormat("0x%.8X", $addr + ((@extended - 2) / 2))
			Else
				Return StringFormat("0x%.8X", $addr + ((@extended - StringLen($pattern) - 2) / 2))
			EndIf
		EndIf
	Next
	Return -3
EndFunc   ;==>FindPattern
Heres another thing. Guildwars is devided into classes, obviously. When reading/writing to for example the speed address, you are right now reading the entire pointer chain.

Instead, you should just read it once (ChContext->Character->Agent->World->EntityInWorld->Speed)
and save the Character from it. The next time when attempting to write to the speed address, you want to check whether the Character has changed. If so, just read the entire ptr chain again.

I noticed that you are reading your "Base" + 44h. Your base obviously holds a ptr to your current character, because 44h is for Agent and Agent+1Ch is World.

So, just check whether the value of your Base has changed.

AutoIT is slow as fuck and i really recommend doing that.
Just my 2 cents :)
05/23/2013 11:00 Mostey#5
#moved