'pAadress' to some adress ? wasnt needed to put on the button some action like Writeprocessmemory (hprocess, theadress, bytes, sifeof, Newvalue )
where 'Newvalue' is the new value in order to change ingame values? cuz on C++ is like that
What the fuck are you talking about? What i wrote is a function on it's own, don't touch any of the shit in there. Call it like this:
To write an integer value:
[highlight=vb.net]
Dim hwnd As Int32 = GetProcessHandle("pinball")
WriteMemory(Of Integer)(hwnd, &HDEADBEEF, 1337)
[/highlight]
ohhh i seee , sorry , on VB is really harder to d that , on c++ is so easy.. , haahaha , well , tyvm anyways , ill test , and i will thanks right now
Edit: well , its reading evrything fine but it isnt writing to the proc memory, like, it isnt changing the value in the game, i click on the button that would give me 10000 poins , but , it doesnt add , andi know that every adress i have is the correct, since ive mde alot of trainers... what doi do ? some tips?
Woops didn't add enough access for WPM. Try this:
[highlight=vb.net]
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function WriteProcessMemory(ByVal hProcess As Int32, ByVal lpBaseAddress As UInt32, ByVal lpBuffer As Byte(), ByVal nSize As Int32, Optional ByRef lpNumberOfBytesWritten As Integer = 0) As Boolean
End Function
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function ReadProcessMemory(ByVal hProcess As Int32, ByVal lpBaseAddress As UInt32, <Out()> ByVal lpBuffer As Byte(), ByVal iSize As Int32, Optional ByRef lpNumberOfBytesRead As Integer = 0) As Boolean
End Function
<DllImport("kernel32.dll")> _
Private Shared Function OpenProcess(ByVal dwDesiredAccess As Int32, ByVal bInheritHandle As Int16, ByVal dwProcessId As Int32) As Int32
End Function
Private Const PROCESS_ALL_ACCESS As Int32 = &H1F0FFF
Private Const PROCESS_VM_READ As Int32 = &H10
Private Const PROCESS_VM_WRITE As Int32 = &H20
Private Const PROCESS_QUERY_INFORMATION As Int32 = &H400
Private Const PROCESS_VM_OPERATION As Int32 = &H8
Private Function GetProcessHandle(ByVal processName As String, Optional ByVal creationFlags As Int32 = (PROCESS_VM_READ Or PROCESS_VM_WRITE Or PROCESS_QUERY_INFORMATION Or PROCESS_VM_OPERATION)) As Int32
Dim namedProcesses As Process() = Process.GetProcessesByName(processName) 'get all the processes running with the given name
If (namedProcesses.Length > 0) Then 'if the process is running
Dim tempHandle As Int32 = OpenProcess(creationFlags, 1, namedProcesses(0).Id) 'try opening the process (first one in the array)
If tempHandle > 0 Then Return tempHandle 'valid handle, return it
End If
Return -1 'something went wrong, illustrate that to the caller.
End Function
Private Function WriteMemory(Of T)(ByVal hProc As Int32, ByVal pAddress As UInt32, ByVal [object] As T) As Boolean
Dim sizeof As Integer = Marshal.SizeOf(GetType(T)) 'first thing we're going to do is convert the object to a byte array.
Dim tempHandle As GCHandle = GCHandle.Alloc([object], GCHandleType.Pinned) 'allocate it to memory
Dim tempBytes As Byte() = ReadUnmanagedBytes(tempHandle.AddrOfPinnedObject() , sizeof) 'read the bytes into an array
tempHandle.Free() 'free the handle
Return WriteProcessMemory(hProc, pAddress, tempBytes, tempBytes.Length) <> 0
End Function
Private Function ReadUnmanagedBytes(ByVal startAddr As IntPtr, ByVal dwSize As Int32) As Byte()
Return (From i As Integer In Enumerable.Range(0, dwSize) Select Marshal.ReadByte(startAddr, i)).ToArray()
End Function
[/highlight]