Post: [Tutorial] C# CEX/DEX Tool Tutorial (Anti-Ban example)
02-13-2014, 07:08 AM #1
FarSideX
I’m too L33T
(adsbygoogle = window.adsbygoogle || []).push({}); Now that everyone has made a tool for Anti-Ban for Ghosts 1.07 I chose that as tool to make a tutorial for. I chose that because some of the posted tools have avoidable errors in them.

If you make a tool from this DO NOT post it. There are far too many people posting tools they made that do the same thing as everyone else's. The nice thing about making your own personal tool is you will know there is no ID stealers or viruses in them. It is also nice to personalise them.

What will you learn from this tutorial?

I have included a simple way of setting up PS3Lib to support CEX and DEX, how to toggle a button's function, the proper way to use two radio buttons, and a safe way of ensuring that the Anti-Ban is going to work among the usual stuff. Also one reason people get banned even after they use these tools is addressed (not doing verification).

Let's get started!

What you will need:

Visual Studio
Enstone's CCAPI.dll (included)
iMCSx's PS3Lib.dll

Note: I used VS 2012 Ultimate, you will need that if you want to use the solution that I will provide but it is not necessary as you can copy/paste the code into an older version if you want to.

Open Visual Studio and start a new C# Windows Forms project. Name it whatever you like, I used "RTE_Tool_Tutorial".
In the solution explorer right click on References and choose Add reference. Use Browse and find PS3Lib.dll and add it.
In the form designer add 1 button and 2 radioButtons to the form, arrange however you like. Mine looked like this.

You must login or register to view this content.

At this point you can compile what you have by pressing start and it will create the directories you will need.
Now you need to copy Enstone's CCAPI.dll into the directory the app runs from.. At this point it will be in your project directory under bin/debug. Copy the dll there, the PS3Lib.dll should already be there since you reference it in your project.

In the solution explorer, right click on Form1.cs and select View Code. This will open up the file you use to write code that extends the Form class. You can copy the code below and paste it over what is in that file replacing all the contents, or type it out yourself. I recommend typing it as you will learn more by doing so.

    
/**************************************************************************************************************
* Simple C# RTE Tutorial v1.0 by FarSideX
* Default names of controls given by the designer were kept for ease of duplicating the tutorial,
* normally you should rename them with more descriptive names.
* Although this program is ment for learning purposes it does function to block banning in
* Call of Duty: Ghosts v1.07 by replacing a branch with link register update (bl)
* with ori 0,0,0 (nop). This method was, to the best of my knowledge, first publicly posted by
* Red-EyeX32 on NGU. I personally think there are better ways of doing Anti-Ban.
* But it works so who am I to judge Smile
**************************************************************************************************************/
using System; // namespaces we will be using System and Forms, also PS3Lib
using System.Windows.Forms;
using PS3Lib; // Add PS3Lib.dll by iMCSx to references

namespace RTE_Tool_Tutorial // This is our namespace, namespaces allow us to use the same varibles, etc. as other namespaces
{ // change this if you started a new project with a different namespace

public partial class Form1 : Form // We will be extending the Form class with our own methods
{
private PS3API PS3 = new PS3API(); // create an instance of iMCSx's PS3API

private static UInt32 antiBanOffset = 0x00556638; // set offsets in static varibles so you only need to update one spot
// when there is an update

private UInt32 orgOpcode; // this will be used to hold the orginal contents of the memory we change

public Form1() // This construtor is called after our Base class is instantiated
{
InitializeComponent(); // Initalizes all the stuff you did in the designer and VS wrote the code for you
}

// Form1_Load is called once your form is loaded into memory and the inital constructor is finished
// This is where we finish setting up our controls, it could be done in the constructor also
//
private void Form1_Load(object sender, EventArgs e)
{
this.Text = "Anti-Ban"; // set the form's title, can also be done in the designer under Form1 properies
button1.Text = "Enable"; // set the text on the button, we will be changing this later when we toggle the button
radioButton1.Text = "TMAPI"; // set first radioButton to be SN System's Target Manager API
radioButton2.Text = "CCAPI"; // set second radioButton to be Enstone's Control Console API
radioButton1.Checked = true; // set TMAPI as default API; setting this here will cause a CheckChanged event to occur
}

// radioButton1_CheckedChanged event handler
// This private method is where we set which API PS3API is to use
// Past this we do not have to make any differentaion between using Target Manager or Control Console APIs
// Only one CheckChanged event handler is required because there are only two radioButtons and the
// event occurs when it changes and not only when set, when using more than two consider using a checkedListBox or array.
// Do not use an eventhandler for both as both will be called
//
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked == true) // Inspect radioButton state to determine which is selected
PS3.ChangeAPI(SelectAPI.TargetManager); // If true let PS3API know we want TargetManager APi
else
PS3.ChangeAPI(SelectAPI.ControlConsole); // If false we want ConsoleControl API
}

// button1_Click event handler
// this is where all the work is done
// I consider the nested if/else statements to be messy, normally this can be avoided with the use of exceptions
// but unfortunatly some libraries do not make use of them leaving few options for more effient and cleaner code.
//
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "Enable") // When button1.Text == "Enable' we insert the hack code
{
if (PS3.ConnectTarget()) // Connect to target PS3, CCAPI users will see a dialog to enter the PS3's IP
if (PS3.AttachProcess()) // Attach to the main game process
{
orgOpcode = PS3.Extension.ReadUInt32(antiBanOffset); // ReadUInt32 should throw an exception but it doesn't and has no error reporting
PS3.Extension.WriteUInt32(antiBanOffset, 0x60000000); // No exception, no error report, verify needed
if (PS3.Extension.ReadUInt32(antiBanOffset) == 0x60000000) // Verify the data was written as PS3Lib does not provide any error reporting
{ // and there is no in game signs if this worked or not
MessageBox.Show("Anti-Ban activated!"); // Let user know it was a success!
// Environment.Exit(); // For an anti-ban only tool exiting app here would be a good idea
// Uncomment it to have the app close after anti-ban is set.
button1.Text = "Disable"; // Success! Change button text so we can toggle its function
radioButton1.Enabled = false; // disable radioButtions so API does not get changed
radioButton2.Enabled = false;
}
else
MessageBox.Show("Verify failed!\nAnti-Ban is not active, PS3 may not be stable please retry.", "Warning!");
}
else
MessageBox.Show("Unable to attach to Ghosts.\nAnti-Ban is not active", "Warning!");
else
MessageBox.Show("Unable to connect to PS3.\nAnti-ban is not active.", "Warning!");
}
else // button1.Text == "Disable" so we restore the Anti-Cheat code, This is just for demonstration purposes
{
PS3.Extension.WriteUInt32(antiBanOffset, orgOpcode); // write back the data we stored
if (PS3.Extension.ReadUInt32(antiBanOffset) == orgOpcode) // verify the write
{
MessageBox.Show("Anti-Cheat restored.\nDo not mod while online.");
PS3.DisconnectTarget(); // Disconnect in case user wants to change targets
button1.Text = "Enable"; // change button1.Text for toggle
radioButton1.Enabled = true; // enable radioButton again
radioButton2.Enabled = true;
}
else
{
MessageBox.Show("Failed to restore Anti-Cheat.", "Warning");
}
}
}

// These last two methods are not required. I use them to prevent myself from picking up too many bad habits
// while coding in C#. If you truly want to learn to program I suggest you choose another less hand holding type of
// programing language such as C or assembly or even PHP. These languages allow you to learn by making mistakes.
// Yes they are more difficult to learn but that is the whole point, C# is more like an application construction set.

// This is called before the form closes
// Since our cleanup is brief we can do it here rather than after the form closes
//
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
PS3.DisconnectTarget(); // Cleanup connection
}

// This is called after the form closes
//
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
GC.Collect(); // Force garbage collection. Not required but not a bad idea either
}
}
}


If you gave a different name to your project the namespace will not match. On the line (15) that has:
    namespace RTE_Tool_Tutorial

change it to match the name you used to start your project.

Read through the source. It is heavily commented. If you have any questions I will answer them as best I can.
Also if you would like to see how something is done just ask.

You must login or register to view this content. Activision is currently wrongfully claiming copyright ownership to this file, use other link.
You must login or register to view this content.
Admin: I posted this in this forum as it does include a tool, move it if you feel it fits in better elsewhere.
(adsbygoogle = window.adsbygoogle || []).push({});

The following user thanked FarSideX for this useful post:

Frozenskies
02-13-2014, 11:20 AM #2
Edit: I found it but how do I paste something in the bin/ debug folder?
02-13-2014, 12:39 PM #3
RatchetBooty
Former Staff
Originally posted by Frozenskies View Post
Edit: I found it but how do I paste something in the bin/ debug folder?


Build the project again. Re-build and the .exe will be in the debug folder. If not its in the release folder.

Anyways good stuff FarSideX, keep it up! I'm sure this will help the people that are trying to learn c#.
But I've never heard of the G.Collect(); function, is it any useful?
02-13-2014, 04:24 PM #4
FarSideX
I’m too L33T
Originally posted by RatchetBooty View Post
Build the project again. Re-build and the .exe will be in the debug folder. If not its in the release folder.

Anyways good stuff FarSideX, keep it up! I'm sure this will help the people that are trying to learn c#.
But I've never heard of the G.Collect(); function, is it any useful?


GC.Collect() causes the garbage collector to test for all freed managed objects and disposes them to allow for maximum memory to be returned to the system for use. It is like calling Dispose on all unused managed resources that don't have accessible Dispose methods. I like my apps to behave well with others so I am just being nice to the system by calling it rather than waiting for the collector to get around to it. Using it also helps me not forget to do so when using languages that require you to free up resources on your own. (Basically every other language except C#, Objective-C, Java and a few others)
02-13-2014, 04:44 PM #5
I get this error now: a using clause must precede all other elements defined in the namespace except extern alias declarations

It's in this part

using System;
using System.Windows.Forms;
using PS3Lib;
02-13-2014, 04:59 PM #6
FarSideX
I’m too L33T
You may have gotten an error from the word wrap added by the forums software in the code. Try fixing the comments that come before the line
    using System;
If that was the case you may get other errors due to line wrap. If so you will have to repair the comments at the end of each line, they should not have a hard CR.
02-13-2014, 06:24 PM #7
c++:
    BYTE Patch[4] = {60, 00, 00, 00};//0x556638 thanks to red eye Winky Winky
SNPS3InitTargetComms();
SNPS3ProcessSetMemory(0xfffffffe, 0, 0x1030600, 0, 0x556638, 4, (const BYTE *)Patch);
02-13-2014, 06:54 PM #8
VezahMoDz
Do a barrel roll!
Originally posted by milky4444 View Post
c++:
    BYTE Patch[4] = {60, 00, 00, 00};//0x556638 thanks to red eye Winky Winky
SNPS3InitTargetComms();
SNPS3ProcessSetMemory(0xfffffffe, 0, 0x1030600, 0, 0x556638, 4, (const BYTE *)Patch);



Would you mind adding me in skype? Smile foxboy_99_ =D
02-13-2014, 08:02 PM #9
FarSideX
I’m too L33T
Please use this as it was intended as a tutorial only.
02-13-2014, 11:40 PM #10
Originally posted by VezahMoDz View Post
Would you mind adding me in skype? Smile foxboy_99_ =D

sure, but i wont be on alot today

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo