小弟刚学写外挂,遇到一些问题,请各位大大指教。问题如下:
在使用openprocess时,无法打开完美世界的进程,以下是我的api
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Const PROCESS_ALL_ACCESS = &H1F0FFF
Dim hwd As Long
Dim pid As Long
Dim hProcess As Long
Private Sub Form_Load()
hwd = FindWindow(vbNullString, "完美世界国际版")
If hwd = 0 Then
MsgBox "未启动游戏", vbOKOnly, "提示"
Unload Form1
End If
GetWindowThreadProcessId hwd, pid
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid)
If hProcess = 0 Then
MsgBox "不能打开进程", vbOKOnly, "提示"
Unload Form1
End If
CloseHandle hProcess
End Sub
PROCESS_ALL_ACCESS 如果是 &H1 或 &H100000 就可以打开进程,可是用readprocessmemory时无法读取数据。也尝试用getlasterror,得到的返回值是5,貌似是access denied。我把完美世界国际换成其他的程序却没有问题。去google查询,是权限的问题,是不是权限不够?有什么方法提升权限? |