Commit graph

22327 commits

Author SHA1 Message Date
Alex Ionescu 6c853c9c32 - Fix a critical bug in KiComputeNewPriority.
- Fix a bug in KiSetPriorityThread which wasn't setting *released = FALSE, which left the var uninitailized and usually = TRUE on the stack.
- Half-copy KiQuantumEnd from my new scheduler code. Main difference is usage of newly created locks, support for quantum-disable and RT threads, and usage of KiComputeNewPriority.

svn path=/trunk/; revision=24060
2006-09-11 05:21:18 +00:00
Alex Ionescu 8028be67cb - Fix KiDeliverApc prototype for PPC compatibilty.
- Fixup comment header for KiDeliverApc and KiInsertQueueApc.
- Set APC trap frame during APC delivery. We actually weren't doing this before (I'm kind of amazed at ROS's previous functionality due to importance of this bug!).
- Use proper in-stack queued spinlock mechanisms.
- Make sure that the Kernel APC list didn't become empty while we acquired the APC lock after the first verification.
- Validate IRQL on return from APC routines, to catch bad code.

svn path=/trunk/; revision=24059
2006-09-11 04:34:25 +00:00
Alex Ionescu d011801cef - Fix lock acquisition/release mismathces in KiInsertQueueApc.
- Support and document InsertApcEnvironment KAPC_ENVIRONMENT type.
- Fixup formatting and ASSERTify.
- Acquire dispatcher lock when insereting an APC into another thread.
- Use delayed interrupt request on SMP systems (and fixup KiRequestApcInterrupt accordingly).

svn path=/trunk/; revision=24058
2006-09-11 03:14:26 +00:00
Alex Ionescu 52b3dfb608 - Fix stupid typo.
svn path=/trunk/; revision=24057
2006-09-11 02:30:38 +00:00
Alex Ionescu 90a7bca112 - Add new KAPC_ENVIRONMENT mode: InsertApcEnvironment.
- Fixup KeInitalizeApc like all the other functions.
- Don't use an expensive 48-byte RtlZeroMemory instead of just clearing two members.

svn path=/trunk/; revision=24056
2006-09-11 02:28:09 +00:00
Alex Ionescu 8b90aed6be - Fix comment headers for KeFlushQueueApc, KeInsertQueueApc.
- ASSERTify KeInsertQueueApc and some formatting fixes.

svn path=/trunk/; revision=24055
2006-09-11 02:17:57 +00:00
Alex Ionescu c9607ffe89 - Fix for Windows Kernel APC Data-Free Local Privilege Escalation Vulnerability (re-initialize the list head after cleaning it, so that the list is circular).
- Optimize KeFlushQueueApc: we can check if the Kernel-Mode APC list is empty without acquiring the lock. If it's empty, we can quit immediately, if not, then we'll acquire and check it again. For user APCs we always need to acquire the lock, though.

svn path=/trunk/; revision=24054
2006-09-11 02:09:13 +00:00
Alex Ionescu 43a412db60 - Add ASSERT_APC definition.
- Fix KeRemoveQueueApc comment header and clean up function.
- Acquire dispatcher lock at DPC level during ApcListEntry read/write.

svn path=/trunk/; revision=24053
2006-09-11 01:45:11 +00:00
Alex Ionescu 4b35027c0f - Cleanup RepairList, KiMoveApcState.
- Fixup comments for KeAreApcsDisabled.
- Implement and add comment header to KeAreAllApcsDisabled.

svn path=/trunk/; revision=24052
2006-09-11 01:30:24 +00:00
Alex Ionescu 2fea34f0e1 - Re-implement KiRequestApcInterrupt in ke_x.h. Make it work by CPU number (as documented) instead of comparing PRCBs.
- Move NtQueueApcThread to ps/state.c since it's a Ps-level function.
- Make NtQueueApcThread use POOL_QUOTA_FAIL_INSTEAD_OF_RAISE and add that flag to our DDK. Also fix the check for SystemThread by looking at the flag, not checking if TEB == NULL. Also fix a memory leak and comment header.
- Fix comment header in KiInitalizeUserApc.

svn path=/trunk/; revision=24051
2006-09-11 01:15:03 +00:00
Alex Ionescu 1462b71058 - Re-organize apc.c into private/public functions (no code change).
- Move KiInitializeUserApc to ke/i386/userapc.c. The routine is non-portable.
- Force Ring 3 state into User APC TrapFrame to maintain system integrity and coherency. Also respect IOPL.
- Use SEH handling routine just like when handling exceptions, to properly re-direct a crash here. Thanks to KJK again for showing me how to write these kinds of routines.

svn path=/trunk/; revision=24050
2006-09-11 00:54:12 +00:00
Alex Ionescu 4d94e0557f - Fix KeEnterCriticalRegion/KeLeaveCriticalRegion by moving to ke_x and adding ASSERTs, and change the code in apc.c to call these inlined versions instead. Also fix comment headers for these functions in apc.c to match the official standard.
svn path=/trunk/; revision=24049
2006-09-11 00:26:17 +00:00
Alex Ionescu 38759195cb - We only need to update the page directory for the current stack, not the whole ETHREAD. (the page fault will be handled).
- Release dispatcher lock from DPC level in KiAttachProcess.
- Add missing decoration/assert to KeAttachProcess, and only acquire APC lock after we've made the invalid attach test. Also acquire dispatcher lock at DPC level here and in KeStackAttachProcess.
- Loop in KeUnStachDetachProcess to avoid the case where we acquired the APC lock while a kernel APC was pending. Keep releaing the loop and re-attemping acquire until it has been delivered.
- Add Decoration for *ServiceTable* functions.

svn path=/trunk/; revision=24048
2006-09-10 23:41:08 +00:00
Alex Ionescu d7ae142cf1 - KPROCSES Flags are LONG, not ULONG.
- Add some missing decoration.
- NUMA node semantics for KeInitializeProcess are only required on SMP builds.
- Allow KeInitailizeProcess to receive an argument specifying if alignment faults should be enabled or not.
- Use KiComputeIopmOffset to get the IopmOFfset instead of setting -1

svn path=/trunk/; revision=24047
2006-09-10 23:17:22 +00:00
Aleksey Bragin 5e7a9fc74e Create a place for some R&D work about booting Windows from inside of FreeLdr
svn path=/trunk/; revision=24046
2006-09-10 21:32:02 +00:00
Alex Ionescu faa5f58b84 - Remove KeGetCurrentProcess. This API doesn't exist.
- Add assertions to relevant functions in process.c and re-format some code.
- Check for invalid APC state in KeDetachProcess.
- Decrease process stack count while holding the Dispatcher Lock at DPC level.
- Implement KiSwapProcess in ctxswitch.S and add SMP-support and LDT swap support for the future, as well as updating the IOPM base in the TSS.

svn path=/trunk/; revision=24044
2006-09-10 20:23:02 +00:00
Aleksey Bragin 54a6548aa7 Fix inconsistent formatting and other trails of GreatLord's fixing
svn path=/trunk/; revision=24043
2006-09-10 20:12:16 +00:00
Saveliy Tretiakov 6a37552f9e implement NtGdiPathToRegion
svn path=/trunk/; revision=24042
2006-09-10 19:42:09 +00:00
Alex Ionescu 344fd08452 - No need to apply the ROS Page hack inside thread switching, since the process is the same.
svn path=/trunk/; revision=24041
2006-09-10 19:41:31 +00:00
Alex Ionescu ecb32725f7 - Add ASSERT_EVENT.
- Same changes to event.c as with the other files.
- Remove lock property, these files have already been audited as clean and were unlocked.

svn path=/trunk/; revision=24040
2006-09-10 19:14:03 +00:00
Alex Ionescu b5c8cf43e7 - Add ASSERT_MUTANT and ASSERT_SEMAPHORE to our DDK.
- Cleanup mutex.c and sem.c. No real code changes, just add ASSERTs, STDCALL->NTAPI, IN/OUT decoration.
- One change though, in KeReleaseMutant, use KeLeaveCriticalRegion instead of manually writing down the code, it's more readable this way.

svn path=/trunk/; revision=24039
2006-09-10 18:47:53 +00:00
Alex Ionescu da15ddafc8 - Get completely rid of old Dispatcher Lock macros and use new ones.
- apc.c -> Also multiple optimizations to use the APC lock instead of the full-fledged dispatcher lock.
- gate.c -> Use APC lock as well, the full dispatcher lock isn't required because a thread can only wait on one and only one gate.
- process.c -> Optimize the code to use the Process and/or APC lock instead of the dispatcher lock. Also delay acquiring the locks after some checks, to make the exit paths simpler.
- More fixes are teh needed.

svn path=/trunk/; revision=24038
2006-09-10 18:26:50 +00:00
Thomas Bluemel 63346a8dda Fix difference in signedness warning
svn path=/trunk/; revision=24037
2006-09-10 18:22:48 +00:00
Thomas Bluemel ac14f5a033 Fix LdrRelocateImageWithBias prototype: Strings in C are neither signed nor unsigned, and they are constants. Fixes warnings with GCC4
svn path=/trunk/; revision=24036
2006-09-10 17:16:59 +00:00
Alex Ionescu 4300e4effe - Update the last remaining old function, KeSetBasePriority. Use new locks and assertions, and also make use of KiComputeNewPriority.
svn path=/trunk/; revision=24035
2006-09-10 17:13:55 +00:00
Alex Ionescu 1ee6196a10 - Reposition and update KeQueryBasePriorityThread to use the new locks.
- Update KeSetAFfinityThread, KeSetPriorityThread with new locks and assertions (plus the current ROS scheduler hack).

svn path=/trunk/; revision=24034
2006-09-10 17:05:07 +00:00
Alex Ionescu 678df444b7 - Update KeRevertToUserAffinityThread, KeSetSystemAffinityThread to use new lock functions, and add code to support future scheduler.
- Update KeSetIdealProcessorThread to properly do Ideal CPU logic instead of blindgly setting it (most importantly, respect UserIdealProcessor and SystemAffinityActive seettings).

svn path=/trunk/; revision=24033
2006-09-10 16:55:03 +00:00
Alex Ionescu d3a7b531f3 - Re-organize all internal functions in 3 groups:
- 1) Utility (FindRightmost/LeftMost Set, etc)
   - 2) State (Alert, AlertResume, ForceResume, Freeze, Resume, Rundown, Start, Suspend, TestAlert)
   - 3) Un/Initialization (KeInitThread, KeInitializeThread, KeUninitThread).

svn path=/trunk/; revision=24032
2006-09-10 16:38:02 +00:00
Aleksey Bragin a9d0596841 - Add msvcrt linking where needed
- Change "rintf" unixism to ceil() and data conversion to integer type

svn path=/trunk/; revision=24031
2006-09-10 16:32:37 +00:00
Alex Ionescu af9e8a64e7 - Remove KeSetPreviousMode, KeDisableThreadApcQueueing.
- Stargint reorganizing some public functions to the bottom of the file.
- Don't hold lock during KeSetKernelStackSwapEnable.

svn path=/trunk/; revision=24030
2006-09-10 16:30:49 +00:00
Alex Ionescu 1b223aebfb - Implement KiAcquireProcessLock, KiReleaseProcessLock.
- Update KeFreezeAllThreads to use the Process and APC In-Stack Queued Spinlock.
- Update KeTerminateThread to use the Process Lock. Call KiRundownThread to cleanup the NPX thread. Add some assertions for Stack in/out-paging. Use KiSetThreadSwapBusy for proper SMP vs UP building.
- NUMA Node semantics in KeStartThread only need to be done for CONFIG_SMP builds, so #ifed them appropriately. Also made it use the Process In-Stack QSL.

svn path=/trunk/; revision=24029
2006-09-10 16:25:57 +00:00
Alex Ionescu e61739c38c - Fix definition of SYNCH_LEVEL.
- Implement KeAcquireInStackQueuedSpinLockRaiseToSynch for UP systems.
- Implement KiAcquireApcLock, KiAcquireApcLockAtDpcLevel, KiReleaseApcLock, KiReleaseApcLockFromDpcLevel.
- KeResumeThread, KeSuspendThread, KeAlertThread, KeForceResumeThread, KeTestAlertThread, KeAlertResumeThread are now the first to use the new APC In-Stack Queued Spinlock for sychronization.

svn path=/trunk/; revision=24028
2006-09-10 16:09:58 +00:00
Hervé Poussineau bd33d79025 Initialize MainResource and PagingIoResource fields in FSRTL_COMMON_FCB_HEADER structure
svn path=/trunk/; revision=24027
2006-09-10 15:58:29 +00:00
Hervé Poussineau 6702dd5240 Let mkhive use cmlib. "make install" now works and this let the livecd go further than before
svn path=/trunk/; revision=24026
2006-09-10 15:39:11 +00:00
Hervé Poussineau 2ca81c5573 Fix some warnings
svn path=/trunk/; revision=24025
2006-09-10 15:26:48 +00:00
Alex Ionescu aafcd436d5 - Thread Support cleanup 1: Separate kthread.c into thrdobj.c (Exported and globally accesible functions dealing with the KTHREAD object) and thrdschd.c (Fully internal thread scheduling routines for Ke* only).
- Also fix KeSetAffinityThread to return the old affinity, instead of NTSTATUS and move NtYieldExecution from Ps to Ke, and move NtDelayExecution to wait.c
- No code changes.

svn path=/trunk/; revision=24024
2006-09-10 15:23:20 +00:00
Aleksey Bragin f9b0ee1a03 vsnprintf -> _vsnprintf
svn path=/trunk/; revision=24023
2006-09-10 15:07:02 +00:00
Alex Ionescu d2cb3868b7 - Add some definitions to ketypes.h
- Fix multiple bugs in KTHREAD/KPROCESS where signed char values were marked as unsigned (and define SCHAR in ntdef.h)
- Change prototype of KiSwapThread for future compatibility.
- Fix prototype of KeSetIdealProcessorThread.
- Add KiAcquireDispatcherLock, KiReleaseDispatcherLock, KiAcquireDispatcherLockAtDpcLevel, KiReleaseDispatcherLockFromDpcLevel to ke_x.h for future use.
- Add KiInsertDeferredReadyList, KiRescheduleThread, KiSetThreadSwapBusy, KiRundownThread, KiCheckDeferredReadyList for future use.
- Add KiAcquirePrcbLock, KiReleasePrcbLock, KiAcquireThreadLock, KiReleaseThreadLock for future use.
- Add KxQueueReadyThread, KiSelectReadyThread for future use.
- Add KiComputeNewPriority for future use.

svn path=/trunk/; revision=24022
2006-09-10 14:43:12 +00:00
Aleksey Bragin 098292d473 These DPRINT1s are ONLY for Magnus' debuggin session.
Correcting his mistake of commiting them to the tree.

(taskmgr.exe should work again)

svn path=/trunk/; revision=24021
2006-09-10 14:23:13 +00:00
Aleksey Bragin b52f7b069b - Implement enable/disable of protection for PE sections in ntdll
- Finally get rid of duplicated relocation code in ntdll by using the relocate function from RTL and enable/disable protection
- Some improvements added to RTL's relocation function, it's split up into two functions now

svn path=/trunk/; revision=24020
2006-09-10 13:33:30 +00:00
Hervé Poussineau 65df8c2bad Revert part of r23972. Now we can boot again
(+ fix a little bug)

svn path=/trunk/; revision=24019
2006-09-10 10:26:58 +00:00
Aleksey Bragin a9bca34078 Dmitry Philippov: Fix GCC4 warning
svn path=/trunk/; revision=24018
2006-09-10 09:31:44 +00:00
Aleksey Bragin e90bd22c08 [AUDIT]
- Code duplication for relocation
- Widely documented PE loading algorithms
- Conclusion: clean

svn path=/trunk/; revision=24017
2006-09-10 08:35:30 +00:00
Aleksey Bragin 746299a0da - Move and slightly modify the relocation code to RTL, change its prototype so that it can be used in future in freeldr, ntdll and in kernel (right now there is code duplication, which is removed from kernel by this commit).
svn path=/trunk/; revision=24016
2006-09-10 08:00:57 +00:00
Hervé Poussineau 0fbf1539ac At last, enable screensaver
svn path=/trunk/; revision=24013
2006-09-10 02:22:12 +00:00
Hervé Poussineau 96bb2d5365 Add stub for SPI_GETSCREENSAVEACTIVE (which always return TRUE at the moment...)
svn path=/trunk/; revision=24012
2006-09-10 02:20:29 +00:00
Hervé Poussineau c965755754 Remove screensaver implementation of win32k (ie revert revision 22879).
svn path=/trunk/; revision=24011
2006-09-10 01:20:53 +00:00
Hervé Poussineau b61c75703c LastInputTick value should be in milliseconds, according to the help of GetTickCount in MSDN
svn path=/trunk/; revision=24010
2006-09-10 01:08:35 +00:00
Hervé Poussineau 54ad3ea87b Add missing entrypoint="0" directive in rbuild files [Part 2/2]
svn path=/trunk/; revision=24009
2006-09-09 22:55:57 +00:00
Hervé Poussineau ae5f6b945d Add missing entrypoint="0" directive in rbuild files [Part 1/2]
svn path=/trunk/; revision=24008
2006-09-09 22:33:07 +00:00