Files
nt-lite/code/public/ntlite/status.h
T
maksw 73abd6f90d isolate POSIX builds from the host UCRT, wire lwext4 and ntfs-3g as ext4.sys and ntfs.sys, split the FAT driver into directory/file/async/driver/mount units, add posixsrv and dwm plus input/console/desktop syscall clients and a pile of new smoke targets, rename serial.sys to cereal.sys, name HDA/USB/lwIP/AHCI workers, harden ATA probing/reset/removal around actual hardware deadlines, absent-channel detection, diagnostics and explicit worker lifetime, redo ACPI S5 shutdown around GAS/MMIO and HW-reduced firmware, scan SSDTs for _S5 and deal with Intel SMI sleep trapping, make serial and SMP timeouts use real monotonic deadlines, add thread names and fix terminal thread teardown, scheduler and APC prepare/commit races, make advisory file locks queryable and preserve split ranges and add mutable file append state, add shared-memory pipes with kernel-assisted wait/wake, introduce capability-scoped input and display managers, split surface map rights into read/write, add explicit unmap and replace present with commit/generation/damage tracking while keeping physical presentation under the display manager, decouple native exception classes from Win32 exception numbers and translate them in kernel32, add opaque process startup data, bump the resource protocol to v3 with namespace directories, symlinks and enumeration and service control to v2 with generic READY handle exports, add the new POSIX errno/status surface and rebuild fds around posixsrv-owned shared open descriptions, descriptor-local flags, exact inheritance snapshots, dup/fcntl/record locks and shared-ring pipes, add waitpid, POSIX credentials/groups/sessions/passwd/group lookups and move sockets onto stable open descriptions, port the shells and apps to the new console/input services and surface commit API, teach init to load services.ini and start/supervise RSSRV, DWM and generic services under restricted capabilities while publishing their endpoints through RSSRV, split RSSRV into namespace, volume, display, session, input, console and resource components and make /SystemRoot a real symlink to the independently published system volume, shift the syscall table again, expand lock/resource/surface/POSIX/service/thread smoke coverage, make docs scream ASK QUESTIONS and DISCUSS at LLMs, replace MIT No Attribution with WTFPL+.
2026-09-16 10:33:20 +02:00

95 lines
6.8 KiB
C

// Public NTLite status ABI declarations shared between kernel, drivers, and user mode.
#pragma once
#include <stdint.h>
// All fallible kernel functions return KSTATUS. Bit 31 is the error bit, bits
// 30..24 identify the facility, and bits 23..0 contain the facility-local code.
typedef uint32_t KSTATUS;
#define KSTATUS_ERROR_BIT 0x80000000u
#define KSTATUS_FACILITY_SHIFT 24u
#define KSTATUS_FACILITY_MASK 0x7Fu
#define KSTATUS_CODE_MASK 0x00FFFFFFu
#define KSTATUS_MAKE_SUCCESS(facility, code) \
((KSTATUS)((((uint32_t)(facility) & KSTATUS_FACILITY_MASK) << KSTATUS_FACILITY_SHIFT) | \
((uint32_t)(code) & KSTATUS_CODE_MASK)))
#define KSTATUS_MAKE_ERROR(facility, code) \
((KSTATUS)(KSTATUS_ERROR_BIT | \
(((uint32_t)(facility) & KSTATUS_FACILITY_MASK) << KSTATUS_FACILITY_SHIFT) | \
((uint32_t)(code) & KSTATUS_CODE_MASK)))
#define KSTATUS_IS_ERROR(status) ((((KSTATUS)(status)) & KSTATUS_ERROR_BIT) != 0u)
#define KSTATUS_FACILITY(status) ((((KSTATUS)(status)) >> KSTATUS_FACILITY_SHIFT) & KSTATUS_FACILITY_MASK)
#define KSTATUS_CODE(status) (((KSTATUS)(status)) & KSTATUS_CODE_MASK)
#define NTLSTATUS_FACILITY_WAIT 0x00u
#define NTLSTATUS_FACILITY_SYSTEM 0x01u
#define NTLSTATUS_FACILITY_PROCESS 0x61u
// Wait-completion statuses are non-error statuses. NTLSTATUS_SUCCESS is exactly
// zero so old zero-initialisation and direct syscall success checks stay valid.
#define NTLSTATUS_SUCCESS ((KSTATUS)0x00000000u)
#define NTLSTATUS_TIMEOUT KSTATUS_MAKE_SUCCESS(NTLSTATUS_FACILITY_WAIT, 0x000001u)
#define NTLSTATUS_PENDING KSTATUS_MAKE_SUCCESS(NTLSTATUS_FACILITY_WAIT, 0x000002u)
#define NTLSTATUS_ALERTED KSTATUS_MAKE_SUCCESS(NTLSTATUS_FACILITY_WAIT, 0x000003u)
#define NTLSTATUS_KERNEL_APC KSTATUS_MAKE_SUCCESS(NTLSTATUS_FACILITY_WAIT, 0x000004u)
#define NTLSTATUS_USER_APC KSTATUS_MAKE_SUCCESS(NTLSTATUS_FACILITY_WAIT, 0x000005u)
#define NTLSTATUS_ABANDONED KSTATUS_MAKE_SUCCESS(NTLSTATUS_FACILITY_WAIT, 0x000006u)
// System-facility failures.
// NTLSTATUS_WOULD_BLOCK is the canonical result for immediate nonblocking operations that cannot make progress.
// NTLSTATUS_TIMEOUT is reserved for finite waits whose deadline expires.
#define NTLSTATUS_FAILURE KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000001u)
#define NTLSTATUS_NOT_SUPPORTED KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000002u)
#define NTLSTATUS_INVALID_PARAMETER KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000003u)
#define NTLSTATUS_INVALID_HANDLE KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000004u)
#define NTLSTATUS_BUFFER_TOO_SMALL KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000005u)
#define NTLSTATUS_CHECKSUM_MISMATCH KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000006u)
#define NTLSTATUS_NO_MEMORY KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000007u)
#define NTLSTATUS_ACCESS_DENIED KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000008u)
#define NTLSTATUS_NOT_FOUND KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000009u)
#define NTLSTATUS_ALREADY_EXISTS KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00000Au)
#define NTLSTATUS_OBJECT_NAME_COLLISION KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00000Bu)
#define NTLSTATUS_OBJECT_DEAD KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00000Cu)
#define NTLSTATUS_QUEUE_FULL KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00000Du)
#define NTLSTATUS_QUEUE_EMPTY KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00000Eu)
#define NTLSTATUS_CANCELLED KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00000Fu)
#define NTLSTATUS_DEVICE_ERROR KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000010u)
#define NTLSTATUS_NO_MORE_FILES KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000011u)
#define NTLSTATUS_INVALID_IRQL KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000012u)
#define NTLSTATUS_WOULD_BLOCK KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000013u)
#define NTLSTATUS_DEADLOCK KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000014u)
#define NTLSTATUS_DEVICE_REMOVED KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000015u)
#define NTLSTATUS_ID_EXHAUSTED KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000016u)
#define NTLSTATUS_CAPABILITY_REVOKED KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000017u)
#define NTLSTATUS_LIMIT_REACHED KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000018u)
#define NTLSTATUS_PORT_DISCONNECTED KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000019u)
#define NTLSTATUS_BROKEN_PIPE KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00001Au)
#define NTLSTATUS_NOT_A_DIRECTORY KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00001Bu)
#define NTLSTATUS_IS_A_DIRECTORY KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00001Cu)
#define NTLSTATUS_DIRECTORY_NOT_EMPTY KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00001Du)
#define NTLSTATUS_CROSS_DEVICE KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00001Eu)
#define NTLSTATUS_NO_CHILD KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x00001Fu)
#define NTLSTATUS_INVALID_IMAGE_FORMAT KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000020u)
#define NTLSTATUS_NAME_TOO_LONG KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000021u)
#define NTLSTATUS_TOO_MANY_LINKS KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000022u)
#define NTLSTATUS_READ_ONLY_FILESYSTEM KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000023u)
#define NTLSTATUS_FILE_TOO_LARGE KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_SYSTEM, 0x000024u)
// Process termination and fault statuses use the process facility.
#define NTLSTATUS_PROCESS_BASE KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000000u)
#define NTLSTATUS_PROCESS_KILLED KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000000u)
#define NTLSTATUS_PROCESS_PAGE_FAULT KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000010u)
#define NTLSTATUS_PROCESS_GENERAL_PROTECTION KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000011u)
#define NTLSTATUS_PROCESS_ILLEGAL_OPCODE KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000012u)
#define NTLSTATUS_PROCESS_DIVIDE_BY_ZERO KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000013u)
#define NTLSTATUS_PROCESS_BREAKPOINT KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000014u)
#define NTLSTATUS_PROCESS_ALIGNMENT_FAULT KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000015u)
#define NTLSTATUS_PROCESS_USER_EXCEPTION KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x000016u)
#define NTLSTATUS_PROCESS_UNKNOWN_FAULT KSTATUS_MAKE_ERROR(NTLSTATUS_FACILITY_PROCESS, 0x00001Fu)
#define KSUCCESS(status) (((KSTATUS)(status)) == NTLSTATUS_SUCCESS)
#define KFAILED(status) KSTATUS_IS_ERROR(status)