MCPcopy Create free account
hub / github.com/NoMercy-ac/NoMercy / DecreasePrivilegeEx

Function DecreasePrivilegeEx

Source/Client/NM_Engine/Decrease_Privileges.cpp:33–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33inline bool DecreasePrivilegeEx(HANDLE hProcess)
34{
35 HANDLE hToken;
36 auto ntStat = g_winapiApiTable->NtOpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
37 if (!NT_SUCCESS(ntStat))
38 {
39 DEBUG_LOG(LL_ERR, "NtOpenProcessToken fail! Status: %p", ntStat);
40 return false;
41 }
42
43 LUID luid;
44 if (!g_winapiApiTable->LookupPrivilegeValueW(NULL, SE_DEBUG_NAME, &luid))
45 {
46 DEBUG_LOG(LL_ERR, "LookupPrivilegeValueW fail! Error: %u", g_winapiApiTable->GetLastError());
47 g_winapiApiTable->CloseHandle(hToken);
48 return false;
49 }
50
51 if (SetTokenPrivilege(hToken, NULL, &luid, SE_PRIVILEGE_REMOVED) == false)
52 {
53 g_winapiApiTable->CloseHandle(hToken);
54 return false;
55 }
56
57 g_winapiApiTable->CloseHandle(hToken);
58 return true;
59}
60
61bool CAccess::DecreasePrivilege(HANDLE hProcess)
62{

Callers 1

DecreasePrivilegeMethod · 0.85

Calls 2

SetTokenPrivilegeFunction · 0.85
CloseHandleMethod · 0.80

Tested by

no test coverage detected