INTRODUCTION
Long ago, Darthatron made a tutorial on how to code a tool in VB, using Visual Basic 6.
To be honest, meh. His tutorial is very old and not up to date. Other than that, the programming language VB sucks, comparing to C# and Java.
Few weeks ago, I finished a Java course in a college that teaches computer science. Unfortunatly, I only know how to use Java as a console, so I decided to try to learn C# too. I found Java and C# pretty similar to each other, so if you already know Java, I highly suggest you to learn C# too :).
That was pretty off-topic, eh?
Anyway, I tried to make a tool in C#, using the latest version of Visual Studio, Visual Studio 13, and you know what's cool about this tutorial? Unlike Darthatron's tutorial, it works with almost any Visual Studio, because I don't use any costum functions! It meants that if someone will see this tutorial, even more 100 years, he will still be able to use it in his latest Visual Studio (Visual Studio 2113?). The only way that this tutorial won't work is if Microsoft are going to change complete C#, which probably won't happen :).
Anyways, you will need:
- Visual Studio 2013
- Basic C# knowledge (if, true/false, else, all dat basic shet)
- A good name for your program (believe me or not, this is very critical. If you will call you program "Gal's Ultra Super Fantastic Mega Tool", it will atract more people than if you name it "Gal's Tool").
This tutorial will teach you making a very simple program, that enables/disables running shoes indoor, in FireRed only.
Well, let's start coding!
THE CODE
Start your VS and open a new Visual C# project. Now, go to the very top of your code. You should see lots of usages of the command "using". Make a new line after the last "using" ("using System.Windows.Forms;", and write:
Go back to your design and make 3 buttons and one label.
Change the name of the first button to "btnOpen" and change the text to "Open ROM",
change the name of the first button to "btnEnable" and the text to "Enable Running Indoor", the second to "btnDisable" and "Disable Running Indoor" and the label's text to "Loaded Game: ".
Disable btnOpen and btnEnable.
Make the window look like this:
Double click on your "Open ROM" button.
Let's make the Open ROM button.
Type in the line before "private void button1_Click(object sender, EventArgs e)":
What it does is it makes an integer called "ofd" to be the new open file dialog.
Now, go to the design again and double click on the Open ROM button again.
Type in the space here:
Don't get scared because of the code.
Every time you get scared because of the code, watch this video:
(unless you have epilepsy).
So, the binary reader is fine, now let's make the hex writing command.
The command is (spoiler alert):
OK, go back to your deigner and double click on "Enable Running Indoor" button.
Write in the space between the { } the following code:
Now, double click on the other button, the Disable Running Indoor button and copy the EXACT code in the Enable Running Indoor button. Just change the line bw.Write(0x00); with:
Now, the result should be:
Alternatively for these codes, you can also use itari's code. Check it out in this post: https://www.pokecommunity.com/posts/8411828/.
If you want to make the BinaryWriter read and replace text & offset from textboxes, see this post: https://www.pokecommunity.com/posts/8431971/.
Also, if you want to make your program support more than one or two versions, here is a template I made for you guys for the Open ROM button:
These are the version I remember. If you guys remember more versions or just want to fix a mistake I did, write it as a comment :).
DECORATE IT
Let's be real here. The design of this program is boring. Make a new design to make people want use this program.
This is what I did:
You guessed it - I am not the best designer in the world, but hey, I know how to make tools in C# :)
NOTES
This is the very basic of making tools. If you want the tool to read graphics from GBA, read from an INI file or read reverse hex, you will need to have functions.
You can make your own functions, or visit Jambo51's or SBird's GitHub. Link for their GitHub: https://github.com/Jambo51, https://github.com/SBird1337/Single.net.
If you guys have questions about the code or C#, comment in the thread. I will try to help you as much I can :).
If you have used this tutorial or the source code for this project, please credit me. I worked really hard on that tutorial ;).
Also, if you want to know why C# is the best language to use, check out SBird's post: https://www.pokecommunity.com/posts/8411792/.
You can download the source code on my GitHub: https://github.com/Omastars.
CREDITS
Microsoft - Making this amazing programming language.
Jambo51 - Pushing me to learn C#, instead of just sticking in VB.
HackMew - Running Indoors Hack (https://www.pokecommunity.com/threads/207026).
https://www.animalseatinganimals.com/ - Wombat Picture.
Unknown - Ditto Conga Video.
Please inform me if I forgot someone :D.
Spoiler:
Long ago, Darthatron made a tutorial on how to code a tool in VB, using Visual Basic 6.
To be honest, meh. His tutorial is very old and not up to date. Other than that, the programming language VB sucks, comparing to C# and Java.
Few weeks ago, I finished a Java course in a college that teaches computer science. Unfortunatly, I only know how to use Java as a console, so I decided to try to learn C# too. I found Java and C# pretty similar to each other, so if you already know Java, I highly suggest you to learn C# too :).
That was pretty off-topic, eh?
Anyway, I tried to make a tool in C#, using the latest version of Visual Studio, Visual Studio 13, and you know what's cool about this tutorial? Unlike Darthatron's tutorial, it works with almost any Visual Studio, because I don't use any costum functions! It meants that if someone will see this tutorial, even more 100 years, he will still be able to use it in his latest Visual Studio (Visual Studio 2113?). The only way that this tutorial won't work is if Microsoft are going to change complete C#, which probably won't happen :).
Anyways, you will need:
- Visual Studio 2013
- Basic C# knowledge (if, true/false, else, all dat basic shet)
- A good name for your program (believe me or not, this is very critical. If you will call you program "Gal's Ultra Super Fantastic Mega Tool", it will atract more people than if you name it "Gal's Tool").
This tutorial will teach you making a very simple program, that enables/disables running shoes indoor, in FireRed only.
Well, let's start coding!
THE CODE
Spoiler:
Start your VS and open a new Visual C# project. Now, go to the very top of your code. You should see lots of usages of the command "using". Make a new line after the last "using" ("using System.Windows.Forms;", and write:
Code:
using System.IO;
Go back to your design and make 3 buttons and one label.
Change the name of the first button to "btnOpen" and change the text to "Open ROM",
change the name of the first button to "btnEnable" and the text to "Enable Running Indoor", the second to "btnDisable" and "Disable Running Indoor" and the label's text to "Loaded Game: ".
Disable btnOpen and btnEnable.
Make the window look like this:
![[PokeCommunity.com] Make your own ROM hacking tool (C#) [PokeCommunity.com] Make your own ROM hacking tool (C#)](https://i.gyazo.com/665c19ad1f35f9be2b54b46d50b7814f.png)
Double click on your "Open ROM" button.
Let's make the Open ROM button.
Type in the line before "private void button1_Click(object sender, EventArgs e)":
Code:
OpenFileDialog ofd = new OpenFileDialog();
Now, go to the design again and double click on the Open ROM button again.
Type in the space here:
![[PokeCommunity.com] Make your own ROM hacking tool (C#) [PokeCommunity.com] Make your own ROM hacking tool (C#)](https://i.gyazo.com/2c0aee13ab7cfc077c7d61f3f9cbcc30.png)
Code:
ofd.Filter = "GBA File(*.gba)|*.gba"; //Makes a filter for the open file dialog. You don't want the user to open .NDS files, aren't ya?
ofd.ShowDialog();//Shows the open file dialog
string gameCode = string.Empty;//Makes a new string that will be used to the gamecode.
using (BinaryReader br = new BinaryReader(File.OpenRead(ofd.FileName))) //Sets a new integer to the BinaryReader
{
br.BaseStream.Seek(0xAC, SeekOrigin.Begin); //The seek is starting from 0xAC
gameCode = Encoding.UTF8.GetString(br.ReadBytes(4)); //Reads 4 bytes from 0xAC and encodes it to text
}
br.Close(); //Closes the BinaryReader. Without it, opening the file with any other command will result the error "This file is being used by another process".
if (gamecode == "BPRE") // Checks if the game code is BPRE.
{
label1.Text = "Loaded Game: Pokémon FireRed"; //If it's BPRE, it changes label1's text.
btnEnable.Enabled = true; //Enables btnEnable, if the gamecode is BPRE.
btnDisable.Enabled = true; //Enables btnDisable, if the gamecode is BPRE.
}
else //If the gamecode isn't BPRE.
{
label1.Text = "Loaded Game: ???"; //Changes label1's text.
btnEnable.Enabled = false; //Disables btnEnable, if the gamecode isn't BPRE.
btnDisable.Enabled = false; //Disables btnEnable, if the gamecode isn't BPRE.
MessageBox.Show ("The loaded game isn't supported"); //Creates a message box with the text "The loaded game isn't supported", since this program only supports FireRed (BPRE).
}
Every time you get scared because of the code, watch this video:
Spoiler:
(unless you have epilepsy).
So, the binary reader is fine, now let's make the hex writing command.
The command is (spoiler alert):
Spoiler:
Code:
BinaryWriter
OK, go back to your deigner and double click on "Enable Running Indoor" button.
Write in the space between the { } the following code:
Code:
BinaryWriter bw = new BinaryWriter(File.OpenWrite(ofd.FileName)); //Makes a new integer for the BinaryWriter. It also "tells" the BinaryWriter what file it should write.
for (int x = 0xBD494; x <= 0xBD494; x++) //Makes another integer that holds the first and the last offset you want the BinaryWriter to change. In the "running indoor" case, only 1 byte needs to be changed so both first and last offset are 0xBD494 (the location of the indoor running byte in FireRed).
{
bw.BaseStream.Position = x;
bw.Write(0x00); //0x00 is the byte you need to replace 0x08 with in order to make running indoor work. This code "tells" the BinaryWriter to write 0x00 at the specified offset.
}
bw.Close(); //Yet again, closes the BinaryWriter to avoid errors.
Now, double click on the other button, the Disable Running Indoor button and copy the EXACT code in the Enable Running Indoor button. Just change the line bw.Write(0x00); with:
Code:
bw.Write(0x08); //The old value.
Now, the result should be:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OpenFileDialog ofd = new OpenFileDialog();
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "GBA File(*.gba)|*.gba";
ofd.ShowDialog();
string gameCode = string.Empty;
using (BinaryReader br = new BinaryReader(File.OpenRead(ofd.FileName)))
{
br.BaseStream.Seek(0xAC, SeekOrigin.Begin);
gameCode = Encoding.UTF8.GetString(br.ReadBytes(4));
}
br.Close();
if (gamecode == "BPRE")
{
label1.Text = "Loaded Game: Pokémon FireRed";
btnEnable.Enabled = true;
btnDisable.Enabled = true;
}
else
{
label1.Text = "Loaded Game: ???";
btnEnable.Enabled = false;
btnDisable.Enabled = false;
MessageBox.Show("The loaded game isn't supported");
}
}
private void btnEnable_Click(object sender, EventArgs e)
{
BinaryWriter bw = new BinaryWriter(File.OpenWrite(ofd.FileName));
for (int x = 0xBD494; x <= 0xBD494; x++)
{
bw.BaseStream.Position = x;
bw.Write(0x00);
}
bw.Close();
}
private void btnDisable_Click(object sender, EventArgs e)
{
BinaryWriter bw = new BinaryWriter(File.OpenWrite(ofd.FileName));
for (int x = 0xBD494; x <= 0xBD494; x++)
{
bw.BaseStream.Position = x;
bw.Write(0x08);
}
bw.Close();
}
}
}
Alternatively for these codes, you can also use itari's code. Check it out in this post: https://www.pokecommunity.com/posts/8411828/.
If you want to make the BinaryWriter read and replace text & offset from textboxes, see this post: https://www.pokecommunity.com/posts/8431971/.
Also, if you want to make your program support more than one or two versions, here is a template I made for you guys for the Open ROM button:
Spoiler:
Code:
OpenFileDialog ofd = new OpenFileDialog(); //Sets a new variable to be OpenFileDialog
ofd.Filter = "GBA File(*.gba)|*.gba"; //Filter
ofd.ShowDialog(); //Shows the dialog
string gameCode = string.Empty; //Creates a new empty string
using (BinaryReader br = new BinaryReader(File.OpenRead(ofd1.FileName))) //Sets a new variable to be BinaryReader
{
br.BaseStream.Seek(0xAC, SeekOrigin.Begin); //0xAC is the beginning offset
gameCode = Encoding.UTF8.GetString(br.ReadBytes(4)); //Reads 4 bytes from 0xAC and encodes it to text
}
if (gameCode == "BPRE")
{
MessageBox.Show("FireRed English");
}
if (gameCode == "BPGE")
{
MessageBox.Show("LeafGreen");
}
if (gameCode == "BPRJ")
{
MessageBox.Show("FireRed Japanese");
}
if (gameCode == "BPGJ")
{
MessageBox.Show("LeafGreen Japanese");
}
if (gameCode == "BPRD")
{
MessageBox.Show("FireRed German");
}
if (gameCode=="BPGD"){
MessageBox.Show("LeafGreen German");
}
if (gameCode == "AXVE")
{
MessageBox.Show("Ruby English");
}
if (gameCode == "AXPE")
{
MessageBox.Show("Sapphire English");
}
if (gameCode == "AXVJ")
{
MessageBox.Show("Ruby Japanese");
}
if (gameCode == "AXPJ")
{
MessageBox.Show("Sapphire Japanese");
}
if (gameCode == "AXVD")
{
MessageBox.Show("Ruby German");
}
if (gameCode == "AXPD")
{
MessageBox.Show("Sapphire German");
}
else
{
MessageBox.Show("This version is currently unsupported");
}
DECORATE IT
Spoiler:
Let's be real here. The design of this program is boring. Make a new design to make people want use this program.
This is what I did:
![[PokeCommunity.com] Make your own ROM hacking tool (C#) [PokeCommunity.com] Make your own ROM hacking tool (C#)](https://i.gyazo.com/e7e1047d5f8502050841d3a86c76b29c.png)
You guessed it - I am not the best designer in the world, but hey, I know how to make tools in C# :)
NOTES
Spoiler:
This is the very basic of making tools. If you want the tool to read graphics from GBA, read from an INI file or read reverse hex, you will need to have functions.
You can make your own functions, or visit Jambo51's or SBird's GitHub. Link for their GitHub: https://github.com/Jambo51, https://github.com/SBird1337/Single.net.
If you guys have questions about the code or C#, comment in the thread. I will try to help you as much I can :).
If you have used this tutorial or the source code for this project, please credit me. I worked really hard on that tutorial ;).
Also, if you want to know why C# is the best language to use, check out SBird's post: https://www.pokecommunity.com/posts/8411792/.
You can download the source code on my GitHub: https://github.com/Omastars.
CREDITS
Spoiler:
Microsoft - Making this amazing programming language.
Jambo51 - Pushing me to learn C#, instead of just sticking in VB.
HackMew - Running Indoors Hack (https://www.pokecommunity.com/threads/207026).
https://www.animalseatinganimals.com/ - Wombat Picture.
Unknown - Ditto Conga Video.
Please inform me if I forgot someone :D.
Last edited: