 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Sun Dec 02, 2007 7:01 pm Post subject: Can some1 give me a vb function... |
|
|
Can some1 make a function that can write the codes into a process like assemble asm at a mem location:
I want a function like this in vb:
writeasm(procId, address, asm)
or something that is close to this.
|
|
Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Dec 02, 2007 7:04 pm Post subject: |
|
|
I wrote a function, I like to call it WriteProcessMemory(). Microsoft liked the API so much, they made it come with all Windows installations!
|
|
Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Sun Dec 02, 2007 7:14 pm Post subject: |
|
|
and does it assemble asm???
|
|
Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Dec 02, 2007 7:19 pm Post subject: |
|
|
dnsi0 wrote: | and does it assemble asm??? |
Translate assemblerunit.pas into VB. Have fun.
|
|
Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Sun Dec 02, 2007 7:33 pm Post subject: |
|
|
Have fun? I dont know delphi that well...
|
|
Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sun Dec 02, 2007 7:43 pm Post subject: |
|
|
tough shit, learn
vb sucks anyways, move to delphi then c++
_________________
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Dec 02, 2007 7:56 pm Post subject: |
|
|
Flyte wrote: | dnsi0 wrote: | and does it assemble asm??? |
Translate assemblerunit.pas into VB. Have fun. |
No need, compile the assembler into a dll and call it inside VB.
I did this for Labyrnth because he wanted to do this same thing in VB6. Firstly, thanks to DB for giving me the project file to only compile what was needed for the dll, all credits to him on that
Now to use it. Firstly you will need this module, or write your own:
Code: | Option Explicit
'
' Global Variables
'
Global dwProcId As Long '// ProcId Of Process
Global bInitialized As Boolean '// Global AutoAsm Init Check
'
' API Constants
'
Private Const MAX_PATH = 260
Private Const TH32CS_SNAPPROCESS = &H2
Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
'
' Process Entry Structure
'
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szexeFile As String * MAX_PATH
End Type
'
' Win32 Standard API
'
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As Any) As Boolean
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As Any) As Boolean
'
' VBProxy Calls (Written By Wiccaan)
'
Private Declare Function vbCEInitAsm Lib "VBProxy.dll" _
(ByVal ProcId As Long, ByRef bPassFail As Boolean) As Boolean
Private Declare Function vbCEDisableScript Lib "VBProxy.dll" _
(ByVal strScript As String, ByRef dwAllocId As Long) As Boolean
Private Declare Function vbCEEnableScript Lib "VBProxy.dll" _
(ByVal strScript As String, ByRef dwAllocId As Long) As Boolean
'
' InitAutoAsm
'
'
Public Sub InitAutoAsm(dwProcId As Long)
On Error Resume Next
If dwProcId = 0 Then Exit Sub
'Dim pInitialized As Boolean
Dim pInitialized As Long
vbCEInitAsm dwProcId, CBool(pInitialized)
bInitialized = VarPtr(pInitialized)
End Sub
'
' EnableScript
'
'
Public Function EnableScript(strScript As String) As Long
If strScript = "" Then Exit Function
If bInitialized = False Then Exit Function
Dim dwAllocatedId As Long
Call vbCEEnableScript(strScript, dwAllocatedId)
EnableScript = dwAllocatedId
End Function
'
' DisableScript
'
'
Public Sub DisableScript(strScript As String, ByVal dwAllocId As Long)
If strScript = "" Then Exit Sub
If bInitialized = False Then Exit Sub
Call vbCEDisableScript(strScript, dwAllocId)
End Sub
'
' FindGame
'
Public Function FindGame(ByVal strGameName As String) As Boolean
Dim pe32 As PROCESSENTRY32
Dim hSnapshot As Long
Dim bProcFound As Boolean
Dim bFoundGame As Boolean
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
pe32.dwSize = Len(pe32)
bProcFound = Process32First(hSnapshot, pe32)
Do While bProcFound
If Right$(LCase$(Left$(pe32.szexeFile, InStr(1, pe32.szexeFile, Chr(0)) - 1)), Len(strGameName)) = LCase$(strGameName) Then
dwProcId = pe32.th32ProcessID
bFoundGame = True
End If
bProcFound = Process32Next(hSnapshot, pe32)
Loop
CloseHandle hSnapshot
FindGame = bFoundGame
End Function |
It simply wraps the functions for you to easily use them.
Next, you need to firstly call InitAutoAsm to prepare the dll to attach and write to the correct process. So with the given module, lets use Minesweeper for example:
You can do this in Form_Load or where ever as long as its called before you attempt to enable or disable a script:
Code: | If FindGame("winmine.exe") = True Then
Call InitAutoAsm(dwProcId)
End If |
Next, you have your enable script. It is important that you store the value returned from EnableScript as it is the allocation ID given to the script via the assembler which is used when you disable the script to unalloc the memory allocated when you used alloc()
So for example lets use Minesweeper again, and for flags we have a script of:
Code: | [ENABLE]
alloc(flagcave,25)
label(flagback)
flagcave:
mov [1005194],A
jmp flagback
100346E:
jmp flagcave
nop
flagback:
[DISABLE]
100346E:
add [1005194],eax
dealloc(flagcave) |
Put this inside a text box, or create a string to hold the whole script. (You will need to add linebreaks and such in the string.)
So now we want to enable the script using Command1 for example:
Code: | Private Sub Command1_Click()
dwFlagAllocId = EnableScript(Text1.Text)
End Sub |
You will need to create a form wide variable, dwFlagAllocId to the top of your project which will be:
Code: | Private dwFlagAllocId As Long |
Now when you click command1 it will call the [enable] part of the script and send it to the dll to handle. When it's done dwFlagAllocId will contain a number (counts up from 0 to what ever).
Next you will need disable, which to do that you would use DisableScript:
Code: | Private Sub Command2_Click()
Call DisableScript(Text1.Text, dwFlagAllocId)
End Sub |
Hope that helps
Oh, you will need to use the VBProxy dll as well for this, I had a few issues getting the ID to pass back correctly so I made a C dll to handle the calls to the assembler dll. This way I could correctly get the IDs to pass back. If you can get it working without, grats, I didn't take much time on that part. I'll take another look at it when I have time.
_________________
- Retired. |
|
Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Mon Dec 03, 2007 7:55 pm Post subject: |
|
|
Doesn't WOrk. And does the [Enable] and [Disable] Tags work???
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Mon Dec 03, 2007 10:38 pm Post subject: |
|
|
dnsi0 wrote: | Doesn't WOrk. And does the [Enable] and [Disable] Tags work??? |
It does work, and yes, you need the [enable] and [disable] tags for it to work. I wrote it for Lab and the above code is from a test program I made for Lab, I will make another quick toss together for Minesweeper for you to show you how it works.
Edit: Demo project attached. Source included and commented to well.. a point. It's only a few lines of code based around what I gave you above. Tested and works fine. I put the script inside a constant string inside a module instead of having it read from a file, you can do either or and it will work fine.
_________________
- Retired. |
|
Back to top |
|
 |
|
|
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
|
|