From 19540dcad57e7a5f803e08a4e464e17e810b588b Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 23 Jul 2010 23:30:00 +0000 Subject: [PATCH] [NTOSKRNL] - Add KiGetLinkedTrapFrame for amd64 - Add MiAddressToPti - Fix MmCreateProcessAddressSpace, MmInitializeHandBuiltProcess prototype (ULONG -> ULONG_PTR) - #if out some C_ASSERTs for other architectures than x86 - #define InitializeSListHead to RtlInitializeSListHead on amd64 - Don't implement MiSyncARM3WithROS on amd64 - Implement RtlPcToFileHeader, RtlpGetStackLimits svn path=/trunk/; revision=48219 --- reactos/ntoskrnl/include/internal/amd64/ke.h | 3 ++ reactos/ntoskrnl/include/internal/amd64/mm.h | 11 ++++++ reactos/ntoskrnl/include/internal/mm.h | 4 +-- reactos/ntoskrnl/include/internal/ntoskrnl.h | 2 +- reactos/ntoskrnl/include/internal/rtl.h | 4 +++ reactos/ntoskrnl/mm/ARM3/mminit.c | 2 ++ reactos/ntoskrnl/rtl/libsupp.c | 37 ++++++++++++++++++++ 7 files changed, 60 insertions(+), 3 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/amd64/ke.h b/reactos/ntoskrnl/include/internal/amd64/ke.h index deab4f4ff84..fc4fe24b494 100644 --- a/reactos/ntoskrnl/include/internal/amd64/ke.h +++ b/reactos/ntoskrnl/include/internal/amd64/ke.h @@ -96,6 +96,9 @@ extern ULONG KeI386CpuStep; #define KeGetTrapFramePc(TrapFrame) \ ((TrapFrame)->Rip) +#define KiGetLinkedTrapFrame(x) \ + (PKTRAP_FRAME)((x)->Rdx) + #define KeGetContextReturnRegister(Context) \ ((Context)->Rax) diff --git a/reactos/ntoskrnl/include/internal/amd64/mm.h b/reactos/ntoskrnl/include/internal/amd64/mm.h index f0d43426b98..889c43e9684 100644 --- a/reactos/ntoskrnl/include/internal/amd64/mm.h +++ b/reactos/ntoskrnl/include/internal/amd64/mm.h @@ -102,6 +102,17 @@ _MiAddressToPte(PVOID Address) } #define MiAddressToPte(x) _MiAddressToPte((PVOID)(x)) +ULONG +FORCEINLINE +MiAddressToPti(PVOID Address) +{ + ULONG64 Pti = (ULONG64)Address >> PTI_SHIFT; + Pti &= PTI_MASK_AMD64; + return Pti; +} + +#define MiAddressToPteOffset(x) MiAddressToPti(x) + /* Convert a PTE into a corresponding address */ PVOID FORCEINLINE diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index f74a150e9d7..a7154de564d 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -1407,14 +1407,14 @@ NTAPI MmCreateProcessAddressSpace( IN ULONG MinWs, IN PEPROCESS Dest, - IN PULONG DirectoryTableBase + IN PULONG_PTR DirectoryTableBase ); NTSTATUS NTAPI MmInitializeHandBuiltProcess( IN PEPROCESS Process, - IN PULONG DirectoryTableBase + IN PULONG_PTR DirectoryTableBase ); diff --git a/reactos/ntoskrnl/include/internal/ntoskrnl.h b/reactos/ntoskrnl/include/internal/ntoskrnl.h index 41d4843f30e..7aa74ef0e51 100644 --- a/reactos/ntoskrnl/include/internal/ntoskrnl.h +++ b/reactos/ntoskrnl/include/internal/ntoskrnl.h @@ -145,7 +145,7 @@ typedef struct _INFORMATION_CLASS_INFO #endif -#if defined (_M_IX86) || defined(_M_AMD64) +#ifdef _M_IX86 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); diff --git a/reactos/ntoskrnl/include/internal/rtl.h b/reactos/ntoskrnl/include/internal/rtl.h index 18489044fc9..4a2f0b4e541 100644 --- a/reactos/ntoskrnl/include/internal/rtl.h +++ b/reactos/ntoskrnl/include/internal/rtl.h @@ -1,5 +1,9 @@ #pragma once +#ifdef _WIN64 +#define InitializeSListHead RtlInitializeSListHead +#endif + NTSTATUS NTAPI RtlQueryAtomListInAtomTable( diff --git a/reactos/ntoskrnl/mm/ARM3/mminit.c b/reactos/ntoskrnl/mm/ARM3/mminit.c index f595ece9a0f..28358f1b53e 100644 --- a/reactos/ntoskrnl/mm/ARM3/mminit.c +++ b/reactos/ntoskrnl/mm/ARM3/mminit.c @@ -350,6 +350,7 @@ SIZE_T MmTotalCommitLimitMaximum; /* PRIVATE FUNCTIONS **********************************************************/ +#ifndef _M_AMD64 // // In Bavaria, this is probably a hate crime // @@ -372,6 +373,7 @@ MiSyncARM3WithROS(IN PVOID AddressStart, Pde++; } } +#endif PFN_NUMBER NTAPI diff --git a/reactos/ntoskrnl/rtl/libsupp.c b/reactos/ntoskrnl/rtl/libsupp.c index cbff1792b2c..aba04f1042e 100644 --- a/reactos/ntoskrnl/rtl/libsupp.c +++ b/reactos/ntoskrnl/rtl/libsupp.c @@ -28,6 +28,30 @@ SIZE_T RtlpAllocDeallocQueryBufferSize = 128; /* FUNCTIONS *****************************************************************/ +PVOID +NTAPI +RtlPcToFileHeader( + IN PVOID PcValue, + OUT PVOID *BaseOfImage) +{ + PLDR_DATA_TABLE_ENTRY LdrEntry; + BOOLEAN InSystem; + + /* Get the base for this file */ + if ((ULONG_PTR)PcValue > (ULONG_PTR)MmHighestUserAddress) + { + /* We are in kernel */ + *BaseOfImage = KiPcToFileHeader(PcValue, &LdrEntry, FALSE, &InSystem); + } + else + { + /* We are in user land */ + *BaseOfImage = KiRosPcToUserFileHeader(PcValue, &LdrEntry); + } + + return *BaseOfImage; +} + VOID NTAPI RtlInitializeRangeListPackage(VOID) @@ -417,6 +441,19 @@ RtlWalkFrameChain(OUT PVOID *Callers, #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