replace ad hoc driver loading with a proper driver manager, new DDK, new PnP manager with device matching, asynchronous startup, resource ownership and removal, add shared PCI capability helpers, replace typed, rigid services with a proper service manager, implement proper system shutdown and restart, shutting down unloads drivers and shuts down services, add simple power button, remove heavyweight boot self-tests and SMP stress runs, add monotonic timestamps to kernel debug output, fruitless USB and PS/2 fixes, make test builds opt in.
This commit is contained in:
1 parent
c0ad63c27f
commit
d36f19509c
160 files changed
+6563
-7366
No files matched your search
@@ -29,26 +29,33 @@
|
||||
// GS base points at SYS_TEB. GS:[0] is the process PEB pointer.
|
||||
#define SYS_PEB_MAGIC 0x30424550u // "PEB0"
|
||||
#define SYS_TEB_MAGIC 0x30424554u // "TEB0"
|
||||
#define SYS_ENV_VERSION 4u
|
||||
#define SYS_ENV_VERSION 5u
|
||||
#define SYS_PATH_MAX 1024u
|
||||
|
||||
#ifndef SYS_USER_ENV_TYPES_DEFINED
|
||||
#define SYS_USER_ENV_TYPES_DEFINED 1
|
||||
|
||||
#define SYS_STARTUP_CAP_SYSTEM_VOLUME 1u
|
||||
#define SYS_STARTUP_CAP_SERVICE_CONTROL 2u
|
||||
#define SYS_STARTUP_CAP_SYSTEM_VOLUME_NAMESPACE 3u
|
||||
#define SYS_STARTUP_CAP_VOLUME_MANAGER 4u
|
||||
#define SYS_STARTUP_CAP_INPUT_MANAGER 5u
|
||||
#define SYS_STARTUP_CAP_DISPLAY_MANAGER 6u
|
||||
#define SYS_STARTUP_CAP_SESSION_CONTROL 7u
|
||||
#define SYS_STARTUP_CAPABILITY_MAX 32u
|
||||
|
||||
// Named startup grants form an immutable process-local manifest. Names confer no rights.
|
||||
typedef struct SYS_STARTUP_CAPABILITY {
|
||||
uint32_t Tag;
|
||||
char Name[SYS_STARTUP_CAPABILITY_NAME_MAX + 1u];
|
||||
SYS_HANDLE Handle;
|
||||
} SYS_STARTUP_CAPABILITY;
|
||||
|
||||
// Validates a canonical, zero-padded grant name received from the process loader.
|
||||
static inline bool SysStartupCapabilityNameValid(const char name[SYS_STARTUP_CAPABILITY_NAME_MAX + 1u]) {
|
||||
if (!name || !name[0]) return false;
|
||||
bool ended = false;
|
||||
for (uint32_t i = 0; i <= SYS_STARTUP_CAPABILITY_NAME_MAX; ++i) {
|
||||
char c = name[i];
|
||||
if (!c) { ended = true; continue; }
|
||||
if (ended || !((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
|
||||
(c >= '0' && c <= '9') || c == '_' || c == '-' || c == '.')) return false;
|
||||
}
|
||||
return ended;
|
||||
}
|
||||
|
||||
typedef struct SYS_PEB {
|
||||
uint32_t Magic;
|
||||
uint32_t Version;
|
||||
@@ -76,7 +83,7 @@ typedef struct SYS_TEB {
|
||||
} SYS_TEB;
|
||||
|
||||
// User bootstrap is consumed by the kernel, loader and personalities.
|
||||
_Static_assert(sizeof(SYS_STARTUP_CAPABILITY) == 8u, "SYS_STARTUP_CAPABILITY ABI size changed");
|
||||
_Static_assert(sizeof(SYS_STARTUP_CAPABILITY) == 68u, "SYS_STARTUP_CAPABILITY ABI size changed");
|
||||
_Static_assert(offsetof(SYS_PEB, ImagePath) == 16u, "SYS_PEB ImagePath offset changed");
|
||||
_Static_assert(offsetof(SYS_PEB, LoaderData) == 64u, "SYS_PEB LoaderData offset changed");
|
||||
_Static_assert(sizeof(SYS_PEB) == 72u, "SYS_PEB ABI size changed");
|
||||
@@ -91,21 +98,23 @@ static inline SYS_PEB* SysGetPeb(void) {
|
||||
return (SYS_PEB*)(uintptr_t)__readgsqword(0);
|
||||
}
|
||||
|
||||
// Returns one tagged startup capability from the immutable PEB descriptor table.
|
||||
static inline SYS_HANDLE SysGetStartupCapability(uint32_t tag) {
|
||||
// Resolves an immutable capability name without interpreting its authority.
|
||||
static inline SYS_HANDLE SysGetStartupCapability(const char* name) {
|
||||
SYS_PEB* peb = SysGetPeb();
|
||||
if (!peb || peb->Magic != SYS_PEB_MAGIC || peb->Version != SYS_ENV_VERSION || !tag ||
|
||||
peb->StartupCapabilityCount > SYS_STARTUP_CAPABILITY_MAX ||
|
||||
if (!peb || peb->Magic != SYS_PEB_MAGIC || peb->Version != SYS_ENV_VERSION ||
|
||||
!name || !name[0] || peb->StartupCapabilityCount > SYS_STARTUP_CAPABILITY_MAX ||
|
||||
(peb->StartupCapabilityCount && !peb->StartupCapabilities))
|
||||
return SYS_HANDLE_INVALID;
|
||||
for (uint32_t i = 0; i < peb->StartupCapabilityCount; ++i) {
|
||||
if (peb->StartupCapabilities[i].Tag == tag)
|
||||
const char* entry = peb->StartupCapabilities[i].Name;
|
||||
uint32_t n = 0;
|
||||
while (n <= SYS_STARTUP_CAPABILITY_NAME_MAX && name[n] && entry[n] && name[n] == entry[n]) ++n;
|
||||
if (n <= SYS_STARTUP_CAPABILITY_NAME_MAX && name[n] == '\0' && entry[n] == '\0')
|
||||
return peb->StartupCapabilities[i].Handle;
|
||||
}
|
||||
return SYS_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
|
||||
// Returns the current thread environment block.
|
||||
static inline SYS_TEB* SysGetTeb(void) {
|
||||
return (SYS_TEB*)(uintptr_t)__readgsqword(offsetof(SYS_TEB, Self));
|
||||
@@ -681,6 +690,14 @@ typedef struct SYS_QUEUE_USER_APC_REQUEST {
|
||||
uint32_t Reserved;
|
||||
} SYS_QUEUE_USER_APC_REQUEST;
|
||||
|
||||
#define SYS_POWER_ACTION_SHUTDOWN 1u
|
||||
#define SYS_POWER_ACTION_RESTART 2u
|
||||
|
||||
KSTATUS SysOpenPowerEvent(SYS_HANDLE* eventHandleOut);
|
||||
KSTATUS SysRequestSystemPower(uint32_t action);
|
||||
KSTATUS SysQuerySystemPower(uint32_t* actionOut);
|
||||
KSTATUS SysCompleteSystemPower(uint32_t action);
|
||||
|
||||
void SysExitProcess(int32_t exitCode);
|
||||
void SysExitThread(int32_t exitCode);
|
||||
KSTATUS SysCreateProcessObject(const SYS_CREATE_PROCESS_OBJECT_REQUEST* request);
|
||||
@@ -996,8 +1013,9 @@ KSTATUS SysReplyPort(const SYS_REPLY_PORT_REQUEST* request);
|
||||
KSTATUS SysDisconnectPort(SYS_HANDLE endpointHandle);
|
||||
KSTATUS SysOpenPortPeerProcess(SYS_HANDLE endpointHandle, SYS_RIGHTS desiredRights,
|
||||
SYS_HANDLE* processHandleOut);
|
||||
KSTATUS SysRegisterSystemService(SYS_SERVICE_ID serviceId, SYS_HANDLE listenerHandle);
|
||||
KSTATUS SysUnregisterSystemService(SYS_SERVICE_ID serviceId, SYS_HANDLE listenerHandle);
|
||||
// The registration capability selects one numeric registry key and authorizes publication.
|
||||
KSTATUS SysRegisterSystemService(SYS_HANDLE registrationHandle, SYS_HANDLE listenerHandle);
|
||||
KSTATUS SysUnregisterSystemService(SYS_HANDLE registrationHandle, SYS_HANDLE listenerHandle);
|
||||
KSTATUS SysConnectSystemService(const SYS_CONNECT_SYSTEM_SERVICE_REQUEST* request);
|
||||
|
||||
KSTATUS SysQueryVolumes(const SYS_QUERY_VOLUMES_REQUEST* request);
|
||||
|
||||
Reference in new issue
Block a user