#define NDEBUG
#include <debug.h>
+SIZE_T RtlpAllocDeallocQueryBufferSize = PAGE_SIZE;
+PTEB LdrpTopLevelDllBeingLoadedTeb = NULL;
+#define IMAGE_DOS_MAGIC 0x5a4d
+#define IMAGE_PE_MAGIC 0x00004550
+
/* FUNCTIONS ***************************************************************/
+#ifndef _M_AMD64
+// FIXME: Why "Not implemented"???
/*
* @implemented
*/
/* Not implemented for user-mode */
return 0;
}
+#endif
BOOLEAN
NTAPI
return UserMode;
}
+/*
+ * @implemented
+ */
PPEB
NTAPI
-RtlpCurrentPeb(VOID)
+RtlGetCurrentPeb(VOID)
{
return NtCurrentPeb();
}
}
-#ifdef DBG
+#if DBG
VOID FASTCALL
CHECK_PAGED_CODE_RTL(char *file, int line)
{
return TRUE;
}
+#ifdef _AMD64_
+VOID
+NTAPI
+RtlpGetStackLimits(
+ OUT PULONG_PTR LowLimit,
+ OUT PULONG_PTR HighLimit)
+{
+ *LowLimit = (ULONG_PTR)NtCurrentTeb()->Tib.StackLimit;
+ *HighLimit = (ULONG_PTR)NtCurrentTeb()->Tib.StackBase;
+ return;
+}
+#endif
+
+BOOLEAN
+NTAPI
+RtlIsThreadWithinLoaderCallout(VOID)
+{
+ return LdrpTopLevelDllBeingLoadedTeb == NtCurrentTeb();
+}
+
/* RTL Atom Tables ************************************************************/
typedef struct _RTL_ATOM_HANDLE
return NULL;
}
+PVOID
+NTAPI
+RtlpLookupModuleBase(
+ PVOID Address)
+{
+ NTSTATUS Status;
+ MEMORY_BASIC_INFORMATION MemoryInformation;
+ ULONG_PTR Base, Limit;
+ PIMAGE_DOS_HEADER DosHeader;
+ PIMAGE_NT_HEADERS NtHeader;
+
+ Status = NtQueryVirtualMemory(NtCurrentProcess(),
+ Address,
+ MemoryBasicInformation,
+ &MemoryInformation,
+ sizeof(MEMORY_BASIC_INFORMATION),
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ return NULL;
+ }
+
+ /* FIXME: remove these checks? */
+ Base = (ULONG_PTR)MemoryInformation.BaseAddress;
+ Limit = Base + MemoryInformation.RegionSize;
+ if ( ((ULONG_PTR)Address < Base) ||
+ ((ULONG_PTR)Address >= Limit) )
+ {
+ /* WTF? */
+ return NULL;
+ }
+
+ /* Check if we got the right kind of memory */
+ if ( (MemoryInformation.State != MEM_COMMIT) ||
+ (MemoryInformation.Type != MEM_IMAGE) )
+ {
+ return NULL;
+ }
+
+ /* Check DOS magic */
+ DosHeader = MemoryInformation.AllocationBase;
+ if (DosHeader->e_magic != IMAGE_DOS_MAGIC)
+ {
+ return NULL;
+ }
+
+ /* Check NT header */
+ NtHeader = (PVOID)((ULONG_PTR)DosHeader + DosHeader->e_lfanew);
+ if (NtHeader->Signature != IMAGE_PE_MAGIC)
+ {
+ return NULL;
+ }
+
+ return MemoryInformation.AllocationBase;
+}
+
/*
* Ldr Resource support code