#define NDEBUG
#include <debug.h>
-#define TAG_ATMT TAG('A', 't', 'o', 'T') /* Atom table */
+#define TAG_ATMT 'TotA' /* Atom table */
extern ULONG NtGlobalFlag;
/* FUNCTIONS *****************************************************************/
+PVOID
+NTAPI
+RtlpLookupModuleBase(
+ PVOID Address)
+{
+ PLDR_DATA_TABLE_ENTRY LdrEntry;
+ BOOLEAN InSystem;
+ PVOID p;
+
+ /* Get the base for this file */
+ if ((ULONG_PTR)Address > (ULONG_PTR)MmHighestUserAddress)
+ {
+ /* We are in kernel */
+ p = KiPcToFileHeader(Address, &LdrEntry, FALSE, &InSystem);
+ }
+ else
+ {
+ /* We are in user land */
+ p = KiRosPcToUserFileHeader(Address, &LdrEntry);
+ }
+
+ return p;
+}
+
VOID
NTAPI
RtlInitializeRangeListPackage(VOID)
NULL,
POOL_COLD_ALLOCATION,
sizeof(RTL_RANGE_ENTRY),
- TAG('R', 'R', 'l', 'e'),
+ 'elRR',
16);
}
BOOLEAN
NTAPI
-RtlpCheckForActiveDebugger(BOOLEAN Type)
+RtlpCheckForActiveDebugger(VOID)
{
/* This check is meaningless in kernel-mode */
- return Type;
+ return FALSE;
}
BOOLEAN
}
-#define TAG_USTR TAG('U', 'S', 'T', 'R')
-#define TAG_ASTR TAG('A', 'S', 'T', 'R')
-#define TAG_OSTR TAG('O', 'S', 'T', 'R')
+#define TAG_USTR 'RTSU'
+#define TAG_ASTR 'RTSA'
+#define TAG_OSTR 'RTSO'
VOID
NTAPI
RtlpFreeMemory(PVOID Mem,
return STATUS_SUCCESS;
}
-#ifdef DBG
+#if DBG
VOID FASTCALL
CHECK_PAGED_CODE_RTL(char *file, int line)
{
return FALSE;
}
-#ifndef _ARM_
+#if !defined(_ARM_) && !defined(_AMD64_)
BOOLEAN
NTAPI
Stack = TrapFrame->Ebp;
#elif defined(_M_PPC)
Stack = TrapFrame->Gpr1;
+#else
+#error Unknown architecture
#endif
/* Validate them */
#endif
+#ifdef _AMD64_
+VOID
+NTAPI
+RtlpGetStackLimits(
+ OUT PULONG_PTR LowLimit,
+ OUT PULONG_PTR HighLimit)
+{
+ PKTHREAD CurrentThread = KeGetCurrentThread();
+ *HighLimit = (ULONG_PTR)CurrentThread->InitialStack;
+ *LowLimit = (ULONG_PTR)CurrentThread->StackLimit;
+}
+#endif
+
/* RTL Atom Tables ************************************************************/
NTSTATUS
HANDLE Handle;
USHORT HandleIndex;
+ /* Initialize ex handle table entry */
ExEntry.Object = Entry;
ExEntry.GrantedAccess = 0x1; /* FIXME - valid handle */
+ /* Create ex handle */
Handle = ExCreateHandle(AtomTable->ExHandleTable,
- &ExEntry);
- if (Handle != NULL)
+ &ExEntry);
+ if (!Handle) return FALSE;
+
+ /* Calculate HandleIndex (by getting rid of the first two bits) */
+ HandleIndex = (USHORT)((ULONG_PTR)Handle >> 2);
+
+ /* Index must be less than 0xC000 */
+ if (HandleIndex >= 0xC000)
{
- HandleIndex = (USHORT)((ULONG_PTR)Handle >> 2);
- /* FIXME - Handle Indexes >= 0xC000 ?! */
- if ((ULONG_PTR)HandleIndex >> 2 < 0xC000)
- {
- Entry->HandleIndex = HandleIndex;
- Entry->Atom = 0xC000 + HandleIndex;
-
- return TRUE;
- }
- else
- ExDestroyHandle(AtomTable->ExHandleTable,
- Handle,
- NULL);
+ /* Destroy ex handle */
+ ExDestroyHandle(AtomTable->ExHandleTable,
+ Handle,
+ NULL);
+
+ /* Return failure */
+ return FALSE;
}
- return FALSE;
+ /* Initialize atom table entry */
+ Entry->HandleIndex = HandleIndex;
+ Entry->Atom = 0xC000 + HandleIndex;
+
+ /* Return success */
+ return TRUE;
}
PRTL_ATOM_TABLE_ENTRY