 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Meeman Advanced Cheater
Reputation: 0
Joined: 15 Nov 2007 Posts: 54
|
Posted: Sun Jan 13, 2008 8:49 pm Post subject: quick vb help |
|
|
so i haven't made a regular game trainer in a really long time and i started working on a new project, where i need to build a sort of memory editor. I keep getting errors. Can you please tell me whats wrong and help me fix the problem.
heres the code to the module i built
| 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, Form1.Text1.Text)
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
|
Now on the main form i have a label for the address and a text box for the value to go in. my code for it to write the value to the address is
| Code: |
Private Sub Command1_Click()
Dim addr$
Dim valu$
addr = "&H" + Form1.Label1.Caption
valu = "&H" + Form1.Text2.Text
Call WriteAInt(addr, valu)
End Sub
|
The error i'm getting says "Compile Error: ByRef argument type mismatch"
Any help would be highly appreciated. +Rep for good info. Thanks so much
-MEEMAN666
_________________
I AM MEEMAN666!!!!!!!!!!
PPT277
programming languages i use: VB6, Delphi 7 , C# 2008, Python
You want to +Rep me!!!!!!! |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Jan 13, 2008 9:43 pm Post subject: |
|
|
The error is on line:
| Code: | | Call WriteAInt(addr, valu) |
in your command button code. This is because you are trying to pass addr and valu as strings when their values should be long and integer.
You can fix this by either declaring the variables correctly, or using the conversion macro functions: Clng() and CInt()
You should really dim things as their proper type though. In this case:
| Code: | Private Sub Command1_Click()
Dim addr As Long
Dim valu As Integer
addr = val("&H" & Form1.Label1.Caption)
valu = val("&H" & Form1.Text2.Text)
Call WriteAInt(addr, valu)
End Sub |
In VB, if you do not give a type, VB will default the variable to a string.
_________________
- 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
|
|