C# making a game trainer from scratch

Here's a little video I made (about 50 minutes)

Using Cheat Engine to find addresses. Then with Visual Studio Community Edition 2017 with Memory.dll do things like AoB scans, write/read addresses with pointers, addresses and offsets.

 

Erfg1

Well-Known Member
OP
Member
Joined
Jan 3, 2016
Messages
105
Trophies
0
Age
36
XP
498
Country
United States
Once you understand the basics you can use almost any programming language. You would also have to learn the structure too.

Things like conditional statements, booleans, integers, floats, etc.
 

ov3rkill

Well-Known Member
Member
Joined
May 10, 2009
Messages
1,671
Trophies
1
Location
in a cardboard box
XP
2,045
Country
Australia
From what I understand, Codecademy wants you to put exactly what it sais on the site,
Example(Not from the actual site):
Would tell me to put a font size in a .css file, when I could just use <style> in html5.

That's why it's good for beginners. It would confuse the hell out of them if you provide them with a lot of info at first.
 
  • Like
Reactions: BooDaRippa

Psionic Roshambo

Well-Known Member
Member
Joined
Aug 12, 2011
Messages
2,215
Trophies
2
Age
49
XP
2,965
Country
United States
I need an FPS shooter that trains me how to code, then my short attention span could be overcome lol

Seriously why has no one made some sort of game game about C++ or C# or just C. Hell even if it is just a trivia game to help noobs learn (like myself)

Or maybe it has been made and I just haven't come across it.

Edit: Maybe this would be a fun place to start off for people. https://codecombat.com/

Edit 2: Maybe this would be a bit better, it claims to support C and C++ and C# so you can pick your weapon of choice. https://www.codewars.com/
 
Last edited by Psionic Roshambo,

Rottweiler

Member
Newcomer
Joined
Sep 25, 2017
Messages
13
Trophies
0
Age
33
XP
53
Country
United States
Recently had to write my own trainer implementation for a game, it supports multiple offsets and getting module base address

var trainer = new Trainer(Process.GetProcessesByName("hl2").FirstOrDefault());
if(trainer.IsValid()) {
var address = (uint) trainer.ReadInt(trainer.GetModuleAddress("server.dll") + 0xFFFFFF);
var result = trainer.WriteInt(address, VALUE, .. offset);
}

PHP:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Growl.Core.Memory
{
    public class Trainer
    {
        public Process Process { get; }
        public bool IsValid { get { return Process != null && Process.Handle != null && !Process.HasExited; } }

        public Trainer(Process process)
        {
            Process = process;
        }

        private uint RecalculateAddress(uint address, params uint[] offset)
        {
            for (int i = 0; i < offset.Length; i++)
            {
                if (i == offset.Length)
                {
                    return address + offset[i];
                }
                else
                {
                    address = (uint)ReadInt(address + offset[i]);
                }
            }

            return address;
        }

        public int ReadInt(uint address)
        {
            var read = 0u;
            var value = -1;
            ReadInt(Process.Handle, address, out value, sizeof(int), out read);
            return value;
        }

        public int ReadInt(uint address, params uint[] offset)
        {
            return ReadInt(RecalculateAddress(address, offset));
        }

        public bool WriteInt(uint address, int value)
        {
            var write = 0u;
            WriteInt(Process.Handle, address, ref value, sizeof(int), out write);
            return write > 0;
        }

        public bool WriteInt(uint address, int value, params uint[] offset)
        {
            return WriteInt(RecalculateAddress(address, offset), value);
        }

        public float ReadFloat(uint address)
        {
            var read = 0u;
            var value = -1f;
            ReadFloat(Process.Handle, address, out value, sizeof(float), out read);
            return value;
        }

        public float ReadFloat(uint address, params uint[] offset)
        {
            return ReadFloat(RecalculateAddress(address, offset));
        }

        public bool WriteFloat(uint address, float value)
        {
            var write = 0u;
            WriteFloat(Process.Handle, address, ref value, sizeof(float), out write);
            return write > 0;
        }

        public bool WriteFloat(uint address, float value, params uint[] offset)
        {
            return WriteFloat(RecalculateAddress(address, offset), value);
        }

        public byte ReadByte(uint address)
        {
            var read = 0u;
            var value = default(byte);
            ReadByte(Process.Handle, address, out value, sizeof(byte), out read);
            return value;
        }

        public byte ReadByte(uint address, params uint[] offset)
        {
            return ReadByte(RecalculateAddress(address, offset));
        }

        public bool WriteByte(uint address, byte value)
        {
            var write = 0u;
            WriteByte(Process.Handle, address, ref value, sizeof(byte), out write);
            return write > 0;
        }

        public bool WriteByte(uint address, byte value, params uint[] offset)
        {
            return WriteByte(RecalculateAddress(address, offset), value);
        }

        public uint GetModuleAddress(string name)
        {
            foreach (ProcessModule module in Process.Modules)
            {
                if (module.ModuleName.ToLower() == name.ToLower() || Regex.Match(module.ModuleName.ToLower(), name.ToLower()).Success)
                {
                    return (uint)module.BaseAddress.ToInt32();
                }
            }

            return default(UInt32);
        }

        [DllImport("kernelbase", EntryPoint = "ReadProcessMemory")]
        private static extern IntPtr ReadInt(IntPtr handle, uint address, out int value, uint length, out uint read);

        [DllImport("kernelbase", EntryPoint = "WriteProcessMemory")]
        private static extern IntPtr WriteInt(IntPtr handle, uint address, ref int value, uint length, out uint write);

        [DllImport("kernelbase", EntryPoint = "ReadProcessMemory")]
        private static extern IntPtr ReadFloat(IntPtr handle, uint address, out float value, uint length, out uint read);

        [DllImport("kernelbase", EntryPoint = "WriteProcessMemory")]
        private static extern IntPtr WriteFloat(IntPtr handle, uint address, ref float value, uint length, out uint write);

        [DllImport("kernelbase", EntryPoint = "ReadProcessMemory")]
        private static extern IntPtr ReadByte(IntPtr handle, uint address, out byte value, uint length, out uint read);

        [DllImport("kernelbase", EntryPoint = "WriteProcessMemory")]
        private static extern IntPtr WriteByte(IntPtr handle, uint address, ref byte value, uint length, out uint write);

    }
}
 
Last edited by Rottweiler,

Rottweiler

Member
Newcomer
Joined
Sep 25, 2017
Messages
13
Trophies
0
Age
33
XP
53
Country
United States
I need an FPS shooter that trains me how to code, then my short attention span could be overcome lol

Seriously why has no one made some sort of game game about C++ or C# or just C. Hell even if it is just a trivia game to help noobs learn (like myself)

Or maybe it has been made and I just haven't come across it.

Edit: Maybe this would be a fun place to start off for people. https://codecombat.com/

Edit 2: Maybe this would be a bit better, it claims to support C and C++ and C# so you can pick your weapon of choice. https://www.codewars.com/

Unity engine uses C# and there are tons of tutorials out there for that. Games in pure C# with GDI tend to perform so bad that nobody wants to use it
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • SylverReZ @ SylverReZ:
    Hope they made lots of spaget
  • K3N1 @ K3N1:
    Chill dog
  • SylverReZ @ SylverReZ:
    Chilli dog
  • Skelletonike @ Skelletonike:
    Damn, I'm loving the new zelda.
  • xtremegamer @ xtremegamer:
    loving the new zelda, i started a game, it was so fucking good, so i
    am waiting on my friend to get home so we can start a new one together
  • Skelletonike @ Skelletonike:
    I just dislike that they don't let me choose the voices before the game starts. Happened with botw as well, had to change to japanese and restart.
  • K3N1 @ K3N1:
    But the important question is can you choose gender
  • Skelletonike @ Skelletonike:
    Same way you can choose Gerald's gender.
  • Skelletonike @ Skelletonike:
    *Geralt, damn autocorrect.
  • Psionic Roshambo @ Psionic Roshambo:
    But can he be trans? Lol
  • K3N1 @ K3N1:
    Zelda transforms into link
  • Psionic Roshambo @ Psionic Roshambo:
    Link I'm not the princess your looking for.... *Pulls a crying game*
  • K3N1 @ K3N1:
    *skirt up* it's exactly what I always wanted
  • Skelletonike @ Skelletonike:
    Just scanned all my zelda amiibos, took a while but didn't get anything that cool, did get the lon lon ranch hylian fabrics though.
  • Skelletonike @ Skelletonike:
    It was pretty funny when I scanned wolf link and got a shit load of meat.
  • K3N1 @ K3N1:
    @Skelletonike, btw I ran that custom for mgs4 on the deck I'm amazed it got that far in game
  • K3N1 @ K3N1:
    Plug in*
  • K3N1 @ K3N1:
    Your favorite activity
  • BentlyMods @ BentlyMods:
    My fav actvity is:

    mario-dancing.gif
  • Psionic Roshambo @ Psionic Roshambo:
    Do the Mario lol
  • K3N1 @ K3N1:
    🍑
  • K3N1 @ K3N1:
    Whoever developed Bramble was smoking that good shit fucking gnomes
    K3N1 @ K3N1: Whoever developed Bramble was smoking that good shit fucking gnomes