Files

58 lines
2.3 KiB
C

// Public nt-lite security context and privilege declarations.
#pragma once
#include <stdint.h>
#include <ntlite/handle.h>
#include <ntlite/status.h>
typedef uint32_t SYS_PRIVILEGES;
// Ambient privileges are reserved for kernel-mediated authority that is not represented by an object capability yet.
#define SYS_PRIV_PROCESS_OPEN_ANY 0x00000001u
#define SYS_PRIV_PROCESS_ENUMERATE 0x00000002u
#define SYS_PRIV_THREAD_ENUMERATE_ANY 0x00000004u
#define SYS_PRIV_KERNEL_DIAGNOSTICS 0x00000008u
#define SYS_PRIV_SYSTEM_POWER 0x00000010u
#define SYS_PRIV_AUDIO_ACCESS 0x00000020u
#define SYS_PRIV_AUDIO_MASTER_CONTROL 0x00000040u
#define SYS_PRIV_CONSOLE_ACCESS 0x00000080u
#define SYS_PRIV_DISPLAY_ACCESS 0x00000100u
#define SYS_PRIV_DEBUG_OUTPUT 0x00000200u
#define SYS_PRIV_RAW_STORAGE 0x00000800u
#define SYS_PRIV_FILESYSTEM_PROVIDER 0x00001000u
#define SYS_PRIV_NETWORK_ACCESS 0x00002000u
#define SYS_PRIV_ALL 0x00003BFFu
// Security-context-specific capability rights.
#define SYS_SECURITY_CONTEXT_RIGHT_DERIVE 0x00000100u
#define SYS_SECURITY_CONTEXT_RIGHT_ASSIGN 0x00000200u
// Zero is a per-API sentinel meaning the calling process's current security context.
#define SYS_SECURITY_CONTEXT_CURRENT SYS_HANDLE_INVALID
typedef struct SYS_SECURITY_CONTEXT_INFO {
uint32_t Size;
uint32_t SecurityId;
SYS_PRIVILEGES EffectivePrivileges;
SYS_PRIVILEGES DelegablePrivileges;
uint32_t Flags;
} SYS_SECURITY_CONTEXT_INFO;
typedef struct SYS_DERIVE_SECURITY_CONTEXT_REQUEST {
uint32_t Size;
SYS_HANDLE SourceContext;
SYS_PRIVILEGES EffectivePrivileges;
SYS_PRIVILEGES DelegablePrivileges;
uint32_t Flags;
SYS_HANDLE* ContextHandleOut;
} SYS_DERIVE_SECURITY_CONTEXT_REQUEST;
#define SYS_SECURITY_CONTEXT_FLAG_NONE 0u
KSTATUS SysDeriveSecurityContext(const SYS_DERIVE_SECURITY_CONTEXT_REQUEST* request);
KSTATUS SysQuerySecurityContext(SYS_HANDLE contextHandle, SYS_SECURITY_CONTEXT_INFO* infoOut);
// Opens the exact immutable security context currently assigned to a process capability.
KSTATUS SysOpenProcessSecurityContext(SYS_HANDLE processHandle, SYS_RIGHTS desiredRights,
SYS_HANDLE* contextHandleOut);