Go Back   FileForums > Games > Game Coders

Thread Tools Display Modes
Old 29-06-2011, 18:15
cocodrilo cocodrilo is offline
Registered User
Join Date: Jun 2011
Location: spain
Posts: 43
Thanks: 0
Thanked 1 Time in 1 Post
cocodrilo is on a distinguished road
Example trainer without modifying code

; Civilization V game trainer by cocodrilo.
; this file not modify or redirect any piece of code.
; Compile with fasm, inject and play :).
; md5 for a tested game dll: 0079e9cc9abbca3678a5d6fa36b46bca CvGameCoreDLLFinal Release.dll
; update offsets for other version if need.

format PE GUI 4.0 DLL
entry main

include 'win32a.inc'

section 'import' import data readable writeable

library u32,'user32.dll',\

import	u32,\

import	k32,\

section 'rel' fixups data discardable

section 'data' data readable writeable

class	      db 'WinClass_FXS',0    ;Game windows class
sDll	      db 'CvGameCoreDLLFinal Release.dll',0	;dll of the game
Dll	      dd 0 ;Dll base
oProc	      dd 0 ;Old windowProc

Players       dd 0 ;Players pointer

offsetToptr   equ 28A700h ;offset to Players pointer.
tSize	      equ 0F400h  ;To iterate in players, ex: PlayerBase+(index*tSize), index 0 is your player to MAX_PLAYERS.

fUnitOfsset   equ 0F1FD0h ;offset to firstUnit method in cvunit class.
nUnitOffset   equ 0EF950h ;offset to nextUnit method  int cvunit class.
unitIndex     dd 0	  ;ptr to unit index required in first/nextUnit.

FirstUnit     dd 0 ;address of this method
NextUnit      dd 0 ;address of this method

TrainerError  db 'Error in trainer',0

section 'code' code readable executable

proc main hInst,reason,reserved
    cmp [reason],DLL_PROCESS_ATTACH
    jne .none
    push wndProc
    push class
    call setGameWindow	  ;setup my own windowproc for game window.
    mov [oProc],eax
    push sDll
    call [GetModuleHandle]
    dec eax
    jns .exit
    push 0
    push TrainerError
    push TrainerError
    push 0
    call [MessageBox]
    xor eax,eax
    inc eax	  ;adjust eax (dll base address) after verification.
    mov [Dll],eax
    mov ecx,dword [eax+offsetToptr]
    mov [Players],ecx
    mov [FirstUnit],eax
    mov [NextUnit],eax
    add [FirstUnit],fUnitOfsset
    add [NextUnit],nUnitOffset
    mov eax,1

;set my windowproc to game window.
proc setGameWindow wCls,wProc
    push 0
    push [wCls]
    call [FindWindow]
    dec eax
    js .exit
    inc eax
    push [wProc]
    push GWL_WNDPROC
    push eax
    call [SetWindowLong]

;only to handle options.
proc wndProc h,msg,wParam,lParam
    cmp [msg],WM_KEYDOWN
    jne .exit
    cmp [wParam],VK_F1
    je .F1
    cmp [wParam],VK_F2
    je .F2
    jmp .exit
    ;F1: Add 5000 gold to your player (remember index 0).
    push 0
    call getPlayer
    or eax,eax
    jz .exit
    mov eax,dword [eax+0F3D0h]	 ; get treasury from player
    push 1388h	 ;5000
    push eax	 ;player base
    call addGold
    jmp .exit
    ;F2: Add 9 moves to all militar units from player 0 (you).
    push 0
    call getPlayer
    push 21Ch	;9 moves * 60
    push eax
    call addMoves
    push [lParam]
    push [wParam]
    push [msg]
    push [h]
    push [oProc]
    call [CallWindowProc]

;index is a index of player
proc getPlayer index
    mov eax,[index]
    mov ebx,tSize
    mul ebx
    mov ebx,[Players]
    add eax,ebx

;tBase is treasury base for player to set gold.
;nGold is value to add
proc addGold tBase, nGold
    push edx
    xor eax,eax
    xor ebx,ebx
    mov edx,dword [tBase]
    push edx
    add ebx, [nGold]
    mov eax,64h
    mul ebx
    pop edx
    add dword [edx+8],eax ;save new gold in [treasury+8]
    pop edx

;this function add extra moves to all  militar units of player
;pBase is player base.
;moves is number of moves to set (number of moves * 60) ex: 9 * 60 to set 9 moves.
proc addMoves pBase,moves
    push 0
    push unitIndex
    mov ecx,dword [pBase] ;is a thiscall calling convention
    call dword [FirstUnit]
    test eax,eax
    jz .finish
    cmp dword [eax+45Ch],0
    jne .combat_unit
    inc dword [unitIndex]
    push 0
    push unitIndex
    mov ecx,dword [pBase]
    call dword [NextUnit]
    jmp .iterate
    push dword [moves]
    pop dword [eax+130h]  ;set new moves
    jmp $-22h		  ;get next unit
So it is only example, this way you can remove the enemies movements, gold etc. need not wait for turns, or turn on or off option, only affected the player you want when you want.

feel free to use this code, adapt it, burn it or do with what you want. no one is perfect, for any errors you can fix yourself. next example, paint on the game screen without modification of code (OpenGL). for example to make menus or display any information on the screen.
Reply With Quote
The Following User Says Thank You to cocodrilo For This Useful Post:
remcodevries (26-08-2013)
Sponsored Links
Old 05-09-2011, 15:58
zeroc0der zeroc0der is offline
Registered User
Join Date: Sep 2011
Location: US
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
zeroc0der is on a distinguished road

thanks! this could be useful
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Announcement and final word on the CheatHappens vs. h4x0r trainer war Joe Forster/STA Game Trainers 7 12-07-2010 08:31
REQ: Stolen trainers to be removed from GCW BigBoi Game Trainers 87 09-04-2009 07:33

All times are GMT -7. The time now is 09:23.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.
Copyright 2000-2020, FileForums @ https://fileforums.com