私は現在、VB.NET を介して G15 キーボードのゲームに健康情報を表示する小さな趣味のプロジェクトを開発しています。
API 呼び出しを介して ReadProcessMemory を使用すると、0 が返され続けます。MSDN のドキュメントでは、Marshal.GetLastWin32Error() 呼び出しを使用して何が問題なのかを調べるように指示されており、1400: INVALID WINDOW HANDLE が返されます。
関数の最初の引数がウィンドウ ハンドルまたはプロセス ID のどちらを必要としているかについて混乱しています。とにかく、アプリケーションの実行中にFindWindowとプロセスIDのハードコーディングの両方を試しました(タスクマネージャーから取得します)。
私は 3 つの異なるゲーム、Urban Terror、Grand Theft Auto: SA、Windows 用の 3D ピンボールを試し、Cheat Engine と呼ばれるアプリケーションからメモリ アドレスを取得しました。それらはすべて失敗しているようです。
これを行うために使用しているコードは次のとおりです。
API 呼び出し:
Private Declare Function ReadProcessMemory Lib "kernel32" ( _
ByVal hProcess As Integer, _
ByVal lpBaseAddress As Integer, _
ByRef lpBuffer As Single, _
ByVal nSize As Integer, _
ByRef lpNumberOfBytesWritten As Integer _
) As Integer
方法:
Dim address As Integer
address = &HA90C62&
Dim valueinmemory As Integer
Dim proc As Process = Process.GetCurrentProcess
For Each proc In Process.GetProcesses
If proc.MainWindowTitle = "3D Pinball for Windows - Space Cadet" Then
If ReadProcessMemory(proc.Handle.ToInt32, address, valueinmemory, 4, 0) = 0 Then
MsgBox("aww")
Else
MsgBox(CStr(valueinmemory))
End If
End If
Next
Dim lastError As Integer
lastError = Marshal.GetLastWin32Error()
MessageBox.Show(CStr(lastError))
誰かがなぜそれが機能しないのか説明してもらえますか? 前もって感謝します。