|
You last visited: Today at 13:52
Advertisement
Help with reading memory with offsets from game
Discussion on Help with reading memory with offsets from game within the AutoIt forum part of the Coders Den category.
11/20/2013, 19:57
|
#16
|
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
|
ok now works
but if i start script first and then game it throw me error
Can't get ModuleGetBaseAdress! @error:21, @extended:299
but when i press OK on msgbox then it work normal, shows me adress and score in tooltip
and if i start game first then script, no errors
And tell me pls if i want use multiple pointers do i need to change only this
Code:
Dim $offsets[1] = [0x30] ; to
Dim $offsets[3] = [0x30, 0xc4, 0x280]
and this
Code:
("Address: " & $memoryData[0] & @CRLF & "Value: " & $memoryData[1], 0, 0) ; to
("Address: " & $memoryData[0] & @CRLF & "Value: " & $memoryData[3], 0, 0)
and have next problem with this
Code:
; write new score to game memory
Func _setScrore()
Local $unicode
$read = GUICtrlRead($Input2) ; read data from input box
;_KDMemory_WriteProcessMemory($handles, $baseAddress, $type, $value, $offsets = 0)
;_KDMemory_WriteProcessMemory($handles, $address, "dword", $read, $offsets[1])
_KDMemory_WriteProcessString($handles, $address, $read, $offsets, $unicode = 0)
EndFunc
when i write number 1 in input and press button to add score it gives 49 not 1, why is that ?
and 1 more problem i have
when i start script first it show me game is not runnning and score is set to 0,
and when i start game it say game is running but not reading score from game
but if i start game first and then script it works normal
So my question is what i need to make to program automatic hook on game when i open game = read data / close / open game again read data
because if game crash i need to turn off script and first start game then open script but i want to open script first then game
here is all code for script
Code:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.8.1
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include "KDMemory.au3"
#Region ### START Koda GUI section
$GUI = GUICreate("Solitaire hack", 195, 235, 392, 224, -1, $WS_EX_COMPOSITED)
$Group1 = GUICtrlCreateGroup("Current score", 8, 8, 177, 53)
$currentScore = GUICtrlCreateInput("", 15, 32, 161, 21, $ES_READONLY)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("New score", 8, 74, 177, 53)
$Input2 = GUICtrlCreateInput("", 15, 98, 161, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Status", 7, 138, 177, 53)
$status = GUICtrlCreateInput("", 14, 162, 161, 21, $ES_READONLY)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$btnSet = GUICtrlCreateButton("Set score", 8, 200, 85, 25)
$btnFreeze = GUICtrlCreateButton("Freeze time", 101, 200, 85, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $processName = "sol.exe", $handles = 0, $address = 0
Global $offsets[1] = [0x30]
Global $processId = ProcessExists($processName)
While 1
_checkGame() ; chech if game is running
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btnSet
_setScrore()
EndSwitch
; checks if game is running
If $processId == 0 Then
If IsArray($handles) Then
_KDMemory_CloseHandles($handles)
$handles = 0
$address = 0
EndIf
ContinueLoop
EndIf
; opens memory
If $handles == 0 Then
$handles = _KDMemory_OpenProcess($processId, 0, 0x001F0FFF)
If @error Then
If MsgBox(52, "Error", "Can't open " & $processName & "! @error: " & @error) == 6 Then
$handles = 0
ContinueLoop
Else
Exit
EndIf
EndIf
EndIf
If $address == 0 Then
$address = _KDMemory_GetModuleBaseAddress($handles, $processName) + 0x00007170
If @error Then
If MsgBox(52, "Error", "Can't get ModuleBaseAddress! @error: " & @error & ", @extended: " & @extended) == 6 Then
$address = 0
ContinueLoop
Else
Exit
EndIf
EndIf
EndIf
; read memory from process
$memoryData = _KDMemory_ReadProcessMemory($handles, $address, "DWORD", $offsets)
If Not @error Then
GUICtrlSetData($currentScore, $memoryData[1])
EndIf
WEnd
; check if game is running and change status in $status variable on change state
Func _checkGame()
If ProcessExists("sol.exe") Then
ProcessWait("sol.exe")
GUICtrlSetData($status, "Game is running.")
Else
; if game is not running set score to 0 and state to 0
GUICtrlSetData($status, "Game is not running.")
GUICtrlSetData($currentScore, 0)
EndIf
EndFunc
; write new score to game memory
Func _setScrore()
Local $unicode
$read = GUICtrlRead($Input2) ; read data from input box
;_KDMemory_WriteProcessMemory($handles, $baseAddress, $type, $value, $offsets = 0)
;_KDMemory_WriteProcessMemory($handles, $address, "dword", $read, $offsets[1])
_KDMemory_WriteProcessString($handles, $address, $read, $offsets, $unicode = 0)
EndFunc
|
|
|
11/21/2013, 00:50
|
#17
|
elite*gold: 0
Join Date: Mar 2009
Posts: 7,260
Received Thanks: 33,147
|
If you want to use a pointer with more than one offset, you have to add the offsets to the array.
Code:
Dim $offsets[5] = [0, 1, 2, 3, 4]
_KDMemory_ReadProcessMemory() will still return an array with two elements. The first element is the address and the second element is the value of the address.
Quote:
and if i start game first then script, no errors
[...]
and 1 more problem i have
when i start script first it show me game is not runnning and score is set to 0,
and when i start game it say game is running but not reading score from game
but if i start game first and then script it works normal
So my question is what i need to make to program automatic hook on game when i open game = read data / close / open game again read data
|
There are a few errors in your script. My example works fine. But that's easy to explain. The process ID identifies a running process and is unique. If the process isn't running, there won't be a process ID (= 0). You have to get the process ID constantly. Just put the line in the While loop.
Quote:
when i write number 1 in input and press button to add score it gives 49 not 1, why is that ?
|
The address 'holds' an integer. 49 is the character code for '1'. You have to use the _KDMemory_WriteProcessMemory() function.
I updated my UDF. Download the new version.
Code:
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include "KDMemory.au3"
#Region GUI
GUICreate("Solitaire hack", 195, 235)
GUICtrlCreateGroup("Current score", 8, 8, 177, 53)
$inp_CurrentScore = GUICtrlCreateInput("", 15, 32, 161, 21, $ES_READONLY)
GUICtrlCreateGroup("New score", 8, 74, 177, 53)
$inp_NewScore = GUICtrlCreateInput("", 15, 98, 161, 21)
GUICtrlCreateGroup("Status", 7, 138, 177, 53)
$inp_Status = GUICtrlCreateInput("Game is not running.", 14, 162, 161, 21, $ES_READONLY)
$btn_SetScore = GUICtrlCreateButton("Set score", 8, 200, 85, 25)
$btn_FreezeTime = GUICtrlCreateButton("Freeze time", 101, 200, 85, 25)
GUISetState()
#EndRegion
Dim $processName = "sol.exe", $handles = 0, $address = 0
Dim $offsetsScore[1] = [0x30]
Dim $offsetsTime[3] = [0x30, 0xC4, 0x280]
Dim $setScore = False, $freezeTime = False
While Sleep(10)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btn_SetScore
$setScore = Not $setScore
Case $btn_FreezeTime
$freezeTime = Not $freezeTime
EndSwitch
; checks if game is running
$processId = ProcessExists($processName)
If $processId == 0 Then
If IsArray($handles) Then
GUICtrlSetData($inp_Status, "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($inp_Status, "Game is running (PID = " & $processId & ").")
EndIf
EndIf
If $address == 0 Then
$address = _KDMemory_GetModuleBaseAddress($handles, $processName) + 0x00007170
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", $offsetsScore)
If Not @error Then
If GUICtrlRead($inp_CurrentScore) <> $memoryData[1] Then GUICtrlSetData($inp_CurrentScore, $memoryData[1])
EndIf
; write process memory
If $setScore Then
_KDMemory_WriteProcessMemory($handles, $address, "DWORD", Int(GUICtrlRead($inp_NewScore)), $offsetsScore)
$setScore = False
EndIf
If $freezeTime Then
_KDMemory_WriteProcessMemory($handles, $address, "DWORD", 0, $offsetsTime)
EndIf
WEnd
|
|
|
11/21/2013, 16:25
|
#18
|
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
|
OK thx for help now is all work fine
|
|
|
|
|
Similar Threads
|
[C#]Reading Memory / Pointer with multiple Offsets.
01/12/2013 - .NET Languages - 23 Replies
I am used to coding in AutoIt. I am trying to move my project into C# but I have only about 2-3 weeks of experience.
In AutoIt, I have this code here that reads the process memory and returns a value.
$map = _MemoryRead(0x00B5CCB8, $handle) // Pointer address 0x00B5CCB8
$map = _MemoryRead($map + 0x02, $handle) // Offset 0x02
$map = _MemoryRead($map + 0xBD, $handle) // Second Offset 0xBD
I am trying desperately to convert this to C# language and I need some help. Here is what I have...
|
[Vb.NET] WoW Memory Reading
11/20/2010 - World of Warcraft - 1 Replies
Hallo,
Ist es irgendwie möglich mit VB.NET die Memory von WoW auszulesen wie bei C# mit der BlackMagic.dll
Danke m vorraus
|
Help with memory reading. C++.
06/12/2010 - Aion - 0 Replies
Hello people, I'm kinda new to memory reading in c++. Been doing similiar stuff, and done some other stuff like packet hacks etc but anyway, to the issue.
I get weird values from AION when reading. And I'm prolly going about this totally wrong so I'll post you the code and hopefully some kind soul out there will point me in the right direction.
int address = 0xA82424;
int value;
DWORD pid;
if(!GameWindow)
{
|
Memory reading etc.
06/18/2008 - General Coding - 11 Replies
-
|
Memory reading help...
02/10/2007 - Conquer Online 2 - 1 Replies
Hi,
I need to read the amount of arrows on an archer (0-500). I have the pointer and offset, and i can get the right number in cheat engine, however whenever i try to read it from autohotkey i always get 0. Don't know why. I've always read 4 byte data before so i don't really know if i have the right code for 2 byte data. Here's the autohotkey code
ExtInt(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4); From AutoHotKey Help
{
Loop %pSize%
result += *(&pSource +...
|
All times are GMT +2. The time now is 13:52.
|
|