reactos/sdk/lib/rtl/rtlp.h
Hermès Bélusca-Maïto 24cb57fdea
[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.
2022-04-07 03:19:09 +02:00

278 lines
5.5 KiB
C

/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS System Libraries
* FILE: lib/rtl/rtlp.h
* PURPOSE: Run-Time Libary Internal Header
* PROGRAMMER: Alex Ionescu
*/
/* INCLUDES ******************************************************************/
/* PAGED_CODE equivalent for user-mode RTL */
#if DBG
extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line);
#define PAGED_CODE_RTL() CHECK_PAGED_CODE_RTL(__FILE__, __LINE__)
#else
#define PAGED_CODE_RTL()
#endif
#ifdef _PPC_
#define SWAPD(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff))
#define SWAPW(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff))
#define SWAPQ(x) ((SWAPD((x)&0xffffffff) << 32) | (SWAPD((x)>>32)))
#else
#define SWAPD(x) (x)
#define SWAPW(x) (x)
#define SWAPQ(x) (x)
#endif
#define ROUND_DOWN(n, align) \
(((ULONG_PTR)(n)) & ~((align) - 1l))
#define ROUND_UP(n, align) \
ROUND_DOWN(((ULONG_PTR)(n)) + (align) - 1, (align))
#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))
extern PVOID MmHighestUserAddress;
NTSTATUS
NTAPI
RtlpSafeCopyMemory(
_Out_writes_bytes_all_(Length) VOID UNALIGNED *Destination,
_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
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(
IN PEXCEPTION_RECORD ExceptionRecord,
IN PCONTEXT Context
);
VOID
NTAPI
RtlCallVectoredContinueHandlers(
IN PEXCEPTION_RECORD ExceptionRecord,
IN PCONTEXT Context
);
#ifdef _M_IX86
typedef struct _DISPATCHER_CONTEXT
{
PEXCEPTION_REGISTRATION_RECORD RegistrationPointer;
} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
#endif
#endif /* !_BLDR_ */
/* These provide support for sharing code between User and Kernel RTL */
PVOID
NTAPI
RtlpAllocateMemory(
SIZE_T Bytes,
ULONG Tag);
VOID
NTAPI
RtlpFreeMemory(
PVOID Mem,
ULONG Tag);
#ifndef _BLDR_
KPROCESSOR_MODE
NTAPI
RtlpGetMode(VOID);
BOOLEAN
NTAPI
RtlpCaptureStackLimits(
IN ULONG_PTR Ebp,
IN ULONG_PTR *StackBegin,
IN ULONG_PTR *StackEnd
);
/* For heap.c and heappage.c */
NTSTATUS
NTAPI
RtlDeleteHeapLock(IN OUT PHEAP_LOCK Lock);
NTSTATUS
NTAPI
RtlEnterHeapLock(IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive);
BOOLEAN
NTAPI
RtlTryEnterHeapLock(IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive);
NTSTATUS
NTAPI
RtlInitializeHeapLock(IN OUT PHEAP_LOCK *Lock);
NTSTATUS
NTAPI
RtlLeaveHeapLock(IN OUT PHEAP_LOCK Lock);
BOOLEAN
NTAPI
RtlpCheckForActiveDebugger(VOID);
BOOLEAN
NTAPI
RtlpHandleDpcStackException(IN PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
IN ULONG_PTR RegistrationFrameEnd,
IN OUT PULONG_PTR StackLow,
IN OUT PULONG_PTR StackHigh);
#endif /* !_BLDR_ */
#define RtlpAllocateStringMemory RtlpAllocateMemory
#define RtlpFreeStringMemory RtlpFreeMemory
#ifndef _BLDR_
ULONG
NTAPI
RtlGetTickCount(VOID);
#define NtGetTickCount RtlGetTickCount
BOOLEAN
NTAPI
RtlpSetInDbgPrint(
VOID
);
VOID
NTAPI
RtlpClearInDbgPrint(
VOID
);
/* i386/except.S */
#ifdef _M_IX86
EXCEPTION_DISPOSITION
NTAPI
RtlpExecuteHandlerForException(PEXCEPTION_RECORD ExceptionRecord,
PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
PCONTEXT Context,
PVOID DispatcherContext,
PEXCEPTION_ROUTINE ExceptionHandler);
#endif
EXCEPTION_DISPOSITION
NTAPI
RtlpExecuteHandlerForUnwind(PEXCEPTION_RECORD ExceptionRecord,
PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
PCONTEXT Context,
PVOID DispatcherContext,
PEXCEPTION_ROUTINE ExceptionHandler);
VOID
NTAPI
RtlpCheckLogException(IN PEXCEPTION_RECORD ExceptionRecord,
IN PCONTEXT ContextRecord,
IN PVOID ContextData,
IN ULONG Size);
VOID
NTAPI
RtlpCaptureContext(OUT PCONTEXT ContextRecord);
//
// Debug Service calls
//
ULONG
NTAPI
DebugService(
IN ULONG Service,
IN PVOID Argument1,
IN PVOID Argument2,
IN PVOID Argument3,
IN PVOID Argument4
);
VOID
NTAPI
DebugService2(
IN PVOID Argument1,
IN PVOID Argument2,
IN ULONG Service
);
/* Timer Queue */
extern HANDLE TimerThreadHandle;
NTSTATUS
RtlpInitializeTimerThread(VOID);
#endif /* !_BLDR_ */
/* bitmap64.c */
typedef struct _RTL_BITMAP64
{
ULONG64 SizeOfBitMap;
PULONG64 Buffer;
} RTL_BITMAP64, *PRTL_BITMAP64;
typedef struct _RTL_BITMAP_RUN64
{
ULONG64 StartingIndex;
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
RtlpUpcaseUnicodeChar(IN WCHAR Source);
WCHAR
NTAPI
RtlpDowncaseUnicodeChar(IN WCHAR Source);
#ifndef _BLDR_
/* ReactOS only */
VOID
NTAPI
LdrpInitializeProcessCompat(PVOID pProcessActctx, PVOID* pOldShimData);
PVOID
NTAPI
RtlpDebugBufferCommit(_Inout_ PRTL_DEBUG_INFORMATION Buffer,
_In_ SIZE_T Size);
#endif /* !_BLDR_ */
/* EOF */