[DllImport("kernel32.dll")]
static extern bool Toolhelp32ReadProcessMemory(uint th32ProcessID,
IntPtr lpBaseAddress, [Out] byte [] lpBuffer, UIntPtr cbRead,
IntPtr lpNumberOfBytesRead);
<DllImport("kernel32.dll", CharSet:=CharSet.Auto)> _
Public Shared Function Toolhelp32ReadProcessMemory(ByVal th32ProcessID As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal cbRead As Integer, ByRef lpNumberOfBytesRead As Integer) As Integer
End Function
<DllImport("kernel32.dll", CharSet:=CharSet.Ansi)> _
Public Shared Function Toolhelp32ReadProcessMemory(ByVal th32ProcessID As Integer, ByVal lpBaseAddress As Integer, <Out()> ByVal lpBuffer As Text.StringBuilder, ByVal cbRead As Integer, ByRef lpNumberOfBytesRead As Integer) As Integer
End Function
None.
In VB.NET, the 'CharSet' field of the 'DllImport' attribute needed to be set to 'Ansi' instead of 'Auto', and 'lpBuffer' should be defined as 'System.Text.StringBuilder' instead of 'Byte()' when returning a string.
Please add some!
Private Function GetControlProgID(ByVal iProcessID As Integer, ByVal iBaseAddress As Integer, ByVal iBlkSize As Integer) As String
Dim iInfoPtr As Integer, iStrPtr As Integer
Dim sWork As New Text.StringBuilder(iBlkSize)
Try
Toolhelp32ReadProcessMemory(iProcessID, iBaseAddress + 44, iInfoPtr, 4, 0) ' Get pointer to class info...
Toolhelp32ReadProcessMemory(iProcessID, iInfoPtr + 36, iStrPtr, 4, 0) ' Get pointer to Control Class string...
If iStrPtr <> 0 Then Toolhelp32ReadProcessMemory(iProcessID, iStrPtr, sWork, iBlkSize, 0)
If (sWork.ToString & " ").Substring(0, 2) <> "VB" Then
Return ""
Else
Return sWork.ToString
End If
Catch ex As Exception
Return ""
End Try
End Function
Do you know one? Please contribute it!