我用AdjustTokenPrivileges成功提升了自己程序的权限,提升到SeDebugPrivilege,但是就算如此还是无法打开梦幻诛仙的进程句柄,只能用&H400这个模式打开,无法用&H1F0FFF打开所有读写功能,请问这是什么原因,是AdjustTokenPrivileges这个方法没用?还是我的程序存在错误?
以下为代码:声明我就没写了,省略了Public Sub Gethwh() Dim tmp As String Dim hwnd As Long Dim strTitle As String * 255 '用来存储窗口的标题 '取得桌面窗口 hwnd = GetDesktopWindow() '取得桌面窗口的第一个子窗口 hwnd = GetWindow(hwnd, GW_CHILD) '通过循环来枚举所有的窗口 Project = 1 Do While hwnd <> 0 '取得下一个窗口的标题,并写入到列表框中 GetClassName hwnd, strTitle, Len(strTitle) If Left$(strTitle, 1) <> vbNullChar Then tmp = Left$(strTitle, InStr(1, strTitle, vbNullChar)) If Left(tmp, 10) = "GAMECLIENT" Then hwd(Project) = hwnd Project = Project + 1 End If End If '调用GetWindow函数,来取得下一个窗口 hwnd = GetWindow(hwnd, GW_HWNDNEXT) LoopEnd SubPrivate Sub Command1_Click() Gethwh GetWindowThreadProcessId Me.hwnd, Processid hProcess = OpenProcess(&H1F0FFF, False, Processid) EnableDebugPrivilege hProcess, hwd(1)End SubPublic Sub EnableDebugPrivilege(hProcess, hwnd) Dim hToken As Long Dim pTokenPrivilege As TOKEN_PRIVILEGES Dim tt As TOKEN_PRIVILEGES Dim d As LUID OpenProcessToken hProcess, 40, hToken X = LookupPrivilegeValue(vbNullString, "SeDebugPrivilege", d) MsgBox X "这里X=1,表示LookupPrivilegeValue函数运行成功 pTokenPrivilege.PrivilegeCount = 1 pTokenPrivilege.Privileges(0).Attributes = 2 pTokenPrivilege.Privileges(0).pLuid = d X = AdjustTokenPrivileges(hToken, 0, pTokenPrivilege, Len(pTokenPrivilege), tt, ReturnLength) MsgBox X "这里X=1,表示AdjustTokenPrivileges函数运行成功 GetWindowThreadProcessId hwnd, Processid hProcess = OpenProcess(&H1F0FFF, False, Processid) MsgBox hProcess "这里hProcess=0,说明根本没有打开进程成功,我查看了getlasterror,得到错误代码还是87,我想问下难道这种提升权限的方法还是不行么?还有什么办法能提升权限打开进程?
CloseHandle hTokenEnd Sub
以下为代码:声明我就没写了,省略了Public Sub Gethwh() Dim tmp As String Dim hwnd As Long Dim strTitle As String * 255 '用来存储窗口的标题 '取得桌面窗口 hwnd = GetDesktopWindow() '取得桌面窗口的第一个子窗口 hwnd = GetWindow(hwnd, GW_CHILD) '通过循环来枚举所有的窗口 Project = 1 Do While hwnd <> 0 '取得下一个窗口的标题,并写入到列表框中 GetClassName hwnd, strTitle, Len(strTitle) If Left$(strTitle, 1) <> vbNullChar Then tmp = Left$(strTitle, InStr(1, strTitle, vbNullChar)) If Left(tmp, 10) = "GAMECLIENT" Then hwd(Project) = hwnd Project = Project + 1 End If End If '调用GetWindow函数,来取得下一个窗口 hwnd = GetWindow(hwnd, GW_HWNDNEXT) LoopEnd SubPrivate Sub Command1_Click() Gethwh GetWindowThreadProcessId Me.hwnd, Processid hProcess = OpenProcess(&H1F0FFF, False, Processid) EnableDebugPrivilege hProcess, hwd(1)End SubPublic Sub EnableDebugPrivilege(hProcess, hwnd) Dim hToken As Long Dim pTokenPrivilege As TOKEN_PRIVILEGES Dim tt As TOKEN_PRIVILEGES Dim d As LUID OpenProcessToken hProcess, 40, hToken X = LookupPrivilegeValue(vbNullString, "SeDebugPrivilege", d) MsgBox X "这里X=1,表示LookupPrivilegeValue函数运行成功 pTokenPrivilege.PrivilegeCount = 1 pTokenPrivilege.Privileges(0).Attributes = 2 pTokenPrivilege.Privileges(0).pLuid = d X = AdjustTokenPrivileges(hToken, 0, pTokenPrivilege, Len(pTokenPrivilege), tt, ReturnLength) MsgBox X "这里X=1,表示AdjustTokenPrivileges函数运行成功 GetWindowThreadProcessId hwnd, Processid hProcess = OpenProcess(&H1F0FFF, False, Processid) MsgBox hProcess "这里hProcess=0,说明根本没有打开进程成功,我查看了getlasterror,得到错误代码还是87,我想问下难道这种提升权限的方法还是不行么?还有什么办法能提升权限打开进程?
CloseHandle hTokenEnd Sub
现在一般好的游戏都有保护,不是这么好读写它的内存了.