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:
maksw committed 2026-10-26 10:08:03 +01:00
1 parent c0ad63c27f
commit d36f19509c
160 files changed
+6563 -7366

No files matched your search

+26 -5
View File
@@ -170,6 +170,7 @@ typedef struct MODULE_ENTRY {
char Name[LDR_KERNEL_MODULE_NAME_MAX];
uintptr_t Base;
size_t Size;
bool ExportsAvailable;
struct MODULE_ENTRY* Next;
} MODULE_ENTRY;
@@ -182,7 +183,8 @@ static KSTATUS KiEnsureUserImageWrite(PROCESS* process, bool user, uintptr_t add
}
// Allocates and inserts one global kernel-module registry entry.
static KSTATUS KiRegisterGlobalModule(const char* name, uintptr_t base, size_t size) {
static KSTATUS KiRegisterGlobalModule(const char* name, uintptr_t base, size_t size,
bool exportsAvailable) {
if (!name || !*name || !base || !size)
return NTLSTATUS_INVALID_PARAMETER;
@@ -201,6 +203,7 @@ static KSTATUS KiRegisterGlobalModule(const char* name, uintptr_t base, size_t s
entry->Name[nameLength] = '\0';
entry->Base = base;
entry->Size = size;
entry->ExportsAvailable = exportsAvailable;
entry->Next = gModules;
gModules = entry;
return NTLSTATUS_SUCCESS;
@@ -213,19 +216,32 @@ KSTATUS LdrRegisterModulesFromBootInfo(const BOOT_INFO* bootInfo) {
KSTATUS status = KiRegisterGlobalModule("kernel.exe",
bootInfo->KernelImage.VirtualBase,
bootInfo->KernelImage.ImageSize);
bootInfo->KernelImage.ImageSize, true);
if (!KSUCCESS(status))
return status;
return KiRegisterGlobalModule("hal.dll",
bootInfo->HalImage.VirtualBase,
bootInfo->HalImage.ImageSize);
bootInfo->HalImage.ImageSize, true);
}
// Registers one loaded kernel module without imposing a fixed registry capacity.
KSTATUS LdrRegisterModule(const char* name, uintptr_t base) {
size_t size = base ? LdrGetImageSize(base) : 0;
return KiRegisterGlobalModule(name, base, size);
return KiRegisterGlobalModule(name, base, size, false);
}
// Makes an initialized module's exports visible to future import resolution.
// Failed images remain mapped for diagnostics but must not provide exports.
KSTATUS LdrSetModuleExportsAvailable(const char* name, bool available) {
if (!name) return NTLSTATUS_INVALID_PARAMETER;
for (MODULE_ENTRY* entry = gModules; entry; entry = entry->Next) {
if (_stricmp(entry->Name, name) == 0) {
entry->ExportsAvailable = available;
return NTLSTATUS_SUCCESS;
}
}
return NTLSTATUS_NOT_FOUND;
}
// Finds the loaded kernel module that owns an address.
@@ -251,7 +267,7 @@ const char* LdrFindKernelModuleByAddress(uintptr_t address, uintptr_t* baseOut,
static uintptr_t KiFindGlobalModuleBase(const char* name) {
if (!name) return 0;
for (MODULE_ENTRY* module = gModules; module; module = module->Next) {
if (_stricmp(module->Name, name) == 0)
if (module->ExportsAvailable && _stricmp(module->Name, name) == 0)
return module->Base;
}
return 0;
@@ -286,6 +302,11 @@ static void* KiGetExportAtBase(uintptr_t base, const char* functionName) {
return (void*)0;
}
// Resolves a named export without depending on the image's registration name.
void* LdrGetImageExport(uintptr_t imageBase, const char* functionName) {
return functionName ? KiGetExportAtBase(imageBase, functionName) : (void*)0;
}
// Export lookup.
void* LdrGetExport(const char* moduleName, const char* functionName) {
uintptr_t base = KiFindGlobalModuleBase(moduleName);