privileges(privileges翻译 )
0 2022-09-04
您好privileges:
特权
双语对照
词典结果:
privilege
[英][ˈprɪvəlɪdʒ][美][ˈprɪvəlɪdʒ, ˈprɪvlɪdʒ]
n.特权; (因财富和社会地位而仅有部分人享有的)权益; 免责特权; 特殊荣幸;
vt.给与…特权,特免;
第三人称单数:privileges过去分词:privileged复数:privileges现在进行时:privileging过去式:privileged
以上结果来自金山词霸
例句:
1.
Eg. you have earned this privilege.
你获得者这项特权。
-----------------------------------
如有疑问欢迎追问!
满意请点击右上方【选为满意回答】按钮
privilege [英]ˈprɪvəlɪdʒ [美]ˈprɪvəlɪdʒ, ˈprɪvlɪdʒ n. 特权;(因财富和社会地位而仅有部分人享有的)权益;免责特权;特殊... vt. 给与…特权,特免 [例句]That privilege should come with weighty conditions.这种特权应当附带苛刻的条件。
1、关于提升权限的方法,在MSDN里面有一个好例子:
#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "cmcfg32.lib")
BOOL SetPrivilege(
HANDLE hToken, // access token handle
LPCTSTR lpszPrivilege, // name of privilege to enable/disable
BOOL bEnablePrivilege // to enable or disable privilege
)
{
TOKEN_PRIVILEGES tp;
LUID luid;
if ( !LookupPrivilegeValue(
NULL, // lookup privilege on local system
lpszPrivilege, // privilege to lookup
&luid ) ) // receives LUID of privilege
{
printf("LookupPrivilegeValue error: %u\n", GetLastError() );
return FALSE;
}
tp.PrivilegeCount = 1;
tp.Privileges[0].Luid = luid;
if (bEnablePrivilege)
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
else
tp.Privileges[0].Attributes = 0;
// Enable the privilege or disable all privileges.
if ( !AdjustTokenPrivileges(
hToken,
FALSE,
&tp,
sizeof(TOKEN_PRIVILEGES),
(PTOKEN_PRIVILEGES) NULL,
(PDWORD) NULL) )
{
printf("AdjustTokenPrivileges error: %u\n", GetLastError() );
return FALSE;
}
if (GetLastError() == ERROR_NOT_ALL_ASSIGNED)
{
printf("The token does not have the specified privilege. \n");
return FALSE;
}
return TRUE;
}
2、经过分析之后,于是写出开关Debug权限的函数:
BOOL CWarKeyDlg::EnableDebugPrivilege(BOOL bEnableDebugPrivilege)
{
HANDLE hToken;
TOKEN_PRIVILEGES tp;
LUID luid;
if(!::OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
{
::MessageBox(this->GetSafeHwnd(), GET_TOKEN_ERROR, MSG_BOX_TITLE, MB_OK);
return FALSE;
}
if(!::LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid))
{
::MessageBox(this->GetSafeHwnd(), GET_PRIVILEGE_VALUE_ERROR, MSG_BOX_TITLE, MB_OK);
::CloseHandle(hToken);
return FALSE;
}
tp.PrivilegeCount = 1;
tp.Privileges[0].Luid = luid;
if(bEnableDebugPrivilege)
{
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
}
else
{
tp.Privileges[0].Attributes = 0;
}
if(!::AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), NULL, NULL))
{
::MessageBox(this->GetSafeHwnd(), ADJUST_PRIVILEGE_ERROR, MSG_BOX_TITLE, MB_OK);
::CloseHandle(hToken);
return FALSE;
}
::CloseHandle(hToken);
if(::GetLastError() == ERROR_NOT_ALL_ASSIGNED)
{
::MessageBox(this->GetSafeHwnd(), ENABLE_DEBUG_ERROR, MSG_BOX_TITLE, MB_OK);
return FALSE;
}
return TRUE;
}
利用这个函数给自己的WarKey开启Debug权限,再访问魔兽进程的内存时,就可以读出其中的数据了。
sos
留言与评论 (共有 条评论) |