redo boot around an explicit system volume and fixed kernel/HAL images, redo volumes and filesystem paths around capabilities instead of drive numbers and kernel CWD state, add a capability/security model with derived and revocable handles and security contexts, add port IPC and rssrv to manage the userspace resource namespace and publish the system volume, move process, dll and path loading to userspace and add process builder syscalls, init now supervises rssrv and the session process, redo the syscall ABI around request structs and four arguments, add a volume manager and proper partition arrival/removal handling so FAT and NTFS mount dynamically, clean up the HAL/DDK boundary so drivers don't depend on HAL internals, save fpu state properly now, the serial driver doesn't hang on a missing port, fix AHCI startup races, fix timeout accounting, fix shared mmap writeback, more smoke tests
This commit is contained in:
1 parent
4add6789ba
commit
f882d339fb
232 files changed
+20934
-8898
No files matched your search
+391
-220
@@ -12,23 +12,39 @@
|
||||
#include <ntlite/time.h>
|
||||
#include <ntlite/display.h>
|
||||
#include <ntlite/status.h>
|
||||
#include <ntlite/handle.h>
|
||||
#include <ntlite/security.h>
|
||||
#include <ntlite/port.h>
|
||||
#include <ntlite/service.h>
|
||||
#include <ntlite/audio.h>
|
||||
#include <ntlite/volume_manager.h>
|
||||
|
||||
// Syscall ABI convention: status-returning calls use KSTATUS. New or revised
|
||||
// operations use a request struct when they need five or more logical arguments
|
||||
// or when a pointer/length pair would otherwise be split across flat arguments.
|
||||
// Syscall ABI convention: status-returning calls use KSTATUS. Syscalls use at most
|
||||
// four register arguments; larger operations use request structures. Every
|
||||
// SYS_*_REQUEST begins with Size, which must equal the exact structure size for
|
||||
// the current ABI. Payload byte counts use Length or another semantic name.
|
||||
|
||||
// User process/thread environment.
|
||||
// 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 1u
|
||||
#define SYS_CWD_MAX 520u
|
||||
#define SYS_ENV_VERSION 4u
|
||||
#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_CAPABILITY_MAX 32u
|
||||
|
||||
typedef struct SYS_STARTUP_CAPABILITY {
|
||||
uint32_t Tag;
|
||||
SYS_HANDLE Handle;
|
||||
} SYS_STARTUP_CAPABILITY;
|
||||
|
||||
typedef struct SYS_PEB {
|
||||
uint32_t Magic;
|
||||
uint32_t Version;
|
||||
@@ -36,7 +52,11 @@ typedef struct SYS_PEB {
|
||||
|
||||
SYS_STRING_VIEW ImagePath;
|
||||
SYS_STRING_VIEW CommandLine;
|
||||
SYS_STRING_VIEW CurrentDirectory;
|
||||
const SYS_STARTUP_CAPABILITY* StartupCapabilities;
|
||||
uint32_t StartupCapabilityCount;
|
||||
uint32_t Reserved;
|
||||
|
||||
const void* LoaderData;
|
||||
} SYS_PEB;
|
||||
|
||||
typedef struct SYS_TEB {
|
||||
@@ -58,14 +78,21 @@ static inline SYS_PEB* SysGetPeb(void) {
|
||||
return (SYS_PEB*)(uintptr_t)__readgsqword(0);
|
||||
}
|
||||
|
||||
// Returns the kernel-maintained current-directory cache from the PEB.
|
||||
static inline SYS_STRING_VIEW SysGetCurrentDirectoryView(void) {
|
||||
// Returns one tagged startup capability from the immutable PEB descriptor table.
|
||||
static inline SYS_HANDLE SysGetStartupCapability(uint32_t tag) {
|
||||
SYS_PEB* peb = SysGetPeb();
|
||||
if (!peb || peb->Magic != SYS_PEB_MAGIC || peb->Version != SYS_ENV_VERSION)
|
||||
return SysSvFromParts("", 0);
|
||||
return peb->CurrentDirectory;
|
||||
if (!peb || peb->Magic != SYS_PEB_MAGIC || peb->Version != SYS_ENV_VERSION || !tag ||
|
||||
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)
|
||||
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));
|
||||
@@ -82,37 +109,40 @@ typedef void (*SYS_USER_APC_ROUTINE)(void* normalContext,
|
||||
uint64_t information);
|
||||
|
||||
typedef struct SYS_FILE_IO_REQUEST {
|
||||
uint32_t FileHandle;
|
||||
uint32_t Size;
|
||||
SYS_HANDLE FileHandle;
|
||||
uint32_t Flags;
|
||||
void* Buffer;
|
||||
size_t Size;
|
||||
size_t Length;
|
||||
size_t* TransferredOut;
|
||||
} SYS_FILE_IO_REQUEST;
|
||||
|
||||
static inline SYS_FILE_IO_REQUEST SysMakeFileIoRequest(uint32_t fileHandle,
|
||||
static inline SYS_FILE_IO_REQUEST SysMakeFileIoRequest(SYS_HANDLE fileHandle,
|
||||
const void* buffer,
|
||||
size_t size,
|
||||
size_t* transferredOut) {
|
||||
SYS_FILE_IO_REQUEST request;
|
||||
request.Size = sizeof(request);
|
||||
request.FileHandle = fileHandle;
|
||||
request.Flags = 0;
|
||||
request.Buffer = (void*)(uintptr_t)buffer;
|
||||
request.Size = size;
|
||||
request.Length = size;
|
||||
request.TransferredOut = transferredOut;
|
||||
return request;
|
||||
}
|
||||
|
||||
typedef struct SYS_ASYNC_FILE_REQUEST {
|
||||
uint32_t FileHandle;
|
||||
uint32_t EventHandle; // optional; 0 means no event signal
|
||||
uint32_t Size;
|
||||
SYS_HANDLE FileHandle;
|
||||
SYS_HANDLE EventHandle; // optional; 0 means no event signal
|
||||
uint32_t Flags;
|
||||
uint64_t Offset; // explicit byte offset; does not touch file pointer
|
||||
void* Buffer;
|
||||
size_t Size;
|
||||
size_t Length;
|
||||
SYS_IO_STATUS_BLOCK* Iosb; // required; initialized to NTLSTATUS_PENDING
|
||||
SYS_USER_APC_ROUTINE ApcRoutine; // optional; requires SysSetUserApcDispatcher
|
||||
void* ApcContext;
|
||||
uint32_t* RequestHandleOut; // optional; receives cancel/query handle
|
||||
SYS_HANDLE* RequestHandleOut; // optional; receives cancel/query handle
|
||||
} SYS_ASYNC_FILE_REQUEST;
|
||||
|
||||
// User APC frames are kernel-issued control records, not resume contexts.
|
||||
@@ -303,16 +333,38 @@ typedef struct SYS_RAISE_EXCEPTION_REQUEST {
|
||||
} SYS_RAISE_EXCEPTION_REQUEST;
|
||||
|
||||
// String-view based syscall request structures.
|
||||
typedef struct SYS_CREATE_PROCESS_REQUEST {
|
||||
SYS_STRING_VIEW Path;
|
||||
SYS_STRING_VIEW CommandLine;
|
||||
uint32_t* HandleOut;
|
||||
} SYS_CREATE_PROCESS_REQUEST;
|
||||
#define SYS_CREATE_PROCESS_OBJECT_FLAG_NONE 0x00000000u
|
||||
|
||||
typedef struct SYS_PATH_HANDLE_REQUEST {
|
||||
SYS_STRING_VIEW Path;
|
||||
uint32_t* HandleOut;
|
||||
} SYS_PATH_HANDLE_REQUEST;
|
||||
typedef struct SYS_CREATE_PROCESS_OBJECT_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t Flags;
|
||||
SYS_STRING_VIEW ImagePath;
|
||||
SYS_STRING_VIEW CommandLine;
|
||||
SYS_HANDLE SecurityContext;
|
||||
SYS_HANDLE* ProcessHandleOut;
|
||||
} SYS_CREATE_PROCESS_OBJECT_REQUEST;
|
||||
|
||||
typedef struct SYS_ALLOC_PROCESS_VM_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_HANDLE ProcessHandle;
|
||||
uint32_t Protect;
|
||||
uint32_t Flags;
|
||||
size_t PageCount;
|
||||
void** BaseOut;
|
||||
} SYS_ALLOC_PROCESS_VM_REQUEST;
|
||||
|
||||
#define SYS_START_PROCESS_FLAG_NONE 0x00000000u
|
||||
typedef struct SYS_START_PROCESS_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_HANDLE ProcessHandle;
|
||||
uint32_t Flags;
|
||||
uintptr_t MainImageBase;
|
||||
size_t MainImageSize;
|
||||
uintptr_t EntryPoint;
|
||||
const SYS_STARTUP_CAPABILITY* StartupCapabilities;
|
||||
uint32_t StartupCapabilityCount;
|
||||
const void* LoaderData;
|
||||
} SYS_START_PROCESS_REQUEST;
|
||||
|
||||
#define SYS_FILE_ACCESS_READ 0x00000001u
|
||||
#define SYS_FILE_ACCESS_WRITE 0x00000002u
|
||||
@@ -328,21 +380,69 @@ typedef struct SYS_PATH_HANDLE_REQUEST {
|
||||
|
||||
#define SYS_FILE_FLAG_NONE 0x00000000u
|
||||
|
||||
typedef struct SYS_OPEN_FILE_REQUEST {
|
||||
// Opens or creates a file beneath a mounted-volume or directory capability.
|
||||
// Path is a canonical native relative path: '/' separators only, with no leading/trailing
|
||||
// separator, empty component, '.', '..', backslash, or embedded NUL.
|
||||
typedef struct SYS_OPEN_FILE_AT_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_HANDLE RootHandle;
|
||||
SYS_STRING_VIEW Path;
|
||||
uint32_t Access;
|
||||
uint32_t Disposition;
|
||||
uint32_t Flags;
|
||||
uint32_t* HandleOut;
|
||||
} SYS_OPEN_FILE_REQUEST;
|
||||
SYS_HANDLE* HandleOut;
|
||||
} SYS_OPEN_FILE_AT_REQUEST;
|
||||
|
||||
// Builds a flags-based file-open request.
|
||||
static inline SYS_OPEN_FILE_REQUEST SysMakeOpenFileRequest(SYS_STRING_VIEW path,
|
||||
uint32_t access,
|
||||
uint32_t disposition,
|
||||
uint32_t flags,
|
||||
uint32_t* handleOut) {
|
||||
SYS_OPEN_FILE_REQUEST request;
|
||||
#define SYS_DIR_ACCESS_ENUMERATE 0x00000001u
|
||||
#define SYS_DIR_ACCESS_OPEN 0x00000002u
|
||||
#define SYS_DIR_ACCESS_MODIFY 0x00000004u
|
||||
#define SYS_DIR_FLAG_NONE 0x00000000u
|
||||
|
||||
// Opens a directory beneath a mounted-volume or directory capability. An empty Path
|
||||
// opens the root itself; non-empty paths use the same canonical relative-path contract.
|
||||
typedef struct SYS_OPEN_DIR_AT_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_HANDLE RootHandle;
|
||||
SYS_STRING_VIEW Path;
|
||||
uint32_t Access;
|
||||
uint32_t Flags;
|
||||
SYS_HANDLE* HandleOut;
|
||||
} SYS_OPEN_DIR_AT_REQUEST;
|
||||
|
||||
// Performs one path-only operation beneath a mounted-volume or directory capability.
|
||||
typedef struct SYS_PATH_AT_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_HANDLE RootHandle;
|
||||
SYS_STRING_VIEW Path;
|
||||
} SYS_PATH_AT_REQUEST;
|
||||
|
||||
// Queries metadata beneath a mounted-volume or directory capability.
|
||||
typedef struct SYS_STAT_AT_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_HANDLE RootHandle;
|
||||
SYS_STRING_VIEW Path;
|
||||
SYS_FILE_STAT* StatOut;
|
||||
} SYS_STAT_AT_REQUEST;
|
||||
|
||||
// Renames one path between capability-relative roots. Cross-volume rename is rejected.
|
||||
typedef struct SYS_RENAME_AT_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_HANDLE OldRootHandle;
|
||||
SYS_STRING_VIEW OldPath;
|
||||
SYS_HANDLE NewRootHandle;
|
||||
SYS_STRING_VIEW NewPath;
|
||||
} SYS_RENAME_AT_REQUEST;
|
||||
|
||||
// Builds a capability-relative file-open request.
|
||||
static inline SYS_OPEN_FILE_AT_REQUEST SysMakeOpenFileAtRequest(SYS_HANDLE rootHandle,
|
||||
SYS_STRING_VIEW path,
|
||||
uint32_t access,
|
||||
uint32_t disposition,
|
||||
uint32_t flags,
|
||||
SYS_HANDLE* handleOut) {
|
||||
SYS_OPEN_FILE_AT_REQUEST request;
|
||||
request.Size = sizeof(request);
|
||||
request.RootHandle = rootHandle;
|
||||
request.Path = path;
|
||||
request.Access = access;
|
||||
request.Disposition = disposition;
|
||||
@@ -351,36 +451,21 @@ static inline SYS_OPEN_FILE_REQUEST SysMakeOpenFileRequest(SYS_STRING_VIEW path,
|
||||
return request;
|
||||
}
|
||||
|
||||
typedef struct SYS_PATH_REQUEST {
|
||||
SYS_STRING_VIEW Path;
|
||||
} SYS_PATH_REQUEST;
|
||||
|
||||
#define SYS_REAL_PATH_FLAG_NONE 0x00000000u
|
||||
|
||||
// SysRealPath returns a canonical native path of the form "N:/path". It uses
|
||||
// the kernel-owned process CWD for relative input, collapses '.', '..', and
|
||||
// repeated separators, and clamps parent traversal at the volume root. The
|
||||
// current filesystem model has no symlinks, so resolution is lexical and does
|
||||
// not require the final path to exist. RequiredSizeOut receives the byte count
|
||||
// including the terminating NUL; a NULL buffer with size zero only queries it.
|
||||
typedef struct SYS_REAL_PATH_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t Flags;
|
||||
SYS_STRING_VIEW Path;
|
||||
char* Buffer;
|
||||
size_t BufferSize;
|
||||
size_t* RequiredSizeOut;
|
||||
} SYS_REAL_PATH_REQUEST;
|
||||
|
||||
typedef struct SYS_STAT_FILE_REQUEST {
|
||||
SYS_STRING_VIEW Path;
|
||||
SYS_FILE_STAT* StatOut;
|
||||
} SYS_STAT_FILE_REQUEST;
|
||||
|
||||
typedef struct SYS_RENAME_FILE_REQUEST {
|
||||
SYS_STRING_VIEW OldPath;
|
||||
SYS_STRING_VIEW NewPath;
|
||||
} SYS_RENAME_FILE_REQUEST;
|
||||
// Builds a capability-relative directory-open request.
|
||||
static inline SYS_OPEN_DIR_AT_REQUEST SysMakeOpenDirAtRequest(SYS_HANDLE rootHandle,
|
||||
SYS_STRING_VIEW path,
|
||||
uint32_t access,
|
||||
uint32_t flags,
|
||||
SYS_HANDLE* handleOut) {
|
||||
SYS_OPEN_DIR_AT_REQUEST request;
|
||||
request.Size = sizeof(request);
|
||||
request.RootHandle = rootHandle;
|
||||
request.Path = path;
|
||||
request.Access = access;
|
||||
request.Flags = flags;
|
||||
request.HandleOut = handleOut;
|
||||
return request;
|
||||
}
|
||||
|
||||
#define SYS_FILE_LOCK_SHARED 1u
|
||||
#define SYS_FILE_LOCK_EXCLUSIVE 2u
|
||||
@@ -395,7 +480,7 @@ typedef struct SYS_RENAME_FILE_REQUEST {
|
||||
// Unlock removes this process's overlapping locks for the file identity.
|
||||
typedef struct SYS_LOCK_FILE_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t FileHandle;
|
||||
SYS_HANDLE FileHandle;
|
||||
uint32_t Mode;
|
||||
uint32_t Flags;
|
||||
uint64_t Offset;
|
||||
@@ -405,17 +490,19 @@ typedef struct SYS_LOCK_FILE_REQUEST {
|
||||
|
||||
typedef struct SYS_UNLOCK_FILE_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t FileHandle;
|
||||
SYS_HANDLE FileHandle;
|
||||
uint32_t Flags;
|
||||
uint64_t Offset;
|
||||
uint64_t Length;
|
||||
} SYS_UNLOCK_FILE_REQUEST;
|
||||
|
||||
typedef struct SYS_WRITE_CONSOLE_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_STRING_VIEW Text;
|
||||
} SYS_WRITE_CONSOLE_REQUEST;
|
||||
|
||||
typedef struct SYS_PRINT_DEBUG_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_STRING_VIEW Text;
|
||||
} SYS_PRINT_DEBUG_REQUEST;
|
||||
|
||||
@@ -423,22 +510,27 @@ typedef struct SYS_PRINT_DEBUG_REQUEST {
|
||||
// SysUnpublishQueue withdraws a name explicitly. Closing the publishing handle
|
||||
// or exiting the process withdraws every name published through that handle.
|
||||
typedef struct SYS_PUBLISH_QUEUE_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_STRING_VIEW Name;
|
||||
uint32_t QueueHandle;
|
||||
SYS_HANDLE QueueHandle;
|
||||
} SYS_PUBLISH_QUEUE_REQUEST;
|
||||
|
||||
typedef struct SYS_UNPUBLISH_QUEUE_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_STRING_VIEW Name;
|
||||
} SYS_UNPUBLISH_QUEUE_REQUEST;
|
||||
|
||||
typedef struct SYS_OPEN_NAMED_QUEUE_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_STRING_VIEW Name;
|
||||
uint32_t* HandleOut;
|
||||
SYS_HANDLE* HandleOut;
|
||||
} SYS_OPEN_NAMED_QUEUE_REQUEST;
|
||||
|
||||
typedef struct SYS_NAMED_QUEUE_OWNER_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_STRING_VIEW Name;
|
||||
uint32_t* ProcessHandleOut;
|
||||
SYS_RIGHTS DesiredAccess;
|
||||
SYS_HANDLE* ProcessHandleOut;
|
||||
} SYS_NAMED_QUEUE_OWNER_REQUEST;
|
||||
|
||||
#define SYS_QUEUE_FLAG_NONE 0x00000000u
|
||||
@@ -455,7 +547,7 @@ typedef struct SYS_NAMED_QUEUE_OWNER_REQUEST {
|
||||
// not copy storage behind it.
|
||||
typedef struct SYS_QUEUE_SEND_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t QueueHandle;
|
||||
SYS_HANDLE QueueHandle;
|
||||
uint32_t Flags;
|
||||
uint64_t TimeoutMilliseconds;
|
||||
const void* Message;
|
||||
@@ -463,7 +555,7 @@ typedef struct SYS_QUEUE_SEND_REQUEST {
|
||||
|
||||
typedef struct SYS_QUEUE_RECV_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t QueueHandle;
|
||||
SYS_HANDLE QueueHandle;
|
||||
uint32_t Flags;
|
||||
uint64_t TimeoutMilliseconds;
|
||||
void* MessageOut;
|
||||
@@ -480,18 +572,19 @@ typedef struct SYS_QUEUE_RECV_REQUEST {
|
||||
typedef struct SYS_WAIT_MANY_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t Flags;
|
||||
const uint32_t* Handles;
|
||||
const SYS_HANDLE* Handles;
|
||||
uint32_t Count;
|
||||
uint32_t* SignaledIndexOut;
|
||||
uint64_t TimeoutMilliseconds;
|
||||
} SYS_WAIT_MANY_REQUEST;
|
||||
|
||||
typedef struct SYS_CREATE_THREAD_REQUEST {
|
||||
uint32_t Size;
|
||||
uintptr_t Entry;
|
||||
uintptr_t Argument;
|
||||
uint32_t Priority;
|
||||
uint32_t Flags;
|
||||
uint32_t* ThreadHandleOut;
|
||||
SYS_HANDLE* ThreadHandleOut;
|
||||
uint32_t* ThreadIdOut;
|
||||
} SYS_CREATE_THREAD_REQUEST;
|
||||
|
||||
@@ -500,31 +593,34 @@ typedef struct SYS_CREATE_THREAD_REQUEST {
|
||||
|
||||
void SysExitProcess(int32_t exitCode);
|
||||
void SysExitThread(int32_t exitCode);
|
||||
KSTATUS SysCreateProcess(const SYS_CREATE_PROCESS_REQUEST* request);
|
||||
KSTATUS SysWaitSingle(uint32_t handle, uint32_t flags, uint64_t timeoutMilliseconds);
|
||||
KSTATUS SysCreateProcessObject(const SYS_CREATE_PROCESS_OBJECT_REQUEST* request);
|
||||
KSTATUS SysAllocProcessVm(const SYS_ALLOC_PROCESS_VM_REQUEST* request);
|
||||
KSTATUS SysProtectProcessVm(SYS_HANDLE processHandle, void* base, size_t pageCount, uint32_t protect);
|
||||
KSTATUS SysStartProcess(const SYS_START_PROCESS_REQUEST* request);
|
||||
KSTATUS SysWaitSingle(SYS_HANDLE handle, uint32_t flags, uint64_t timeoutMilliseconds);
|
||||
KSTATUS SysWaitMany(const SYS_WAIT_MANY_REQUEST* request);
|
||||
// SysOpenInputQueue returns a readable and waitable handle to the default
|
||||
// keyboard input queue. The handle does not create a second event stream;
|
||||
// SysReadInputEvent, SysPeekInputEvent, SysReadKey, and SysReadKeyboardChar
|
||||
// consume the same queue. SysWaitSingle succeeds for this handle when a
|
||||
// keyboard input event can be read.
|
||||
KSTATUS SysOpenInputQueue(uint32_t flags, uint32_t* handleOut);
|
||||
KSTATUS SysOpenInputQueue(uint32_t flags, SYS_HANDLE* handleOut);
|
||||
|
||||
static inline KSTATUS SysWait(uint32_t handle, uint32_t flags) {
|
||||
static inline KSTATUS SysWait(SYS_HANDLE handle, uint32_t flags) {
|
||||
return SysWaitSingle(handle, flags, SYS_WAIT_TIMEOUT_INFINITE);
|
||||
}
|
||||
KSTATUS SysGetProcessExitCode(uint32_t handle, int32_t* exitCodeOut);
|
||||
KSTATUS SysOpenProcess(uint32_t pid, uint32_t* handleOut);
|
||||
KSTATUS SysGetProcessExitCode(SYS_HANDLE handle, int32_t* exitCodeOut);
|
||||
KSTATUS SysOpenProcess(uint32_t pid, SYS_RIGHTS desiredAccess, SYS_HANDLE* handleOut);
|
||||
// Protected kernel processes remain openable for query and wait operations,
|
||||
// but SysKillProcess returns NTLSTATUS_ACCESS_DENIED for them.
|
||||
KSTATUS SysKillProcess(uint32_t processHandle, int32_t exitCode);
|
||||
KSTATUS SysKillProcess(SYS_HANDLE processHandle, int32_t exitCode);
|
||||
|
||||
#define SYS_PROCESS_NAME_MAX 64u
|
||||
#define SYS_PROCESS_CWD_MAX 128u
|
||||
|
||||
#define SYS_PROCESS_STATE_RUNNING 0u
|
||||
#define SYS_PROCESS_STATE_TERMINATING 1u
|
||||
#define SYS_PROCESS_STATE_EXITED 2u
|
||||
#define SYS_PROCESS_STATE_CONSTRUCTING 3u
|
||||
|
||||
#define SYS_PROCESS_FLAG_SYSTEM 0x00000001u
|
||||
#define SYS_PROCESS_FLAG_CURRENT 0x00000002u
|
||||
@@ -532,6 +628,7 @@ KSTATUS SysKillProcess(uint32_t processHandle, int32_t exitCode);
|
||||
#define SYS_PROCESS_FLAG_EXITED 0x00000008u
|
||||
#define SYS_PROCESS_FLAG_IDLE 0x00000010u
|
||||
#define SYS_PROCESS_FLAG_TERMINATION_PROTECTED 0x00000020u
|
||||
#define SYS_PROCESS_FLAG_CONSTRUCTING 0x00000040u
|
||||
|
||||
#define SYS_THREAD_STATE_READY 0u
|
||||
#define SYS_THREAD_STATE_RUNNING 1u
|
||||
@@ -599,16 +696,12 @@ typedef struct SYS_THREAD_INFO {
|
||||
typedef struct SYS_PROCESS_INFO {
|
||||
uint32_t Size;
|
||||
uint32_t ProcessId;
|
||||
uint32_t SecurityId;
|
||||
uint32_t State;
|
||||
uint32_t Flags;
|
||||
|
||||
uint32_t ThreadCount;
|
||||
uint32_t HandleCount;
|
||||
// ModuleCount is the number of DLL-like process modules recorded by the loader.
|
||||
// The main executable image is reported separately through ImageBase/ImageSize.
|
||||
uint32_t ModuleCount;
|
||||
uint32_t CurrentDrive;
|
||||
|
||||
int32_t ExitCode;
|
||||
|
||||
uintptr_t ImageBase;
|
||||
@@ -630,63 +723,14 @@ typedef struct SYS_PROCESS_INFO {
|
||||
uintptr_t LastExceptionFaultAddress;
|
||||
|
||||
char Name[SYS_PROCESS_NAME_MAX];
|
||||
char CurrentDirectory[SYS_PROCESS_CWD_MAX];
|
||||
} SYS_PROCESS_INFO;
|
||||
|
||||
KSTATUS SysGetProcessList(SYS_PROCESS_INFO* processesOut, size_t maxCount, size_t* countOut);
|
||||
KSTATUS SysGetProcessPid(uint32_t handle, uint32_t* pidOut);
|
||||
KSTATUS SysGetProcessPid(SYS_HANDLE handle, uint32_t* pidOut);
|
||||
KSTATUS SysGetThreadList(uint32_t pid, SYS_THREAD_INFO* threadsOut, size_t maxCount, size_t* countOut);
|
||||
|
||||
#define SYS_MODULE_NAME_MAX 64u
|
||||
#define SYS_MODULE_INFO_VERSION 1u
|
||||
|
||||
#define SYS_LOAD_MODULE_FLAG_NONE 0u
|
||||
|
||||
#define SYS_MODULE_FLAG_PUBLIC_REF 0x00000001u
|
||||
#define SYS_MODULE_FLAG_IMPORT_PINNED 0x00000002u
|
||||
#define SYS_MODULE_FLAG_UNLOADABLE 0x00000004u
|
||||
|
||||
typedef struct SYS_MODULE_INFO {
|
||||
uint32_t Size;
|
||||
uint32_t Version;
|
||||
uint32_t Flags;
|
||||
uint32_t Reserved;
|
||||
|
||||
uintptr_t Base;
|
||||
size_t ImageSize;
|
||||
uintptr_t EntryPoint;
|
||||
|
||||
uint32_t PublicRefCount;
|
||||
uint32_t ImportRefCount;
|
||||
uint32_t TotalRefCount;
|
||||
uint32_t Reserved2;
|
||||
|
||||
char Name[SYS_MODULE_NAME_MAX];
|
||||
} SYS_MODULE_INFO;
|
||||
|
||||
typedef struct SYS_LOAD_MODULE_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t Flags;
|
||||
SYS_STRING_VIEW Path;
|
||||
uint32_t* ModuleHandleOut;
|
||||
SYS_MODULE_INFO* InfoOut;
|
||||
} SYS_LOAD_MODULE_REQUEST;
|
||||
|
||||
typedef struct SYS_GET_MODULE_EXPORT_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t ModuleHandle;
|
||||
SYS_STRING_VIEW Name;
|
||||
uintptr_t* AddressOut;
|
||||
} SYS_GET_MODULE_EXPORT_REQUEST;
|
||||
|
||||
KSTATUS SysLoadModule(const SYS_LOAD_MODULE_REQUEST* request);
|
||||
KSTATUS SysUnloadModule(uint32_t moduleHandle);
|
||||
KSTATUS SysGetModuleInfo(uint32_t moduleHandle, SYS_MODULE_INFO* infoOut);
|
||||
KSTATUS SysGetModuleExport(const SYS_GET_MODULE_EXPORT_REQUEST* request);
|
||||
KSTATUS SysGetModuleList(SYS_MODULE_INFO* modulesOut, size_t maxCount, size_t* countOut);
|
||||
|
||||
KSTATUS SysCreateThread(const SYS_CREATE_THREAD_REQUEST* request);
|
||||
KSTATUS SysResumeThread(uint32_t threadHandle, uint32_t* previousSuspendCountOut);
|
||||
KSTATUS SysResumeThread(SYS_HANDLE threadHandle, uint32_t* previousSuspendCountOut);
|
||||
uint32_t SysGetCurrentTid(void);
|
||||
uint32_t SysGetCurrentPid(void);
|
||||
KSTATUS SysSetThreadPriority(uint32_t priority);
|
||||
@@ -700,15 +744,15 @@ KSTATUS SysYield(void);
|
||||
// state before applying the new schedule.
|
||||
typedef struct SYS_SET_TIMER_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t TimerHandle;
|
||||
SYS_HANDLE TimerHandle;
|
||||
uint32_t Flags;
|
||||
uint64_t DueTimeMilliseconds;
|
||||
uint64_t PeriodMilliseconds;
|
||||
} SYS_SET_TIMER_REQUEST;
|
||||
|
||||
KSTATUS SysCreateTimer(uint32_t* handleOut);
|
||||
KSTATUS SysCreateTimer(SYS_HANDLE* handleOut);
|
||||
KSTATUS SysSetTimer(const SYS_SET_TIMER_REQUEST* request);
|
||||
KSTATUS SysCancelTimer(uint32_t timerHandle);
|
||||
KSTATUS SysCancelTimer(SYS_HANDLE timerHandle);
|
||||
|
||||
// SysSleep blocks the current thread through the same timer backend used by
|
||||
// waitable timer handles. A zero-length sleep yields the processor.
|
||||
@@ -770,49 +814,72 @@ KSTATUS SysQueryVm(void* address, SYS_VM_REGION_INFO* out);
|
||||
#define SYS_MAP_ACCESS_EXECUTE 0x00000008u
|
||||
#define SYS_MAP_FLAG_NONE 0x00000000u
|
||||
|
||||
KSTATUS SysCreateFileMapping(uint32_t fileHandle, uint32_t protect, uint32_t flags,
|
||||
uint64_t maximumSize, uint32_t* mappingHandleOut);
|
||||
KSTATUS SysMapFile(uint32_t mappingHandle, uint64_t offset, size_t size,
|
||||
uint32_t access, uint32_t flags, void** baseOut);
|
||||
KSTATUS SysCloseHandle(uint32_t handle);
|
||||
typedef struct SYS_CREATE_FILE_MAPPING_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_HANDLE FileHandle;
|
||||
uint32_t Protect;
|
||||
uint32_t Flags;
|
||||
uint64_t MaximumSize;
|
||||
SYS_HANDLE* MappingHandleOut;
|
||||
} SYS_CREATE_FILE_MAPPING_REQUEST;
|
||||
|
||||
#define SYS_HANDLE_RIGHT_READ 0x00000001u
|
||||
#define SYS_HANDLE_RIGHT_WRITE 0x00000002u
|
||||
#define SYS_HANDLE_RIGHT_WAIT 0x00000004u
|
||||
#define SYS_HANDLE_RIGHT_SIGNAL 0x00000008u
|
||||
#define SYS_HANDLE_RIGHT_DUPLICATE 0x00000010u
|
||||
#define SYS_HANDLE_RIGHT_QUERY 0x00000020u
|
||||
#define SYS_HANDLE_RIGHT_TERMINATE 0x00000040u
|
||||
#define SYS_HANDLE_RIGHT_LOCK 0x00000080u
|
||||
#define SYS_HANDLE_RIGHT_RESUME 0x00000100u
|
||||
#define SYS_HANDLE_RIGHT_ALL 0x000001FFu
|
||||
typedef struct SYS_MAP_FILE_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_HANDLE MappingHandle;
|
||||
uint32_t Access;
|
||||
uint32_t Flags;
|
||||
uint64_t Offset;
|
||||
size_t Length;
|
||||
void** BaseOut;
|
||||
} SYS_MAP_FILE_REQUEST;
|
||||
|
||||
KSTATUS SysCreateFileMapping(const SYS_CREATE_FILE_MAPPING_REQUEST* request);
|
||||
KSTATUS SysMapFile(const SYS_MAP_FILE_REQUEST* request);
|
||||
KSTATUS SysCloseHandle(SYS_HANDLE handle);
|
||||
|
||||
#define SYS_DUPLICATE_HANDLE_FLAG_NONE 0x00000000u
|
||||
#define SYS_DUPLICATE_HANDLE_FLAG_SAME_RIGHTS 0x00000001u
|
||||
|
||||
typedef struct SYS_DUPLICATE_HANDLE_REQUEST {
|
||||
uint32_t SourceHandle;
|
||||
uint32_t TargetProcessHandle;
|
||||
uint32_t DesiredRights;
|
||||
uint32_t Size;
|
||||
SYS_HANDLE SourceHandle;
|
||||
SYS_HANDLE TargetProcessHandle;
|
||||
SYS_RIGHTS DesiredRights;
|
||||
uint32_t Flags;
|
||||
uint32_t* TargetHandleOut;
|
||||
SYS_HANDLE* TargetHandleOut;
|
||||
} SYS_DUPLICATE_HANDLE_REQUEST;
|
||||
|
||||
// Duplicate creates another handle to the same revocation grant. DesiredRights
|
||||
// may attenuate the alias but can never exceed the source handle's rights.
|
||||
// Cross-process duplication also requires transfer authority on the source.
|
||||
KSTATUS SysDuplicateHandle(const SYS_DUPLICATE_HANDLE_REQUEST* request);
|
||||
|
||||
KSTATUS SysCreateMutex(uint32_t* handleOut);
|
||||
KSTATUS SysTryAcquireMutex(uint32_t handle);
|
||||
KSTATUS SysReleaseMutex(uint32_t handle);
|
||||
typedef struct SYS_DERIVE_HANDLE_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_HANDLE SourceHandle;
|
||||
SYS_RIGHTS DesiredRights;
|
||||
SYS_HANDLE* DerivedHandleOut;
|
||||
} SYS_DERIVE_HANDLE_REQUEST;
|
||||
|
||||
KSTATUS SysCreateSem(int32_t initial, int32_t max, uint32_t* handleOut);
|
||||
KSTATUS SysTryWaitSem(uint32_t handle);
|
||||
KSTATUS SysSignalSem(uint32_t handle);
|
||||
// Derive creates a child grant. Revoking that child invalidates its aliases and
|
||||
// descendants without revoking the parent grant.
|
||||
KSTATUS SysDeriveHandle(const SYS_DERIVE_HANDLE_REQUEST* request);
|
||||
// Revoke invalidates the selected grant, every alias of it, and all descendants.
|
||||
KSTATUS SysRevokeHandle(SYS_HANDLE handle);
|
||||
|
||||
KSTATUS SysCreateEvent(uint32_t type, uint32_t initialState, uint32_t* handleOut);
|
||||
KSTATUS SysSignalEvent(uint32_t handle);
|
||||
KSTATUS SysClearEvent(uint32_t handle);
|
||||
KSTATUS SysCreateMutex(SYS_HANDLE* handleOut);
|
||||
KSTATUS SysTryAcquireMutex(SYS_HANDLE handle);
|
||||
KSTATUS SysReleaseMutex(SYS_HANDLE handle);
|
||||
|
||||
KSTATUS SysCreateQueue(uint32_t* handleOut);
|
||||
KSTATUS SysCreateSem(int32_t initial, int32_t max, SYS_HANDLE* handleOut);
|
||||
KSTATUS SysTryWaitSem(SYS_HANDLE handle);
|
||||
KSTATUS SysSignalSem(SYS_HANDLE handle);
|
||||
|
||||
KSTATUS SysCreateEvent(uint32_t type, uint32_t initialState, SYS_HANDLE* handleOut);
|
||||
KSTATUS SysSignalEvent(SYS_HANDLE handle);
|
||||
KSTATUS SysClearEvent(SYS_HANDLE handle);
|
||||
|
||||
KSTATUS SysCreateQueue(SYS_HANDLE* handleOut);
|
||||
KSTATUS SysSendQueue(const SYS_QUEUE_SEND_REQUEST* request);
|
||||
KSTATUS SysRecvQueue(const SYS_QUEUE_RECV_REQUEST* request);
|
||||
KSTATUS SysPublishQueue(const SYS_PUBLISH_QUEUE_REQUEST* request);
|
||||
@@ -820,30 +887,44 @@ KSTATUS SysUnpublishQueue(const SYS_UNPUBLISH_QUEUE_REQUEST* request);
|
||||
KSTATUS SysOpenNamedQueue(const SYS_OPEN_NAMED_QUEUE_REQUEST* request);
|
||||
KSTATUS SysOpenNamedQueueOwnerProcess(const SYS_NAMED_QUEUE_OWNER_REQUEST* request);
|
||||
|
||||
KSTATUS SysOpenFile(const SYS_OPEN_FILE_REQUEST* request);
|
||||
KSTATUS SysCreatePort(const SYS_CREATE_PORT_REQUEST* request);
|
||||
KSTATUS SysConnectPort(const SYS_CONNECT_PORT_REQUEST* request);
|
||||
KSTATUS SysAcceptPort(const SYS_ACCEPT_PORT_REQUEST* request);
|
||||
KSTATUS SysSendPort(const SYS_SEND_PORT_REQUEST* request);
|
||||
KSTATUS SysReceivePort(const SYS_RECEIVE_PORT_REQUEST* request);
|
||||
KSTATUS SysCallPort(const SYS_CALL_PORT_REQUEST* request);
|
||||
KSTATUS SysReplyPort(const SYS_REPLY_PORT_REQUEST* request);
|
||||
KSTATUS SysDisconnectPort(SYS_HANDLE endpointHandle);
|
||||
KSTATUS SysRegisterSystemService(SYS_SERVICE_ID serviceId, SYS_HANDLE listenerHandle);
|
||||
KSTATUS SysUnregisterSystemService(SYS_SERVICE_ID serviceId, SYS_HANDLE listenerHandle);
|
||||
KSTATUS SysConnectSystemService(const SYS_CONNECT_SYSTEM_SERVICE_REQUEST* request);
|
||||
|
||||
KSTATUS SysQueryVolumes(const SYS_QUERY_VOLUMES_REQUEST* request);
|
||||
KSTATUS SysOpenVolume(SYS_HANDLE managerHandle, uint32_t instanceId, SYS_RIGHTS desiredRights, SYS_HANDLE* volumeHandleOut);
|
||||
KSTATUS SysWaitVolumeChange(SYS_HANDLE managerHandle, uint64_t observedGeneration, uint64_t timeoutMilliseconds);
|
||||
|
||||
KSTATUS SysOpenFileAt(const SYS_OPEN_FILE_AT_REQUEST* request);
|
||||
KSTATUS SysOpenDirAt(const SYS_OPEN_DIR_AT_REQUEST* request);
|
||||
KSTATUS SysStatAt(const SYS_STAT_AT_REQUEST* request);
|
||||
KSTATUS SysDeleteAt(const SYS_PATH_AT_REQUEST* request);
|
||||
KSTATUS SysRenameAt(const SYS_RENAME_AT_REQUEST* request);
|
||||
KSTATUS SysCreateDirAt(const SYS_PATH_AT_REQUEST* request);
|
||||
KSTATUS SysRemoveDirAt(const SYS_PATH_AT_REQUEST* request);
|
||||
KSTATUS SysReadFile(const SYS_FILE_IO_REQUEST* request);
|
||||
KSTATUS SysWriteFile(const SYS_FILE_IO_REQUEST* request);
|
||||
KSTATUS SysReadFileAsync(const SYS_ASYNC_FILE_REQUEST* request);
|
||||
KSTATUS SysWriteFileAsync(const SYS_ASYNC_FILE_REQUEST* request);
|
||||
KSTATUS SysCancelIo(uint32_t asyncRequestHandle);
|
||||
KSTATUS SysSeekFile(uint32_t handle, uint64_t offset);
|
||||
KSTATUS SysGetFilePos(uint32_t handle, uint64_t* positionOut);
|
||||
KSTATUS SysGetFileSize(uint32_t handle, uint64_t* sizeOut);
|
||||
KSTATUS SysGetFileStat(uint32_t handle, SYS_FILE_STAT* statOut);
|
||||
KSTATUS SysStatFile(const SYS_STAT_FILE_REQUEST* request);
|
||||
KSTATUS SysTruncateFile(uint32_t handle, uint64_t newSize);
|
||||
KSTATUS SysFlushFile(uint32_t handle);
|
||||
KSTATUS SysDeleteFile(const SYS_PATH_REQUEST* request);
|
||||
KSTATUS SysRenameFile(const SYS_RENAME_FILE_REQUEST* request);
|
||||
KSTATUS SysCancelIo(SYS_HANDLE asyncRequestHandle);
|
||||
KSTATUS SysSeekFile(SYS_HANDLE handle, uint64_t offset);
|
||||
KSTATUS SysGetFilePos(SYS_HANDLE handle, uint64_t* positionOut);
|
||||
KSTATUS SysGetFileSize(SYS_HANDLE handle, uint64_t* sizeOut);
|
||||
KSTATUS SysGetFileStat(SYS_HANDLE handle, SYS_FILE_STAT* statOut);
|
||||
KSTATUS SysTruncateFile(SYS_HANDLE handle, uint64_t newSize);
|
||||
KSTATUS SysFlushFile(SYS_HANDLE handle);
|
||||
KSTATUS SysLockFile(const SYS_LOCK_FILE_REQUEST* request);
|
||||
KSTATUS SysUnlockFile(const SYS_UNLOCK_FILE_REQUEST* request);
|
||||
|
||||
KSTATUS SysOpenDir(const SYS_PATH_HANDLE_REQUEST* request);
|
||||
KSTATUS SysReadDir(uint32_t handle, SYS_DIR_ENTRY* entryOut);
|
||||
KSTATUS SysCreateDir(const SYS_PATH_REQUEST* request);
|
||||
KSTATUS SysRemoveDir(const SYS_PATH_REQUEST* request);
|
||||
KSTATUS SysSetCwd(const SYS_PATH_REQUEST* request);
|
||||
KSTATUS SysRealPath(const SYS_REAL_PATH_REQUEST* request);
|
||||
KSTATUS SysReadDir(SYS_HANDLE handle, SYS_DIR_ENTRY* entryOut);
|
||||
|
||||
// Console and graphics.
|
||||
typedef struct SYS_CONSOLE_INFO {
|
||||
@@ -857,9 +938,40 @@ typedef struct SYS_CONSOLE_INFO {
|
||||
KSTATUS SysWriteConsole(const SYS_WRITE_CONSOLE_REQUEST* request);
|
||||
KSTATUS SysGetConsoleInfo(SYS_CONSOLE_INFO* infoOut);
|
||||
KSTATUS SysSetConsoleCursor(int x, int y);
|
||||
KSTATUS SysFillConsoleCharacter(char c, int x, int y, size_t length, size_t* writtenOut);
|
||||
KSTATUS SysFillConsoleAttribute(uint16_t attr, int x, int y, size_t length, size_t* writtenOut);
|
||||
KSTATUS SysPutScreenChar(char c, int x, int y, uint32_t fg, uint32_t bg);
|
||||
|
||||
typedef struct SYS_FILL_CONSOLE_CHARACTER_REQUEST {
|
||||
uint32_t Size;
|
||||
char Character;
|
||||
uint8_t Reserved[3];
|
||||
int32_t X;
|
||||
int32_t Y;
|
||||
size_t Length;
|
||||
size_t* WrittenOut;
|
||||
} SYS_FILL_CONSOLE_CHARACTER_REQUEST;
|
||||
|
||||
typedef struct SYS_FILL_CONSOLE_ATTRIBUTE_REQUEST {
|
||||
uint32_t Size;
|
||||
uint16_t Attribute;
|
||||
uint16_t Reserved;
|
||||
int32_t X;
|
||||
int32_t Y;
|
||||
size_t Length;
|
||||
size_t* WrittenOut;
|
||||
} SYS_FILL_CONSOLE_ATTRIBUTE_REQUEST;
|
||||
|
||||
typedef struct SYS_PUT_SCREEN_CHAR_REQUEST {
|
||||
uint32_t Size;
|
||||
char Character;
|
||||
uint8_t Reserved[3];
|
||||
int32_t X;
|
||||
int32_t Y;
|
||||
uint32_t Foreground;
|
||||
uint32_t Background;
|
||||
} SYS_PUT_SCREEN_CHAR_REQUEST;
|
||||
|
||||
KSTATUS SysFillConsoleCharacter(const SYS_FILL_CONSOLE_CHARACTER_REQUEST* request);
|
||||
KSTATUS SysFillConsoleAttribute(const SYS_FILL_CONSOLE_ATTRIBUTE_REQUEST* request);
|
||||
KSTATUS SysPutScreenChar(const SYS_PUT_SCREEN_CHAR_REQUEST* request);
|
||||
|
||||
typedef struct SYS_CREATE_SURFACE_REQUEST {
|
||||
uint32_t Size;
|
||||
@@ -867,19 +979,19 @@ typedef struct SYS_CREATE_SURFACE_REQUEST {
|
||||
uint32_t Height;
|
||||
uint32_t Format;
|
||||
uint32_t Flags;
|
||||
uint32_t* HandleOut;
|
||||
SYS_HANDLE* HandleOut;
|
||||
} SYS_CREATE_SURFACE_REQUEST;
|
||||
|
||||
KSTATUS SysCreateSurface(const SYS_CREATE_SURFACE_REQUEST* request);
|
||||
KSTATUS SysMapSurface(uint32_t surfaceHandle, void** baseOut, uint32_t* pitchBytesOut);
|
||||
KSTATUS SysQuerySurface(uint32_t surfaceHandle, SYS_SURFACE_DESC* descOut);
|
||||
KSTATUS SysPresentSurface(uint32_t surfaceHandle, const DISPLAY_RECT* rects, uint32_t rectCount);
|
||||
KSTATUS SysMapSurface(SYS_HANDLE surfaceHandle, void** baseOut, uint32_t* pitchBytesOut);
|
||||
KSTATUS SysQuerySurface(SYS_HANDLE surfaceHandle, SYS_SURFACE_DESC* descOut);
|
||||
KSTATUS SysPresentSurface(SYS_HANDLE surfaceHandle, const DISPLAY_RECT* rects, uint32_t rectCount);
|
||||
KSTATUS SysClearScreen(uint32_t color);
|
||||
KSTATUS SysGetScreenSize(int* widthOut, int* heightOut);
|
||||
KSTATUS SysQueryDisplayInfo(SYS_DISPLAY_INFO* infoOut);
|
||||
|
||||
// Display clocks are waitable pacing objects. Providers with frame-event
|
||||
// support signal them once per submitted frame. Other providers use the BSP
|
||||
// support signal them once per submitted frame. Other providers use the boot processor
|
||||
// scheduler tick, with PeriodMilliseconds rounded up to one or more ticks.
|
||||
#define SYS_DISPLAY_CLOCK_FLAG_NONE 0u
|
||||
#define SYS_DISPLAY_CLOCK_DEFAULT_PERIOD_MS 1ull
|
||||
@@ -888,7 +1000,7 @@ typedef struct SYS_OPEN_DISPLAY_CLOCK_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t Flags;
|
||||
uint64_t PeriodMilliseconds;
|
||||
uint32_t* HandleOut;
|
||||
SYS_HANDLE* HandleOut;
|
||||
} SYS_OPEN_DISPLAY_CLOCK_REQUEST;
|
||||
|
||||
KSTATUS SysOpenDisplayClock(const SYS_OPEN_DISPLAY_CLOCK_REQUEST* request);
|
||||
@@ -920,7 +1032,7 @@ typedef struct SYS_GLOBAL_INPUT_STATE {
|
||||
// empty. A finite timeout returns NTLSTATUS_TIMEOUT only when its deadline expires.
|
||||
typedef struct SYS_INPUT_EVENT_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t QueueHandle;
|
||||
SYS_HANDLE QueueHandle;
|
||||
uint32_t Flags;
|
||||
uint64_t TimeoutMilliseconds;
|
||||
INPUT_KEY_RECORD* RecordOut;
|
||||
@@ -984,6 +1096,7 @@ typedef struct SYS_SOCKET_ADDRESS {
|
||||
} SYS_SOCKET_ADDRESS;
|
||||
|
||||
typedef struct SYS_SOCKET_SEND_TO_REQUEST {
|
||||
uint32_t Size;
|
||||
const void* Buffer;
|
||||
size_t Length;
|
||||
uint32_t Flags;
|
||||
@@ -993,6 +1106,7 @@ typedef struct SYS_SOCKET_SEND_TO_REQUEST {
|
||||
} SYS_SOCKET_SEND_TO_REQUEST;
|
||||
|
||||
typedef struct SYS_SOCKET_RECV_FROM_REQUEST {
|
||||
uint32_t Size;
|
||||
void* Buffer;
|
||||
size_t Length;
|
||||
uint32_t Flags;
|
||||
@@ -1002,6 +1116,7 @@ typedef struct SYS_SOCKET_RECV_FROM_REQUEST {
|
||||
} SYS_SOCKET_RECV_FROM_REQUEST;
|
||||
|
||||
typedef struct SYS_RESOLVE_HOST_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_STRING_VIEW Name;
|
||||
uint32_t Family;
|
||||
uint32_t Flags;
|
||||
@@ -1010,6 +1125,7 @@ typedef struct SYS_RESOLVE_HOST_REQUEST {
|
||||
} SYS_RESOLVE_HOST_REQUEST;
|
||||
|
||||
typedef struct SYS_SOCKET_OPTION_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t Option;
|
||||
void* Value;
|
||||
size_t ValueSize;
|
||||
@@ -1017,7 +1133,7 @@ typedef struct SYS_SOCKET_OPTION_REQUEST {
|
||||
} SYS_SOCKET_OPTION_REQUEST;
|
||||
|
||||
typedef struct SYS_POLLFD {
|
||||
uint32_t Handle;
|
||||
SYS_HANDLE Handle;
|
||||
uint32_t Events;
|
||||
uint32_t ReturnedEvents;
|
||||
} SYS_POLLFD;
|
||||
@@ -1053,8 +1169,8 @@ typedef struct SYS_POLL_REQUEST {
|
||||
// queueing.
|
||||
typedef struct SYS_ASYNC_SOCKET_REQUEST {
|
||||
uint32_t Size;
|
||||
uint32_t SocketHandle;
|
||||
uint32_t EventHandle;
|
||||
SYS_HANDLE SocketHandle;
|
||||
SYS_HANDLE EventHandle;
|
||||
uint32_t Operation;
|
||||
uint32_t Flags;
|
||||
uint32_t SocketFlags;
|
||||
@@ -1075,28 +1191,47 @@ typedef struct SYS_ASYNC_SOCKET_REQUEST {
|
||||
size_t OptionValueSize;
|
||||
size_t* OptionActualSizeOut;
|
||||
|
||||
uint32_t* HandleOut;
|
||||
SYS_HANDLE* HandleOut;
|
||||
uint32_t* PollReturnedEventsOut;
|
||||
|
||||
SYS_IO_STATUS_BLOCK* Iosb;
|
||||
SYS_USER_APC_ROUTINE ApcRoutine;
|
||||
void* ApcContext;
|
||||
uint32_t* RequestHandleOut;
|
||||
SYS_HANDLE* RequestHandleOut;
|
||||
} SYS_ASYNC_SOCKET_REQUEST;
|
||||
|
||||
KSTATUS SysCreateSocket(uint32_t domain, uint32_t type, uint32_t protocol, uint32_t* handleOut);
|
||||
KSTATUS SysBindSocket(uint32_t socket, const SYS_SOCKET_ADDRESS* address, size_t addressSize);
|
||||
KSTATUS SysListenSocket(uint32_t socket, uint32_t backlog);
|
||||
KSTATUS SysAcceptSocket(uint32_t socket, SYS_SOCKET_ADDRESS* remoteAddressOut, size_t* remoteAddressSizeInOut, uint32_t* acceptedHandleOut);
|
||||
KSTATUS SysConnectSocket(uint32_t socket, const SYS_SOCKET_ADDRESS* address, size_t addressSize);
|
||||
KSTATUS SysSendSocket(uint32_t socket, const void* buffer, size_t length, uint32_t flags, size_t* sentOut);
|
||||
KSTATUS SysRecvSocket(uint32_t socket, void* buffer, size_t length, uint32_t flags, size_t* receivedOut);
|
||||
KSTATUS SysShutdownSocket(uint32_t socket, uint32_t how);
|
||||
KSTATUS SysSendToSocket(uint32_t socket, const SYS_SOCKET_SEND_TO_REQUEST* request);
|
||||
KSTATUS SysRecvFromSocket(uint32_t socket, const SYS_SOCKET_RECV_FROM_REQUEST* request);
|
||||
KSTATUS SysCreateSocket(uint32_t domain, uint32_t type, uint32_t protocol, SYS_HANDLE* handleOut);
|
||||
KSTATUS SysBindSocket(SYS_HANDLE socket, const SYS_SOCKET_ADDRESS* address, size_t addressSize);
|
||||
KSTATUS SysListenSocket(SYS_HANDLE socket, uint32_t backlog);
|
||||
KSTATUS SysAcceptSocket(SYS_HANDLE socket, SYS_SOCKET_ADDRESS* remoteAddressOut, size_t* remoteAddressSizeInOut, SYS_HANDLE* acceptedHandleOut);
|
||||
KSTATUS SysConnectSocket(SYS_HANDLE socket, const SYS_SOCKET_ADDRESS* address, size_t addressSize);
|
||||
|
||||
typedef struct SYS_SOCKET_SEND_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_HANDLE Socket;
|
||||
uint32_t Flags;
|
||||
const void* Buffer;
|
||||
size_t Length;
|
||||
size_t* SentOut;
|
||||
} SYS_SOCKET_SEND_REQUEST;
|
||||
|
||||
typedef struct SYS_SOCKET_RECV_REQUEST {
|
||||
uint32_t Size;
|
||||
SYS_HANDLE Socket;
|
||||
uint32_t Flags;
|
||||
void* Buffer;
|
||||
size_t Length;
|
||||
size_t* ReceivedOut;
|
||||
} SYS_SOCKET_RECV_REQUEST;
|
||||
|
||||
KSTATUS SysSendSocket(const SYS_SOCKET_SEND_REQUEST* request);
|
||||
KSTATUS SysRecvSocket(const SYS_SOCKET_RECV_REQUEST* request);
|
||||
KSTATUS SysShutdownSocket(SYS_HANDLE socket, uint32_t how);
|
||||
KSTATUS SysSendToSocket(SYS_HANDLE socket, const SYS_SOCKET_SEND_TO_REQUEST* request);
|
||||
KSTATUS SysRecvFromSocket(SYS_HANDLE socket, const SYS_SOCKET_RECV_FROM_REQUEST* request);
|
||||
KSTATUS SysResolveHost(const SYS_RESOLVE_HOST_REQUEST* request); // Cry about it.
|
||||
KSTATUS SysSetSocketOption(uint32_t socket, const SYS_SOCKET_OPTION_REQUEST* request);
|
||||
KSTATUS SysGetSocketOption(uint32_t socket, const SYS_SOCKET_OPTION_REQUEST* request);
|
||||
KSTATUS SysSetSocketOption(SYS_HANDLE socket, const SYS_SOCKET_OPTION_REQUEST* request);
|
||||
KSTATUS SysGetSocketOption(SYS_HANDLE socket, const SYS_SOCKET_OPTION_REQUEST* request);
|
||||
KSTATUS SysPoll(const SYS_POLL_REQUEST* request);
|
||||
KSTATUS SysSocketIoAsync(const SYS_ASYNC_SOCKET_REQUEST* request);
|
||||
|
||||
@@ -1125,6 +1260,9 @@ typedef struct SYS_MEMORY_STATUS {
|
||||
#define SYS_KERNEL_STATS_DISK 11u
|
||||
#define SYS_KERNEL_STATS_NET_IRP 12u
|
||||
#define SYS_KERNEL_STATS_EXCEPTION 13u
|
||||
#define SYS_KERNEL_STATS_PORT 14u
|
||||
#define SYS_KERNEL_STATS_VOLUME 15u
|
||||
#define SYS_KERNEL_STATS_VOLUME_MANAGER 16u
|
||||
|
||||
// Public stats payloads start with Size and Version. Size is the byte count
|
||||
// returned for that payload, including any trailing records. Version describes
|
||||
@@ -1146,6 +1284,20 @@ typedef struct SYS_EXCEPTION_STATS {
|
||||
uintptr_t LastFaultAddress;
|
||||
} SYS_EXCEPTION_STATS;
|
||||
|
||||
typedef struct SYS_PORT_STATS {
|
||||
uint32_t Size;
|
||||
uint32_t Version;
|
||||
uint64_t ConnectionsCreated;
|
||||
uint64_t DirectDeliveries;
|
||||
uint64_t DirectBytes;
|
||||
uint64_t QueuedMessages;
|
||||
uint64_t QueuedBytes;
|
||||
uint64_t QueuedDeliveries;
|
||||
uint64_t RepliesCompleted;
|
||||
uint64_t Disconnects;
|
||||
uint64_t ProcessQuotaRejects;
|
||||
} SYS_PORT_STATS;
|
||||
|
||||
typedef struct SYS_SCHEDULER_STATS {
|
||||
uint32_t Size;
|
||||
uint32_t Version;
|
||||
@@ -1184,7 +1336,7 @@ typedef struct SYS_PMM_STATS {
|
||||
|
||||
typedef struct SYS_CPU_STAT {
|
||||
uint32_t CpuIndex;
|
||||
uint32_t LapicId;
|
||||
uint32_t HardwareId;
|
||||
uint32_t Flags;
|
||||
uint32_t CurrentTid;
|
||||
uint32_t CurrentThreadFlags;
|
||||
@@ -1336,7 +1488,7 @@ typedef struct SYS_FILE_CACHE_STATS {
|
||||
uint64_t MaxResidentPages;
|
||||
} SYS_FILE_CACHE_STATS;
|
||||
|
||||
// Filesystem stats are generic VFS/driver telemetry. Drivers should map
|
||||
// Filesystem stats are generic I/O/provider telemetry. Drivers should map
|
||||
// private metadata work onto these counters instead of exposing filesystem-
|
||||
// specific cache names through the public ABI.
|
||||
typedef struct SYS_FILESYSTEM_STATS {
|
||||
@@ -1357,6 +1509,25 @@ typedef struct SYS_FILESYSTEM_STATS {
|
||||
uint64_t MaxDataReadSpanSectors;
|
||||
} SYS_FILESYSTEM_STATS;
|
||||
|
||||
typedef struct SYS_VOLUME_STATS {
|
||||
uint32_t Size;
|
||||
uint32_t Version;
|
||||
uint64_t CreatedVolumes;
|
||||
uint64_t MountedVolumes;
|
||||
uint64_t RemovedVolumes;
|
||||
uint64_t DeadIoRejects;
|
||||
uint64_t ProviderDestroys;
|
||||
} SYS_VOLUME_STATS;
|
||||
|
||||
typedef struct SYS_VOLUME_MANAGER_STATS {
|
||||
uint32_t Size;
|
||||
uint32_t Version;
|
||||
uint64_t Snapshots;
|
||||
uint64_t VolumeOpens;
|
||||
uint64_t Waits;
|
||||
uint64_t Wakeups;
|
||||
} SYS_VOLUME_MANAGER_STATS;
|
||||
|
||||
typedef struct SYS_DISK_STATS {
|
||||
uint32_t Size;
|
||||
uint32_t Version;
|
||||
@@ -1459,7 +1630,7 @@ typedef struct SYS_PTE_STATS {
|
||||
#define SYS_CPU_FLAG_STARTED 0x00000002u
|
||||
#define SYS_CPU_FLAG_PARKED 0x00000004u
|
||||
#define SYS_CPU_FLAG_ONLINE 0x00000008u
|
||||
#define SYS_CPU_FLAG_BSP 0x00000010u
|
||||
#define SYS_CPU_FLAG_BOOT_PROCESSOR 0x00000010u
|
||||
#define SYS_CPU_FLAG_PRIMARY 0x00000020u
|
||||
|
||||
// Time and diagnostics.
|
||||
|
||||
Reference in new issue
Block a user