0

以前は、次のコードを使用してポインターとオフセットからメモリ アドレスを読み取ったことがありますが、再び使用するようになり、前回どのように機能させたのかわかりません。エラー「valueタイプ「Byte の 1 次元配列」は整数に変換できません」というメッセージが表示され、ReadProcessMemory 呼び出しの BytesAtAddress 変数が強調表示されます。

私はこれに約25分間立ち往生していますが、それは簡単だと確信しているので、誰が何が悪いのか指摘してもらえますか.

ありがとう!

Public Shared Function ReadPointerFromMemory(ByVal BaseAddress As Integer, ByVal PointerOffset As Integer, ByVal BytesToRead As Integer, ByVal pHandle As IntPtr) As Integer
    Dim BytesAtAddress As Byte() = New Byte(BytesToRead - 1) {}
    Dim BytesRead As Integer
    Dim MemoryBase As Integer
    Dim ReturnVal As Integer
    ReadProcessMemory(pHandle, CType(BaseAddress, IntPtr), BytesAtAddress, BytesToRead, BytesRead)
    MemoryBase = BitConverter.ToInt32(BytesAtAddress, 0)
    MemoryBase += PointerOffset
    ReadProcessMemory(pHandle, CType(MemoryBase, IntPtr), BytesAtAddress, BytesToRead, BytesRead)
    ReturnVal = BitConverter.ToInt32(BytesAtAddress, 0)
    Return ReturnVal
End Function
4

1 に答える 1

1

http://msdn.microsoft.com/en-us/library/ms886794.aspxを参考にしてReadProcessMemoryください。

BOOL ReadProcessMemory( 
  HANDLE hProcess, 
  LPCVOID lpBaseAddress, 
  LPVOID lpBuffer, 
  DWORD nSize, 
  LPDWORD lpNumberOfBytesRead 
);

したがって、エラーに応じて、必要なのはBytesAtAddress配列自体ではなく、バッファー上のポインターです。とに変更MemoryBase As Integerすることもできます。または、ByVal の代わりに必要なすべての変数 ByRef を関数に渡すことをお勧めします。 MemoryBase As IntPtrReturnVal As IntegerReturnVal As IntPtr

于 2012-06-05T18:56:36.677 に答える