Tool creating in VB6
Im writting this tutorial to show that the language that Experts cannot stand, but newcommers understand and like, can be used for more than you think! In writting this I enphasise that you must first understand that Visual Basic is at the bottom of the chart when it comes to compatibility. This is for you to create from to provide a sense of accomplishment rather than to be used as a basis of releasing Tools. Never the less lets move on!
1: CREATING THE BASIS
Load up Visual Basic and Create a Standard EXE. Create 2 CommandButtons and 1 TextBox. Give the buttons Captions of 'Open' and 'Save'. Make the Textbox have no text and lock it.(These options are in the right Under The Project Properties). Next you need to create a CommonDialog. This isnt in the default toobox you must add it yourself. To do this move your mouse over to the toolbox, right click, and go to 'Components..'. You can also use the shortcut (CTRL+T). Scroll the list to find 'Microsoft Common Dialog Control' Click apply.
When that is done there should be a new button in your toolbox. Click on it and put it in your application. You have just created the basic 4 items needed for a rom hacking tool!
2: THE COMMON DIALOG BOX
The Common Dialog Box has a few commands that we will need:
Show the Open file dialog.
Show the save file dialog.(Wont need it as were editing a file.)
The Full Path of the file loaded.(Must use ShowOpen first!)
The title of the file.(excluding the path)
So that is the basics of opening and using the CommonDialog.
3: USING COMMONDIALOG IN APPLICATION
To use this in a application you would first need to Show the 'Open file' dialog, next show the path in a text box. Use this in the 'Open' button Click:
CommonDialog1.ShowOpen 'Show the Open File Dialog
Text1.Text = CommonDialog1.FileName 'Set the textbox to the full path of file
Run that and you will see that clicking the 'Open' button will let you choose a file and display it's path in the textbox.
4. VISUAL BASIC FILE EDITING COMMANDS
Visual Basic has 2 commands that will read and get info from a file. But before using these we must open the file for editing and declare a byte value:
Open CommonDialog1.FileName For Binary As #1
That will open the file loaded for editing as "#1" and set the variable byte1 for use.
THE PUT COMMAND)
So know that we have the file opened for editing lets learn the code to edit it:
Put #1, &HFF44, byte1
The put command requires 3 things: The file that was oppened(#1), the offset to put data to, before continuing you must know that when dealing with HEX in VB use must use "&H" before the offset and for some reason you have to add 1 to the oringinal offset(FF43 would be FF44 in VB) and last the byte to put into the offset. So the code above would Put the byte '1' into the offset FF43 of a rom.
THE GET COMMAND)
So we have learned that the Put command writes to a file, so how would you get a byte from the rom? This requires the Get command:
Dim gotbyte As String
Get #1,&HFF44, gotbyte
This will get the byte of the offset FF43 and store it as the string gotbyte. If you wanted to write the byte in a textbox just use the code above and:
CLOSING A FILE
Text1.Text = gotbyte
When fishised with a file its nice to close it to not get errors when opening another file.
Closes the file oppened as #1.
5. THE OUTRO
So you have know learned the basics of opening, and editing a rom! Please remember that the offset you use is +1 in VB, and to always Dim variables before using them. And to close a file after using PUT or GET to avoid any errors. As stated first many people do not like Visual Basic because of its compatibility issues, but use this to create your own tools for any rom that you would like to hack. And if you do release to public dont forget to state that it was made in Visual Basic 6 and requires runtime files.
Happy Tool Making,