View previous topic :: View next topic |
Author |
Message |
igor Expert Cheater
Reputation: 1
Joined: 04 Apr 2012 Posts: 145
|
Posted: Sat Apr 21, 2012 2:17 pm Post subject: [VB.Net] How To Make Trainer |
|
|
Hi Hitler,
I want to create my own trainer in vb.net using Cheat Engine's Auto Assembler script.
This is the script i created for step 2 of tutorial-i386 v.3.1 and CE v.6.1
Code: |
[ENABLE]
alloc(newmem,1024)
label(returnhere)
newmem:
mov [ebx+00000458],(int)100 //Alt: db C7 83 58 04 00 00 64 00 00 00
jmp returnhere
"Tutorial-i386.exe"+20F3E:
jmp newmem
nop
returnhere:
[DISABLE]
dealloc(newmem)
"Tutorial-i386.exe"+20F3E:
sub [ebx+00000458],eax //Alt: db 29 83 58 04 00 00
|
Now how do I create trainer from above script.
check this i posted my problem here
forum.cheatengine.org/viewtopic.php?t=550892#5352203 _________________
r--._,---------------.
"-, .c-.-----------""
/ i--'
C__J
Last edited by igor on Mon Apr 23, 2012 5:49 am; edited 3 times in total |
|
Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Sat Apr 21, 2012 10:20 pm Post subject: |
|
|
Well, since you're using vb.net it's not possible for you to use inline assembly as C enables.
your other choice is using WriteProcessMemory method which means you have to write the script's bytes into the process's memory by yourself.
create 2 buffers, one containing the bytes with the enable script that turns on the script, and one containing the original bytes that turns off the script.
allocate virtual memory at the desired process (using VirtualAllocEx: read about all those api i tell you on msdn)
and use WriteProcessMemory to write those bytes at the allocated address.
to watch the bytes of the script just write it on CE as auto assembler script and watch it on memory view. _________________
Stylo |
|
Back to top |
|
 |
vnlagrla Cheater
Reputation: 0
Joined: 10 Apr 2011 Posts: 33
|
Posted: Sat Apr 21, 2012 11:04 pm Post subject: |
|
|
I can show you how to do it in c# if you want a quick trainer, but if you need VB i can learn it quick. so post back if you want my help |
|
Back to top |
|
 |
igor Expert Cheater
Reputation: 1
Joined: 04 Apr 2012 Posts: 145
|
Posted: Sun Apr 22, 2012 4:12 am Post subject: |
|
|
Stylo wrote: | allocate virtual memory at the desired process (using VirtualAllocEx: read about all those api i tell you on msdn)
and use WriteProcessMemory to write those bytes at the allocated address.
| Could you give me an example of VirtualAllocEx. I know how to use WriteProcessMemory but i don't know how to use VirtualAllocEx.
vnlagrla wrote: | I can show you how to do it in c# if you want a quick trainer, but if you need VB i can learn it quick. so post back if you want my help | I don't know C# well enough but you can give C# example I will get idea from it. _________________
r--._,---------------.
"-, .c-.-----------""
/ i--'
C__J |
|
Back to top |
|
 |
Pingo Grandmaster Cheater
Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Sun Apr 22, 2012 7:25 am Post subject: |
|
|
First off, dont use the name script in your threads, its gay.
Code: | <DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function VirtualAllocEx(ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As Integer, ByVal flAllocationType As UInt32, ByVal flProtect As UInt32) As IntPtr
End Function |
Code: | Public Function Alloc() As IntPtr
Return VirtualAllocEx(Process Handle here, IntPtr.Zero, &H200, &H1000, &H40)
End Function |
Deallocate using VirtualFreeEx
Since you can use writeprocessmemory, you should beable to finish from here. A simple way to calculate the the bytes is Cave - starting point - 5
If you cant figure it out, read the msdn.
At one point i wanted the same thing but i just created my own from scratch.
I simply gotta do this to create your script
Code: | Inject("Tutorial-i386.exe+20F3E", "C7835804000064000000", "298358040000") |
One click allocates and jumps to the cave. Another click deallocates and write the default bytes.
Keep working at it, it'l come to you. _________________
|
|
Back to top |
|
 |
igor Expert Cheater
Reputation: 1
Joined: 04 Apr 2012 Posts: 145
|
Posted: Mon Apr 23, 2012 5:22 am Post subject: |
|
|
Pingo wrote: | At one point i wanted the same thing but i just created my own from scratch.I simply gotta do this to create your script
Code: | Inject("Tutorial-i386.exe+20F3E", "C7835804000064000000", "298358040000") |
| How did you declare Inject Function? _________________
r--._,---------------.
"-, .c-.-----------""
/ i--'
C__J |
|
Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Mon Apr 23, 2012 1:37 pm Post subject: |
|
|
Inject is just a function he created to modify the desired bytes to it's own code that apply the hack.
Simply when u want to turn it off just "Inject" the original bytes to the exact address and the hack is off. _________________
Stylo |
|
Back to top |
|
 |
Pingo Grandmaster Cheater
Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Mon Apr 23, 2012 5:17 pm Post subject: |
|
|
What Stylo said. Alot of people here have their own style of doing things, thats my way. I started out just like you, having no idea where to start but i kept reading and finally it clicked.
Im not gonna feed you code but i might beable to point you in the right direction.
Break it down into smaller parts.
Tutorial-i386.exe+20F3E You can split that right at the + sign. Loop the process module collection to get the base of Tutorial-i386.exe then its as simple as parsing 20F3E and adding it to the base.
I already told you how to calculate the jump so all you really need to do now create something that'l write the correct bytes.
I use strings cause for me, its clean and i like it. I still need to convert the string to a byte array so i can write it.
Think of it as a puzzle, dont picture it as a whole. Create one piece of code at a time and before you know, it'l start to resemble something.
Just keep reading the posts on this forum. The answers are here. _________________
|
|
Back to top |
|
 |
igor Expert Cheater
Reputation: 1
Joined: 04 Apr 2012 Posts: 145
|
Posted: Tue Apr 24, 2012 2:15 am Post subject: |
|
|
Pingo wrote: | Im not gonna feed you code but i might beable to point you in the right direction. | I don't want the whole ready-made code but I want your guidance to complete my code.
Could you guys tell me which functions that are mandatory to import from kernel32.dll, I know only two which is WriteProcessMemory and VirtualAllocEx. Is there any other functions that I should import. I want only important ones for now to complete my code, I can add other functions later as soon as I learn (like VirtualFreeEx to prevent memory leak and other optional functions).
You can tell me optional functions but say it clearly that these are optional. _________________
r--._,---------------.
"-, .c-.-----------""
/ i--'
C__J |
|
Back to top |
|
 |
Pingo Grandmaster Cheater
Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Tue Apr 24, 2012 4:37 am Post subject: |
|
|
VirtualAllocEx <-Needed
WriteProcessMemory <-Needed
If you wish to clean up
VirtualFreeEx <-optional but should be used
If you want to read it to check whether the value is default first, like i do.
ReadProcessMemory <-optional
But you can do it with just the two imports you already know.
How long have you been coding in VB? _________________
|
|
Back to top |
|
 |
igor Expert Cheater
Reputation: 1
Joined: 04 Apr 2012 Posts: 145
|
Posted: Tue Apr 24, 2012 7:38 am Post subject: |
|
|
Pingo wrote: | How long have you been coding in VB? | I have coded in VB.Net from the past two years. But the problem is I only used VB.Net for database and graphics programming. I know nothing about memory hacking.
I have searched forum and found OpenProcess function. Is that necessary to use or I can go without it.
ok. i stuck on this.
Code: | <DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function VirtualAllocEx(ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As Integer, ByVal flAllocationType As UInt32, ByVal flProtect As UInt32) As IntPtr
End Function |
In above "hProcess" is IntPtr and how can I convert game name "Tutorial-i386.exe" String to IntPtr. _________________
r--._,---------------.
"-, .c-.-----------""
/ i--'
C__J |
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
Back to top |
|
 |
Pingo Grandmaster Cheater
Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
|
Back to top |
|
 |
igor Expert Cheater
Reputation: 1
Joined: 04 Apr 2012 Posts: 145
|
Posted: Tue Apr 24, 2012 11:57 am Post subject: |
|
|
OK, now I'm able to use OpenProcess, VirtualAllocEx and WriteProcessMemory without any problem.
here is my code it works perfect.
Code: | Dim MyProcess As Process() = Process.GetProcessesByName("Tutorial-i386")
Dim hProcess As IntPtr = OpenProcess(PROCESS_ALL_ACCESS, 0, MyProcess(0).Id)
Dim hAddress As IntPtr = VirtualAllocEx(hProcess, &H800000, 512, MEM_COMMIT, PAGE_EXECUTE_READWRITE)
Me.Text = GetLastError
Dim wrte As Byte() = {&HC7, &H83, &H58, &H4, &H0, &H0, &H64, &H0, &H0, &H0}
WriteProcessMemory(hProcess, hAddress, wrte, 512, 0) |
I wanna ask you how to create code cave to jump allocated memory and jump back to original ("Tutorial-i386.exe"+20F3E).
I allocated memory at address &H800000 _________________
r--._,---------------.
"-, .c-.-----------""
/ i--'
C__J |
|
Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Tue Apr 24, 2012 12:40 pm Post subject: |
|
|
Usually, when u allocate memory using VirtualAlloc, use NULL instead of the address you want to allocate the memory at.
it'll automatically allocate u a memory and return the allocated address as the return value.
to jump to the allocated address just use the formula: (codecave address - address of redirection) - 5. _________________
Stylo |
|
Back to top |
|
 |
|