Coding in C++
Page 1 of 1
Coding in C++
Hello I'm gonna show you all how to make a simple trainer in C++.
Setup
Now we're gonna create our project.
Go to File -> New -> New project -> Win32 Project.
Call the project TwistTut for this tutorial.
After you've done that you should see an application wizard.
Click next.
Click DLL On application type.
And on additonal options click Empty Project.
Now you can click Finish.
Creating Files
Right click Header Files -> Add -> New Item -> Windows form.
Call it Form1 for this tutorial.
You should see a pop-up asking you something, just click yes.
You should see 2 files now, Form1.h and Form1.cpp.
If you wanna keep your source neat and good-looking move the .cpp file to source files by drag n dropping it.
Form1.h
Right click Form1.h in your solution explorer and click View Code.
On the first line add
Double click Form1.cpp to open it, there's really just 1 line there and thats the line that includes the .h file.
On the first line in Form1.cpp type
Now right click Source files -> Add -> New Item -> C++ File.
Call it MainDLL for this Tutorial.
MainDLL
Now we're finally gonna create the .dll!
on the first line of MainDLL.cpp add this:
And in the third line, add this:
Now, the last part of the code in MainDLL.cpp
Moment of truth
Change Debug on top of your Visual Studio to Release.
Now ontop of your Visual Studio Click build -> Build solution.
If you did all of this right you should get this:
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Now you can try injecting it, locate the DLL by going Docs -> Visual Studio -> Projects -> TwistTut -> Release -> DLL.
Adding A Hack.
So, now we're gonna add a hack to our form.
Double click Form1.h to get to the design.
In the top right corner you should see a toolbox, click it.
find checkBox, drag it to your form and drop it.
Now double click it, you should be redirected to Form1.h
You should see this:
Remove the } Under it.
So it looks like this.
We're gonna use a script called Super Tubi. (eMS v70)
we'll cover JMP scripts and codecaves later on.
If you look at the script it has 1 Addres. 00488083
We can write that as a DWORD
So jump down to the end of your code in Form1.cpp and write
Now, let's write the enable and disable bytes.
Let's see our script has 2 Enable bytes which are: 90 90
Write this:
The disable bytes also has 2 bytes because we edited 2 bytes which needs to be reseted when being unticked.
Now, on top of your Visual Studio click Build -> Build project.
If it succeded go inject it, but inject a bypass first and test the hack!
Setup
Now we're gonna create our project.
Go to File -> New -> New project -> Win32 Project.
Call the project TwistTut for this tutorial.
After you've done that you should see an application wizard.
Click next.
Click DLL On application type.
And on additonal options click Empty Project.
Now you can click Finish.
Creating Files
Right click Header Files -> Add -> New Item -> Windows form.
Call it Form1 for this tutorial.
You should see a pop-up asking you something, just click yes.
You should see 2 files now, Form1.h and Form1.cpp.
If you wanna keep your source neat and good-looking move the .cpp file to source files by drag n dropping it.
Form1.h
Right click Form1.h in your solution explorer and click View Code.
On the first line add
- Code:
#include <Windows.h>
Double click Form1.cpp to open it, there's really just 1 line there and thats the line that includes the .h file.
On the first line in Form1.cpp type
- Code:
#include <Windows.h>
- Code:
using namespace TwistTut;
- Code:
void Main(void)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew Form1); //change Form1 this to the name of your Form
Application::Exit();
}
Now right click Source files -> Add -> New Item -> C++ File.
Call it MainDLL for this Tutorial.
MainDLL
Now we're finally gonna create the .dll!
on the first line of MainDLL.cpp add this:
- Code:
#include <Windows.h>
- Code:
extern void Main(void);
And in the third line, add this:
- Code:
::BOOL WINAPI DllWork ( __in ::HMODULE hModule )
{
Main();
return true;
}
Now, the last part of the code in MainDLL.cpp
- Code:
::BOOL WINAPI DllMain ( __in ::HMODULE hModule, __in ::DWORD dwReason, __in __reserved ::LPVOID lpvReserved )
{
::HANDLE hThread = NULL;
if ( dwReason == DLL_PROCESS_ATTACH )
{
if (( hThread = ::CreateThread(NULL, 0, (::LPTHREAD_START_ROUTINE)&DllWork, (::HMODULE)hModule, 0, NULL) ) == NULL )
{
return FALSE;
}
if ( ::CloseHandle(hThread) == FALSE )
{
//do nothing
}
}
return TRUE;
}
Moment of truth
Change Debug on top of your Visual Studio to Release.
Now ontop of your Visual Studio Click build -> Build solution.
If you did all of this right you should get this:
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Now you can try injecting it, locate the DLL by going Docs -> Visual Studio -> Projects -> TwistTut -> Release -> DLL.
Adding A Hack.
So, now we're gonna add a hack to our form.
Double click Form1.h to get to the design.
In the top right corner you should see a toolbox, click it.
find checkBox, drag it to your form and drop it.
Now double click it, you should be redirected to Form1.h
You should see this:
- Code:
private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
}
};
}
Remove the } Under it.
So it looks like this.
- Code:
private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e);
};
}
We're gonna use a script called Super Tubi. (eMS v70)
- Code:
[Enable]
//v70
00488083: //75 36 83 7C 24 0C 00 75 19 8B 86 ?? 20 00 00 FF 70 65 83 C0 61
db 90 90
[Disable]
00488083:
db 75 36
we'll cover JMP scripts and codecaves later on.
If you look at the script it has 1 Addres. 00488083
We can write that as a DWORD
So jump down to the end of your code in Form1.cpp and write
- Code:
DWORD SuperTubiAddy = 0x00488083;
Now, let's write the enable and disable bytes.
Let's see our script has 2 Enable bytes which are: 90 90
Write this:
- Code:
BYTE enableSuperTubi[] = {0x90, 0x90}; //Here we enable the hack by editing the bytes.
The disable bytes also has 2 bytes because we edited 2 bytes which needs to be reseted when being unticked.
- Code:
BYTE disableSuperTubi[] = {0x75, 0x36}; //Disables the hack by resetting the bytes.
- Code:
void Form1::checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
{
unsigned long oldProtect;
VirtualProtect((LPVOID)SuperTubiAddy, 2, PAGE_EXECUTE_READWRITE, &oldProtect);
if(this->checkBox1->Checked)
{
memcpy((void*)SuperTubiAddy, enableSuperTubi, sizeof(enableSuperTubi));
}
else
{
memcpy((void*)SuperTubiAddy, disableSuperTubi, sizeof(disableSuperTubi));
}
}
- Code:
unsigned long oldProtect;
VirtualProtect((LPVOID)SuperTubiAddy, 2, PAGE_EXECUTE_READWRITE, &oldProtect);
Now, on top of your Visual Studio click Build -> Build project.
If it succeded go inject it, but inject a bypass first and test the hack!
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum