I HATE USING API's in .NET....
Anyway....
VB Code:
Private Const PROCESS_VM_READ = (&H10) <DllImport("kernel32", EntryPoint:="OpenProcess")> _ Public Shared Function OpenProcess(ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer End Function
This Seems to be working correctly....
VB Code:
<DllImport("kernel32", EntryPoint:="CloseHandle")> _ Public Shared Function CloseHandle(ByVal hObject As Integer) As Integer End Function
VB Code:
<DllImport("kernel32", EntryPoint:="ReadProcessMemory")> _ Public Shared Function ReadProcessMemory(ByVal hProcess As Integer, _ ByVal lpBaseAddress As Integer, _ ByRef lpBuffer As Object, _ ByVal nSize As Integer, _ ByRef lpNumberOfBytesWritten As Integer) As Integer End Function
This seems to be giving me the problem....
if it Fails the return value is 0
VB Code:
Private Function ReadStringPointer(ByVal intProcessId As Integer, ByVal intPointer As Integer) As String 'Read Pointer Dim ProcessHandle As Integer = OpenProcess(PROCESS_VM_READ, 0, intProcessId) If ProcessHandle = 0 Then MsgBox("Invaild ProcessHandle") Exit Function End If Dim Buffer As String = New String(Chr(0), 260) Dim intRet As Integer = Winamp.ReadProcessMemory(ProcessHandle, intPointer, Buffer, 260, vbNull) Winamp.CloseHandle(ProcessHandle) MsgBox("Process Handle: " & ProcessHandle & vbCrLf & _ "Return Value: " & intRet) Return Buffer End Function
This is driving me up the wall. After I grab the Proccess Id and the Pointer I call ReadStringPointer and my app just exits.... it doesnt throw exceptions, just exits. I dont even get to see the form (calling from Form_load)
Orginally, I used IntPtr's for the Handles but it didnt work so i tried just integers.





Reply With Quote