*/
#define PLACE_IN_SECTION(s) __attribute__((section (s)))
#ifdef __GNUC__
-#define INIT_FUNCTION PLACE_IN_SECTION("init")
+#define INIT_FUNCTION PLACE_IN_SECTION("INIT")
#define PAGE_LOCKED_FUNCTION PLACE_IN_SECTION("pagelk")
#define PAGE_UNLOCKED_FUNCTION PLACE_IN_SECTION("pagepo")
#else
#undef PsGetCurrentProcess
#define PsGetCurrentProcess _PsGetCurrentProcess
+#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))
+
//
// We are very lazy on ARM -- we just import intrinsics
// Question: Why wasn't this done for x86 too? (see fastintrlck.asm)
#define InterlockedOr _InterlockedOr
#define InterlockedAnd _InterlockedAnd
+//
+// Use inlined versions of fast/guarded mutex routines
+//
+#define ExEnterCriticalRegionAndAcquireFastMutexUnsafe _ExEnterCriticalRegionAndAcquireFastMutexUnsafe
+#define ExReleaseFastMutexUnsafeAndLeaveCriticalRegion _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion
+#define ExAcquireFastMutex _ExAcquireFastMutex
+#define ExReleaseFastMutex _ExReleaseFastMutex
+#define ExAcquireFastMutexUnsafe _ExAcquireFastMutexUnsafe
+#define ExReleaseFastMutexUnsafe _ExReleaseFastMutexUnsafe
+#define ExTryToAcquireFastMutex _ExTryToAcquireFastMutex
+
+#define KeInitializeGuardedMutex _KeInitializeGuardedMutex
+#define KeAcquireGuardedMutex _KeAcquireGuardedMutex
+#define KeReleaseGuardedMutex _KeReleaseGuardedMutex
+#define KeAcquireGuardedMutexUnsafe _KeAcquireGuardedMutexUnsafe
+#define KeReleaseGuardedMutexUnsafe _KeReleaseGuardedMutexUnsafe
+#define KeTryToAcquireGuardedMutex _KeTryToAcquireGuardedMutex
+
#include "ke.h"
-#ifdef _M_AMD64
-#include "amd64/mm.h"
-#else
-#include "i386/mm.h"
-#include "i386/v86m.h"
-#endif
#include "ob.h"
#include "mm.h"
#include "ex.h"
#include "../kdbg/kdb.h"
#endif
#include "dbgk.h"
+#include "spinlock.h"
#include "tag.h"
#include "test.h"
#include "inbv.h"
#include "hal.h"
#include "arch/intrin_i.h"
-ULONG (*FrLdrDbgPrint)(const char *Format, ...);
-
-#include <pshpack1.h>
-/*
- * Defines a descriptor as it appears in the processor tables
- */
-typedef struct __DESCRIPTOR
-{
- ULONG a;
- ULONG b;
-} IDT_DESCRIPTOR, GDT_DESCRIPTOR;
-
-#include <poppack.h>
-//extern GDT_DESCRIPTOR KiGdt[256];
-
-/*
- * Initalization functions (called once by main())
- */
-BOOLEAN NTAPI ObInit(VOID);
-BOOLEAN NTAPI CmInitSystem1(VOID);
-VOID NTAPI CmShutdownSystem(VOID);
-BOOLEAN NTAPI KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock);
-
-/* FIXME - RtlpCreateUnicodeString is obsolete and should be removed ASAP! */
-BOOLEAN FASTCALL
-RtlpCreateUnicodeString(
- IN OUT PUNICODE_STRING UniDest,
- IN PCWSTR Source,
- IN POOL_TYPE PoolType);
-
-VOID
-NTAPI
-RtlpLogException(IN PEXCEPTION_RECORD ExceptionRecord,
- IN PCONTEXT ContextRecord,
- IN PVOID ContextData,
- IN ULONG Size);
-
/*
* generic information class probing code
*/
#define IQS(TypeQuery, TypeSet, AlignmentQuery, AlignmentSet, Flags) \
{ sizeof(TypeQuery), sizeof(TypeSet), sizeof(AlignmentQuery), sizeof(AlignmentSet), Flags }
-#ifndef _M_AMD64
-FORCEINLINE
-#else
-static inline
-#endif
-NTSTATUS
-DefaultSetInfoBufferCheck(ULONG Class,
- const INFORMATION_CLASS_INFO *ClassList,
- ULONG ClassListEntries,
- PVOID Buffer,
- ULONG BufferLength,
- KPROCESSOR_MODE PreviousMode)
-{
- NTSTATUS Status = STATUS_SUCCESS;
-
- if (Class < ClassListEntries)
- {
- if (!(ClassList[Class].Flags & ICIF_SET))
- {
- Status = STATUS_INVALID_INFO_CLASS;
- }
- else if (ClassList[Class].RequiredSizeSET > 0 &&
- BufferLength != ClassList[Class].RequiredSizeSET)
- {
- if (!(ClassList[Class].Flags & ICIF_SET_SIZE_VARIABLE))
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- }
- }
-
- if (NT_SUCCESS(Status))
- {
- if (PreviousMode != KernelMode)
- {
- _SEH_TRY
- {
- ProbeForRead(Buffer,
- BufferLength,
- ClassList[Class].AlignmentSET);
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
- }
- }
- }
- else
- Status = STATUS_INVALID_INFO_CLASS;
-
- return Status;
-}
-
-#ifndef _M_AMD64
-FORCEINLINE
-#else
-static inline
-#endif
-NTSTATUS
-DefaultQueryInfoBufferCheck(ULONG Class,
- const INFORMATION_CLASS_INFO *ClassList,
- ULONG ClassListEntries,
- PVOID Buffer,
- ULONG BufferLength,
- PULONG ReturnLength,
- PULONG_PTR ReturnLengthLong,
- KPROCESSOR_MODE PreviousMode)
-{
- NTSTATUS Status = STATUS_SUCCESS;
-
- if (Class < ClassListEntries)
- {
- if (!(ClassList[Class].Flags & ICIF_QUERY))
- {
- Status = STATUS_INVALID_INFO_CLASS;
- }
- else if (ClassList[Class].RequiredSizeQUERY > 0 &&
- BufferLength != ClassList[Class].RequiredSizeQUERY)
- {
- if (!(ClassList[Class].Flags & ICIF_QUERY_SIZE_VARIABLE))
- {
- Status = STATUS_INFO_LENGTH_MISMATCH;
- }
- }
-
- if (NT_SUCCESS(Status))
- {
- if (PreviousMode != KernelMode)
- {
- _SEH_TRY
- {
- if (Buffer != NULL)
- {
- ProbeForWrite(Buffer,
- BufferLength,
- ClassList[Class].AlignmentQUERY);
- }
-
- if (ReturnLength != NULL)
- {
- ProbeForWriteUlong(ReturnLength);
- }
- if (ReturnLengthLong != NULL)
- {
- ProbeForWrite(ReturnLengthLong, sizeof(ULONG_PTR), sizeof(ULONG_PTR));
- }
- }
- _SEH_HANDLE
- {
- Status = _SEH_GetExceptionCode();
- }
- _SEH_END;
- }
- }
- }
- else
- Status = STATUS_INVALID_INFO_CLASS;
-
- return Status;
-}
-
/*
* Use IsPointerOffset to test whether a pointer should be interpreted as an offset
* or as a pointer
#endif
-#ifndef _WIN64
+#if defined (_M_IX86) || defined(_M_AMD64)
C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, SystemCall) == 0x300);
C_ASSERT(FIELD_OFFSET(KTHREAD, InitialStack) == KTHREAD_INITIAL_STACK);
C_ASSERT(FIELD_OFFSET(KTHREAD, Teb) == KTHREAD_TEB);
C_ASSERT(FIELD_OFFSET(KTHREAD, CallbackStack) == KTHREAD_CALLBACK_STACK);
C_ASSERT(FIELD_OFFSET(KTHREAD, ApcState.Process) == KTHREAD_APCSTATE_PROCESS);
C_ASSERT(FIELD_OFFSET(KPROCESS, DirectoryTableBase) == KPROCESS_DIRECTORY_TABLE_BASE);
-C_ASSERT(FIELD_OFFSET(KPCR, Tib.ExceptionList) == KPCR_EXCEPTION_LIST);
-C_ASSERT(FIELD_OFFSET(KPCR, Self) == KPCR_SELF);
#endif
#ifdef _M_IX86
+C_ASSERT(FIELD_OFFSET(KPCR, Tib.ExceptionList) == KPCR_EXCEPTION_LIST);
+C_ASSERT(FIELD_OFFSET(KPCR, Self) == KPCR_SELF);
C_ASSERT(FIELD_OFFSET(KPCR, IRR) == KPCR_IRR);
C_ASSERT(FIELD_OFFSET(KPCR, IDR) == KPCR_IDR);
C_ASSERT(FIELD_OFFSET(KPCR, Irql) == KPCR_IRQL);