帮忙 转译一段VB 至C#,谢谢
Public Declare Function ReadProcessMemory Lib "kernel32.dll" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As LongPublic Type TBBUTTON
iBitmap As Long
idCommand As Long
fsState As Byte
fsStyle As Byte
bReserved1 As Byte
bReserved2 As Byte
dwData As Long
iString As Long
End Type
Dim udtTb As TBBUTTON
lret = ReadProcessMemory(hProcess, ByVal lAddress, ByVal VarPtr(udtTb), ByVal Len(udtTb), ByVal 0&) --------------------编程问答-------------------- 有一个Reflector.exe软件,可转换!!
网上google一下!! --------------------编程问答-------------------- 参考
http://www.codeproject.com/KB/trace/minememoryreader.aspx --------------------编程问答-------------------- --------------------编程问答--------------------
--------------------编程问答-------------------- vb 的EXE 放到Reflector.exe 中看不到代码 --------------------编程问答-------------------- [DllImport("Kernel32.dll")]
//try
[System.Runtime.InteropServices.DllImportAttribute("kernel32.dll")]
public static extern long ReadProcessMemory(
long hProcess,object lpBaseAddress ,object lpBuffer ,
long nSize , long lpNumberOfBytesWritten
);
Public struct TBBUTTON
{
Long iBitmap ,
Long idCommand ,
Byte fsState ,
Byte fsStyle ,
Byte bReserved1 ,
Byte bReserved2 ,
Long dwData ,
Long iString
}
long lret =
ReadProcessMemory(hProcess, lAddress, udtTb, (long)udtTb.Length, 0)
public static extern bool ReadProcessMemory(ntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, UInt32 nSize, ref UInt32 lpNumberOfBytesRead);
使用
public byte[] Read(IntPtr handle,IntPtr address,UInt32 size,ref UInt32 bytes)
{
byte[] buffer = new byte[size];
ReadProcessMemory(handle,address,buffer,size, ref bytes);
return buffer;
}
--------------------编程问答-------------------- public static extern long ReadProcessMemory(
long hProcess,object lpBaseAddress ,object lpBuffer ,
long nSize , long lpNumberOfBytesWritten
);
这里用 object 就无法将TBBUTTON 转化为object .
我是这样写的
public static extern long ReadProcessMemory(
long hProcess, ref object lpBaseAddress , ref object lpBuffer ,
long nSize , long lpNumberOfBytesWritten
);
--------------------编程问答-------------------- Fibona 你第三个参数是用byte[] 但是我这里是需要一个自定义的TBBUTTON. 这个如何写。 --------------------编程问答-------------------- 关注!! --------------------编程问答-------------------- 顶下。 --------------------编程问答-------------------- 我再顶
补充:.NET技术 , C#