-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuitest.cpp
More file actions
executable file
·41 lines (32 loc) · 1.26 KB
/
uitest.cpp
File metadata and controls
executable file
·41 lines (32 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <windows.h>
#include <iostream>
#include <vector>
DWORD GetCurrentProcessIntegrityLevel ()
{
auto handle = GetCurrentProcessToken ();
DWORD actualSize = 0;
GetTokenInformation (handle, TokenIntegrityLevel, nullptr, 0, &actualSize);
std::vector<unsigned char> buf (actualSize);
GetTokenInformation (handle, TokenIntegrityLevel, buf.data (), static_cast<DWORD> (buf.size ()), &actualSize);
auto info = reinterpret_cast<TOKEN_MANDATORY_LABEL*> (buf.data ());
auto sid = info->Label.Sid;
auto count = *GetSidSubAuthorityCount (sid);
return *GetSidSubAuthority (sid, count - 1);
}
DWORD GetCurrentProcessUiAccess ()
{
auto handle = GetCurrentProcessToken ();
DWORD actualSize = 0;
GetTokenInformation (handle, TokenUIAccess, nullptr, 0, &actualSize);
std::vector<unsigned char> buf (actualSize);
GetTokenInformation (handle, TokenUIAccess, buf.data (), static_cast<DWORD> (buf.size ()), &actualSize);
return *reinterpret_cast<DWORD*> (buf.data ());
}
int main ()
{
auto integrityLevel = GetCurrentProcessIntegrityLevel ();
auto uiAccessFlag = GetCurrentProcessUiAccess ();
std::cout << "integrity level: " << std::hex << integrityLevel << "\n";
std::cout << "ui access: " << uiAccessFlag << "\n";
Sleep (5000);
}