Fix more wrong structure defintions... and use proper values for Thread/Process mapping, not some weird undocumented/reversed values with no explenation.

svn path=/trunk/; revision=12747
This commit is contained in:
Alex Ionescu 2005-01-03 04:06:24 +00:00
parent d222bec89c
commit b429ae3287
6 changed files with 33 additions and 33 deletions

View file

@ -113,7 +113,7 @@ KIRQL STDCALL KeGetCurrentIrql (VOID);
#ifndef __USE_W32API
#define KeGetCurrentProcessorNumber() (KeGetCurrentKPCR()->ProcessorNumber)
ULONG KeGetDcacheFillSize(VOID);
ULONG STDCALL KeGetPreviousMode (VOID);
KPROCESSOR_MODE STDCALL KeGetPreviousMode (VOID);
#endif
struct _KTHREAD* STDCALL KeGetCurrentThread (VOID);

View file

@ -47,6 +47,7 @@
/* Thread access rights */
#define THREAD_TERMINATE (0x0001L)
#define THREAD_SUSPEND_RESUME (0x0002L)
#define THREAD_ALERT (0x0004L)
#define THREAD_GET_CONTEXT (0x0008L)
#define THREAD_SET_CONTEXT (0x0010L)
#define THREAD_SET_INFORMATION (0x0020L)
@ -69,6 +70,7 @@
#define PROCESS_SET_QUOTA (0x0100L)
#define PROCESS_SET_INFORMATION (0x0200L)
#define PROCESS_QUERY_INFORMATION (0x0400L)
#define PROCESS_SET_PORT (0x0800L)
#define PROCESS_ALL_ACCESS (0x1f0fffL)

View file

@ -158,15 +158,18 @@ typedef struct _SECTION_OBJECT
typedef struct _SECTION_OBJECT *PSECTION_OBJECT;
typedef struct _EPROCESS_QUOTA_ENTRY {
ULONG Usage;
ULONG Limit;
ULONG Peak;
ULONG Return;
} EPROCESS_QUOTA_ENTRY, *PEPROCESS_QUOTA_ENTRY;
typedef struct _EPROCESS_QUOTA_BLOCK {
KSPIN_LOCK QuotaLock;
ULONG ReferenceCount;
ULONG QuotaPeakPoolUsage[2];
ULONG QuotaPoolUsage[2];
ULONG QuotaPoolLimit[2];
ULONG PeakPagefileUsage;
ULONG PagefileUsage;
ULONG PagefileLimit;
EPROCESS_QUOTA_ENTRY QuotaEntry[3];
LIST_ENTRY QuotaList;
ULONG ReferenceCount;
ULONG ProcessCount;
} EPROCESS_QUOTA_BLOCK, *PEPROCESS_QUOTA_BLOCK;
/*

View file

@ -27,9 +27,11 @@ static KSPIN_LOCK PsProcessListLock;
static ULONG PiNextProcessUniqueId = 0; /* TODO */
static LARGE_INTEGER ShortPsLockDelay, PsLockTimeout;
static GENERIC_MAPPING PiProcessMapping = {PROCESS_READ,
PROCESS_WRITE,
PROCESS_EXECUTE,
static GENERIC_MAPPING PiProcessMapping = {STANDARD_RIGHTS_READ | PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
STANDARD_RIGHTS_WRITE | PROCESS_CREATE_PROCESS | PROCESS_CREATE_THREAD |
PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_DUP_HANDLE |
PROCESS_TERMINATE | PROCESS_SET_QUOTA | PROCESS_SET_INFORMATION | PROCESS_SET_PORT,
STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE,
PROCESS_ALL_ACCESS};
#define MAX_PROCESS_NOTIFY_ROUTINE_COUNT 8
@ -1191,10 +1193,10 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
PKERNEL_USER_TIMES ProcessTimeP =
(PKERNEL_USER_TIMES)ProcessInformation;
ProcessTimeP->CreateTime = (TIME) Process->CreateTime;
ProcessTimeP->CreateTime = Process->CreateTime;
ProcessTimeP->UserTime.QuadPart = Process->Pcb.UserTime * 100000LL;
ProcessTimeP->KernelTime.QuadPart = Process->Pcb.KernelTime * 100000LL;
ProcessTimeP->ExitTime = (TIME) Process->ExitTime;
ProcessTimeP->ExitTime = Process->ExitTime;
if (ReturnLength)
{
@ -2144,7 +2146,6 @@ PsChargeProcessPoolQuota(
)
{
PEPROCESS_QUOTA_BLOCK QuotaBlock;
KIRQL OldValue;
ULONG NewUsageSize;
ULONG NewMaxQuota;
@ -2154,40 +2155,33 @@ PsChargeProcessPoolQuota(
/* Quota Operations are not to be done on the SYSTEM Process */
if (Process == PsInitialSystemProcess) return STATUS_SUCCESS;
/* Acquire Spinlock */
KeAcquireSpinLock(&QuotaBlock->QuotaLock, &OldValue);
/* New Size in use */
NewUsageSize = QuotaBlock->QuotaPoolUsage[PoolType] + Amount;
NewUsageSize = QuotaBlock->QuotaEntry[PoolType].Usage + Amount;
/* Does this size respect the quota? */
if (NewUsageSize > QuotaBlock->QuotaPoolLimit[PoolType]) {
if (NewUsageSize > QuotaBlock->QuotaEntry[PoolType].Limit) {
/* It doesn't, so keep raising the Quota */
while (MiRaisePoolQuota(PoolType, QuotaBlock->QuotaPoolLimit[PoolType], &NewMaxQuota)) {
while (MiRaisePoolQuota(PoolType, QuotaBlock->QuotaEntry[PoolType].Limit, &NewMaxQuota)) {
/* Save new Maximum Quota */
QuotaBlock->QuotaPoolLimit[PoolType] = NewMaxQuota;
QuotaBlock->QuotaEntry[PoolType].Limit = NewMaxQuota;
/* See if the new Maximum Quota fulfills our need */
if (NewUsageSize <= NewMaxQuota) goto QuotaChanged;
}
KeReleaseSpinLock(&QuotaBlock->QuotaLock, OldValue);
return STATUS_QUOTA_EXCEEDED;
}
QuotaChanged:
/* Save new Usage */
QuotaBlock->QuotaPoolUsage[PoolType] = NewUsageSize;
QuotaBlock->QuotaEntry[PoolType].Usage = NewUsageSize;
/* Is this a new peak? */
if (NewUsageSize > QuotaBlock->QuotaPeakPoolUsage[PoolType]) {
QuotaBlock->QuotaPeakPoolUsage[PoolType] = NewUsageSize;
if (NewUsageSize > QuotaBlock->QuotaEntry[PoolType].Peak) {
QuotaBlock->QuotaEntry[PoolType].Peak = NewUsageSize;
}
/* Release spinlock */
KeReleaseSpinLock(&QuotaBlock->QuotaLock, OldValue);
/* All went well */
return STATUS_SUCCESS;
}

View file

@ -43,9 +43,10 @@ static BOOLEAN DoneInitYet = FALSE;
static KEVENT PiReaperThreadEvent;
static BOOLEAN PiReaperThreadShouldTerminate = FALSE;
static GENERIC_MAPPING PiThreadMapping = {THREAD_READ,
THREAD_WRITE,
THREAD_EXECUTE,
static GENERIC_MAPPING PiThreadMapping = {STANDARD_RIGHTS_READ | THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION,
STANDARD_RIGHTS_WRITE | THREAD_TERMINATE | THREAD_SUSPEND_RESUME | THREAD_ALERT |
THREAD_SET_INFORMATION | THREAD_SET_CONTEXT,
STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE,
THREAD_ALL_ACCESS};
/* FUNCTIONS ***************************************************************/

View file

@ -316,7 +316,7 @@ KeSetPreviousMode (ULONG Mode)
/*
* @implemented
*/
ULONG STDCALL
KPROCESSOR_MODE STDCALL
KeGetPreviousMode (VOID)
{
return (ULONG)PsGetCurrentThread()->Tcb.PreviousMode;