Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[VB.Net] How To Make Trainer
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Sep 08, 2015 8:43 am    Post subject: Reply with quote

I have no problem with you asking for help with advanced concepts and using other people's code.
It wasn't until you asked for help with 'IndexOutOfRangeException' that I became irritated.
That is a very, very common exception and easy to debug.
Even with my irritation, my previous post still provided insight as to the cause of that exception.
It means you're trying to use an index for an array that wasn't big enough.
Well, the only place with an array in the code you posted is: MyProcess(0)
That means it couldn't find the process name that you defined.
Either because you typed the name wrong or because the process wasn't open when you ran the trainer.
Back to top
View user's profile Send private message
vegettadbz
Cheater
Reputation: 0

Joined: 01 Dec 2010
Posts: 28

PostPosted: Wed Sep 09, 2015 12:58 pm    Post subject: Reply with quote

Hey again.
I think I am getting how the code works, but it crashes my game...

Based on Igor code and previous posts, I have the following.
I have bolded the parts that I suppose that I have to change for my game... I hope I am right


Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

CheckBox1.CheckedChanged
Dim MyProcess As Process() = Process.GetProcessesByName("Tutorial-i386")
If CheckBox1.Checked = True Then
Dim hAddress As Integer = VirtualAllocEx(MyProcess(0).Handle, IntPtr.Zero, 11, MEM_COMMIT, PAGE_EXECUTE_READWRITE)
'For Jump To Code-Cave
Dim JumpCall As String = JmpCall(hAddress, &H420F3E, 6, False)
Dim JumpBytes As Byte() = HX2Bts(JumpCall)
WriteProcessMemory(MyProcess(0).Handle, &H420F3E, JumpBytes, JumpBytes.Length, IntPtr.Zero)
'For Writing Cave
Dim CaveBytes As Byte() = HX2Bts("C7 83 58 04 00 00 64 00 00 00 C3")
WriteProcessMemory(MyProcess(0).Handle, hAddress, CaveBytes, CaveBytes.Length, IntPtr.Zero)
hAddres = hAddress
ElseIf CheckBox1.Checked = False Then
'For Writing Orignal Bytes
Dim OrignalBytes As Byte() = HX2Bts("29 83 58 04 00 00")
WriteProcessMemory(MyProcess(0).Handle, &H420F3E, OrignalBytes, OrignalBytes.Length, 0)
'For Clear Allocated Memory
VirtualFreeEx(MyProcess(0).Handle, hAddres, IntPtr.Zero, MEM_DECOMMIT)
End If

End Sub


Original Cheat

http://s171.photobucket.com/user/vegettobdz/media/diafora/P1_zpsstvq956m.png.html

Code:

CE Scipt:

[ENABLE]

//code from here to '[DISABLE]' will be used to enable the cheat

aobscanmodule(money,FarmFrenzy_HeaveHo.wrp.exe,01 5F 60 FF 77 60 8B 35 1C) //

alloc(newmem,$1000)

label(code)

label(return)

newmem:

code:

  add [edi+60],186A0  // ADD MONEY

  push [edi+60]

  jmp return

money:

  jmp code

  nop

return:

registersymbol(money)

[DISABLE]

money:

add [edi+60],ebx

push [edi+60]

unregistersymbol(money)

dealloc(newmem)

{
// ORIGINAL CODE - INJECTION POINT: "FarmFrenzy_HeaveHo.wrp.exe"+997CE

// ---------- INJECTING HERE ----------
"FarmFrenzy_HeaveHo.wrp.exe"+997CE: 01 5F 60                 -  add [edi+60],ebx

"FarmFrenzy_HeaveHo.wrp.exe"+997D1: FF 77 60                 -  push [edi+60]
// ---------- DONE INJECTING  ----------
}


Hacked Code

http://s171.photobucket.com/user/vegettobdz/media/diafora/P2_zps8tr1tpfi.png.html?sort=3&o=0

http://s171.photobucket.com/user/vegettobdz/media/diafora/P3_zps8btlyf23.png.html?sort=3&o=0

The above VB code become like this (I think...)

Code:

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

CheckBox1.CheckedChanged
        Dim MyProcess As Process() = Process.GetProcessesByName("FarmFrenzy_HeaveHo.wrp")
        If CheckBox1.Checked = True Then
            Dim hAddress As Integer = VirtualAllocEx(MyProcess(0).Handle, IntPtr.Zero, [b]7[/b], MEM_COMMIT, PAGE_EXECUTE_READWRITE)

            'For Jump To Code-Cave
            Dim JumpCall As String = JmpCall(hAddress, &H4997CE, 7, False)
            Dim JumpBytes As Byte() = HX2Bts(JumpCall)
            WriteProcessMemory(MyProcess(0).Handle, &H4997CE, JumpBytes, JumpBytes.Length, IntPtr.Zero)
            'For Writing Cave

            Dim CaveBytes As Byte() = HX2Bts("81 47 60 A0 86 01 00")
            WriteProcessMemory(MyProcess(0).Handle, hAddress, CaveBytes, CaveBytes.Length, IntPtr.Zero)
            hAddres = hAddress
        ElseIf CheckBox1.Checked = False Then
            'For Writing Orignal Bytes
            Dim OrignalBytes As Byte() = HX2Bts("01 5f 60 ff 77 60")
           //Also tried HX2Bts("01 5f 60")
            WriteProcessMemory(MyProcess(0).Handle, &H4997CE, OrignalBytes, OrignalBytes.Length, 0)
            ' For Clear Allocated Memory
            VirtualFreeEx(MyProcess(0).Handle, hAddres, IntPtr.Zero, MEM_DECOMMIT)
        End If

End Sub




What am I doing wrong?


Last edited by vegettadbz on Thu Sep 10, 2015 3:19 am; edited 1 time in total
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed Sep 09, 2015 4:19 pm    Post subject: Reply with quote

You should always set the bytes for the code cave before overwriting the game's code with the jump.
It's possible the game will jump to the code cave before there's any code to execute (crash).

Your code cave also needs to end with a jump back to the original address plus 6 (size of overwritten bytes).
Otherwise, it will just continue executing whatever random bytes are there (crash).

Finally, the other instruction you overwrote was: push [edi+60]
You never rewrote that instruction in your code cave.
This means somewhere down the road, the game is trying to pop something off the stack that doesn't exist (crash).
Back to top
View user's profile Send private message
vegettadbz
Cheater
Reputation: 0

Joined: 01 Dec 2010
Posts: 28

PostPosted: Thu Sep 10, 2015 3:28 am    Post subject: Reply with quote

I get the idea of how it works, but I really don't know how I can do that in VB... I am not even sure that I can do that in CE, which is more easy.
An example with the above code in VB would be great.
Back to top
View user's profile Send private message
vegettadbz
Cheater
Reputation: 0

Joined: 01 Dec 2010
Posts: 28

PostPosted: Wed Sep 16, 2015 2:26 pm    Post subject: Reply with quote

I tested somethings but I still have some issues. I changed theselines of the above code (previous post)

Code:
Dim hAddress As Integer = VirtualAllocEx(MyProcess(0).Handle, IntPtr.Zero, 10, MEM_COMMIT, PAGE_EXECUTE_READWRITE)

Dim JumpCall As String = JmpCall(hAddress, &H4997CE, 10, False)

Dim CaveBytes As Byte() = HX2Bts("81 47 60 A0 86 01 00 ff 77 60")


It jumps to the code cave but it doesn't write the new bytes.
The original bytes are fine.
Do I miss something?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites