[PERF]: Replace early ZwClose system calls with ObCloseHandle(KernelMode). This avoids taking a system call for those cases and gives a slight perf boost to booting up the system. It also pushes the first system call somewhat later in the boot process, allowing for easier debugging should the interface have issues/need tracing.

[NTOS]: Do not attempt querying the Registry Primary Handle for the Backing Hive File Size in the case where there is no actual Primary! There was no error checking so nobody noticed this happens -- it also probably resets Cluster to 0 (instead of 1), which can cause corruption in some cases.
[NTOS]: Make KiUserTrap use the MODE_MASK instead of hard-coding a check for Ring 0 CS (which is slower and not as correct).

svn path=/trunk/; revision=45217
This commit is contained in:
Sir Richard 2010-01-23 21:27:26 +00:00
parent 89f8b943b1
commit cdb563f380
6 changed files with 17 additions and 13 deletions

View file

@ -163,13 +163,17 @@ CmpInitializeHive(OUT PCMHIVE *RegistryHive,
/* Set flags */
Hive->Flags = HiveFlags;
/* Check how large the file is */
ZwQueryInformationFile(Primary,
&IoStatusBlock,
&FileInformation,
sizeof(FileInformation),
FileStandardInformation);
Cluster = FileInformation.EndOfFile.LowPart;
/* Check if this is a primary */
if (Primary)
{
/* Check how large the file is */
ZwQueryInformationFile(Primary,
&IoStatusBlock,
&FileInformation,
sizeof(FileInformation),
FileStandardInformation);
Cluster = FileInformation.EndOfFile.LowPart;
}
/* Initialize it */
Status = HvInitialize(&Hive->Hive,

View file

@ -303,7 +303,7 @@ ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
KernelMode,
&ExpNlsSectionPointer,
NULL);
ZwClose(NlsSection);
ObCloseHandle(NlsSection, KernelMode);
if (!NT_SUCCESS(Status))
{
/* Failed */

View file

@ -310,7 +310,7 @@ ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType,
/* Dereference and close handle */
ObDereferenceObject(Thread);
ZwClose(hThread);
ObCloseHandle(hThread, KernelMode);
}
/*++
@ -586,7 +586,7 @@ ExpInitializeWorkerThreads(VOID)
ExpWorkerThreadBalanceManagerPtr = Thread;
/* Close the handle and return */
ZwClose(ThreadHandle);
ObCloseHandle(ThreadHandle, KernelMode);
}
/* PUBLIC FUNCTIONS **********************************************************/

View file

@ -165,7 +165,7 @@ FORCEINLINE
KiUserTrap(IN PKTRAP_FRAME TrapFrame)
{
/* Anything else but Ring 0 is Ring 3 */
return (TrapFrame->SegCs != KGDT_R0_CODE);
return (TrapFrame->SegCs & MODE_MASK);
}
BOOLEAN

View file

@ -466,7 +466,7 @@ KiDispatchExceptionFromTrapFrame(IN NTSTATUS Code,
NULL,
TrapFrame,
TrapFrame->EFlags & EFLAGS_V86_MASK ?
-1 : TrapFrame->SegCs & MODE_MASK,
-1 : KiUserTrap(TrapFrame),
TRUE);
/* Return from this trap */

View file

@ -586,7 +586,7 @@ PspInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
KernelMode,
(PVOID*)&SysThread,
NULL);
ZwClose(SysThreadHandle);
ObCloseHandle(SysThreadHandle, KernelMode);
SysThreadCreated = TRUE;
/* Return success */