77 lines
3.1 KiB
C
77 lines
3.1 KiB
C
// Native userspace module-loader declarations.
|
|
|
|
#pragma once
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <ntlite/handle.h>
|
|
#include <ntlite/status.h>
|
|
#include <ntlite/string_view.h>
|
|
|
|
#define NTL_MODULE_NAME_MAX 64u
|
|
#define NTL_MODULE_LOAD_FLAG_NONE 0x00000000u
|
|
|
|
// Opaque process-local userspace module identity. It is never a kernel capability.
|
|
typedef uintptr_t NTL_MODULE_HANDLE;
|
|
#define NTL_MODULE_HANDLE_INVALID ((NTL_MODULE_HANDLE)0u)
|
|
|
|
// Maps one PE import name to the canonical module filename used by policy.
|
|
// canonicalNameOut may refer to requestedName storage or to caller-owned static storage.
|
|
typedef KSTATUS (*NTL_MODULE_NAME_RESOLVER)(void* context,
|
|
SYS_STRING_VIEW requestedName,
|
|
SYS_STRING_VIEW* canonicalNameOut);
|
|
|
|
typedef struct NTL_MODULE_INFO {
|
|
uintptr_t Base;
|
|
size_t Size;
|
|
uintptr_t EntryPoint;
|
|
uint32_t PublicRefCount;
|
|
uint32_t ImportPinned;
|
|
char Name[NTL_MODULE_NAME_MAX];
|
|
} NTL_MODULE_INFO;
|
|
|
|
typedef struct NTL_LOAD_MODULE_AT_REQUEST {
|
|
uint32_t Size;
|
|
uint32_t Flags;
|
|
SYS_HANDLE RootHandle;
|
|
SYS_STRING_VIEW Path;
|
|
SYS_HANDLE ModuleRootHandle;
|
|
SYS_STRING_VIEW ModuleDirectory;
|
|
NTL_MODULE_NAME_RESOLVER ResolveModuleName;
|
|
void* ResolveContext;
|
|
NTL_MODULE_HANDLE* ModuleHandleOut;
|
|
NTL_MODULE_INFO* InfoOut;
|
|
} NTL_LOAD_MODULE_AT_REQUEST;
|
|
|
|
#if defined(NTL_SYSCALL_STATIC)
|
|
#define NTL_MODULE_LOADER_API
|
|
#elif defined(NTL_SYSCALL_BUILD)
|
|
#define NTL_MODULE_LOADER_API __declspec(dllexport)
|
|
#else
|
|
#define NTL_MODULE_LOADER_API
|
|
#endif
|
|
|
|
// Identity module-name policy for native images whose import names are already canonical.
|
|
NTL_MODULE_LOADER_API KSTATUS NtlResolveModuleNameIdentity(void* context,
|
|
SYS_STRING_VIEW requestedName,
|
|
SYS_STRING_VIEW* canonicalNameOut);
|
|
|
|
// Resolves the installed Win32/POSIX compatibility import aliases for generic userspace launchers.
|
|
NTL_MODULE_LOADER_API KSTATUS NtlResolveSystemModuleName(void* context,
|
|
SYS_STRING_VIEW requestedName,
|
|
SYS_STRING_VIEW* canonicalNameOut);
|
|
|
|
// Loads one DLL-like image into the current process. Dependency images are resolved
|
|
// beneath ModuleRootHandle/ModuleDirectory and remain import-pinned for process lifetime.
|
|
NTL_MODULE_LOADER_API KSTATUS NtlLoadModuleAt(const NTL_LOAD_MODULE_AT_REQUEST* request);
|
|
NTL_MODULE_LOADER_API KSTATUS NtlUnloadModule(NTL_MODULE_HANDLE module);
|
|
NTL_MODULE_LOADER_API KSTATUS NtlGetModuleInfo(NTL_MODULE_HANDLE module, NTL_MODULE_INFO* infoOut);
|
|
NTL_MODULE_LOADER_API KSTATUS NtlGetModuleExport(NTL_MODULE_HANDLE module,
|
|
SYS_STRING_VIEW name,
|
|
uintptr_t* addressOut);
|
|
NTL_MODULE_LOADER_API KSTATUS NtlGetModuleList(NTL_MODULE_INFO* modulesOut,
|
|
size_t maxCount,
|
|
size_t* countOut);
|
|
|
|
#undef NTL_MODULE_LOADER_API
|