domingo, 19 de octubre de 2008

How To Build A Visual Basic Trainer! V1.0

If you’re going to password protect your trainer, I suggest that for form 1 you should make that the form that is password protected.

Introduction:

When you start VB a menu will pop up.
Click on Standard EXE.
There is a properties box; you can edit the look, color and a lot more
There is your project box, when you have multiple forms, modules or other projects open this will help you navigate easier.
You must add a module to make a trainer, to add a module follow the instructions below.
Go to the project button at the top and click add module. A box will popup, in the box you will insert the code below.

Module Code:

Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVallpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Long
Private Declare Function ReadProcessMem Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Public Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Long) As Integer
Public Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
Public Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Public Sub WriteAInt(Address As Long, Value As Integer)
Dim hwnd As Long, pid As Long, phandle As Long
'2: 9090, write in reverse
hwnd = FindWindow(vbNullString, "Delta Force 2, V1.06.15")
If (hwnd <> 0) Then
GetWindowThreadProcessId hwnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle <> 0) Then
WriteProcessMemory phandle, Address, Value, 2, 0&
End If
CloseHandle phandle
End If
End Sub

*NOTE*
Where it says Delta Force 2, V1.06.15 you can change that to any game name, just find the window name by alt-tabbing out of the game.
You can add a button 2 ways. You can click the button and draw the button or double click the button for a set height and width.



Adding Pokes to the Button:

Now say we want to make GPS ON for DF2. We would double click the button and put Call WriteAInt(&H42697C, &H9090) and GPS OFF would be Call WriteAInt(&H0042697C, &H757E)
Now you do the same with GPS OFF just make another button and put the off code in it. That’s all that’s to coding a button.


Adding color to your project:

In this tutorial I will teach you how to add color to your project. First we will add color to the form. First click on the form. Now go over to the properties box on the right.
Now scroll down to where it says Backcolor and choose whatever color you want.
Now to change a buttons color click on the button and then scroll down to Style and choose the option 1 - Graphical. Now scroll up to Backcolor and change that to whatever you want your button color to be. You can also change the font color, size and style from the properties box.

Freezing Buttons:

This tutorial will explain how to freeze a button for an option like freeze ammo. The first thing you need to do is add a timer.
After doing that you will need to click the time and go over to the properties box and put the Interval at 100 and Enabled=True. Now double click on the time and in between the Private Sub Timer1_Timer () and End Sub enter your addy and value code like I did below. (I used the GPS code for DF2)

Call WriteAInt(&H42697C, &H9090) <---On Addy.

Now all we did was make the code freeze, but now we want to make the code freeze and unfreeze when we click it. So now double click on the the button (I’m using the GPS code on and off) and insert the code below in the button.

If Timer1.Enabled = True Then
Timer1.Enabled = False
Command1.Caption = "Gps OFF"
Else
Timer1.Enabled = True
Command1.Caption = "Gps ON"
End If

The words in gray you need to change according to what you call the timer and button.

Message Box:

In this tutorial I am going to show you how to make those annoying message boxes that popup when you start a trainer, for an About or Help button, and for leaving a trainer. First thing we will do is add one to popup when the trainer starts. Let’s start by double clicking on the form. Now a box will popup. The left drop down box choose Form and the right choose Load. Now insert the code below between the Private Sub Form_Load() and End Sub.

MsgBox "Text Here"

Now to add the code MsgBox "Text Here" to a button and you got a help or about button. Now the same goes for leaving a trainer as it did with loading a trainer, just choose form on the left and UnLoad on the right and add the code MsgBox "Text Here"
Now I will show you some other commands for message boxes. You know when you get an error in windows and you get that noise with the X on the top of the dialog box, well we can do that in VB also. I have put all the commands below and an example.

system vbSystemModal
normal vbApplicationModal
foreground msg box vbMsgBoxSetForeground
error vbCritical
exclamation vbExclamation
information vbinformation
question vbquestion

Now here is 1 example on how to use these. Say I wanted to use question. I would put MsgBox "Text Here”, vbquestion
This goes the same for the rest of them above. If you need more help ask in the forums.

Hotkeys:

Alright now were on to the hotkeys tut. First of all if you don't have a working trainer by now without hotkeys you should not read this tut until you can at least make a trainer that WORKS. Anyway lets get on with the tut. First you need to add a timer. Then set the timer to your form with the following settings.
Enabled=True
Interval=1
Now you need to double click the command button and add your code like usual.
Call WriteAInt(&H42697C, &H9090) (I'm using the GPS ON Addy)
Now double click on the timer that you added and add the following code.
If GetKeyPress(vbKeyyourkeyhere) Then Call WriteAint(&H42697C, &H9090) (Text in gray is your key *ex* vbKeyShift or vbKeyCTRL)
That's all there is to Hotkeys. If you have any questions or need help feel free to ask on the forums.

Adding Graphics:

Now you know some people have Progress Bars or other stuff on their trainer. Well in this tut I will show you how to get all those options. First you need to go to Project then go down to Components...
Now on the tab Controls go down to where it says Microsoft Windows Common Controls 6.0 and check that and press OK.
Now you should have a few more options on your tool bar like I have below.
Now as always if you need help with this tutorial go to the forums and ask.

Checkboxes:

This tutorial will teach you how to use checkboxes to turn trainer options on. First you open up a project add your module then add a checkbox. Now open the first checkbox and put the code below in. I'm using GPS ON and OFF as an example.

If Check1 = Checked Then
Call WriteAInt(&H0042697C, &H9090) (<--GPS ON)
Else
Call WriteAInt(&H0042697C, &H756E) (<--GPS OFF)

Now when you check the checkbox the code is activated and when you uncheck the checkbox the code is deactivated
*NOTE*
You can do the same with the option button.

Password Gate:

You may want to password protect a squad trainer or anything else you make. You need to make 1 button and 1 textbox.
Now you need to add * or any other symbol in the PasswordChar option in Properties.
Now add the code below to your button.

Private Sub cmdStart_Click()
If txtPass.Text = "passwordhere" Then
Main.Show
Else
Unload Me
NeedPass.Show
End If
End Sub

Now the gray color text in there is what you need to change according to what you call stuff. For ex. txtPass is the name of your textbox
and Main is the name of the window the trainer options are on.
Form1 is the form the password protection is on and Main is the trainer window with the options on it.

Building your Trainer:

Now assuming your done designing and coding your trainer we can make it into an exe. First of all save all your stuff by going to Save Project. Then after you do that go to File and Make projectname.exe.
Now you may see a box come up and it will highlight a line of code, that means that there is something missing or wrong in that line of code and it will not make the trainer, but if no box comes up then that means your trainer was made successfully and you can now make a trainer in VB.

Converting Poke Codes to VB Codes:

If you have a lot of Poke Codes and you don't want to find the Codes for VB (Visual Basic) then look below. Ok let's say the Poke Code is Poke 0042697C 90 90 (GPS On). Take Poke away and put Call WriteAInt(&H0042697C, &H9090) and there you go. You have the VB Code.

NOTE: Not all Poke Codes work when they convert!

:: Hyper Link ::

This tutorial shows you how to add a hyper link to your application.


Add this code to your module,

:: Code ::
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Function OpenBrowser(Frm As Form, ToOpen As String)
ShellExecute Frm.hwnd, "Open", ToOpen, &O0, &O0, SW_NORMAL
End Function


And the easy bit is your button code,

:: Code ::
OpenBrowser Me, "http://www.vbtrainer.cjb.net" ' Put your link here

This code can be put on form load, form unload, button click, label click or any other option you chose.

:: Trainer Protection ::

This is how to protect your trainer against, T Spy and Trainer Snoop.


General Declaration/Module code

:: Code ::

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Long

This code is used for Window names.


Function codes - We can't have the 2 Window Names in 1 Function.

:: Code ::

Public Function CheckSpy1() As Long ' The Spy Protection Function for Trainer Snoop
CheckSpy = FindWindow(vbNullString, "TRNSNP") ' Checks for the window name of Trainer Snoop
End Function ' Ends function

Public Function CheckSpy2() As Long ' The Spy Protection Function for T Spy
CheckSpy = FindWindow(vbNullString, "TrainerSpy XP + NT / 2000 / XP + Coded By BofeN") ' Checks for the window name of T Spy XP
End Function ' Ends function

This is the function that the form load calls to check if the programs are open.


Form Load

:: Code ::

Private Sub Form_Load() ' Form Load
If CheckSpy1() <> 0 Then ' Starts the function
MsgBox "Why are you spying on me?", vbCritical, "Error!" ' Shows a message box
Unload Me ' Closes the trainer
Exit Sub ' Exits sub routine
End If ' Ends If statment

If CheckSpy2() <> 0 Then ' Starts the function
MsgBox "Why are you spying on me?", vbCritical, "Error!" ' Shows a message box
Unload Me ' Closes the trainer
Exit Sub ' Exits sub routine
End If ' Ends If statment
End Sub ' Exits sub routine

This is just a quick look at using a menu in VB6
1/ Click on the Add menu tab in VB

2/ This should now open up a new window in your VB program
• In the caption Box enter the name which you would like to see i.e. File
• In the name box enter a name which you would know it by I use the same name as in the caption box
• In the Index box just enter 1 as it is the 1st one in your menu.

2/ This should now open up a new window in your VB program
• In the caption Box enter the name which you would like to see i.e. File
• In the name box enter a name which you would know it by I use the same name as in the caption box
• In the Index box just enter 1 as it is the 1st one in your menu.

3/ Lets add some more to our menu. I want to add a sub menu under the File menu this could be “ Print Page, Save , Exit and so on “ all we need to do is click on the Next tab in the Menu Editor . Now click on the right arrow tab you should now see four little dots and the Caption and the Name box are now clear, in the caption box enter the name of your new sub menu ( for this just type in Show Speed ) in the name box type in (speed) and in the index box type ( 2 ) . You can now add a short cut to Show Speed , just click on the short cut dropdown box and set it to (CTRL + A) this is going to add a short cut to your Show Speed later on .

4/ Do the same again but this time in the Caption and the Name box enter (Exit) and set the index box to (3) and set the short cut to (CTRL + X)

5/ Now click the Next Tab again but this time press the left arrow tab to take of the 4 dots as we now want to add a help tab to our menu., In the caption Box type in (Help) and in the name box type in (help) and set the index box to 4

6/ Now it’s the same as step 3 but this time enter ( Show Help and set the short cut to CTRL + H and the Index box to 5

Now click on the OK tab

Run your form and have a look to see what it looks like . In part 2 we look at adding commands to your menu

Part 2
1/ the 1st thing we are going to do is add a button to your form and set its name to cmd_speed and its caption to speed. Now dbl click your form and type in
Private Sub Form_Load()
cmd_speed.Visible = False
End Sub
If you run the form now you won’t be able to see the Speed button what we need to do now is add a command to the menu and so when you click on or use the short cut that we can see the Speed button.
2/ Click on to the menu and then click on Show Speed and type in
Private Sub speed_Click(Index As Integer)
cmd_speed.Visible = True
End Sub
Now run your form and try out your menu
Do the same again but this time for the Exit in the menu and type in
Private Sub exit_Click(Index As Integer)
End
End Sub
This now lets you close down your program when you press the EXIT in your menu or if you press CTRL + X
The nice thing about using a menu is that you can hide things away and cut down on the number of buttons you have on your program and just call them up then you need them.
In part 1 we added a Help to our menu this is if you want to add a help to your program you may want to show your help keys etc.

No hay comentarios: