[NTOSKRNL]

- Fix a bug in CmpSetSystemValues, where an uninitialized handle would be closed in the failure path.
- Add a hack on top of the MI_GET_ROS_DATA(x) hack so that we can squeeze a pointer into a 32 bit field.
Make MmInitializeProcessAddressSpace amd64 ready and use a portable way to determine the page table base pfn in MiInitializeWorkingSetList
- Make MmProbeAndLockPages ready for 3 and 4 level page tables
add MiIsPteOnP*eBoundary macros - use  these in MmProbeAndLockPages
- Raise IRQL to SYNCH_LEVEL not DISPATCH_LEVEL in KiAcquireDispatcherLock
- Add MiNonPagedSystemSize for all architectures
- Fix amd64 definition of KERNEL_HANDLE_FLAG
- Fix definition of PrototypePte
- Fix KiGetLinkedTrapFrame()
- Make MmProtectTpPteMask 64 bit wide 
- Fix definition of MI_PTE_LOOKUP_NEEDED for amd64
- Impllement KiSendEOI() to be able to send an EOI from C code.
- Fix some MSVC/amd64 warnings

svn path=/trunk/; revision=55423
This commit is contained in:
Timo Kreuzer 2012-02-04 23:08:20 +00:00
parent cb837e18a1
commit d7bdbf2152
15 changed files with 195 additions and 119 deletions

View file

@ -333,7 +333,7 @@ CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName, ValueName = { 0, 0, NULL }; UNICODE_STRING KeyName, ValueName = { 0, 0, NULL };
HANDLE KeyHandle; HANDLE KeyHandle = NULL;
NTSTATUS Status; NTSTATUS Status;
ASSERT(LoaderBlock != NULL); ASSERT(LoaderBlock != NULL);
@ -374,7 +374,7 @@ Quickie:
RtlFreeUnicodeString(&ValueName); RtlFreeUnicodeString(&ValueName);
/* Close the key and return */ /* Close the key and return */
NtClose(KeyHandle); if (KeyHandle) NtClose(KeyHandle);
/* Return the status */ /* Return the status */
return (ExpInTextModeSetup ? STATUS_SUCCESS : Status); return (ExpInTextModeSetup ? STATUS_SUCCESS : Status);
@ -1098,7 +1098,8 @@ CmpLoadHiveThread(IN PVOID StartContext)
{ {
WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH], ConfigPath[MAX_PATH]; WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH], ConfigPath[MAX_PATH];
UNICODE_STRING TempName, FileName, RegName; UNICODE_STRING TempName, FileName, RegName;
ULONG FileStart, i, ErrorResponse, WorkerCount, Length; ULONG i, ErrorResponse, WorkerCount, Length;
USHORT FileStart;
//ULONG RegStart; //ULONG RegStart;
ULONG PrimaryDisposition, SecondaryDisposition, ClusterSize; ULONG PrimaryDisposition, SecondaryDisposition, ClusterSize;
PCMHIVE CmHive; PCMHIVE CmHive;
@ -1259,7 +1260,8 @@ CmpInitializeHiveList(IN USHORT Flag)
UNICODE_STRING TempName, FileName, RegName; UNICODE_STRING TempName, FileName, RegName;
HANDLE Thread; HANDLE Thread;
NTSTATUS Status; NTSTATUS Status;
ULONG RegStart, i; ULONG i;
USHORT RegStart;
PSECURITY_DESCRIPTOR SecurityDescriptor; PSECURITY_DESCRIPTOR SecurityDescriptor;
PAGED_CODE(); PAGED_CODE();
@ -1611,25 +1613,25 @@ CmpFreeDriverList(IN PHHIVE Hive,
PLIST_ENTRY NextEntry, OldEntry; PLIST_ENTRY NextEntry, OldEntry;
PBOOT_DRIVER_NODE DriverNode; PBOOT_DRIVER_NODE DriverNode;
PAGED_CODE(); PAGED_CODE();
/* Parse the current list */ /* Parse the current list */
NextEntry = DriverList->Flink; NextEntry = DriverList->Flink;
while (NextEntry != DriverList) while (NextEntry != DriverList)
{ {
/* Get the driver node */ /* Get the driver node */
DriverNode = CONTAINING_RECORD(NextEntry, BOOT_DRIVER_NODE, ListEntry.Link); DriverNode = CONTAINING_RECORD(NextEntry, BOOT_DRIVER_NODE, ListEntry.Link);
/* Get the next entry now, since we're going to free it later */ /* Get the next entry now, since we're going to free it later */
OldEntry = NextEntry; OldEntry = NextEntry;
NextEntry = NextEntry->Flink; NextEntry = NextEntry->Flink;
/* Was there a name? */ /* Was there a name? */
if (DriverNode->Name.Buffer) if (DriverNode->Name.Buffer)
{ {
/* Free it */ /* Free it */
CmpFree(DriverNode->Name.Buffer, DriverNode->Name.Length); CmpFree(DriverNode->Name.Buffer, DriverNode->Name.Length);
} }
/* Was there a registry path? */ /* Was there a registry path? */
if (DriverNode->ListEntry.RegistryPath.Buffer) if (DriverNode->ListEntry.RegistryPath.Buffer)
{ {
@ -1637,7 +1639,7 @@ CmpFreeDriverList(IN PHHIVE Hive,
CmpFree(DriverNode->ListEntry.RegistryPath.Buffer, CmpFree(DriverNode->ListEntry.RegistryPath.Buffer,
DriverNode->ListEntry.RegistryPath.MaximumLength); DriverNode->ListEntry.RegistryPath.MaximumLength);
} }
/* Was there a file path? */ /* Was there a file path? */
if (DriverNode->ListEntry.FilePath.Buffer) if (DriverNode->ListEntry.FilePath.Buffer)
{ {
@ -1645,7 +1647,7 @@ CmpFreeDriverList(IN PHHIVE Hive,
CmpFree(DriverNode->ListEntry.FilePath.Buffer, CmpFree(DriverNode->ListEntry.FilePath.Buffer,
DriverNode->ListEntry.FilePath.MaximumLength); DriverNode->ListEntry.FilePath.MaximumLength);
} }
/* Now free the node, and move on */ /* Now free the node, and move on */
CmpFree(OldEntry, sizeof(BOOT_DRIVER_NODE)); CmpFree(OldEntry, sizeof(BOOT_DRIVER_NODE));
} }
@ -1673,7 +1675,7 @@ CmGetSystemDriverList(VOID)
/* Initialize the driver list */ /* Initialize the driver list */
InitializeListHead(&DriverList); InitializeListHead(&DriverList);
/* Open the system hive key */ /* Open the system hive key */
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\System"); RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\System");
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
@ -1683,7 +1685,7 @@ CmGetSystemDriverList(VOID)
NULL); NULL);
Status = NtOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes); Status = NtOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes);
if (!NT_SUCCESS(Status)) return NULL; if (!NT_SUCCESS(Status)) return NULL;
/* Reference the key object to get the root hive/cell to access directly */ /* Reference the key object to get the root hive/cell to access directly */
Status = ObReferenceObjectByHandle(KeyHandle, Status = ObReferenceObjectByHandle(KeyHandle,
KEY_QUERY_VALUE, KEY_QUERY_VALUE,
@ -1697,38 +1699,38 @@ CmGetSystemDriverList(VOID)
NtClose(KeyHandle); NtClose(KeyHandle);
return NULL; return NULL;
} }
/* Do all this under the registry lock */ /* Do all this under the registry lock */
CmpLockRegistryExclusive(); CmpLockRegistryExclusive();
/* Get the hive and key cell */ /* Get the hive and key cell */
Hive = KeyBody->KeyControlBlock->KeyHive; Hive = KeyBody->KeyControlBlock->KeyHive;
RootCell = KeyBody->KeyControlBlock->KeyCell; RootCell = KeyBody->KeyControlBlock->KeyCell;
/* Open the current control set key */ /* Open the current control set key */
RtlInitUnicodeString(&KeyName, L"Current"); RtlInitUnicodeString(&KeyName, L"Current");
ControlCell = CmpFindControlSet(Hive, RootCell, &KeyName, &AutoSelect); ControlCell = CmpFindControlSet(Hive, RootCell, &KeyName, &AutoSelect);
if (ControlCell == HCELL_NIL) goto EndPath; if (ControlCell == HCELL_NIL) goto EndPath;
/* Find all system drivers */ /* Find all system drivers */
Success = CmpFindDrivers(Hive, ControlCell, SystemLoad, NULL, &DriverList); Success = CmpFindDrivers(Hive, ControlCell, SystemLoad, NULL, &DriverList);
if (!Success) goto EndPath; if (!Success) goto EndPath;
/* Sort by group/tag */ /* Sort by group/tag */
if (!CmpSortDriverList(Hive, ControlCell, &DriverList)) goto EndPath; if (!CmpSortDriverList(Hive, ControlCell, &DriverList)) goto EndPath;
/* Remove circular dependencies (cycles) and sort */ /* Remove circular dependencies (cycles) and sort */
if (!CmpResolveDriverDependencies(&DriverList)) goto EndPath; if (!CmpResolveDriverDependencies(&DriverList)) goto EndPath;
/* Loop the list to count drivers */ /* Loop the list to count drivers */
for (i = 0, NextEntry = DriverList.Flink; for (i = 0, NextEntry = DriverList.Flink;
NextEntry != &DriverList; NextEntry != &DriverList;
i++, NextEntry = NextEntry->Flink); i++, NextEntry = NextEntry->Flink);
/* Allocate the array */ /* Allocate the array */
ServicePath = ExAllocatePool(NonPagedPool, (i + 1) * sizeof(PUNICODE_STRING)); ServicePath = ExAllocatePool(NonPagedPool, (i + 1) * sizeof(PUNICODE_STRING));
if (!ServicePath) KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 2, 1, 0, 0); if (!ServicePath) KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 2, 1, 0, 0);
/* Loop the driver list */ /* Loop the driver list */
for (i = 0, NextEntry = DriverList.Flink; for (i = 0, NextEntry = DriverList.Flink;
NextEntry != &DriverList; NextEntry != &DriverList;
@ -1743,17 +1745,17 @@ CmGetSystemDriverList(VOID)
&DriverEntry->RegistryPath, &DriverEntry->RegistryPath,
ServicePath[i]); ServicePath[i]);
} }
/* Terminate the list */ /* Terminate the list */
ServicePath[i] = NULL; ServicePath[i] = NULL;
EndPath: EndPath:
/* Free the driver list if we had one */ /* Free the driver list if we had one */
if (!IsListEmpty(&DriverList)) CmpFreeDriverList(Hive, &DriverList); if (!IsListEmpty(&DriverList)) CmpFreeDriverList(Hive, &DriverList);
/* Unlock the registry */ /* Unlock the registry */
CmpUnlockRegistry(); CmpUnlockRegistry();
/* Close the key handle and dereference the object, then return the path */ /* Close the key handle and dereference the object, then return the path */
ObDereferenceObject(KeyBody); ObDereferenceObject(KeyBody);
NtClose(KeyHandle); NtClose(KeyHandle);

View file

@ -5,7 +5,9 @@
#ifdef _M_IX86 #ifdef _M_IX86
EXTERN _KiSystemService:PROC EXTERN _KiSystemService:PROC
#elif defined(_M_AMD64) #elif defined(_M_AMD64)
#include <ksamd64.inc>
EXTERN KiSystemService:PROC EXTERN KiSystemService:PROC
EXTERN KiZwSystemService:PROC
#endif #endif
.code .code

View file

@ -56,6 +56,8 @@
#define AMD64_TSS 9 #define AMD64_TSS 9
#define APIC_EOI_REGISTER 0xFFFFFFFFFFFE00B0ULL
#ifndef __ASM__ #ifndef __ASM__
#include "intrin_i.h" #include "intrin_i.h"
@ -68,6 +70,17 @@ typedef struct _KIDT_INIT
PVOID ServiceRoutine; PVOID ServiceRoutine;
} KIDT_INIT, *PKIDT_INIT; } KIDT_INIT, *PKIDT_INIT;
#include <pshpack1.h>
typedef struct _KI_INTERRUPT_DISPATCH_ENTRY
{
UCHAR _Op_nop;
UCHAR _Op_push;
UCHAR _Vector;
UCHAR _Op_jmp;
ULONG RelativeAddress;
} KI_INTERRUPT_DISPATCH_ENTRY, *PKI_INTERRUPT_DISPATCH_ENTRY;
#include <poppack.h>
extern ULONG Ke386CacheAlignment; extern ULONG Ke386CacheAlignment;
extern ULONG KeI386NpxPresent; extern ULONG KeI386NpxPresent;
extern ULONG KeI386XMMIPresent; extern ULONG KeI386XMMIPresent;
@ -95,7 +108,7 @@ extern ULONG KeI386CpuStep;
((TrapFrame)->Rip) ((TrapFrame)->Rip)
#define KiGetLinkedTrapFrame(x) \ #define KiGetLinkedTrapFrame(x) \
(PKTRAP_FRAME)((x)->Rdx) (PKTRAP_FRAME)((x)->TrapFrame)
#define KeGetContextReturnRegister(Context) \ #define KeGetContextReturnRegister(Context) \
((Context)->Rax) ((Context)->Rax)
@ -233,6 +246,14 @@ KeQueryInterruptHandler(IN ULONG Vector)
(ULONG64)Idt->OffsetLow); (ULONG64)Idt->OffsetLow);
} }
VOID
FORCEINLINE
KiSendEOI()
{
/* Write 0 to the apic EOI register */
*((volatile ULONG*)APIC_EOI_REGISTER) = 0;
}
VOID VOID
FORCEINLINE FORCEINLINE
KiEndInterrupt(IN KIRQL Irql, KiEndInterrupt(IN KIRQL Irql,
@ -240,6 +261,7 @@ KiEndInterrupt(IN KIRQL Irql,
{ {
/* Make sure this is from the clock handler */ /* Make sure this is from the clock handler */
ASSERT(TrapFrame->ErrorCode == 0xc10c4); ASSERT(TrapFrame->ErrorCode == 0xc10c4);
//KeLowerIrql(Irql);
} }
BOOLEAN BOOLEAN

View file

@ -127,8 +127,8 @@ FORCEINLINE
KIRQL KIRQL
KiAcquireDispatcherLock(VOID) KiAcquireDispatcherLock(VOID)
{ {
/* Raise to DPC level */ /* Raise to synch level */
return KeRaiseIrqlToDpcLevel(); return KfRaiseIrql(SYNCH_LEVEL);
} }
FORCEINLINE FORCEINLINE
@ -303,7 +303,7 @@ KiAcquireDispatcherObject(IN DISPATCHER_HEADER* Object)
/* Let the CPU know that this is a loop */ /* Let the CPU know that this is a loop */
YieldProcessor(); YieldProcessor();
} }
/* Try acquiring the lock now */ /* Try acquiring the lock now */
} while (InterlockedCompareExchange(&Object->Lock, } while (InterlockedCompareExchange(&Object->Lock,
@ -902,7 +902,7 @@ KiRemoveEntryTimer(IN PKTIMER Timer)
{ {
ULONG Hand; ULONG Hand;
PKTIMER_TABLE_ENTRY TableEntry; PKTIMER_TABLE_ENTRY TableEntry;
/* Remove the timer from the timer list and check if it's empty */ /* Remove the timer from the timer list and check if it's empty */
Hand = Timer->Header.Hand; Hand = Timer->Header.Hand;
if (RemoveEntryList(&Timer->TimerListEntry)) if (RemoveEntryList(&Timer->TimerListEntry))
@ -962,17 +962,17 @@ KiComputeDueTime(IN PKTIMER Timer,
OUT PULONG Hand) OUT PULONG Hand)
{ {
LARGE_INTEGER InterruptTime, SystemTime, DifferenceTime; LARGE_INTEGER InterruptTime, SystemTime, DifferenceTime;
/* Convert to relative time if needed */ /* Convert to relative time if needed */
Timer->Header.Absolute = FALSE; Timer->Header.Absolute = FALSE;
if (DueTime.HighPart >= 0) if (DueTime.HighPart >= 0)
{ {
/* Get System Time */ /* Get System Time */
KeQuerySystemTime(&SystemTime); KeQuerySystemTime(&SystemTime);
/* Do the conversion */ /* Do the conversion */
DifferenceTime.QuadPart = SystemTime.QuadPart - DueTime.QuadPart; DifferenceTime.QuadPart = SystemTime.QuadPart - DueTime.QuadPart;
/* Make sure it hasn't already expired */ /* Make sure it hasn't already expired */
Timer->Header.Absolute = TRUE; Timer->Header.Absolute = TRUE;
if (DifferenceTime.HighPart >= 0) if (DifferenceTime.HighPart >= 0)
@ -984,17 +984,17 @@ KiComputeDueTime(IN PKTIMER Timer,
*Hand = 0; *Hand = 0;
return FALSE; return FALSE;
} }
/* Set the time as Absolute */ /* Set the time as Absolute */
DueTime = DifferenceTime; DueTime = DifferenceTime;
} }
/* Get the Interrupt Time */ /* Get the Interrupt Time */
InterruptTime.QuadPart = KeQueryInterruptTime(); InterruptTime.QuadPart = KeQueryInterruptTime();
/* Recalculate due time */ /* Recalculate due time */
Timer->DueTime.QuadPart = InterruptTime.QuadPart - DueTime.QuadPart; Timer->DueTime.QuadPart = InterruptTime.QuadPart - DueTime.QuadPart;
/* Get the handle */ /* Get the handle */
*Hand = KiComputeTimerTableIndex(Timer->DueTime.QuadPart); *Hand = KiComputeTimerTableIndex(Timer->DueTime.QuadPart);
Timer->Header.Hand = (UCHAR)*Hand; Timer->Header.Hand = (UCHAR)*Hand;
@ -1515,7 +1515,7 @@ _KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
GuardedMutex->Count = GM_LOCK_BIT; GuardedMutex->Count = GM_LOCK_BIT;
GuardedMutex->Owner = NULL; GuardedMutex->Owner = NULL;
GuardedMutex->Contention = 0; GuardedMutex->Contention = 0;
/* Initialize the Wait Gate */ /* Initialize the Wait Gate */
KeInitializeGate(&GuardedMutex->Gate); KeInitializeGate(&GuardedMutex->Gate);
} }
@ -1525,21 +1525,21 @@ VOID
_KeAcquireGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex) _KeAcquireGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
{ {
PKTHREAD Thread = KeGetCurrentThread(); PKTHREAD Thread = KeGetCurrentThread();
/* Sanity checks */ /* Sanity checks */
ASSERT((KeGetCurrentIrql() == APC_LEVEL) || ASSERT((KeGetCurrentIrql() == APC_LEVEL) ||
(Thread->SpecialApcDisable < 0) || (Thread->SpecialApcDisable < 0) ||
(Thread->Teb == NULL) || (Thread->Teb == NULL) ||
(Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
ASSERT(GuardedMutex->Owner != Thread); ASSERT(GuardedMutex->Owner != Thread);
/* Remove the lock */ /* Remove the lock */
if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V)) if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
{ {
/* The Guarded Mutex was already locked, enter contented case */ /* The Guarded Mutex was already locked, enter contented case */
KiAcquireGuardedMutex(GuardedMutex); KiAcquireGuardedMutex(GuardedMutex);
} }
/* Set the Owner */ /* Set the Owner */
GuardedMutex->Owner = Thread; GuardedMutex->Owner = Thread;
} }
@ -1549,21 +1549,21 @@ VOID
_KeReleaseGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex) _KeReleaseGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
{ {
LONG OldValue, NewValue; LONG OldValue, NewValue;
/* Sanity checks */ /* Sanity checks */
ASSERT((KeGetCurrentIrql() == APC_LEVEL) || ASSERT((KeGetCurrentIrql() == APC_LEVEL) ||
(KeGetCurrentThread()->SpecialApcDisable < 0) || (KeGetCurrentThread()->SpecialApcDisable < 0) ||
(KeGetCurrentThread()->Teb == NULL) || (KeGetCurrentThread()->Teb == NULL) ||
(KeGetCurrentThread()->Teb >= (PTEB)MM_SYSTEM_RANGE_START)); (KeGetCurrentThread()->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
ASSERT(GuardedMutex->Owner == KeGetCurrentThread()); ASSERT(GuardedMutex->Owner == KeGetCurrentThread());
/* Destroy the Owner */ /* Destroy the Owner */
GuardedMutex->Owner = NULL; GuardedMutex->Owner = NULL;
/* Add the Lock Bit */ /* Add the Lock Bit */
OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT); OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT);
ASSERT((OldValue & GM_LOCK_BIT) == 0); ASSERT((OldValue & GM_LOCK_BIT) == 0);
/* Check if it was already locked, but not woken */ /* Check if it was already locked, but not woken */
if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN)) if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN))
{ {
@ -1573,7 +1573,7 @@ _KeReleaseGuardedMutexUnsafe(IN OUT PKGUARDED_MUTEX GuardedMutex)
/* The mutex will be woken, minus one waiter */ /* The mutex will be woken, minus one waiter */
NewValue = OldValue + GM_LOCK_WAITER_WOKEN - NewValue = OldValue + GM_LOCK_WAITER_WOKEN -
GM_LOCK_WAITER_INC; GM_LOCK_WAITER_INC;
/* Remove the Woken bit */ /* Remove the Woken bit */
if (InterlockedCompareExchange(&GuardedMutex->Count, if (InterlockedCompareExchange(&GuardedMutex->Count,
NewValue, NewValue,
@ -1590,21 +1590,21 @@ VOID
_KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex) _KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
{ {
PKTHREAD Thread = KeGetCurrentThread(); PKTHREAD Thread = KeGetCurrentThread();
/* Sanity checks */ /* Sanity checks */
ASSERT(KeGetCurrentIrql() <= APC_LEVEL); ASSERT(KeGetCurrentIrql() <= APC_LEVEL);
ASSERT(GuardedMutex->Owner != Thread); ASSERT(GuardedMutex->Owner != Thread);
/* Disable Special APCs */ /* Disable Special APCs */
KeEnterGuardedRegion(); KeEnterGuardedRegion();
/* Remove the lock */ /* Remove the lock */
if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V)) if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
{ {
/* The Guarded Mutex was already locked, enter contented case */ /* The Guarded Mutex was already locked, enter contented case */
KiAcquireGuardedMutex(GuardedMutex); KiAcquireGuardedMutex(GuardedMutex);
} }
/* Set the Owner and Special APC Disable state */ /* Set the Owner and Special APC Disable state */
GuardedMutex->Owner = Thread; GuardedMutex->Owner = Thread;
GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable; GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable;
@ -1615,20 +1615,20 @@ VOID
_KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) _KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
{ {
LONG OldValue, NewValue; LONG OldValue, NewValue;
/* Sanity checks */ /* Sanity checks */
ASSERT(KeGetCurrentIrql() <= APC_LEVEL); ASSERT(KeGetCurrentIrql() <= APC_LEVEL);
ASSERT(GuardedMutex->Owner == KeGetCurrentThread()); ASSERT(GuardedMutex->Owner == KeGetCurrentThread());
ASSERT(KeGetCurrentThread()->SpecialApcDisable == ASSERT(KeGetCurrentThread()->SpecialApcDisable ==
GuardedMutex->SpecialApcDisable); GuardedMutex->SpecialApcDisable);
/* Destroy the Owner */ /* Destroy the Owner */
GuardedMutex->Owner = NULL; GuardedMutex->Owner = NULL;
/* Add the Lock Bit */ /* Add the Lock Bit */
OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT); OldValue = InterlockedExchangeAdd(&GuardedMutex->Count, GM_LOCK_BIT);
ASSERT((OldValue & GM_LOCK_BIT) == 0); ASSERT((OldValue & GM_LOCK_BIT) == 0);
/* Check if it was already locked, but not woken */ /* Check if it was already locked, but not woken */
if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN)) if ((OldValue) && !(OldValue & GM_LOCK_WAITER_WOKEN))
{ {
@ -1638,7 +1638,7 @@ _KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
/* The mutex will be woken, minus one waiter */ /* The mutex will be woken, minus one waiter */
NewValue = OldValue + GM_LOCK_WAITER_WOKEN - NewValue = OldValue + GM_LOCK_WAITER_WOKEN -
GM_LOCK_WAITER_INC; GM_LOCK_WAITER_INC;
/* Remove the Woken bit */ /* Remove the Woken bit */
if (InterlockedCompareExchange(&GuardedMutex->Count, if (InterlockedCompareExchange(&GuardedMutex->Count,
NewValue, NewValue,
@ -1648,7 +1648,7 @@ _KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
KeSignalGateBoostPriority(&GuardedMutex->Gate); KeSignalGateBoostPriority(&GuardedMutex->Gate);
} }
} }
/* Re-enable APCs */ /* Re-enable APCs */
KeLeaveGuardedRegion(); KeLeaveGuardedRegion();
} }
@ -1658,21 +1658,21 @@ BOOLEAN
_KeTryToAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) _KeTryToAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
{ {
PKTHREAD Thread = KeGetCurrentThread(); PKTHREAD Thread = KeGetCurrentThread();
/* Block APCs */ /* Block APCs */
KeEnterGuardedRegion(); KeEnterGuardedRegion();
/* Remove the lock */ /* Remove the lock */
if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V)) if (!InterlockedBitTestAndReset(&GuardedMutex->Count, GM_LOCK_BIT_V))
{ {
/* Re-enable APCs */ /* Re-enable APCs */
KeLeaveGuardedRegion(); KeLeaveGuardedRegion();
YieldProcessor(); YieldProcessor();
/* Return failure */ /* Return failure */
return FALSE; return FALSE;
} }
/* Set the Owner and APC State */ /* Set the Owner and APC State */
GuardedMutex->Owner = Thread; GuardedMutex->Owner = Thread;
GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable; GuardedMutex->SpecialApcDisable = Thread->SpecialApcDisable;

View file

@ -56,8 +56,11 @@
// //
// Identifies a Kernel Handle // Identifies a Kernel Handle
// //
#define KERNEL_HANDLE_FLAG \ #ifdef _WIN64
((ULONG_PTR)1 << ((sizeof(HANDLE) * 8) - 1)) #define KERNEL_HANDLE_FLAG 0xFFFFFFFF80000000ULL
#else
#define KERNEL_HANDLE_FLAG 0x80000000
#endif
#define ObIsKernelHandle(Handle, ProcessorMode) \ #define ObIsKernelHandle(Handle, ProcessorMode) \
(((ULONG_PTR)(Handle) & KERNEL_HANDLE_FLAG) && \ (((ULONG_PTR)(Handle) & KERNEL_HANDLE_FLAG) && \
((ProcessorMode) == KernelMode)) ((ProcessorMode) == KernelMode))

View file

@ -1650,7 +1650,8 @@ IoGetRequestorSessionId(IN PIRP Irp,
/* Return the session */ /* Return the session */
if ((Process = IoGetRequestorProcess(Irp))) if ((Process = IoGetRequestorProcess(Irp)))
{ {
*pSessionId = Process->Session; // FIXME: broken
*pSessionId = PtrToUlong(Process->Session);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -281,8 +281,9 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
// nonpaged pool expansion (above) and the system PTEs. Note that it is // nonpaged pool expansion (above) and the system PTEs. Note that it is
// then aligned to a PDE boundary (4MB). // then aligned to a PDE boundary (4MB).
// //
MiNonPagedSystemSize = (MmNumberOfSystemPtes + 1) * PAGE_SIZE;
MmNonPagedSystemStart = (PVOID)((ULONG_PTR)MmNonPagedPoolStart - MmNonPagedSystemStart = (PVOID)((ULONG_PTR)MmNonPagedPoolStart -
(MmNumberOfSystemPtes + 1) * PAGE_SIZE); MiNonPagedSystemSize);
MmNonPagedSystemStart = (PVOID)((ULONG_PTR)MmNonPagedSystemStart & MmNonPagedSystemStart = (PVOID)((ULONG_PTR)MmNonPagedSystemStart &
~(PDE_MAPPED_VA - 1)); ~(PDE_MAPPED_VA - 1));

View file

@ -593,6 +593,12 @@ MmProbeAndLockPages(IN PMDL Mdl,
NTSTATUS ProbeStatus; NTSTATUS ProbeStatus;
PMMPTE PointerPte, LastPte; PMMPTE PointerPte, LastPte;
PMMPDE PointerPde; PMMPDE PointerPde;
#if (_MI_PAGING_LEVELS >= 3)
PMMPDE PointerPpe;
#endif
#if (_MI_PAGING_LEVELS == 4)
PMMPDE PointerPxe;
#endif
PFN_NUMBER PageFrameIndex; PFN_NUMBER PageFrameIndex;
BOOLEAN UsePfnLock; BOOLEAN UsePfnLock;
KIRQL OldIrql; KIRQL OldIrql;
@ -741,8 +747,10 @@ MmProbeAndLockPages(IN PMDL Mdl,
PointerPte = MiAddressToPte(StartAddress); PointerPte = MiAddressToPte(StartAddress);
PointerPde = MiAddressToPde(StartAddress); PointerPde = MiAddressToPde(StartAddress);
#if (_MI_PAGING_LEVELS >= 3) #if (_MI_PAGING_LEVELS >= 3)
DPRINT1("PAE/x64 Not Implemented\n"); PointerPpe = MiAddressToPpe(StartAddress);
ASSERT(FALSE); #endif
#if (_MI_PAGING_LEVELS == 4)
PointerPxe = MiAddressToPxe(StartAddress);
#endif #endif
// //
@ -776,7 +784,7 @@ MmProbeAndLockPages(IN PMDL Mdl,
// //
// Check if this came from kernel mode // Check if this came from kernel mode
// //
if (Base >= MM_HIGHEST_USER_ADDRESS) if (Base > MM_HIGHEST_USER_ADDRESS)
{ {
// //
// We should not have a process // We should not have a process
@ -834,11 +842,14 @@ MmProbeAndLockPages(IN PMDL Mdl,
// Assume failure and check for non-mapped pages // Assume failure and check for non-mapped pages
// //
*MdlPages = LIST_HEAD; *MdlPages = LIST_HEAD;
#if (_MI_PAGING_LEVELS >= 3) while (
/* Should be checking the PPE and PXE */ #if (_MI_PAGING_LEVELS == 4)
ASSERT(FALSE); (PointerPxe->u.Hard.Valid == 0) ||
#endif #endif
while ((PointerPde->u.Hard.Valid == 0) || #if (_MI_PAGING_LEVELS >= 3)
(PointerPpe->u.Hard.Valid == 0) ||
#endif
(PointerPde->u.Hard.Valid == 0) ||
(PointerPte->u.Hard.Valid == 0)) (PointerPte->u.Hard.Valid == 0))
{ {
// //
@ -1042,7 +1053,14 @@ MmProbeAndLockPages(IN PMDL Mdl,
PointerPte++; PointerPte++;
/* Check if we're on a PDE boundary */ /* Check if we're on a PDE boundary */
if (!((ULONG_PTR)PointerPte & (PD_SIZE - 1))) PointerPde++; if (MiIsPteOnPdeBoundary(PointerPte)) PointerPde++;
#if (_MI_PAGING_LEVELS >= 3)
if (MiIsPteOnPpeBoundary(PointerPte)) PointerPpe++;
#endif
#if (_MI_PAGING_LEVELS == 4)
if (MiIsPteOnPxeBoundary(PointerPte)) PointerPxe++;
#endif
} while (PointerPte <= LastPte); } while (PointerPte <= LastPte);
// //

View file

@ -78,6 +78,8 @@
#define PDE_COUNT 1024 #define PDE_COUNT 1024
#define PTE_COUNT 1024 #define PTE_COUNT 1024
C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE); C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE);
#define MiIsPteOnPdeBoundary(PointerPte) \
((((ULONG_PTR)PointerPte) & (PAGE_SIZE - 1)) == 0)
#elif _M_ARM #elif _M_ARM
#define PD_COUNT 1 #define PD_COUNT 1
#define PDE_COUNT 4096 #define PDE_COUNT 4096
@ -164,7 +166,7 @@ C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE);
#error Define these please! #error Define these please!
#endif #endif
extern const ULONG MmProtectToPteMask[32]; extern const ULONG_PTR MmProtectToPteMask[32];
extern const ULONG MmProtectToValue[32]; extern const ULONG MmProtectToValue[32];
// //
@ -262,7 +264,11 @@ extern const ULONG MmProtectToValue[32];
// //
// Prototype PTEs that don't yet have a pagefile association // Prototype PTEs that don't yet have a pagefile association
// //
#ifdef _M_AMD64
#define MI_PTE_LOOKUP_NEEDED 0xffffffffULL
#else
#define MI_PTE_LOOKUP_NEEDED 0xFFFFF #define MI_PTE_LOOKUP_NEEDED 0xFFFFF
#endif
// //
// System views are binned into 64K chunks // System views are binned into 64K chunks
@ -444,6 +450,7 @@ extern SIZE_T MmMaximumNonPagedPoolInBytes;
extern PFN_NUMBER MmMaximumNonPagedPoolInPages; extern PFN_NUMBER MmMaximumNonPagedPoolInPages;
extern PFN_NUMBER MmSizeOfPagedPoolInPages; extern PFN_NUMBER MmSizeOfPagedPoolInPages;
extern PVOID MmNonPagedSystemStart; extern PVOID MmNonPagedSystemStart;
extern SIZE_T MiNonPagedSystemSize;
extern PVOID MmNonPagedPoolStart; extern PVOID MmNonPagedPoolStart;
extern PVOID MmNonPagedPoolExpansionStart; extern PVOID MmNonPagedPoolExpansionStart;
extern PVOID MmNonPagedPoolEnd; extern PVOID MmNonPagedPoolEnd;
@ -1379,7 +1386,14 @@ MiRemoveZeroPageSafe(IN ULONG Color)
// //
// New ARM3<->RosMM PAGE Architecture // New ARM3<->RosMM PAGE Architecture
// //
#ifdef _WIN64
// HACK ON TOP OF HACK ALERT!!!
#define MI_GET_ROS_DATA(x) \
(((x)->RosMmData == 0) ? NULL : ((PMMROSPFN)((ULONG64)(ULONG)((x)->RosMmData) | \
((ULONG64)MmNonPagedPoolStart & 0xffffffff00000000ULL))))
#else
#define MI_GET_ROS_DATA(x) ((PMMROSPFN)(x->RosMmData)) #define MI_GET_ROS_DATA(x) ((PMMROSPFN)(x->RosMmData))
#endif
#define MI_IS_ROS_PFN(x) (((x)->u4.AweAllocation == TRUE) && (MI_GET_ROS_DATA(x) != NULL)) #define MI_IS_ROS_PFN(x) (((x)->u4.AweAllocation == TRUE) && (MI_GET_ROS_DATA(x) != NULL))
#define ASSERT_IS_ROS_PFN(x) ASSERT(MI_IS_ROS_PFN(x) == TRUE); #define ASSERT_IS_ROS_PFN(x) ASSERT(MI_IS_ROS_PFN(x) == TRUE);
typedef struct _MMROSPFN typedef struct _MMROSPFN

View file

@ -93,6 +93,7 @@ ULONG MmMaxAdditionNonPagedPoolPerMb = 400 * 1024;
// http://www.ditii.com/2007/09/28/windows-memory-management-x86-virtual-address-space/ // http://www.ditii.com/2007/09/28/windows-memory-management-x86-virtual-address-space/
// //
PVOID MmNonPagedSystemStart; PVOID MmNonPagedSystemStart;
SIZE_T MiNonPagedSystemSize;
PVOID MmNonPagedPoolStart; PVOID MmNonPagedPoolStart;
PVOID MmNonPagedPoolExpansionStart; PVOID MmNonPagedPoolExpansionStart;
PVOID MmNonPagedPoolEnd = MI_NONPAGED_POOL_END; PVOID MmNonPagedPoolEnd = MI_NONPAGED_POOL_END;

View file

@ -913,7 +913,7 @@ MiInitializeWorkingSetList(IN PEPROCESS CurrentProcess)
MmWorkingSetList->LastInitializedWsle = 4; MmWorkingSetList->LastInitializedWsle = 4;
/* The rule is that the owner process is always in the FLINK of the PDE's PFN entry */ /* The rule is that the owner process is always in the FLINK of the PDE's PFN entry */
Pfn1 = MiGetPfnEntry(MiAddressToPte(PDE_BASE)->u.Hard.PageFrameNumber); Pfn1 = MiGetPfnEntry(CurrentProcess->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT);
ASSERT(Pfn1->u4.PteFrame == MiGetPfnEntryIndex(Pfn1)); ASSERT(Pfn1->u4.PteFrame == MiGetPfnEntryIndex(Pfn1));
Pfn1->u1.Event = (PKEVENT)CurrentProcess; Pfn1->u1.Event = (PKEVENT)CurrentProcess;
} }
@ -963,13 +963,23 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
/* Setup the PFN for the PDE base of this process */ /* Setup the PFN for the PDE base of this process */
#ifdef _M_AMD64
PointerPte = MiAddressToPte(PXE_BASE);
#else
PointerPte = MiAddressToPte(PDE_BASE); PointerPte = MiAddressToPte(PDE_BASE);
#endif
PageFrameNumber = PFN_FROM_PTE(PointerPte); PageFrameNumber = PFN_FROM_PTE(PointerPte);
ASSERT(Process->Pcb.DirectoryTableBase[0] == PageFrameNumber * PAGE_SIZE);
MiInitializePfn(PageFrameNumber, PointerPte, TRUE); MiInitializePfn(PageFrameNumber, PointerPte, TRUE);
/* Do the same for hyperspace */ /* Do the same for hyperspace */
#ifdef _M_AMD64
PointerPde = MiAddressToPxe((PVOID)HYPER_SPACE);
#else
PointerPde = MiAddressToPde(HYPER_SPACE); PointerPde = MiAddressToPde(HYPER_SPACE);
#endif
PageFrameNumber = PFN_FROM_PTE(PointerPde); PageFrameNumber = PFN_FROM_PTE(PointerPde);
//ASSERT(Process->Pcb.DirectoryTableBase[0] == PageFrameNumber * PAGE_SIZE); // we're not lucky
MiInitializePfn(PageFrameNumber, (PMMPTE)PointerPde, TRUE); MiInitializePfn(PageFrameNumber, (PMMPTE)PointerPde, TRUE);
/* Setup the PFN for the PTE for the working set */ /* Setup the PFN for the PTE for the working set */

View file

@ -261,7 +261,7 @@ MmAllocateSpecialPool(SIZE_T NumberOfBytes, ULONG Tag, POOL_TYPE PoolType, ULONG
RtlZeroMemory(Header, sizeof(POOL_HEADER)); RtlZeroMemory(Header, sizeof(POOL_HEADER));
/* Save allocation size there */ /* Save allocation size there */
Header->Ulong1 = NumberOfBytes; Header->Ulong1 = (ULONG)NumberOfBytes;
/* Make sure it's all good */ /* Make sure it's all good */
ASSERT((NumberOfBytes <= PAGE_SIZE - sizeof(POOL_HEADER)) && ASSERT((NumberOfBytes <= PAGE_SIZE - sizeof(POOL_HEADER)) &&
@ -286,7 +286,7 @@ MmAllocateSpecialPool(SIZE_T NumberOfBytes, ULONG Tag, POOL_TYPE PoolType, ULONG
That time will be used to check memory consistency within the allocated That time will be used to check memory consistency within the allocated
page. */ page. */
Header->PoolTag = Tag; Header->PoolTag = Tag;
Header->BlockSize = TickCount.LowPart; Header->BlockSize = (USHORT)TickCount.LowPart;
DPRINT1("%p\n", Entry); DPRINT1("%p\n", Entry);
return Entry; return Entry;
} }
@ -305,7 +305,7 @@ MiSpecialPoolCheckPattern(PUCHAR P, PPOOL_HEADER Header)
Ptr = P + BytesRequested; Ptr = P + BytesRequested;
/* Calculate how many bytes to check */ /* Calculate how many bytes to check */
BytesToCheck = (PUCHAR)PAGE_ALIGN(P) + PAGE_SIZE - Ptr; BytesToCheck = (ULONG)((PUCHAR)PAGE_ALIGN(P) + PAGE_SIZE - Ptr);
/* Remove pool header size if we're catching underruns */ /* Remove pool header size if we're catching underruns */
if (((ULONG_PTR)P & (PAGE_SIZE - 1)) == 0) if (((ULONG_PTR)P & (PAGE_SIZE - 1)) == 0)
@ -335,7 +335,7 @@ MmFreeSpecialPool(PVOID P)
KIRQL Irql = KeGetCurrentIrql(); KIRQL Irql = KeGetCurrentIrql();
POOL_TYPE PoolType; POOL_TYPE PoolType;
ULONG BytesRequested, BytesReal = 0; ULONG BytesRequested, BytesReal = 0;
ULONG_PTR PtrOffset; ULONG PtrOffset;
PUCHAR b; PUCHAR b;
PMI_FREED_SPECIAL_POOL FreedHeader; PMI_FREED_SPECIAL_POOL FreedHeader;
LARGE_INTEGER TickCount; LARGE_INTEGER TickCount;
@ -358,7 +358,7 @@ MmFreeSpecialPool(PVOID P)
} }
/* Determine if it's a underruns or overruns pool pointer */ /* Determine if it's a underruns or overruns pool pointer */
PtrOffset = (ULONG_PTR)P & (PAGE_SIZE - 1); PtrOffset = (ULONG)((ULONG_PTR)P & (PAGE_SIZE - 1));
if (PtrOffset) if (PtrOffset)
{ {
/* Pool catches overruns */ /* Pool catches overruns */

View file

@ -165,7 +165,8 @@ NtAssignProcessToJobObject (
ExAcquireRundownProtection(&Process->RundownProtect); ExAcquireRundownProtection(&Process->RundownProtect);
if(NT_SUCCESS(Status)) if(NT_SUCCESS(Status))
{ {
if(Process->Job == NULL && Process->Session == Job->SessionId) // FIXME: This is broken
if(Process->Job == NULL && PtrToUlong(Process->Session) == Job->SessionId)
{ {
/* Just store the pointer to the job object in the process, we'll /* Just store the pointer to the job object in the process, we'll
assign it later. The reason we can't do this here is that locking assign it later. The reason we can't do this here is that locking
@ -269,7 +270,7 @@ NtCreateJobObject (
/* setup the job object */ /* setup the job object */
InitializeListHead(&Job->ProcessListHead); InitializeListHead(&Job->ProcessListHead);
Job->SessionId = CurrentProcess->Session; /* inherit the session id from the caller */ Job->SessionId = PtrToUlong(CurrentProcess->Session); /* inherit the session id from the caller, FIXME: broken */
Status = ExInitializeResource(&Job->JobLock); Status = ExInitializeResource(&Job->JobLock);
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))

View file

@ -1113,7 +1113,8 @@ ULONG
NTAPI NTAPI
PsGetCurrentProcessSessionId(VOID) PsGetCurrentProcessSessionId(VOID)
{ {
return PsGetCurrentProcess()->Session; // FIXME: this is broken!
return PtrToUlong(PsGetCurrentProcess()->Session);
} }
/* /*

View file

@ -419,7 +419,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
_SEH2_TRY _SEH2_TRY
{ {
/* Write back the Session ID */ /* Write back the Session ID */
SessionInfo->SessionId = Process->Session; //MmGetSessionId(Process); SessionInfo->SessionId = PtrToUlong(PsGetProcessSessionId(Process));
} }
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{ {
@ -818,32 +818,32 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
} }
_SEH2_END; _SEH2_END;
break; break;
case ProcessImageInformation: case ProcessImageInformation:
DPRINT1("Image Information Query Not implemented: %lx\n", ProcessInformationClass); DPRINT1("Image Information Query Not implemented: %lx\n", ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
case ProcessDebugObjectHandle: case ProcessDebugObjectHandle:
DPRINT1("Debug Object Query Not implemented: %lx\n", ProcessInformationClass); DPRINT1("Debug Object Query Not implemented: %lx\n", ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
case ProcessHandleTracing: case ProcessHandleTracing:
DPRINT1("Handle tracing Not implemented: %lx\n", ProcessInformationClass); DPRINT1("Handle tracing Not implemented: %lx\n", ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
case ProcessLUIDDeviceMapsEnabled: case ProcessLUIDDeviceMapsEnabled:
DPRINT1("LUID Device Maps Not implemented: %lx\n", ProcessInformationClass); DPRINT1("LUID Device Maps Not implemented: %lx\n", ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
case ProcessExecuteFlags: case ProcessExecuteFlags:
DPRINT1("No execute Not implemented: %lx\n", ProcessInformationClass); DPRINT1("No execute Not implemented: %lx\n", ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
case ProcessWow64Information: case ProcessWow64Information:
case ProcessLdtInformation: case ProcessLdtInformation:
case ProcessWx86Information: case ProcessWx86Information:
@ -855,12 +855,12 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
DPRINT1("WS Watch Not implemented: %lx\n", ProcessInformationClass); DPRINT1("WS Watch Not implemented: %lx\n", ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
case ProcessPooledUsageAndLimits: case ProcessPooledUsageAndLimits:
DPRINT1("Pool limits Not implemented: %lx\n", ProcessInformationClass); DPRINT1("Pool limits Not implemented: %lx\n", ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
/* Not supported by Server 2003 */ /* Not supported by Server 2003 */
default: default:
DPRINT1("Unsupported info class: %lx\n", ProcessInformationClass); DPRINT1("Unsupported info class: %lx\n", ProcessInformationClass);
@ -978,7 +978,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
Status = STATUS_PRIVILEGE_NOT_HELD; Status = STATUS_PRIVILEGE_NOT_HELD;
break; break;
} }
/* Get the LPC Port */ /* Get the LPC Port */
Status = ObReferenceObjectByHandle(PortHandle, Status = ObReferenceObjectByHandle(PortHandle,
0, 0,
@ -1050,10 +1050,10 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
_SEH2_YIELD(break); _SEH2_YIELD(break);
} }
_SEH2_END; _SEH2_END;
/* Set the mode */ /* Set the mode */
Process->DefaultHardErrorProcessing = DefaultHardErrorMode; Process->DefaultHardErrorProcessing = DefaultHardErrorMode;
/* Call Ke for the update */ /* Call Ke for the update */
if (DefaultHardErrorMode & SEM_NOALIGNMENTFAULTEXCEPT) if (DefaultHardErrorMode & SEM_NOALIGNMENTFAULTEXCEPT)
{ {
@ -1219,7 +1219,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
PsProcessPriorityBackground); PsProcessPriorityBackground);
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;
case ProcessBasePriority: case ProcessBasePriority:
/* Validate input length */ /* Validate input length */
@ -1242,7 +1242,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
_SEH2_YIELD(break); _SEH2_YIELD(break);
} }
_SEH2_END; _SEH2_END;
/* Extract the memory priority out of there */ /* Extract the memory priority out of there */
if (BasePriority & 0x80000000) if (BasePriority & 0x80000000)
{ {
@ -1253,22 +1253,22 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
{ {
MemoryPriority = MEMORY_PRIORITY_BACKGROUND; MemoryPriority = MEMORY_PRIORITY_BACKGROUND;
} }
/* Validate the number */ /* Validate the number */
if ((BasePriority > HIGH_PRIORITY) || (BasePriority <= LOW_PRIORITY)) if ((BasePriority > HIGH_PRIORITY) || (BasePriority <= LOW_PRIORITY))
{ {
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
/* Check if the new base is higher */ /* Check if the new base is higher */
if (BasePriority > Process->Pcb.BasePriority) if (BasePriority > Process->Pcb.BasePriority)
{ {
DPRINT1("Should check privilege\n"); DPRINT1("Should check privilege\n");
} }
/* Call Ke */ /* Call Ke */
KeSetPriorityAndQuantumProcess(&Process->Pcb, BasePriority, 0); KeSetPriorityAndQuantumProcess(&Process->Pcb, BasePriority, 0);
/* Now set the memory priority */ /* Now set the memory priority */
MmSetMemoryPriorityProcess(Process, MemoryPriority); MmSetMemoryPriorityProcess(Process, MemoryPriority);
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
@ -1351,14 +1351,14 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
_SEH2_YIELD(break); _SEH2_YIELD(break);
} }
_SEH2_END; _SEH2_END;
/* Setting 'break on termination' requires the SeDebugPrivilege */ /* Setting 'break on termination' requires the SeDebugPrivilege */
if (!SeSinglePrivilegeCheck(SeDebugPrivilege, PreviousMode)) if (!SeSinglePrivilegeCheck(SeDebugPrivilege, PreviousMode))
{ {
Status = STATUS_PRIVILEGE_NOT_HELD; Status = STATUS_PRIVILEGE_NOT_HELD;
break; break;
} }
/* Set or clear the flag */ /* Set or clear the flag */
if (Break) if (Break)
{ {
@ -1370,9 +1370,9 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
} }
break; break;
case ProcessAffinityMask: case ProcessAffinityMask:
/* Check buffer length */ /* Check buffer length */
if (ProcessInformationLength != sizeof(KAFFINITY)) if (ProcessInformationLength != sizeof(KAFFINITY))
{ {
@ -1393,7 +1393,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
_SEH2_YIELD(break); _SEH2_YIELD(break);
} }
_SEH2_END; _SEH2_END;
/* Make sure it's valid for the CPUs present */ /* Make sure it's valid for the CPUs present */
ValidAffinity = Affinity & KeActiveProcessors; ValidAffinity = Affinity & KeActiveProcessors;
if (!Affinity || (ValidAffinity != Affinity)) if (!Affinity || (ValidAffinity != Affinity))
@ -1435,7 +1435,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
Status = STATUS_PROCESS_IS_TERMINATING; Status = STATUS_PROCESS_IS_TERMINATING;
} }
break; break;
/* Priority Boosting status */ /* Priority Boosting status */
case ProcessPriorityBoost: case ProcessPriorityBoost:
@ -1469,7 +1469,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
/* Call Ke to do the work */ /* Call Ke to do the work */
KeSetDisableBoostProcess(&Process->Pcb, DisableBoost); KeSetDisableBoostProcess(&Process->Pcb, DisableBoost);
/* Loop the threads too */ /* Loop the threads too */
for (Next = Process->ThreadListHead.Flink; for (Next = Process->ThreadListHead.Flink;
Next != &Process->ThreadListHead; Next != &Process->ThreadListHead;
@ -1494,7 +1494,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
Status = STATUS_PROCESS_IS_TERMINATING; Status = STATUS_PROCESS_IS_TERMINATING;
} }
break; break;
case ProcessDebugFlags: case ProcessDebugFlags:
/* Check buffer length */ /* Check buffer length */
@ -1516,7 +1516,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
_SEH2_YIELD(break); _SEH2_YIELD(break);
} }
_SEH2_END; _SEH2_END;
/* Set the mode */ /* Set the mode */
if (DebugFlags & ~1) if (DebugFlags & ~1)
{ {
@ -1537,7 +1537,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
/* Done */ /* Done */
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;
case ProcessEnableAlignmentFaultFixup: case ProcessEnableAlignmentFaultFixup:
/* Check buffer length */ /* Check buffer length */
@ -1559,7 +1559,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
_SEH2_YIELD(break); _SEH2_YIELD(break);
} }
_SEH2_END; _SEH2_END;
/* Set the mode */ /* Set the mode */
if (EnableFixup) if (EnableFixup)
{ {
@ -1569,12 +1569,12 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
{ {
Process->DefaultHardErrorProcessing &= ~SEM_NOALIGNMENTFAULTEXCEPT; Process->DefaultHardErrorProcessing &= ~SEM_NOALIGNMENTFAULTEXCEPT;
} }
/* Call Ke for the update */ /* Call Ke for the update */
KeSetAutoAlignmentProcess(&Process->Pcb, FALSE); KeSetAutoAlignmentProcess(&Process->Pcb, FALSE);
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;
/* We currently don't implement any of these */ /* We currently don't implement any of these */
case ProcessLdtInformation: case ProcessLdtInformation:
case ProcessLdtSize: case ProcessLdtSize:
@ -1584,32 +1584,32 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
DPRINT1("VDM/16-bit Request not implemented: %lx\n", ProcessInformationClass); DPRINT1("VDM/16-bit Request not implemented: %lx\n", ProcessInformationClass);
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
case ProcessQuotaLimits: case ProcessQuotaLimits:
DPRINT1("Quota Limits not implemented\n"); DPRINT1("Quota Limits not implemented\n");
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
case ProcessWorkingSetWatch: case ProcessWorkingSetWatch:
DPRINT1("WS watch not implemented\n"); DPRINT1("WS watch not implemented\n");
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
case ProcessDeviceMap: case ProcessDeviceMap:
DPRINT1("Device map not implemented\n"); DPRINT1("Device map not implemented\n");
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
case ProcessHandleTracing: case ProcessHandleTracing:
DPRINT1("Handle tracing not implemented\n"); DPRINT1("Handle tracing not implemented\n");
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
case ProcessExecuteFlags: case ProcessExecuteFlags:
DPRINT1("No execute support not implemented\n"); DPRINT1("No execute support not implemented\n");
Status = STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
break; break;
/* Anything else is invalid */ /* Anything else is invalid */
default: default:
DPRINT1("Invalid Server 2003 Info Class: %lx\n", ProcessInformationClass); DPRINT1("Invalid Server 2003 Info Class: %lx\n", ProcessInformationClass);