*/
#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"
#include "ob.h"
#include "mm.h"
#include "hal.h"
#include "arch/intrin_i.h"
-ULONG (*FrLdrDbgPrint)(const char *Format, ...);
+extern ULONG (*FrLdrDbgPrint)(const char *Format, ...);
#include <pshpack1.h>
/*
#define IQS(TypeQuery, TypeSet, AlignmentQuery, AlignmentSet, Flags) \
{ sizeof(TypeQuery), sizeof(TypeSet), sizeof(AlignmentQuery), sizeof(AlignmentSet), Flags }
-<<<<<<< .working
-#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;
-}
-
-=======
->>>>>>> .merge-rechts.r37853
/*
* Use IsPointerOffset to test whether a pointer should be interpreted as an offset
* or as a pointer
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);