|
-
Jun 30th, 2001, 06:27 PM
#1
Thread Starter
Addicted Member
WriteProcessMemory API?
can anyone give me an example on how to use the WriteProcessMemory API function?
-
Jun 30th, 2001, 06:49 PM
#2
Thread Starter
Addicted Member
-
Jun 30th, 2001, 11:08 PM
#3
Thread Starter
Addicted Member
-
Jul 1st, 2001, 01:49 AM
#4
Hyperactive Member
This is just sample code to get you started, you'd have to know the address in memory to actually accomplish something.
Add a CommandButton (Command1) to the Form.
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal 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 Sub Command1_Click()
Dim hWnd As Long
Dim pid As Long
Dim pHandle As Long
hWnd = FindWindow(vbNullString, "Calc")
If (hWnd = 0) Then
MsgBox "Window not found!"
Exit Sub
End If
GetWindowThreadProcessId hWnd, pid
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
WriteProcessMemory pHandle, &H42D120, "", 6, 0& ' Replace &H42D120 with the address in memory you want to edit. Also, replace "" with the value.
CloseHandle hProcess
End Sub
Keep in mind that this code does absolutely NOTHING, it's just something to get you started. BTW, I've messed with WriteProcessMemory a lot, and I know that the format of the above code works.
[vbcode]
' comment
Rem remark
[/vbcode]
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
|