Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial C++ Trainer without dll injection
#1
Today we're gonna learn how to make your very own trainer in C++, without DLL injection of any sort. Smile

Credits:
n0n3


Knowledge needed/optional:

Basic C++ coding "skillZ"

Basic understanding of the PE and finding an address with Cheat Engine ;P


Ok let's get to it then.

Our target today is Windows's pinball game (start->run->"pinball")


First, declarations.


Code:
    HWND hWnd;

    DWORD dwID;

    HANDLE hProcess;

hWnd = Window Handle.

dwID = Process ID.

hProcess = Process Handle.


Defined in windows.h btw, so #include <windows.h>


Let's recover the window handle then.


Code:
    hWnd = FindWindow(NULL, "3D Pinball for Windows - Space Cadet");


FindWindow's return value is the HANDLE of the window.

For more info goto msdn. (google->msdn)


Let's recover the process id.


Code:
    GetWindowThreadProcessId(hWnd, &dwID);

For more info goto msdn, this isn't difficult at all.

We recovered the process's ID.


Next, process handle.

Code:
hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, dwID);

Process security and access rights - Process Security and Access Rights (Windows)


PROCESS_ALL_ACCESS, hmm, I wonder what that might be.

Anyways, we don't need the second argument, and the third argument is the process ID.

If function works successfuly returned value is the process handle, which is exactly what we need.


Error handling would look like this:

Code:
hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, dwID);

if(hProcess == NULL)

       whatever //error


Here comes the fun part ;D


Code:
int value = 1000000;

WriteProcessMemory(hProcess, (LPVOID) 0x00C20C62, (LPVOID) &value, sizeof(&value), NULL);

hProcess = Process handle.

(LPVOID) typecasting - needed.

0x00C20C62 - "Score" address in pinball.

(LPVOID) typecasting - needed.

&value - pointer to the value integer (1000000)

Next argument is number of bytes to be written (size)

So we use sizeof for it to work well.


We don't need the next parameter.


Full program will look like this:

Code:
#include <iostream>

#include <windows.h>


using namespace std;


int main()

{

    HWND hWnd;

    DWORD dwID;

    HANDLE hProcess;


    hWnd = FindWindow(NULL, "3D Pinball for Windows - Space Cadet");


    GetWindowThreadProcessId(hWnd, &dwID);

    hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, dwID);


    int value = 1000000;

    

    WriteProcessMemory(hProcess, (LPVOID) 0x00C20C62, (LPVOID) &value, sizeof(&value), NULL);

    return 0;

}


Guess what, it works, and you've just made a pinball trainer in C++ Smile

I'm so proud of you ;')

Reply

#2
Omg hacks, thanks
Reply

#3
Big GrinDDDDDDD
Reply

#4
Thanks, I was wanting to start making hacks like this (and then apprimorate).

Many thanks for the comments man!

By the way, is there a ".Contains" in FindWindow?

EDIT:

I'm getting this error on
Code:
hWnd = FindWindow(NULL, "3D Pinball for Windows - Space Cadet");

Code:
error C2664: 'FindWindowW' : cannot convert parameter 2 from 'const char [37]' to 'LPCWSTR'

EDIT:

I found that using FindWindowA fixes.
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Release] Black Ops Single Player/Zombie Trainer V3.6 Craig87 52 82,583 07-01-2013, 15:12
Last Post: explosivebanana55
  [Release] LF's BO2 Trainer (Latest Version) LegitFlash 3 4,750 06-11-2013, 18:14
Last Post: surtek
  Black Ops 2 DLC camo trainer surtek 10 10,220 04-19-2013, 23:16
Last Post: Gladio
  Black Ops 2 camo trainer surtek 33 27,285 04-16-2013, 11:07
Last Post: surtek
  Saint Row: The Third - +7 Trainer - Steam v1.0.0.1 - DX10/11 d0h! 5 29,927 03-02-2013, 15:31
Last Post: BunnySkills
  [Release] [DETECTED] Black ops 2 Zombie Trainer dylankrajewski 8 14,981 02-09-2013, 10:07
Last Post: Erik The Born
  Preview BarataConsole Trainer/Mod/Plugin API JariZ 1 2,919 02-05-2013, 23:59
Last Post: barata
  [Release] MW3 +12 Singleplayer Trainer 1.9.453 by Geomatrical Silencemod 15 10,856 01-18-2013, 21:54
Last Post: JariZ
  Black Ops 2 emblem trainer surtek 3 5,543 12-17-2012, 17:23
Last Post: surtek
  Black Ops 2 token trainer surtek 4 4,995 12-16-2012, 04:37
Last Post: Stocker

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.