[BOOT][SDK:RTL] Compile a reduced RTL library for FreeLdr / NT bootloader...

... as it should have always been done (and must be done for NTDLL
and NTOS kernel as well). This allows using the RTL with the correct
definitions and the reduced functionality available at boot-time.

+ Make the RTL main header compatible.

In addition, this will permit re-using existing code that already
uses the RTL (mostly string conversions).

See commits 427c90af3 (r36761) and b46e8cc18 (r36980) for some
background.
This commit is contained in:
Hermès Bélusca-Maïto 2022-03-21 21:06:52 +01:00
parent 2ac49f0824
commit 24cb57fdea
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
8 changed files with 422 additions and 15 deletions

View file

@ -9,13 +9,15 @@
#ifndef RTL_H
#define RTL_H
/* We're a core NT DLL, we don't import syscalls */
/* We are a core NT DLL, we don't import syscalls */
#define _INC_SWPRINTF_INL_
#undef __MSVCRT__
/* C Headers */
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef _BLDR_
/* PSDK/NDK Headers */
#define WIN32_NO_STATUS
@ -43,6 +45,12 @@
/* SEH support with PSEH */
#include <pseh/pseh2.h>
#else
#include <ndk/rtlfuncs.h>
#endif /* _BLDR_ */
/* Internal RTL header */
#include "rtlp.h"

View file

@ -43,23 +43,31 @@ RtlpSafeCopyMemory(
_In_reads_bytes_(Length) CONST VOID UNALIGNED *Source,
_In_ SIZE_T Length);
#ifndef _BLDR_
VOID
NTAPI
RtlpGetStackLimits(PULONG_PTR LowLimit,
PULONG_PTR HighLimit);
#ifdef _M_IX86
PEXCEPTION_REGISTRATION_RECORD
NTAPI
RtlpGetExceptionList(VOID);
VOID
NTAPI
RtlpSetHeapParameters(IN PRTL_HEAP_PARAMETERS Parameters);
VOID
NTAPI
RtlpSetExceptionList(PEXCEPTION_REGISTRATION_RECORD NewExceptionList);
#endif /* _M_IX86 */
/* For heap.c */
VOID
NTAPI
RtlpSetHeapParameters(IN PRTL_HEAP_PARAMETERS Parameters);
/* For vectoreh.c */
BOOLEAN
NTAPI
RtlCallVectoredExceptionHandlers(
@ -81,6 +89,8 @@ typedef struct _DISPATCHER_CONTEXT
} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
#endif
#endif /* !_BLDR_ */
/* These provide support for sharing code between User and Kernel RTL */
PVOID
NTAPI
@ -94,6 +104,8 @@ RtlpFreeMemory(
PVOID Mem,
ULONG Tag);
#ifndef _BLDR_
KPROCESSOR_MODE
NTAPI
RtlpGetMode(VOID);
@ -106,6 +118,7 @@ RtlpCaptureStackLimits(
IN ULONG_PTR *StackEnd
);
/* For heap.c and heappage.c */
NTSTATUS
NTAPI
RtlDeleteHeapLock(IN OUT PHEAP_LOCK Lock);
@ -137,9 +150,13 @@ RtlpHandleDpcStackException(IN PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
IN OUT PULONG_PTR StackLow,
IN OUT PULONG_PTR StackHigh);
#endif /* !_BLDR_ */
#define RtlpAllocateStringMemory RtlpAllocateMemory
#define RtlpFreeStringMemory RtlpFreeMemory
#ifndef _BLDR_
ULONG
NTAPI
RtlGetTickCount(VOID);
@ -209,18 +226,14 @@ DebugService2(
IN ULONG Service
);
/* Tags for the String Allocators */
#define TAG_USTR 'RTSU'
#define TAG_ASTR 'RTSA'
#define TAG_OSTR 'RTSO'
/* Timer Queue */
extern HANDLE TimerThreadHandle;
NTSTATUS
RtlpInitializeTimerThread(VOID);
#endif /* !_BLDR_ */
/* bitmap64.c */
typedef struct _RTL_BITMAP64
{
@ -234,6 +247,11 @@ typedef struct _RTL_BITMAP_RUN64
ULONG64 NumberOfBits;
} RTL_BITMAP_RUN64, *PRTL_BITMAP_RUN64;
/* Tags for the String Allocators */
#define TAG_USTR 'RTSU'
#define TAG_ASTR 'RTSA'
#define TAG_OSTR 'RTSO'
/* nls.c */
WCHAR
NTAPI
@ -243,6 +261,8 @@ WCHAR
NTAPI
RtlpDowncaseUnicodeChar(IN WCHAR Source);
#ifndef _BLDR_
/* ReactOS only */
VOID
NTAPI
@ -253,5 +273,6 @@ NTAPI
RtlpDebugBufferCommit(_Inout_ PRTL_DEBUG_INFORMATION Buffer,
_In_ SIZE_T Size);
#endif /* !_BLDR_ */
/* EOF */