Jump to content

GUI and Memory Access Demo


Recommended Posts

Hello All,

I am programmer from way back, I know many languages; C++, Fortran, Cobol, Pascal, BASIC, Visual Basic, among others. I run a small business and program lots of things in my spare time. I like this small concise compiler AutoIt. It packs a pretty good punch.

I have been lurking in the shadows until now, looking over the forum for advice and such. I decide I better balance my karma and give something back. This is a little AutoIt script I worked out on my own, it is not a game bot(I read that posting) , it is a game trainer for a rather old game I have kicking around on my PC. So I will apologize that it is not highly "useful" in the practical sense. But someone can use it to learn from.

;A short example of a game trainer
;shows how to access, read and write to process memory
;shows how to create and use a GUI (graphical user interface)
;This is a work in progress and should be used as a learning tool.

#include <NomadMemory.au3> 
#include <GuiConstantsEx.au3>

;This trainer is made to access the old "Lucas Arts Afterlife" Heaven and Hell simulation game.
;I used another program TSearch ver 1.6 to find the addresses needed.
;Check to see if the program is in memory.
If not ProcessExists("ALIFE.EXE") Then
    MsgBox(0, "Game Check", "After Life is not running.")
;Get the process ID number
$pid = ProcessExists("ALIFE.EXE")
GuiCreate("After Life Trainer 1.0", 400, 400)

;Get Pennies and Planet Population
$Mem_Open = _MemoryOpen($pid) 
$Mem_Read = _MemoryRead("0x63043C", $Mem_Open) 
$Money = GuiCtrlCreateInput($Mem_Read, 5, 5, 120, 20)
$Pennies = GuiCtrlCreateButton("Total Pennies", 140, 5, 100, 30)
$gcx = GuiCtrlCreateInput(0, 130, 40, 30, 20)
$gcy = GuiCtrlCreateInput(0, 165, 40, 30, 20)
$Mem_Read = _MemoryRead("0x57E1C0", $Mem_Open) 
$population =  GuiCtrlCreateInput($Mem_Read, 5, 40, 120, 20)
GuiCtrlCreateLabel("Area Population in Sector on Planet", 5, 65, 200, 20)
$SetPop = GuiCtrlCreateButton("Set Population", 5, 95, 100, 30)
$BigPop = GuiCtrlCreateButton("Set to ALL Sectors", 105, 95, 100, 30)

$msg = GUIGetMsg()
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
        Case $msg = $Pennies                                ;Pennies button got pushed
            $Data = GUICtrlRead($Money)                     ;get the amount inside the input box
            $Mem_Open = _MemoryOpen($pid)                   ;open memory for read/write
            _MemoryWrite("0x63043C", $Mem_Open, $Data)      ;patch the pennies with the new amount
            $Mem_Read = _MemoryRead("0x63043C", $Mem_Open)  ;read the memory (just to be sure)
            GUICtrlSetData($Money, $Mem_Read)               ;display what was entered
            _MemoryClose($Mem_Open)                         ;close the memory access
        ;This sets the surface population of the planet by sector.  
        Case $msg = $SetPop
            $Data = GUICtrlRead($population)
            $Sector = 0x57E1C0 + GUICtrlRead($gcx)*1344 + GUICtrlRead($gcy)*42
            $Mem_Open = _MemoryOpen($pid) 
            _MemoryWrite($Sector, $Mem_Open, $Data)
            $Mem_Read = _MemoryRead($Sector, $Mem_Open) 
            GUICtrlSetData($population, $Mem_Read)
        ;This will set all the sectors to the same amount 2048 sectors times the amount entered.    
        Case $msg = $BigPop
            $Data = GUICtrlRead($population)
            $Mem_Open = _MemoryOpen($pid) 
            For $gcx = 0 to 63
                For $gcy = 0 to 31
                    $Sector = 0x57E1C0 + $gcx*1344 + $gcy*42
                    _MemoryWrite($Sector, $Mem_Open, $Data)

I plan to do more with this, but again it is a rather obscure game, so I will post more useful scripts in the future. I mainly did this script to wet my whistle on some of the basics of the language.


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

  • Recently Browsing   0 members

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