- Implement KeReadStateThread.
- Fix PspTerminateProcess to handle case where there's no threads in the process.
- Fix check in PspTerminateProcess. ObClearProcessHandleTable gets called if there's a debug port, not if there's an object table.
- Simplfy PspReapRoutine.
- Fix PspExitThread to wait for all other threads before continuing to kill the last thread. Should fix lots of race/wait conditions.
- PspExitThread should check for !DeadThread and not !Terminated before determining if it should free the TEB. Also, the DbgK handle should only be closed if the thread isn't already dead.
- Fixup formatting of some code to warn less on MSVC.
- Fail various APIs if acquiring rundown protection failed.
- Fix Process Quantum/Priority settings.
- Grant PROCESS_TERMINATE by default.
- Add PROCESS_SET_INFORMATION, STANDARD_RIGHTS_ALL and PROCESS_SET_QUOTA to the default process granted access mask.
- Initialize process/thread/image notification callbacks durin phase 0 Ps initialization.
- The Audit Name belongs to the system process, not the idle process.
- Detect more failures in phase 0 startup.
- Fix various race conditions/incorrect checks in ps/security.c related to impersonation information. Also allow PspAssignPrimaryToken to be called directly with the token pointer and not only the handle.
- Wrap system thread startup stub in SEH and write a SEH filter function to print out debug information when a system thread dies unexpectedly.
svn path=/trunk/; revision=25504
- Add NtInitialUserProcessBuffer settings and validate/user them when launching smss.
- Use SePublicDefaultUnrestrictedSd for the root system link.
- Make enough space for the smss process parameters, there's 6 strings, not 4.
- Fix incorrect length of NtSystemRoot string.
- Disable SYSENTER on CPUs that don't support it.
- Detect and enable NX feature bit.
- Detect and enable DTS support.
- Implement Ki386EnableXMMIExceptions (the XMMI handler still needs to be done, however).
- Implement KiI386PentiumLockErrataFixup to work around the F00F bug.
- Implement KiIsNpxErrataPresent to detect the FDIV bug.
- Implement CPU Speed detection.
- Only setup Initial FX State if the CPU supports FXSR.
- Setup some more PCR fields during init.
- Use NX_SUPPORT_POLICY flags documented in ntddk.h
- Don't boot if CMPXCHG8B is not supported by the CPU. This is the same requirement as Windows.
- Don't overwrite all the PRCB locks in KiInitSpinlocks due to a stupid bug in the timer spinlock initialization.
svn path=/trunk/; revision=25503
- Guard some more code with #ifdef NEW_SCHEDULER.
- Fix bugs in KiDispatchInterrupt.
- Use PRCB fields instead of PriorityListHead/PriorityListMask to reduces number of code changes between NEW_SCHEDULER and old.
- Fully implement KiDeferredReadyThread, but only for Uni-Processor systems. Supports unwait boosts as well as lock boosts. Not yet used.
- Implement NEW_SCHEDULER version of KiSwapThread and NtYieldExecution.
svn path=/trunk/; revision=25502
- Simplify KiSelectReadyThread.
- Use ASSERT_IRQL_EQUAL instead of ASSERT_IRQL, because ASSERT_IRQL is braindead and doesn't actually do what the name proposes. This caused us to miss many critical bugs.
- Don't lower IRQL to PASSIVE_LEVEL after KeInsertQueueApc. This caused a call to KiExitDispatcher at PASSIVE, which is completely fucked. Also do the same fix in KeFreezeAllThreads and KeThawAllThreads.
- Implement code in KiDispatchInterrupt to switch to a new thread, but don't enable for now.
- Fix the KiMask32Array. One of the values was totally off and screwed up priority/affinity masks.
- Exit the dispatcher in KiAdjustQuantumThread. This wasn't done, thus causing a weird system state.
- Fix a bug in KiSetPriorityThread which wasn't properly checking the ProcessReadyQueue member and thus not applying priority changes.
- Fixup lock release and dispatcher exit in wait functions in the NoWait case. It was inverted and messed up, leading to system inconsistency.
svn path=/trunk/; revision=25501
tempary fix, we can not optimize code so good yet. so if it more that 4 register same time we are using own frame, ebx is working as our ebp for we already resvert the ebp
svn path=/trunk/; revision=25497
- Disable KiSetAffinityThread to do nothing else but change affinity instead of doing re-scheduling (temporary change).
- Cleanup KiQuantumEnd to prepare for new scheduler.
- Fix up a large bug in KeInsertQueueDpc which was making every DPC become a Threaded DPC due to a bad assignment-instead-of-compare.
- Copy KiSelectNextThread for new scheduler branch, without SMT support.
- Fix a bug in KiAdjustQuantumThread under new scheduler.
- Re-implement KiSetPriorityThread under new scheduler, leave hacks for current scheduler support.
- Remove old testing assert from KiExitDispatcher.
svn path=/trunk/; revision=25491
- Make KiComputeNewPriority accept various priority adjuments instead of always assuming an increase of 1 priority level.
- Fix ASSERT in KeSetEventBoostPriority: API is valid *only* for Synchronization events, not notification ones.
- Use proper KiComputeNewPriority call in KeSetEventBoostPriority, since we're not adjusting by 1.
- Make sure the FreezeCount is also 0 in KeAlertResumeThread, before signalling the suspend semaphore.
- Simply alert-mode check in KeAlertThread.
- Don't exit the critical region in KeFreezeAllThreads, it needs to be held.
- Don't enter a critical region in KeThawAllThreads, it should already have been entered; release it after thawing is complete.
- Also change the list loop in these functions to always start with the first thread.
- Copy over boost-disable flag in KeStartThread.
- Don't acquire the dispatcher lock in KeTestAlertThread.
- Set the KernelStackResident flag to TRUE in KeInitThread.
- Fix KeSetIdealProcessorThread to check the CPU is valid on the system, not valid across all valid CPU numbers. Also fix it to compare affinity, not processor.
- Fix KeSetBasePriorityThread to properly call KiComputeNewPriority with an adjustment of 0, and then properly manually adjust with the delta between the new base priority and the old base priority.
- Also normalize the new priority if it's too low.
- Always set the priority decrement back to 0 when KeSetPriorityThread is called.
- Normalize the priority in KeSetPriorityThread if it falls too low.
- Fix process stack count check in KeTerminateThread.
- Acquire thread and PRCB lock in KiAdjustQuantumThread.
- Use KiComputeNewPriority in KiAdjustQuantumThread.
- Dispatch a new thread in KiAdjustQuantumThread to take into account the new scheduler settings.
- Thread priorities should make more sense now...
svn path=/trunk/; revision=25490
- Code is very similar to Ob* Fast Referencing, and the use of macros to encapsulate generic referencing should be done later. Essentially, Ob sticks ObRefs around FastRefs, while ExCallbacks sticks ExRundown around FastRefs.
svn path=/trunk/; revision=25484
- Stub ExReferenceCallBackBlock and ExDereferenceCallBackBlock until I get the locking right.
- These callbacks are used by Cm as well as Ps inside Windows NT and combine the power of PushLocks, Rundown Protection and Fast Referencing to ensure callbacks only get called once and thread safely. Not yet used in ROS.
svn path=/trunk/; revision=25483
- Make code use standard NT structures.
- Fix object type initialization.
- Fix calls to ExCreatecallback during system initalization which were randomly overwriting memory.
- Fix ExREgisterCallback which was allocating only a pointer inside of the entire structure, also over-writing system memory.
svn path=/trunk/; revision=25482
- Re-identize some APC code (just formatting change).
- Detect APC during GateWait. Previous check scanned for DeferredReady, which is incorrect.
- Simplfy KeremovequeueApc to take advantage of the fact RemoveEntryList now returns whether the list is empty or not.
svn path=/trunk/; revision=25479
- pixel bits must be pre-multiplied with the alpha channel
- along with the previous LookupIconIdFromDirectoryEx, basic alpha blending is working. some bugfixing is still required.
svn path=/trunk/; revision=25475
- The rundown event is a sync event, not a notification event.
- Only take slow path when waiting for release if the value changed *and* is still not active, not if only one of the two is true.
svn path=/trunk/; revision=25472
[4 bug fixes]:
- Setup default GrantedAccess for system init thread/process in ObInit.
- Fix a small bug in ObpReapObject.
- Set object header flag is deletion was done deferred.
- Simplify ObpDeferObjectDeletion.
- Use KeAreAllApcsDisabled instead of only checking IRQL to determine if we should do defered deletion.
svn path=/trunk/; revision=25471
- Isolate FuckedUpCm version of ObpLookupDirectoryObject into CmpLookupDirectoryObject to avoid name info leak.
- Rename ObpIncrementQueryReference to ObpAcquireNameInformation and ObpDecrementQueryReference to ObpReleaseNameInformation and make some changes to make calling a lot easier.
- Fixup reference increment loop in above function.
- Fix incorrect check for defer delete flag instead of query references flag.
- Only clear the directory/directory lock flag in ObpCleanupDirectoryLookup if the directory was actually locked.
- Fix lock logic in ObpLookupDirectoryEntry.
- Properly handle the case when lookup occurs after an existing object, avoid name information leak and reference leak.
- Hold shared lock inside NtQuerydirectoryObject.
- Properly initiailize the directory object in NtCreateDirectoryObject.
- Clear create info before creating the unnamed handle in ObInsertObject.
- Only dereference the target process if we actually have one in NtDuplicateObject.
- Don't double-reference the name information in ObpDeleteNameCheck, thus avoiding another leak.
- Fix object case sensitivity check in ObpLookupObjectName.
svn path=/trunk/; revision=25469
- ObpReferenceProcessObjectByHandle is always called with HandleInformation, remove this check.
- ObpReferenceProcessObjectByHandle already gets a process parameter, don't query the current one.
- ObpReferenceProcessObjectByHandle already gets a handle table, don't query the current one.
- ObpDecrementHandleCount shouldn't remove the object from the creator info.
- ObpDecrementHandleCount should clear the exclusive process if this is the last handle.
- Killing a protected handle should raise an exception if a debug port is connected, not an exception port.
- ObpIncrementHandleCount should support OBJ_FORCE_ACCESS_CHECK.
- ObpIncrementHandleCount needs to support ObDuplicateHandle.
- ObpIncrementHandleCount needs to support being called without an AccessState.
- Fix interlocked handle count accounting.
- Allow user-mode to create kernel-mode handles.
- Fix the way Additional reference bias is de-referenced during failures.
- Complete rundown in ObKillProcess.
- Send SourceProcess in ObDuplicateHandle.
- Assume initial failure and clear handle in ObDuplicateHandle.
- Don't leak object table references when failing in ObDuplicateHandle.
- Assume failure in ObOpenObjectByName.
- Don't leak buffer during failure in ObOpenObjectByName.
- Don't leak object reference durning failure in ObOpenObjecByName.
- Validate handle attributes in ObOpenObjectByPointer.
- Use RtlCopyMemory when possible to speed up.
svn path=/trunk/; revision=25467
- Fix LPC process closing bug.
- Rewrite executive timer support to make it thread-safe and use proper locking order and semantics as well as safe referencing. Also implement Windows 2003 feature of flushing DPCs when a timer is deleted, to avoid the timer from being fired after deletion.
svn path=/trunk/; revision=25461