Proper Trainer Tutorial

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
User avatar
gibberishh
Table Makers
Table Makers
Posts: 383
Joined: Fri Jul 02, 2021 5:48 pm
Reputation: 250

Proper Trainer Tutorial

Post by gibberishh »

I've been searching for a good tutorial to teach myself how to create a full trainer in CE. All the tutorials I've come across so far teach me how to add form controls and do something entirely stupid with them. Like click a button to display Hello World.

Is there some article, forum post, video tutorial, etc. that teaches me how to actually manipulate game (memory) values or inject code? I've released several tables with ASM scripts (a little bit of Lua here and there). I wish to create a form (from scratch) using which I can manipulate the values at specific memory addresses (or memrecs if that is more efficient) on certain events, or enable/disable code injection scripts.

What is the best way? Should I be directly updating the actual memory location with my new value (e.g., through an onChange event of a text box) or should I manipulate the memory record's value in the table through the form? Is there a straightforward way to 'link' memory records to form controls (like we used to do with ODBC in Visual Basic) or do I have to code individual Read and Write scripts for each control?

Same question for ASM scripts: do I need to rewrite those scripts in Lua or should I simply manipulate the .Active property of the memory record?

Btw, I have tried automatic generation of trainers and found it to be completely useless. They do absolutely nothing with the scripts saved in the table. I have also created and publicly released a form that allows users to update the config of a game. It basically outputs a text file (config.ini) and has nothing to do with manipulating memory, but I am somewhat familiar with forms.

Thanks

Paul44
RCE Fanatics
RCE Fanatics
Posts: 887
Joined: Thu Jul 27, 2017 9:02 am
Reputation: 566

Re: Proper Trainer Tutorial

Post by Paul44 »

^ check this out: [ [Link] ]
(i've gone through this one myself to get "momentum" and pick up some details)
As using forms is concerned, most of my tables use a (one and the same) form, primarily to show a list (of items) allowing gamers to manipulate per item (~ for 1 particular table, i did a multiselect) or per list(box)... most/all code is lua_driven.

Tip: you might want to explain your goal using a particular example (for a particular game), so readers can get a better idea of what you are trying to achieve. Also - actually my first assumption when reading your post - if you want to create a (non-CE interface) trainer (~ plenty of wellknown authors out there 8-)), keep in mind that most of these are (probably) written in C++ ?! (you should be able to find examples on youtube/etc)

Is it a matter of protecting your code, talk to #STN first...

fyi: as it happens, i recently started reading [Modern X86 Assembly Language Programming] (for both 32-bit, 64-bit); which uses C++ and Masm examples/integration. I'm NOT doing any programming - that'll take 1+year to finish that book, nor is it my ambition to do that kind of stuff - just reading and 'trying' to understand the instruction sets...

User avatar
gibberishh
Table Makers
Table Makers
Posts: 383
Joined: Fri Jul 02, 2021 5:48 pm
Reputation: 250

Re: Proper Trainer Tutorial

Post by gibberishh »

Paul44 wrote:
Mon Nov 28, 2022 5:22 pm
Tip: you might want to explain your goal...
Is it a matter of protecting your code, talk to #STN first...
Thanks. I'll go through this (again) and hopefully it will set me on the right path.

Frankly my primary goal is to learn trainer development. It has constantly flummoxed me that we spend hours creating cheat tables, then (acc to this tutorial) have to spend several hours not only rewriting everything for trainers (if we wish to) instead of leveraging the work already done, and possibly designing form controls using additional code.

I'll also independently explore 'designing' a form (which outputs binary in the xml) and manipulating existing memrec's properties through it to create a trainer instead to see if it works (vs. mixing ASM into Lua). Unless I'm outputting controls like checkboxes in a for loop, I find the design method much easier than the coding method for forms, and prefer coding only the events.

My secondary goal is to provide a decent GUI for a couple of my tables. Some of my tables are huge (50+ cheats) and although I have organized them in a half-decent tree structure, a tabbed GUI would make them more approachable. Or, sometimes I need to check data integrity which is far easier in Lua than ASM. E.g., to equip a sword I have to change the byte at 00000016 to 1, but to make sure I have a sword I have to check the byte at 00000004. Lua could simply check the two memrec values before allowing form control manipulation whereas in the cheat table they are two separate memrecs so changing the value of one has no influence on the other.

Nah, I'm open about sharing my code. People are welcome to take it, extend it, improve it, do whatever they wish. In fact sometimes I actively wish someone would take over/collaborate on development of my existing tables ;)

Paul44
RCE Fanatics
RCE Fanatics
Posts: 887
Joined: Thu Jul 27, 2017 9:02 am
Reputation: 566

Re: Proper Trainer Tutorial

Post by Paul44 »

^ a) rewriting everything for trainers: i guess "form painters" are not an easy feat, so you'll get something basic with standard CE (one of the reasons why i've never used it)
b) tabbed GUI: CE comes with Tabs, but never experimented with it (and it might only (?) be usefull for CE research)
c) check data integrity: yep, i agree; lua is a 'one-time' execution. which is why i have added a "standard" timer in all my tables to check - among others - particular lua routines that need to run every x secs.
=> check any of my tables: in Lua startup 'WinTitleTimer()'. This routine also "runs" by default a 'Scripts to run per Timer interval' script; in which i add any lua routines that need to run/execute every x secs

anyway: do please update your topic when you've achieved (some of) your goal(s); i'm interested to see where you are going with this...

User avatar
gibberishh
Table Makers
Table Makers
Posts: 383
Joined: Fri Jul 02, 2021 5:48 pm
Reputation: 250

Re: Proper Trainer Tutorial

Post by gibberishh »

  • Actually I find the form design stuff very easy to use. There's also a good suite of controls that (until now) let me do almost anything and create very approachable UI. Unless you have used very old form designers (like Visual Foxpro) you probably won't know why I sound almost excited about the choice of controls available in CE.
  • Afaik, there are only 'memory scan' tabs in CE. The actual records, to my knowledge, can't be tabbed. One can access the various panels of CE via getMainForm().PanelX and maybe someone can insert extra panels and stuff but I expect this to be extra complicated.
  • Am familiar with timers, but I doubt I will need one. In a form (after initial population) I can simply en/disable the Equip Sword checkbox upon the onChange event of the Have Sword checkbox. Or conversely (depending on what the game allows), I can automatically tick the Have box when the user ticks the Equip box. Or I might not even display Equip Sword in a multiselect listbox while Have is not ticked. And only when my Lua is satisfied that all conditions have been met (within the onChange event), I can actually update the memory record/s that need to be changed.
Sure, I'll post about progress I make. This will take some time though because I expect to be busy with other stuff for the next several days.

Post Reply

Who is online

Users browsing this forum: No registered users