我是學(xué)C#的,并且是自己學(xué)著玩不是很精通,在網(wǎng)上看了一個(gè)寫外掛的文章,我自己試著寫了一個(gè) 可就是讀不出來(lái)數(shù)據(jù)?!!? 并且發(fā)現(xiàn) OpenProcess的返回值總是在變化???。penProcess 返回值不是一個(gè)進(jìn)程的句柄嗎?進(jìn)程句柄對(duì)于同一個(gè)程序來(lái)說(shuō)應(yīng)該是固定的吧?我的這個(gè)這么會(huì)總變化呢? 并且讀出來(lái)的數(shù)據(jù)總是0!? ? ? (為了使問(wèn)題簡(jiǎn)單一些,我自己寫了個(gè)模擬游戲,用的是Visual Basic 6.0精簡(jiǎn)版)代碼和現(xiàn)在地址如下:http://d.namipan.com/d/9cf212f12c8497fa18102a7dccf7a29a61a41c67a7120000?
?
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As LongPrivate Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As LongPrivate Const PROCESS_ALL_ACCESS = &H1F0FFF '全權(quán)打開進(jìn)程Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long'Dim rea As LongPrivate Sub Timer1_Timer()'Dim fw, pid, openp, readPM As LongDim fw As LongDim pid As LongDim ope As LongDim rea As Longfw = FindWindow(vbNullString, "一個(gè)模擬游戲")If fw = 0 ThenLabel3.BackColor = RGB(255, 0, 0)Label3.Caption = "FindWindow失敗"ElseLabel3.Caption = "FindWindow成功!" & fwEnd IfGetWindowThreadProcessId fw, pid '返回程序進(jìn)程IDIf pid = 0 ThenLabel4.BackColor = RGB(255, 0, 0)Label4.Caption = "pid失敗"ElseLabel4.Caption = "pid成功!" & pidEnd Ifope = OpenProcess(PROCESS_ALL_ACCESS, False, pid)If ope = 0 ThenLabel5.BackColor = RGB(255, 0, 0)Label5.Caption = "ope失敗"ElseLabel5.Caption = "ope成功!" & opeEnd If'ReadProcessMemory 進(jìn)程, ByVal 地址, 輸出值, 字節(jié), 0&ReadProcessMemory ope, ByVal &H14FD74, rea, 4, 0&?????? '&h表示是16進(jìn)制的數(shù)'藍(lán)? 0014FD7C'紅 0014FD74Label1.Caption = "w" & reaEnd Sub
用VB調(diào)用API函數(shù)OpenProcess的返回值是不固定的嗎?
炎炎設(shè)計(jì)
2018-12-06 14:23:48