以前は、次のコードを使用してポインターとオフセットからメモリ アドレスを読み取ったことがありますが、再び使用するようになり、前回どのように機能させたのかわかりません。エラー「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