how would i write a program to change values in a games memory i know how to do it with hotkeys but how would i write it so when i click a button the cheat is activated? please help
Posted on 2001-04-13 15:24:00 by sToNeRiFiK
Write the code for the button press then put the code that would be for the hotkey there. -brad
Posted on 2001-04-14 00:38:00 by Rage9
Check out masta's tutorial on this site. Nice little one about how to make a trainer for starcraft. The trainer doesn't work now, but on version 1.0 it should. But it gives you an understanding.
Posted on 2001-04-14 02:59:00 by Jon Richardson
i thought that tut waz in french or sumtin?
Posted on 2001-04-15 14:44:00 by sToNeRiFiK
Here is a trainer I made a long time ago when I was first learning to program in MASM. Shows you how to patch memory by pressing a button........


; #########################################################################

      .386
      .model flat, stdcall  ; 32 bit memory model
      option casemap :none  ; case sensitive

      include Project.inc     ; local includes for this file

; #########################################################################
; ===========
; train code
; ===========
.data
  memname         db "Delta Force 2,  V1.06.15",0
  notfound        db "shutting down - Please start df2 and restart trainer",0 
  filename        db 'df2.exe',0 
  error           db "Error !!!!!",0
  writebytes      db 56
  writebytes2     db 40
  writebytes3     db 37
  address         equ 0079A5E4h
  address2        equ 0079A468h
  address3        equ 0079A568h 
  ID_TIMER        equ 1
  TIMER_INTERRUPT equ 1000
  pid dd ?
  phandle dd ?
  gamewnd dd ?
  dwprocessid dd ? 
  gameprocess dd ?
  hDlg        HWND  ?
  statClass db "STATIC",0
; ########################### List Processes ##############################
checkforgame proto
WriteValue proto
 StaticImage PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
 
; #########################################################################
.const
IDD_DIALOG1 equ 1

.code

start:
      invoke GetModuleHandle, NULL
      mov hInstance, eax


Invoke DialogBoxParam, hInstance, IDD_DIALOG1, NULL, NULL, NULL
Invoke ShowWindow, eax, SW_SHOW
Invoke FindWindow, NULL, ADDR memname  
invoke GetWindowThreadProcessId, eax, offset dwprocessid
invoke OpenProcess,PROCESS_VM_WRITE OR PROCESS_VM_OPERATION,NULL,dwprocessid
mov gameprocess, eax


      invoke GetCommandLine
      mov CommandLine, eax

      invoke InitCommonControls

      invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
      invoke ExitProcess,eax

; #########################################################################

WinMain proc hInst     :DWORD,
             hPrevInst :DWORD,
             CmdLine   :DWORD,
             CmdShow   :DWORD

      ;====================
      ; Put LOCALs on stack
      ;====================

      LOCAL wc   :WNDCLASSEX
      LOCAL msg  :MSG
      LOCAL Wwd  :DWORD
      LOCAL Wht  :DWORD
      LOCAL Wtx  :DWORD
      LOCAL Wty  :DWORD

      ;==================================================
      ; Fill WNDCLASSEX structure with required variables
      ;==================================================

      invoke LoadIcon,hInst,500    ; icon ID
      mov hIcon, eax

      szText szClassName,"Project_Class"

      mov wc.cbSize,         sizeof WNDCLASSEX
      mov wc.style,          CS_HREDRAW or CS_VREDRAW \
                             or CS_BYTEALIGNWINDOW
      mov wc.lpfnWndProc,    offset WndProc
      mov wc.cbClsExtra,     NULL
      mov wc.cbWndExtra,     NULL
      m2m wc.hInstance,      hInst
      mov wc.hbrBackground,  COLOR_BTNFACE+1
      mov wc.lpszMenuName,   NULL
      mov wc.lpszClassName,  offset szClassName
      m2m wc.hIcon,          hIcon
        invoke LoadCursor,NULL,IDC_ARROW
      mov wc.hCursor,        eax
      m2m wc.hIconSm,        hIcon

      invoke RegisterClassEx, ADDR wc

      ;================================
      ; Centre window at following size
      ;================================

      mov Wwd, 500
      mov Wht, 350

      invoke GetSystemMetrics,SM_CXSCREEN
      invoke TopXY,Wwd,eax
      mov Wtx, eax

      invoke GetSystemMetrics,SM_CYSCREEN
      invoke TopXY,Wht,eax
      mov Wty, eax

      invoke CreateWindowEx,WS_EX_LEFT,
                            ADDR szClassName,
                            ADDR szDisplayName,
                            WS_OVERLAPPED or WS_SYSMENU,
                            Wtx,Wty,Wwd,Wht,
                            NULL,NULL,
                            hInst,NULL
      mov   hWnd,eax

      invoke LoadMenu,hInst,600  ; menu ID
Posted on 2001-05-03 01:24:00 by Mr. Ying
i have done the starcraft tutorial and i understand how it works and everything. but in the tutorial it just tells you the memory addresses. how do you find the memory addresses on your own??? skud.
Posted on 2001-05-06 13:55:00 by skud
To make it short goto gamehackers.com or gamehacking.com (*don't remember the exact link) and read their tuts and look at their tools. Or you can read all the boring stuff I wrote. Finding memory address' isn't too hard. Get some game hacking tools, start them up, start the game up, choose the memory process you want to monitor from gamehackingtool, go into game and find value (gas, money, etc). And then go back to the tool and search for a dword, btye, etc of the value. Repeat the process since you will usually find more than one variable with that value (these are BIG programs!). You can do a lot more than that with some experiance and knowing asm helps because then you can get a debugging tool like softice and set breakpoints to find the sections of code that needs changing; and then nop whatever subtracts your money ;) Then make a program that changes the code in memory. One fellow made a trainer for the computer version of FF7. It had something like 70 options! Ranging from money and magic to characters you had! The reason you might have to acually change the code in memory instead of just finding the addresses where certain values are stored is because some games try and prevent you from cheating like this; what I'm guessing they do is make an array of values and decide where they want to store certain things everytime you play - use lots of pointers and then switch what variable they use every game - OR have dummy values and check to see if the dummy values aren't equalling the proper value and then hiding the right value.. The possiblities for them are also endless i guess.You'll eventually learn good strategies for thwarting them. Try visiting www.gamehackers.com or other game hacking sites and read their tutorials and download and experiment with their tools. Also make sure you have a good understanding of dwords and bytes and words and all that stuff so you can guess what type they're going to store the value. (ie, life bars are usually bytes and so 255(256?) is usually the max amount of life, and money and stuff would be in an integer (do you call them integers in ASM? or is it a C thing?) The tools will want to know if you're searching for a dword, byte, whatever and it's value. Well, that is all I know. ..Matt, the writer of lenghly, boring, ..stuff!
Posted on 2001-05-06 14:27:00 by matthew
Well, I have also tried to do a trainer for a game, but the addresses of the values changes each time you restart the computer. It is a DOS game. Is there a way to work around this?
Posted on 2001-05-17 09:02:00 by gliptic
Segments should definitely change, but offsets shouldn't. So you need to find the segment offset from the first segment of the game your data is in, and then make the trainer figure out the first segment of the app when it's loading the game (or activated, if it's not a loader-trainer). This is only theory, and it's ages since I've done DOS stuff :).
Posted on 2001-05-17 09:12:00 by f0dder
Thanks! I'll try that!
Posted on 2001-05-18 01:57:00 by gliptic