Jump to content

_MemoryPointerRead understanding


Recommended Posts

umm omg i got it working have a look at the code all i did was deleted 2 lines that was doubled up but i showed u that code so i dont know if u deleted them 4 it to work

before:

#include <MemoryConstants.au3>
#include <NomadMemory.au3>
SetPrivilege("SeDebugPrivilege", 1)
HotKeySet('{ESC}', '_TerminateLoop')

$pid = ProcessExists("Tutorial.exe") ;Step 8: Multilevel pointers: (PW=525927)

Global $fLoop = True
Global $Offset1[5]
$Offset1[0] = 0 ; Is ALWAYS 0.
$Offset1[1] = Dec("c")
$Offset1[2] = Dec("14")
$Offset1[3] = Dec("0")
$Offset1[4] = Dec("18")

$StaticOffset = Dec("60c20")

$openmem = _MemoryOpen($pid) ; Open the memory
$baseADDR = _MemoryGetBaseAddress($openmem, 1)
$finalADDR = "0x" & Hex($baseADDR + $StaticOffset) ; Creates the final static address you read from.

$Value = _MemoryPointerRead($finalADDR, $openmem, $Offset1)
ConsoleWrite ( "Address = " & $Value[0] & @CRLF & "Value = " & $Value[1] & @CRLF)

; Click change pointer and press Esc before 3 seconds passes away. :)
While $fLoop
    Sleep(10)
WEnd

$Value = _MemoryPointerRead($finalADDR, $openmem, $Offset1)
ConsoleWrite ( "Address = " & $Value[0] & @CRLF & "Value = " & $Value[1] & @CRLF)
_MemoryWrite($Value[0], $openmem, 5000)
_MemoryClose($openmem)


Func _TerminateLoop()
    $fLoop = False
EndFunc

After:

#include <MemoryConstants.au3>
#include <NomadMemory.au3>
SetPrivilege("SeDebugPrivilege", 1)
HotKeySet('{ESC}', '_TerminateLoop')

$pid = ProcessExists("Tutorial.exe") ;Step 8: Multilevel pointers: (PW=525927)

Global $fLoop = True
Global $Offset1[5]
$Offset1[0] = 0 ; Is ALWAYS 0.
$Offset1[1] = Dec("c")
$Offset1[2] = Dec("14")
$Offset1[3] = Dec("0")
$Offset1[4] = Dec("18")

$StaticOffset = Dec("60c20")

$openmem = _MemoryOpen($pid) ; Open the memory
$baseADDR = _MemoryGetBaseAddress($openmem, 1)
$finalADDR = "0x" & Hex($baseADDR + $StaticOffset) ; Creates the final static address you read from.



; Click change pointer and press Esc before 3 seconds passes away. :)
While $fLoop
    Sleep(10)
WEnd

$Value = _MemoryPointerRead($finalADDR, $openmem, $Offset1)
ConsoleWrite ( "Address = " & $Value[0] & @CRLF & "Value = " & $Value[1] & @CRLF)
_MemoryWrite($Value[0], $openmem, 5000)
_MemoryClose($openmem)


Func _TerminateLoop()
    $fLoop = False
EndFunc

that code not ment to be there? or is it ment to?

Link to comment
Share on other sites

For the hell of it, I created a game hacker for Zoo Tycoon.

Here is the stripped down fully commented code so you can see how to increase by X, set values, read, set hotkeys and do what you need to do to make a fully working 'trainer'.

#include <NomadMemory.au3>
; MY NomadMemory has every memory function in it. If yours does NOT, add them in so you don't get an error.

; Check if the game is going
If WinExists("Zoo Tycoon") = 0 Then
    TrayTip("Error", "Please start the game first", 1)
    Sleep(3000)
    Exit
EndIf

TrayTip("Cheats", "Alt1 - Lotz o money. Alt2 - 100 Zoo rating(good for an award)", 5)


SetPrivilege("SeDebugPrivilege", 1)
Opt("OnExitFunc", "endscript")



; Setup the hotkeys to call functions.
HotKeySet("!1", "SetMoney")
HotKeySet("!2", "SetRating")


; Simple main offset
Global $MainOffset[2]
$MainOffset[0] = 0 ; Is ALWAYS 0.
$MainOffset[1] = Dec("C") ; Static Addr Oset.


; Main read
$pid = WinGetProcess("Zoo Tycoon") ; PID
$openmem = _MemoryOpen($pid) ; Open the memory
$baseADDR = _MemoryGetBaseAddress($openmem, 1, 0x00500000) ; I moved $IV_Address to a third paramater in my function for my own debugging.
; Func _MemoryGetBaseAddress($ah_Handle, $iHexDec = 0, $iv_Address = 0x00100000)


; Create 0x(Add base adress to the offset)
$baseADDR = "0x" & Hex($baseADDR + Dec("238048")) ; zoo.exe+00238048
$baseADDR = _MemoryPointerRead($baseADDR, $openmem, $MainOffset, "float") ; Read offset
; *********


;Addresses
$MoneyAddress = $baseADDR[0]
$RatingAddress = "0x" & Hex($MoneyAddress + Dec("20"))
$ZooGuestAddress = _MemoryGetBaseAddress($openmem, 1)
$ZooGuestAddress = "0x" & Hex($ZooGuestAddress + Dec("23E270"))
;**********

; Main loop. Keep the script going
While 1
    Sleep(500)
    If WinExists("Zoo Tycoon") = 0 Then Exit
WEnd

; Hotkey calls this to set the money to 2bill. Also a float value
Func SetMoney()
    
    _MemoryWrite($MoneyAddress, $openmem, 2000000000, "float")
    
    ;Lets say I wanted to increase it by 1000 everytime instead
    $Current = _MemoryRead($MoneyAddress, $openmem, "float")
    _MemoryWrite($MoneyAddress, $openmem, $Current + 1000, "float")
EndFunc


Func endscript()
    _MemoryClose($openmem)
    Exit
EndFunc

; Hotkey calls this to set the rating to 100. Also a 2 byte value
Func SetRating()
    _MemoryWrite($RatingAddress, $openmem, 100, "short")
EndFunc

(This WILL NOT run on your pc unless you happen to have zoo tycoon marine mania installed on your pc and running. This is to show you HOW to do it.)

Link to comment
Share on other sites

For this particular tutorial or generally?

yes this is 4 the cheat engine tutorial the multi pointer part just wanted to get it working with that 1st cos its the easiest thing to get it to work with. im going to be making a trainer 4 the sims3

Here is the stripped down fully commented code so you can see how to increase by X, set values, read, set hotkeys and do what you need to do to make a fully working 'trainer'.

thankyou i will have to try to work it out.

Link to comment
Share on other sites

#include <NomadMemory.au3>
SetPrivilege("SeDebugPrivilege", 1)
HotKeySet('{ESC}', '_TerminateLoop')
HotKeySet('{PGUP}', '_Increase')
HotKeySet('{PGDN}', '_Show')

$pid = ProcessExists("Tutorial.exe") ;Step 8: Multilevel pointers: (PW=525927)

Global $fLoop = True
Global $Offset1[5]
$Offset1[0] = 0 ; Is ALWAYS 0.
$Offset1[1] = Dec("c")
$Offset1[2] = Dec("14")
$Offset1[3] = Dec("0")
$Offset1[4] = Dec("18")

$StaticOffset = Dec("60c20")

$openmem = _MemoryOpen($pid) ; Open the memory
$baseADDR = _MemoryGetBaseAddress($openmem, 1)
$finalADDR = "0x" & Hex($baseADDR + $StaticOffset) ; Creates the final static address you read from.

While $fLoop
    Sleep(10)
WEnd

_MemoryClose($openmem)
Exit


Func _TerminateLoop()
    $fLoop = False
EndFunc

Func _Increase()
    Local $avValue = _MemoryPointerRead($finalADDR, $openmem, $Offset1)
    If IsArray($avValue) Then _
        _MemoryPointerWrite($finalADDR, $openmem, $Offset1, $avValue[1]+10)
EndFunc
    
Func _Show()
    Local $avValue = _MemoryPointerRead($finalADDR, $openmem, $Offset1)
    If IsArray($avValue) Then ConsoleWrite($avValue[1] & @CRLF)
EndFunc

Use Page-Down or Page-Up to see the changes reflection, the static control won't update the address content for a very good reason not to pool a specific address without the knowledge of the application.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...