syron Posted February 10, 2008 Posted February 10, 2008 Hi guys, I'm pretty new to AutoIt. I was making a little tool for a game. It should read out the HP, MP and so on. I've got pointers and so on, but I dont really know how to put that into my script. I attached a picture which shows what's the pointer and the offset, please help me to find out what do write in my script, I mean the 0xDATAS to get my script working. It works with those addresses which r generated when the game starts, but when I put the pointers / offset into my script it doesnt work! On the screenshot u see the current hp stuff and in the script is the variable called $CurHpOffset. Thanks in advantage! expandcollapse popup#Include <Memory.au3> Global $Pointer = 0x008F71DC Global $CurHpOffset = 0x450 Global $CurMpOffset = 0x454 Global $CurEpOffset = 0x458 Global $CurSpOffset = 0x45C HotKeySet("{F6}", "GetInfo") While 1 WEnd Func GetInfo() Global $Process = WinGetProcess("Element Client") ; HP Anzeige Global $DllInfo1 = _MemoryOpen($Process) $CurHpAdd = _FindNewAddress($Pointer, $CurHpOffset) $CurHp = _MemoryRead($CurHpAdd, $DllInfo1) _MemoryClose($Process) ; MP Anzeige Global $DllInfo1 = _MemoryOpen($Process) $CurMpAdd = _FindNewAddress($Pointer, $CurMpOffset) $CurMp = _MemoryRead($CurMpAdd, $DllInfo1) _MemoryClose($Process) ; EP Anzeige Global $DllInfo1 = _MemoryOpen($Process) $CurEpAdd = _FindNewAddress($Pointer, $CurEpOffset) $CurEp = _MemoryRead($CurEpAdd, $DllInfo1) _MemoryClose($Process) ; SP Anzeige Global $DllInfo1 = _MemoryOpen($Process) $CurSpAdd = _FindNewAddress($Pointer, $CurSpOffset) $CurSp = _MemoryRead($CurSpAdd, $DllInfo1) _MemoryClose($Process) MsgBox(64, "Your character info:", "Your character`s hp: " & $CurHp) MsgBox(64, "Your character info:", "Your character`s mp: " & $CurMp) MsgBox(64, "Your character info:", "Your character`s exp: " & $CurEp) MsgBox(64, "Your character info:", "Your character`s sp: " & $CurSp) EndFunc Func _FindNewAddress(ByRef $Pointer, ByRef $OSet) $New_Address = _MemoryRead($Pointer, $DllInfo1) + $OSet Return $New_Address EndFunc
BrettF Posted February 10, 2008 Posted February 10, 2008 Not sure why this would happen, but does the pointers change at any point whilst running the game? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
syron Posted February 10, 2008 Author Posted February 10, 2008 no, the pointer doesn't change. it always points me to the right address in CheatEngine, even if I restart the game
BrettF Posted February 10, 2008 Posted February 10, 2008 no, the pointer doesn't change. it always points me to the right address in CheatEngine, even if I restart the gameOk. How does the following go for you? I played around a bit. For some reason I don't have _MemoryOpen () or _MemoryRead () so I can't even see if it works... expandcollapse popup#include <Memory.au3> ; Declare Vars Global $Pointer = 0x008F71DC Global $CurHpOffset = 0x450 Global $CurMpOffset = 0x454 Global $CurEpOffset = 0x458 Global $CurSpOffset = 0x45C Global $Process = WinGetProcess("Element Client") Global $DllInfo1 ;Set Hotkeys HotKeySet("{F6}", "GetInfo") While 1 ;Sleep to conserve CPU Sleep(10) WEnd Func GetInfo() ;Local $ret[4] ;Open the memory $DllInfo1 = _MemoryOpen($Process) ; HP Anzeige $CurHpAdd = _FindNewAddress($Pointer, $CurHpOffset) $CurHp = _MemoryRead($CurHpAdd, $DllInfo1) ; MP Anzeige $CurMpAdd = _FindNewAddress($Pointer, $CurMpOffset) $CurMp = _MemoryRead($CurMpAdd, $DllInfo1) ; EP Anzeige $CurEpAdd = _FindNewAddress($Pointer, $CurEpOffset) $CurEp = _MemoryRead($CurEpAdd, $DllInfo1) ; SP Anzeige $CurSpAdd = _FindNewAddress($Pointer, $CurSpOffset) $CurSp = _MemoryRead($CurSpAdd, $DllInfo1) ;Close the memory _MemoryClose($Process) ;Display Data MsgBox(64, "Your character info:", "Your character`s hp: " & $CurHp) MsgBox(64, "Your character info:", "Your character`s mp: " & $CurMp) MsgBox(64, "Your character info:", "Your character`s exp: " & $CurEp) MsgBox(64, "Your character info:", "Your character`s sp: " & $CurSp) ;Displayed data could also be returned as so: ;$ret[0] = $CurHp;HP ;$ret[1] = $CurMp;MP ;$ret[2] = $CurEp;EXP ;$ret[3] = $CurSP;SP ;Return $Ret EndFunc ;==>GetInfo Func _FindNewAddress($Pointer, $OSet) $New_Address = _MemoryRead($Pointer, $DllInfo1) + $OSet Return $New_Address EndFunc ;==>_FindNewAddress Is anything running that would block attempts to read the memory? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
syron Posted February 10, 2008 Author Posted February 10, 2008 (edited) well... u might can use it with _MemOpen / _MemRead and so on. nope, nothing blocks it, cuz I disabled everything in the game exe Edited February 10, 2008 by syron
BrettF Posted February 10, 2008 Posted February 10, 2008 well... u might see it using _MemOpen / _MemRead and so on.nope, nothing blocks it, cuz I disabled everything in the game exe No I don't see it. What version AutoIt do you have installed? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
syron Posted February 10, 2008 Author Posted February 10, 2008 No I don't see it. What version AutoIt do you have installed?AutoIt Version 3. well I can easily give you the memory.au3, which I am using... expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.4.9 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include-once #region _Memory ;================================================================================================= ; AutoIt Version: 3.1.127 (beta) ; Language: English ; Platform: All Windows ; Author: Nomad ; Requirements: These functions will only work with beta. ;================================================================================================= ; Credits: wOuter - These functions are based on his original _Mem() functions. But they are ; easier to comprehend and more reliable. These functions are in no way a direct copy ; of his functions. His functions only provided a foundation from which these evolved. ;================================================================================================= ; ; Functions: ; ;================================================================================================= ; Function: _MemoryOpen($iv_Pid[, $iv_DesiredAccess[, $iv_InheritHandle]]) ; Description: Opens a process and enables all possible access rights to the process. The ; Process ID of the process is used to specify which process to open. You must ; call this function before calling _MemoryClose(), _MemoryRead(), or _MemoryWrite(). ; Parameter(s): $iv_Pid - The Process ID of the program you want to open. ; $iv_DesiredAccess - (optional) Set to 0x1F0FFF by default, which enables all ; possible access rights to the process specified by the ; Process ID. ; $if_InheritHandle - (optional) If this value is TRUE, all processes created by ; this process will inherit the access handle. Set to TRUE ; (1) by default. Set to 0 if you want it to be FALSE. ; Requirement(s): A valid process ID. ; Return Value(s): On Success - Returns an array containing the Dll handle and an open handle to ; the specified process. ; On Failure - Returns 0 ; @Error - 0 = No error. ; 1 = Invalid $iv_Pid. ; 2 = Failed to open Kernel32.dll. ; 3 = Failed to open the specified process. ; Author(s): Nomad ; Note(s): ;================================================================================================= Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $if_InheritHandle = 1) If Not ProcessExists($iv_Pid) Then SetError(1) Return 0 EndIf Local $ah_Handle[2] = [DllOpen('kernel32.dll')] If @Error Then SetError(2) Return 0 EndIf Local $av_OpenProcess = DllCall($ah_Handle[0], 'int', 'OpenProcess', 'int', $iv_DesiredAccess, 'int', $if_InheritHandle, 'int', $iv_Pid) If @Error Then DllClose($ah_Handle[0]) SetError(3) Return 0 EndIf $ah_Handle[1] = $av_OpenProcess[0] Return $ah_Handle EndFunc ;================================================================================================= ; Function: _MemoryRead($iv_Address, $ah_Handle[, $sv_Type]) ; Description: Reads the value located in the memory address specified. ; Parameter(s): $iv_Address - The memory address you want to read from. It must be in hex ; format (0x00000000). ; $ah_Handle - An array containing the Dll handle and the handle of the open ; process as returned by _MemoryOpen(). ; $sv_Type - (optional) The "Type" of value you intend to read. This is set to ; 'dword'(32bit(4byte) signed integer) by default. See the help file ; for DllStructCreate for all types. ; An example: If you want to read a word that is 15 characters in ; length, you would use 'char[16]'. ; Requirement(s): The $ah_Handle returned from _MemoryOpen. ; Return Value(s): On Success - Returns the value located at the specified address. ; On Failure - Returns 0 ; @Error - 0 = No error. ; 1 = Invalid $ah_Handle. ; 2 = $sv_Type was not a string. ; 3 = $sv_Type is an unknown data type. ; 4 = Failed to allocate the memory needed for the DllStructure. ; 5 = Error allocating memory for $sv_Type. ; 6 = Failed to read from the specified process. ; Author(s): Nomad ; Note(s): Values returned are in Decimal format, unless specified as a 'char' type, then ; they are returned in ASCII format. Also note that size ('char[size]') for all ; 'char' types should be 1 greater than the actual size. ;================================================================================================= Func _MemoryRead($iv_Address, $ah_Handle, $sv_Type = 'dword') If Not IsArray($ah_Handle) Then SetError(1) Return 0 EndIf Local $v_Buffer = DllStructCreate($sv_Type) If @Error Then SetError(@Error + 1) Return 0 EndIf DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '') If Not @Error Then Local $v_Value = DllStructGetData($v_Buffer, 1) Return $v_Value Else SetError(6) Return 0 EndIf EndFunc ;================================================================================================= ; Function: _MemoryWrite($iv_Address, $ah_Handle, $v_Data[, $sv_Type]) ; Description: Writes data to the specified memory address. ; Parameter(s): $iv_Address - The memory address you want to write to. It must be in hex ; format (0x00000000). ; $ah_Handle - An array containing the Dll handle and the handle of the open ; process as returned by _MemoryOpen(). ; $v_Data - The data to be written. ; $sv_Type - (optional) The "Type" of value you intend to write. This is set to ; 'dword'(32bit(4byte) signed integer) by default. See the help file ; for DllStructCreate for all types. ; An example: If you want to write a word that is 15 characters in ; length, you would use 'char[16]'. ; Requirement(s): The $ah_Handle returned from _MemoryOpen. ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; @Error - 0 = No error. ; 1 = Invalid $ah_Handle. ; 2 = $sv_Type was not a string. ; 3 = $sv_Type is an unknown data type. ; 4 = Failed to allocate the memory needed for the DllStructure. ; 5 = Error allocating memory for $sv_Type. ; 6 = $v_Data is not in the proper format to be used with the "Type" ; selected for $sv_Type, or it is out of range. ; 7 = Failed to write to the specified process. ; Author(s): Nomad ; Note(s): Values sent must be in Decimal format, unless specified as a 'char' type, then ; they must be in ASCII format. Also note that size ('char[size]') for all ; 'char' types should be 1 greater than the actual size. ;================================================================================================= Func _MemoryWrite($iv_Address, $ah_Handle, $v_Data, $sv_Type = 'dword') If Not IsArray($ah_Handle) Then SetError(1) Return 0 EndIf Local $v_Buffer = DllStructCreate($sv_Type) If @Error Then SetError(@Error + 1) Return 0 Else DllStructSetData($v_Buffer, 1, $v_Data) If @Error Then SetError(6) Return 0 EndIf EndIf DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '') If Not @Error Then Return 1 Else SetError(7) Return 0 EndIf EndFunc ;================================================================================================= ; Function: _MemoryClose($ah_Handle) ; Description: Closes the process handle opened by using _MemoryOpen(). ; Parameter(s): $ah_Handle - An array containing the Dll handle and the handle of the open ; process as returned by _MemoryOpen(). ; Requirement(s): The $ah_Handle returned from _MemoryOpen. ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 ; @Error - 0 = No error. ; 1 = Invalid $ah_Handle. ; 2 = Unable to close the process handle. ; Author(s): Nomad ; Note(s): ;================================================================================================= Func _MemoryClose($ah_Handle) If Not IsArray($ah_Handle) Then SetError(1) Return 0 EndIf DllCall($ah_Handle[0], 'int', 'CloseHandle', 'int', $ah_Handle[1]) If Not @Error Then DllClose($ah_Handle[0]) Return 1 Else DllClose($ah_Handle[0]) SetError(2) Return 0 EndIf EndFunc ;================================================================================================= ; Function: _MemoryPointerRead ($iv_Address, $ah_Handle, $av_Offset[, $sv_Type]) ; Description: Reads a chain of pointers and returns an array containing the destination ; address and the data at the address. ; Parameter(s): $iv_Address - The static memory address you want to start at. It must be in ; hex format (0x00000000). ; $ah_Handle - An array containing the Dll handle and the handle of the open ; process as returned by _MemoryOpen(). ; $av_Offset - An array of offsets for the pointers. Each pointer must have an ; offset. If there is no offset for a pointer, enter 0 for that ; array dimension. ; $sv_Type - (optional) The "Type" of data you intend to read at the destination ; address. This is set to 'dword'(32bit(4byte) signed integer) by ; default. See the help file for DllStructCreate for all types. ; Requirement(s): The $ah_Handle returned from _MemoryOpen. ; Return Value(s): On Success - Returns an array containing the destination address and the value ; located at the address. ; On Failure - Returns 0 ; @Error - 0 = No error. ; 1 = $av_Offset is not an array. ; 2 = Invalid $ah_Handle. ; 3 = $sv_Type is not a string. ; 4 = $sv_Type is an unknown data type. ; 5 = Failed to allocate the memory needed for the DllStructure. ; 6 = Error allocating memory for $sv_Type. ; 7 = Failed to read from the specified process. ; Author(s): Nomad ; Note(s): Values returned are in Decimal format, unless a 'char' type is selected. ; Set $av_Offset like this: ; $av_Offset[0] = NULL (not used) ; $av_Offset[1] = Offset for pointer 1 (all offsets must be in Decimal) ; $av_Offset[2] = Offset for pointer 2 ; etc... ; (The number of array dimensions determines the number of pointers) ;================================================================================================= Func _MemoryPointerRead ($iv_Address, $ah_Handle, $av_Offset, $sv_Type = 'dword') If IsArray($av_Offset) Then If IsArray($ah_Handle) Then Local $iv_PointerCount = UBound($av_Offset) - 1 Else SetError(2) Return 0 EndIf Else SetError(1) Return 0 EndIf Local $iv_Data[2], $i Local $v_Buffer = DllStructCreate('dword') For $i = 0 to $iv_PointerCount If $i = $iv_PointerCount Then $v_Buffer = DllStructCreate($sv_Type) If @Error Then SetError(@Error + 2) Return 0 EndIf $iv_Address = '0x' & hex($iv_Data[1] + $av_Offset[$i]) DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '') If @Error Then SetError(7) Return 0 EndIf $iv_Data[1] = DllStructGetData($v_Buffer, 1) ElseIf $i = 0 Then DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '') If @Error Then SetError(7) Return 0 EndIf $iv_Data[1] = DllStructGetData($v_Buffer, 1) Else $iv_Address = '0x' & hex($iv_Data[1] + $av_Offset[$i]) DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '') If @Error Then SetError(7) Return 0 EndIf $iv_Data[1] = DllStructGetData($v_Buffer, 1) EndIf Next $iv_Data[0] = $iv_Address Return $iv_Data EndFunc ;================================================================================================= ; Function: _MemoryPointerWrite ($iv_Address, $ah_Handle, $av_Offset, $v_Data[, $sv_Type]) ; Description: Reads a chain of pointers and writes the data to the destination address. ; Parameter(s): $iv_Address - The static memory address you want to start at. It must be in ; hex format (0x00000000). ; $ah_Handle - An array containing the Dll handle and the handle of the open ; process as returned by _MemoryOpen(). ; $av_Offset - An array of offsets for the pointers. Each pointer must have an ; offset. If there is no offset for a pointer, enter 0 for that ; array dimension. ; $v_Data - The data to be written. ; $sv_Type - (optional) The "Type" of data you intend to write at the destination ; address. This is set to 'dword'(32bit(4byte) signed integer) by ; default. See the help file for DllStructCreate for all types. ; Requirement(s): The $ah_Handle returned from _MemoryOpen. ; Return Value(s): On Success - Returns the destination address. ; On Failure - Returns 0. ; @Error - 0 = No error. ; 1 = $av_Offset is not an array. ; 2 = Invalid $ah_Handle. ; 3 = Failed to read from the specified process. ; 4 = $sv_Type is not a string. ; 5 = $sv_Type is an unknown data type. ; 6 = Failed to allocate the memory needed for the DllStructure. ; 7 = Error allocating memory for $sv_Type. ; 8 = $v_Data is not in the proper format to be used with the ; "Type" selected for $sv_Type, or it is out of range. ; 9 = Failed to write to the specified process. ; Author(s): Nomad ; Note(s): Data written is in Decimal format, unless a 'char' type is selected. ; Set $av_Offset like this: ; $av_Offset[0] = NULL (not used, doesn't matter what's entered) ; $av_Offset[1] = Offset for pointer 1 (all offsets must be in Decimal) ; $av_Offset[2] = Offset for pointer 2 ; etc... ; (The number of array dimensions determines the number of pointers) ;================================================================================================= Func _MemoryPointerWrite ($iv_Address, $ah_Handle, $av_Offset, $v_Data, $sv_Type = 'dword') If IsArray($av_Offset) Then If IsArray($ah_Handle) Then Local $iv_PointerCount = UBound($av_Offset) - 1 Else SetError(2) Return 0 EndIf Else SetError(1) Return 0 EndIf Local $iv_StructData, $i Local $v_Buffer = DllStructCreate('dword') For $i = 0 to $iv_PointerCount If $i = $iv_PointerCount Then $v_Buffer = DllStructCreate($sv_Type) If @Error Then SetError(@Error + 3) Return 0 EndIf DllStructSetData($v_Buffer, 1, $v_Data) If @Error Then SetError(8) Return 0 EndIf $iv_Address = '0x' & hex($iv_StructData + $av_Offset[$i]) DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '') If @Error Then SetError(9) Return 0 Else Return $iv_Address EndIf ElseIf $i = 0 Then DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '') If @Error Then SetError(3) Return 0 EndIf $iv_StructData = DllStructGetData($v_Buffer, 1) Else $iv_Address = '0x' & hex($iv_StructData + $av_Offset[$i]) DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '') If @Error Then SetError(3) Return 0 EndIf $iv_StructData = DllStructGetData($v_Buffer, 1) EndIf Next EndFunc #endregion
martin Posted February 10, 2008 Posted February 10, 2008 @syron The UDF you call Memory.au3 is actually NomadMemory.au3. It might be better to rename it to avoid future confusion with Memory.au3 which is supplied with AutoIt. The function you have to calculate the memory address is possibly the problem. This is how I calculate the new memory address from the base address and an offset Func AddrCalc($StartAddr, $Offset) Return '0x' & Hex(number($StartAddr) + $Offset, 8) EndFunc It looks unecessarily complicated but I've been using it for a long time with no problems. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
BrettF Posted February 10, 2008 Posted February 10, 2008 Ah. You should have said it wasn't an AutoIt include. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
syron Posted February 10, 2008 Author Posted February 10, 2008 (edited) @syron The UDF you call Memory.au3 is actually NomadMemory.au3. It might be better to rename it to avoid future confusion with Memory.au3 which is supplied with AutoIt. The function you have to calculate the memory address is possibly the problem. This is how I calculate the new memory address from the base address and an offset Func AddrCalc($StartAddr, $Offset) Return '0x' & Hex(number($StartAddr) + $Offset, 8) EndFunc It looks unecessarily complicated but I've been using it for a long time with no problems.Does that mean, that I should replace the "_FindNewAddress" function with your "AddrCalc" function? sry Im pretty new to working with addresses, hope you understand it. and if I should replace it, could u show me how it should look like? Edited February 10, 2008 by syron
BrettF Posted February 10, 2008 Posted February 10, 2008 (edited) Does that mean, that I should replace the "_FindNewAddress" function with your "AddrCalc" function?sry Im pretty new to working with addresses, hope you understand it. and if I should replace it, could u show me how it should look like?Yes. Just replace all contents of you func with the return line that was posted. Edited February 10, 2008 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
syron Posted February 10, 2008 Author Posted February 10, 2008 That's how it looks like now just replaced the code in the function. but it doesnt work :/ it should read out "1335" Hp and the msgbox gives me "16" #Include <NomadMemory.au3> Global $Pointer = 0x008F71DC Global $CurHpOffset = 0x450 Global $CurMpOffset = 0x454 Global $CurEpOffset = 0x458 Global $CurSpOffset = 0x45C HotKeySet("{F6}", "GetInfo") While 1 WEnd Func GetInfo() Global $Process = WinGetProcess("Element Client") ; HP Anzeige Global $DllInfo1 = _MemoryOpen($Process) $CurHpAdd = _FindNewAddress($Pointer, $CurHpOffset) $CurHp = _MemoryRead($CurHpAdd, $DllInfo1) _MemoryClose($Process) MsgBox(64, "Your character info:", "Your character`s hp: " & $CurHp) EndFunc Func _FindNewAddress($Pointer, $Oset) Return '0x' & Hex(number($Pointer) + $Oset, 8) EndFunc
martin Posted February 10, 2008 Posted February 10, 2008 (edited) That's how it looks like now just replaced the code in the function. but it doesnt work :/ it should read out "1335" Hp and the msgbox gives me "16" #Include <NomadMemory.au3> Global $Pointer = 0x008F71DC Global $CurHpOffset = 0x450 Global $CurMpOffset = 0x454 Global $CurEpOffset = 0x458 Global $CurSpOffset = 0x45C HotKeySet("{F6}", "GetInfo") While 1 WEnd Func GetInfo() Global $Process = WinGetProcess("Element Client") ; HP Anzeige Global $DllInfo1 = _MemoryOpen($Process) $CurHpAdd = _FindNewAddress($Pointer, $CurHpOffset) $CurHp = _MemoryRead($CurHpAdd, $DllInfo1) _MemoryClose($Process) MsgBox(64, "Your character info:", "Your character`s hp: " & $CurHp) EndFunc Func _FindNewAddress($Pointer, $Oset) Return '0x' & Hex(number($Pointer) + $Oset, 8) EndFunc The memory address has to be the memory address pointed to by the pointer not the address of the pointer. 0x008F71DC is the address of the pointer, you want the contents. Ah, now I see what your function was doing. Sorry I misunderstood. Try doing this then Func _FindNewAddress($Pointer, $Oset) Return '0x' & Hex(_MemoryRead($Pointer,$DllInfo1) + $Oset, 8) EndFunc Edited February 10, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
syron Posted February 10, 2008 Author Posted February 10, 2008 (edited) well... it gives me 7929939 instead of 1335 :/ Take a look at the screenshot on my first post, could be there a problem of taking the addresses into the Autoit code? Edited February 10, 2008 by syron
BrettF Posted February 10, 2008 Posted February 10, 2008 Try make the offset a whole number maybe? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
syron Posted February 10, 2008 Author Posted February 10, 2008 Try make the offset a whole number maybe?you mean 0x00000450 instead of 0x450 ? Already tried it. No difference :/
MerkurAlex Posted February 10, 2008 Posted February 10, 2008 (edited) Im also new to memory reading but couldnt you just use the _memoryreadpointer() function inside the NomadMemory.au3? Edited February 10, 2008 by EagleClaw [quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]
Siao Posted February 10, 2008 Posted February 10, 2008 (edited) Seriously, if you have no clue about these things, you should just forget about it and do something else. This way will be safer for you and everyone else. Or at least start from reading the documentation of that software (Cheat Engine?). Because it's pretty obvious you aren't even familiar with that screenshot you posted, and it has nothing to do with AutoIt. It's evident that you should read memory at 0x8f71dc to get the address of a pointer (0x52a31b0 in the example). Then read that memory to get the address of the data struct (0x51d4838 in the example). And only then add the offset 0x450 to read what you want to read. Edited February 10, 2008 by Siao "be smart, drink your wine"
syron Posted February 10, 2008 Author Posted February 10, 2008 (edited) Seriously, if you have no clue about these things, you should just forget about it and do something else.Or at least start from reading the documentation of that software (Cheat Engine?).Because it's pretty obvious you aren't even familiar with that screenshot you posted.It's evident that you should read memory at 0x8f71dc to get the address of a pointer (0x52a31b0 in the example). Then read that memory to get the address of the data struct (0x51d4838 in the example). And only then add the offset 0x450 to read what you want to read.yeah u r right, it was just a test, cuz I learned PHP with things like this... I had no clue about how to write e.g. some datas into tables and isn't there a sentence which a teacher gives a pupil? "Learning by doing" so that's how I learn stuff and I understand the complete code, the only problem is the thing in the CheatEngine which is absolutely new to me, but I figured out by myself how to get the pointers and so on...but thanks for the information about the address of a pointer, ty Edited February 10, 2008 by syron
ToyleY Posted February 11, 2008 Posted February 11, 2008 (edited) I keep getting this message (sometimes, sometimes not):_WinAPI_WriteProcessMemory: Only part of a ReadProcessMemory OrWriteProcessMemory request was completed.It happens when _MemWrite is called in Memory.au3Func _MemWrite(ByRef $tMemMap, $pSrce, $pDest = 0, $iSize = 0, $sSrce = "ptr") Local $iWritten If $pDest = 0 Then $pDest = DllStructGetData($tMemMap, "Mem") If $iSize = 0 Then $iSize = DllStructGetData($tMemMap, "Size") Return _WinAPI_WriteProcessMemory(DllStructGetData($tMemMap, "hProc"), $pDest, $pSrce, $iSize, $iWritten, $sSrce) EndFunc ;==>_MemWriteoÝ÷ Ø"¶l¢jnµêè®+-êÞj§z¶¥¦ºéëÞ®¯zg¦¢¼©®åzk0ØZ*-êé®+jk2ý´áȬ¶jYm«]¡ë-çZ¨jëh×6 _MemWrite ($struct_MemMap, $TextRange_ptr)I have looked at $struct_MemMap and $TextRange_ptr just beforew the call and $struct_MemMap= "" (nothing) and $TextRange_ptr = 0x01FC1000.Any ideas? Edited February 11, 2008 by ToyleY
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now