pozzum Newbie cheater Reputation: 0
Joined: 19 Jun 2015 Posts: 22
|
Posted: Sun Nov 06, 2016 8:45 pm Post subject: [VB.Net] WriteProcessMemory generating PInvokeStack [SOLVED] |
|
|
Been trying to figure out what is wrong with write function.
I've been trying to modify a vb class I found online.
I think the problem is that my process is 64 bit and the address needs to be long / int64 but it keeps throwing up PInvokeStackImbalance errors and I don't quite know what that means.
Here is my modified code
Code: | Public Class ReadWriteRebuild
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
Private Declare Function WriteProcessMemory1 Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Long, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Const PROCESS_ALL_ACCESS = &H1F0FF
Public Shared Sub writeinteger(ByVal ProcessName As String, ByVal Address As Int64, ByVal Value As Integer, Optional ByVal nsize As Integer = 4)
If ProcessName.EndsWith(".exe") Then
ProcessName = ProcessName.Replace(".exe", "")
End If
Dim MyP As Process() = Process.GetProcessesByName(ProcessName)
If MyP.Length = 0 Then
MessageBox.Show(ProcessName & " isn't open!")
Exit Sub
End If
Dim hProcess As Integer = OpenProcess(PROCESS_ALL_ACCESS, 0, MyP(0).Id)
If hProcess = 0 Then
MessageBox.Show("Failed to open " & ProcessName & "!")
Exit Sub
End If
Dim hAddress As Long
Dim vBuffer As Integer
hAddress = Address
vBuffer = Value
WriteProcessMemory1(hProcess, hAddress, CInt(vBuffer), nsize, 0)
End Sub
End Class
|
I'm just getting started and I'm trying to understand this hopefully someone would be able to help me understand.
EDIT: SOLVED I had to change my program to 64 bit that seemed to be it.
|
|