|
-
Jan 11th, 2004, 03:08 PM
#1
Thread Starter
New Member
Problems with this module
This is a module to help read values in memory from a chosen process.
VB Code:
Module Module1
Public Const PROCESS_ALL_ACCESS = &H1F0FFF
'This above code makes it work on Windows XP
Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, ByVal lpdwProcessId As Long) As Long
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Integer, ByVal lpBuffer As Integer, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Long
Public Declare Function ReadProcessMem Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Long, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long
Public Function ReadFour(ByVal GameClass As String, ByVal Address As Long, ByVal valbuffer As Long)
Dim hWnd As Long
Dim pId As Long
Dim phandle As Long
hWnd = FindWindow(GameClass, vbNullString)
If (hWnd = 0) Then
[COLOR=red]frmmain[/COLOR].lbl_debug.Caption = "Debug: Please Run x and restart the application."
Exit Function
End If
GetWindowThreadProcessId(hWnd, pId)
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pId)
If (phandle = 0) Then
MsgBox("Can't get ProcessId", vbCritical, "Error")
Exit Function
End If
ReadProcessMem(phandle, Address, valbuffer, 4, 0&)
CloseHandle([COLOR=red]hProcess[/COLOR])
End Function
End Module
I put in red the places that Visual studio is reporting errors. Anyone have any ideas? (I'm using VS.NET 2003)
The author then suggest a possible use for this module:
Get the CLASS NAME of your game.. and now ..
go to your form.
Add a timer and a textbox or label. I suggest label.. its cleaner..
we are going to call our timer Timer1
Timer1_Timer()
Call Module1.ReadMorph("Game Class Name", &HAddress, variable)
'Im using a label for this example
Label1.caption = variable
End Sub
There you go!
Simple code so that you can read an address and put its value in a label or textbox ect ect.
Hope that was educational/helpful.
Last edited by Tortle; Jan 11th, 2004 at 03:33 PM.
-
Jan 11th, 2004, 03:25 PM
#2
What errors are you getting? Do you have a form named frmmain and does it have a label on it named lbl_debug?
-
Jan 11th, 2004, 03:27 PM
#3
Frenzied Member
Not sure, see if you can fix
CloseHandle(hProcess)
by using
CloseHandle phandle
-
Jan 11th, 2004, 03:31 PM
#4
Thread Starter
New Member
Originally posted by BrianS
Not sure, see if you can fix
CloseHandle(hProcess)
by using
CloseHandle phandle
That removed the error, yes, but I don't know if it can replace 'hProcess'.
I don't have any form called 'frmmain'. I just have a blank default Form1.vb
-
Jan 11th, 2004, 04:02 PM
#5
-
Jan 11th, 2004, 04:03 PM
#6
Thread Starter
New Member
Originally posted by MartinLiss
Is this .Net?
I don't know what his code is.
But I am using .net 2003
-
Jan 11th, 2004, 04:47 PM
#7
Frenzied Member
The code doesn't appear to be functional with the hProcess in that spot. Following the logic, it only makes sense to do it the way I posted.
Originally posted by Tortle
That removed the error, yes, but I don't know if it can replace 'hProcess'.
I don't have any form called 'frmmain'. I just have a blank default Form1.vb
-
Jan 11th, 2004, 04:50 PM
#8
-
Jan 11th, 2004, 04:53 PM
#9
Frenzied Member
Then change
frmmain.lbl_debug.Caption = "Debug: Please Run x and restart the application."
to
Form1.lbl_debug.Caption = "Debug: Please Run x and restart the application."
And create a label called lbl_debug on your Form1.
I dont use .net, so not sure if this is the proper syntax, but you should be able to make it work since now you know what it's supposed to do.
Originally posted by Tortle
I don't have any form called 'frmmain'. I just have a blank default Form1.vb
-
Jan 11th, 2004, 05:05 PM
#10
Thread Starter
New Member
Originally posted by BrianS
Then change
frmmain.lbl_debug.Caption = "Debug: Please Run x and restart the application."
to
Form1.lbl_debug.Caption = "Debug: Please Run x and restart the application."
And create a label called lbl_debug on your Form1.
I dont use .net, so not sure if this is the proper syntax, but you should be able to make it work since now you know what it's supposed to do.
Ok, I did that, and now I am getting the error "Reference to a non-shared member requires an object reference."
-
Jan 11th, 2004, 05:08 PM
#11
Frenzied Member
Probably a .net error, can't help you there sorry.
-
Jan 11th, 2004, 06:29 PM
#12
Thread Starter
New Member
Ok, I removed that, it's just for error messaging.
Now for the actual program, this is what I have so far.
VB Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Call Module1.ReadFour(GameClass, &H0, Valbuffer)
TextBox1.Show()
End Sub
What do I put in the Valbuffer parameter?
I also want to put the value into a variable, so that I can show it with TextBox1.show
Last edited by Tortle; Jan 11th, 2004 at 06:58 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|