프로세스에서 디버그 권한 감지 (Windows, C)
-
06-07-2019 - |
문제
안에 이전 질문 특정 사용자에게는 디버그 권한이 없다는 사실을 극복하는 방법을 물었습니다. 이제 존재하지 않는 것을 설정할 수 없으므로 사용자가 디버그 권한을 가지고 있는지 어떻게 확인합니까?
나는 lookupprivilegevalue ()를 사용해야한다는 것을 알고 있습니다. 특정 권한이 있는지 여부를 나타내는 반환 된 값에 대해 어디에서 읽을 수 있는지 알 수 없습니다.
코드에 감사드립니다.
감사
해결책
에서 http://msdn.microsoft.com/en-us/library/aa446619%28vs.85%29.aspx
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;
}
함수가 디버그 권한을 설정하도록 요청할 때 error_not_all_assigns를 반환하면 토큰이 없습니다.
제휴하지 않습니다 StackOverflow