Commit graph

148 commits

Author SHA1 Message Date
Alex Ionescu 9522e0a02b [25 bug fixes]:
- 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
2007-01-18 09:44:49 +00:00
Alex Ionescu 14060f6c04 - Reimplement Process/Thread/Image notification callbacks by using the new executive lightweight callback implementation.
- Remove corresponding entry from kernel fun.

svn path=/trunk/; revision=25486
2007-01-16 15:09:53 +00:00
Alex Ionescu 1c15cd5161 - Fix _PsProcessType for MSVC compilation.
svn path=/trunk/; revision=25364
2007-01-08 07:42:38 +00:00
Alex Ionescu d83fcae7d1 - Forgot to actually initialize Dbgk during system initialization, so any API would crash.
- Fix some stupid bugs in NtCreateDebugObject.
- Add tracing framework and add tracing to all of debug.c.
- Dbgk *almost* works: http://www.tinykrnl.org/dbgworking.png. Here I attach to services.exe and the kernel is sending notifications for all threads and DLLs loaded.

svn path=/trunk/; revision=24981
2006-11-30 04:16:35 +00:00
Alex Ionescu 2a4049fdfc - Implement DbgkPostFakeThreadMessages.
- Add Dbgk-calls to NtMap/UnmapViewOfSection to nodify debugging services of new DLL image load.
- Dbgk support is now skeletally complete, I will write a simple test app to test some functionality and start finding/fixing bugs.

svn path=/trunk/; revision=24980
2006-11-30 01:57:25 +00:00
Alex Ionescu 1c3d0f91a1 - Argh, another forgotten file. Too many local changes :(
svn path=/trunk/; revision=24734
2006-11-12 22:37:52 +00:00
Alex Ionescu 9c4178c05b - Define DBGKM_APINUMBER
- Implement DbgkpSendApiMessageLpc, DbgkpSendApiMessage, DbgkCopyProcessDebugPort, DbgkForwardException, DbgkFreeDebugEvent, DbgpWakeTarget.
- Close original handle in DbgkOpenHandles.

svn path=/trunk/; revision=24575
2006-10-20 05:16:04 +00:00
Alex Ionescu 0d09a4e5f9 - Fixup DEBUG_OBJECT definition.
- Implement DbgkpCloseObject.
- Implement DbgkpOpenHandles.
- Fix various bugs in the code and flag usage.
- Enable calling DbgkClearProcessDebugObject when terminating a process.

svn path=/trunk/; revision=24574
2006-10-19 20:08:52 +00:00
Alex Ionescu 04c5f92621 - Combine SeInit1 and SeInit2 into SeInit since both can be done together now.
- Call PsInitSystem instead of PspInitPhase0, since PsInitsystem is the "external" phase-choosing routine.
- Implement ExComputeTickCountMultiplier to create a 24-bit precision remainder + whole integer of the ms/clock tick used in SharedUserData.
- Set the OS version and Machine Type (i386/PPC (<3 Arty) in SharedUserData.
- Move some HAL calls in Phase 2 (actually Phase 1...), same for KeInit2.
- Break into KDBG a bit earlier.

svn path=/trunk/; revision=24363
2006-10-02 15:52:58 +00:00
Alex Ionescu 2855e1f08f - Do MmInit1 in KiInitializeKernel so we can access SharedUserData from it (we'll need to setup the CPU Features there).
- Cleanup some external/prototype mess and put them nicely into headers.

svn path=/trunk/; revision=24351
2006-10-01 19:43:18 +00:00
Alex Ionescu bee17dc290 - Large cleanup of psmgr.c. Move all externs and prototype, into headers, reformat and re-arrange the code.
- Optimize PspLookupUserEntrypoints to use static ANSI_STRINGs instead of building them at runtime.
- Fix mapping/loading of the System DLL so that it's loaded as executable code, not read-only code. Also fix a handle leak of the section, and re-factor some code into smaller shared functions to reduce code duplication.

svn path=/trunk/; revision=24154
2006-09-17 05:20:24 +00:00
Alex Ionescu e6fd23de2c - 1>Build Time 0:04
1>ReactOS Kernel - 0 error(s), 253 warning(s)
- Add winerror.h to ps/win32.c so it can get the Win32 error definition it needs (winerror.h doesn't add any other nasty win32 headers, so this isn't really a header policy violation).
- Fix prototypes of KdEnableDebugger and KdDisableDebugger.
- Write one of the cleanest and most ingenious hacks I've ever come up with it, which bypasses the incompatibility of hard-coded WDK externals.

svn path=/trunk/; revision=23973
2006-09-07 22:38:06 +00:00
Alex Ionescu de6dc70c56 - Implement XP-style process name auditing to store the full name of the process in EPROCESS instead of only the first 16 ascii characters. This is required for one of the newer Info process classes. Implemented SeInitializeProcessAuditName and SeLocateProcessImageName.
- Remove #ifed out code in PspCreateProcess which was attempting to create the name structure. Add code to MmCreateProcessAddressSpace to initialize the audit name after the 16-byte name.
- Implement some helper APIs for better code refactoring.
- TODO: Get rid of PspGetImagePath and wrap around SeLocateProcessImageName instead.

svn path=/trunk/; revision=23303
2006-07-27 00:22:36 +00:00
Alex Ionescu 9b5a87cdac - Fix trace macro to print line number in decimal, not hex.
- Implement PspSetCrossThreadFlag and PspClearCrossThreadFlag and use them. Thanks to Thomas for the idea.
- Fix a bug in Fast Referencing, thanks to Thomas.

svn path=/trunk/; revision=23260
2006-07-23 21:38:31 +00:00
Alex Ionescu 251250ad96 - Temporarly disable screensaver code. Sorry greatlord but you're creating 150 realtime threads per minute and killing the system with the code. Please fix it.
- Fix some incorrect tracing macro usage and make it add the current line.
- Re-organize I/O bugs per priority.

svn path=/trunk/; revision=23256
2006-07-23 20:12:45 +00:00
Alex Ionescu 881a60f895 - Add tracing in process/thread.c as well.
- Add a new tracing class/macro for reference counts and add it in kill/process/thread.c.
- Remove tracing TODO from kernel fun.

svn path=/trunk/; revision=23254
2006-07-23 19:45:16 +00:00
Alex Ionescu 78ffb6aecc - Make use of PsChangeQuantumTable on system startup to setup the raw priority separation.
- Call PspComputeQuantumAndPriority in PspCreateProcess to calculate process base priority and quantum for child threads.
- Add security code to calculate process's access rights to itself, as documented in WI II.

svn path=/trunk/; revision=23248
2006-07-23 17:01:43 +00:00
Alex Ionescu a818a86bf9 - Fixup PSTRACE to print much nicer output and actually work.
- Add tracing for security.c and kill.c.

svn path=/trunk/; revision=23234
2006-07-23 07:13:19 +00:00
Alex Ionescu 90ea51a96b - ImperstionationLocale -> ImpersonationLocale.
- Implement PspWriteTebImpersonationInfo for setting the impersonation locale and impersonation status in the TEB (since User-mode needs to read this value and we don't want to NtQueryInformationThread for it each time to read the ETHERAD flag).
- Complete the implementation of PspSetPrimaryToken to recalculate a process's access rights to itself based on a new primary token.
- Reorganize ps.h header like ob.h and io.h, implement Tracing support but not the tracing itself yet.
- Get rid of some deprecated cruft.

svn path=/trunk/; revision=23233
2006-07-23 05:43:28 +00:00
Alex Ionescu db04986dce - Give winlogon SE_ASSIGNPRIMARYTOKEN_PRIVILEGE because it was lacking it and would fail under this kernel patch.
- PspAssignPrimaryToken was good enough for actually *assigning* the token, but when NtSetInfoProcess is called with ProcessPrimaryToken, we want to do a lot more then just randomly assigning it. Added PspSetPrimaryToken which first verifies if the token being assigned is a child token and if not, checks for SeAssignPrimaryTokenPrivilege. Also added a fixme for more code that's needed, to actually re-calculate the process's granted access towards itself. Also added thread-safety.

svn path=/trunk/; revision=23226
2006-07-22 16:03:12 +00:00
Alex Ionescu 2f2139d851 - Implement Kernel, Memory Manager and Process Manager APIs for the following concepts (not yet used):
- Process Quantum.
  - Fixed and Variable Quantum Tables.
  - Long and Short Quantum Variability.
  - Priority Separation and Separation Masks.
  - Foreground Quantum Table.
  - Process Priority, Priority Modes and Priority Classes.
  - Virtual Memory Priority
  - Job Scheduling Classes
- Implement PsSetProcessPriorityByClass.

svn path=/trunk/; revision=23214
2006-07-21 19:28:38 +00:00
Alex Ionescu e9600e4c9c - Add Pushlock support for GCC (Thanks Thomas!)
- Remove a bunch of deprecated crap from ps.h
- Get rid of PsLockProcess, PsUnlockProcess. Use the process pushlock instead.
- When assigning the job, only acquiring rundown protection is enough.
- Use interlocked intrinsics for setting the ExceptionPort instead of locking the entire process object.
- Disable locking in ProcessSessionInformation for NtSetInformationProcess. The whole API seems wrong anyway, on my XP machine calling it does not change the session or change any token data. To verify later...

svn path=/trunk/; revision=23197
2006-07-20 17:44:30 +00:00
Alex Ionescu a92681004e - Move a bunch of externs to ps.h and delete many dupped/tripped ones.
- Change FAST_MUTEX PsActiveProcessMutex to KGUARDED_MUTEX.
- Define PS Flags and use them, isntead of magic numbers. (For magic mushrooms, you'll have to wait a while, these aren't implemented yet).

svn path=/trunk/; revision=23194
2006-07-20 16:26:10 +00:00
Alex Ionescu 6cf95d5263 - Move ps/locale.c to ex/locale.c, since it has nothing to do with Process/Thread management (locale settings are part of the executive).
- Cleanup formatting in the file and add proper credits (Thomas and Eric).
- Create internal Exp* functions for Setting/Getting the user langid, since they need to be called 2, 3 times by other code and thus shared.
- Remove some deprecated code, make the functions themselves initialize the default ID when called for the first time (which should be done by winlogon --> it seems this isn't done yet?).
- Set default locale to 0x409 instead of 0x0.

svn path=/trunk/; revision=23133
2006-07-18 01:58:10 +00:00
Alex Ionescu a9bcf7b487 [AUDIT] - notify.c contains trivial (3 or 4 lines of code) implementations of adding a pointer to an array, and then looping said array and calling a pointer. Your grandmother could code this.
- Cleanup notify.c and fix the return value of PsSetCreateProcessNotifyRoutine.
- Create ps_x.h for inlined Ps routines and put the internal routines which call the registered callbacks in it.

svn path=/trunk/; revision=23131
2006-07-17 22:18:44 +00:00
Alex Ionescu f4539b7037 - Massive re-write of some parts of Ps, based on a patch I wrote almost a year ago and peer-reviewed with Thomas and Filip. Causes some shutdown regressions and process leaks (will fix). Needs more work. Changelog:
- Architectural changes to match information in Windows Internals 4 and other documented sources of information (Windows Internals II by Probert). Code should match Win2003 layout.
    - Handle almost any possible process/thread sub structure and add its cleanup code stubs, so that when we actually implement them, we won't forget to clean them up in the process code.
    - Add interlocked usage of process and thread flags in order to make everything more thread-safe.
    - Better handle cases where threads die instantly, race conditions, and other weird issues.
    - Better handle process termination and thread termination.
    - Implement NtCreateProcessEx and update PspCreateProcess/NtCreateProcess.
    - Improve cleanup of process object in PspProcessDelete.
    - Optimize some things like User Thread startup.
    - Add some extra asserts, paged_code checks and also user-mode security check.
    - Implement helper API PsGetNextProcessThread
    - Optimize thread reaper (thanks Filip)
    - Do proper referencing/dereferencing of thread/processes (thanks Thomas)
    - Document FIXMEs needed for Ps code to be up to standards and complete.

svn path=/trunk/; revision=22976
2006-07-09 18:54:13 +00:00
Alex Ionescu 19e2ef808c - Get rid of ROS_EPROCESS and all the ugly type-casting that was being done, now that the last two hacks make us able to compatibly use EPROCESS.
svn path=/trunk/; revision=21935
2006-05-18 20:32:17 +00:00
Alex Ionescu 7b3c313c1c - Use EPROCESS 's AddressCreationLock instead of the MADDRESS_SPACE Lock.
- Overlay MADDRES_SPACE over MM_AVL_NODE. Even though our structures are currently incompatible, they represent the same thing (The EPROCESS's Address space).

svn path=/trunk/; revision=21934
2006-05-18 20:10:44 +00:00
Alex Ionescu 93a0bb6787 - Use the Spare0 array, present in EPROCESS instead of ReactOS-specific members for Process Locking (temporary fix until pushlocks are used).
svn path=/trunk/; revision=21933
2006-05-18 18:55:38 +00:00
Alex Ionescu 8481c1fa10 - NDK 0.98, now with versionned headers. Too many changes to list, see the TinyKRNL SVN Logs for more detailed information. Thanks to Andrew (Wax), Thomas and Aleksey for testing.
svn path=/trunk/; revision=21880
2006-05-10 17:47:44 +00:00
Alex Ionescu 11272023e5 Part 1 of <many> ntoskrnl header cleanups
svn path=/trunk/; revision=17844
2005-09-13 23:28:21 +00:00
Alex Ionescu 3dac092c29 - Remove cid.c
- Do direct handle creation/deletion where needed.

svn path=/trunk/; revision=17182
2005-08-07 22:48:07 +00:00
Alex Ionescu 1bb6a5ce2c - Remove unused ldr/userldr.c
- Rename LdrLoadInitialProcess to Exp... and move to executive initialization.
- Removed ldr/init.c
- Renamed ldr/sysdll.c functions to Psp (correct naming) and deleted file.
- Renamed SystemDll... ntdll pointers to correct Ke names
- Use direct Ke names instead of going through an API call.
- Make ExpInit... functions STDCALL

svn path=/trunk/; revision=17053
2005-08-05 03:44:24 +00:00
Filip Navara 160b65f87e Setup quota blocks for processes.
svn path=/trunk/; revision=16943
2005-08-01 11:21:42 +00:00
Alex Ionescu 7669e8fd6d - Disable APC Queuing & Flush APC queues during thread shutdown.
- Detect if Kernel APCs were pending during thread shutdown.
 - Call Lego Routine, if registered, during thread shutdown.

svn path=/trunk/; revision=16705
2005-07-23 17:40:48 +00:00
Alex Ionescu c12e487549 build win32k with NDK, finally\!
svn path=/trunk/; revision=16271
2005-06-25 20:05:56 +00:00
Alex Ionescu deb7a80fdd Large partial cleanup of ntoskrnl internal headers, mostly to delete obsoleted or non-useful headers, to reformat some horrible tab, spaces, etc mixups, and to move to NDK some public structures and remove all the include headers so that the standard one can be added. Note the word partial, meaning more will come in order to fully fix the mess.
svn path=/trunk/; revision=16268
2005-06-25 17:01:17 +00:00
Alex Ionescu 95f0ca7fdb Build ntoskrnl with NDK, and don't use rosrtl
svn path=/trunk/; revision=16266
2005-06-25 14:04:56 +00:00
KJK::Hyperion 321df5d69c Partial merge from the ROX-U branch (various fixes for Visual C++ compilation, see logs for r16198 and r16208)
svn path=/trunk/; revision=16212
2005-06-21 23:42:58 +00:00
Alex Ionescu 428572a138 Move Exported functions away from internal/ke.h, move exported data from internal/ex.h, add internal structures to internal/ifs.h, include ntdddisk.h in internal/xhal.h for access to PDRIVE_LAYOUT_INFORMATION, remove DDK function from internal/nls.h, remove KTRAP_FRAME from internal/i386/ke.h, add some more temporary types to krnltypes.h, protect PNP_VETO_TYPE, move EVENT_TRACE_HEADER to DDK, guard disk.h properly, correct DRIVE_LAYOUT_INFORMATION typedef in DDK, add PNP_VETO_TYPE, NLSTABLEINFO, CPTABLEINFO, remove KDPC_DATA, PP_LOOKASIDE_LIST. remove PROCESSOR_POWER_STATE from ntpoapi, remove MAILSLOT_CREATE_PARAMETERS, NAMED_PIPE_CREATE_PARAMETERS, IO_COMPLETION_INFORMATION_CLASS, PAGEFAULT_HISTORY, SECTION_XXX_INFORMATION, RtlSelfRelativeToAbsoluteSD, ZwQuerySection/Object, ZwQuerySystemInformation, ZwSetInformationObject, ZwSetSystemInformation from IFS
svn path=/trunk/; revision=16072
2005-06-19 03:55:34 +00:00
Filip Navara 52f8761d3a Use W32API for NTOSKRNL.
svn path=/trunk/; revision=16053
2005-06-18 18:32:29 +00:00
Alex Ionescu 6b86cb4406 Fix build, clean up headers, add public stuff to public headers
svn path=/trunk/; revision=15326
2005-05-15 23:24:11 +00:00
Steven Edwards e4be245882 strip whitespace from end of lines
svn path=/trunk/; revision=15164
2005-05-09 01:38:29 +00:00
Thomas Bluemel 917fe293f6 more fixes for GCC4
svn path=/trunk/; revision=15110
2005-05-08 03:09:14 +00:00
Alex Ionescu 7ed5318927 Update ETHREAD to latest version.
svn path=/trunk/; revision=15068
2005-05-07 00:37:48 +00:00
Alex Ionescu 8c4f9d3417 Update EPROCESS to latest version. Basic Fast Referencing Stubs to allow Token access. Needs to be implemented. Use ActiveProcessLinks instead of ros-specific list.
svn path=/trunk/; revision=15065
2005-05-06 22:54:40 +00:00
Alex Ionescu 5267e6247e Update KPROCESS structure to latest version and document all its fields on the Wiki page. Move Kernel Structures to ke.h from ps.h, remove stuff from ntifs.h that shouldnt be there
svn path=/trunk/; revision=15027
2005-05-05 22:40:05 +00:00
Alex Ionescu 4b4d215e36 Thread Creation and Context Switching re-write, plus Idle/First Thread minimization attempt. Full changelog on ML, too large to post here
svn path=/trunk/; revision=14742
2005-04-22 12:52:25 +00:00
Alex Ionescu 610dd8e8bc Use official THREAD_STATE enumeration for thread states
svn path=/trunk/; revision=14671
2005-04-18 15:49:57 +00:00
Alex Ionescu 6733de66c9 Fix win32k
svn path=/trunk/; revision=14670
2005-04-18 14:56:52 +00:00