Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Declare Function GetWindowThreadProcessId Lib "user32" _ (ByVal hwnd As Long, lpdwProcessId As Long) As Long Declare Function OpenProcess Lib "kernel32" _ (ByVal dwDesiredAccess As Long, _ ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) As Long Declare Function CloseHandle Lib "kernel32" _ (ByVal hObject As Long) As Long 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 Public Declare Function ReadProcessMemory Lib "kernel32" _ (ByVal hProcess As Long, lpBaseAddress As Any, _ lpBuffer As Any, ByVal nSize As Long, _ lpNumberOfBytesWritten As Long) As Long Private Sub Command1_Click() 'Declare some variables we need Dim hwnd As Long' Holds the handle returned by FindWindow Dim pid As Long ' Used To hold the Process Id Dim pHandle As Long ' Holds the Process Handle 'First get a handle to the "game" window hwnd = FindWindow(vbNullString, "appname") If (hwnd = 0) Then MsgBox "Window Not found!" Exit Sub End If 'We can now get the pid GetWindowThreadProcessId hwnd, pid 'Use the pid to get a Process Handle pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) If (pHandle = 0) Then MsgBox "Couldn't Get a process handle!" Exit Sub End If 'Now we can write to our address in memory WriteProcessMemory pHandle, &H40C352, Text1, Len(Text1), 0& '^hexaddress(dont forget &H) 'Close the Process Handle CloseHandle hProcess End Sub Inputs: hexaddress what to write the (running!) aplications name. Assumes:you need a button called comand1 and a text box called text1 Side Effects: can cause program u r writing to, to crash if u edit the wrong address |