Files
nt-lite/code/kernel/ldr_image.h
T

28 lines
1.1 KiB
C

#pragma once
// ldr_image.h - minimal PE32+ loader
// Loads an already-mapped PE image and resolves its imports.
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <ke_status.h>
// Map a PE32+ image from 'buffer' into the kernel virtual address space.
// On success, *baseOut receives the virtual base address.
KSTATUS LdrLoadImage(const void* buffer, size_t size, uintptr_t* baseOut, bool user);
// Look up a named export in a loaded module.
// 'moduleName' must match a name in BOOT_INFO.Modules (e.g., "hal.dll").
void* LdrGetExport(const char* moduleName, const char* functionName);
// Get the entry point address of a loaded image.
uintptr_t LdrGetEntryPoint(uintptr_t base);
// Resolve the import table of an already-loaded image.
KSTATUS LdrResolveImports(uintptr_t imageBase);
// Called by KernelMain to register all modules from BOOT_INFO so that
// LdrGetExport can find them.
struct BOOT_INFO; // forward declare for the compiler to shut the fuck up
void LdrRegisterModulesFromBootInfo(const struct BOOT_INFO* bootInfo);
void LdrRegisterModule(const char* name, uintptr_t base);