Compare commits

..

1018 Commits

Author SHA1 Message Date
Aleksey Bragin
6cb08c7fd3 - Move the last two items out from "unmaintained" thus restoring branches directory hierarchy.
- Delete "unmaintained" (it was a bad temporary solution after all).

svn path=/branches/cis/; revision=36848
2008-10-20 16:50:26 +00:00
Aleksey Bragin
bfb890a68d Move unmaintained stuff (cis, os2, rosky, vms, and msvc6) to a respective branch [01/02]
svn path=/branches/unmaintained/; revision=24496
2006-10-13 09:00:21 +00:00
Art Yerkes
a8e91f11af Fixen. Delete is still broken.
We now use BalancedRoot->Parent as the nil element and distinguish it from
the embedded element.
Fix null and root macros, assert macro and some other stuff.

svn path=/trunk/; revision=24495
2006-10-13 07:02:04 +00:00
Aleksey Bragin
20d422c02d - Fix a mistake in low memory pages allocation algorithm (commit-reviewers, where are you? :))
svn path=/trunk/; revision=24494
2006-10-12 20:46:07 +00:00
Hervé Poussineau
3dce4b0486 Read object security descriptors from .inf file. Apply them for registry keys and services and display a message for files
svn path=/trunk/; revision=24493
2006-10-12 09:01:16 +00:00
Hervé Poussineau
32ac32df07 Better stubs for RpcImpersonateClient and RpcRevertToSelf (taken from Wine)
svn path=/trunk/; revision=24492
2006-10-12 08:57:21 +00:00
Hervé Poussineau
cc0716b65d Send right security descriptor to InitializeObjectAttributes, so ntoskrnl won't fail
The code was working because we never tried to call RegCreateKeyEx with a security descriptor...

svn path=/trunk/; revision=24491
2006-10-11 23:11:59 +00:00
Hervé Poussineau
47ef13cf4a Replace incomplete and broken implementations of ConvertStringSecurityDescriptorToSecurityDescriptorW and ConvertStringSidToSidW by new ones
svn path=/trunk/; revision=24490
2006-10-11 22:14:05 +00:00
Hervé Poussineau
dc1d41df49 Add some definitions
svn path=/trunk/; revision=24489
2006-10-11 21:57:22 +00:00
Hervé Poussineau
a29de84b89 Don't try to signal init event, as it has been removed in r24413/24414
svn path=/trunk/; revision=24488
2006-10-11 18:25:22 +00:00
Thomas Bluemel
5cb6da33e5 Fixed InterlockedExchangeAdd
svn path=/trunk/; revision=24487
2006-10-11 17:41:42 +00:00
KJK::Hyperion
11962157c1 How could so much be so wrong in so little code is something future generations will forever ponder in vain. Fixed constraints on inline asm outputs for compare-exchange intrinsics
svn path=/trunk/; revision=24486
2006-10-11 16:07:45 +00:00
Thomas Bluemel
c0c399894e Some header upgrades
svn path=/trunk/; revision=24485
2006-10-11 11:44:40 +00:00
Thomas Bluemel
d395d0ad39 Fix polling of ShutdownNotify
svn path=/trunk/; revision=24484
2006-10-11 10:34:36 +00:00
Aleksey Bragin
e81472d5d0 - Add global var for keeping size of NLS data in pages
- Restructure memory-map building loop to create special descriptor for NLS data
- Fix a bug in memory-map building loop which lead to not covering last XXX pages of memory

svn path=/trunk/; revision=24483
2006-10-10 15:20:03 +00:00
Art Yerkes
79e9d9d8aa Added 'austin' AVL implementation and provide a binding for the AVL functions
in generictable.

Not tested, (but nothing relies on it yet).

Austin is
 Copyright (C) 2000 Kaz Kylheku <kaz@ashi.footprints.net>
 Copyright (C) 2000 Carl van Tast <vanTast@netway.at>

Copying, reuse and modification are permitted on liberal terms.

svn path=/trunk/; revision=24482
2006-10-10 12:31:16 +00:00
Aleksey Bragin
a8e5dde037 Add a stub to peloader.c
svn path=/trunk/; revision=24481
2006-10-10 10:42:07 +00:00
Aleksey Bragin
3bef467687 - Implement WinLdrLoadBootDrivers() / WinLdrLoadDeviceDriver() - to be able to load boot-time drivers
- Perform hardware detection in the beginning (I had to insert RegInitializeRegistry() hack because MachHwDetect initializes certain stuff in registry)
- Convert info from hwdetect to suitable form in LPB (code by Alex Ionescu, just moved/adapted). Debug routine added to output its contents.
- Move allocation memory for NlsData into "phase 0" (AllocateAndInitLPB)
- Fixed SystemRoot to be of a correct form (later will be autogenerated of course, now just for reference)

svn path=/trunk/; revision=24480
2006-10-10 10:38:45 +00:00
Filip Navara
493f953a0c Fix setting of SystemBootDevice and SystemStartOptions in registry.
Fix detection of MiniNT systems.

svn path=/trunk/; revision=24479
2006-10-10 00:22:04 +00:00
Filip Navara
7bbb81a0d4 Sort the key indexes in CM.
svn path=/trunk/; revision=24478
2006-10-09 23:43:06 +00:00
Hervé Poussineau
ca6e7110f5 - Start NetLogon service (lsass.exe)
- Fix lots of problems in error handling
- Some general cleanup

svn path=/trunk/; revision=24477
2006-10-09 19:19:28 +00:00
Hervé Poussineau
e16a26e1f2 Formatting and add a call to StartServiceCtrlDispatcher
svn path=/trunk/; revision=24476
2006-10-09 19:16:47 +00:00
Magnus Olsen
f86ee0a05c make our msvcrt bit more windows nt4/2000 compatible
do not link _i64toa and _i64tow to ntdll they are missing in windows nt4/windows 2000 ntdll. 

svn path=/trunk/; revision=24475
2006-10-09 18:42:24 +00:00
Magnus Olsen
80c28a9405 fixed so our taskmgr works in windows 2000
svn path=/trunk/; revision=24474
2006-10-09 18:01:56 +00:00
Thomas Bluemel
ca392ef651 Make sure the compiler doesn't optimize away writes to video memory
svn path=/trunk/; revision=24473
2006-10-09 16:37:27 +00:00
Thomas Bluemel
8a80403d2a Some portability fixes that address possible alignment issues. Read R. Chen's blog 10/06/06 for more information.
svn path=/trunk/; revision=24472
2006-10-09 15:09:50 +00:00
Aleksey Bragin
182fc37942 Revert r24430 changes (by Magnus Olsen) since they are incorrect (additionally confirmed by Filip Navara)
svn path=/trunk/; revision=24471
2006-10-09 15:02:33 +00:00
Thomas Bluemel
b79edc3b52 Fix compilation with GCC4
svn path=/trunk/; revision=24470
2006-10-09 14:59:10 +00:00
Thomas Bluemel
2600e04b68 Strings should be const char *. Fixes compilation with GCC4
svn path=/trunk/; revision=24469
2006-10-09 14:54:40 +00:00
Thomas Bluemel
b8dd6657bc Strings should be const char *. Fixes compilation with GCC4
svn path=/trunk/; revision=24468
2006-10-09 14:43:16 +00:00
Mindflyer
c255fa82a3 Change copyright to 1996-2006, because
a) our earliest version records show 1996
b) we are now in 2006

svn path=/trunk/; revision=24467
2006-10-09 12:37:03 +00:00
Aleksey Bragin
b6df2387ba Fix mkhive compiling by adding _NTSYSTEM_ define. This is needed after Thomas' fixes to headers.
svn path=/trunk/; revision=24466
2006-10-09 08:07:19 +00:00
Alex Ionescu
4ffb9d2c3e - Some misc changes to fix some of the 250+ warnings in the MSVC build.
svn path=/trunk/; revision=24465
2006-10-09 05:59:18 +00:00
Alex Ionescu
6951a4887c - Bootvid rewrite by Filip Navara (with some fixes by myself)
- HAL DMA enhancements by Filip Navara.
- CSRSS Console enhancements by Filip Navara.
- Win32k Primitive Queue/Input/Painting/Focus enhancements by Filip Navara.
- Other misc win32k/CSR bug fixes by Filip Navara.
- The new bootvid code has some bugs, but try out a GUI Boot!

svn path=/trunk/; revision=24464
2006-10-09 04:00:34 +00:00
Alex Ionescu
3012ee8072 - Initialize the registry in one shot, and allow it to fail and do the associated CONFIG_INIT_FAILED bugcheck.
- Initialize Io in one shot, with IoInitSystem.
- Locate the system DLL a bit later, since on the boot CD this creates a small incompatibility due to the wrong path being in use.

svn path=/trunk/; revision=24463
2006-10-09 01:16:28 +00:00
Alex Ionescu
b772538a22 - Add RtlInitEmptyAnsiString to DDK.
- Fix a pretty bad stack/memory corruption bug related to IoReassignSystemRoot.
- Combine IoInit2 and IoInit3 into IoInitSystem, and make it return a BOOLEAN, and handle error with the appropriate IO1_INIT_FAILED bugcheck. Will combine IoInit1 soon.

svn path=/trunk/; revision=24462
2006-10-08 23:46:26 +00:00
Alex Ionescu
2b1ade4723 - Remove InitSharedUserDataPage since this entire function is not needed anymore due to the recent ARC improvements.
- Call IoAssignDriverLetters with the proper parameters, and give it a chance to update the SystemRoot path (although our version doesn't yet do this).

svn path=/trunk/; revision=24461
2006-10-08 22:50:26 +00:00
Alex Ionescu
d4b5fef3d6 - Finalize ARC Boot changes:
* Rename IoCreateArcNames to IopCreateArcNames and set it to NTAPI, as well as pass the loader block as a parameter.
  * Reduce buffers to 128 bytes, since ARC Paths don't get longer then that.
  * Optimize stack usage by using a single ANSI_STRING instead of 3 or 4.
  * Optimize stack usage by using a single ansi buffer, not 2 or more.

svn path=/trunk/; revision=24458
2006-10-08 21:38:45 +00:00
Alex Ionescu
b5f79593de - Optimize IopApplyRosCdromArcHack by not searching for the second copy of ntoskrnl if we already found the first.
- Also optimize stack usage by only using an ANSI buffer instead of having another Unicode buffer and unicode strings. Saves 530 bytes of stack.

svn path=/trunk/; revision=24457
2006-10-08 21:16:20 +00:00
Alex Ionescu
5e214ceaa0 - Part 2.5 of ARC Boot changes. Re-factor IoCreateArcNames not to use a list-entry of detected disk from pool that gets looped and de-referenced, but instead use a simple loop which calls a function that gets disk information one-by-one (IopGetDiskInformation), so that it's used on the spot instead of allocated, linked, and retrieved later.
- Inline IopAssignArcNamesToDisk to reduce some stack size abuse and too much parameter shuffling.
- Stack use is still very inefficient, will fix next.

svn path=/trunk/; revision=24456
2006-10-08 21:09:00 +00:00
Thomas Bluemel
73c2dc5053 Some header fixes
svn path=/trunk/; revision=24454
2006-10-08 20:28:03 +00:00
Alex Ionescu
1047de88bf - Greatly simplify and optimize IoCreateArcNames by using ARC data from FreeLDR/NTLDR (now nearly 100% compatible!) instead of querying registry data (which FreeLdr had already set up, so we cached those values like ntldr does).
- Last step is to stop using a list of drives and pool allocated entries, to optimize memory usage and re-factor the code.

svn path=/trunk/; revision=24453
2006-10-08 19:59:53 +00:00
Alex Ionescu
c537eb20f2 - Have FreeLDR fill out ARC_DISK_SIGNATURE information for each detected disk, as it's filling the registry.
- Add code to KiRosFrldrLpbToLpb to convert this array to the official ARC_DISK_INFORMATION structure that contains LIST_ENTRYies for each ARC_DISK_SIGNATURE, and initialize the ArcDiskSignatureListHead.
- The end result will be that in the next patch we can remove a bunch of registry-reading code in IoCreateArcNames.

svn path=/trunk/; revision=24452
2006-10-08 19:34:16 +00:00
Alex Ionescu
7a1b73cf84 - Part 2 of ARC boot changes: Major modifications done to the existing code, as well as re-formatting and cleanup. Floppy ARC names are not created anymore (they don't exist), and CD-ROM ARC name is only created 1) when there is a boot CD and 2) only for the boot CD. This mimics NT functionality.
- Optimize some code paths, mostly by not querying the whole GET_DRIVE_GEOMETRY IRP twice and reducing some buffer usage. Also re-factor some code better into smaller functions.
- Document and work around currently FreeLDR incompatibility (lack of ARC_DISK_INFORMATION) data in LoaderBlock.

svn path=/trunk/; revision=24451
2006-10-08 16:58:03 +00:00
Aleksey Bragin
b234cb305e - Add dumping boot drivers list, remove unneded comment
- Implement WinLdrScanRegistry() (based on freeldr's already existing implementation) which searches for boot-loading drivers
- Implement WinLdrAddDriverToList() - it correctly fills an entry in the BootDriversList in LoaderParameterBlock

svn path=/trunk/; revision=24444
2006-10-08 10:06:06 +00:00
Aleksey Bragin
3c3080f16b - Add simple support functions to be able to use more RTL in FreeLdr
svn path=/trunk/; revision=24442
2006-10-08 08:54:44 +00:00
Alex Ionescu
6d262bb755 - Whoops, don't call IopReassignSystemRoot twice.
svn path=/trunk/; revision=24441
2006-10-08 07:59:30 +00:00
Alex Ionescu
66f4128216 - Part 1 of ARC boot cleanups/changes: Create a valid \\SystemRoot symbolic link as the system is booting, which points to the ARC name, then, once drivers have loaded, re-assign it to the proper NT Device name. Added proper security descriptors and flags to symbolic links, as well as proper bugchecks when required.
- Kept and cleaned up the ROS hack for CD-ROM boot.

svn path=/trunk/; revision=24440
2006-10-08 07:53:37 +00:00
Alex Ionescu
9307f32ce3 - More re-shuffling of initialization calls, including enabling access to the blue screen much much earlier (no point in doing it so late, but this change is not that useful since soon we'll have bootvid).
- Split Po init in two, so the early Po init (which we'll need to do eventually) doesn't depent on the later Po init (which uses a PnP notification which depends on the Io system).
- Make I/O initialize quite a bit later.

svn path=/trunk/; revision=24439
2006-10-08 04:47:26 +00:00
Alex Ionescu
4b00ba5d4d - Inline and make some slight correctiions to KiInitailizeSystemClock, since it's based on the Ex subsystem, not Ke. Add code for boot-time timezone bias, but currently disabled because I need to implement a function to read configuration registry data at startup.
- Improve Init bugchecks to give the exact module that failed. Add Kd initilization in the same block as the other subsystems.
- Rename and re-arrange some initlization calls.

svn path=/trunk/; revision=24438
2006-10-08 04:05:27 +00:00
Alex Ionescu
9088db842e - Stub LdrVerifyMappedImageMatchesChecksum.
- Separate locating the system DLL from initializing it.
- Implement split-phase PsInitSystem for Phase 0 and 1, and make system dll initialization as part of phase 1.
- Add MmVerifyImageIsOkForMpUse and MmCheckSystemImage to validate the system DLL.
- Add a separate bugcheck for each failure in PsLocateSystemDll, matching with the NT bugchecks that would occur.

svn path=/trunk/; revision=24437
2006-10-08 02:10:34 +00:00
Alex Ionescu
ebd9a573ec - In NTLDR boot, try to get the first kernel physical address from the loader entries.
- Fixup HAL's image base in the loader parameter block, since we load it at a different place then freeldr tells us.
- We've reached a dead end in NTLDR compatibility. Out memory manager initialization code makes some assumptions which are totally incompatible with the page table state that NTLDR gives us.

svn path=/trunk/; revision=24436
2006-10-08 00:04:03 +00:00
Alex Ionescu
378f64d047 - FreeLDR: Create the loader entry for ntoskrnl now that FreeLDR PE-loads it since last year. This lets us remove a large hack in ntoskrnl which was manually creating the entry and filling it in.
- Rename some LastKrnl... addresses into MmFreeLdr to easily identify them, and remove the need to use MmFreeLdrMemLower and MmFreeLdrPageDirectoryStart.
- Remove the static KERNEL_BASE definition based on a GCC-specific external. Everything now uses the actual module entry's saved base address.
- Fix a Ps Initialization hack and properly set the boot PDE.
- Add a hack for NTLDR's lack of MmFreeLdrMemHigher and MmFreeLdrPageDirectoryEnd.

svn path=/trunk/; revision=24435
2006-10-07 22:23:35 +00:00
Ged Murphy
f8fa7d16f8 move the string parsing routine into it's own function so it can be used with DeviceProblemWizard_RunDLL when required.
svn path=/trunk/; revision=24434
2006-10-07 15:02:43 +00:00
Ged Murphy
71bc38ca20 testing ros-diffs
svn path=/trunk/; revision=24433
2006-10-07 14:35:22 +00:00
Aleksey Bragin
a40bc5ff5f - Add structure for describing boot-loaded drivers
svn path=/trunk/; revision=24432
2006-10-07 13:07:25 +00:00
Alex Ionescu
b53f179583 - Fix calls to HvInitializeHive
svn path=/trunk/; revision=24431
2006-10-06 23:11:49 +00:00
Magnus Olsen
2db2156bb3 Fixed control apps windows, Let me known if it create any regress.
svn path=/trunk/; revision=24430
2006-10-06 21:59:42 +00:00
Aleksey Bragin
41c8741041 - Load and initialize in-memory registry
- Query NLS file names from registry instead of hardcoding
- Move loading of NLS data to WinLdrLoadAndScanSystemHive()

svn path=/trunk/; revision=24429
2006-10-06 21:20:36 +00:00
Alex Ionescu
e2295b6e85 - Fix calls to HvInitializeHive due to my last patch. Proof that Fireball doesn't properly test his commits... I broke Freeldr building before his commit, yet he commited it anyway even though freeldr couldn't build ;). Just kidding.
svn path=/trunk/; revision=24428
2006-10-06 20:52:50 +00:00
Aleksey Bragin
0b9fa0e21a - Make arc-path passed to the kernel look a bit more correct (still a hack of course)
- Add KdCom.dll loading along with ntoskrnl.exe and hal.dll
- Move registry-related code to a new file wlregistry.c
- WinLdrLoadAndScanSystemHive() is going to combine loading, initializing and parsing registry. NLS / OEM font data loading is marked with FIXMEs now, since it needs going into that routine (because registry tells the file names, not hardcoding them)

svn path=/trunk/; revision=24427
2006-10-06 20:28:55 +00:00
Alex Ionescu
9bfa61479f - Add PROFILE_ACPI_DOCKING_STATE.
- Fix HvInitialize definition to match more closely NT's since I need some of the extra parameters for the cm rewrite.
- Implement ExInitializePushLock and ExConvertPushLockSharedToExclusive macros.

svn path=/trunk/; revision=24426
2006-10-06 19:29:25 +00:00
Ged Murphy
6318f42ad0 fix a TCHAR brain lapse...
svn path=/trunk/; revision=24425
2006-10-06 17:10:57 +00:00
Ged Murphy
2380e7bb33 implemented DeviceProperties_RunDLLW and DeviceProperties_RunDLLA
svn path=/trunk/; revision=24424
2006-10-06 16:08:54 +00:00
Alex Ionescu
a4c366b659 - Add internal EX_CALLBACK Object to NDK. (Callback blocks are a new NT 5.2 kernel mechanism much like RunOncs blocks in Vista user-mode). They're managed by rundown protection and fast-referencing through interlocked calls to push/pop/sychrnonize system callbacks.
- Add ObOpenObjectByName to NDK, since this API is not documented in official headers.

svn path=/trunk/; revision=24422
2006-10-06 06:36:35 +00:00
Alex Ionescu
45d84c9668 - Guard some current cmlib includes against new cm branch
- Remove NTSYSAPI from NtBuildNumber definition in NDK.

svn path=/trunk/; revision=24416
2006-10-05 23:01:38 +00:00
Alex Ionescu
8859463623 - Remove SMSS's code for signaling the "init" event.
- Make ExpInitNls responsible for NLS initialization in Phase 0 as well, to clean up the code in ExpInitailizeExecutive a bit.
- Initialize the system time/clock in Phase 1, not in Phase 0.
- Do HAL Phase1 initialization as the first step in Phase 1 initialization, then initialize the system clock (since the HAL's RTC is now configured).
- Do Ob Phase 1 init in Phase 1 initialization, not in phase 0.
- Do Ke Phase 1 init after HAL, Ob and Ex phase 1 inits.
- Initialize NLS for Phase 1 after Ke Phase 1, instead of much later.

svn path=/trunk/; revision=24414
2006-10-05 16:38:58 +00:00
Alex Ionescu
093d1a3aba - Get rid of the completely convoluted way that Phase 1 initialization was being ended, with umpteen events and waits and timeouts all synchronized from user-mode and do a simple 5-second wait to determine if smss started OK or not.
- Promote the Phase 1 initialization thread by jumping directly into the zero-page thread, and remove manual zero-page thread initialization code since we simply jump into its main routine.
- 100 less lines of code :)

svn path=/trunk/; revision=24413
2006-10-05 16:14:28 +00:00
Alex Ionescu
eb8c705ce9 - Put all Phase 1 Ex* Initialization in ExpInitSystemPhase1 and clean up associated deprecated calls.
- Call ExpInitializePushLocks since we weren't doing this before.

svn path=/trunk/; revision=24412
2006-10-05 15:13:59 +00:00
Alex Ionescu
3f66fcf605 - Rewrite ExpLoadInitialProcess by inlining and simplifying what the call to RtlCreateProcsesParameters should do, and also create our own custom environment with the same arguments that NT's smss gets.
- This optimizes booting as well as gets use the differnet SESSIONY_INITIALIZATION_FAILED, where Y is a number representing which step of the process parameter/envieonment creation failed.

svn path=/trunk/; revision=24411
2006-10-05 14:49:20 +00:00
Aleksey Bragin
3727f8fc7d - Add #ifdef DEBUG / #endif to fix compile. FreeLdr's debug macros needs some improvement in the future...
svn path=/trunk/; revision=24410
2006-10-05 09:15:44 +00:00
Alex Ionescu
5162751ab3 - Use KeLoaderBlock for registry hive loading.
- Get rid of the CACHED_MODULE array and associated structures and stop using them, get rid of ParseAndCacheLoadedModules. Stop using KeLoadedModules and KeLoadedModuleCount outside of freeldr.c.
- Except for MmInit1, the kernel should now be totally isolated from FreeLDR-specific data.

svn path=/trunk/; revision=24409
2006-10-05 02:02:27 +00:00
Alex Ionescu
0bfcd77883 - Implement ExpInitNls to initialize the NLS Section using the new semantics recently implemented. Works pretty much like the previous code in rtl/nls.c except it uses the new variable names as well as maps a view of the NLS Table into the system process.c
- Delete rtl/nls.c and all the associated deprecated code.
- Do MmInit1 and SharedUserData stuff *after* initializing the initial thread, to avoid an ASSERT during bootup.

svn path=/trunk/; revision=24408
2006-10-05 01:44:54 +00:00
Ged Murphy
52d60b023b add a few more icons to the device imagelist
svn path=/trunk/; revision=24407
2006-10-04 22:29:18 +00:00
Christoph von Wittich
a387e6f9f8 -removed unused var
svn path=/trunk/; revision=24406
2006-10-04 22:06:00 +00:00
Aleksey Bragin
b103aa1ece - Add most needed memory-manipulating functions. Some places are really crappy (like WinLdrSetProcessorContext's IDT filling), will be fixed soon.
- FIXME: Since FreeLdr doesn't really keep track of which memory is of which type, this code has a massive hack for guessing the memory type, which is incorrect for future usage

svn path=/trunk/; revision=24405
2006-10-04 21:58:36 +00:00
Christoph von Wittich
a361366988 -support debugging of control panel applets
svn path=/trunk/; revision=24404
2006-10-04 21:47:43 +00:00
Christoph von Wittich
245dca159a -don't use GetLastError with Reg* functions
-remove @16 from def file (msvc doesn't like it)

svn path=/trunk/; revision=24403
2006-10-04 21:47:08 +00:00
Aleksey Bragin
602923e572 - Fix warning in winldr.c
- Implement WinLdrAllocateDataTableEntry() used for allocating and initializing the DTE
- Implement WinLdrLoadImage(), which uses LdrRelocateImageWithBias() from RTL, calling it with loader name "FLx86" (RTL should treat it differently -- ROS/WinLdr-specific behavior)

svn path=/trunk/; revision=24402
2006-10-04 21:36:56 +00:00
Aleksey Bragin
76abbb4423 - Remove some crap from the LoadAndBootWindows()
- Change debugging checkpoint to online-asm (all this is temporary), since any code after while(1){}; seems to be just optimized away by gcc
- Uncomment NDEBUG for now

svn path=/trunk/; revision=24401
2006-10-04 21:11:16 +00:00
Thomas Bluemel
32dcc834ed Fix broken resources
svn path=/trunk/; revision=24400
2006-10-04 19:55:53 +00:00
Ged Murphy
a595b4c7da add some overlay icons needed for devmgmt
svn path=/trunk/; revision=24399
2006-10-04 19:04:16 +00:00
Thomas Bluemel
948a1f9045 Fix almost the same bug in LdrGetProcedureAddress as in r24397
svn path=/trunk/; revision=24398
2006-10-04 18:46:57 +00:00
Thomas Bluemel
80da4a434c - Fix binary search algorithm in LdrGetProcedureAddress
- Fix temporary ntdll export hack (r24395)

svn path=/trunk/; revision=24397
2006-10-04 16:51:51 +00:00
Ged Murphy
7e6d549b19 - Open the device propsheet for child items (not parents as there isn't much point)
- Tag the Device ID onto the treeview items and provide functionality to tear it down
- Remove/change some code which wasn't needed to speed up opening time3
- We now have a pretty functional device manager. However it's heavily reliant on devmgr.dll, therefore functionality per device will rely on how complete this lib is.

svn path=/trunk/; revision=24396
2006-10-04 16:39:45 +00:00
Alex Ionescu
d0cb64ce3d - Implement XPSP2+ syscall stub that uses indirect pointer instead of executable code inside KUSER_SHARED_DATA.
- Someone (FILIP!) please fix LdrGetProcedureAddress. It's broken and I had to rename an ntdll export to make it work (see comments).
- Make sure you REBUILD CLEAN. This commit changes NCITool!!!
- Setup some NPX-related CPU features in SharedUserData during KiInitializeKernel.
- Remove some now-deprecated initialization functions.

svn path=/trunk/; revision=24395
2006-10-04 16:00:36 +00:00
Thomas Bluemel
48236aa642 Don't compile with -Wconversion since we have function callbacks that have parameters with sizes different from int without forward declarations. Fixes superfluous warnings.
svn path=/trunk/; revision=24394
2006-10-04 15:19:23 +00:00
Aleksey Bragin
778bad347c - Format code of InstallFatBootcodeToPartition(), changing from tabs+spaces mix to tabs only (use "ignore whitespaces" settings to view other changes)
- Change installation logic when installing to a NTLDR's boot.ini: Firstly freeldr.ini is checked for existence, and either created or updated, then boot.ini is checked for having a proper entry, and if needed - entry is added. Fixes related bugs (having more and more ReactOS entries, no entry added if freeldr.ini already exists in the root folder)

svn path=/trunk/; revision=24392
2006-10-04 12:26:12 +00:00
Magnus Olsen
41dea75354 this file some have forget set eol-style native
fixed

svn path=/trunk/; revision=24391
2006-10-04 10:59:01 +00:00
Magnus Olsen
07725072f3 1. move all languages file to own folder
2. fixed sub languages on allot languages rc files
3. add LMH1 Norwegian translations.

See issue #1698 for more details.

svn path=/trunk/; revision=24389
2006-10-04 06:58:03 +00:00
Alex Ionescu
38a5188c8e - Fix boot crash due to last patch, forgot that SharedUserDAta wasn't available yet.
svn path=/trunk/; revision=24388
2006-10-04 05:59:56 +00:00
Alex Ionescu
a6056d1fa9 - Fix KUSER_SHARED_DATA in winddk.h
- Scanfor NOEXECUTE/EXECUTE/OPTIN/OPTOUT/ALWAYSON/ALWAYSOFF load strings and set the appropriate NX policy in KUSER_SHARED_DATA as well as kernel CPU Feature flags.

svn path=/trunk/; revision=24387
2006-10-04 05:48:46 +00:00
Alex Ionescu
1e4f141555 - Add KF_XMMI64 feature flag for SSE2 and detect it.
- Detect Hyper-Threading and set Local APIC ID (put back Thomas's code that he added in an old revision and that I had accidentally removed and forgotten to re-convert into the new KiGetFeatureBits function).
- Add code to set the kernel MX Csr Mask in the FX Save Area.
- Startup the sysenter handler on the DPC stack.
- Detect and notify users with broken Pentiums.
- Do some NPX checks to forcefully disable any FPU flags that might be set (SSE, MMX, 3DNOW) if the NPX is disabled.

svn path=/trunk/; revision=24386
2006-10-04 05:29:30 +00:00
Alex Ionescu
917979cceb - Make Kernel initialization (KeInit2) portable/more complete. KeInit2 becomes KeInitSystem, the portable part, with a call to KiInitMachineDependent, the arch-specific part.
- Do all CPU configuration through IPIs and synchronize with potential multiple CPUs.
- Add mtrr.c and patpge.c for future support of MTRR, AMD K6 MTRR, PGE and PAT support, with initilization calls in each of them (which only print out a "Sorry" message).
- Add some stubbed code for extra initizliation to do later once some detection things are fixed.

svn path=/trunk/; revision=24385
2006-10-04 03:37:11 +00:00
Ged Murphy
ad0184614e update comctl32 to Wine-0.9.22 to get the new imagelist code.
svn path=/trunk/; revision=24384
2006-10-03 22:46:26 +00:00
Ged Murphy
2ef79f3efe add LPCDLGTEMPLATE definition
svn path=/trunk/; revision=24383
2006-10-03 22:43:46 +00:00
Ged Murphy
f1775cc055 fix processor display
svn path=/trunk/; revision=24382
2006-10-03 20:51:35 +00:00
Thomas Bluemel
99379a7e2c Fix warning
svn path=/trunk/; revision=24381
2006-10-03 20:04:39 +00:00
Ged Murphy
a2d3c5fe33 - Implement the context menu (mouse only at the moment) makeing it accessable when the cursor over the item only
- open the propsheet when double clicking child items
- make 'properties' bold

svn path=/trunk/; revision=24380
2006-10-03 19:55:15 +00:00
Hervé Poussineau
21dd51fc8b Copy i8042prt driver from 0.3.1 branch to trunk. Try #2
svn path=/trunk/; revision=24379
2006-10-03 18:04:03 +00:00
Hervé Poussineau
90b4dc09c7 Of course, I've added one level in directory structure in 24377. Delete the whole i8042prt driver and retry
(Sorry, this revision won't build)

svn path=/trunk/; revision=24378
2006-10-03 18:03:28 +00:00
Hervé Poussineau
273908b19f Copy i8042prt driver from 0.3.1 branch to trunk
svn path=/trunk/; revision=24377
2006-10-03 18:00:04 +00:00
Hervé Poussineau
b207566c12 Add back registry entries from i8042prt/kbdclass/mouclass
svn path=/trunk/; revision=24376
2006-10-03 17:57:29 +00:00
Thomas Bluemel
fd990e9ada Fix displaying Win32 errors (the Reg* APIs don't set the last error code!)
svn path=/trunk/; revision=24375
2006-10-03 17:02:36 +00:00
Thomas Bluemel
7b5fcdd9fa Fix displaying the size of the RAM
svn path=/trunk/; revision=24374
2006-10-03 16:25:13 +00:00
Hervé Poussineau
30189808bf Fix a few warnings
svn path=/trunk/; revision=24373
2006-10-03 14:28:21 +00:00
Ged Murphy
640d89daad set processor information in the sysdm control panel applet
svn path=/trunk/; revision=24372
2006-10-02 23:35:43 +00:00
Andrew Munger
2167cc7a61 Patch from ShadowFlare, bug 1838.
"The current implementation continues to register or unregister additional DLLs
that were specified, even if one of the earlier ones failed.  The behavior on
the Microsoft version is different; if one fails, it stops there instead of
continuing.  Some installers may possibly depend on this behavior."

svn path=/trunk/; revision=24371
2006-10-02 22:21:37 +00:00
Aleksey Bragin
835bb80157 - Add registry entry for usbdriver.sys's legacy loading. Commented out by default.
- Add usbdriver.sys to bootcd

svn path=/trunk/; revision=24370
2006-10-02 21:28:01 +00:00
Aleksey Bragin
903c277247 - Change CONNECT_DATA to DEV_CONNECT_DATA
- Add the last bit to the usb mouse driver to make it functional - recognition by mouclass.sys, and sending input data to it
- Misc small changes

Now USB mouse works in 2nd stage (you need to add usbdriver.sys as a legacy driver to the registry certainly)

TODO, but not of the top priority:
- Make unloading correct

svn path=/trunk/; revision=24369
2006-10-02 21:23:41 +00:00
Hervé Poussineau
c99914fdac Disable keyboard and mouse before checking the i8042 controller.
Flush queue before enabling them

svn path=/trunk/; revision=24368
2006-10-02 21:14:40 +00:00
Hervé Poussineau
3674f2ef32 Fix 2 typos (spotted by Fireball)
svn path=/trunk/; revision=24367
2006-10-02 19:36:14 +00:00
Ged Murphy
3193a5d7e9 - display system RAM on the general page.
- fixes bug 1835

svn path=/trunk/; revision=24366
2006-10-02 18:51:31 +00:00
Hervé Poussineau
b2aeafcad4 Implement CMP_WaitNoPendingInstallEvents
Wait for Pnp manager to finish its job before displaying the 2nd stage setup
Thanks Filip for his precious help on the umpnpmgr.exe side (not thread-safe as Single linked list functions are not implemented in ntdll)

svn path=/trunk/; revision=24365
2006-10-02 18:46:39 +00:00
Ged Murphy
4cfbdb6f63 - Only call SetupDiGetClassDevs once for each class, this makes load time 3 times faster although I'm still not happy with it. We may have to enumerate the drivers in the background.
- use UINT for 1 bit flags, reduce the width a little and check the menu.

svn path=/trunk/; revision=24364
2006-10-02 18:14:58 +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
06142d4e0d - Setup memory limits in shared user data.
- Loop security descriptors to find NLS data and make a copy of it in kernel pool, because the NLS buffer from NTLDR will be freed on NT. Also discovered a bug in Freeldr where it doesn't allocate ths NLS files sequentially, leaving a hole of 0x1000 between them. Added a hack to compensate (won't break NTLDR booting, just will waste 8KB of memory).
- Allocate the system call count table on checked builds.
- Refactor Ob/Se booting to match more closely NT, and so that we can do Se initialization in one shot.

svn path=/trunk/; revision=24362
2006-10-02 15:05:03 +00:00
Thomas Bluemel
62ac7ad5c9 Fix some warnings
svn path=/trunk/; revision=24361
2006-10-02 13:29:55 +00:00
Alex Ionescu
afa1de7c81 - Implement Phase 0 Ex initialization (Resource, Lookaside initialization) and generic Ex initialization routine.
- Clear the crypto exponent on boot-up.
- Set default global flags for checked builds.
- Set NtSystemRoot (SharedUserData) to C:<NT BOOT PATH> on startup.
- Cleanup lookas.c file and implement routines to initialize the system lookaside list in phase 0.

svn path=/trunk/; revision=24360
2006-10-02 13:23:03 +00:00
Thomas Bluemel
526efd2ee7 Define NTOSAPI before including ntddk.h to avoid including function prototypes with dllimport
svn path=/trunk/; revision=24359
2006-10-02 12:22:17 +00:00
Alex Ionescu
7fcf928e38 - Continue implementation of KiRosFrldrLpbToNtLpb by parsing the FreeLDR command line and:
* Removing the ARC Boot path and splitting it into the ARC Boot Device Name, the ARC HAL Device Name, and the NT Boot and HAL Path Names, saved in their respective LoaderBlock pointers.
  * Converting every slash to a space. ("/DEBUGPORT" -> " DEBUGPORT")
  * Now we can fully parse and read NTLDR command lines.
- Update various code in the kernel to:
  * Use LoaderBlock->ArcDeviceNamePath & friends instead of the command line.
  * Stop depending on slashes, and instead use strstr for parameters.

svn path=/trunk/; revision=24358
2006-10-02 05:40:36 +00:00
Aleksey Bragin
5c112af711 - Add a check to the boot.ini-changing code, to prevent creation of a new ReactOS entry after each installation.
svn path=/trunk/; revision=24356
2006-10-01 21:48:05 +00:00
Andrew Munger
e6adaebbce Resource sync from trunk.
Merged 24269, 24281, 24285, 24292, 24294-24295,
24298-24299, and 24303.

svn path=/branches/ros-branch-0_3_1/; revision=24355
2006-10-01 21:32:47 +00:00
Aleksey Bragin
5cf4352021 - Implement loading of NLS data, SYSTEM hive data (just simple loading into memory, without any kind of parsing or even checking if that data is correct)
- Add a function for creating a stub of hardware config (config consisting of only one node - root)
- Implement two steps of LPB initialization (names Phase 0 and Phase 1 are used internally by me, and doesn't correspond to anything)
- Implement a WinLdrSetupForNt, which allocates and initializes some specific structures (PCR, TSS, GDT, IDT)
- Respectively enable calls to these functions from LoadAndBootWindows()

svn path=/trunk/; revision=24354
2006-10-01 21:15:15 +00:00
Aleksey Bragin
eb998b4eaf - Comment out xbox memory detection for now (until fully switched to NT-style LPB)
- Fix HalpInitializePhase0() prototype
- Add halxbox back to build

svn path=/trunk/; revision=24353
2006-10-01 21:07:25 +00:00
Alex Ionescu
0c1b724e79 - Un-optimize KeGetPcr and make it use fs:20h instead of hard-coding the 0xFF.... address, because someone decided that ROS should have a different KPCR address then NT.
- This gets NTLDR working with ReactOS and I can boot all the way to MmInit1 (which fails due to missing KeMemoryMap & freeldr data).
- Serial port output works with DPRINT1 as well ;-)

svn path=/trunk/; revision=24352
2006-10-01 20:27:36 +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
Aleksey Bragin
3d9d36ccff - Add new type of debug print for windows loader
- Add address conversion routines for windows loader
- Add stubs for PE loading, memory operations
- Add some code to the LoadAndBootWindows()

Some notes:
- The windows loader is going to become some kind of a library in future, shared at least between freeldr and EFI loader.
- The code in windows loader is specific to i386 architecture for now, but I add it to the "freeldr_base". I better separate it a bit later, after discussion with arty (because I hardly want compatibility with loading windows on PPC).

svn path=/trunk/; revision=24350
2006-10-01 19:39:49 +00:00
Andrew Munger
b5dbaf9282 Merge the one line fix from 24273 v. 24276.
svn path=/branches/ros-branch-0_3_1/; revision=24349
2006-10-01 19:29:03 +00:00
Alex Ionescu
71e329a125 - Do MmInit1 much earlier in the boot phase (right at the beginning of ExpInitalizeExecutive). This gives us access to things like SharedUserData, which NT has since NTLDR. Will try moving it up even higher.
- Also move some ROS-specific/Freeldr hacks on top of the file so they'll be easier to remove later when needed.
- Fix a bug in ExInitPoolLookasidePointers which was making us overwrite low-memory.
- Initialize NLS tables during Phase 0, so that the associated APIs can work earlier.
- Bugcheck if HAL Phase 0 initialization failed, and force interrupts enabled after the HAL is ready.

svn path=/trunk/; revision=24348
2006-10-01 19:27:10 +00:00
Alex Ionescu
9f40202dfc - Add setupblk.h from TinyKRNL with all the definitions for NT's SETUPLDR structures (SETUP_LOADER_BLOCK and hardware configuration stuff). Update KiRosFrldrLpbToNtLpb to setup the Flags field of this block to "Text-Mode Setup Active" when we know that we're in ROS text mode.
- Update ExpInitializeExecutive to check for a valid setup block and detect text-mode and network installation modes. Use ExpInTextModeSetup instead of SetupMode variable, to make detection compatible with NTLDR.

svn path=/trunk/; revision=24347
2006-10-01 18:27:59 +00:00
Alex Ionescu
cbfbbdb7f1 - Implement ExpIsLoaderValid to validate the LOADER_PARAMETER_BLOCK's extension for the right size and version (we currently support 5.2 and over).
- Add code in KiRosFrldrLpbToNtLpb to setup a LOADER_PARAMETER_EXTENSION and set the right version and size.
- Initialize the per-CPU PRCB Paged/NPaged lookaslide pool lists.
- Add code to support application CPUs booting in ExpInitializeExecutive, and pass the loaderblock as a parameter.

svn path=/trunk/; revision=24346
2006-10-01 18:01:38 +00:00
Alex Ionescu
0adfdd1ace - Implement static compile-time assertions and use them for structure field checks. Thanks to Thomas and KJK.
svn path=/trunk/; revision=24345
2006-10-01 15:52:10 +00:00
Alex Ionescu
4f1804b0c0 - Use __readfsdword instead of de-referencing the Boot PCR, which is not queried for Application CPUs. (And put the Goto back where it was). Thanks to Thomas Weidenmueller for noticing.
svn path=/trunk/; revision=24344
2006-10-01 15:22:42 +00:00
KJK::Hyperion
41ecee90f7 Fixed:
- _InterlockedCompareExchange64 (more efficient handling of 64-bit operands)
 - __writecr0, __writecr3, __writecr4 (for real this time)

svn path=/trunk/; revision=24343
2006-10-01 14:49:07 +00:00
Thomas Bluemel
70da417c02 Fix usage of a uninitialized variable, unnecessary goto not replaced by a if(...) statement
svn path=/trunk/; revision=24342
2006-10-01 14:02:08 +00:00
Thomas Bluemel
d7978d0054 fix __writecr0, __writecr3 and __writecr4
svn path=/trunk/; revision=24341
2006-10-01 12:33:24 +00:00
Thomas Bluemel
408d13caaa Fix function name (fixes a redefinition error)
svn path=/trunk/; revision=24340
2006-10-01 12:19:36 +00:00
Hervé Poussineau
5895844509 Add ufatx.dll, to be able to create FATX (Xbox file system) partitions
svn path=/trunk/; revision=24339
2006-10-01 10:11:46 +00:00
Hervé Poussineau
72a9a3af12 Rewrite SetupDiGetClassImageListExW and SetupDiGetClassImageIndex which were completly wrong
Add stub for SetupDiDestroyClassImageList
Now, you can see some icons in device manager

svn path=/trunk/; revision=24338
2006-10-01 09:05:19 +00:00
Alex Ionescu
ebafbecc80 - Fix Ki386InitializeTss to use dynamic GDT calculated from KiGetMachineBootPointers instead of static internal address. Now NTLDR boots us all the way to HalInitializeProcessor.
svn path=/trunk/; revision=24337
2006-10-01 07:31:33 +00:00
Alex Ionescu
7c753a339a - Put IDT in RW .data section
- Fix Ki386InitializeTss to properly set Boot TSS descriptor data (set it to 32-bits). Also properly setup the DF/NMI Task Gates in the IDT.

svn path=/trunk/; revision=24336
2006-10-01 07:24:24 +00:00
Alex Ionescu
00564d63b7 - Clear KPCR->TEB during bootstrap as well.
- Use KPCR_PROCESSOR_NUMBER instead of 0x130.

svn path=/trunk/; revision=24335
2006-10-01 06:46:08 +00:00
Alex Ionescu
aebf830821 - Add two more lines in boot.S which detect boot-by-NTLDR and jump into KiSystemService (I thought FreeLdr didn't use the entrypoint, but it looks like it does, so this hack is needed). Detection is done by checking for the high bit in the PLOADER_PARAMETER_BLOCK pointer, which will be set on NT.
- Fix a double bug in KiSystemStartup. First, we were setting KPCR->Number instead of KPRCB->Number. Second, we were using KeGetPcr instead of __writefsdword. It worked on ROS because KeGetPcr is hard-coded to ROS's KPCR buffer.

svn path=/trunk/; revision=24334
2006-10-01 06:43:26 +00:00
Alex Ionescu
790760dcf4 - Remove all the remaining code in boot.S and make KiRosPrepareForSystemStartup fastcall. Now NtProcessStartup just does a jmp to KiRosPrepareForSystemStartup without any other code.
- Use freeldr's stack during all of freeldr.c, and only switch to the boot stack in KiSystemStartup before calling KiInitializeKernel. This is what NT does as well (it piggybacks on NTLDR's stack until then). This allowed us to clean boot.S and now we can boot from NTLDR properly.

svn path=/trunk/; revision=24333
2006-10-01 06:08:05 +00:00
Alex Ionescu
380f89c205 - Fully use KeLoaderBlock->InLoadOrderListHead for driver loading and symbol lookups, instead of KeLoaderModules/KeLoaderModuleCount. Still not 100% compatible with NTLDR (since it uses BootDriverListHead with a special structure), but much closer to a portable design that doesn't rely on static kernel data.
- Change some internal functions to use UNICODE_STRING instead of PCHAR since this is how LdrEntry->BaseDllName is, and also it's closer to NT Design.

svn path=/trunk/; revision=24331
2006-10-01 05:05:57 +00:00
Andrew Munger
32b3c2fdf9 WaxDragon curses BrandonTurner.
svn path=/branches/ros-branch-0_3_1/; revision=24330
2006-10-01 04:57:50 +00:00
Andrew Munger
786ac12c99 Oops. I forgot the branch has a config.rbuild...
svn path=/branches/ros-branch-0_3_1/; revision=24329
2006-10-01 04:47:34 +00:00
Andrew Munger
550317611d Sync win32k and gdi32_winetest from trunk.
Merged 24228-24229, 24231, 24234-24239,
24255-24257, 24260-24264, 24266-24268,
24270-24271, 24287-24288.

svn path=/branches/ros-branch-0_3_1/; revision=24328
2006-10-01 04:37:32 +00:00
Hervé Poussineau
fbe45c7180 Give enough space to retrieve full device class description
svn path=/trunk/; revision=24326
2006-09-30 23:37:44 +00:00
KJK::Hyperion
ae3c3041f4 Fixes to un-break trunk:
* Disabling XBox HAL for now (TEMPORARY MEASURE)
 * Port MP HAL to the new loader structures

svn path=/trunk/; revision=24325
2006-09-30 23:35:17 +00:00
Hervé Poussineau
7227204f68 Better resources handling in serial driver.
All: copy lower device flags to FDO. This prevents the serial mouse to use buffered I/O

svn path=/trunk/; revision=24324
2006-09-30 23:06:51 +00:00
Hervé Poussineau
b606a6771c Do not expect a call to AddDevice with a NULL Pdo. Those are not guaranteed
svn path=/trunk/; revision=24323
2006-09-30 22:41:23 +00:00
Hervé Poussineau
3f47783c54 Implement SetupDiGetDriverInstallParamsW
Add support for DI_FLAGSEX_INSTALLEDDRIVER

svn path=/trunk/; revision=24322
2006-09-30 20:42:47 +00:00
Hervé Poussineau
b0e0c40c5d i8042prt manages PS/2 ports, not PS/2 devices. Take it into account when browsing devices detected by freeldr.
svn path=/trunk/; revision=24321
2006-09-30 19:09:10 +00:00
Hervé Poussineau
c1e52bcfca Fix wrong default registry value, which was possibly leading to non PS/2 keyboard detection at startup
svn path=/trunk/; revision=24320
2006-09-30 17:26:31 +00:00
Thomas Bluemel
41f18c74da Recalculate property sheet sizes after adding/removing sheets.
svn path=/trunk/; revision=24319
2006-09-30 16:31:35 +00:00
Alex Ionescu
c25e3321b0 - Complete much more of KiRosFrldrLpbtoNtLpb. We now:
- Create a LDR_DATA_TABLE entry for each module (driver, hal, kernel) and properly fill it out and insert it into the loader block.
  - Use the NLS data block to hold pointers to the NLS tables.
  - Use the ->RegistryBase/Length loader block members to hold pointers to the SYSTEM hive.
  - Create a MEMORY_ALLOCATION_DESCRIPTOR for each type of memory currently used (LoaderNlsData, LoaderRegistrydata, LoaderSystemCode, LoaderHalCode, LoaderBootDriver).
  - Changes are currently UNUSED!
- Revert LOADER_PARAMETER_BLOCK change, it actually really is PNLS_DATA_BLOCK.

svn path=/trunk/; revision=24318
2006-09-30 16:04:23 +00:00
Alex Ionescu
13ccbc28b2 - Re-remove intrinics from winddk.h
- Fix a typo in LOADER_PARAMETER_BLOCK

svn path=/trunk/; revision=24317
2006-09-30 14:57:30 +00:00
Magnus Olsen
10bd13604b adding back __readcr4 and __readcr3 to winddk.h for gcc does not have it. come bit futer build trunk
svn path=/trunk/; revision=24316
2006-09-30 14:43:41 +00:00
KJK::Hyperion
52fb2adb7c Corrected DWORD operand typo (%l -> %k)
svn path=/trunk/; revision=24315
2006-09-30 14:40:12 +00:00
Thomas Bluemel
b1a25bba1d Fix GCC4 warnings
svn path=/trunk/; revision=24314
2006-09-30 11:54:37 +00:00
Magnus Olsen
767b7de159 hopply this will fix hal_xbox build not tested.
svn path=/trunk/; revision=24313
2006-09-30 11:33:21 +00:00
Magnus Olsen
ce35dd9b7b fix build of blue again gcc does not have _disable and _enable, but MSVC have it.
svn path=/trunk/; revision=24312
2006-09-30 10:52:41 +00:00
Ged Murphy
c3a99cfb3e implement refresh, although it runs at a snails pace until the multiple SetupDiGetClassDevs call issue is fixed
svn path=/trunk/; revision=24311
2006-09-30 10:39:36 +00:00
Ged Murphy
c2e551ecea stop icon from changing when selected.
This change doesn't seem quite right to me, but it works for now

svn path=/trunk/; revision=24310
2006-09-30 10:31:28 +00:00
Ged Murphy
f8df38ff88 add a line at the root of the tree for user ergonomics :)
svn path=/trunk/; revision=24309
2006-09-30 10:18:04 +00:00
Alex Ionescu
540d96660c - Save processor state in the PKPRCB in KiInitializeKernel.
- Set the booting CPU as idle if no next thread was scheduled.
- Raise IRQL to HIGH_LEVEL upon exiting KiInitializeKernel to match the re-lowering to DISPATCH_LEVEL in KiSystemStartup (and subsequent interrupt flush).

svn path=/trunk/; revision=24308
2006-09-30 07:04:49 +00:00
Alex Ionescu
f516d2846e - Add loop around the KiFreezeExecutionLock before continuing OS boot.
- Only check for break-in on the Boot CPU.
- Set priority to 0 *Before* lowering to DISPATCH_LEVEL.
- Also force interrupts to be enabled before lowering IRQL.
- Also set the idle thread's wait irql to DISPATCH_LEVEL (might fix some odd crashes) and set it as Running on UP builds (on SMP builds this is done in other code).

svn path=/trunk/; revision=24307
2006-09-30 06:18:45 +00:00
Alex Ionescu
eb0f964be3 - Fix some bugs in intrin.h (missing __inline__ statments in some locations, which were causing warnings due to "static").
- Remove intrinsics in winddk.h since they're now properly done in intrin.h (thanks KJK!!!)
- Make freeldr.c setup the boot KTSS like NTLDR does, so that the GDT entry for it is valid (and remove the code that was doing this from Ki386InitializeTss)
- Refactor KiSystemStartup to use 100% dynamic pointers and machine data queried from the Loader Block or actual GDT/IDT/Selectors in memory, isntead of hard-coded ntoskrnl offsets. This makes it possible to be loaded by NTLDR, which sets these system structures up by itself. (we do it in freeldr.c, as hacks).

svn path=/trunk/; revision=24306
2006-09-30 05:42:22 +00:00
Alex Ionescu
8b1ba6c11a - Use LOADER_PARAMETER_BLOCK everywhere in ReactOS except freeldr.c
- Implemented KiRosFrldrLpbtoNtLpb to do a lightweight conversion and setup. Next patches will try to get rid of PLOADER_MODULE and use LDR_DATA_TABLE_ENTRY as well as increase bootstrap compatibility.

svn path=/trunk/; revision=24305
2006-09-30 03:33:50 +00:00
Andrew Munger
723627e679 Merge 24208, 24236, 24242, and 24259 from trunk. LiveCD fixes.
svn path=/branches/ros-branch-0_3_1/; revision=24304
2006-09-30 02:54:20 +00:00
Ged Murphy
79e7a43785 - update french timedate resource file
- patch by Sylvain Petreolle

svn path=/trunk/; revision=24303
2006-09-29 18:04:15 +00:00
Aleksey Bragin
cad356e2d8 Add devmgmt to the build system, thus fixing make bootcd
svn path=/trunk/; revision=24302
2006-09-29 17:57:20 +00:00
Ged Murphy
1533a93526 add devmgmt.exe as it's usable in ROS now
svn path=/trunk/; revision=24301
2006-09-29 17:34:50 +00:00
Aleksey Bragin
b652b371db - Implement device creating, with the specified DeviceExtension
- Add stub for processing IRPs sent to the mouse driver

TODO (will be done once problem with load-order will be resolved):
- Store mouclass's callback address
- Actually call it thus making driver working
- Cleanup routines

svn path=/trunk/; revision=24300
2006-09-29 17:07:48 +00:00
Ged Murphy
c89da0aef0 there's always one that gets away ...
svn path=/trunk/; revision=24299
2006-09-29 17:07:17 +00:00
Ged Murphy
db3ddf3123 - Add the device imagelist icons to setupapi.
- It appears SetupDiGetClassImageListExW will need some work before these are usable though.

svn path=/trunk/; revision=24298
2006-09-29 16:56:24 +00:00
Ged Murphy
91b9b125db - fix the treeview so it displays parent and child devices
- display the device icons for each item
- other bits and bats I'm too lazy to list
- it still load slowly due to multiple calls to SetupDiGetClassDevs. Need to think of a better way of gathering the info. For now though, it works.

svn path=/trunk/; revision=24297
2006-09-29 16:38:38 +00:00
Aleksey Bragin
4da7594216 - Change in CONNECT_DATA for drivers so that they get direct pointer to the raw configuration data returned by the device
- Spelling fixes
- More debug prints added to ease debugging
- Added entries for mouse and keyboard drivers (keyboard is currently commented out)
- Implemented actual usb mouse driver - contains 1 hack aimed to correct determining the endpoint. Driver fully works except for actually sending data to win32k/HID driver stack

svn path=/trunk/; revision=24296
2006-09-29 09:08:20 +00:00
Ged Murphy
1d1b74fa19 change run icon as a few people wanted something more fitting and add 2 more icons to the system imagelist
svn path=/trunk/; revision=24295
2006-09-28 22:57:09 +00:00
Ged Murphy
cc033012dd new timedate and powercfg icons
svn path=/trunk/; revision=24294
2006-09-28 22:14:00 +00:00
Ged Murphy
c31fb83895 rename folder to make it clear
svn path=/trunk/; revision=24293
2006-09-28 22:03:03 +00:00
Ged Murphy
0d942e1cef fix the floppy icons and add 2 new ones for network drives.
svn path=/trunk/; revision=24292
2006-09-28 22:01:07 +00:00
Ged Murphy
4aa949d1df - Reserve enough space on the heap to store the GUID
- Thanks to Thomas for restoring my sanity

svn path=/trunk/; revision=24291
2006-09-28 21:36:12 +00:00
Ged Murphy
afcf1f7b14 clean up irregularities
svn path=/trunk/; revision=24290
2006-09-28 21:15:51 +00:00
Ged Murphy
7c67a5ec0d Initial development of a devmgmt.msc clone.
Unusable at the moment though.

svn path=/trunk/; revision=24289
2006-09-28 20:05:17 +00:00
Magnus Olsen
2e3507e05d NtGdiCreateDIBitmap
fixed 2 more hiden bugs (cause some crash/bsod) but not the bug I am searching for. 

svn path=/trunk/; revision=24288
2006-09-28 19:08:07 +00:00
Magnus Olsen
9e939c11e9 fix a hidden bug in IntCreateBitmapIndirect
svn path=/trunk/; revision=24287
2006-09-28 18:32:09 +00:00
Hervé Poussineau
eeef3f67ba Support mount manager in disk.sys
svn path=/trunk/; revision=24286
2006-09-28 16:33:12 +00:00
Ged Murphy
c191e989a6 update a few cpl icons
svn path=/trunk/; revision=24285
2006-09-27 22:40:18 +00:00
Magnus Olsen
86e57e8c93 hpoussin forget change this regkey to SOFTWARE\\Microsoft\\WindowsNT\\CurrentVersion\\Winlogon"
svn path=/trunk/; revision=24284
2006-09-27 17:30:08 +00:00
Thomas Bluemel
28d82c0229 Don't use BOOL for 1 bit flags because it's signed.
svn path=/trunk/; revision=24283
2006-09-27 12:43:50 +00:00
Thomas Bluemel
87099f3ca6 Move the memory in RtlpDeleteData instead of copying it because the source and destination may be overlapping.
svn path=/trunk/; revision=24282
2006-09-27 12:28:25 +00:00
Hervé Poussineau
fa9c62c9a0 Patch by Matthias Kupfer
Fix tiny typo in all rc-files "%" -> "%s"
See issue #1828 for more details.

svn path=/trunk/; revision=24281
2006-09-26 21:08:11 +00:00
Hervé Poussineau
36032a956d Fix format build.
Why dependency tracking didn't detect this problem? Another mystery...

svn path=/trunk/; revision=24280
2006-09-26 19:52:55 +00:00
Hervé Poussineau
2c56c7d7e8 Merge from Wine:
Frank Richter <frank.richter@gmail.com>
setupapi: Duplicate behaviour of native SetupGetInfInformation with NULL ReturnBuffer and certain ReturnBufferSizes.

svn path=/trunk/; revision=24279
2006-09-26 19:44:17 +00:00
Hervé Poussineau
21ff1ddb3d Fix some warnings in winlogon code
Change winlogon registry key to "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" for compatibility reasons, as some programs read it directly

svn path=/trunk/; revision=24278
2006-09-26 19:18:02 +00:00
Hervé Poussineau
572541f16a Two more constants found in FMIFS...
svn path=/trunk/; revision=24277
2006-09-26 19:12:39 +00:00
Alex Ionescu
54403619f8 - In some far, far away galaxy, a long, long time ago, Greatlord will learn to fix 1-line bugs and/or talk to the developers responsible instead of reverting their code...until then....
svn path=/trunk/; revision=24276
2006-09-26 05:29:46 +00:00
Magnus Olsen
7a0843f8af fixed overlaping memory problem with RtlMoveMemory. The rewrite of RtlMoveMemory did not handling overlaping memory. it shows with ntdll_winetest rtl, use the old asm version from the string.a instead
svn path=/trunk/; revision=24273
2006-09-25 23:46:32 +00:00
Magnus Olsen
b3f30cb100 restore files mem.c and memgen.c
restore no i386 arch define in rbuild
do not remove it, it is for build on no i386 platform
the was accident delete in r23830 

svn path=/trunk/; revision=24272
2006-09-25 23:26:08 +00:00
Magnus Olsen
56c76b3069 NtGdiSetViewportExtEx
fix a bsd by moving in some value to seh last
 we can run gdi32_winetest mapping without bsd

svn path=/trunk/; revision=24271
2006-09-25 21:28:09 +00:00
Magnus Olsen
4c2f6e8647 implement PEN_GetObject, we can now get pen from GetopjectType. and manger pass some new wine test
svn path=/trunk/; revision=24270
2006-09-25 20:12:43 +00:00
Johannes Anderwald
ff8121c676 * fix typo in german resource file spotted by pilic
* fix bug 1797
* set svn-eolstyle:native property
See issue #1797 for more details.

svn path=/trunk/; revision=24269
2006-09-25 19:28:40 +00:00
Magnus Olsen
888f16ea6f NtGdiRestoreDC
1. fix do not delete all hdc and the restore hdc. 
2. fix calc of SaveLevel the calc are not perfect

we only have 6 fails when we try restore dc now with wine gdi32 test dc 

svn path=/trunk/; revision=24268
2006-09-25 18:50:40 +00:00
Saveliy Tretiakov
b79a852fe5 - PATH_RoundRect from wine
- RtlCopyMemory -> memcpy


svn path=/trunk/; revision=24267
2006-09-25 08:06:20 +00:00
Magnus Olsen
604ab3e4c0 Fixed some bugs in win32k function BITMAP_GetObject.
svn path=/trunk/; revision=24266
2006-09-25 05:25:11 +00:00
Magnus Olsen
6f10b47b94 update winetest gdi32 with more wine test
svn path=/trunk/; revision=24264
2006-09-24 22:27:00 +00:00
Magnus Olsen
2b9e96e558 fixed another build break by me :(
svn path=/trunk/; revision=24263
2006-09-24 21:17:31 +00:00
Magnus Olsen
08256d0670 sorry I broken the build it fixed now
svn path=/trunk/; revision=24262
2006-09-24 21:10:36 +00:00
Magnus Olsen
9b6f293ce5 adding more missing struct need them later in winetest
svn path=/trunk/; revision=24261
2006-09-24 20:53:47 +00:00
Magnus Olsen
235dd5fe2b adding more missing struct
svn path=/trunk/; revision=24260
2006-09-24 20:28:57 +00:00
Art Yerkes
350e281e1c Fix use of unicode for unix host regardless of -fshort-wchar.
svn path=/trunk/; revision=24259
2006-09-24 20:14:44 +00:00
KJK::Hyperion
29b494be56 Cosmetic changes
svn path=/trunk/; revision=24258
2006-09-24 18:07:21 +00:00
Saveliy Tretiakov
2047460d02 memcpy -> RtlCopyMemory
assert -> ASSERT


svn path=/trunk/; revision=24257
2006-09-24 17:10:58 +00:00
Saveliy Tretiakov
a5b535fee4 - Implement NtGdiStrokePath and NtGdiStrokeAndFillPath (based on wine)
- Get rid of PATH_GetPathFromDc()


svn path=/trunk/; revision=24256
2006-09-24 17:02:29 +00:00
Saveliy Tretiakov
a04da34bc0 More prototypes
svn path=/trunk/; revision=24255
2006-09-24 17:01:46 +00:00
Hervé Poussineau
f1d365f767 Don't hardcode the list of available filesystems in fmifs.dll, but store it in the registry.
Adding a filesystem is now only a matter of creating a u{FS}.dll + one registry entry to be able to use normal format.exe/chkdsk.exe/...

svn path=/trunk/; revision=24254
2006-09-24 13:42:24 +00:00
Hervé Poussineau
9cea0fddde Display available file systems in usage screen
svn path=/trunk/; revision=24253
2006-09-24 12:50:51 +00:00
Hervé Poussineau
c492ac0ccc Implement QueryAvailableFileSystemFormat and SetLabel in fmifs.dll
Fix a few prototypes

svn path=/trunk/; revision=24252
2006-09-24 11:55:58 +00:00
Hervé Poussineau
e84a6d47b1 [FORMATTING] Replace spaces by tabs
svn path=/trunk/; revision=24251
2006-09-24 11:08:27 +00:00
Hervé Poussineau
7c4cca9870 Add a filter command in KDBG, which is a wrapper around NtSetDebugFilterState/NtSetDebugFilterState.
svn path=/trunk/; revision=24250
2006-09-24 10:39:43 +00:00
Magnus Olsen
595ffab596 Update some gdi32 winetest
svn path=/trunk/; revision=24249
2006-09-24 09:43:16 +00:00
Magnus Olsen
9e99515740 adding two more missing define
svn path=/trunk/; revision=24248
2006-09-24 09:41:28 +00:00
Magnus Olsen
9f553707a1 adding OBJ_COLORSPACE it was missing, need it soon
svn path=/trunk/; revision=24247
2006-09-24 09:24:23 +00:00
Magnus Olsen
7f9492fc2f tested in dib16
Fixed all wine test for brush, zero fualt now
passing all 32 test fine. 
gdi32 bitmap test only 7 fails now

svn path=/trunk/; revision=24246
2006-09-24 08:36:56 +00:00
Hervé Poussineau
2abe11c82a Revert r24233, which leads to have the header written too late in debug log and was preventing a crash during the first DbgPrint calls when using GDB
Replace it by another fix (not tested)

svn path=/trunk/; revision=24245
2006-09-24 07:38:53 +00:00
Magnus Olsen
c32cdd8bfb revers 24232 for cause some other unknown regress.
I need found a better way to solv the null termeting strings

svn path=/trunk/; revision=24244
2006-09-24 07:30:43 +00:00
Hervé Poussineau
7bfdc5ceb7 Allow digits in computer name.
http://www.reactos.org/bugzilla/show_bug.cgi?id=1806#c2 still needs to be checked
See issue #1806 for more details.

svn path=/trunk/; revision=24243
2006-09-24 06:25:49 +00:00
Art Yerkes
5d46ef1a26 Fix mkhive on unix.
svn path=/trunk/; revision=24242
2006-09-24 02:58:31 +00:00
Hervé Poussineau
939cbfc4c7 Report correct interrupt resources to ntoskrnl
svn path=/trunk/; revision=24241
2006-09-23 22:26:28 +00:00
Hervé Poussineau
68434f2227 Add default destination for driver files in keyboard.inf
svn path=/trunk/; revision=24240
2006-09-23 22:09:18 +00:00
Hervé Poussineau
9e314810ae Skip keyboard detection in freeldr, as it doesn't work in Qemu 0.8.2
svn path=/trunk/; revision=24239
2006-09-23 20:21:41 +00:00
Aleksey Bragin
cd007816d8 Change #defines of bios memory types to a proper enum. Makes it easier to distinguish BIOS memory types and FreeLoader's memory types (in future).
svn path=/trunk/; revision=24238
2006-09-23 16:50:39 +00:00
Hervé Poussineau
0e779901fc Do not display the group name of a service if it doesn't exists
svn path=/trunk/; revision=24237
2006-09-23 16:06:15 +00:00
Hervé Poussineau
edeb548dd1 Subkeys names should be case insensitive.
Fixes the 'make install' problem, where shell was not starting at third boot

svn path=/trunk/; revision=24236
2006-09-23 16:01:02 +00:00
Magnus Olsen
52b43f7ae9 IntGdiCreateSolidBrush
Remove the if table I did. 
Remove Color = Color & 0xffffff to Color = Color
that gave same result and pass equal many wine test. 
we still have some werid xlate bugs some where, for set/get pixel. I should have remove Color & 0xffffff in frist place. but the code did look right.  


svn path=/trunk/; revision=24235
2006-09-23 15:54:11 +00:00
Magnus Olsen
2d24316959 fixed some more setpixel bugs
svn path=/trunk/; revision=24234
2006-09-23 12:33:54 +00:00
Aleksey Bragin
e126931cb0 - Issue a synchronous invalidate device relations request instead of asynchronous (eliminates the "can't open \SystemRoot\ bugcheck during 2nd stage startup)
- Comment out usbport/usbhub/etc from bootcd, they will be enabled once they don't crash and/or slow down system.

svn path=/trunk/; revision=24233
2006-09-23 09:34:34 +00:00
Magnus Olsen
cc70b77eca add NULL termate on ansi string when WideCharToMultiByteCP doing wchar to ansi converting.
svn path=/trunk/; revision=24232
2006-09-23 07:28:44 +00:00
Magnus Olsen
63535f6e15 remove folder gdi for all gdi test are in gdi32
svn path=/trunk/; revision=24231
2006-09-23 06:19:28 +00:00
Andrew Munger
8f9a18cfff Merge 24219-24222, and 24209 from trunk.
svn path=/branches/ros-branch-0_3_1/; revision=24230
2006-09-22 21:45:35 +00:00
Magnus Olsen
cfe10b7a75 Implement BRUSH_GetObject it is not perfect, it return wrong color in some case. But we get down from 20 to 11 fails in wine test.
Wine say GetObject (HANDLE obj, INT Count, PVOID * Buffer) if Buffer is NULL return the requeuer size in bytes

svn path=/trunk/; revision=24229
2006-09-22 20:19:49 +00:00
Magnus Olsen
391e807b81 finish implement NtGdiCloseEnhMetaFile it is not fully tested it can contain bugs
svn path=/trunk/; revision=24228
2006-09-22 17:26:20 +00:00
Magnus Olsen
230edc01b6 merges ros-branch-0_3_1 r24226 to trunk with arty permission. "ARP query support. Thanks to WaxDragon for encouragement and debugging."
svn path=/trunk/; revision=24227
2006-09-22 08:10:11 +00:00
Art Yerkes
50ee081131 ARP query support.
Thanks to WaxDragon for encouragement and debugging.

svn path=/branches/ros-branch-0_3_1/; revision=24226
2006-09-22 06:36:16 +00:00
Aleksey Bragin
2a0160473e Add an MM api to get the memory map from Freeldr's memory manager (as opposed to MachGetMemoryMap which gets architecture-specfic memory map returned by BIOS/firmware/etc).
Currently this api is unused, it's going to be used by windows/reactos bootloader in future.

svn path=/trunk/; revision=24224
2006-09-21 17:25:41 +00:00
Saveliy Tretiakov
7d1faef9ee Fix boot with /DEBUGPORT=GDB and /DEBUGPORT=COM1. I don't know why, but this works...
svn path=/trunk/; revision=24223
2006-09-21 07:42:21 +00:00
Magnus Olsen
d42d3c29c0 set GetLastErrorMsg if CreateFontIndirectA(NULL) are use as inputparam . it make same beauvoir as CreateFontIndirectW
svn path=/trunk/; revision=24222
2006-09-21 02:47:37 +00:00
James Tabor
6d8ba42532 Fix CreateFontIndirectA so it will not bigcheck with a null pointer.
svn path=/trunk/; revision=24221
2006-09-20 21:34:08 +00:00
James Tabor
18733c4397 Kill debug prints.
svn path=/trunk/; revision=24220
2006-09-20 21:09:30 +00:00
James Tabor
fff3bf11fa Gdi32 font.c:
- Patch by Dmitry Timoshkov
  - If there is no space for strings GetOutlineTextMetricsA should not indicate that they present.

svn path=/trunk/; revision=24219
2006-09-20 20:36:27 +00:00
Hervé Poussineau
f1cf836837 Big update of i8042prt driver. The driver is now plug&play compliant and some mouse driver filters may be installed.
svn path=/trunk/; revision=24218
2006-09-20 18:56:04 +00:00
Hervé Poussineau
d2241f8ec4 If boot resources are provided, use them instead of using resource requirements.
In all cases, translate the resource list before calling the driver

svn path=/trunk/; revision=24217
2006-09-20 18:16:24 +00:00
Aleksey Bragin
364cdf1951 - Add ability to allocate either "low" or "high" pages
- Don't display a warning to user if allocating memory at certain address fails
- Change debug prints so they tell in which function allocation failed
- Include RTL and LDR headers from NDK, so that it's possible to use functions from RTL in FreeLdr in future

svn path=/trunk/; revision=24216
2006-09-20 16:54:54 +00:00
Saveliy Tretiakov
b9ade034f9 Fix booting with /DEBUGPORT=GDB and Pice too.
svn path=/trunk/; revision=24215
2006-09-20 15:00:17 +00:00
Hervé Poussineau
9907e96a49 Save correct boot resources lists in registry
svn path=/trunk/; revision=24214
2006-09-20 14:46:21 +00:00
Magnus Olsen
3138af456a commit rc languages to xml parser for the webservre and standalone.
svn path=/trunk/; revision=24213
2006-09-20 14:38:37 +00:00
Thomas Bluemel
8e90ccee4d Some tchar fixes
svn path=/trunk/; revision=24212
2006-09-20 09:54:00 +00:00
Thomas Bluemel
d0e354f6c1 Fix warnings
svn path=/trunk/; revision=24211
2006-09-20 09:27:59 +00:00
Brandon Turner
59c2e127cc Add a config.rbuild and set DBG=0
svn path=/branches/ros-branch-0_3_1/; revision=24210
2006-09-19 17:38:10 +00:00
Andrew Munger
14d0c5f34a Initialize h_alises with a length 1 array containing a terminating null as specified. Patch by arty. (Fixes ncftp connection)
svn path=/trunk/; revision=24209
2006-09-19 04:25:14 +00:00
James Tabor
f8fcca6f06 Kill some warnings.
svn path=/trunk/; revision=24208
2006-09-18 23:37:22 +00:00
Andrew Munger
ece02ec90c Bump to 0.3.1-SVN
svn path=/branches/ros-branch-0_3_1/; revision=24207
2006-09-18 22:59:55 +00:00
Ged Murphy
3f0a7fb997 - Add a cute custom control to sysdm allowing dialogs to display hyperlink style text which can open web pages and run exe's.
- see the general page, and the user account dialog for examples.

svn path=/trunk/; revision=24205
2006-09-18 22:25:00 +00:00
Andrew Munger
d00d45c34e Reapply entrypoint fix, patch from Usurp.
svn path=/trunk/; revision=24204
2006-09-18 21:49:12 +00:00
The Wine Synchronizer
d3cd32d90d Autosyncing with Wine HEAD
svn path=/trunk/; revision=24203
2006-09-18 16:59:16 +00:00
The Wine Synchronizer
d88a99e18e Autosyncing with Wine HEAD
svn path=/trunk/; revision=24202
2006-09-18 16:52:25 +00:00
The Wine Synchronizer
9e9bd06847 Autosyncing with Wine HEAD
svn path=/trunk/; revision=24201
2006-09-18 16:51:34 +00:00
The Wine Synchronizer
1b0a889e2b Autosyncing with Wine HEAD
svn path=/trunk/; revision=24200
2006-09-18 16:50:11 +00:00
The Wine Synchronizer
446242dfb2 Autosyncing with Wine HEAD
svn path=/trunk/; revision=24199
2006-09-18 16:49:02 +00:00
The Wine Synchronizer
2cb8454522 Autosyncing with Wine HEAD
svn path=/trunk/; revision=24198
2006-09-18 16:47:55 +00:00
The Wine Synchronizer
11c17d1dc0 Autosyncing with Wine HEAD
svn path=/trunk/; revision=24197
2006-09-18 16:46:41 +00:00
The Wine Synchronizer
04b927e3ff Autosyncing with Wine HEAD
svn path=/trunk/; revision=24196
2006-09-18 16:45:21 +00:00
Hervé Poussineau
a11691c3c4 Autosyncing with Wine HEAD
svn path=/trunk/; revision=24195
2006-09-18 16:41:29 +00:00
The Wine Synchronizer
82845620c6 Autosyncing with Wine HEAD
svn path=/trunk/; revision=24194
2006-09-18 16:36:06 +00:00
The Wine Synchronizer
8bde95b20e Autosyncing with Wine HEAD
svn path=/trunk/; revision=24193
2006-09-18 16:32:05 +00:00
The Wine Synchronizer
fab72e48ec Autosyncing with Wine HEAD
svn path=/trunk/; revision=24192
2006-09-18 16:28:29 +00:00
Hervé Poussineau
ed5305eeae Autosyncing with Wine HEAD
svn path=/trunk/; revision=24191
2006-09-18 14:34:40 +00:00
Johannes Anderwald
f8b5e46f8b * fix build
svn path=/trunk/; revision=24190
2006-09-18 10:58:00 +00:00
Aleksey Bragin
a42c7ad876 Fix some defines used in fiber.S in kernel32.dll (fixes build)
svn path=/trunk/; revision=24189
2006-09-18 08:56:28 +00:00
Magnus Olsen
6e100cf43f revert 24179 it was bad idea. and wrong way todo it on
See issue #21478 for more details.

svn path=/trunk/; revision=24188
2006-09-18 05:13:17 +00:00
Alex Ionescu
8b094bf093 - Implement FPU Exception Handler.
- We can now properly handle FPU faults (wrote a small test for invalid fpu precision).
- OpenGL probably still doesn't work, as there might be some bugs around the place. However, you should not see FPU Bugchecks anymore.

svn path=/trunk/; revision=24187
2006-09-18 02:33:21 +00:00
Alex Ionescu
03c36d1a35 - Implement Trap 16: Math Coprocessor Fault. Happens during Floating Point precision error test that I wrote. Simply calls shared NPX handler in KiTrap7.
- Implement some extra checks in KiTrap7 and start coding the NPX shared handler. We *almost* have full FPU support now... (trying to get this done for tomorrow morning so that Greatlord can sent me the 15 000$ he promised...)

svn path=/trunk/; revision=24186
2006-09-18 01:07:13 +00:00
Alex Ionescu
d228dcccad - On SMP systems, update KPROCESS->ActiveProcessors and assert their validty. Needed for a similar assertion and check in KiSwapProcess which we already have.
- Also on SMP, make sure to clear the KTHREAD's swap-busy lock after the actual swap has been done.

svn path=/trunk/; revision=24185
2006-09-18 00:34:13 +00:00
Alex Ionescu
2ea699f94e - Assert that the current CPU is the one the thread is supposed to be running on.
- Get CR0, read the KTHREAD NPX State, disable interrupts and verify if the NPX state is dirty. If it is, then reload CR0 with the new value. Re-enable interrupts. This sequence should make FPU work during context switching, but I haven't tested yet. At the very least, it should get rid of TRAP_FAULT_UNKNOWN blue screen.
- Set TEB in the same time as the selector is being configured, not way earlier.

svn path=/trunk/; revision=24184
2006-09-18 00:30:30 +00:00
Alex Ionescu
63da586075 - Fix some bugs in LDT switch (EDI->EBP)
- Turn simple bugcheck into BugCheckEx with information that the helpfile says it should have.

svn path=/trunk/; revision=24183
2006-09-18 00:17:53 +00:00
Alex Ionescu
8de07ee7b4 - Don't update CR3 in KTSS, it's not used.
- Don't read a useless stack pointer anymore.
- Update KTSS_ESP0 near the end of context switching, not at the beginning anymore.
- Same for IOPM and I/O Redirection Map Base Address.

svn path=/trunk/; revision=24182
2006-09-18 00:10:58 +00:00
Alex Ionescu
eaf28f0509 - Stop doing cli/sti doing context switching (For now, since it's only needed for FPU, which isn't yet done).
- Stop using XP KPCR fields for storing stack values, they're not used inside the kernel anymore and now have 2003 values (WMI tracing, etc).
- Move parts of the process switch (LDT reload) out-of-line.

svn path=/trunk/; revision=24181
2006-09-18 00:02:46 +00:00
Alex Ionescu
b52483ba9a - Add func.endfunc decoration.
- Add code to wait for SwapBusy == FALSE on SMP.
- Add stub code to check for new PCR fields in 2003. Currently disabled because thread swap code still uses XP fields.
- Check for active DPCs at the end of thread swap, not at the beginning.
- Set PRCB->IdleThread outside of the thread swap routine.
- Don't set the thread state to running inside the swap routine, we already do it outside.

svn path=/trunk/; revision=24180
2006-09-17 23:17:07 +00:00
Magnus Olsen
70cca480e5 implemet GdiReleaseDC it redirect to NtUserReleaseDC(HWD hwd, HDC hdc) now
svn path=/trunk/; revision=24179
2006-09-17 22:10:24 +00:00
Alex Ionescu
3e709fbbd9 - Fix some insidious bugs in exception handling, mostly related to the art of unwinding (RtlUnwind).
- Can't name specifics, but probably fixes multiple SEH/application bugs/regressions since about 6-8 months ago. Fixes my personal SEH test from 22 failures/crashes/BSODs to 22 succeesses...
- Also fixes some crashes in kernel-kqemu mode.

svn path=/trunk/; revision=24178
2006-09-17 21:09:10 +00:00
Magnus Olsen
45f71f78c8 did delete NtGdiDeleteObjectApp at end of NtGdiCloseEnhMetaFile by mistake. radding it
svn path=/trunk/; revision=24177
2006-09-17 20:42:59 +00:00
Magnus Olsen
fa61787952 Activate CloseEnhMetaFile in gdi32.
We do not leak memory from CreateEnhMetaFile.
 

svn path=/trunk/; revision=24176
2006-09-17 20:22:27 +00:00
Magnus Olsen
d3eeef4046 NtGdiCloseEnhMetaFile
1. translate EMF_Create_HENHMETAFILE to reactos 
2. Delete hdc.

NtGdiCreateEnhMetaFile
1. Set hdc ownership. 


svn path=/trunk/; revision=24175
2006-09-17 20:21:01 +00:00
Alex Ionescu
23dc37d575 - Cleanup except_asm.s and add .func/.endfunc and fix some double definitions.
svn path=/trunk/; revision=24174
2006-09-17 18:44:52 +00:00
Alex Ionescu
b820ec4930 - Fix a bug in KeRaiseUserExceptionDispatcher which was causing us not to set the Exception Address (EIP) in the EH record.
- Fix a terrible stack corruption bug in KeRaiseUserExceptionDispatcher which was causing us to eventually fuck up the stack in user mode (0x14 bytes instead of 0x50 bytes were reserved).
- Protect User-mode Callbacks with SEH, and use STATUS_POP_CALLBACK_STACK.
- Fix another nasty stack corruption bug in user-mode APC delivery.
- Protect User-mode APC delivery with SEH.
- Fix SEH handlers to return EXCEPTION_EXECUTE_HANDLER isntead of ExceptionContinueSearch.

svn path=/trunk/; revision=24173
2006-09-17 17:31:52 +00:00
Magnus Olsen
4493c99327 fast implemet of NtGdiCloseEnhMetaFile
follow thing need be done before it is finish but it will slov leaked memory and filehandle from NtGdiCreateEnhMetaFile
for we have NtGdiCreateEnhMetaFile implement. NtGdiCloseEnhMetaFile is base on wine cvs 15/9-2006
Todo
1. Rewrite it to own api call IntGdiCloseEmhMetaFile
2. Use Zw and Int direcly so we do not need todo  context swith each call
3. Translate follow api to kernel api 
   // hMapping = CreateFileMappingW(Dc->hFile, NULL, PAGE_READONLY, 0, 0, NULL);
   // Dc->emh = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0);
   // hmf = EMF_Create_HENHMETAFILE( Dc->emh, (Dc->hFile != 0) );


 

svn path=/trunk/; revision=24172
2006-09-17 15:47:29 +00:00
Hervé Poussineau
6afc1a0152 Define some registry entries as not volatile, to prevent new installation of device at each boot
svn path=/trunk/; revision=24171
2006-09-17 15:42:50 +00:00
Hervé Poussineau
3ab77c0239 DeviceNode->ResourceList and DeviceNode->ResourceListTranslated should not share memory with DeviceNode->BootResources
svn path=/trunk/; revision=24170
2006-09-17 15:24:55 +00:00
Alex Ionescu
adb93d9531 - A missing "return" statement to KiDispatchException which was causing all user-mode exceptions to become second-chance and thus crash the app. mIRC works again, and probably numerous other apps (mozilla as well i think, since it had the same issue)
svn path=/trunk/; revision=24169
2006-09-17 15:01:57 +00:00
Hervé Poussineau
551811ac52 Disable some code I did during the last day to repair ReactOS boot. Let's hope it is enough
svn path=/trunk/; revision=24168
2006-09-17 14:27:17 +00:00
Magnus Olsen
5c66b358e1 Upgrade from dejavu font 2.9 to 2.10
reason 
1. Bugfix some charters that did not show in Windows/ReactOS
2. Fixing space between some charters 
3. Dejvau san font support 100% folllow Latin Extended-B, Latin Extended-C, Greek and Coptic, Superscripts and Subscripts, Currency Symbols.
4. and allot more new charters 

svn path=/trunk/; revision=24167
2006-09-17 13:37:59 +00:00
Hervé Poussineau
ac233d6e61 Don't go further than end of string when writing value to registry
svn path=/trunk/; revision=24166
2006-09-17 12:20:44 +00:00
Hervé Poussineau
f271868696 Don't enable acpi service by default, it would be automatically installed if necessary
svn path=/trunk/; revision=24165
2006-09-17 12:17:44 +00:00
Magnus Olsen
15732d3ae2 implement last part of NtGdiCreateEnhMetaFile
it can now create file.  (add ntdll.a to rbuild need RtlDosPathNameToNtPathName_U api)

svn path=/trunk/; revision=24164
2006-09-17 10:56:13 +00:00
Hervé Poussineau
b6919c977d Merge from Wine:
James Hawkins <truiken@gmail.com>
- Add stubs for SetupOpenLog, SetupCloseLog, and SetupLogError
- Implement pSetupGetField, with tests.

svn path=/trunk/; revision=24162
2006-09-17 10:34:51 +00:00
Hervé Poussineau
f07b34a9d0 I don't know how to save REG_LINK info on disk, so ignore them. Incidently, fixes "make install_registry"
svn path=/trunk/; revision=24156
2006-09-17 08:44:17 +00:00
Alex Ionescu
8ef78cb6e6 - Create a KD-compatible KiDebugRoutine and piggyback KDBG on it.
- Create separate GDB entry hack routine.
- Fix booting with /BREAK and continuing after an INT3/ASSERTion.

svn path=/trunk/; revision=24155
2006-09-17 07:06:35 +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
Hervé Poussineau
1b0d4ce154 Install VMware driver using UpdateDriverForPlugAndPlayDevicesW function.
Installing a driver is not as easy as copying files and adding some registry entries, especially when autogenerated PnP ids change...

svn path=/trunk/; revision=24153
2006-09-17 00:28:19 +00:00
Hervé Poussineau
68bee00b1d Make IoInvalidateDeviceRelations really asynchronous
Implement IoSynchronousInvalidateDeviceRelations

svn path=/trunk/; revision=24152
2006-09-16 23:30:57 +00:00
Johannes Anderwald
5d0d792e67 * update comments
* remove unused members in ConsoleInfo struct
* update global struct on UDN_DELTAPOS events
* update WindowSize ScreenBuffer member when bigger / smaller on scroll events

svn path=/trunk/; revision=24151
2006-09-16 21:41:57 +00:00
Hervé Poussineau
5ed7c7746e Fix compilation (3 variables were unused)
svn path=/trunk/; revision=24150
2006-09-16 21:21:05 +00:00
Hervé Poussineau
47f4f5c36a Change detection method to see if a driver is a legacy one
Fix last issues with PCI driver

svn path=/trunk/; revision=24149
2006-09-16 20:53:27 +00:00
Alex Ionescu
78ef70deda - Fix one of the oldest hacks in ReactOS: KeGetCurrentThread() and PsGetcurrentProcess used to be NULL during early boot stage. We also didn't have an official idle therad/process. Also system intialization was not in its sepearte thread. Changes:
- Implemented SeAssignPrimaryToken.
   - Setup Boot/System Token for Idle Process in SeInit2.
   - Remove ROS hack in SeCaptureSubjectContextEx.
   - Call SeAssignPrimaryToken in PspInitializeProcessSecurty when called for the Initial Process creation.
   - Implement PsInitiailizeQuotaSystem and set PspDefauptQuotaBlock for the idle process so that it can be used for the initial process.
   - Rewrite Process Manager Phase 0 initialization from scratch, to create a new initial system process and thread which will be used for Phase 1 (in ROS, phase 2) initialization of the executive.
   - Fix a bug in PspCreateProcess which was using an uninitialized value of SectionObject in some cases, instead of NULL.
   - Call PsInitailizeQuotaSystem from ObInit, and also create the system handle table inside the idle process, and make it the ObpKernelHandleTable.
   - Do Executive Phase 0 Initialization at APC_LEVEL.
   - Start idle thread at HIGH_PRIORITY then lower it to 0 once the Initial Thread is setup, so that it can run, then keep priority to 0 at DISPATCH_LEVEL and jump into idle loop code.
   - Add NtYieldExecution to idle loop code since it's now being used.
   - Fix IoGetCurrentProcess which was previously hacked.
   - Remove some checks for Thread == NULL in ke_x.h, since this is now impossible.
   - Split Phase 0/1 initialization in ex\init.c, since one runs in a separate thread now. Also don't lower IRQL to PASSIVE_LEVEL anymore (run at APC_LEVEL).

svn path=/trunk/; revision=24148
2006-09-16 20:37:49 +00:00
Alex Ionescu
0d996fd421 - Revert part of 24108 which was scanning the process's thread ready list and making the threads ready. This shouldn't currently happen on ReactOS but it seems that happens on Fireball's machine and crashes it, so I'm reverting it.
svn path=/trunk/; revision=24147
2006-09-16 20:27:53 +00:00
Hervé Poussineau
25e2b01535 Don't crash if PCI AddDevice is called with a NULL Pdo (happens if pci.sys is considered as a legacy driver)
svn path=/trunk/; revision=24146
2006-09-16 20:22:54 +00:00
Martin Fuchs
30f438bb7b explorer: minor code cleanup
svn path=/trunk/; revision=24145
2006-09-16 15:41:17 +00:00
Martin Fuchs
fcfeb83217 "Debug Release" mix configuration for notifyhook project file
svn path=/trunk/; revision=24144
2006-09-16 15:40:24 +00:00
Martin Fuchs
a06bdc9503 explorer: handle child window creation errors
svn path=/trunk/; revision=24143
2006-09-16 15:39:07 +00:00
Magnus Olsen
bb1f92d0d3 fixed a memory I accident created when to free a hdc
svn path=/trunk/; revision=24142
2006-09-16 06:40:37 +00:00
Alex Ionescu
5acd247d8e - Implement most of the Ring 3/0 Invalid Opcode handler. Stops apps like mIRC from BSODing the system anymore.
svn path=/trunk/; revision=24141
2006-09-16 06:03:04 +00:00
James Tabor
6b30b92bf0 I think this was on Ged mind.
svn path=/trunk/; revision=24140
2006-09-16 05:29:25 +00:00
Art Yerkes
f20c6b89df Not sure where LicenseDialogProc is supposed to come from. For now, we'll
disable it until it gets fixed.

svn path=/trunk/; revision=24139
2006-09-16 01:56:51 +00:00
Alex Ionescu
d664420182 - Merge in my latest Dispatcher changes for KeWaitForMultipleObject, which are basically the same kind of changes as have been done for KeDelay/KeWaitForSingle. (Optimizations and readability improvements).
- Also fixed a previous bug where we didn't respect alertable waits anymore for KeWaitForMultiple...
- Remove krnlfun entry, the rest of dispatcher changes are tied to the new timer implementation for later.

svn path=/trunk/; revision=24138
2006-09-16 00:07:02 +00:00
Magnus Olsen
aa64d1177f Implement NtGdiCreateEnhMetaFile it is base on wine cvs 15/9-2006 version of CreateEnhMetaFileW in wine gdi32.dll
Our are not complete it can not create the file.
But we parseing now some NULL pointer test and some other test in winetest for gdi32. 

 

svn path=/trunk/; revision=24137
2006-09-15 23:24:04 +00:00
Hervé Poussineau
dfda3eceff Fix "normal" formatting, by removing differences between quick and normal formatting.
Normal formatting is quick formatting + fill sectors with 0 (not done yet)

svn path=/trunk/; revision=24136
2006-09-15 17:04:18 +00:00
Ged Murphy
4db2ab349a enable system info (again)
svn path=/trunk/; revision=24135
2006-09-15 16:45:00 +00:00
Ged Murphy
c09e1c12ab - add hardware profile and start and recovery dialogs
- popup a message box for dialogs not yet implemented

svn path=/trunk/; revision=24134
2006-09-15 16:37:26 +00:00
Aleksey Bragin
4094a71f3e Fix typos in comments
svn path=/trunk/; revision=24133
2006-09-15 16:07:11 +00:00
Aleksey Bragin
ee7e88e8ec Add missing "NTAPI"
svn path=/trunk/; revision=24132
2006-09-15 16:01:50 +00:00
Aleksey Bragin
04a96186b4 Revert a change in debug.h introduced in 19329 by Hartmut Birr. Freeldr's debug output doesn't expect any DbgPrint call to result in a "__FILE__:__LINE__ output_string" substitution.
Now FreeLdr's debug output looks good again.

svn path=/trunk/; revision=24131
2006-09-15 10:45:53 +00:00
Magnus Olsen
ed022d17fd arcoding winetest CreateEnhMetaFileA all param can be NULL
and we fail on this. But this is only one bugfix, We need bugfix win32k now. To completed the bugfix

svn path=/trunk/; revision=24130
2006-09-15 10:36:50 +00:00
Hervé Poussineau
b73a685a79 Assume bus number #0 if not specified in resource list
svn path=/trunk/; revision=24129
2006-09-15 09:09:18 +00:00
Hervé Poussineau
2a1513dc5c - Fix Freeldr to correctly send reported resources (at least PCI buses and PS/2 devices)
- Let Root bus report BootResources
- If no resource requirement are found, use the boot resource list (not sure of this one)

svn path=/trunk/; revision=24128
2006-09-15 06:48:01 +00:00
Hervé Poussineau
3daa4394f7 Check for ACPI BIOS identifier, to prevent double enumeration of devices
Move boot resource informations to Root\ key (if available)
Add a missing \0 at the end of hardwareId list

svn path=/trunk/; revision=24127
2006-09-14 22:29:07 +00:00
Ged Murphy
af77fee9dd fix a few dialog asthetics
svn path=/trunk/; revision=24126
2006-09-14 21:51:56 +00:00
Ged Murphy
faa4bd22bb put system info back in
svn path=/trunk/; revision=24125
2006-09-14 20:46:06 +00:00
Hervé Poussineau
7ac40876f4 Report to registry hardware found by Freeloader.
See issue #645 for more details.

svn path=/trunk/; revision=24124
2006-09-14 20:30:35 +00:00
Magnus Olsen
eccbefcccb thx fireball fixing a spelling fault
svn path=/trunk/; revision=24123
2006-09-14 20:00:28 +00:00
Ged Murphy
da666d1ce5 sneaky little blighter
svn path=/trunk/; revision=24122
2006-09-14 19:12:48 +00:00
Ged Murphy
4732ef2b6a start to overhaul sysdm.cpl and make it more like XP's, which is much more user friendly
- completely rewrite the resource file to make it readable and logical
- do the same with the resource.h file (I'll cry if anyone messes these 2 up, it's mega neat now ... ;p)
- add the ReactOS logo to the first page (general tab)
- move the licence to it's own dialog accessable from the general tab
- rearrange the computer name and hardware pages
- delete the user profile page and add it as a separate dialog accessable from the advanced page
- add an error reporting button (as per XP) which opens a web browser directly to bugzilla.
- loads of other little alterations.
*note, I've dissabled language files until I've finished messing with the resources*

svn path=/trunk/; revision=24121
2006-09-14 19:09:56 +00:00
Magnus Olsen
a413ba4de2 forget this file thx Quip at irc
svn path=/trunk/; revision=24120
2006-09-14 19:02:56 +00:00
Magnus Olsen
e1ba479b2c 1. move all languages to own folder
2. accepted LMH1 languages patch (with small modification)

See issue #1696 for more details.

svn path=/trunk/; revision=24119
2006-09-14 17:33:25 +00:00
Magnus Olsen
5f0ec93a17 translations patch accepted from LMH1 (with small modification from me)
See issue #1695 for more details.

svn path=/trunk/; revision=24118
2006-09-14 17:26:08 +00:00
Magnus Olsen
3e4ab62cca 1. move all languages to own folder
2. accepted LMH1 languages patch (with small modification)
3. fixed right sublang on few languages rc files
See issue #1685 for more details.

svn path=/trunk/; revision=24117
2006-09-14 17:17:51 +00:00
Magnus Olsen
eb39f6f8dc translations patch accepted from LMH1 (with small modification from me)
See issue #1679 for more details.

svn path=/trunk/; revision=24116
2006-09-14 16:53:53 +00:00
Ged Murphy
d667517b42 start to rewrite the virtmem code to remove many bugs and make it more readable.
I'm currently working on enhancements to sysdm, but it's probably better to commit this separately 

svn path=/trunk/; revision=24115
2006-09-14 16:49:11 +00:00
Magnus Olsen
4a1ee5a228 adding Japanese keyboard to reactos installer
svn path=/trunk/; revision=24114
2006-09-14 16:40:40 +00:00
Magnus Olsen
3f285b2d73 adding Japanese keyboard drv patch from ja731j (real name : Simon Hanae mail : ja731j at ja731j dot homeip dot net
See issue #1795 for more details.

svn path=/trunk/; revision=24113
2006-09-14 16:39:35 +00:00
Aleksey Bragin
efcc4447c1 Reapply fixed half of 24020 (relocation update in rtl). Tested on vmware and real hardware.
svn path=/trunk/; revision=24112
2006-09-14 16:37:05 +00:00
Saveliy Tretiakov
63ae604355 Fix typo. palate -> pallete
svn path=/trunk/; revision=24111
2006-09-14 16:04:08 +00:00
Alex Ionescu
1b75e6549e - Converted some macros to inlined functions.
- Modified KeDelayExecutionThread and KeWaitForSingleObject to be much simpler and readable, reducing some of the loops and continues, and 4th-level indentation. Also packed up common wait initialization at the beginning of the function, and into two new inline functions: KxDelayThreadWait and KxSingleThreadWait. No actual semantic changes, just re-ordering.
- Rename KiUnwakeQueue to KiActivateWaiterQueue.

svn path=/trunk/; revision=24110
2006-09-14 15:48:02 +00:00
Aleksey Bragin
bb617c9ac9 Sylvain Petreolle: Fix a typo in the code (palGDI -> sysGDI)
svn path=/trunk/; revision=24109
2006-09-14 15:40:16 +00:00
Alex Ionescu
74703ca408 - Implement KeReadyThread that wraps KiReadyThread so that \ps doesn't have to worry about dispatcher lock.
- Make sure all a process's threads are ready if they're on the ready queue, during attachment.
- Merge in KiReadyThread from scheduler code, with a small code change to keep working with ROS's scheduler lists instead.

svn path=/trunk/; revision=24108
2006-09-14 12:13:32 +00:00
Magnus Olsen
beb74a2356 remove entrypoint in rbuild files.
1. This change are right but binutils setting
   PE header flags wrongs for cpl/dll wrong

2. Remove entrypoint for cpl until this bug have
   been fixed in binutils.
    

svn path=/trunk/; revision=24107
2006-09-14 09:10:13 +00:00
Aleksey Bragin
4309a525f4 Show the value, not the address in memory! (Thanks to Dmitry Philippov)
svn path=/trunk/; revision=24106
2006-09-14 08:27:08 +00:00
Aleksey Bragin
d64332beb2 Mikhail Zvyozdochkin: If I enter directly DNS server address in TCP/IP properties window, and after it open this window again, DNS server address is not retrieved to text field.
Patch 1746

svn path=/trunk/; revision=24105
2006-09-14 08:20:50 +00:00
Magnus Olsen
dc1e819150 Fixing two NULL pointer crash in win32k.
I do not known if I done right in NtGdiRealizePalette step2, step2 is not tested.  

svn path=/trunk/; revision=24104
2006-09-14 07:43:20 +00:00
Alex Ionescu
20425875ce - Implement KiAcquireDispatcherObject, KiReleaseDispatcherObject, used on SMP for dispatcher objects which use the volatile long member in the dispatcher header (such as gates).
- Implement KiTryThreadLock which tries to acquire the lock but exits if it can't, isntead of looping.
- Re-factor KeWaitForGate to make it SMP-safe by acquiring various locks when required.
- Fixed up KeSignalGateBoostPriority so it can also be SMP-safe, and also fix what exactly happens when the gate is signaled (directly make the other thread ready instead of doing a KiUnwaitThread on it).
- Split KxAcquireSpinLock/KxReleaseSpinLock into SMP vs UP like the other routines.

svn path=/trunk/; revision=24103
2006-09-14 05:53:51 +00:00
Alex Ionescu
d53352c677 - Implement KiUnlinkThread to unlink a thread from its wait blocks, handle queue and timer activation/removal.
- Don't play with priorities in KiAbortWaitThread anymore, since we'll soon support Win2003 delayed "adjust increment" functionality, so that the code is not repeated many times.
- Rename KiAbortWaitThread to KiUnwaitThread, make it use KiUnlinkThread and delayed adjustment.
- Implement KxUnwaitThread and KxUnwaitThreadForEvent, optimized versions of KiWaitTest that can be used in special circumstances (notification events, thread termination, process signalling).
- Optimize KeSetEvent by handling signaled notification events without acquiring the dispatcher lock, and by using new inlined routines described above.
- Reimplement KeSetEventBoostPriority properly to actually do boosting.
- Fixup KeRundownQueue with a more typical/proper LIST_ENTRY loop.
- Let me know if you see regressions...

svn path=/trunk/; revision=24102
2006-09-14 03:49:20 +00:00
Alex Ionescu
c440454c10 - Update Kernel Fun.
svn path=/trunk/; revision=24101
2006-09-13 21:46:32 +00:00
Magnus Olsen
a2a7c9632f Greek keyboard layout changes by Apal
See issue #1631 for more details.

svn path=/trunk/; revision=24100
2006-09-13 19:08:41 +00:00
Saveliy Tretiakov
5971670b9b Separate NtGdiModifyWorldTransform and IntGdiModifyWorldTransform for internal usage.
svn path=/trunk/; revision=24099
2006-09-13 16:50:19 +00:00
KJK::Hyperion
182b4dc71d <intrin.h> compatibility header. Implements Visual C++ intrinsics in GCC. Licensed very liberally, please keep it that way
svn path=/trunk/; revision=24098
2006-09-13 14:07:41 +00:00
Saveliy Tretiakov
457e0142bd Move IntGdiGradientFill and IntSystemParametersInfo prototypes to header files.
Delete DestroyThreadWindows prototype (function does not exist).


svn path=/trunk/; revision=24097
2006-09-13 13:43:39 +00:00
Saveliy Tretiakov
0eabb5d7bc Move UserDrawIconEx and UserGetCurIconObject prototyepes to header file.
svn path=/trunk/; revision=24096
2006-09-13 13:03:17 +00:00
Saveliy Tretiakov
e6c1f9ca4b Add UnattendSetupEnabled key for enabling\disabling unattended setup without editing rbuild files.
Modifing rbuild files all the time is not handy and slows down build process.


svn path=/trunk/; revision=24095
2006-09-13 12:33:59 +00:00
Alex Ionescu
63142230b2 - Rename kqueue.c to devque. KQUEUE (kernel queues) are implemented in queue.c, and this filename always confused me. Why would you name KDEVICE_QUEUE into kqueue.c, when you already have KQUEUE in queue.c?!
- Rename exception.c to except.c, mostly due to MSVC's incompatibility with multiple identically named files.
- SVN delete usercall.c leftover.
- Fix KeSetPriorityAndQuantumProcess to use Queued Spinlocks and KiAcquireProcess/ThreadLock when needed.

svn path=/trunk/; revision=24094
2006-09-13 03:02:40 +00:00
Alex Ionescu
630f3d1e69 - Cleanup ipi.c, reformat, and re-organize.
- Undefine all functions for UP builds, except KeIpiGenericCall.
- Implement KeIpiGenericCall for UP builds and add @implemented tag.

svn path=/trunk/; revision=24093
2006-09-13 02:25:32 +00:00
Alex Ionescu
31e4c651c4 - Renamed device.c to config.c and removed all irrelevant code from it, leaving only the two KeFindConfigurationEntry*** functions in it.
- Also fixed the above for incorrect formatting/excessive whitespace.
- The other routines in device.c were moved to cpu.c, since they deal with CPU-specific things.
- Cleaned up KeFlushEntireTb.
- Added inlined routines for setting/getting CR, and also getting GDTR, IDTR, LDTR, TR. Used to implement KiSaveProcessorControlState.
- Implemented KeSaveStateForHibernate.

svn path=/trunk/; revision=24092
2006-09-13 02:08:22 +00:00
Alex Ionescu
b4aab80937 - Fix a typo that happened after-the-fact.
svn path=/trunk/; revision=24091
2006-09-13 02:04:33 +00:00
Alex Ionescu
7687187bf0 - Implement KxAcquireSpinLock/KxReleaseSpinLock for inline acquisition of spinlocks, SMP, UP and DBG. (on DBG builds, we OR the spinlock value with the KTHREAD address, then compare on release.)
- Make In-Stack QSLs a complete no-op in UP, we were still touching some fields.
- Cleanup and re-organize spinlock.c

svn path=/trunk/; revision=24090
2006-09-13 01:41:17 +00:00
Alex Ionescu
07a0973e21 - Remove usercall.c from portable part of Ke and add it to ke\i386. The implementation is slightly arch-specific.
- Remove code in userapc.c and move it into usercall.c, since both functions basically deal with user-mode callouts.
- Handle STATUS_CALLBACK_POP_STACK and add the status to ntstatus.h
- Also handle future support for GDI Batch flushing.

svn path=/trunk/; revision=24089
2006-09-13 01:00:50 +00:00
Alex Ionescu
a614833b08 - Use inlined guarded region routines instead of duplicating code.
- Add @implemented tags.

svn path=/trunk/; revision=24088
2006-09-13 00:35:56 +00:00
Alex Ionescu
d99f96a295 - Implement KiAcquireDeviceQueueLock/KiReleaseDeviceQueueLock for locking KDEVICE_QUEUEs, since they can be used from Threaded DPCs which don't execute at DISPATCH_LEVEL, so the lock needs to be acquired differently.
- Add ASSERT_DEVICE_QUEUE and ASSERTify + reformat kqueue.c.
- Implement KeRemoveByKeyDeviceQueueIfBusy.
- Cleanup exception.c
- Remove dangerous/broken KeGetCurrentIrql() define.

svn path=/trunk/; revision=24087
2006-09-13 00:20:46 +00:00
Aleksey Bragin
c0cda24302 Just one entrypoint="0" is enough
svn path=/trunk/; revision=24086
2006-09-12 21:33:56 +00:00
Hervé Poussineau
6ed6c1661e Don't call notification procedures with APC disabled, it may lead to some strange results.
Thanks Alex for the time he took to help me to debug this issue

svn path=/trunk/; revision=24085
2006-09-12 21:18:22 +00:00
Ged Murphy
3fd92a4f96 Revert changes from r23620 until a better solution can be found as it breaks opening of cpl applets with VS.
The 'DebugSettings' should be stored in the .user file.

svn path=/trunk/; revision=24084
2006-09-12 21:02:39 +00:00
Aleksey Bragin
3b58ac1932 Fix last things preventing me from compiling the tree:
vsnprintt -> _vsnprintf in the wine/unicode.h and in riched20

svn path=/trunk/; revision=24083
2006-09-12 18:51:05 +00:00
Hervé Poussineau
2140d54ca5 Start to support GUID_DEVICE_SYS_BUTTON interface. It is required to handle keyboards with power buttons (wake/sleep/power)
(This commit is done now to be able to debug an APC problem)

svn path=/trunk/; revision=24082
2006-09-12 15:19:51 +00:00
Hervé Poussineau
fec5904b50 [AUDIT] This file only include other files, so it can't be dirty.
Additionally, define GUID_DEVICE_SYS_BUTTON

svn path=/trunk/; revision=24081
2006-09-12 15:19:17 +00:00
Alex Ionescu
2829cc5982 - Re-merge 24062+24063, with a minor difference, they work now.
svn path=/trunk/; revision=24080
2006-09-12 13:54:52 +00:00
Alex Ionescu
6b1e4db5b5 - Partial revert of r20462/63. New HAL/Po/Ki code remains, but restored the original PsIdleThread code. I know what the bug is but I'm too tired to fix it, so I'd rather revert the broken part.
- Install + 2nd stage + boot to desktop will not work in qemu, kernel-kqemu and vmware (all wax and I tested).

svn path=/trunk/; revision=24079
2006-09-12 05:37:14 +00:00
Alex Ionescu
978da5c0af - Revert 24020 (good code, but buggy) and 24041 (bad code/revision).
- This gets us as far as 24061(+24048) for booting.

svn path=/trunk/; revision=24078
2006-09-12 05:21:27 +00:00
Aleksey Bragin
4e03e0ec4a Those two #ifdefs were wrong on my setup (straightforward RosBE 3.4.2, and also updated to 3.4.4). So:
1. Removed the stricmp guard
2. Added a #ifdef->#undef solution

If this break compilation on linux or on gcc 4 on win32 (very low probability, if any), let's think further.

svn path=/trunk/; revision=24076
2006-09-11 21:40:50 +00:00
Saveliy Tretiakov
17189649af For windows with WS_EX_DLGMODALFRAME sysmenu can be opened only by right mouse click
svn path=/trunk/; revision=24074
2006-09-11 15:49:42 +00:00
Hervé Poussineau
6f5c6f23d3 Fix halmp compilation
svn path=/trunk/; revision=24073
2006-09-11 14:35:46 +00:00
Saveliy Tretiakov
68f5e47ce6 This testapp demonstrates WS_SYSMENU + WS_EX_DLGMODALFRAME behavior
and shows that DrawCaption does care about WS_EX_DLGMODALFRAME and WS_EX_TOOLWINDOW.


svn path=/trunk/; revision=24072
2006-09-11 13:09:12 +00:00
Saveliy Tretiakov
529631027a Fix WS_SYSMENU+WS_EX_DLGMODALFRAME bug.
Fixes Messagebox broblem and some others.

svn path=/trunk/; revision=24071
2006-09-11 13:07:12 +00:00
Aleksey Bragin
d263039fe9 Add missing header
svn path=/trunk/; revision=24070
2006-09-11 13:01:39 +00:00
Hervé Poussineau
60fb482ad4 Fix compilation on Linux hosts - try #2
We can't use the _WIN32 symbol which is automatically defined once you include psdk/windef.h ...

svn path=/trunk/; revision=24069
2006-09-11 12:42:35 +00:00
Alex Ionescu
5fb31962db - Implement KiReleaseProcessLockFromDpcLevel and use it in KeTerminateThread. We were lowering to PASSIVE during thread termination, and then doing a context switch at PASSIVE, which you can guess is pretty bad.
svn path=/trunk/; revision=24068
2006-09-11 12:00:02 +00:00
Hervé Poussineau
07dc58982f We want to support hives version 1.3+ (up to 1.5 currently). Fix test accordingly
svn path=/trunk/; revision=24067
2006-09-11 11:28:54 +00:00
Hervé Poussineau
7b79f44d6b Better handling of REG_LINK values
Try to fix Linux build (thanks Usurp on IRC)

svn path=/trunk/; revision=24066
2006-09-11 11:04:33 +00:00
Saveliy Tretiakov
4f6a751b6f Implement NtGdiCloseFigure (Fixes BSOD!)
svn path=/trunk/; revision=24065
2006-09-11 11:01:35 +00:00
Saveliy Tretiakov
059fb2c54e Implement NtGdiFlattenPath
svn path=/trunk/; revision=24064
2006-09-11 10:43:42 +00:00
Alex Ionescu
c19a362969 - Implement HalProcessorIdle.
- Fix KiIdleLoop to actuall load the PCR in EBX. It was using a completely random value.
- Call the Processor Idle Routine now, isntead of hard-coding STI+HLT. This routine had already been setup during bootup by PoInitailizePrcb.
- Implemented PopIdle0 and made it call HalProcessorIdle. No performance/throttling is done yet.

svn path=/trunk/; revision=24063
2006-09-11 06:50:19 +00:00
Alex Ionescu
81997fc0bc - Implement and export HalClearSoftawareInterrupt (currently implemented to match the hacked ROS version, no new version written yet).
- Implement CPU Idle Loop in assembly for UP and SMP systems. Differences:
  * Runs with interrupts off most of the time, except when it does interrupt cycling at each iteration.
  * Calls KiRetireDpcList directly, instead of going through KiDispatchInterrupt.
  * Support for new scheduler and immediate thread switch.
  * Support for Idle Scheduler.
  * Support for HAL/ACPI/CPU Driver-defined "Idle Function". currently disabled and STI+HLT harcoded instead.
- Removed ps/idle.c and dumped the hack code directly in psmgr.c wher eit's used.

svn path=/trunk/; revision=24062
2006-09-11 06:22:26 +00:00
Alex Ionescu
a0fac81cfd - Add the actual missing code to KiQuantumEnd. It's asserted to make sure it'll never execute (yet).
- Add KiExitDispatcher from my new scheduler code. Same as KiQuantumEnd, added an assertion to make sure it doesn't enter in code paths that shouldn't yet happen.

svn path=/trunk/; revision=24061
2006-09-11 05:26:38 +00:00
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
Hervé Poussineau
bc6649b746 Put a NULL entry point if explicitly asked for. Thanks w3seek for his help on this issue
svn path=/trunk/; revision=24007
2006-09-09 20:39:50 +00:00
Christoph von Wittich
e10a07af00 *add support for the new SVN 1.4.x binary format
svn path=/trunk/; revision=24006
2006-09-09 20:38:41 +00:00
Magnus Olsen
eb1866f25c Implement GetLastInput base on bug 1753 patch by P43LOk,
It did not catch the last input tick  from keyboard or mouse. 
This code is not tested in reactos, but should work. 
See issue #1753 for more details.

svn path=/trunk/; revision=24005
2006-09-09 19:41:12 +00:00
Saveliy Tretiakov
70a18c5a4e Implement NtGdiGetPath (based on wine)
svn path=/trunk/; revision=24004
2006-09-09 19:26:43 +00:00
Hervé Poussineau
0f51b5f0bc Implement registry handle closing notifications in ntoskrnl
svn path=/trunk/; revision=24003
2006-09-09 19:08:37 +00:00
The Wine Synchronizer
4246de3191 Autosyncing with Wine HEAD
svn path=/trunk/; revision=24002
2006-09-09 17:48:42 +00:00
Hervé Poussineau
b5957ce896 Fix MsiDatabaseIsTablePersistentA/W prototype
Update msi_ros.diff file for upcoming update

svn path=/trunk/; revision=24001
2006-09-09 17:42:28 +00:00
Hervé Poussineau
8e420b3974 Implement "Check volume" page in usetup.
Doesn't work yet because VfatChkdsk() is not implemented

svn path=/trunk/; revision=24000
2006-09-09 17:11:03 +00:00
Hervé Poussineau
07f8340c15 Use Guid specified in device info set (if available) in SetupDiGetClassDevsExW.
Update some documentation (taken from Wine)

svn path=/trunk/; revision=23999
2006-09-09 17:10:51 +00:00
Hervé Poussineau
8dcf1980fe Set 2nd stage setup to language selected in registry
Try to use GetLastInputInfo API instead of a keyboard/mouse hook for screensaver (not enabled yet)

svn path=/trunk/; revision=23998
2006-09-09 17:10:42 +00:00
Hervé Poussineau
52d59f6a4f Don't use buffered input when reading username/password in text mode
svn path=/trunk/; revision=23997
2006-09-09 17:09:45 +00:00
Hervé Poussineau
4ca190a004 Remove useless member in DESKTOP_OBJECT structure
svn path=/trunk/; revision=23996
2006-09-09 17:09:33 +00:00
Hervé Poussineau
1dc7b0f6af Add VfatChkdsk() prototype
svn path=/trunk/; revision=23995
2006-09-09 16:47:09 +00:00
Saveliy Tretiakov
52c652809d revert last commit
svn path=/trunk/; revision=23993
2006-09-09 14:49:11 +00:00
Saveliy Tretiakov
b2dbae0fab Messageboxes shouldn't have WS_SYSMENU
svn path=/trunk/; revision=23992
2006-09-09 14:38:07 +00:00
Art Yerkes
812b97ae66 Correct bug in cache which could cause us to lose the last block of a file.
This is wierd and insidious, and probably was the cause of n00bs not being
able to boot on occasion.

svn path=/trunk/; revision=23990
2006-09-09 13:47:45 +00:00
Saveliy Tretiakov
68c6a664cf Replace MmCopyFromCaller with probing and seh.
svn path=/trunk/; revision=23988
2006-09-09 13:19:03 +00:00
Aleksey Bragin
e6bb607c6f [AUDIT]
- PE loading/relocating/fixups/etc is greatly documented in a number of sources (e.g. good russian-language article - http://www.uinc.ru/articles/41/, it has links to a different media describing loading process of PE)
- Nothing suspicious found in the code itself

svn path=/trunk/; revision=23987
2006-09-09 12:22:40 +00:00
Saveliy Tretiakov
c439fb86f7 Add winetests to bootcd
svn path=/trunk/; revision=23986
2006-09-09 11:42:52 +00:00
Aleksey Bragin
249e8c91ba Dmitry Philippov: GCC 4 compiling fixes for PackMgr and tests/wm_paint
svn path=/trunk/; revision=23985
2006-09-09 11:41:24 +00:00
KJK::Hyperion
dd77d1676b modified Resources/hresult.xml
Added S_OK and S_FALSE

modified   Resources/ntstatus.xml
    Added all possible STATUS_WAIT_XX codes as STATUS_WAIT_0 + XX

modified   TechBot.Console/App.config
    Don't use hard-coded paths, please!

modified   TechBot.Library/ErrorCommand.cs
    New and improved !error command, now performs heuristics to catch all possible or likely uses

modified   TechBot.Library/HresultCommand.cs
    Removed useless field

modified   TechBot.Library/NumberParser.cs
    Made a couple of methods static

modified   TechBot.Library/TechBotService.cs
    Disable !api until it fails gracefully

svn path=/trunk/; revision=23984
2006-09-09 10:53:28 +00:00
Art Yerkes
25c11e5f6e Make UNIMPLEMENTED available everywhere and remove some #ifdef cruft.
svn path=/trunk/; revision=23983
2006-09-09 09:41:09 +00:00
Thomas Bluemel
94a97e085a Added missing definitions
svn path=/trunk/; revision=23982
2006-09-09 09:26:26 +00:00
James Tabor
03a2724000 User32 static.c:
- Patch by Dmitry Timoshkov, modified for ReactOS.
    - Use computed icon rectangle if SS_CENTERIMAGE style is set.

svn path=/trunk/; revision=23981
2006-09-08 22:30:46 +00:00
Aleksey Bragin
9233af3e50 Add a bit of error reporting
svn path=/trunk/; revision=23980
2006-09-08 22:00:39 +00:00
The Wine Synchronizer
1869f86db6 Autosyncing with Wine HEAD
svn path=/trunk/; revision=23979
2006-09-08 20:13:51 +00:00
The Wine Synchronizer
8377230a7b Autosyncing with Wine HEAD
svn path=/trunk/; revision=23978
2006-09-08 20:12:06 +00:00
The Wine Synchronizer
5a367d19d2 Autosyncing with Wine HEAD
svn path=/trunk/; revision=23977
2006-09-08 20:08:45 +00:00
The Wine Synchronizer
527fb9fa9b Autosyncing with Wine HEAD
svn path=/trunk/; revision=23976
2006-09-08 19:33:33 +00:00
Aleksey Bragin
335e03625a Fix invalid charset (DOS -> Windows)
svn path=/trunk/; revision=23975
2006-09-08 15:39:34 +00:00
Hervé Poussineau
9243a83d80 Adapt usetup to handle more easily additional filesystems
This also prepares ground for the Chkdsk disk page

svn path=/trunk/; revision=23974
2006-09-07 22:42:28 +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
254f6b62ac - More MSVC fixes (down to 19 errors):
- Header changes: fix FILE_LOCK_INFO, LARGE_MCB, BASE_MCB, MM_SYSTEMSIZE.
- Remove many things in W32API which are incorrectly there (due to winnt being used by the win32api DDK). Defined them in the NDK instead, where appropriate (mostly definitions that are present in user-mode headers, but not kernel-mode headers).
- Hacked the ERESOURCE functions to define a special ERESOURCE_XP type. This is necessary because ERESOURCE is an opaque-yet-exported structure, and its structure changed in Vista.
- Removed support for IMAGE_SCN_TYPE_NO_LOAD. It is a reserved field and Windows does not "respect" it. (sections marked as no-load will still be loaded by NT).

svn path=/trunk/; revision=23972
2006-09-07 21:36:15 +00:00
Hervé Poussineau
7d80cdabff Add ufat.dll and the optional ufatx.dll (to be added later to repository)
svn path=/trunk/; revision=23971
2006-09-07 20:57:02 +00:00
Hervé Poussineau
8c22629a9e [FORMATTING] Fix tab/space mess by replacing them by 4 spaces. No code change
svn path=/trunk/; revision=23970
2006-09-07 20:15:45 +00:00
Hervé Poussineau
1b337150cc Update prototypes
svn path=/trunk/; revision=23969
2006-09-07 19:46:18 +00:00
James Tabor
2fad285b14 Removed NtUserGetKeyboardType, there was no win32k.db entry for it.
svn path=/trunk/; revision=23968
2006-09-07 19:23:39 +00:00
Thomas Bluemel
3a4bb3b8dc Yes we should do it as WINE. Fixes a buffer overflow in RtlDetermineDosPathNameType_U()
svn path=/trunk/; revision=23967
2006-09-07 19:20:42 +00:00
Hervé Poussineau
2417bf273f Correctly handle optional parameters
svn path=/trunk/; revision=23966
2006-09-07 19:16:47 +00:00
Hervé Poussineau
022504ad3c Some 64 bits fixes (approved by Filip)
svn path=/trunk/; revision=23965
2006-09-07 19:13:37 +00:00
Hervé Poussineau
a2548c11a4 Fix format.exe compilation
svn path=/trunk/; revision=23964
2006-09-07 18:08:00 +00:00
Hervé Poussineau
24ff7a71b4 Fix compilation
svn path=/trunk/; revision=23963
2006-09-07 17:55:51 +00:00
Hervé Poussineau
0d173915ac Correctly implement autochk, which now calls the ChkdskEx function in u{FS}.dll.
svn path=/trunk/; revision=23962
2006-09-07 17:54:23 +00:00
Hervé Poussineau
611b577fd6 Add a stub for FAT12/16/32 chkdsk
svn path=/trunk/; revision=23961
2006-09-07 17:44:08 +00:00
Hervé Poussineau
eb50899ee0 Declare prototype for ChkdskEx function in u{FS}.dll
svn path=/trunk/; revision=23960
2006-09-07 17:39:42 +00:00
Magnus Olsen
3387c46e16 fixed win32k build, trunks builds again thanks w3seek for the help
svn path=/trunk/; revision=23959
2006-09-07 17:35:31 +00:00
Hervé Poussineau
8f329a8565 Fix typo: _GNUC_ -> __GNUC__
svn path=/trunk/; revision=23958
2006-09-07 13:47:14 +00:00
Magnus Olsen
861ae4bcca fixed rosapps so it compiles again
svn path=/trunk/; revision=23957
2006-09-07 11:10:27 +00:00
Magnus Olsen
01acfd4778 fixed follow test, acclertor, alive, alphablend, bitblt, button, button2, capclock, carets, combotst, dibtest, dirdlg, DxHalTest, edit, enhmetafile, enumfonts, enumwnd, enumws, gradient, hello, hivtest, icontest, lineclip, linetest, mdi, midtest
svn path=/trunk/; revision=23956
2006-09-07 10:31:37 +00:00
Magnus Olsen
433252a084 fixed ctm, kill, lsdd, man, regexpl, tcat can be build again
svn path=/trunk/; revision=23955
2006-09-07 10:01:22 +00:00
Magnus Olsen
d6a960a884 fixed so packmgr builds again
svn path=/trunk/; revision=23954
2006-09-07 09:53:25 +00:00
Magnus Olsen
c410304d3c fixed waring msg newline
svn path=/trunk/; revision=23953
2006-09-07 09:46:50 +00:00
Magnus Olsen
d287153576 fixed all network apps in rosapps.
svn path=/trunk/; revision=23952
2006-09-07 09:42:17 +00:00
Magnus Olsen
e3d7c1e7aa 1. fixed mc build again
2. fixed some warnings

svn path=/trunk/; revision=23951
2006-09-07 09:17:39 +00:00
Johannes Anderwald
4d044a7f0d * fix building ntoskrnl
svn path=/trunk/; revision=23950
2006-09-07 09:06:47 +00:00
Magnus Olsen
a5ea7e70cd fixed gdb2 build thx hpoussin for the host info
svn path=/trunk/; revision=23949
2006-09-07 08:50:42 +00:00
Magnus Olsen
fa303561af fixed build for ddraw_demo
svn path=/trunk/; revision=23948
2006-09-07 08:29:06 +00:00
Magnus Olsen
e32b3e7588 fixed build for maze again
svn path=/trunk/; revision=23947
2006-09-07 08:26:54 +00:00
Magnus Olsen
b780b50b58 fixed build for touch again
svn path=/trunk/; revision=23946
2006-09-07 08:23:54 +00:00
Magnus Olsen
49b27aaae4 fixed mode can be compile again.
svn path=/trunk/; revision=23945
2006-09-07 08:20:29 +00:00
Magnus Olsen
bff34182eb update shlguid, remove the dublacte guid, winefiles can be build now again
svn path=/trunk/; revision=23944
2006-09-07 07:14:49 +00:00
Magnus Olsen
d6fbed40b0 include psdk shlguid.h
svn path=/trunk/; revision=23943
2006-09-07 07:13:07 +00:00
Magnus Olsen
e50296456b Fixed so explorer can be compiling again.
Have not tested with rest of reactos if this break any anything. 

svn path=/trunk/; revision=23942
2006-09-07 06:36:33 +00:00
Alex Ionescu
dd25974e25 - More MSVC fixes:
Additions or changes to headers: FSRTL_PER_FILEOBJECT_CONTEXT, FsRtlAreNamesEqual uses CONST buffers, KiIpiGenericCall + PKPIP_BROADCAST_WORKER, MmPageEntireDriver returns PVOID, Obf(De)referenceObject return LONG_PTR, KeGetPreviousMode is ExGetPreviousMode. KeGetCurrentPrcb is reimplemented in inline, MAX_PATH exposed to drivers.
- Changes: STATIC->static. static __inline ->FORCEINLINE. STDCALL -> NTAPI (Some). WORD/DWORD/BYTE -> NT Types.
- Kernel bugs fixed: Some string concatenations were broken, some functions had wrong return values.

svn path=/trunk/; revision=23941
2006-09-07 05:07:34 +00:00
Thomas Bluemel
17e434d5bd Add user32 to build notifyhook
svn path=/trunk/; revision=23940
2006-09-06 21:44:06 +00:00
Brandon Turner
80562db631 Link to shell32 so we can use CommandLineToArgvW when compiling unicode. Thanks to Usurp for finding the problem.
svn path=/trunk/; revision=23939
2006-09-06 21:17:23 +00:00
Johannes Anderwald
29a8ffa699 * add console.dll to bootcd
* add setting for unattended GUI setup (disabled)

svn path=/trunk/; revision=23938
2006-09-06 21:12:06 +00:00
Art Yerkes
e1ba8f15ae Fix this properly: specify the search path among our various header sets.
svn path=/trunk/; revision=23937
2006-09-06 20:58:02 +00:00
Art Yerkes
d7a2739bdf Ditto.
svn path=/trunk/; revision=23936
2006-09-06 20:31:11 +00:00
Art Yerkes
ec6a7a35c4 Added _fpreset prototype. Not sure why this isn't picked up here.
svn path=/trunk/; revision=23935
2006-09-06 20:30:28 +00:00
Thomas Bluemel
3c13ad4c32 Delete empty directory
svn path=/trunk/; revision=23934
2006-09-06 20:10:02 +00:00
Thomas Bluemel
02a7a31265 - Force using the import libraries built by ReactOS only, don't use the ones that come with the mingw compiler (doesn't work for CPP!)
- Import the mingw startup library and customized it a little. _tmain() is now supported, compiling an application as unicode is now just a matter of setting the module attribute unicode="true"
- Fixed .rbuild files to import all libraries neccessary
- Various GUID header changes and hacks to get everything to build/link properly
- Fixed the IShellView2 interface

svn path=/trunk/; revision=23933
2006-09-06 20:00:41 +00:00
Magnus Olsen
292bb9268e [Audlt] this file was written by filip for mingw w32sapi, and it contain few GUID from wine to keep wine dsound happy.
I did add the GUID from wine. 

svn path=/trunk/; revision=23932
2006-09-06 19:57:19 +00:00
Magnus Olsen
d009b08d81 [Audlt] this file was written by filip for mingw w32sapi and it same as mingw w32aspi,
svn path=/trunk/; revision=23931
2006-09-06 19:51:03 +00:00
Johannes Anderwald
753aa1c0e2 * halfplement reading / writing Console User settings
* remove hardcoded constants
* shuffle initialization code :-)
* changing console text / background color now works :-)))))))
* changing cursor works only for one input (needs be investigated)

svn path=/trunk/; revision=23930
2006-09-06 19:37:53 +00:00
Thomas Bluemel
7aae13b091 Fixed difference in signedness warnings
svn path=/trunk/; revision=23929
2006-09-06 19:28:35 +00:00
Thomas Bluemel
84269d7917 Fixed difference in signedness warnings
svn path=/trunk/; revision=23928
2006-09-06 18:59:30 +00:00
Aleksey Bragin
7f0a82ce58 Fix MSVC 2005 compilation (Platform SDK is correctly included)
svn path=/trunk/; revision=23927
2006-09-06 18:43:35 +00:00
Saveliy Tretiakov
1fc89de847 Some win32k docs (from win32k rewrite branch).
svn path=/trunk/; revision=23926
2006-09-06 16:31:03 +00:00
Alex Ionescu
f0af84da4e - MSVC Build Fixes
svn path=/trunk/; revision=23925
2006-09-06 12:19:00 +00:00
Magnus Olsen
173cb3c677 update it.rc languages translation by gabrielilardi at hotmail.it (Gabriel ilardi)
svn path=/trunk/; revision=23924
2006-09-05 20:46:24 +00:00
Saveliy Tretiakov
90759eb5a2 Call NtUserDrawCaption directly
svn path=/trunk/; revision=23923
2006-09-05 16:28:20 +00:00
Johannes Anderwald
4da1de7ca1 * msvc compiling fix
svn path=/trunk/; revision=23922
2006-09-05 10:14:40 +00:00
Brandon Turner
d6d0d40cad Implement CryptSignHashW based WINE and old CryptSignHashA. Change CryptSignHashA to call CryptSignHashW.
svn path=/trunk/; revision=23921
2006-09-04 22:51:28 +00:00
Hervé Poussineau
d5168c3b05 Allow allow lower case when being called
svn path=/trunk/; revision=23920
2006-09-04 22:16:43 +00:00
Hervé Poussineau
aa34958d1b Add a hack to enable formatting (was broken since at least r20156)
svn path=/trunk/; revision=23919
2006-09-04 21:58:38 +00:00
Johannes Anderwald
478f24b02b * use ConsoleInfo struct directly
* change type in global struct (avoid buffer overflow when reading value from registry)

svn path=/trunk/; revision=23918
2006-09-04 21:26:49 +00:00
Hervé Poussineau
94b07b79db Add ufat.dll, to be able to format drives to FAT and FAT32 format
svn path=/trunk/; revision=23917
2006-09-04 20:55:39 +00:00
Thomas Bluemel
7ed51f5c9e rename version.h to ver.h to avoid a possible conflict with include/reactos/version.h
svn path=/trunk/; revision=23916
2006-09-04 20:14:48 +00:00
Hervé Poussineau
90d5c19850 Remove Vfat(x)Initialize and Vfat(x)Cleanup which were empty
Remove vfatlib dependancy of fmifs.dll (Providers like ufat.dll are loaded dynamically at startup)

svn path=/trunk/; revision=23915
2006-09-04 19:27:19 +00:00
Hervé Poussineau
132cf4ece8 [FORMATTING] Add standard headers
Replace the mix of tabs/spaces by tabs
Replace STDCALL by NTAPI

svn path=/trunk/; revision=23914
2006-09-04 17:11:14 +00:00
Hervé Poussineau
4ba3312a81 Add prototypes for some fmifs.dll functions.
These have been found with trial and error on a MS Windows XP SP2 system with MS Visual Studio 2003

svn path=/trunk/; revision=23913
2006-09-04 16:46:13 +00:00
Hervé Poussineau
e094312326 Fix compilation of rosapps with gcc 3.4.5.
Thanks Gge on IRC

svn path=/trunk/; revision=23912
2006-09-04 16:29:00 +00:00
Johannes Anderwald
c12e6bbcba * move reading / applying options out of console.dll
* remove unused code
* notify win32csr when a property has changed

svn path=/trunk/; revision=23911
2006-09-04 13:13:42 +00:00
KJK::Hyperion
8ee7f4296b PSEH was based on clean-room reverse engineering (read: trial-and-error) and on the pre-existing work of Matt Pietrek, just like the exception handling code used in Wine. I, the author, declare it clean
svn path=/trunk/; revision=23910
2006-09-04 12:04:54 +00:00
James Tabor
ab4e2c9cf4 User32 bitmap.c:
- Patch by Michael Kaufmann
  - CopyImage: Handle the flags LR_COPYDELETEORG, LR_CREATEDIBSECTION, and LR_MONOCHROME.

svn path=/trunk/; revision=23906
2006-09-04 03:08:18 +00:00
James Tabor
76b17ae494 User32 combo.c:
- Patch by Dmitry Timoshkov
  - do not force repainting on WM_WINDOWPOSCHANGED in combobox, it
    breaks Z-order based painting.
  - do nothing in the combobox WM_ERASEBKGND handler do all painting in
    WM_PAINT like Windows does.


svn path=/trunk/; revision=23905
2006-09-04 03:03:14 +00:00
Magnus Olsen
09a8680165 Adding small hack to getting SetPixel color right when it is more that 3 bytes long.
This hack allown us pass one more test. (Debuging in progress)

svn path=/trunk/; revision=23904
2006-09-03 22:54:22 +00:00
Alex Ionescu
9fbb616938 - Final cleanup for now:
- main.c -> freeldr.c + cleanups and nice formatitng.
  - Move out variables that were in main.c to ex\init.c or cpu.c, depending.
  - Separate i386/kernel.c into i386/kiinit.c for X86-specific intiailization, and /krnlinit.c for portable initialization across all architectures. Also move out global variables appropriately.
  - main_asm.S -> cpu.S

svn path=/trunk/; revision=23903
2006-09-03 21:06:30 +00:00
Hervé Poussineau
00abb85d36 Reorder the file
Add some more defines/typdefs from Wine sspi.h
Fix a few typos

svn path=/trunk/; revision=23902
2006-09-03 21:02:09 +00:00
Alex Ionescu
c65323691c - Add Ke386SetInterruptDescriptorTable inlined function to set the IDT.
- Rename and fixup initial stacks, instead of using 16 different variables all with confusining meanings and values. Define P0BootStack as the initial kernel stack, and KiDoubleFaultStack as the double-fault trap (and initial DPC) stack.
- Fix call to KiInitializePcr which was setting an incorrect DPC stack.
- Make space on the initial stack for a KTRAP_FRAME as well, not only for the FPU save area.
- Also push initial CR0 NPX state on the initial stack.
- Load the IDT and GDT directly in KiRosPrepareForSystemStartup.
- Completely rewrite main_asm.S in Intel syntax and clean it up.

svn path=/trunk/; revision=23901
2006-09-03 19:57:55 +00:00
Aleksey Bragin
4eebe5e53f Add comptypeDIB definition to headers
svn path=/trunk/; revision=23900
2006-09-03 19:38:16 +00:00
Magnus Olsen
7fe1969532 Fixed one more bug, we did create wrong bpp if we got HDC = NULL for CreateDIBitmap, when I read wine code
it is always 1Bpp and 1Plans and we are doing same now if HDC is NULL, some wine test deepness on it. 
Hopply it will take care of some program problem. 

svn path=/trunk/; revision=23899
2006-09-03 18:16:08 +00:00
Alex Ionescu
c6f105da0b - Add Ke386SetFs, Ds, Es (using Ke386SetSeg) and Ke386SetTr new inlined commands.
- Also setup an NMI Task gate after the double fault task gate. Will be useful when we hand to handle NMIs later.
- Setup FS in KiSystemStartup and initialize the TSS before the PCR. Also add a bit more support for SMP systems (To skip boot-cpu-only initialization).
- Also setup DS/ES directly in KiSystemStartup.
- Initialize KD at phase 0 in KiSystemStartup, not in KiInitializeKernel, and also check for debug break at this time.

svn path=/trunk/; revision=23898
2006-09-03 17:18:08 +00:00
Hervé Poussineau
25090facc3 Allow setup to detect extended partitions
svn path=/trunk/; revision=23896
2006-09-03 12:32:15 +00:00
Alex Ionescu
d8155f97a7 - Remove LDT initialization, LDT shouldn't be initialized at bootup.
- Move LDT-only GDT routines to ldt.c
- Cleanup formatting of GDT-related exported function stubs in gdt.c and rename file to abios.c. Those routines deal specifically with the ABIOS GDT selectors and are for ABIOS support.
- Move the lone 2 routines in fpu.c to cpu.c.

svn path=/trunk/; revision=23895
2006-09-03 07:13:02 +00:00
Alex Ionescu
6b42f391e0 - Fix KTSS definition.
- Add GetSegment inlines (ie: GetSs, GetDs, etc)
- Fix up definition of KiBootGdt to use KGDTENTRY instead of USHORT. Also define KiGdtDescriptor using KDESCRIPTOR.
- Remove GDT initialization code completely. The GDT is already initialized on boot.
- Remove tss.c and add KiInitializeTss(2) to setup a TSS and proper IOPM/Interrupt Direction map settings for V86/VDM.
- Copy the TSS code over but prettyify it to use NT/NDK structures instead of ugly USHORT typecasts.

svn path=/trunk/; revision=23894
2006-09-03 06:51:03 +00:00
Magnus Olsen
00f50dd922 Fixed some more wine test for NtGdiGetDIBits
FIxed so we can now create BITMAPCOREHEADER bitmap (Bugs in NtGdiGetDIBits did stop create of it) 



svn path=/trunk/; revision=23892
2006-09-02 23:58:53 +00:00
Magnus Olsen
7aa07b393c 1. Copy DIB_GetBitmapInfo from wine cvs (date 2/9-2006)
2. Bugfix NtGdiGetDIBits the BITMAPCOREHEADER is not same as BITMAPINFOHEADER
   we now separate it in if(Bits==NULL) that will allow us pass two more wine tests
   follow winetest is working now 
   1. bitmap.c 227 Test failed: GetDIBits doesn't work with a BITMAPCOREHEADER 
   2. bitmap.c 233 GetDIBits doesn't work with a BITMAPCOREHEADER 
   both of them are fixed now 

svn path=/trunk/; revision=23891
2006-09-02 21:02:03 +00:00
Aleksey Bragin
7bfe48177c Separate Device Manager code (what was left from it in hub.c) from Hub code
svn path=/trunk/; revision=23890
2006-09-02 20:32:50 +00:00
Alex Ionescu
252a2d1598 - Part 2 of 2: Implement KiDispatchInterrupt in assembly since it's 1) Perf-critical 2) Requires us to switch the stack to the DPC stack, which is unsafe (and impossible, unless inlining) in C.
svn path=/trunk/; revision=23889
2006-09-02 19:53:24 +00:00
Alex Ionescu
0f9c7bdf03 - Part 1.5 of 2: Re-factor KiDispatchInterrupt to separate DPC delivery routine (so that it can stay in C, since KiDispatch should be done in ASM so we can switch stacks).
- Use interrupt enable/disable instead of raising to HIGH_LEVEL.
  - Better use and pairing of locks.
  - Fix a lot of race conditions in DPC dispatching, due to the fact almost all data we're touching is ultra-volatile and can change at any time depending on various locks being held/released + interrupt state.
  - Add stub code/support for tick-hased table-based timer implementation and deferred threads.

svn path=/trunk/; revision=23888
2006-09-02 19:12:31 +00:00
Alex Ionescu
7802140549 - Fix a bug in RtlFillMemory.
- Fix overlap check comments.

svn path=/trunk/; revision=23887
2006-09-02 16:36:48 +00:00
Alex Ionescu
38ca1d7d77 - Add missing volatile statements to KPROCESS, KTHREAD, KPRCB and KDPC_DATA.
- Fix KDPC definition in DDK. You can always count on the w32api to get even the simplest structures wrong.
- Fix memory overwrite bug in KiInitSpinlocks.
- Part 1 of 2: Cleanup and improve DPC implementation to add partial support for Threaded DPCs and remove SMP vs non-SMP ifdefs. (At the expense of, oh God, 5 wasted CPU cycles!).

svn path=/trunk/; revision=23886
2006-09-02 16:19:00 +00:00
Aleksey Bragin
ea0c0daec0 Add forgotten "xs-native.cpp" to the MSVC project of ROS Explorer
svn path=/trunk/; revision=23885
2006-09-02 11:27:36 +00:00
The Wine Synchronizer
99b4a1d7ee Autosyncing with Wine HEAD
svn path=/trunk/; revision=23883
2006-09-02 06:27:09 +00:00
The Wine Synchronizer
8dff62e1f8 Autosyncing with Wine HEAD
svn path=/trunk/; revision=23882
2006-09-02 06:24:20 +00:00
Alex Ionescu
aa69c69afb - Move machine-specific initializations to KeInit2.
- Initialize bugcheck messages much earlier, separate clock initialization from KeInit2.
- Completely move out and isolate ROS/FREELDR PE loading hacks to KiRosPrepareForSystemStartup so that KiSystemStartup is clean of them.

svn path=/trunk/; revision=23881
2006-09-02 05:10:16 +00:00
Alex Ionescu
ea01969067 - More Initialization changes:
- Initialize bugcheck lists, timer DPC, profile list/locks, timer lists, the swap lists and syscall table as part of KiInitSystem (portable).
   - Add more initialization for the initial/idle process+thread (some code disabled due to dispatcher problems).
   - Add code to support future Timer implementation (based on tick-hashes)
   - Separate post-boostrap initialization code in KiInitializeKernel.
   - Add some support for future SMP paths.
   - Create a DPC stack.
- Changes based on WI4 and my automated parsing tool.

svn path=/trunk/; revision=23880
2006-09-02 04:40:09 +00:00
Alex Ionescu
deed4ed0d6 - More kernel initialization changes and cleanups.
- Start support for an initial boot thread.

svn path=/trunk/; revision=23879
2006-09-02 02:59:44 +00:00
Thomas Bluemel
dbf97f3b50 Fix creating the console system menu items
svn path=/trunk/; revision=23878
2006-09-01 23:18:23 +00:00
Hervé Poussineau
c2d18fb0b6 Add softpub.h header
svn path=/trunk/; revision=23877
2006-09-01 23:06:32 +00:00
The Wine Synchronizer
abb022f081 Autosyncing with Wine HEAD
svn path=/trunk/; revision=23876
2006-09-01 22:47:57 +00:00
Hervé Poussineau
e1d577c47c Add a stub sensapi.dll. This is a step to fix bug 1751
svn path=/trunk/; revision=23875
2006-09-01 22:41:31 +00:00
Hervé Poussineau
43d85c0abc Add some error codes (taken from Wine)
svn path=/trunk/; revision=23874
2006-09-01 22:10:56 +00:00
Thomas Bluemel
00c354405e Don't call BeginPaint/EndPaint while processing a WM_DRAWITEM message
svn path=/trunk/; revision=23873
2006-09-01 21:53:31 +00:00
Thomas Bluemel
c474673ac7 disable code that dereferences a random pointer
svn path=/trunk/; revision=23871
2006-09-01 18:56:06 +00:00
Thomas Bluemel
13e3041822 Don't leak a reference in NtReleaseSemaphore() in case KeReleaseSemaphore() raises and exception
svn path=/trunk/; revision=23870
2006-09-01 18:41:00 +00:00
Thomas Bluemel
4a586b2eb2 remove superfluous dereference
svn path=/trunk/; revision=23869
2006-09-01 18:20:44 +00:00
Ged Murphy
61059050bb - Use a more generic print service
- don't assign a service name at the start as it causes problems when query(ex) doesn't supply one.
- Simplify the service starting code.
- Add missing options to the print type
- rewrite the querying functionality to be cleaner, and use existing code.
- remove the braces I left, used for collapsing dbg info

svn path=/trunk/; revision=23868
2006-09-01 16:55:36 +00:00
Eric Kohl
9e843c89fc Fix indentation, no code changes.
svn path=/trunk/; revision=23867
2006-09-01 15:49:50 +00:00
Alex Ionescu
a85e942346 - More initialization cleanup.
svn path=/trunk/; revision=23866
2006-09-01 13:13:08 +00:00
Hervé Poussineau
562f8391e8 Fix build when compilation units are enabled for usetup.c
svn path=/trunk/; revision=23865
2006-09-01 12:58:56 +00:00
Alex Ionescu
5244a29dad - Fix bugs in RtlCompareMemory, RtlCompareMemoryULong
svn path=/trunk/; revision=23864
2006-09-01 12:38:57 +00:00
Eric Kohl
6b8b0b56b2 Remove trailing whitespace
svn path=/trunk/; revision=23863
2006-09-01 11:16:32 +00:00
Hervé Poussineau
f05d1bb617 Fix option selection in bootcd
Fix SetupOpenFileQueue, SetupCloseFileQueue and SetupCommitFileQueueW prototypes to match setupapi.dll ones

svn path=/trunk/; revision=23862
2006-09-01 09:53:33 +00:00
Alex Ionescu
30f4d83978 - Add back defines accidentaly removed.
svn path=/trunk/; revision=23854
2006-09-01 03:19:25 +00:00
Alex Ionescu
ad9fdb1ae3 - Fix bug in RtlZero, Fill, Move memory where the last 1-3 bytes weren't being copied.
svn path=/trunk/; revision=23853
2006-09-01 03:15:32 +00:00
Alex Ionescu
369f93b984 - Multiple changes to low-level Kernel initalization sequence to bring it a bit closer to Windows.
- Main difference is new CPU detection algorithms for ID, cache, etc, as well as using KF_ Kernel Feature bits instead of x86 CPU features (For portability).
- Also many many other cleanups and re-sequencing.

svn path=/trunk/; revision=23852
2006-09-01 03:05:30 +00:00
Ged Murphy
3c411c196d forgot to turn debugging off
svn path=/trunk/; revision=23850
2006-08-31 22:51:28 +00:00
Alex Ionescu
01081d279e - Some cleanups
- Add support for recovering from user-mode win32k callback fault.
- Also add support for debug register saving/reloading during user-mode callbacks and return.

svn path=/trunk/; revision=23849
2006-08-31 18:10:11 +00:00
Ged Murphy
158e4c116a first commit of an overhaul of sc.exe
- establish a connection to the SCM for each separate request, allowing the minimum privlidges required, instead of a generic (over privlidged) one.
- start to move service printing to separate functions and reduce code duplication
- make output 100% as per Windows
- fix some commands, e.g. 'interrogate'
- improve error checking
- improve code structure

svn path=/trunk/; revision=23848
2006-08-31 17:59:02 +00:00
Eric Kohl
8537a75fba Pass additional arguments to a service when it is started by a call to StartService.
svn path=/trunk/; revision=23846
2006-08-31 17:16:19 +00:00
Alex Ionescu
5a633f8fc9 - Remove some deprecated code and custom ROS exports/code.
svn path=/trunk/; revision=23845
2006-08-31 17:10:58 +00:00
Thomas Bluemel
87ab1c53a7 Add stubs for the condition variable functions
svn path=/trunk/; revision=23844
2006-08-31 16:56:49 +00:00
Aleksey Bragin
26b82125e5 Change a very ugly done DbgPrint() function to a good implementation. Now Freeldr shows all DPRINTs from e.g. cmlib correctly.
svn path=/trunk/; revision=23843
2006-08-31 16:08:17 +00:00
Aleksey Bragin
5cd8b68023 Sylvain Petreolle: Partly fix unicode build of cmd (a typo)
svn path=/trunk/; revision=23842
2006-08-31 14:14:42 +00:00
Hervé Poussineau
02d5b53e84 Add ATTACH_PARENT_PROCESS constant
svn path=/trunk/; revision=23841
2006-08-31 14:11:33 +00:00
Hervé Poussineau
1ebc320243 Remove some code duplication when calling PopupError
Add ConAttachConsole stub

svn path=/trunk/; revision=23840
2006-08-31 12:35:39 +00:00
Hervé Poussineau
8b597b0970 Fix build for Linux people, where gcc claims that it doesn't support I64 for printf. Thanks Usurp on IRC
svn path=/trunk/; revision=23839
2006-08-31 12:31:34 +00:00
Hervé Poussineau
ed70ab7f26 Fix Linux build (filename case problem...) Thanks gregj on IRC
svn path=/trunk/; revision=23837
2006-08-31 11:09:05 +00:00
Hervé Poussineau
cc2684d474 Cleanup in .inf file handling of usetup:
- Equivalent setupapi functions have the same protoype as in Win32 API
- Extra functions have the INF_* prefix

svn path=/trunk/; revision=23836
2006-08-31 09:13:03 +00:00
Hervé Poussineau
f52bca045b Clean up console functions in usetup. We now have 2 categories:
- The same functions as in Win32 Console API, prefixed with Con
- The helpers (which call Con* functions) prefixed with CONSOLE_
Do according changes in other files

svn path=/trunk/; revision=23834
2006-08-31 06:14:25 +00:00
Alex Ionescu
e870b20916 - Don't do fast system calls with the wrong DS/ES selectors.
- Properly load DS/ES on system startup and GDT load
- Use proper DS/ES during deprecated IRQ handling.
- Always use GS as 0 for all of the above.
- *FINALLY* fixes the oldest bug there ever was -> DS/ES corruption noticed in VMWare (And recently in QEMU+KERNELKQEMU, since it behaves internally like vmware). Hacks in trap code have FINALLY been removed!

svn path=/trunk/; revision=23833
2006-08-31 05:25:58 +00:00
Alex Ionescu
d2ba2fdc17 - Implement more parts of the GPF Handler.
- Add support for lazy loading.
- QEMU + -kernel-qemu seems to work now.
- Hack away the Win32k bug that's been there for ages (copy to user-mode from kernel-mode failing due to probe due to incorrect previous mode). It's not the right fix, but nobody seems to be willing to fix it, and it doesn't make anything less stable, sicne the actually copy is in SEH anyway. It opens a security vuln. (wow, not like we have 15000) in exchange for fixing dozens of win32k bugs and failures.

svn path=/trunk/; revision=23832
2006-08-31 04:10:33 +00:00
Pablo Borobia
e82f58c755 Testing commit
svn path=/trunk/; revision=23831
2006-08-31 03:12:14 +00:00
Alex Ionescu
e4e58dde50 - Write new, optimized, small, working and clean functions (fixes booting, last few commits broke it for me):
- RtlCompareMemory
    - RtlCompareMemoryUlong
    - RtlFillMemory
    - RtlFillMemoryUlong
    - RtlFillMemoryUlongUlong
    - RtlMoveMemory
    - RtlZeroMemory
    - RtlPrefetchMemoryNonTemporal
    - RtlUshortByteSwap
    - RtlUlongByteSwap
    - RtlUlonglongByteSwap

svn path=/trunk/; revision=23830
2006-08-31 01:20:55 +00:00
Thomas Bluemel
5b8d955fb7 Fix difference in signedness warnings
svn path=/trunk/; revision=23829
2006-08-30 21:47:38 +00:00
Thomas Bluemel
1fcf9ceba0 Use the new ProbeForWriteIoStatusBlock macro
svn path=/trunk/; revision=23828
2006-08-30 21:45:17 +00:00
Thomas Bluemel
176e324621 - Fix some probing macros
- Add probing macros for IO_STATUS_BLOCK structures
- Added two inline functions ProbeArrayForRead() and ProbeArrayForWrite(), mainly for use in win32k as they also check for integer overflows.

svn path=/trunk/; revision=23827
2006-08-30 21:44:12 +00:00
Magnus Olsen
0d6e03c305 Wrote RtlUshotByteSwap RtlUlongByteSwap and RtlUlonglongByteSwap to asm code.
but we need a C api for header to linking it right. Put the asm version to i386 

svn path=/trunk/; revision=23826
2006-08-30 21:17:53 +00:00
Thomas Bluemel
73120d4d50 Revert r23824. This needs to go into the clipboard branch for now.
svn path=/trunk/; revision=23825
2006-08-30 20:59:32 +00:00
Pablo Borobia
0effbf25dc * added GetLayout definition
* added Clipboards definitions
* added GetLastInputInfo definition

svn path=/trunk/; revision=23824
2006-08-30 20:56:17 +00:00
Thomas Bluemel
a65807043a Revert r23810, r23811, r23813. The clipboard changes are in the clipboard branch for now.
svn path=/trunk/; revision=23823
2006-08-30 20:40:07 +00:00
Hervé Poussineau
15d6307da5 mpr.dll can now be autosynced with Wine
svn path=/trunk/; revision=23822
2006-08-30 20:37:56 +00:00
Ged Murphy
08ecb38f3b update msi wine regtest
svn path=/trunk/; revision=23821
2006-08-30 20:37:49 +00:00
Ged Murphy
0ce8d02acc update comctl32 winetest
svn path=/trunk/; revision=23818
2006-08-30 20:28:33 +00:00
Hervé Poussineau
42b655b8f9 avifil32.dll can now be autosynced with Wine
svn path=/trunk/; revision=23816
2006-08-30 20:16:11 +00:00
Hervé Poussineau
85bfb7d006 wineimport.cmd (>= r23814) is now able to handle msi.dll autosync. Mark it as such.
svn path=/trunk/; revision=23815
2006-08-30 20:01:42 +00:00
Pablo Borobia
fc86ed2df2 * Added more clipboard regression tests
svn path=/trunk/; revision=23813
2006-08-30 19:46:40 +00:00
Hervé Poussineau
4c7a515ebc Add msi_ros.diff
svn path=/trunk/; revision=23812
2006-08-30 19:41:09 +00:00
Pablo Borobia
38bee199b7 shel32.dll part:
* Clipboard implemtation in win32k and user32
* Added a clipboard system for each Window Station
* GetLastInputInfo implementation
* GetLayout in win32k Stubs
* Shell32 changes to cut/copy & paste link/paste
* Implemented ALT+PrintScreen to clipboard

svn path=/trunk/; revision=23811
2006-08-30 19:35:54 +00:00
Pablo Borobia
5a624910f1 user32.dll part:
* Clipboard implemtation in win32k and user32
* Added a clipboard system for each Window Station
* GetLastInputInfo implementation
* GetLayout in win32k Stubs
* Shell32 changes to cut/copy & paste link/paste
* Implemented ALT+PrintScreen to clipboard

svn path=/trunk/; revision=23810
2006-08-30 19:35:22 +00:00
Alex Ionescu
3d10f77c92 - It should now be safe to remove the V86 ESP0 hack, since V86 mode works fine (tested on VMWare/QEmu).
svn path=/trunk/; revision=23809
2006-08-30 19:29:16 +00:00
Hervé Poussineau
21aef1a7a7 Update MSI to current Wine version.
Autosync will be put in place very soon for this dll.

svn path=/trunk/; revision=23808
2006-08-30 19:24:26 +00:00
Ged Murphy
6d52441d10 [WINESYNC]
update comctl32 to Wine_0.9.20

svn path=/trunk/; revision=23807
2006-08-30 19:18:49 +00:00
Thomas Bluemel
900bf1a753 Implement Slim Reader/Writer (SRW) locks:
- Implement AcquireSRWLockExclusive(), AcquireSRWLockShared(), InitializeSRWLock(), ReleaseSRWLockExclusive(), ReleaseSRWLockShared()
- NOTE: Some versions of GCC have a code generation bug with specially aligned structures on the stack. If compiled with such a compiler, the code might trigger special assertions. Pushlocks are also affected by this compiler bug.
- NOTE: The algorithms are most likely not the same as in Windows. Applications are supposed to treat the lock variables as opaque data, therefore it shouldn't matter.

svn path=/trunk/; revision=23806
2006-08-30 19:02:42 +00:00
Hervé Poussineau
538082297d Fix MsiGetFeatureStateA/W and MsiGetComponentStateA/W prototypes
svn path=/trunk/; revision=23805
2006-08-30 18:08:21 +00:00
Magnus Olsen
ec839eb8e2 Kill inline asm code compete in RtlUlongByteSwap for it doing swap wrong.
we go back using the C version. Thanks Fireball  

svn path=/trunk/; revision=23804
2006-08-30 17:51:36 +00:00
Alex Ionescu
7ea78797f2 - Fix KeRaiseUserException (can't use "return" from SEH_HANDLE).
svn path=/trunk/; revision=23803
2006-08-30 17:01:58 +00:00
Alex Ionescu
5fc996c43e - Some fixes to KiDispatchException: Add support for forwarding exception back to user-mode, protect against V86 or invalid-stack faults, handle stack overflow exception while handling usermode exception (Thanks KJK for the SEH_FILTER help). Decrement EIP by one when hitting an INT3, to get the correct address.
- Remove two associated kernel fun entries.

svn path=/trunk/; revision=23802
2006-08-30 16:58:12 +00:00
Eric Kohl
99e4b3809f - fix indentation and remove trailing whitespace
- StartServiceA/W: terminate argument buffer with a double zero.

svn path=/trunk/; revision=23801
2006-08-30 10:53:37 +00:00
Hervé Poussineau
a301256472 Add missing includes in .rc file
Sort them in alphabetical order

svn path=/trunk/; revision=23800
2006-08-30 10:40:59 +00:00
Magnus Olsen
0b5c566337 Implement RtlRandomEx by copy RtlRandom code.
ms have two different implement, One random is faster that other, (in some doc I read (maybe from osr) some year ago),  the RtlRandomEx  is not document in the free ddk/sdk, but it is include in ddk/ifs kit, according the doc. 

svn path=/trunk/; revision=23799
2006-08-30 10:13:01 +00:00
Johannes Anderwald
5a487c19e7 * remove useless cast
svn path=/trunk/; revision=23798
2006-08-30 09:45:08 +00:00
Johannes Anderwald
29b76a30a2 - fix definition of FONTENUMPROC
svn path=/trunk/; revision=23797
2006-08-30 09:17:47 +00:00
Alex Ionescu
841fa5cc41 - Update kernel fun.
svn path=/trunk/; revision=23796
2006-08-30 06:56:06 +00:00
Alex Ionescu
1b0f8e7e81 - Implement RtlCaptureStackBackTrace and RtlWalkFrameChain and add definitions to ntifs.h
- Get rid of KeRosGetStackFrames and replace usage by RtlWalkFrameChain or RtlCaptureStackBackTrace, depending.
- Remove this entry from Kernel Fun.

svn path=/trunk/; revision=23795
2006-08-30 06:52:10 +00:00
Alex Ionescu
a9bb1c6668 - Add about two dozen new bugcheck codes and strings.
- Major cleanup of exp.c to move out deprecated and old code.
- Use KdDebuggerNotPresent to determine if KDBG is there or not. KdDebuggerEnable is now set whenever booting with debugging -- even if only serial port or screen debugging.
- Complete cleanup and major rewrite/improvement of bugcheck code:
  - Moved stack dump routines to bug.c and cleaned them up. Next step is to remove most of them and implement them properly as part of RtlCaptureStackBackTrace and RtlWalkFrameChain.
  - Use InbvDisplayString for everything now. BSODs will only truly show on screen. (however, part of the KeBugCheckWithTf improvements, a special "if debugger enabled" BSOD will also be displayed for debugging purposes).
  - Do checksum calculation in bugcheck callbacks.
  - Detect and display which drivers belong to which EIP.
  - Implemented code to select the proper verbose BSOD message depending on the bug check code.
  - Also implemented code to detect a variety of "known" bug check codes and to recover more data on them, and/or modify them accordingly. Sadly ROS doesn't yet make use of most of these codes.
  - Factored out and split some code into individual routines.
  - Look and functionality is now identical to Windows XP.
  - Stack trace will only be shown if KDBG isn't connected. If KDBG is connected you can do "bt" anyway (which is more powerful).

svn path=/trunk/; revision=23794
2006-08-30 05:22:56 +00:00
Alex Ionescu
655e78f3cc - Jesus Christ... will Hell freeze over before someone finally listens and implements a proper PE loader in Freeloader?
svn path=/trunk/; revision=23793
2006-08-30 01:22:41 +00:00
Hervé Poussineau
ab77204ef9 Implement RegNtPreEnumerateValueKey/RegNtPostEnumerateValueKey registry callbacks.
Add missing callbacks in some paths
Fix a few typos

svn path=/trunk/; revision=23792
2006-08-29 23:01:52 +00:00
Brandon Turner
7b27e1c573 Better rand() implementation. This should fix the problem where you get 0 every time you use rand()
svn path=/trunk/; revision=23791
2006-08-29 22:27:48 +00:00
Magnus Olsen
0a5a03e8d1 found more inline asm.
1. move all inline asm to folder i386
2. to do : seh.s should be rewrites to intel syntax 
3. to do : almost all c files in folders i386 need be convert to true asm instead using inline asm 
4. add dection for x86 arch in rbuild for each found I have done 


svn path=/trunk/; revision=23790
2006-08-29 19:14:18 +00:00
Magnus Olsen
d43aed9f5c Audult : code is from djgpp most of it, ReactOS own code is like two line long
svn path=/trunk/; revision=23789
2006-08-29 19:10:12 +00:00
Magnus Olsen
f4b5816b23 [Audut] clean, after locking at the header I can see clear they comes from wine/djgpp with small changes in some headers that is ros specify.
svn path=/trunk/; revision=23788
2006-08-29 18:31:06 +00:00
Magnus Olsen
40e426cce5 Detect i386 asm code for setjump (we only have one asm version I add arch dections for it in rbuild
svn path=/trunk/; revision=23787
2006-08-29 18:03:24 +00:00
Magnus Olsen
3c0cd4da37 1. Rewote atan.c to pure asm
2. Rewote log10 to pure asm
3. Delete unuse c/asm files like ceil, cos, fabs, flor, sin, sqrt, and tan 
4. Switch to rtl asm version of pow 
5. Follow need be convert to asm atan2, exp, fmod, ldexp
6. Follow need c version  atan2, exp, fmod, ldexp, atan, log10, pow
7. Add i386 arch dections in rbuild for asm/inline asm so we using only i386 asm on x86 cpu 
 

svn path=/trunk/; revision=23784
2006-08-29 17:51:13 +00:00
Alex Ionescu
8453270af7 - Implement GetSideSidFromToken. Patch by Grzegorz Jaśkiewicz.
svn path=/trunk/; revision=23781
2006-08-29 15:22:53 +00:00
Magnus Olsen
ae4f64c515 Copied remotely
svn path=/trunk/; revision=23780
2006-08-29 15:08:14 +00:00
Magnus Olsen
cbab61db9c Copied remotely
svn path=/trunk/; revision=23779
2006-08-29 15:08:10 +00:00
Magnus Olsen
2a1e87e35e Copied remotely
svn path=/trunk/; revision=23778
2006-08-29 15:08:01 +00:00
Magnus Olsen
99dfca5a2c Copied remotely
svn path=/trunk/; revision=23777
2006-08-29 15:07:57 +00:00
Magnus Olsen
aff35f6703 Copied remotely
svn path=/trunk/; revision=23776
2006-08-29 15:05:07 +00:00
Magnus Olsen
ec9e57b10e Copied remotely
svn path=/trunk/; revision=23775
2006-08-29 15:04:58 +00:00
Magnus Olsen
261a9da3bd Copied remotely
svn path=/trunk/; revision=23774
2006-08-29 15:03:41 +00:00
Magnus Olsen
9f6a6f34c0 Copied remotely ceil from rtl to crt/math/i386
svn path=/trunk/; revision=23773
2006-08-29 15:02:41 +00:00
Magnus Olsen
2934b1b61e Created folder remotely
here we prepare copy asm version of math api from rtl asm version

svn path=/trunk/; revision=23772
2006-08-29 15:01:19 +00:00
Magnus Olsen
a260e8be5d add back change long to long_ptr change did not think about it was correct thx hpussin
svn path=/trunk/; revision=23771
2006-08-29 14:25:55 +00:00
Magnus Olsen
eda0d576b0 revert 23768 for this member does not exists in psdk or ddk in windows.
and that reason is it wrong. I told the author of the patch on the irc 
this changes was wrong. 

svn path=/trunk/; revision=23770
2006-08-29 14:13:42 +00:00
Christoph von Wittich
3a3cd44034 fix indentation
svn path=/trunk/; revision=23769
2006-08-29 13:01:47 +00:00
Hervé Poussineau
4b05210f15 Add some missing SIDs. Fix bug 1772.
See http://www.msfn.org/board/lofiversion/index.php/t43597.html for the list of authorities

svn path=/trunk/; revision=23768
2006-08-29 11:27:50 +00:00
Hervé Poussineau
f4763c0ce0 Fix bug 1770. Patch by Grzegorz Jaskiewicz
svn path=/trunk/; revision=23767
2006-08-29 11:02:08 +00:00
Magnus Olsen
2cac0acc13 put in if define i386 for asm version of cos, sin, atan2, floor, ceil we do not have a C version of those commands in rbuild file
svn path=/trunk/; revision=23766
2006-08-29 08:28:50 +00:00
Alex Ionescu
28122cd8d9 - Complete and utter reimplementation of V86 Mode for Ke386CallBios. Details below. Tested on QEMU/VMWARE. May give you a breakpoint/crash on real hardware - please let me know the V86 opcode displayed on the debug log/screen if this is the case *if you see such a message*.
- Got rid of all the previous related assembly code and implemented Ki386SetupAndExitToV86Mode and Ki386BiosCallREturnAddress.
- Implemented GPF (Trap 13) code for V86 faults (which will happen in V86 mode). Implement a generic Ki386HandleOpcodeV86 handler that increments counts and calls the right opcode handler.
- Implemented an Opcode Table Entry Index and Opcode Table array for mapping opcodes that caused a GPF to their V86 handlers/emulators.
- Implemented handlers for PUSHF, POPF, CLI, STI, IRETD and INTnn, which is what QEMU/VMWare and *most* VIDEO ROM BIOS code should use.
- Created a /vdm tree and moved all NTVDM/VDM specific code there.
- Halfplemented VdmStart/EndExecution APIs which the BIOS ROM V86 implementation is built upon. Currently don't handle VDM at all, only this V86 mode.
- Also added code for NtVdmControl and fixed up CSRSS and ACPI's calls to this API.
- Added detection and FIXMEs for support of VMEs in VMWare, Bochs and real hardware (VME is not yet supported).
- Move exp.c fixmes to krnlfun and remove kernel fun entries that this patch fixes.

svn path=/trunk/; revision=23763
2006-08-28 23:56:35 +00:00
Alex Ionescu
9d1c606794 [AUDIT] - Our CSRSS implementation is too different and incompatible for NT to have possibly been done through non-clean methods. Clean methods were probably not even used, except for reading documentation, since most of the code seems to be based on guesses and original implementations. (As a simple example, NT's CSRSS is 4kb, with all actions done by a server DLL. ROS has none of this).
svn path=/trunk/; revision=23762
2006-08-28 23:55:50 +00:00
Thomas Bluemel
d5f1f3ceca Move the __ALIGNED attribute to the correct position in the definition of EX_PUSH_LOCK_WAIT_BLOCK
svn path=/trunk/; revision=23761
2006-08-28 20:20:03 +00:00
Ged Murphy
96ff7d566c couple of minor fixes.
svn path=/trunk/; revision=23760
2006-08-28 19:33:28 +00:00
Thomas Bluemel
ca9ef93e32 "Fix" using an uninitialized variable (line 950) in lines 1334-1337. Yes I'm back, for now!
svn path=/trunk/; revision=23759
2006-08-28 18:15:46 +00:00
Johannes Anderwald
6e015da993 * fix another typo :-)
svn path=/trunk/; revision=23758
2006-08-28 07:13:40 +00:00
Magnus Olsen
c8385edeec fixing the spelling english spelling thanks mifritscher to notice it.
svn path=/trunk/; revision=23757
2006-08-27 22:20:33 +00:00
Magnus Olsen
18adfbcd79 Commit one part from big patch from Pablo Borobia (pborobia at gmail dot com) he is done the clipboard project
1. implement detail show for network. 

Magnus Olsen (me) aka GreatLord
I did review ncpa changes, he did only forget free the memory when detail propers was exit. I set erly style on file
that was not set. I also update most .rc so they contain the english res text. please translators translate this. 



svn path=/trunk/; revision=23756
2006-08-27 21:44:53 +00:00
Hervé Poussineau
becdf59777 Add French and Bengali resources to build
Sort files by alphabetical order

svn path=/trunk/; revision=23755
2006-08-27 20:56:34 +00:00
Hervé Poussineau
ffc884d4ca Add guard to prevent multiple inclusions (not used yet)
svn path=/trunk/; revision=23754
2006-08-27 20:23:26 +00:00
Johannes Anderwald
a5d8d20855 * improve error checking (by hpoussin)
* use correct CLSID -> now auto-start apps from %ALLUSERSPROFILE% can be started too

svn path=/trunk/; revision=23753
2006-08-27 20:01:14 +00:00
Johannes Anderwald
fbfe8c9245 * auto-start apps in autostart folder
* currently only works for current user
* SHGetFolderPathW CSIDL_ALTSTARTUP fails (All Users\...)

svn path=/trunk/; revision=23752
2006-08-27 19:22:48 +00:00
Christoph von Wittich
d3112a4a86 added vdmdbg.dll to bootcd
svn path=/trunk/; revision=23751
2006-08-27 19:08:20 +00:00
Johannes Anderwald
a80ab420d2 * fix warning
* set svn-eol-style native

svn path=/trunk/; revision=23750
2006-08-27 18:14:53 +00:00
Magnus Olsen
1a375085e9 reapplay rev 23614, it we have now russain letters and other contrus special letters.
The bug I experis before was reletate to ntoslnrl and is complete gone. I have now reboot and boot around 10-20 times
and run same program. But we see all unicode -> ansi problem with this change if u select russan in reactos 

svn path=/trunk/; revision=23749
2006-08-27 16:51:11 +00:00
Hervé Poussineau
43eef84aa9 Set user locale at login. User interface may now be (again) in other languages than English
svn path=/trunk/; revision=23747
2006-08-27 15:18:20 +00:00
Magnus Olsen
217e03e8e8 sorry wrong version
svn path=/trunk/; revision=23746
2006-08-27 14:55:31 +00:00
Magnus Olsen
a962c1d8c0 fix a crash in quake
svn path=/trunk/; revision=23745
2006-08-27 14:53:32 +00:00
Christoph von Wittich
0d7f6179b7 forgot to commit these files
svn path=/trunk/; revision=23744
2006-08-27 14:20:17 +00:00
Christoph von Wittich
5a6172f875 added LiveCDRegTest and BootCDRegTest targets
svn path=/trunk/; revision=23743
2006-08-27 13:28:23 +00:00
Christoph von Wittich
454bef01db renamed isoboot_regtest.asm to isobtrt.asm to comply with ISO-9660 standard
svn path=/trunk/; revision=23742
2006-08-27 13:26:43 +00:00
Klemens Friedl
b32b0a47c8 samba-tng: update the description
svn path=/trunk/; revision=23741
2006-08-27 12:28:22 +00:00
Christoph von Wittich
ec61eadeca * added bootloader which can be used for automated regression tests using buildbot
svn path=/trunk/; revision=23740
2006-08-27 11:59:01 +00:00
Christoph von Wittich
1424ff8a8c added GetSiteSidFromToken stub
svn path=/trunk/; revision=23739
2006-08-27 11:44:21 +00:00
Johannes Anderwald
c71c15d905 * make edit controls look standard
* GeT rId oF aNNoyIng DOt In EdiT cONtROl

svn path=/trunk/; revision=23738
2006-08-27 10:28:05 +00:00
Johannes Anderwald
8895520e58 * store static colors in global struct to make it thread-safe
svn path=/trunk/; revision=23737
2006-08-27 09:50:29 +00:00
Johannes Anderwald
adcaf80140 * auto-select correct radio button
* only repaint required on up/down notifications events

svn path=/trunk/; revision=23736
2006-08-27 09:42:16 +00:00
Johannes Anderwald
7a535d12d5 * dont code during night :-))))
svn path=/trunk/; revision=23735
2006-08-27 00:51:43 +00:00
Johannes Anderwald
f8feed90ce * optimize a few code paths
* add error checking in various places
* implement painting console image

svn path=/trunk/; revision=23734
2006-08-27 00:46:50 +00:00
Magnus Olsen
ab519c08f9 forget commit rbuild file for win32k
svn path=/trunk/; revision=23733
2006-08-26 23:27:49 +00:00
Magnus Olsen
6518b5361d for 24bpp
1. Remove inline asm for hline and implement a asm version of it in intel syntax. 
   (optimzeing of this version can be done better, but it for be done for now)
2. set eorly style on file I forget. 



svn path=/trunk/; revision=23732
2006-08-26 23:26:39 +00:00
Aleksey Bragin
c5edc7e6d3 - Typecast a param so that it doesn't give an error in gcc
- Make cmlib compilable as a makefile target "cmlib_host" (needed for linking with mkhive)

svn path=/trunk/; revision=23731
2006-08-26 21:19:34 +00:00
Magnus Olsen
1a6675e3d7 fpr 32bpp
1. Remove inline asm from hline and convert it to own asm file with intel syntax. 
2. Reimplement colorfill inline asm version and convert it to own asm file with intel syntax. 
   the asm code can be optimze bit more. But for done 

svn path=/trunk/; revision=23730
2006-08-26 21:18:33 +00:00
Aleksey Bragin
2857ff8136 Add testsets to building process too, so that they don't bitrot (compile time is neglectable)
svn path=/trunk/; revision=23729
2006-08-26 21:11:08 +00:00
Aleksey Bragin
0e407eb6b4 Don't crash during disconnection if a device doesn't have a driver
svn path=/trunk/; revision=23728
2006-08-26 21:09:11 +00:00
Aleksey Bragin
f0549011c0 Dmitry Philippov:
- Implement RTL_QUERY_REGISTRY_DELETE (which simply deletes the key after querying)
 - Fix REG_MULTI_SZ to actually walk through the whole data, not stopping at the first encountered 0 character. This makes the "ntdll_winetest.exe reg" test behave exactly as on Windows XP

svn path=/trunk/; revision=23727
2006-08-26 20:45:30 +00:00
Magnus Olsen
32a1a90cc7 fix a typo
svn path=/trunk/; revision=23726
2006-08-26 19:44:47 +00:00
Magnus Olsen
f73c521e7e adding 640x480x32, 800x600x32, 1024x768x32 select for vbe. accoding to VBE 2.0 spec this mode shall always be while for graphic card with vbe 2.0 or higher.
svn path=/trunk/; revision=23725
2006-08-26 19:40:24 +00:00
Klemens Friedl
b5e0a940b1 add samba-tng to the packmgr repo
svn path=/trunk/; revision=23724
2006-08-26 18:43:44 +00:00
Alex Ionescu
c5c008ec96 - Even though in assembly we return the BOOLEAN in all of EAX, HalBeginSystemInterrupt should, in theory, only use AL and we shouldn't make assumptions about any other bits. So chang ethe code to or al, al, instead of or eax, eax.
svn path=/trunk/; revision=23723
2006-08-26 16:23:59 +00:00
Alex Ionescu
1db10cc5ad - Remove useless stack operations in KiInterruptDispatch that I used for debugging.
svn path=/trunk/; revision=23722
2006-08-26 16:07:31 +00:00
Alex Ionescu
3213baa7ae - Fix some bugs in KiChainedDispatch.
svn path=/trunk/; revision=23721
2006-08-26 16:04:29 +00:00
Alex Ionescu
9e78b36f2e - Fix a bug during exceptions, thanks to W3seek, nice find.
svn path=/trunk/; revision=23720
2006-08-26 15:40:27 +00:00
Magnus Olsen
0e96db4bf5 bug 1769 : from w3seek : Implement some new functions
svn path=/trunk/; revision=23719
2006-08-26 14:28:34 +00:00
Johannes Anderwald
b4e91152db * show selected static control via DrawFocusRect
svn path=/trunk/; revision=23718
2006-08-26 13:43:15 +00:00
Magnus Olsen
a7216d7b12 do right typecast for ReadFile so it compiles on gcc 4.x
svn path=/trunk/; revision=23717
2006-08-26 10:01:03 +00:00
Magnus Olsen
def45d4b5a fixed one waring that thomas got with gcc 4.x
svn path=/trunk/; revision=23716
2006-08-26 09:57:38 +00:00
Hervé Poussineau
916f69a7cb Fix a missing referencing in PsImpersonateClient (dereferenced in PsRevertThreadToSelf)
PspWriteTebImpersonationInfo may be used to set or to clear impersonation info => remove an extra assignment

svn path=/trunk/; revision=23715
2006-08-26 08:46:18 +00:00
Alex Ionescu
617e78ebf0 - Transform TRAP_PROLOG into a GAS macro.
- Remove code in the page fault handler which was corrupting the trap frame.
- Remove some ROS hacks that dealt with the fact the trap frame was getting corrupted, since now it isn't anymore.
- Enable code that checks for Teb->GdiBatchCount during win32k system calls. The bugs that were mentionned in the #if 0 are fixed.

svn path=/trunk/; revision=23714
2006-08-26 06:14:32 +00:00
Brandon Turner
9f5f1ce315 * Implement: /low, /normal, /high, /realtime, /belownormal, and /abovenormal
* Correctly build the string used to create the process.

svn path=/trunk/; revision=23713
2006-08-25 23:12:50 +00:00
Hervé Poussineau
ec5899ca4f Implement IOCTL_SERIAL_WAIT_ON_MASK
Better implementation of IOCTL_SERIAL_SET_WAIT_MASK
Remove "Serial:" prefix on debug output

svn path=/trunk/; revision=23712
2006-08-25 22:07:10 +00:00
Alex Ionescu
3c97814afe - Hervé est un Dieu qui mérite une infinité de bières et de femmes vierges (et nues).
- This should fix booting on VMWare.

svn path=/trunk/; revision=23711
2006-08-25 20:18:34 +00:00
Magnus Olsen
bf4ff7bb94 forget this file thx christ
svn path=/trunk/; revision=23710
2006-08-25 18:26:26 +00:00
Magnus Olsen
87b9d209fd Add frist version of ReactOS net command. I finish frist step early that I calc, you need samba-tng rpcclient to use net command in your path. net command only support follow command "net start, net start serivce_display name, net stop", more will follow later.
The help text I need some help with to fill in the info how thuse command work and design the help text better. 
 


svn path=/trunk/; revision=23709
2006-08-25 17:50:26 +00:00
Hervé Poussineau
10782a0cfa Add an assert in IntEngCreateXlate
svn path=/trunk/; revision=23708
2006-08-25 15:49:31 +00:00
Alex Ionescu
397f1f88d2 - Viva la deprecation! Trunk should now boot and the installer should work.
- Basically revert the new HAL/KERNEL IRQ code by putting the old one in, but without the actual pain of svn reverting and losing all the previous code.
- The old code goes in ntoskrnl\deprecated, and we only add a comment to the .rbuild file, re-export an old function, and initialize the old code in kernel.c. All the other kernel changes stay in-place to be tested.
- Same for hal, basically replace irq.S with irql.c in the .rbuild file, and disable the call to Halpinit1. All the other changes remain.

svn path=/trunk/; revision=23707
2006-08-25 14:50:01 +00:00
Alex Ionescu
bb00cadd67 - Fix some bugs
svn path=/trunk/; revision=23706
2006-08-25 14:15:11 +00:00
Aleksey Bragin
3f4b7e4705 - Enable PIRQ when initializing UHCI, this solves the "no irq" problem on some UHC controllers (most popular type of such controller is the one emulated by VMWare)
- Fix a mistake in the source code resulting in a bugcheck
- Add _X86 to .rbuild (by Thomas)

svn path=/trunk/; revision=23705
2006-08-25 13:20:13 +00:00
Johannes Anderwald
50746a376e * share common painting code
* align static control in same way

svn path=/trunk/; revision=23704
2006-08-25 12:19:42 +00:00
Ged Murphy
a6c41b9d22 delete old dir
svn path=/trunk/; revision=23703
2006-08-25 10:12:28 +00:00
Ged Murphy
7adefa6232 move uptime to rosapps so Alex doesn't blow up into teeny weeny pieces ;)
svn path=/trunk/; revision=23702
2006-08-25 10:11:57 +00:00
Alex Ionescu
387c84f0f5 - Add some debugging code to see why trap frames are screwed up.
svn path=/trunk/; revision=23701
2006-08-25 04:11:45 +00:00
Alex Ionescu
38a0558e07 - We do not speak about the v86 hack.
- This should fix the V86 GPF error.

svn path=/trunk/; revision=23700
2006-08-25 02:23:47 +00:00
Alex Ionescu
b23894894d - Get rid of some code.
svn path=/trunk/; revision=23699
2006-08-25 02:22:50 +00:00
Alex Ionescu
35778c9f25 - If SeCaptureSubjectContextEx is called without a process, at least NULL-initialize the context to catch dereferences of invalid pointers.
svn path=/trunk/; revision=23698
2006-08-25 01:04:44 +00:00
Alex Ionescu
7d305ec8e6 - Fix compiling/linking problems.
- Remove KrnlFun entry - IRQs are now done through a typical NT/ROS trap frame and are synchronized and compatible with trap.S.
- Enable 2nd entry interrupt calls in HalBeginSystemInterrupt, since IRQs now use the right trap frame.

svn path=/trunk/; revision=23697
2006-08-25 00:46:41 +00:00
Ged Murphy
31cc308502 add an 'uptime' command.
Available in either Windows or Linux output. (defaulted to Windows)

svn path=/trunk/; revision=23696
2006-08-25 00:33:27 +00:00
Alex Ionescu
425592dd06 - The last piece of the puzzle: we had to initialize the IDR in HalInitProcessor to set it to the default of 0xFFFFFFB so that we don't get IRQ 0 and IRQ 1 until we're ready to handle them, which was causing the clock interrupt to be called too early.
- Remove irqhand.S and all other remaining pieces of deprecated code.

svn path=/trunk/; revision=23695
2006-08-25 00:30:26 +00:00
Alex Ionescu
5d9935a1fa - Got rid of the deprecated stuff left in irq.c and directly implemented it as part of irqhand.S (which is also deprecated).
- Cleaned up irq.c. Fixed file header, function prototypes, includes, etc, and moved general definitions and externs to ke.h

svn path=/trunk/; revision=23694
2006-08-24 23:25:37 +00:00
Johannes Anderwald
52f5a2cccc * handle PSN_APPLY effectively
* remove no longer used callback
* reenable PropSheet_Changed macros
* fix styles for dialog

svn path=/trunk/; revision=23693
2006-08-24 20:55:13 +00:00
Alex Ionescu
fe2d752e93 - Fix some bugs in clock.S
- Enable clock.S versions of KeUpdateSystem/RunTime and export them properly.
- Enable systimer.S to call into kernel's KeUpdateSystemTime.
- Enable Hal's Clock Interrupt during Phase 1.
- Remove most of the code that was still left in irq.c
- Only one large problem remains now, which is the spurious firing of the clock interrupt before we're ready to handle it... I will try to fix this today.

svn path=/trunk/; revision=23692
2006-08-24 19:17:14 +00:00
Andrew Munger
d43585136b DBG=0 fixes, patch by Physicus.
svn path=/trunk/; revision=23691
2006-08-24 18:48:15 +00:00
Christoph von Wittich
3dd85ba73d some more msvc warning fixes
svn path=/trunk/; revision=23690
2006-08-24 17:23:07 +00:00
Hervé Poussineau
cd01646b34 Fix all warnings detected by gcc 4.2
Patch by Thomas Weidenmueller

svn path=/trunk/; revision=23689
2006-08-24 16:58:12 +00:00
Christoph von Wittich
0c186af160 fixed some warnings (patch by w3seek)
svn path=/trunk/; revision=23688
2006-08-24 16:39:14 +00:00
Hervé Poussineau
71391c6a4f Build usbdriver without warning, at least with gcc 3.4.2
svn path=/trunk/; revision=23687
2006-08-24 16:21:16 +00:00
Christoph von Wittich
6db46bea8e fixed some warnings
svn path=/trunk/; revision=23686
2006-08-24 16:06:12 +00:00
Aleksey Bragin
342cd42b44 Fix a lot of annoying warnings, leaving basically only ehci.c and gendrv.c as big warnings providers
svn path=/trunk/; revision=23685
2006-08-24 12:58:52 +00:00
Aleksey Bragin
2036235837 Dmitry Philippov: Implement SmProcessFileRenameList()
svn path=/trunk/; revision=23684
2006-08-24 11:06:48 +00:00
Aleksey Bragin
1b82756b34 Temporary fix a call to KeUpdateSystemTime(), passing third CLOCK_INCREMENT's value (100000) as third param.
svn path=/trunk/; revision=23683
2006-08-24 09:32:32 +00:00
Aleksey Bragin
be7b345087 Fix compiling
svn path=/trunk/; revision=23682
2006-08-24 09:01:22 +00:00
Alex Ionescu
721fa0869e - Add more missing offsets to asm.h (as always, taken from ks386.inc)
- Fix incorrect KPCR_PRCB_DPC_ROUTINE_ACTIVE which was totally wrong (And could've caused a crash in the context swicher)
- Also fix the definition of KRCB which was off-by-4 after about offset ~0x500. It wasn't causing problems because assembly code only used < 0x500.
- Write the ASM implementation of KeUpdateRunTime (not used yet).

svn path=/trunk/; revision=23681
2006-08-24 07:48:50 +00:00
Alex Ionescu
065837f112 - Make KeUpdateSystemTime independent, so that it returns and exits from the current ROSterrupt by itself.
- Make KeUpdateRunTime increase the interrupt count, check for V86 as well as for user-mode by using the CS and EFLAGS (isntead of PreviousMode), also only request DPCs if DpcInterruptRequested isn't already set, and only perform Quantum End if this isn't the idle thread.
- Add clock.S which will have the clock interrupt handlers of the kernel (UpdateSystemTime and UpdateRunTime) and ultimately replace the only reason irqhand.S is still around (the clock interrupt). Implement the current version of KeUpdateSystemTime in assembly, with stack optimizations since we'll be called from the HAL later.

svn path=/trunk/; revision=23680
2006-08-24 06:52:33 +00:00
Alex Ionescu
5e7ef1d665 - Update KeUpdateSystemTime to use variable increments.
- Update KeTickCount properly instead of an ugly timecast hack.
- Also update UserSharedData->TickCount.
- Get rid of KiRawTicks.
- Properly update KiTickOffset at the end.

svn path=/trunk/; revision=23679
2006-08-24 06:27:29 +00:00
Alex Ionescu
8b82c0d641 - Write a basic Clock Interrupt handler in the HAL (doesn't deal with changing increments yet, just like current ROS). It will call KeUpdateSystemTime once ready.
- Implement KeDisconnectInterrupt with the new implementation.
- Put Clock Interrupt initialization in the right place (might still be too late: must investigate more).
- Added a debug print when unexpected interrupts are called, just noticed this happens on my checked machine, and it's a useful tracing tool.

svn path=/trunk/; revision=23678
2006-08-24 05:36:50 +00:00
Alex Ionescu
15899302f6 - Completely re-implement IRQ support (KeInitialize/Connect/Disconnect) interrupt using the same model as NT. Implementation was done by analyzing various of my systems at runtime with WinDBG and tracing through some of the code and dumping relevant objects.
- Uses new code added to trap.s for generic dispatching, as well as the NT implementation which copies a "template" into the ->DispatchCode array of every KINTERRUPT object.
- Also adds support for chained interrupts, but this hasn't been tested yet. Floating interrupts are not supported on NT it seems, so I haven't implemented those at all.
- KiDisableInterrupt not yet re-implemented, and timer code is still piggybacked on the old implementation.

svn path=/trunk/; revision=23677
2006-08-24 02:53:40 +00:00
Alex Ionescu
c8c71fcd5c - Implement Chained and Normal generic interrupt handlers.
- Make generated handlers have a proper .func symbol for symbol data.
- Make IDT writable, the page shouldn't be read-only.
- Change some symbol names.

svn path=/trunk/; revision=23676
2006-08-24 01:53:54 +00:00
Aleksey Bragin
b899ba11ba - Add a new level of debug verbosity
- Fix a bunch of warnings by Thomas and me

svn path=/trunk/; revision=23675
2006-08-23 22:17:09 +00:00
Alex Ionescu
5870fa3d6c - Enable the code in KeInitializeInterrupt that copies the Interrupt Template to the KINTERRUPT object and modifies the template pointer to point to the KINTERRUPT.
- Add the template code in trap.s.

svn path=/trunk/; revision=23674
2006-08-23 19:02:00 +00:00
Alex Ionescu
abe9e92dcf - Get rid of some large debugging functions that were called at all times, and don't manually deliver user APCs anymore, since the HAL handles it now.
svn path=/trunk/; revision=23673
2006-08-23 18:09:44 +00:00
Alex Ionescu
da725d9d30 - Fix some bugs in INT_PROLOG so that it can be used in cases like Unexepcted interrupts, where we don't want to push a fake error code, and want to use our own parameter.
svn path=/trunk/; revision=23672
2006-08-23 18:02:52 +00:00
Hervé Poussineau
daedfda3d4 Allow to change more easily the prefix of remote interface functions in services.exe
This is a step to share this file with Samba-TNG
Thanks to Elrond from Samba-TNG for help

svn path=/trunk/; revision=23671
2006-08-23 17:57:34 +00:00
Alex Ionescu
c0ad9f32d3 - [AUDIT] After spending some time looking at the current HAL, I believe it to be clean and written by authors which had knowledge of system internals and have always used clean-rooming. As well, the difference in implementation, complete and utter incompatibility with NT as well as the presence of some Linux-based code confirms this.
- Fix function definitions of HalQueryRealTimeClock, HalGetEnvironmentVariable. They were defined in the NDK in one way, but implemented another way, and since the HAL didn't include its own NDK file, the compiler didn't realize this. Calls of these functions might've experienced serious problems.
- Also fix HalHandleNmi and HalInitSystem definitions.
- Add stub code to actually setup the Clock Interrupt.

svn path=/trunk/; revision=23670
2006-08-23 17:28:39 +00:00
Alex Ionescu
8401f43ab0 - Switch PRIMARY_VECTOR_BASE to 0x30 instead of 0x40, as it should be.
svn path=/trunk/; revision=23669
2006-08-23 16:58:43 +00:00
Aleksey Bragin
7ad1947410 - Unmess header files a little - create one header file (usbdriver.h) which includes all other needed headers, also splitting a bit.
Also split out the roothub driver and device manager from hub.c (which was over 4500 SLOC)
- Enable PCH usage
- Reduced a few warnings

svn path=/trunk/; revision=23668
2006-08-23 12:36:08 +00:00
Aleksey Bragin
edaf50a0e7 Add accidentally deleted line (a call to WideCharToMultiByte() )
svn path=/trunk/; revision=23667
2006-08-23 08:24:37 +00:00
Alex Ionescu
4ade91ae66 - Kill two more hacks. IDR isn't hacked at 0xFFFFFFA on startup anymore, and the PIC is correctly set to 0xFA at startup.
svn path=/trunk/; revision=23666
2006-08-23 06:59:11 +00:00
Alex Ionescu
7fa6c080b5 - Enable 2nd entry for HalEndSystemInterrupt but not actually using the optimized 2nd entry since ROS IRQs are currently built with a completely different trap frame.
svn path=/trunk/; revision=23665
2006-08-23 06:51:54 +00:00
Alex Ionescu
9ac4b05366 - Fix some IDR->IRR bugs.
- Enable 2ndEntry for HalpEndSoftwareInterrupt (pending interrupt inside an interrupt).

svn path=/trunk/; revision=23664
2006-08-23 06:42:25 +00:00
Alex Ionescu
280da54a61 - Switch HalEndSystemInterrupt to ASM version and get completely rid of the irql.C file.
svn path=/trunk/; revision=23663
2006-08-23 06:38:46 +00:00
Alex Ionescu
a82987f860 - Switch to ASM version of KfLowerIrql
svn path=/trunk/; revision=23662
2006-08-23 06:35:33 +00:00
Alex Ionescu
de56d52a1b - Fix bugs in ASM version of KfLowerIrql (not yet used)
- Fix bugs in INT_PROLOG.
- Fix an important bug in TRAP_EPILOG which was causing register restoration to happen at all times (such as in Kei386EoiHelper/KiServiceExit2 when it shouldn't happen).
- Add DRx restoration from trap frame, if DR7 is set.
- Added and fixed some debugging assertions in TRAP_EPILOG.

svn path=/trunk/; revision=23661
2006-08-23 06:33:52 +00:00
Alex Ionescu
c30a8d1cd4 - Duplicate code between the remaining functions (KfLowerIRql and HalEndSystemInterrupt) so testing the switch to their ASM versions will be easier.
- Use same table as in ASM code.

svn path=/trunk/; revision=23660
2006-08-23 01:23:11 +00:00
Alex Ionescu
955d04b6ff - Disable interrupts while in HalpLowerIrql
- Properly handle IRR.
- Call IRR Handlers through the SWINT table.

svn path=/trunk/; revision=23659
2006-08-23 01:07:14 +00:00
Alex Ionescu
9f38dc5900 - Deliver APCs through a proper interrupt gate as well.
svn path=/trunk/; revision=23658
2006-08-23 00:51:08 +00:00
Alex Ionescu
44804d565e - Call KiDispatchInterrupt through an interrupt gate instead of directly.
svn path=/trunk/; revision=23657
2006-08-23 00:49:35 +00:00
Alex Ionescu
bbd5e3237f - Remove HalpEndSystemInterrupt since we were already doing that code in HalpLowerIrql.
svn path=/trunk/; revision=23656
2006-08-23 00:39:52 +00:00
Alex Ionescu
a2c9ae57c3 - Use the IRR to determine APC delivery.
svn path=/trunk/; revision=23655
2006-08-22 23:41:39 +00:00
Alex Ionescu
132b7c834f - Add the code necessary in the C version of KeLowerIRql to properly mask the PIC, and enable #ifed code in ASM KeRaiseIrql to mask the PIC, since it now works.
svn path=/trunk/; revision=23654
2006-08-22 22:45:45 +00:00
Alex Ionescu
fcdd76f501 - Get rid of the peculiar idea that the HAL should manually hack into ntoskrnl through a hack export and hackishly call the registered device interrupt handlers. This is why computers have a PIC in the first place...
svn path=/trunk/; revision=23653
2006-08-22 22:20:02 +00:00
Alex Ionescu
fcda0db1c6 - Switch to ASM version of HalEnableSystemInterrupt
svn path=/trunk/; revision=23652
2006-08-22 22:13:01 +00:00
Alex Ionescu
f5f0688575 - Use the IDR in the PCR intead of a local picmask.
- Use ASM version of HalBeginSystemInterrupt.

svn path=/trunk/; revision=23651
2006-08-22 22:10:52 +00:00
Aleksey Bragin
23b6ae75fb Dmitry Philippov:
- Add a test case for a multisz value which has zero-sized strings
- Add a test case for query registry delete

All tests are known to be passed on Windows XP SP2

svn path=/trunk/; revision=23650
2006-08-22 21:45:57 +00:00
Alex Ionescu
4e5173d7d0 - Commit current work on IRQ rewrite. Currently in a very ugly/dirty state of flux between the new ASM code (with tiny hacks) and the old C code (with giant hacks). I feel that this is a good/stable middle ground before continuing further with the changes.
svn path=/trunk/; revision=23649
2006-08-22 20:50:52 +00:00
Christoph von Wittich
746195690d * some msvc /W4 fixes
svn path=/trunk/; revision=23648
2006-08-22 20:06:30 +00:00
Hervé Poussineau
b7578b2c4b Fix GCC 4 build. Patch by Thomas Weidenmüller
svn path=/trunk/; revision=23647
2006-08-22 18:53:50 +00:00
Art Yerkes
acad050569 Fix elrond bug. DNS timeouts now work properly even in the absence of ICMP
destination unreachable or a proper response.

svn path=/trunk/; revision=23646
2006-08-22 06:23:00 +00:00
Alex Ionescu
67096f53f5 - Implement GENERATE_IDT_STUBS/GENERATE_INT_HANDLERS
- Generate actual Unexpected Interrupt entries in the IDT for INTs > 0x30 (basically IRQs).
- Generated all 208 Unexpected Interrupt Handlers for all INTs (using a single macro line) and implement a "Tail" function to handle them instead of bugchecking like before (they're now sent to HAL properly).
- Implement INT_PROLOG macro to create KTRAP_FRAME for interrupts (similar to traps).
- Part 1 of major changes to come....

svn path=/trunk/; revision=23645
2006-08-21 22:40:23 +00:00
Ged Murphy
9281b0c841 - Cleanup / rewrite much of the ip config code
- Move hardcoded strings into a resource file ready for translation
- Query registry data for friendly names, etc. We can remove some of this when the XP/vista API, GetAdaptersAddresses is implemented.
- tested in Windows, untested in ROS...

svn path=/trunk/; revision=23644
2006-08-21 19:28:18 +00:00
Hervé Poussineau
b8d9b16369 Fix compilation of ntoskrnl
svn path=/trunk/; revision=23643
2006-08-21 17:16:36 +00:00
Magnus Olsen
1288ce8d7c Update version number to 0.3.x
svn path=/trunk/; revision=23642
2006-08-21 15:04:20 +00:00
Johannes Anderwald
043df7bed9 * colors.c: add error checking
* console.c: add defaults
* layout: halfplement layout dialog

svn path=/trunk/; revision=23641
2006-08-21 10:57:14 +00:00
Magnus Olsen
038473fdfd revers 23614 it cause unexped regress in some api, the code need be goto thung pretty hard even try remove hardcode font in win32k, and it cause regress there and there. and cause regreess on boot time to time. sorry it took me most night figout out why. But I do not yet how to solv it.
svn path=/trunk/; revision=23640
2006-08-21 05:14:22 +00:00
Art Yerkes
58cdf1c29b Added gdi32, because we depend on CreateSolidBrush and kin.
svn path=/trunk/; revision=23639
2006-08-21 04:41:11 +00:00
Art Yerkes
ae19f2956d - Fixed timeout calculation.
- Fixed a couple of leaks.

svn path=/trunk/; revision=23638
2006-08-21 03:59:02 +00:00
Alex Ionescu
0ba60c4b62 - Delete bios.c and usertrap.c
- Add Ke entries to KernelFun!

svn path=/trunk/; revision=23637
2006-08-21 03:49:02 +00:00
Alex Ionescu
f038f4a895 - Gutted out KiTrapHandler. Now it is only a gateway for GPF/UD for V86 mode.
- Removed all the code in userptrap.c and removed KiKernelTrapHandler.
- Set Traps 11, 12, 16 and 17 as unhandled for now(Segment fault, stack fault, fpu fault and alignment fault). We weren't really "handling" them in the past either.
- I probably need to implement GPF handler for non-V86 mode to support Lazy segment loading and fix the vmware syscall bug that has been haunting me for two years.

svn path=/trunk/; revision=23636
2006-08-21 03:31:53 +00:00
Alex Ionescu
775b443831 - Call KiSystemFatalException directly instead of duplicating the code 5 times.
svn path=/trunk/; revision=23635
2006-08-21 03:03:52 +00:00
Alex Ionescu
03f23a9e0a - Convert 8, 9, 10, 15/F
svn path=/trunk/; revision=23634
2006-08-21 03:01:47 +00:00
Alex Ionescu
162d423eff - Switch 4, 5, 6 to common ASM dispatcher as well.
svn path=/trunk/; revision=23633
2006-08-21 02:32:08 +00:00
Alex Ionescu
4bb966cd9a - Implement generic exception dispatcher for traps (kind-of analogous to KiKernelTrapHandler/KiUserTrapHandler but in assembly and more generic/compact).
- Switch Traps 0, 1  to it.
- Trap 2 is NMI, bugcheck immediately since we can't handle them yet.

svn path=/trunk/; revision=23632
2006-08-21 02:01:07 +00:00
Alex Ionescu
c43ef4fb30 - Fixes to CONTEXT<->KTRAP_FRAME conversion.
svn path=/trunk/; revision=23631
2006-08-21 01:07:01 +00:00
Brandon Turner
4c9f6c31bb Label NtReadFileScatter as unimplemented.
svn path=/trunk/; revision=23630
2006-08-21 00:02:33 +00:00
Johannes Anderwald
44f2cc5731 * colors.c: implement color dialog (reading from registry is not yet supported)
* font.c/layout.c/console.c/options.c: add UNREFERENCED_PARAMETER macros, fix sharing of global struct
* console.def: fix building with MSVC

svn path=/trunk/; revision=23629
2006-08-20 23:55:08 +00:00
Alex Ionescu
74f108bb28 - Detect NPX/FPU in simple assembly and XMMI/SSE2 by using CPU Feature flags, replacing the old asm+c mess.
- Handle FPU/SSE saving in the CONTEXT<->KTRAP_FRAME routines directly, and using KiFlushNPXState assembly function.
- Implement a naive Trap 7 (FPU Fault) handler in assembly that properly does most of the work required to handle an FPU fault. Not yet complete however since it almost ignores user-mode faults (just like trunk). FPU isn't done in ctx switching yet.
- Remove all the other .c code that dealt with FPU stuff and had become incompatible since more then a year ago.

svn path=/trunk/; revision=23628
2006-08-20 23:53:07 +00:00
Michele Cicciotti
aabf06072b modified porting-tools/rdesktop-core-tester/activex.cpp
modified   porting-tools/rdesktop-core-tester/rdesktop-core-tester.cpp
    And from the chrysalis out came... the caterpillar. MissTosca stops just short of being demonstrable. I'll keep working on it, but the Google Summer of Code is, for all intent and purposes, over. The matter is in the hands of my judges now. Wish me luck

modified   rdesktop/iso.c
modified   rdesktop/proto.h
modified   rdesktop/rdesktop.h
modified   rdesktop/rdp.c
    Very minor fixes

modified   rdesktop/tcp.c
    Use asynchronous I/O and alertable waits to allow aborting the protocol thread ASAP

svn path=/trunk/; revision=23627
2006-08-20 21:02:10 +00:00
Art Yerkes
9cb66d7953 Add the ability to specify DNS servers and make adns work right in case they
are specified.

svn path=/trunk/; revision=23626
2006-08-20 20:51:54 +00:00
Alex Ionescu
43d5f7e90d - Remove some FPU deprecated constants and use the new ones.
- Deliver APCs on return from context switch with pending kernel APCs.

svn path=/trunk/; revision=23625
2006-08-20 20:27:03 +00:00
Alex Ionescu
893a8bcac6 - Don't use EFLAGS to store the Wait IRQL, just push directly, it's cleaner.
- Detect if kernel APCs are pending and request APC_LEVEL software interrupt from HAL if they are, returning with the right apc status.
- Also update INT21 VDM Descriptor handler when updating LDT descriptor.

svn path=/trunk/; revision=23624
2006-08-20 20:09:25 +00:00
Alex Ionescu
017e14551b - Damn copy/paste bug.
svn path=/trunk/; revision=23623
2006-08-20 20:02:18 +00:00
Alex Ionescu
baf87a4cfb - Fix bug 1764 reported by alexvlas.
svn path=/trunk/; revision=23622
2006-08-20 20:00:56 +00:00
Alex Ionescu
233e643648 - Add support for APC-delivery after context-switch (not yet programmed)
- Detect and crash if context switch is done inside a DPC.
- Switch kernel stack a bit earlier
- Don't switch address space if we're still in the same process, and fix some duplicated code that was mixed up together.
- Move LDT setup out-of-line.

svn path=/trunk/; revision=23621
2006-08-20 19:55:32 +00:00
Johannes Anderwald
9348f70d7d * implement debugger settings for Control Panel Applets for MSVC2005
* in order to use, start the vcproj save sln and restart && enjoy

svn path=/trunk/; revision=23620
2006-08-20 19:19:21 +00:00
Alex Ionescu
58257141b3 - Some micro-architectural changes and cleanups.
svn path=/trunk/; revision=23619
2006-08-20 19:08:57 +00:00
Aleksey Bragin
f448f3bae0 [FORMATTING]
svn path=/trunk/; revision=23616
2006-08-20 14:01:17 +00:00
Magnus Olsen
4e7aa7365f do not hard code to Bitstream Vera Sans use MS Shell Dlg instead
svn path=/trunk/; revision=23615
2006-08-20 12:46:02 +00:00
Magnus Olsen
35b13e8bb0 Fixed some hard code font name
1. Bitstream Vera Sans to MS Sans Serif
2. Bitstream Vera Sans Mono to Courier New
This fixed some problem that bug 1191 mentor but not all. 
I tested this change in ReactOS 
1. using BootCD install whole process and run some ros own program
   and tested cmd. No problem was found with this change. 

svn path=/trunk/; revision=23614
2006-08-20 12:42:30 +00:00
Michele Cicciotti
be56b5e77c modified porting-tools/rdesktop-core-tester/activex.cpp
modified   porting-tools/rdesktop-core-tester/rdesktop-core-tester.vcproj
modified   porting-tools/rdesktop-core-tester/stdafx.h
    Support acting as both the stand-alone DLL (mstscax.dll) and the redistributable (msrdp.ocx)
    Wrap the non-standard "sealed" keyword in a macro
    Almost all state now correctly passed between rdesktop-core and the ActiveX
    Some debugging aids
    Prepared a functional DllMain
    Pulled in Common Controls, needed for the full-screen titlebar

modified   rdesktop/rdesktop.h
modified   rdesktop/rdp.c
modified   rdesktop/secure.c
    Minor clean-up

svn path=/trunk/; revision=23613
2006-08-19 21:44:41 +00:00
Michele Cicciotti
efcb331e18 modified porting-tools/rdesktop-core-tester/activex.cpp
Getting closer and closer and closer yet...

modified   porting-tools/rdesktop-core-tester/mstsclib_h.h
modified   porting-tools/rdesktop-core-tester/mstsclib_i.c
modified   porting-tools/rdesktop-core-tester/mstsclib_redist_h.h
modified   porting-tools/rdesktop-core-tester/mstsclib_redist_i.c
    Regenerated, no code changes

modified   porting-tools/rdesktop-core-tester/rdesktop-core-tester.cpp
modified   rdesktop/cache.c
modified   rdesktop/iso.c
modified   rdesktop/licence.c
modified   rdesktop/mcs.c
modified   rdesktop/orders.c
modified   rdesktop/parse.h
modified   rdesktop/proto.h
modified   rdesktop/pstcache.c
modified   rdesktop/rdesktop.h
modified   rdesktop/rdp.c
modified   rdesktop/rdp5.c
modified   rdesktop/secure.c
modified   rdesktop/tcp.c
    Trimmed down rdesktop-core library to the maximum extent possible
    Handle errors gracefully
    Use actual Unicode strings
    Fixed most warnings
    Added hooks for events happening inside the protocol's main loop

modified   porting-tools/rdesktop-core-tester/stdafx.cpp
    Clean-up

svn path=/trunk/; revision=23612
2006-08-19 18:40:53 +00:00
Aleksey Bragin
10f76ae52b Fix a bit of warnings
svn path=/trunk/; revision=23611
2006-08-19 18:09:30 +00:00
Aleksey Bragin
1f4c3ee955 - Brandon Turner's warning fixing patch
- When compiled with gcc we assume that CPU can't do TSC (the function will be rewritten anyway since it's weird to use inline assembly in a driver)
- Changed to the correct .rc file, removed duplicate one (ehci.rc)
- usbdriver now compiles with reactos build system

svn path=/trunk/; revision=23610
2006-08-19 16:53:49 +00:00
Johannes Anderwald
6da011c669 * implement console resources
* based on a patch by Lohnegrim

svn path=/trunk/; revision=23609
2006-08-19 10:35:00 +00:00
Brandon Turner
cd6e6b75c6 include sndvol32 on the bootcd. this fixes bug 1754
svn path=/trunk/; revision=23606
2006-08-18 23:48:02 +00:00
Aleksey Bragin
c0f94a72fc According to Filip Navara, HCELL's structure is
1. No plans to support NT 3.x hives (thus no need for OldCell / NewCell)
2. Cmlib is a bit architecturally different from NT's implementation:
"... i don't need the UserData, because that is what i return ... i don't consider it part of the header anymore"

svn path=/trunk/; revision=23605
2006-08-18 22:03:36 +00:00
Brandon Turner
5cd8f73f12 Don't redefine HIWORD or LOWORD if they are defined already.
Make 2 new macros USE_NON_PENDING_IRQL, USE_BASIC_NON_PENDING_IRQL and use accordingly to remove warnings

svn path=/trunk/; revision=23604
2006-08-18 21:37:02 +00:00
Aleksey Bragin
9bd9265d9f Fixes:
- missing ";" at eol
 - some compatibility issues with newer WDK's files

svn path=/trunk/; revision=23603
2006-08-18 21:00:43 +00:00
Aleksey Bragin
430d3e90b8 Import "USB Driver stack project for Windows NT 4.0" by Zhiming/Woodhead (mypublic99@yahoo.com).
It supports UHCI/EHCI controllers.
Don't expect it to compile with ReactOS build environment. I intend to do some work on it, and use this place to keep my changes, before it's suitable for ReactOS.


"I would like to see it useful for ReactOS" (c) woodhead

 

svn path=/trunk/; revision=23602
2006-08-18 20:37:55 +00:00
Magnus Olsen
4fec2ff8db fixed msvs build
svn path=/trunk/; revision=23601
2006-08-18 09:15:26 +00:00
Magnus Olsen
2384d41068 fixed to error that was show in msvs when it compiles
svn path=/trunk/; revision=23600
2006-08-18 09:06:28 +00:00
Brandon Turner
4316d67743 minor grammatical / wording fixes. bug 1747
svn path=/trunk/; revision=23599
2006-08-18 01:51:44 +00:00
Ged Murphy
00a97e886c don't read the 0000 key.
stops the annoying 'Missing NetCfgInstanceId Entry' message box when running in Windows.

svn path=/trunk/; revision=23598
2006-08-17 20:23:10 +00:00
Ged Murphy
0731e09013 match up taskmgr with current icon theme
svn path=/trunk/; revision=23597
2006-08-17 19:11:17 +00:00
Ged Murphy
369176ea9d Don't allow ws2_32 access to apps with bad setup data
(commit correct version this time)

svn path=/trunk/; revision=23596
2006-08-17 16:48:36 +00:00
Ged Murphy
885da5be07 Don't allow ws2_32 access to apps with bad setup data
svn path=/trunk/; revision=23595
2006-08-17 16:44:54 +00:00
Alex Ionescu
22917c0ebe - Properly disable impersonation in PsDisableImpersonation if it was previously enabled, instead of not disabling it. (fix a wrong check). Thanks to Arty.
svn path=/trunk/; revision=23588
2006-08-16 03:17:21 +00:00
James Tabor
a2976ce0d4 Only lower word is used with dwTypeData as bitmap handle.
svn path=/trunk/; revision=23587
2006-08-15 18:05:18 +00:00
Ged Murphy
b01f9a2937 [AUDIT]
iprtprio
unimplemented

svn path=/trunk/; revision=23585
2006-08-14 21:48:55 +00:00
Ged Murphy
3eb1c6a341 Add debug print
svn path=/trunk/; revision=23584
2006-08-14 21:35:51 +00:00
Alex Ionescu
361a28608d - Get rid of "ChunkSize" through a sickening hack (however this should make the Hv* interface compatible enough for me to resume work on the cm branch).
svn path=/trunk/; revision=23583
2006-08-14 21:09:41 +00:00
Magnus Olsen
207e201632 uppdate Dejavu font from 2.7 to 2.9
svn path=/trunk/; revision=23582
2006-08-14 19:48:29 +00:00
Johannes Anderwald
b94a1c980f * create a directory "system" under %SystemRoot% to make dumb apps work
* fixes bug 879

svn path=/trunk/; revision=23581
2006-08-14 17:40:41 +00:00
Ged Murphy
546f463b79 [AUDIT]
ws2_32
- All exported functions are fully documented on MSDN
- All internal functions are clearly written with no signs of reversing
- Reformat all code to ReactOS standard

svn path=/trunk/; revision=23580
2006-08-14 17:26:36 +00:00
James Tabor
4fe1ff2259 - User32: menu, patch by Michael Kaufmann. Fix the keyboard navigation and some graphical glitches for multi-column menus.
svn path=/trunk/; revision=23579
2006-08-14 14:44:40 +00:00
Alex Ionescu
d634e929b4 - Make HHIVE part of EREGISTRY_HIVE, similarly to NT.
- Get rid of Opaque member and paramter..

svn path=/trunk/; revision=23578
2006-08-14 14:16:00 +00:00
Alex Ionescu
055aceee0e - Parameter changes to HvInitialize
svn path=/trunk/; revision=23577
2006-08-14 12:50:09 +00:00
Alex Ionescu
b25952bbc1 - CELL_HEADER -> HCELL.
svn path=/trunk/; revision=23576
2006-08-14 12:22:00 +00:00
Alex Ionescu
b2ff1d22b8 - Fix small build brekage.
- Fix HBIN definition.

svn path=/trunk/; revision=23575
2006-08-14 12:15:26 +00:00
Alex Ionescu
da51ac07a6 - VALUE_CELL => CM_KEY_VALUE
svn path=/trunk/; revision=23574
2006-08-14 12:01:20 +00:00
Alex Ionescu
aa9cca267c - KEY_CELL => CM_KEY_NODE
svn path=/trunk/; revision=23573
2006-08-14 11:57:47 +00:00
Alex Ionescu
a627f5639b - Start using some NT structures (need to get rid of "Opaque").
svn path=/trunk/; revision=23572
2006-08-14 11:35:48 +00:00
Aleksey Bragin
75b35d0b0f - Change class.c to Wine-style debugging prints, add a bit of TRACEs, WARNs and ERRs (channel-based debugging output would really help a lot...)
- Fix IntMapDesktopView() to actually store the created mapping in a global list of mappings. Previously, any operation to map an address from such heap resulted in a NULL.
As a side-effect, "user32_winetest.exe class" went from 31 to 27 failures.

svn path=/trunk/; revision=23571
2006-08-13 21:43:53 +00:00
Aleksey Bragin
48ed6cd4d0 Dmitry Philippov: In MoveFileWithProgressW()
- Change alloca() to RtlAllocateHeap() and add missing freeing of the allocated space
    - Fix incorrect FileNameLength param in call to NtSetInformationFile()
    - Add support for MOVEFILE_REPLACE_EXISTING flag

svn path=/trunk/; revision=23570
2006-08-13 19:49:34 +00:00
Aleksey Bragin
81ff664e0c Dmitry Philippov: Add more tests for delayed file operations
svn path=/trunk/; revision=23569
2006-08-13 19:12:53 +00:00
Johannes Anderwald
2d95178395 * fix registry BSOD when no value exists
* fixes bug 1750
* thnx to P43LOk for bug report

svn path=/trunk/; revision=23568
2006-08-13 18:57:28 +00:00
Johannes Anderwald
0b11700c2c * add registry test code from bug 1750 by P43LOk
svn path=/trunk/; revision=23567
2006-08-13 18:52:57 +00:00
Art Yerkes
b194f1db87 Accept a NULL ResourceList if the caller is just asking how big the result
will be, as indicated by a zero BufferSize.

svn path=/trunk/; revision=23566
2006-08-13 07:05:14 +00:00
James Tabor
4e777dcafd - User32: menu, Patch by Aric Stewart, Implement MNS_NOTIFYBYPOS. Added WM_MENUCOMMAND to winuser.h.
svn path=/trunk/; revision=23565
2006-08-13 04:48:34 +00:00
Michele Cicciotti
2c5ded9a8c modified porting-tools/mstscax/mstscax.cpp
Guard against NULL pointers in certain methods
   Append a newline to debug messages
   Support a couple forgotten VARIANT types
   Corrected implementations of IUnknown::QueryInterface
   Better debug output for IDispatch::GetIDsOfNames and IDispatch::Invoke
   Debug output for IQuickActivate

modified   porting-tools/rdesktop-core-tester/activex.cpp
   Way too many changes to list. Basically, I wrote an ActiveX control without any help from third party libraries such as ATL. It was educative, but not terribly fun. Very nearly there
   All properties of the control are now supported, aligned to the behavior of the original control, version 5.2. Parameter validation and range enforcement eveeywhere

modified   porting-tools/rdesktop-core-tester/mstsclib.idl
   Reindented
   Removed explicit __stdcall convention
   Added alternate interface ids/class ids for compatibility with the msrdp.ocx redistributable. Code does not support this yet

modified   porting-tools/rdesktop-core-tester/mstsclib.rc
added      porting-tools/rdesktop-core-tester/mstsclib_redist.idl
added      porting-tools/rdesktop-core-tester/mstsclib_redist.rc
modified   porting-tools/rdesktop-core-tester/rdesktop-core-tester.vcproj
added      porting-tools/rdesktop-core-tester/typelib.rh
   Support two type libraries for compatibility with the msrdp.ocx redistributable. Code does not support this yet

modified   porting-tools/rdesktop-core-tester/mstsclib_h.h
modified   porting-tools/rdesktop-core-tester/mstsclib_i.c
added      porting-tools/rdesktop-core-tester/mstsclib_redist_h.h
added      porting-tools/rdesktop-core-tester/mstsclib_redist_i.c
   Auto-generated files, for the poor souls without MIDL

modified   porting-tools/rdesktop-core-tester/stdafx.h
   Added missing OLE header
   Corrected typo

svn path=/trunk/; revision=23564
2006-08-12 20:40:12 +00:00
Johannes Anderwald
eb1be244ca * implement unattend switch for intl
* makes ReactOS gui setup run unattended (untill VmWare popsup)

svn path=/trunk/; revision=23563
2006-08-12 19:32:57 +00:00
Johannes Anderwald
e1dde86798 * make rundll32 work w/o kernel32 hack
* thnx to Alex_Ionescu for hint

svn path=/trunk/; revision=23562
2006-08-12 19:29:08 +00:00
Johannes Anderwald
b08d57c6a7 revert my useless code
svn path=/trunk/; revision=23561
2006-08-12 18:16:17 +00:00
Johannes Anderwald
d68fdca31f disable code for now
svn path=/trunk/; revision=23560
2006-08-12 17:41:38 +00:00
Johannes Anderwald
2d88d68e4d * handle special case
svn path=/trunk/; revision=23559
2006-08-12 17:29:38 +00:00
James Tabor
219faa9936 Remove hack for TS messages.
svn path=/trunk/; revision=23558
2006-08-12 15:55:03 +00:00
James Tabor
8d995ea23d Implement SendNotifyMessage. Needs more testing.
svn path=/trunk/; revision=23557
2006-08-12 15:50:45 +00:00
Ged Murphy
635b9fb393 fix a few resource leaks
svn path=/trunk/; revision=23556
2006-08-12 15:17:29 +00:00
Ged Murphy
7c636c8e1f [AUDIT]
smdll.dll
This is a ReactOS native library

svn path=/trunk/; revision=23555
2006-08-12 14:55:16 +00:00
Magnus Olsen
7fda8aece2 revers Revision: 23549 | * allocate a terminating zero for every parsed argument
The code cause a regress. and the old code is 100% correct. I spoken with janderwald about it
*argc can be 0 when it call to CommandLineToArgv and he did not think of it. and agrument 
agrc is always 1, but that can not be take into accunt. for u do not paraser how many argc it exists
you parser the current argv, like is it 0, is it 1 so on. 

 


svn path=/trunk/; revision=23554
2006-08-12 14:51:51 +00:00
Ged Murphy
bdea0e74a9 [AUDIT]
samlib.dll
Confirmed to be clean by Eric Kohl

svn path=/trunk/; revision=23553
2006-08-12 14:48:29 +00:00
Ged Murphy
c79e850942 revert 23551, wrong directory.
As my penance, I'll review this one next ;)

svn path=/trunk/; revision=23552
2006-08-12 14:47:31 +00:00
Ged Murphy
b386ef68c8 [AUDIT]
samlib.dll
Confirmed to be clean by Eric Kohl

svn path=/trunk/; revision=23551
2006-08-12 14:44:58 +00:00
Johannes Anderwald
2066acf1fa * remove unused export
svn path=/trunk/; revision=23550
2006-08-12 14:22:40 +00:00
Johannes Anderwald
9ab72b3399 * allocate a terminating zero for every parsed argument
svn path=/trunk/; revision=23549
2006-08-12 14:17:44 +00:00
Johannes Anderwald
c20e99d518 * unhack calling international control panel applet by using rundll32
svn path=/trunk/; revision=23548
2006-08-12 14:14:52 +00:00
Johannes Anderwald
336ae5366e * put application name in quotes when lpCommandLine is != NULL
svn path=/trunk/; revision=23547
2006-08-12 14:10:31 +00:00
Ged Murphy
4a4efbf11b [AUDIT]
packet.dll
3rd party lib from winpcap

svn path=/trunk/; revision=23546
2006-08-12 11:01:41 +00:00
Aleksey Bragin
ac3d2f0869 - Remove non-needed checks from GetClassInfoA/W, because they are performed in GetClassInfoExA/W or not performed in Windows at all
- So now GetClassInfoA/W implementations are correct and all hacks are moved to GetClassInfoExA/W. This doesn't fix Abiword, but might fix direct calls to GetClassInfoExA/W which might fail due to not set "cbSize" member of WNDCLASS struct.
I marked this as HACKHACK for further investigation and removal.


svn path=/trunk/; revision=23545
2006-08-11 21:24:11 +00:00
Aleksey Bragin
a31fa06b4d Computer name must always be uppercased, even despite it is an example
svn path=/trunk/; revision=23544
2006-08-11 09:05:24 +00:00
Aleksey Bragin
e91fadbcbd Revert one meaningless change from the previous patch
svn path=/trunk/; revision=23543
2006-08-10 20:56:48 +00:00
Art Yerkes
9834923eaf Added missing return.
svn path=/trunk/; revision=23542
2006-08-10 19:52:55 +00:00
Hervé Poussineau
65cde24d6c "Unicodify" msgina
Add stubs for locking/unlocking

svn path=/trunk/; revision=23541
2006-08-10 18:41:23 +00:00
Hervé Poussineau
e3d8854be7 Add code to start the screensaver from winlogon
This code should replace the existing one in win32k/csrss, but is not activated (yet) due to some bugs:
- Calling SetWindowsHookEx with WH_KEYBOARD_LL gives a BSOD when pressing a key
- Time field in PKBDLLHOOKSTRUCT/PMSLLHOOKSTRUCT should be in milliseconds
- Screen saver parameters can't be retrieved with SystemParametersInfoW
- Probably others...

Plus a few less important ones:
- When sending a message with HWND_BROADCAST, the invisible SAS window doesn't get the message
- When calling (NtUser)SystemParametersInfo, WM_SETTINGSCHANGE message is not sent
- desk.cpl doesn't save (some) screensaver parameters to registry

svn path=/trunk/; revision=23540
2006-08-10 18:37:03 +00:00
Martin Fuchs
3318c29301 some commentary changes
svn path=/trunk/; revision=23539
2006-08-09 21:27:05 +00:00
Martin Fuchs
f465feb351 refresh shell background in response to system color changes
svn path=/trunk/; revision=23538
2006-08-09 20:10:41 +00:00
Aleksey Bragin
ccf643d45b Dmitriy Philippov (shedon@mail.ru):
- The MOVEFILE_DELAY_UNTIL_REBOOT flag is incorrect processed in the MoveFileWithProgressW function.
- The add_boot_rename_entry function contains too many bugs, it crashes when
deleting operation is performed, it does not save old entry in registry, etc...

Fixes are based on the testing application located in reactos/base/application/testsets/smss/movefile


svn path=/trunk/; revision=23537
2006-08-09 19:46:07 +00:00
Aleksey Bragin
46d49263c2 Dmitriy Philippov (shedon@mail.ru): Add test application for move file after reboot function of smss.exe / kernel32.dll
svn path=/trunk/; revision=23536
2006-08-09 19:42:50 +00:00
Hervé Poussineau
3be6aa3601 Check if logoff succeeded before continuing
Check if shutdown succeeded before calling kernel

svn path=/trunk/; revision=23534
2006-08-09 14:29:12 +00:00
Hervé Poussineau
4419e2ce2a A thread may exit with a status code of 0.
svn path=/trunk/; revision=23533
2006-08-09 12:46:41 +00:00
Hervé Poussineau
009c9838df Fix a bug in NtQueryInformationThread, which was leading to its unusability in user mode
svn path=/trunk/; revision=23532
2006-08-09 12:15:18 +00:00
Aleksey Bragin
f253f896e7 - Add tracing to class.c
- Slightly change header to match the new style

svn path=/trunk/; revision=23531
2006-08-09 10:00:04 +00:00
Hervé Poussineau
6007fa59ce Remove HandleExitWindows, and move its code to HandleLogoff and HandleShutdown
Lots of cleanup

svn path=/trunk/; revision=23530
2006-08-09 06:31:02 +00:00
Andrew Munger
844073d973 Update the hardcoded ViewCVS URL. Now packmgr works on the bootcd.
svn path=/trunk/; revision=23529
2006-08-08 21:19:11 +00:00
James Tabor
e2f4a9bdf8 Fix build, for NDEBUG.
svn path=/trunk/; revision=23528
2006-08-08 20:51:59 +00:00
Andrew Munger
16837dffa3 Correct the path to the package.dll for packmgr.
svn path=/trunk/; revision=23526
2006-08-08 20:13:27 +00:00
James Tabor
43bcb034b6 - DrawCaption
- Patch by Saveliy Tretiakov, new NtUserDrawCaption implementation.
    See URL for more details, http://www.reactos.org/archives/public/ros-dev/2006-July/008575.html


svn path=/trunk/; revision=23525
2006-08-08 20:00:53 +00:00
Aleksey Bragin
0468c25a60 Force -fno-sibling-call-optimisation to every module's CFLAGs. This fixes *numerous* bugs (thanks to a bug in GCC itself), even in DBG=1 builds!
Just an example, comctl32.dll doesn't crash anymore in LISTVIEW_Callback().

Thanks to Dmitriy Philippov (aka Shedon) for encountering the comctl32 bug and investigating it!

svn path=/trunk/; revision=23524
2006-08-08 12:41:56 +00:00
Hervé Poussineau
cd084157bd Give a valid name to the event
svn path=/trunk/; revision=23523
2006-08-08 11:10:59 +00:00
Hervé Poussineau
6889ad333c Patch by Filip Navara: Remove the call to HvFree, as the hive was not initialized
svn path=/trunk/; revision=23522
2006-08-08 09:31:19 +00:00
Eric Kohl
4d64dd44c6 - Implement ScmStartServiceA and revert the last modification of StartServiceA.
- Fix EnumServicesStatusExW.

svn path=/trunk/; revision=23521
2006-08-07 22:13:26 +00:00
Hervé Poussineau
2f021d099e - Start lsass.exe sooner, as Gina can call LsaRegisterLogonProcess in WlxInitialize
- Check that loaded Gina has all needed functions
- Set security attributes on windowstation and desktops

svn path=/trunk/; revision=23520
2006-08-07 17:18:58 +00:00
Hervé Poussineau
30c988c9be Call ScmrStartServiceW in StartServiceA to prevent code duplicating between ScmrStartServiceA/W in services.exe
svn path=/trunk/; revision=23519
2006-08-07 17:04:48 +00:00
Johannes Anderwald
552dc71367 * GUI settings for unattended setup
svn path=/trunk/; revision=23518
2006-08-07 13:32:31 +00:00
Johannes Anderwald
1547291dcc * make 2nd stage setup semi-unattendable (locale page is missing)
* to enable add the boot\bootdata\unattend.inf                          6   optional
to boot\bootdata\packages\reactos.dff

svn path=/trunk/; revision=23517
2006-08-07 13:31:11 +00:00
Hervé Poussineau
6845ab891c Add missing svn:eol-style property
svn path=/trunk/; revision=23516
2006-08-07 11:11:15 +00:00
Hervé Poussineau
dca537db04 Skip first call to AddDevice
svn path=/trunk/; revision=23515
2006-08-07 11:03:35 +00:00
Hervé Poussineau
8fb3dbf0ac Remove extra call to SETUP_CreateDevicesList
svn path=/trunk/; revision=23514
2006-08-07 11:02:14 +00:00
Hervé Poussineau
2d8c75910e Return code is really a NTSTATUS, not an unsigned int
svn path=/trunk/; revision=23513
2006-08-07 09:56:33 +00:00
Hervé Poussineau
2d7a591549 Move some more standard types in a common header
Thanks to Elrond from Samba-TNG for help

svn path=/trunk/; revision=23512
2006-08-07 09:48:54 +00:00
The Wine Synchronizer
7c4786c712 [FORMATTING]
Fix file headers to match coding style, and include reference to all programmers.

No code change.

svn path=/trunk/; revision=23511
2006-08-07 07:54:08 +00:00
Hervé Poussineau
157b8e865c Put standard types in a common header
Thanks to Elrond from Samba-TNG for help

svn path=/trunk/; revision=23510
2006-08-06 22:45:51 +00:00
Aleksey Bragin
f792bc36a0 Relax restriction on the segment in NtSetLdtEntries(). Look into diff for details. Thanks to Myria for providing information.
There were no reasons found which can proof that this change could lead to security issues.

svn path=/trunk/; revision=23509
2006-08-06 22:02:02 +00:00
Aleksey Bragin
4a57b7984a Goodbye REGISTRY_ERROR bsod!
- Change UserMode -> KernelMode in ObReferenceObject*() calls, because that calls failed
- Remove Cm-specific hack from Ob

"advapi32_winetest.exe registry" shows 0 failures on the first run and 2 failures on further runs.
I suppose there might be a leakage in the CM. To be investigated further (or wait till complete Cm rewrite in October).

svn path=/trunk/; revision=23508
2006-08-06 21:15:55 +00:00
Hervé Poussineau
15e0dc6523 SECURITY_NT_NON_UNIQUE_RID -> SECURITY_NT_NON_UNIQUE
svn path=/trunk/; revision=23507
2006-08-06 20:33:34 +00:00
Aleksey Bragin
310cebde9f - Change DbgPrint prototype back to Alex's fix. His change was correct and my commit was wrong.
- Respectively fix all occurences of DbgPrint()'s wrong prototypes throughout the tree
- HACKHACK: Change KeNumberProcessors definition in "else" branch of NTDDI_VERSION #if. I'm not sure how to properly fix this and for now I marked this place. Probably NTDDI_VERSION should be set correctly in ntoskrnl and other modules which use this variable. 

svn path=/trunk/; revision=23506
2006-08-06 19:57:24 +00:00
Hervé Poussineau
afb2063fd3 Fix an infinite loop if environment variable is not defined
svn path=/trunk/; revision=23505
2006-08-06 18:44:27 +00:00
Hervé Poussineau
887690f26d Move code around files to be more like Wine. No code change.
svn path=/trunk/; revision=23504
2006-08-06 18:37:39 +00:00
Hervé Poussineau
918b7c6c45 Implement CreateWellKnownSid and IsWellKnownSid, by ripping the Wine implementation (created by Robert Reif)
svn path=/trunk/; revision=23503
2006-08-06 18:22:36 +00:00
Hervé Poussineau
b1079a9149 Add more SID defines
svn path=/trunk/; revision=23502
2006-08-06 18:08:16 +00:00
Hervé Poussineau
63e6cdc364 Cleanup shutdown code path. Now, the user can logoff and logon again.
svn path=/trunk/; revision=23501
2006-08-06 15:47:04 +00:00
Hervé Poussineau
b229f6fcb2 Update French translation
svn path=/trunk/; revision=23500
2006-08-06 15:40:47 +00:00
Hervé Poussineau
6d3b584805 Fix a few referencing bugs (Object type must be specified if AccessMode is UserMode)
svn path=/trunk/; revision=23499
2006-08-06 15:38:56 +00:00
Hervé Poussineau
82aec77c32 STDCALL -> NTAPI
Update my mail address

svn path=/trunk/; revision=23498
2006-08-06 15:37:21 +00:00
Hervé Poussineau
6821c84844 Fix return type in .idl file
(advapi32.dll and services.exe already agreed on a error code status as return type)

svn path=/trunk/; revision=23497
2006-08-06 14:29:19 +00:00
Hervé Poussineau
705830858c - Add dsgetdc.h header
- Add missing constants SECURITY_MIN_SID_SIZE/SECURITY_MAX_SID_SIZE
- Define FreeInheritedFromArray only when _WIN32_WINNT >= 0x0501

svn path=/trunk/; revision=23496
2006-08-06 12:03:31 +00:00
Magnus Olsen
d68102ed54 forget remove one line in DirectDraw_GetAvailableVidMem sorry
svn path=/trunk/; revision=23495
2006-08-06 10:29:56 +00:00
Magnus Olsen
803578b8bc fixing some bugs in DirectDraw_GetAvailableVidMem
svn path=/trunk/; revision=23494
2006-08-06 10:28:08 +00:00
Magnus Olsen
1df8bd39ee Bugfix DirectDraw_AddRef
svn path=/trunk/; revision=23493
2006-08-06 09:56:21 +00:00
Magnus Olsen
f5b7920569 fixing ddraw regress instead bsod or fail create surface, now it fail on attach surface
svn path=/trunk/; revision=23492
2006-08-06 08:47:18 +00:00
Aleksey Bragin
dc159816df [AUDIT]
Configuration Manager

Cm part of the kernel was developed from scratch for a long time ago, and based only on legally clean information sources. After going through the code, it doesn't have any signs of questionable origin.
Authorship information will be added during formatting of the code.

svn path=/trunk/; revision=23491
2006-08-05 21:39:29 +00:00
Aleksey Bragin
8310980ff6 Fix the last definition of DbgPrint
svn path=/trunk/; revision=23490
2006-08-05 21:17:55 +00:00
Aleksey Bragin
4a9752bbe4 Fix DbgPrint / DbgPrintEx definitions to use PCCHAR instead of PCCH (recent WDK uses PCCHAR).
This change fixes compiling.

svn path=/trunk/; revision=23489
2006-08-05 20:57:36 +00:00
Alex Ionescu
3646d0b420 - Fix another incorrect DbgPrint prototype.
svn path=/trunk/; revision=23488
2006-08-05 16:50:36 +00:00
Alex Ionescu
86e31ea51a - Fix how DDK is included.
svn path=/trunk/; revision=23487
2006-08-05 16:50:23 +00:00
Alex Ionescu
4a84399353 - mangledDDK had no idea what a const char is, now it does.
- mangledDDK had wrong prototypes of DbgPrint/Ex.
- PSEH too.
- Fixed ntoskrnl headers to build with Windows 2003 header definitions. Make handle.c force usage of Windows 2000 header definitions, because the handle code is Win2K.
- mangledDDK had wrong KeNumberProcessors definition.

svn path=/trunk/; revision=23486
2006-08-05 16:49:07 +00:00
Alex Ionescu
9d109579e3 - DDK Compatibility fixes.
svn path=/trunk/; revision=23484
2006-08-05 16:27:20 +00:00
Aleksey Bragin
7f1a5332e2 Convert \ to / path separator in .rc files (fixes linux building process)
svn path=/trunk/; revision=23482
2006-08-05 13:38:51 +00:00
Magnus Olsen
5cf9d852b7 1. move rc languages to folder lang
2. Adding rsrc.rc so u can open rc file in vs 
3. fixing sublang id for some languages  so it can be open in vs

svn path=/trunk/; revision=23481
2006-08-05 11:55:35 +00:00
Magnus Olsen
db565c34cd 1. move rc languages to folder lang
2. Adding rsrc.rc so u can open rc file in vs 
3. fixing sublang id for some languages  so it can be open in vs

svn path=/trunk/; revision=23480
2006-08-05 11:43:49 +00:00
Magnus Olsen
c196fd1221 1. move rc languages to folder lang
2. Adding rsrc.rc so u can open rc file in vs 
3. fixing sublang id for almost all languages  so it can be open in vs
ToDO
each langues have diffent menu and dialog for some have update En.rc and not the rest of the languages file 
Never only update En.rc update all other languages file same time so we have same desgin and option and dialog
box on each languages. 

svn path=/trunk/; revision=23479
2006-08-05 10:37:42 +00:00
Magnus Olsen
a86f6c873d forget this file thx fireball
svn path=/trunk/; revision=23478
2006-08-05 10:08:29 +00:00
Magnus Olsen
8c69a85ea6 1. move rc languages to folder lang
2. Adding rsrc.rc so u can open rc file in vs 
3. fixing sublang id for hu.rc so it can be open in vs

svn path=/trunk/; revision=23477
2006-08-05 09:29:13 +00:00
Magnus Olsen
812c059223 1. move rc languages to folder lang
2. Adding rsrc.rc so u can open rc file in vs 

svn path=/trunk/; revision=23476
2006-08-05 09:21:21 +00:00
Aleksey Bragin
3a9d44aa99 Change "\" to "/", so it compiles both on Linux and Windows.
svn path=/trunk/; revision=23475
2006-08-05 09:15:18 +00:00
Magnus Olsen
f5c9f4acdb 1. move rc languse to folder lang
2. Adding rsrc.rc so u can open rc file in vs 
3. Fixing Ru and Hu sublang id. so they showing in vs instead for unkown langues. 

svn path=/trunk/; revision=23474
2006-08-05 09:05:28 +00:00
Magnus Olsen
5004195fad move rc languse to folder lang
svn path=/trunk/; revision=23473
2006-08-05 09:03:04 +00:00
Magnus Olsen
60bdf62560 move the lang filr to folder lang
(do not use torstensvn to move file, torstensvn can not manger move all file at once, only command base svn)

svn path=/trunk/; revision=23472
2006-08-05 08:43:23 +00:00
Aleksey Bragin
591d64daec Moved language resource files to lang subdir.
svn path=/trunk/; revision=23471
2006-08-05 08:35:32 +00:00
Magnus Olsen
7f27d73fda Moved remotely
svn path=/trunk/; revision=23470
2006-08-05 08:30:47 +00:00
Magnus Olsen
20a0e7fdb3 Moved remotely
svn path=/trunk/; revision=23469
2006-08-05 08:30:39 +00:00
Magnus Olsen
fc71bab6eb Moved remotely
svn path=/trunk/; revision=23468
2006-08-05 08:30:26 +00:00
Magnus Olsen
055745600b Moved remotely
svn path=/trunk/; revision=23467
2006-08-05 08:30:18 +00:00
Magnus Olsen
81e2c1b0e0 Moved remotely
svn path=/trunk/; revision=23466
2006-08-05 08:30:11 +00:00
Magnus Olsen
714ccb42ca Moved remotely
svn path=/trunk/; revision=23465
2006-08-05 08:30:03 +00:00
Magnus Olsen
ac06d7203f Moved remotely
svn path=/trunk/; revision=23464
2006-08-05 08:29:58 +00:00
Magnus Olsen
0ac77c3f8c Moved remotely
svn path=/trunk/; revision=23463
2006-08-05 08:29:49 +00:00
Magnus Olsen
d2fd2cd3fa Moved remotely
svn path=/trunk/; revision=23462
2006-08-05 08:28:29 +00:00
Magnus Olsen
c24caedf13 Created folder remotely
svn path=/trunk/; revision=23461
2006-08-05 08:27:21 +00:00
Magnus Olsen
937ceea974 finsih the move of langues rc
svn path=/trunk/; revision=23460
2006-08-05 08:26:42 +00:00
Magnus Olsen
300d54c674 Moved remotely
svn path=/trunk/; revision=23459
2006-08-05 08:13:11 +00:00
Magnus Olsen
254a2e45f6 Moved remotely
svn path=/trunk/; revision=23458
2006-08-05 08:12:46 +00:00
Magnus Olsen
99db1b9c92 Moved remotely
svn path=/trunk/; revision=23457
2006-08-05 08:12:31 +00:00
Magnus Olsen
ec9f9a3f13 Moved remotely
svn path=/trunk/; revision=23456
2006-08-05 08:12:03 +00:00
Magnus Olsen
d22731eceb Moved remotely
svn path=/trunk/; revision=23455
2006-08-05 08:11:50 +00:00
Magnus Olsen
6c109b3daa Moved remotely
svn path=/trunk/; revision=23454
2006-08-05 08:11:34 +00:00
Magnus Olsen
ef91589118 Created folder remotely
we store all langues rc file to folder lang

svn path=/trunk/; revision=23453
2006-08-05 08:10:44 +00:00
James Tabor
79b9b1a431 Patch by Dan Hipschman, Call SetLastError in CreateWindowEx when WS_CHILD is set with no parent.
svn path=/trunk/; revision=23452
2006-08-05 01:48:20 +00:00
Ged Murphy
c44fecf418 change definition to ensure calling of unicode
svn path=/trunk/; revision=23449
2006-08-04 23:40:16 +00:00
Brandon Turner
4ea471d5a5 update the help for exit to include /b
svn path=/trunk/; revision=23448
2006-08-04 21:24:57 +00:00
Hervé Poussineau
56a847b2ca Implement /CMDCONS switch, which allows the user to start in text mode
Autologon should only be done once (when starting the computer, not after the user has logged out)
Remove the status message dialog only in GUI

svn path=/trunk/; revision=23447
2006-08-04 19:44:35 +00:00
Aleksey Bragin
41fb06f69a Add an entry to enable unattended 1st stage setup (commented out by default).
In order to get unattended setup working:
1. Copy unattend.inf.sample to unattend.inf, adjust as needed
2. Uncomment the line in bootdata.rbuild to include it into bootcd

svn path=/trunk/; revision=23446
2006-08-04 19:28:54 +00:00
Hervé Poussineau
3455731503 Try to implement a working shutdown.
Sorry, I had to disable some code to close user processes in subsystems/win32/csrss/win32csr/exitros.c

svn path=/trunk/; revision=23445
2006-08-04 15:39:44 +00:00
Hervé Poussineau
3008860064 We should be able to set ThreadImpersonationToken information with NtSetInformationThread
svn path=/trunk/; revision=23444
2006-08-04 13:52:16 +00:00
Hervé Poussineau
c5245d5b4b - Remove now useless entries about PCI bus, as StartService is now working in 2nd stage setup
- Add Netlogon service (lsass.exe)

svn path=/trunk/; revision=23443
2006-08-04 12:01:27 +00:00
Hervé Poussineau
06797ae112 - Specify *W at the end of function calls, and remove the need to define UNICODE
- Rename MsGina to Gina
- Start services.exe before running 2nd stage setup

svn path=/trunk/; revision=23442
2006-08-04 11:37:18 +00:00
Ged Murphy
6777e6905f fix loading of current values for ip and dhcp
svn path=/trunk/; revision=23441
2006-08-03 22:20:44 +00:00
Ged Murphy
2175834be0 - load the current IP address when switching from dhcp to manual.
- this isn't how Windows behaves, but it should be as it makes life slightly easier in most cases

svn path=/trunk/; revision=23440
2006-08-03 21:29:09 +00:00
Ged Murphy
7288929ef0 doh, rushed code leads to leaked resources.
thanks lkjasa for pointing it out.

svn path=/trunk/; revision=23439
2006-08-03 20:32:10 +00:00
Ged Murphy
728a261829 size the buffer dynamically to avoid potentially overflowing it
svn path=/trunk/; revision=23438
2006-08-03 19:06:12 +00:00
Ged Murphy
c6b0db6688 Add a header to the prop sheet and correct a variable spelling
fixes bug 1731
patch from itay.perl@gmail.com

svn path=/trunk/; revision=23437
2006-08-03 18:01:47 +00:00
Christoph von Wittich
53af48a8b2 -removed DefWindowProc from the Dialog WndProcs
svn path=/trunk/; revision=23436
2006-08-03 15:57:10 +00:00
Hervé Poussineau
5ef94aacb7 Don't try to remove a status message if none have been displayed and GINA has not been initialized
svn path=/trunk/; revision=23435
2006-08-03 15:14:14 +00:00
Hervé Poussineau
603ac11c9a Simplify management of loggedout window
Implement locking/unlocking of the workstation (only by code, not the associated dialogs)

svn path=/trunk/; revision=23434
2006-08-03 13:54:44 +00:00
Hervé Poussineau
e202c810ac Implement shutdown and unlocking
Remove some useless code
Implement Timeout for dialogs

svn path=/trunk/; revision=23433
2006-08-03 13:50:40 +00:00
James Tabor
21ea0d9494 Fix build
svn path=/trunk/; revision=23432
2006-08-03 01:30:40 +00:00
Christoph von Wittich
26dbfdec15 -splitted resource file into en.rc and msgina.rc
-prettyfied msgina a bit
-fixed line endings

svn path=/trunk/; revision=23430
2006-08-03 00:32:32 +00:00
James Tabor
a0f6dcc406 Fixed typo, btw this fixes most of the edit tests.
svn path=/trunk/; revision=23429
2006-08-03 00:01:05 +00:00
James Tabor
db09492d5f - Win32k
- CreateWindowsEx: Patch based on janderwald patch.
    1. Reading and follow wine source (user/win.c & winex11.drv/window.c), I noticed that cs->hwndParent is unmodified when passed to the children via WM_NC/CREATE.
    2. Reordered the "fine the parent" code, based on wine. I've tested this change for last two weeks.

svn path=/trunk/; revision=23428
2006-08-02 23:39:53 +00:00
Hervé Poussineau
4546ac2820 Fix compilation
svn path=/trunk/; revision=23427
2006-08-02 22:49:02 +00:00
Ged Murphy
972b814ded disable the floating toolbars by default until they are useful.
svn path=/trunk/; revision=23425
2006-08-02 21:52:20 +00:00
Hervé Poussineau
d194ee80a5 Winlogon:
- Register CTRL+ALT+DELETE notification
- Better session loop between all GINA dialogs
- Display a dialog box if GINA DLL cannot be loaded
GINA:
- Add an graphical and text interface to enter username/password
- Take care of autologon parameters in registry

svn path=/trunk/; revision=23424
2006-08-02 21:01:37 +00:00
Johannes Anderwald
d99c9b45f0 .c files are not executable files
svn path=/trunk/; revision=23423
2006-08-02 20:51:13 +00:00
Hervé Poussineau
0d5fd6cd68 - Implement INF_STYLE_OLDNT style in SetupOpenInfFileW
- Add some documentation in header file

svn path=/trunk/; revision=23422
2006-08-02 20:45:13 +00:00
Ged Murphy
5b8e3e2f5b fix MSI build warnings
svn path=/trunk/; revision=23421
2006-08-02 20:01:22 +00:00
Ged Murphy
64a6bb9b0e remove wine file. This should now be defined in our psdk
svn path=/trunk/; revision=23420
2006-08-02 20:00:45 +00:00
Johannes Anderwald
31b43700f6 add description on how to bypass MBR installation page
svn path=/trunk/; revision=23419
2006-08-02 18:59:06 +00:00
Johannes Anderwald
6c41639b61 * make ReactOS textmode setup full-unattendable
svn path=/trunk/; revision=23418
2006-08-02 18:58:07 +00:00
Michele Cicciotti
6556fec93f modified porting-tools/mstscax/mstscax.cpp
modified   porting-tools/mstscax/stdafx.h
   Added support for aggregation (ActiveX controls are expected to be aggregable)
   Added IMsRdpClientAdvancedSettings4 stub
   Added some other minor stubs

added      porting-tools/rdesktop-core-tester/activex.cpp
modified   porting-tools/rdesktop-core-tester/stdafx.h
modified   porting-tools/rdesktop-core-tester/rdesktop-core-tester.vcproj
   Full stubs for RDP client ActiveX control

added      porting-tools/rdesktop-core-tester/mstsclib.idl
added      porting-tools/rdesktop-core-tester/mstsclib.rc
added      porting-tools/rdesktop-core-tester/mstsclib_h.h
added      porting-tools/rdesktop-core-tester/mstsclib_i.c
   IDL definition file and type library resource for the ActiveX control. MIDL-generated files temporarily committed

modified   porting-tools/rdesktop-core-tester/rdesktop-core-tester.cpp
   Overall cleanup
   GDI code now uses SaveDC/RestoreDC instead of multiple calls
   Virtual Channel API stubs

modified   rdesktop/bitmap.c
   Re-enable optimizations

modified   rdesktop/channels.c
   Magic numbers are evil

modified   rdesktop/mcs.c
modified   rdesktop/rdesktop.h
   MCS channel ids were superfluous

modified   rdesktop/rdesktop-core.vcproj
modified   rdesktop/secure.c
modified   rdesktop/types.h
   Removed virtual channels implementation, preparing to replace with extensible, multithreaded, Windows-compatible implementation

svn path=/trunk/; revision=23417
2006-08-02 14:21:45 +00:00
Martin Fuchs
2a4389576a fix GCC build error "explicit qualification in declaration of MLStorage::..." for ibrowser
svn path=/trunk/; revision=23416
2006-08-02 12:20:14 +00:00
Martin Fuchs
a16732d63c fix GCC build error "explicit qualification in declaration of MLStorage::..."
svn path=/trunk/; revision=23415
2006-08-02 12:11:24 +00:00
Ged Murphy
6193e2092b - sync MSI to Wine 0.9.18
- note, it still has the swprintf warnings which I'll fix tomorrow (if someone reminds me ;) )
- MSI Wine test is now in trunk, if anyone has chance to do a before and after test ...

svn path=/trunk/; revision=23414
2006-08-01 23:12:11 +00:00
Ged Murphy
5e15912284 add msi wine regression test
svn path=/trunk/; revision=23410
2006-08-01 22:48:23 +00:00
James Tabor
1d2d013384 - User32
- Dialog.c Partial sync to wine. 
  - Add WinPosActivateOtherWindow to winpos.c, activate another window when the dialog gets hidden in EndDialog.
  - Misc fixes and changes.

svn path=/trunk/; revision=23409
2006-08-01 21:14:45 +00:00
Hervé Poussineau
963218942e Use the locally modified StartupInfo, instead of the one the caller gave us
svn path=/trunk/; revision=23407
2006-08-01 15:59:14 +00:00
The Wine Synchronizer
e184a78b53 Revert 23354 (causes a bugcheck). It will be committed when Alex has time to fix that issue.
svn path=/trunk/; revision=23405
2006-08-01 12:50:11 +00:00
Martin Fuchs
9940e41a7b fix output of XML document types
svn path=/trunk/; revision=23403
2006-08-01 09:23:41 +00:00
Filip Navara
eb035c3d8f Fix the damn detection code.
svn path=/trunk/; revision=23401
2006-08-01 03:43:51 +00:00
Martin Fuchs
2005844309 cleanup project files
svn path=/trunk/; revision=23400
2006-07-31 23:49:13 +00:00
Martin Fuchs
0887b49c1b move string constants into XMLStorage namespace
svn path=/trunk/; revision=23399
2006-07-31 23:46:20 +00:00
Martin Fuchs
8cb05b5ab7 IBrowser: update XMLStorage library and remove Expat dependency
svn path=/trunk/; revision=23398
2006-07-31 23:23:19 +00:00
Martin Fuchs
350cddb3d6 Explorer: update XMLStorage library and remove Expat dependency
svn path=/trunk/; revision=23397
2006-07-31 23:21:55 +00:00
Andrew Munger
4a89b0422d Fix the build on linux (for real). Patch from hpoussin, who checked that it didn't break the win32 build.
This also reverts 23394.

svn path=/trunk/; revision=23396
2006-07-31 22:34:55 +00:00
Martin Fuchs
56781e4522 ibrowser resources: fix norwegian sublanguage ID
svn path=/trunk/; revision=23395
2006-07-31 22:29:45 +00:00
Eric Kohl
5bcb07458e Fix missing _strnicmp on Linux.
svn path=/trunk/; revision=23394
2006-07-31 20:20:10 +00:00
Brandon Turner
899a4ac7b8 Implement the reading and writing of pagefile settings. We should not longer have to edit it by hand in regedit. This works 100% flawlessly in win2k3 but has not been tested in ros yet. Patch by Christian Wallukat (cwallukat@gmx.at) and myself.
svn path=/trunk/; revision=23381
2006-07-30 23:14:02 +00:00
The Wine Synchronizer
ad4cd97427 Autosyncing with Wine HEAD
svn path=/trunk/; revision=23380
2006-07-30 21:27:45 +00:00
Eric Kohl
1edf91632a Updated information about widl.
svn path=/trunk/; revision=23378
2006-07-30 13:39:42 +00:00
Eric Kohl
945bcdf5e8 This modification is required for use with the WINE widl.
svn path=/trunk/; revision=23377
2006-07-30 13:02:53 +00:00
Eric Kohl
9c239fd76f Synchronize with current WINE widl 20060729.
svn path=/trunk/; revision=23376
2006-07-30 12:58:24 +00:00
Hervé Poussineau
6c4f49b5cd - Create a window to receive the CTRL+ALT+DELETE event (not working yet)
- Remove support for console start (it is the role of msgina, not winlogon)
- Implement some simple functions

svn path=/trunk/; revision=23375
2006-07-30 08:38:35 +00:00
Hervé Poussineau
6b63d81fbd Implement SM_REMOTESESSION message
svn path=/trunk/; revision=23374
2006-07-29 23:55:07 +00:00
Hervé Poussineau
754546cdfc Add autologon information (not used yet)
svn path=/trunk/; revision=23373
2006-07-29 23:13:17 +00:00
Christoph von Wittich
9cff1db692 fix ASSERT in ndis, now the Realtek 8029AS (ne2000) driver is working
svn path=/trunk/; revision=23368
2006-07-29 20:23:44 +00:00
Aleksey Bragin
6698793717 Move two helper macros into cm.h, and uncomment DPRINTs using them in registry code
svn path=/trunk/; revision=23365
2006-07-29 20:01:38 +00:00
325 changed files with 2555 additions and 160317 deletions

0
.gitignore vendored
View File

View File

@@ -0,0 +1,46 @@
<?xml version="1.0"?>
<!--
Copyright (C) 2005 Casper S. Hornstrup
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-->
<project name="ReactOS.ApiStatus" default="publish">
<property name="reactos.dir" value="reactos" />
<property name="apistatus.xsl" value="rapistatus.xsl" />
<property name="apistatus.xml" value="rapistatus.xml" />
<property name="apistatus.html" value="index2.html" />
<include buildfile="config.include" />
<target name="publish">
<delete dir="${reactos.dir}" if="${directory::exists(reactos.dir)}" />
<exec program="svn" commandline="export -r HEAD ${source.url} ${reactos.dir}" />
<exec program="rgenstat" commandline="reactos\apistatus.lst ${apistatus.xml}" />
<style style="${apistatus.xsl}" destdir="${reactos.dir}" in="${apistatus.xml}" out="${apistatus.html}" />
<copy todir="${publish.dir}" overwrite="true">
<fileset basedir=".">
<include name="${apistatus.xml}" />
<include name="${apistatus.html}" />
</fileset>
</copy>
<delete>
<fileset basedir=".">
<include name="${apistatus.xml}" />
<include name="${apistatus.html}" />
</fileset>
</delete>
<delete dir="${reactos.dir}" if="${directory::exists(reactos.dir)}" />
</target>
</project>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2005 Casper S. Hornstrup
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-->
<project>
<property name="source.url" value="svn://svn.reactos.com/trunk/reactos" />
<property name="publish.dir" value="C:\api" />
</project>

199
ReactOS.ApiStatus/rapistatus.xsl Executable file
View File

@@ -0,0 +1,199 @@
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="no"/>
<!-- <xsl:output method="xml"/>-->
<!-- Will not work: <xsl:strip-space elements="*"/> -->
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>
ReactOS API Status
</TITLE>
<SCRIPT src="rapistatus.js"></SCRIPT>
<LINK rel="stylesheet" type="text/css" href="rapistatus.css"></LINK>
</HEAD>
<BODY onLoad="onLoad();">
<P>
<H1>ReactOS API Status</H1>
</P>
<P>
<TABLE>
<TR>
<TD> <INPUT type="checkbox" ID="implemented" onClick="selectImplemented();" checked="1"/> </TD>
<TD> <IMG src="i.gif"/> </TD>
<TD> Implemented </TD>
<TD width="20"/>
</TR>
<TR>
<TD> <INPUT type="checkbox" ID="unimplemented" onClick="selectUnimplemented();" checked="1"/> </TD>
<TD> <IMG src="u.gif"/> </TD>
<TD> Unimplemented </TD>
<TD width="20"/>
</TR>
</TABLE>
</P>
<DIV ID="ROOT">
<xsl:apply-templates/>
</DIV>
<P>
Legend :<BR/>
<TABLE>
<TR>
<TD> <IMG src="c.gif"/> </TD>
<TD> Component </TD>
<TD> <IMG src="i.gif"/> </TD>
<TD> Implemented </TD>
<TD> <IMG src="sc.gif"/> </TD>
<TD> Complete </TD>
<TR>
</TR>
<TD> <IMG src="f.gif"/> </TD>
<TD> Function </TD>
<TD> <IMG src="u.gif"/> </TD>
<TD> Unimplemented </TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>
</P>
</BODY>
</HTML>
</xsl:template>
<!-- component -->
<xsl:template match="/components">
<xsl:apply-templates select="component">
<xsl:sort select="@name"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="components/component[@implemented_total or @unimplemented_total]">
<DIV>
<xsl:call-template name="ELEMENT">
<xsl:with-param name="class">c</xsl:with-param>
</xsl:call-template>
<xsl:apply-templates>
<xsl:with-param name="base"><xsl:value-of select="@base"/></xsl:with-param>
</xsl:apply-templates>
</DIV>
</xsl:template>
<!-- function -->
<xsl:template match="functions">
<xsl:param name="base"/>
<xsl:apply-templates select="f">
<xsl:sort select="@n"/>
<xsl:with-param name="base"><xsl:value-of select="$base"/></xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="functions/f">
<xsl:param name="base"/>
<DIV>
<xsl:call-template name="ELEMENT">
<xsl:with-param name="class">f</xsl:with-param>
<xsl:with-param name="base"><xsl:value-of select="$base"/></xsl:with-param>
</xsl:call-template>
<xsl:apply-templates/>
</DIV>
</xsl:template>
<!-- support templates -->
<xsl:template name="ELEMENT">
<xsl:param name="class"/>
<xsl:param name="base"/>
<xsl:param name="image"/>
<xsl:attribute name="class">
<xsl:value-of select="$class"/>
<xsl:text>_</xsl:text>
</xsl:attribute>
<xsl:call-template name="toggle"/>
<xsl:choose>
<xsl:when test="local-name() != 'component' and @i = 'true'">
<img src="i.gif" class="i"/>
</xsl:when>
<xsl:when test="local-name() != 'component' and @i = 'false'">
<img src="u.gif" class="u"/>
</xsl:when>
<xsl:when test="local-name() = 'component' and @complete >= 100">
<img src="sc.gif"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@i"/><img src="tb.gif" with="12" height="12"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$image">
<img src="{$image}.gif" class="t"/>
</xsl:when>
<xsl:otherwise>
<img src="{$class}.gif" class="t"/>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="name"/>
<xsl:call-template name="n"/>
<xsl:call-template name="file">
<xsl:with-param name="base"><xsl:value-of select="$base"/></xsl:with-param>
</xsl:call-template>
<xsl:call-template name="status"/>
</xsl:template>
<xsl:template name="status">
<xsl:if test="@complete and @complete != 0">
<SPAN class="st">
<img src="sc.gif"/>
<xsl:text>: </xsl:text>
<xsl:value-of select="@complete"/>
<xsl:text>%</xsl:text>
</SPAN>
</xsl:if>
<xsl:if test="@implemented_total">
<SPAN class="st">
<img src="i.gif"/>: <xsl:value-of select="@implemented_total"/>
</SPAN>
</xsl:if>
<xsl:if test="@unimplemented_total">
<SPAN class="st">
<img src="u.gif"/>: <xsl:value-of select="@unimplemented_total"/>
</SPAN>
</xsl:if>
</xsl:template>
<xsl:template name="toggle">
<xsl:choose>
<xsl:when test="local-name() = 'component'">
<IMG src="tp.gif" class="t"/>
</xsl:when>
<xsl:otherwise>
<IMG src="tb.gif"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="name">
<xsl:if test="@name">
<SPAN class="l"><xsl:value-of select="@name"/></SPAN>
</xsl:if>
</xsl:template>
<xsl:template name="n">
<xsl:if test="@n">
<SPAN class="l"><xsl:value-of select="@n"/></SPAN>
</xsl:if>
</xsl:template>
<xsl:template name="file">
<xsl:param name="base"/>
<xsl:if test="@f">
<SPAN class="h"><xsl:value-of select="$base"/><xsl:value-of select="@f"/></SPAN>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="publishPath" value="c:\iso" /> <!-- c:\iso or ftp://ftp.server.com/iso -->
<add key="smtpServer" value="localhost" />
<add key="errorEmail" value="mailbox@somewhere-on-the-net" />
<add key="makeParameters" value="" />
<add key="fastDisk" value="" />
</appSettings>
</configuration>

View File

@@ -0,0 +1,14 @@
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("ReactOS Sin Custom Revision Action")]
[assembly: AssemblyDescription("ReactOS Sin Custom Revision Action")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ReactOS Project")]
[assembly: AssemblyProduct("React Operating System")]
[assembly: AssemblyCopyright("Copyright 2005 ReactOS Project")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]

View File

@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<project name="ReactOS.CustomRevisionAction" default="build">
<property name="output.dir" value="bin" />
<target name="build" description="Build component">
<mkdir dir="${output.dir}" />
<csc target="exe"
output="${output.dir}\ReactOS.CustomRevisionAction.exe"
optimize="true"
debug="true"
doc="${output.dir}\ReactOS.CustomRevisionAction.xml"
warninglevel="0">
<sources>
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,340 @@
using System;
using System.IO;
using System.Diagnostics;
using System.Configuration;
using System.Web.Mail;
namespace ReactOS.CustomRevisionAction
{
public class MainClass
{
/// <summary>
/// Path to store published binaries at.
/// </summary>
private static string publishPath;
/// <summary>
/// Whether or not to publish ISOs to a remote destination via FTP.
/// </summary>
private static bool PublishToRemoteFtpLocation
{
get
{
return publishPath.StartsWith("ftp://");
}
}
/// <summary>
/// Run the application.
/// </summary>
/// <param name="script">Script to run.</param>
/// <param name="args">Arguments to pass to script.</param>
/// <param name="workingDirectory">Working directory.</param>
/// <param name="standardOutput">Receives standard output.</param>
/// <param name="standardError">Receives standard error.</param>
/// <returns>
/// Exit code.
/// </returns>
private static int RunScript(string script,
string args,
string workingDirectory,
out string standardOutput,
out string standardError)
{
ProcessStartInfo scriptProcessStartInfo = new ProcessStartInfo(script,
args);
scriptProcessStartInfo.CreateNoWindow = true;
/*
* All standard streams must be redirected.
* Otherwise DuplicateHandle() will fail.
*/
scriptProcessStartInfo.RedirectStandardInput = true;
scriptProcessStartInfo.RedirectStandardError = true;
scriptProcessStartInfo.RedirectStandardOutput = true;
scriptProcessStartInfo.UseShellExecute = false;
scriptProcessStartInfo.WorkingDirectory = workingDirectory;
RedirectableProcess redirectableProcess = new RedirectableProcess(scriptProcessStartInfo);
standardOutput = redirectableProcess.ProcessOutput;
standardError = redirectableProcess.ProcessError;
return redirectableProcess.ExitCode;
}
/// <summary>
/// Retrieve value of configuration from configuration file.
/// </summary>
/// <param name="name">Name of configuration option.</param>
/// <param name="defaultValue">
/// Default value to be returned if the option does not exist.
/// </param>
/// <returns>
/// Value of configuration option or null if the option does not
/// exist and no default value is provided.
/// </returns>
private static string GetConfigurationOption(string name,
string defaultValue)
{
if (ConfigurationSettings.AppSettings[name] != null)
return ConfigurationSettings.AppSettings[name];
else
return defaultValue;
}
/// <summary>
/// Send an email.
/// </summary>
/// <param name="subject">Subject of the email.</param>
/// <param name="body">Content of the email.</param>
private static void SendErrorMail(string subject, string body)
{
try
{
string smtpServer = GetConfigurationOption("smtpServer", "localhost");
string toEmail = GetConfigurationOption("errorEmail", null);
if (toEmail == null)
return;
string fromEmail = GetConfigurationOption("fromEmail", null);
if (fromEmail == null)
fromEmail = toEmail;
MailMessage mm = new MailMessage();
mm.Priority = MailPriority.Normal;
mm.From = toEmail;
mm.To = toEmail;
mm.Subject = subject;
mm.Body += body;
mm.Body += "<br>";
mm.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer = smtpServer;
SmtpMail.Send(mm);
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
}
/// <summary>
/// Fail with an error message.
/// </summary>
/// <param name="revision">Repository revision.</param>
/// <param name="text">Error message.</param>
private static void Fail(int revision,
string text)
{
Console.WriteLine(text);
Console.Error.WriteLine(text);
SendErrorMail(String.Format("[{0}] ReactOS Publish Error", revision), text);
}
/// <summary>
/// Fail with an error message.
/// </summary>
/// <param name="text">Error message.</param>
private static void Fail(string text)
{
Console.WriteLine(text);
Console.Error.WriteLine(text);
SendErrorMail("ReactOS Publish Error", text);
}
/// <summary>
/// Generate filename of distribution.
/// </summary>
/// <param name="branch">Branch.</param>
/// <param name="revision">Revision.</param>
private static string GetDistributionFilename(string branch,
int revision)
{
return String.Format("ReactOS-{0}-r{1}.iso",
branch,
revision);
}
private static void SplitRemotePublishPath(string publishPath,
out string server,
out string directory)
{
string searchString = "://";
int index = publishPath.IndexOf(searchString);
if (index == -1)
throw new InvalidOperationException();
int endOfProtocolIndex = index + searchString.Length;
string withoutProtocol = publishPath.Remove(0, endOfProtocolIndex);
index = withoutProtocol.IndexOf("/");
if (index == -1)
{
server = withoutProtocol;
directory = "";
}
else
{
server = withoutProtocol.Substring(0, index);
directory = withoutProtocol.Remove(0, index + 1);
}
}
/// <summary>
/// Copy ISO to the (remote) destination.
/// </summary>
/// <param name="sourceFilename">Name of source ISO file to copy.</param>
/// <param name="branch">Branch.</param>
/// <param name="revision">Revision.</param>
/// <remarks>
/// Structure is ftp://ftp.server.com/whereever/<branch>/ReactOS-<branch>-r<revision>.iso.
/// </remarks>
private static void CopyISOToRemoteFtpDestination(string sourceFilename,
string branch,
int revision)
{
string distributionFilename = GetDistributionFilename(branch,
revision);
string destinationFilename = Path.Combine(Path.GetDirectoryName(sourceFilename),
distributionFilename);
File.Move(sourceFilename, destinationFilename);
string server;
string directory;
SplitRemotePublishPath(publishPath, out server, out directory);
FtpClient ftpClient = new FtpClient(server, "anonymous", "sin@svn.reactos.com");
ftpClient.Login();
if (directory != "")
ftpClient.ChangeDir(directory);
/* Create destination directory if it does not already exist */
if (!ftpClient.DirectoryExists(branch))
ftpClient.MakeDir(branch);
ftpClient.ChangeDir(branch);
ftpClient.Upload(destinationFilename);
ftpClient.Close();
}
/// <summary>
/// Copy ISO to the (local) destination.
/// </summary>
/// <param name="sourceFilename">Name of source ISO file to copy.</param>
/// <param name="branch">Branch.</param>
/// <param name="revision">Revision.</param>
/// <remarks>
/// Structure is <branch>\ReactOS-<branch>-r<revision>.iso.
/// </remarks>
private static void CopyISOToLocalDestination(string sourceFilename,
string branch,
int revision)
{
string distributionFilename = GetDistributionFilename(branch,
revision);
string destinationDirectory = Path.Combine(publishPath,
branch);
string destinationFilename = Path.Combine(destinationDirectory,
distributionFilename);
if (!Directory.Exists(destinationDirectory))
Directory.CreateDirectory(destinationDirectory);
File.Copy(sourceFilename,
destinationFilename);
}
/// <summary>
/// Copy ISO to the destination.
/// </summary>
/// <param name="sourceFilename">Name of source ISO file to copy.</param>
/// <param name="branch">Branch.</param>
/// <param name="revision">Revision.</param>
/// <remarks>
/// Structure is <branch>\ReactOS-<branch>-r<revision>.iso.
/// </remarks>
private static void CopyISOToDestination(string sourceFilename,
string branch,
int revision)
{
if (PublishToRemoteFtpLocation)
CopyISOToRemoteFtpDestination(sourceFilename, branch, revision);
else
CopyISOToLocalDestination(sourceFilename, branch, revision);
}
/// <summary>
/// Publish a revision of ReactOS.
/// </summary>
/// <param name="text">Error message.</param>
private static int Publish(string branch,
int revision,
string workingDirectory)
{
string make = "mingw32-make";
string makeParameters = GetConfigurationOption("makeParameters", "");
string reactosDirectory = Path.Combine(workingDirectory,
"reactos");
Console.WriteLine(String.Format("ReactOS directory is {0}",
reactosDirectory));
string standardOutput;
string standardError;
int exitCode = RunScript(make,
makeParameters + " bootcd",
reactosDirectory,
out standardOutput,
out standardError);
if (exitCode != 0)
{
Fail(revision,
String.Format("make bootcd failed: (error: {0}) {1}",
standardError,
standardOutput));
return exitCode;
}
string sourceFilename = Path.Combine(reactosDirectory,
"ReactOS.iso");
if (File.Exists(sourceFilename))
CopyISOToDestination(sourceFilename,
branch,
revision);
else
{
Fail(revision,
"make bootcd produced no ReactOS.iso");
return exitCode;
}
return exitCode;
}
/// <summary>
/// Program entry point.
/// </summary>
/// <param name="args">Arguments from command line.</param>
/// <remarks>
/// If exit code is 0, then the commit was processed successfully.
/// If exit code is 1, then the commit was not processed successfully.
/// </remarks>
public static void Main(string[] args)
{
try
{
System.Environment.ExitCode = 1;
publishPath = ConfigurationSettings.AppSettings["publishPath"];
if (publishPath == null)
{
Fail("PublishPath option not set.");
return;
}
if (args.Length < 3)
{
Fail("Usage: ReactOS.CustomRevisionAction action branch revision");
return;
}
string action = args[0]; /* bootcd */
string branch = args[1];
int revision = Int32.Parse(args[2]);
System.Environment.ExitCode = Publish(branch,
revision,
System.Environment.CurrentDirectory);
}
catch (Exception ex)
{
Fail(String.Format("Exception: {0}", ex));
System.Environment.ExitCode = 1;
}
}
}
}

View File

@@ -0,0 +1,145 @@
/*
* When using the ProcessStartInfo.RedirectStandardXxx properties there is a chance of
* the parent and child process blocking due to a race condition. This class handles the
* problem.
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessstartinfoclassredirectstandardoutputtopic.asp
*/
using System;
using System.IO;
using System.Threading;
using System.Diagnostics;
namespace ReactOS.CustomRevisionAction
{
/// <summary>
/// Process that redirects standard output and standard error streams.
/// </summary>
public class RedirectableProcess
{
/// <summary>
/// Process.
/// </summary>
private Process process;
/// <summary>
/// Redirected standard error stream.
/// </summary>
private string processError;
/// <summary>
/// Redirected standard output stream.
/// </summary>
private string processOutput;
/// <summary>
/// Exit code.
/// </summary>
private int exitCode;
/// <summary>
/// Redirected standard error stream.
/// </summary>
public string ProcessError
{
get
{
return processError;
}
}
/// <summary>
/// Redirected standard output stream.
/// </summary>
public string ProcessOutput
{
get
{
return processOutput;
}
}
/// <summary>
/// Exit code.
/// </summary>
public int ExitCode
{
get
{
return exitCode;
}
}
/// <summary>
/// Run an excutable and redirect standard error and/or standard output safely.
/// </summary>
public RedirectableProcess(ProcessStartInfo processStartInfo)
{
Run(processStartInfo, null);
}
/// <summary>
/// Run an excutable and redirect standard error and/or standard output safely.
/// </summary>
public RedirectableProcess(ProcessStartInfo processStartInfo, string input)
{
Run(processStartInfo, input);
}
private void Run(ProcessStartInfo processStartInfo, string input)
{
process = new Process();
process.StartInfo = processStartInfo;
process.Start();
if (processStartInfo.RedirectStandardInput && input != null)
{
process.StandardInput.AutoFlush = true;
process.StandardInput.WriteLine(input);
}
Thread readStandardError = null;
if (processStartInfo.RedirectStandardError)
{
readStandardError = new Thread(new ThreadStart(ReadStandardError));
readStandardError.Start();
}
Thread readStandardOutput = null;
if (processStartInfo.RedirectStandardOutput)
{
readStandardOutput = new Thread(new ThreadStart(ReadStandardOutput));
readStandardOutput.Start();
}
if (processStartInfo.RedirectStandardError)
{
readStandardError.Join();
}
if (processStartInfo.RedirectStandardOutput)
{
readStandardOutput.Join();
}
process.WaitForExit();
exitCode = process.ExitCode;
process = null;
}
/// <summary>
/// Read standard error thread entry-point.
/// </summary>
private void ReadStandardError()
{
if (process != null)
{
processError = process.StandardError.ReadToEnd();
}
}
/// <summary>
/// Read standard output thread entry-point.
/// </summary>
private void ReadStandardOutput()
{
if (process != null)
{
processOutput = process.StandardOutput.ReadToEnd();
}
}
}
}

View File

@@ -0,0 +1,8 @@
<?php
/* Rename to config.php */
define(ISO_BASE_URL, "http://www.server.com/iso/");
define(ISO_PATH, "C:\\iso\\");
?>

View File

@@ -0,0 +1,230 @@
<?php
include ('config.php');
function dm_usort_cmp ($a, $b) {
if ($a == $b) return 0;
return ($a > $b) ? -1 : 1;
}
function dm_usort_cmp_desc ($a, $b) {
if ($a == $b) return 0;
return ($a > $b) ? 1 : -1;
}
function printHeader()
{
?>
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>ReactOS Revison ISOs</title>
<meta name="generator" content="Editpad">
<meta name="keywords" content="OS, ReactOS, operating system">
<meta name="author" content="ReactOS Project (ros-dev@reactos.com)">
<style>
.box
{
padding: 0px;
background-color: #88aadd;
border-left: 1px solid #f0f0f0;
border-right: 1px solid #000000;
border-top: 1px solid #f0f0f0;
border-bottom: 1px solid #000000;
}
</style>
</head>
<body bgcolor="#88aadd">
<form method="post" action="">
<?php
}
function printMenu($revision)
{
?>
<table border="0" class="box" cellpadding="5">
<tr>
<td height="2px">
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<b>Branch:</b>
</td>
<td>
<select name="branch" tabindex="1">
<?php
$d = dir(ISO_PATH);
$i = 0;
$dirlist = array();
while (false !== ($entry = $d->read())) {
if ((strcasecmp($entry, ".") != 0) && (strcasecmp($entry, "..") != 0) && is_dir(ISO_PATH . "\\" . $entry) == "dir") {
$dirlist[$i++] = $entry;
}
}
$d->close();
if (is_array($dirlist)) {
usort($dirlist, "dm_usort_cmp");
reset($dirlist);
while (list($key, $val) = each($dirlist)) {
$branch = $val;
if ($branch == $_POST["branch"] || (!isset($_POST["branch"]) && $branch == "trunk"))
$selected = " selected";
else
$selected = "";
echo "<option$selected>$branch</option>";
}
}
?>
</select>
</td>
<td>
&nbsp;
</td>
<td>
<b>Revision:</b>
</td>
<td>
<?php
echo "<input type=\"text\" name=\"revision\" size=\"10\" maxlength=\"10\" tabindex=\"2\" value=\"" . $revision . "\"></input>";
?>
</td>
<td>
&nbsp;
</td>
<td>
<input type="submit" name="getiso" value="Download" tabindex="3" style="border: 1px solid #000000"></input>
</td>
</tr>
<tr>
<td colspan="7">
<hr size="2" width="100%" />
</td>
</tr>
<tr>
<td colspan="4">
<input type="submit" name="getnextiso" value="Next ISO" tabindex="4" style="border: 1px solid #000000"></input>
</td>
<td colspan="3" align="right">
<input type="submit" name="getlatestiso" value="Latest ISO" tabindex="5" style="border: 1px solid #000000"></input>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="2px">
</td>
</tr>
</table>
<?php
}
function printFooter()
{
?>
</form>
<script>
var revision = document.getElementById('revision');
if (revision) revision.focus();
</script>
</body>
</html>
<?php
}
function locateRevisionISO($branch, $revision, $latest)
{
$revision = intval($revision);
$path = ISO_PATH . "\\" . $branch;
$d = dir($path);
$i = 0;
$filelist = array();
while (false !== ($entry = $d->read())) {
if (is_dir($path . "\\" . $entry) != "dir")
$filelist[$i++] = $entry;
}
$d->close();
if (is_array($filelist)) {
$sortFunction = $latest ? "dm_usort_cmp" : "dm_usort_cmp_desc";
usort($filelist, $sortFunction);
reset($filelist);
while (list($key, $filename) = each($filelist)) {
if (ereg('ReactOS-' . $branch . '-r([0-9]*).iso', $filename, $regs))
{
$thisRevision = intval($regs[1]);
if (($latest) && ($thisRevision < $revision))
return $regs[1];
else if ($thisRevision > $revision)
return $regs[1];
$lastRevision = $thisRevision;
}
}
}
return "";
}
function getNextRevisionISO($branch, $revision)
{
return locateRevisionISO($branch, $revision, false);
}
function getLatestRevisionISO($branch)
{
return locateRevisionISO($branch, 999999, true);
}
function main()
{
$branch = $_POST["branch"];
$revision = $_POST["revision"];
$filename = "ReactOS-" . $branch . "-r" . $revision . ".iso";
if (file_exists(ISO_PATH . $branch . "\\" . $filename))
{
$location = ISO_BASE_URL . $branch . "/" . $filename;
header("Location: $location");
return;
}
else
{
printHeader();
printMenu($_POST["revision"]);
echo "<br><b>No ISO exist for branch '" . $branch . "' and revision " . $revision . ".</b><br><br>";
printFooter();
}
}
if (!empty($_POST["getiso"]) && !empty($_POST["branch"]) && !empty($_POST["revision"]) && is_numeric($_POST["revision"]))
main();
else if (!empty($_POST["getnextiso"]) && !empty($_POST["branch"]) && !empty($_POST["revision"]) && is_numeric($_POST["revision"]))
{
printHeader();
printMenu(getNextRevisionISO($_POST["branch"], $_POST["revision"]));
printFooter();
}
else if (!empty($_POST["getlatestiso"]) && !empty($_POST["branch"]))
{
printHeader();
printMenu(getLatestRevisionISO($_POST["branch"]));
printFooter();
}
else
{
printHeader();
printMenu($_POST["revision"]);
printFooter();
}
?>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="smtpServer" value="localhost" />
<add key="errorEmail" value="mailbox@somewhere-on-the-net" />
<add key="makeParameters" value="" />
<add key="fastDisk" value="" />
</appSettings>
</configuration>

View File

@@ -0,0 +1,14 @@
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("ReactOS Sin Verifier")]
[assembly: AssemblyDescription("ReactOS Sin Verifier")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ReactOS Project")]
[assembly: AssemblyProduct("React Operating System")]
[assembly: AssemblyCopyright("Copyright 2005 ReactOS Project")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]

View File

@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<project name="ReactOS.Verify" default="build">
<property name="output.dir" value="bin" />
<target name="build" description="Build component">
<mkdir dir="${output.dir}" />
<csc target="exe"
output="${output.dir}\ReactOS.Verify.exe"
optimize="true"
debug="true"
doc="${output.dir}\ReactOS.Verify.xml"
warninglevel="0">
<sources>
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

279
ReactOS.Verify/Main.cs Normal file
View File

@@ -0,0 +1,279 @@
using System;
using System.IO;
using System.Diagnostics;
using System.Configuration;
using System.Web.Mail;
using System.Collections;
using System.Collections.Specialized;
namespace ReactOS.Verify
{
public class MainClass
{
/// <summary>
/// Run the application.
/// </summary>
/// <param name="script">Script to run.</param>
/// <param name="args">Arguments to pass to script.</param>
/// <param name="workingDirectory">Working directory.</param>
/// <param name="standardOutput">Receives standard output.</param>
/// <param name="standardError">Receives standard error.</param>
/// <returns>
/// Exit code.
/// </returns>
private static int RunScript(string script,
string args,
string workingDirectory,
StringDictionary environmentVarables,
out string standardOutput,
out string standardError)
{
ProcessStartInfo scriptProcessStartInfo = new ProcessStartInfo(script,
args);
scriptProcessStartInfo.CreateNoWindow = true;
/*
* All standard streams must be redirected.
* Otherwise DuplicateHandle() will fail.
*/
scriptProcessStartInfo.RedirectStandardInput = true;
scriptProcessStartInfo.RedirectStandardError = true;
scriptProcessStartInfo.RedirectStandardOutput = true;
scriptProcessStartInfo.UseShellExecute = false;
scriptProcessStartInfo.WorkingDirectory = workingDirectory;
if (environmentVarables != null)
{
foreach (DictionaryEntry de in environmentVarables)
scriptProcessStartInfo.EnvironmentVariables.Add(de.Key as string, de.Value as string);
}
RedirectableProcess redirectableProcess = new RedirectableProcess(scriptProcessStartInfo);
standardOutput = redirectableProcess.ProcessOutput;
standardError = redirectableProcess.ProcessError;
return redirectableProcess.ExitCode;
}
/// <summary>
/// Retrieve value of configuration from configuration file.
/// </summary>
/// <param name="name">Name of configuration option.</param>
/// <param name="defaultValue">
/// Default value to be returned if the option does not exist.
/// </param>
/// <returns>
/// Value of configuration option or null if the option does not
/// exist and no default value is provided.
/// </returns>
private static string GetConfigurationOption(string name,
string defaultValue)
{
if (ConfigurationSettings.AppSettings[name] != null)
{
string s = ConfigurationSettings.AppSettings[name].Trim();
return s.Equals(String.Empty) ? defaultValue : s;
}
else
return defaultValue;
}
/// <summary>
/// Send an email.
/// </summary>
/// <param name="subject">Subject of the email.</param>
/// <param name="body">Content of the email.</param>
private static void SendErrorMail(string subject, string body)
{
try
{
string smtpServer = GetConfigurationOption("smtpServer", "localhost");
string email = GetConfigurationOption("errorEmail", null);
if (email == null)
return;
MailMessage mm = new MailMessage();
mm.Priority = MailPriority.Normal;
mm.From = email;
mm.To = email;
mm.Subject = subject;
mm.Body += body;
mm.Body += "<br>";
mm.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer = smtpServer;
SmtpMail.Send(mm);
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
}
/// <summary>
/// Fail with an error message.
/// </summary>
/// <param name="text">Error message.</param>
private static void Fail(string text)
{
Console.WriteLine(text);
}
/// <summary>
/// Paths to fast disk for temporary files.
/// </summary>
private static string TemporaryFastDisk
{
get
{
string temporaryFastDisk = GetConfigurationOption("temporaryFastDisk", null);
if (temporaryFastDisk == null || temporaryFastDisk.Trim().Equals(String.Empty))
return null;
return temporaryFastDisk.Trim();
}
}
/// <summary>
/// Paths to fast disk for intermediate files.
/// </summary>
private static string IntermediateFastDisk
{
get
{
string intermediateFastDisk = GetConfigurationOption("intermediateFastDisk", null);
if (intermediateFastDisk == null || intermediateFastDisk.Trim().Equals(String.Empty))
return null;
return intermediateFastDisk.Trim();
}
}
/// <summary>
/// Paths to fast disk for output files.
/// </summary>
private static string OutputFastDisk
{
get
{
string outputFastDisk = GetConfigurationOption("outputFastDisk", null);
if (outputFastDisk == null || outputFastDisk.Trim().Equals(String.Empty))
return null;
return outputFastDisk.Trim();
}
}
/// <summary>
/// Return collection of environment variables.
/// </summary>
/// <returns>Collection of environment variables or null if there is none.</returns>
private static StringDictionary GetEnvironmentVarables()
{
StringDictionary environmentVarables = new StringDictionary();
if (TemporaryFastDisk != null)
environmentVarables.Add("ROS_TEMPORARY", TemporaryFastDisk);
if (IntermediateFastDisk != null)
environmentVarables.Add("ROS_INTERMEDIATE", IntermediateFastDisk);
if (OutputFastDisk != null)
environmentVarables.Add("ROS_OUTPUT", OutputFastDisk);
return environmentVarables;
}
/// <summary>
/// Run make.
/// </summary>
/// <param name="arguments">Arguments.</param>
/// <param name="standardOutput">Receives standard output.</param>
/// <param name="standardError">Receives standard error.</param>
/// <returns>Make exit code.</returns>
private static int RunMake(string arguments,
out string standardOutput,
out string standardError)
{
string make = "mingw32-make";
string makeParameters = GetConfigurationOption("makeParameters", "");
string reactosDirectory = Path.Combine(System.Environment.CurrentDirectory,
"reactos");
return RunScript(make,
makeParameters + " " + arguments,
reactosDirectory,
GetEnvironmentVarables(),
out standardOutput,
out standardError);
}
/// <summary>
/// Verify a revision of ReactOS by building it all.
/// </summary>
private static int VerifyFull()
{
string standardOutput;
string standardError;
int exitCode = RunMake("bootcd",
out standardOutput,
out standardError);
if (exitCode != 0)
{
Fail(String.Format("make bootcd failed: (error: {0}) {1}",
standardError,
standardOutput));
return exitCode;
}
string reactosDirectory = Path.Combine(System.Environment.CurrentDirectory,
"reactos");
string isoFilename = Path.Combine(reactosDirectory,
"ReactOS.iso");
if (!File.Exists(isoFilename))
Fail("make bootcd produced no ReactOS.iso");
return exitCode;
}
/// <summary>
/// Verify a revision of ReactOS by building parts.
/// </summary>
/// <param name="components">Comma separated list of components to build.</param>
private static int VerifyPartial(string components)
{
string standardOutput;
string standardError;
string componentParameters = "\"" + components.Replace(",", "\" \"") + "\"";
int exitCode = RunMake(componentParameters,
out standardOutput,
out standardError);
if (exitCode != 0)
Fail(String.Format("make failed for targets {0}: (error: {1}) {2}",
componentParameters,
standardError,
standardOutput));
return exitCode;
}
/// <summary>
/// Verify a revision of ReactOS.
/// </summary>
/// <param name="args">Arguments from command line.</param>
private static int Verify(string[] args)
{
if (args.Length > 0)
return VerifyPartial(args[0]);
else
return VerifyFull();
}
/// <summary>
/// Program entry point.
/// </summary>
/// <param name="args">Arguments from command line.</param>
/// <remarks>
/// If exit code is 0, then the commit was processed successfully.
/// If exit code is 1, then the commit was not processed successfully.
/// </remarks>
public static void Main(string[] args)
{
try
{
System.Environment.ExitCode = Verify(args);
}
catch (Exception ex)
{
string text = String.Format("Exception: {0}", ex);
SendErrorMail("ReactOS Verify Error", text);
System.Environment.ExitCode = 1;
}
}
}
}

View File

@@ -0,0 +1,145 @@
/*
* When using the ProcessStartInfo.RedirectStandardXxx properties there is a chance of
* the parent and child process blocking due to a race condition. This class handles the
* problem.
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessstartinfoclassredirectstandardoutputtopic.asp
*/
using System;
using System.IO;
using System.Threading;
using System.Diagnostics;
namespace ReactOS.Verify
{
/// <summary>
/// Process that redirects standard output and standard error streams.
/// </summary>
public class RedirectableProcess
{
/// <summary>
/// Process.
/// </summary>
private Process process;
/// <summary>
/// Redirected standard error stream.
/// </summary>
private string processError;
/// <summary>
/// Redirected standard output stream.
/// </summary>
private string processOutput;
/// <summary>
/// Exit code.
/// </summary>
private int exitCode;
/// <summary>
/// Redirected standard error stream.
/// </summary>
public string ProcessError
{
get
{
return processError;
}
}
/// <summary>
/// Redirected standard output stream.
/// </summary>
public string ProcessOutput
{
get
{
return processOutput;
}
}
/// <summary>
/// Exit code.
/// </summary>
public int ExitCode
{
get
{
return exitCode;
}
}
/// <summary>
/// Run an excutable and redirect standard error and/or standard output safely.
/// </summary>
public RedirectableProcess(ProcessStartInfo processStartInfo)
{
Run(processStartInfo, null);
}
/// <summary>
/// Run an excutable and redirect standard error and/or standard output safely.
/// </summary>
public RedirectableProcess(ProcessStartInfo processStartInfo, string input)
{
Run(processStartInfo, input);
}
private void Run(ProcessStartInfo processStartInfo, string input)
{
process = new Process();
process.StartInfo = processStartInfo;
process.Start();
if (processStartInfo.RedirectStandardInput && input != null)
{
process.StandardInput.AutoFlush = true;
process.StandardInput.WriteLine(input);
}
Thread readStandardError = null;
if (processStartInfo.RedirectStandardError)
{
readStandardError = new Thread(new ThreadStart(ReadStandardError));
readStandardError.Start();
}
Thread readStandardOutput = null;
if (processStartInfo.RedirectStandardOutput)
{
readStandardOutput = new Thread(new ThreadStart(ReadStandardOutput));
readStandardOutput.Start();
}
if (processStartInfo.RedirectStandardError)
{
readStandardError.Join();
}
if (processStartInfo.RedirectStandardOutput)
{
readStandardOutput.Join();
}
process.WaitForExit();
exitCode = process.ExitCode;
process = null;
}
/// <summary>
/// Read standard error thread entry-point.
/// </summary>
private void ReadStandardError()
{
if (process != null)
{
processError = process.StandardError.ReadToEnd();
}
}
/// <summary>
/// Read standard output thread entry-point.
/// </summary>
private void ReadStandardOutput()
{
if (process != null)
{
processOutput = process.StandardOutput.ReadToEnd();
}
}
}
}

0
reactos/.gitignore vendored
View File

View File

@@ -1,206 +0,0 @@
# Doxyfile 1.3.5
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "ReactOS NTOSKRNL"
PROJECT_NUMBER =
OUTPUT_DIRECTORY = doxy-doc
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = YES
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = ..
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = NO
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = YES
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
HAVE_DOT = YES
WARN_IF_UNDOCUMENTED = NO
WARN_IF_DOC_ERROR = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = .
FILE_PATTERNS = *.c \
*.h
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = YES
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = YES
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
VERBATIM_HEADERS = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = YES
TREEVIEW_WIDTH = 200
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = YES
RTF_HYPERLINKS = YES
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = NO
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH = ../include
INCLUDE_FILE_PATTERNS = *.h
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = NO
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 0
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = YES

View File

@@ -1,29 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
//
// Alex's Big Ol' List of FIXMEs, bugs and regressions
// If you see something here, Alex *KNOWS ABOUT IT*.
// Do NOT bug him about it.
// Do NOT ask if he knows about it.
// Do NOT complain about it.
// Do NOT ask when it will be fixed.
// Failure to respect this will *ACHIEVE NOTHING*.
//
// Io:
// - Add tracing to iofunc.c, file.c and device.c
// - Add Access Checks in IopParseDevice.
// - Add validation checks in IoCreateFile.
// - Add probe/alignment checks for Query/Set routines.
// - Verify ShareAccess APIs, XP added some new semantics.
// - Add support for some fast-paths when querying/setting data.
// - Add support for Fast Dispatch I/O.
//
// Ob:
// - Fix bug related to Deferred Loading (don't requeue active work item).
// - Add Directory Lock.
// - Use Object Type Mutex/Lock.
//
// Ex:
// - Use pushlocks for handle implementation.
//
///////////////////////////////////////////////////////////////////////////////

View File

@@ -1,123 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/cacheman.c
* PURPOSE: Cache manager
*
* PROGRAMMERS: David Welch (welch@cwcom.net)
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
CcInit(VOID)
{
CcInitView();
}
/*
* @unimplemented
*/
LARGE_INTEGER
STDCALL
CcGetFlushedValidData (
IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
IN BOOLEAN BcbListHeld
)
{
LARGE_INTEGER i;
UNIMPLEMENTED;
i.QuadPart = 0;
return i;
}
/*
* @unimplemented
*/
PVOID
STDCALL
CcRemapBcb (
IN PVOID Bcb
)
{
UNIMPLEMENTED;
return 0;
}
/*
* @unimplemented
*/
VOID
STDCALL
CcScheduleReadAhead (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length
)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID
STDCALL
CcSetAdditionalCacheAttributes (
IN PFILE_OBJECT FileObject,
IN BOOLEAN DisableReadAhead,
IN BOOLEAN DisableWriteBehind
)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID
STDCALL
CcSetBcbOwnerPointer (
IN PVOID Bcb,
IN PVOID Owner
)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID
STDCALL
CcSetDirtyPageThreshold (
IN PFILE_OBJECT FileObject,
IN ULONG DirtyPageThreshold
)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID
STDCALL
CcSetReadAheadGranularity (
IN PFILE_OBJECT FileObject,
IN ULONG Granularity
)
{
UNIMPLEMENTED;
}

View File

@@ -1,727 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/copy.c
* PURPOSE: Implements cache managers copy interface
*
* PROGRAMMERS:
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *******************************************************************/
static PFN_TYPE CcZeroPage = 0;
#define MAX_ZERO_LENGTH (256 * 1024)
#define MAX_RW_LENGTH (256 * 1024)
#if defined(__GNUC__)
/* void * alloca(size_t size); */
#elif defined(_MSC_VER)
void* _alloca(size_t size);
#else
#error Unknown compiler for alloca intrinsic stack allocation "function"
#endif
ULONG CcFastMdlReadWait;
ULONG CcFastReadNotPossible;
ULONG CcFastReadWait;
ULONG CcFastReadNoWait;
ULONG CcFastReadResourceMiss;
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
CcInitCacheZeroPage(VOID)
{
NTSTATUS Status;
Status = MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE, &CcZeroPage);
if (!NT_SUCCESS(Status))
{
DbgPrint("Can't allocate CcZeroPage.\n");
KEBUGCHECKCC;
}
Status = MiZeroPage(CcZeroPage);
if (!NT_SUCCESS(Status))
{
DbgPrint("Can't zero out CcZeroPage.\n");
KEBUGCHECKCC;
}
}
NTSTATUS
NTAPI
ReadCacheSegmentChain(PBCB Bcb, ULONG ReadOffset, ULONG Length,
PVOID Buffer)
{
PCACHE_SEGMENT head;
PCACHE_SEGMENT current;
PCACHE_SEGMENT previous;
IO_STATUS_BLOCK Iosb;
LARGE_INTEGER SegOffset;
NTSTATUS Status;
ULONG TempLength;
KEVENT Event;
PMDL Mdl;
Mdl = alloca(MmSizeOfMdl(NULL, MAX_RW_LENGTH));
Status = CcRosGetCacheSegmentChain(Bcb, ReadOffset, Length, &head);
if (!NT_SUCCESS(Status))
{
return(Status);
}
current = head;
while (current != NULL)
{
/*
* If the current segment is valid then copy it into the
* user buffer.
*/
if (current->Valid)
{
TempLength = min(Bcb->CacheSegmentSize, Length);
memcpy(Buffer, current->BaseAddress, TempLength);
Buffer = (PVOID)((ULONG_PTR)Buffer + TempLength);
Length = Length - TempLength;
previous = current;
current = current->NextInChain;
CcRosReleaseCacheSegment(Bcb, previous, TRUE, FALSE, FALSE);
}
/*
* Otherwise read in as much as we can.
*/
else
{
PCACHE_SEGMENT current2;
ULONG current_size;
ULONG i;
PPFN_TYPE MdlPages;
/*
* Count the maximum number of bytes we could read starting
* from the current segment.
*/
current2 = current;
current_size = 0;
while (current2 != NULL && !current2->Valid && current_size < MAX_RW_LENGTH)
{
current2 = current2->NextInChain;
current_size += Bcb->CacheSegmentSize;
}
/*
* Create an MDL which contains all their pages.
*/
MmInitializeMdl(Mdl, NULL, current_size);
Mdl->MdlFlags |= (MDL_PAGES_LOCKED | MDL_IO_PAGE_READ);
current2 = current;
current_size = 0;
MdlPages = (PPFN_TYPE)(Mdl + 1);
while (current2 != NULL && !current2->Valid && current_size < MAX_RW_LENGTH)
{
PVOID address = current2->BaseAddress;
for (i = 0; i < (Bcb->CacheSegmentSize / PAGE_SIZE); i++, address = RVA(address, PAGE_SIZE))
{
*MdlPages++ = MmGetPfnForProcess(NULL, address);
}
current2 = current2->NextInChain;
current_size += Bcb->CacheSegmentSize;
}
/*
* Read in the information.
*/
SegOffset.QuadPart = current->FileOffset;
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Status = IoPageRead(Bcb->FileObject,
Mdl,
&SegOffset,
&Event,
&Iosb);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = Iosb.Status;
}
if (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA)
{
MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
}
if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE)
{
while (current != NULL)
{
previous = current;
current = current->NextInChain;
CcRosReleaseCacheSegment(Bcb, previous, FALSE, FALSE, FALSE);
}
return(Status);
}
current_size = 0;
while (current != NULL && !current->Valid && current_size < MAX_RW_LENGTH)
{
previous = current;
current = current->NextInChain;
TempLength = min(Bcb->CacheSegmentSize, Length);
memcpy(Buffer, previous->BaseAddress, TempLength);
Buffer = (PVOID)((ULONG_PTR)Buffer + TempLength);
Length = Length - TempLength;
CcRosReleaseCacheSegment(Bcb, previous, TRUE, FALSE, FALSE);
current_size += Bcb->CacheSegmentSize;
}
}
}
return(STATUS_SUCCESS);
}
NTSTATUS
NTAPI
ReadCacheSegment(PCACHE_SEGMENT CacheSeg)
{
ULONG Size;
PMDL Mdl;
NTSTATUS Status;
LARGE_INTEGER SegOffset;
IO_STATUS_BLOCK IoStatus;
KEVENT Event;
SegOffset.QuadPart = CacheSeg->FileOffset;
Size = (ULONG)(CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset);
if (Size > CacheSeg->Bcb->CacheSegmentSize)
{
Size = CacheSeg->Bcb->CacheSegmentSize;
}
Mdl = alloca(MmSizeOfMdl(CacheSeg->BaseAddress, Size));
MmInitializeMdl(Mdl, CacheSeg->BaseAddress, Size);
MmBuildMdlForNonPagedPool(Mdl);
Mdl->MdlFlags |= MDL_IO_PAGE_READ;
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Status = IoPageRead(CacheSeg->Bcb->FileObject, Mdl, &SegOffset, & Event, &IoStatus);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = IoStatus.Status;
}
if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE)
{
DPRINT1("IoPageRead failed, Status %x\n", Status);
return Status;
}
if (CacheSeg->Bcb->CacheSegmentSize > Size)
{
memset ((char*)CacheSeg->BaseAddress + Size, 0,
CacheSeg->Bcb->CacheSegmentSize - Size);
}
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
WriteCacheSegment(PCACHE_SEGMENT CacheSeg)
{
ULONG Size;
PMDL Mdl;
NTSTATUS Status;
IO_STATUS_BLOCK IoStatus;
LARGE_INTEGER SegOffset;
KEVENT Event;
CacheSeg->Dirty = FALSE;
SegOffset.QuadPart = CacheSeg->FileOffset;
Size = (ULONG)(CacheSeg->Bcb->AllocationSize.QuadPart - CacheSeg->FileOffset);
if (Size > CacheSeg->Bcb->CacheSegmentSize)
{
Size = CacheSeg->Bcb->CacheSegmentSize;
}
Mdl = alloca(MmSizeOfMdl(CacheSeg->BaseAddress, Size));
MmInitializeMdl(Mdl, CacheSeg->BaseAddress, Size);
MmBuildMdlForNonPagedPool(Mdl);
Mdl->MdlFlags |= MDL_IO_PAGE_READ;
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Status = IoSynchronousPageWrite(CacheSeg->Bcb->FileObject, Mdl, &SegOffset, &Event, &IoStatus);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = IoStatus.Status;
}
if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE))
{
DPRINT1("IoPageWrite failed, Status %x\n", Status);
CacheSeg->Dirty = TRUE;
return(Status);
}
return(STATUS_SUCCESS);
}
/*
* @unimplemented
*/
BOOLEAN STDCALL
CcCanIWrite (
IN PFILE_OBJECT FileObject,
IN ULONG BytesToWrite,
IN BOOLEAN Wait,
IN BOOLEAN Retrying)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @implemented
*/
BOOLEAN STDCALL
CcCopyRead (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
OUT PVOID Buffer,
OUT PIO_STATUS_BLOCK IoStatus)
{
ULONG ReadOffset;
ULONG TempLength;
NTSTATUS Status = STATUS_SUCCESS;
PVOID BaseAddress;
PCACHE_SEGMENT CacheSeg;
BOOLEAN Valid;
ULONG ReadLength = 0;
PBCB Bcb;
KIRQL oldirql;
PLIST_ENTRY current_entry;
PCACHE_SEGMENT current;
DPRINT("CcCopyRead(FileObject 0x%p, FileOffset %I64x, "
"Length %d, Wait %d, Buffer 0x%p, IoStatus 0x%p)\n",
FileObject, FileOffset->QuadPart, Length, Wait,
Buffer, IoStatus);
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
ReadOffset = (ULONG)FileOffset->QuadPart;
DPRINT("AllocationSize %d, FileSize %d\n",
(ULONG)Bcb->AllocationSize.QuadPart,
(ULONG)Bcb->FileSize.QuadPart);
/*
* Check for the nowait case that all the cache segments that would
* cover this read are in memory.
*/
if (!Wait)
{
KeAcquireSpinLock(&Bcb->BcbLock, &oldirql);
current_entry = Bcb->BcbSegmentListHead.Flink;
while (current_entry != &Bcb->BcbSegmentListHead)
{
current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT,
BcbSegmentListEntry);
if (!current->Valid && current->FileOffset < ReadOffset + Length
&& current->FileOffset + Bcb->CacheSegmentSize > ReadOffset)
{
KeReleaseSpinLock(&Bcb->BcbLock, oldirql);
IoStatus->Status = STATUS_UNSUCCESSFUL;
IoStatus->Information = 0;
return FALSE;
}
current_entry = current_entry->Flink;
}
KeReleaseSpinLock(&Bcb->BcbLock, oldirql);
}
TempLength = ReadOffset % Bcb->CacheSegmentSize;
if (TempLength != 0)
{
TempLength = min (Length, Bcb->CacheSegmentSize - TempLength);
Status = CcRosRequestCacheSegment(Bcb,
ROUND_DOWN(ReadOffset,
Bcb->CacheSegmentSize),
&BaseAddress, &Valid, &CacheSeg);
if (!NT_SUCCESS(Status))
{
IoStatus->Information = 0;
IoStatus->Status = Status;
DPRINT("CcRosRequestCacheSegment faild, Status %x\n", Status);
return FALSE;
}
if (!Valid)
{
Status = ReadCacheSegment(CacheSeg);
if (!NT_SUCCESS(Status))
{
IoStatus->Information = 0;
IoStatus->Status = Status;
CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE);
return FALSE;
}
}
memcpy (Buffer, (char*)BaseAddress + ReadOffset % Bcb->CacheSegmentSize,
TempLength);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
ReadLength += TempLength;
Length -= TempLength;
ReadOffset += TempLength;
Buffer = (PVOID)((char*)Buffer + TempLength);
}
while (Length > 0)
{
TempLength = min(max(Bcb->CacheSegmentSize, MAX_RW_LENGTH), Length);
ReadCacheSegmentChain(Bcb, ReadOffset, TempLength, Buffer);
ReadLength += TempLength;
Length -= TempLength;
ReadOffset += TempLength;
Buffer = (PVOID)((ULONG_PTR)Buffer + TempLength);
}
IoStatus->Status = STATUS_SUCCESS;
IoStatus->Information = ReadLength;
DPRINT("CcCopyRead O.K.\n");
return TRUE;
}
/*
* @implemented
*/
BOOLEAN STDCALL
CcCopyWrite (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN PVOID Buffer)
{
NTSTATUS Status;
ULONG WriteOffset;
KIRQL oldirql;
PBCB Bcb;
PLIST_ENTRY current_entry;
PCACHE_SEGMENT CacheSeg;
ULONG TempLength;
PVOID BaseAddress;
BOOLEAN Valid;
DPRINT("CcCopyWrite(FileObject 0x%p, FileOffset %I64x, "
"Length %d, Wait %d, Buffer 0x%p)\n",
FileObject, FileOffset->QuadPart, Length, Wait, Buffer);
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
WriteOffset = (ULONG)FileOffset->QuadPart;
if (!Wait)
{
/* testing, if the requested datas are available */
KeAcquireSpinLock(&Bcb->BcbLock, &oldirql);
current_entry = Bcb->BcbSegmentListHead.Flink;
while (current_entry != &Bcb->BcbSegmentListHead)
{
CacheSeg = CONTAINING_RECORD(current_entry, CACHE_SEGMENT,
BcbSegmentListEntry);
if (!CacheSeg->Valid)
{
if ((WriteOffset >= CacheSeg->FileOffset &&
WriteOffset < CacheSeg->FileOffset + Bcb->CacheSegmentSize)
|| (WriteOffset + Length > CacheSeg->FileOffset &&
WriteOffset + Length <= CacheSeg->FileOffset +
Bcb->CacheSegmentSize))
{
KeReleaseSpinLock(&Bcb->BcbLock, oldirql);
/* datas not available */
return(FALSE);
}
}
current_entry = current_entry->Flink;
}
KeReleaseSpinLock(&Bcb->BcbLock, oldirql);
}
TempLength = WriteOffset % Bcb->CacheSegmentSize;
if (TempLength != 0)
{
ULONG ROffset;
ROffset = ROUND_DOWN(WriteOffset, Bcb->CacheSegmentSize);
TempLength = min (Length, Bcb->CacheSegmentSize - TempLength);
Status = CcRosRequestCacheSegment(Bcb, ROffset,
&BaseAddress, &Valid, &CacheSeg);
if (!NT_SUCCESS(Status))
{
return(FALSE);
}
if (!Valid)
{
if (!NT_SUCCESS(ReadCacheSegment(CacheSeg)))
{
return(FALSE);
}
}
memcpy ((char*)BaseAddress + WriteOffset % Bcb->CacheSegmentSize,
Buffer, TempLength);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, TRUE, FALSE);
Length -= TempLength;
WriteOffset += TempLength;
Buffer = (PVOID)((ULONG_PTR)Buffer + TempLength);
}
while (Length > 0)
{
TempLength = min (Bcb->CacheSegmentSize, Length);
Status = CcRosRequestCacheSegment(Bcb, WriteOffset,
&BaseAddress, &Valid, &CacheSeg);
if (!NT_SUCCESS(Status))
{
return(FALSE);
}
if (!Valid && TempLength < Bcb->CacheSegmentSize)
{
if (!NT_SUCCESS(ReadCacheSegment(CacheSeg)))
{
CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE);
return FALSE;
}
}
memcpy (BaseAddress, Buffer, TempLength);
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, TRUE, FALSE);
Length -= TempLength;
WriteOffset += TempLength;
Buffer = (PVOID)((ULONG_PTR)Buffer + TempLength);
}
return(TRUE);
}
/*
* @unimplemented
*/
VOID
STDCALL
CcDeferWrite (
IN PFILE_OBJECT FileObject,
IN PCC_POST_DEFERRED_WRITE PostRoutine,
IN PVOID Context1,
IN PVOID Context2,
IN ULONG BytesToWrite,
IN BOOLEAN Retrying
)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID
STDCALL
CcFastCopyRead (
IN PFILE_OBJECT FileObject,
IN ULONG FileOffset,
IN ULONG Length,
IN ULONG PageCount,
OUT PVOID Buffer,
OUT PIO_STATUS_BLOCK IoStatus
)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID
STDCALL
CcFastCopyWrite(
IN PFILE_OBJECT FileObject,
IN ULONG FileOffset,
IN ULONG Length,
IN PVOID Buffer)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
NTSTATUS
STDCALL
CcWaitForCurrentLazyWriterActivity (
VOID
)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
/*
* @implemented
*/
BOOLEAN STDCALL
CcZeroData (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER StartOffset,
IN PLARGE_INTEGER EndOffset,
IN BOOLEAN Wait)
{
NTSTATUS Status;
LARGE_INTEGER WriteOffset;
ULONG Length;
ULONG CurrentLength;
PMDL Mdl;
ULONG i;
IO_STATUS_BLOCK Iosb;
KEVENT Event;
DPRINT("CcZeroData(FileObject 0x%p, StartOffset %I64x, EndOffset %I64x, "
"Wait %d)\n", FileObject, StartOffset->QuadPart, EndOffset->QuadPart,
Wait);
Length = EndOffset->u.LowPart - StartOffset->u.LowPart;
WriteOffset.QuadPart = StartOffset->QuadPart;
if (FileObject->SectionObjectPointer->SharedCacheMap == NULL)
{
/* File is not cached */
Mdl = alloca(MmSizeOfMdl(NULL, MAX_ZERO_LENGTH));
while (Length > 0)
{
if (Length + WriteOffset.u.LowPart % PAGE_SIZE > MAX_ZERO_LENGTH)
{
CurrentLength = MAX_ZERO_LENGTH - WriteOffset.u.LowPart % PAGE_SIZE;
}
else
{
CurrentLength = Length;
}
MmInitializeMdl(Mdl, (PVOID)WriteOffset.u.LowPart, CurrentLength);
Mdl->MdlFlags |= (MDL_PAGES_LOCKED | MDL_IO_PAGE_READ);
for (i = 0; i < ((Mdl->Size - sizeof(MDL)) / sizeof(ULONG)); i++)
{
((PPFN_TYPE)(Mdl + 1))[i] = CcZeroPage;
}
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Status = IoSynchronousPageWrite(FileObject, Mdl, &WriteOffset, &Event, &Iosb);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = Iosb.Status;
}
MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
if (!NT_SUCCESS(Status))
{
return(FALSE);
}
WriteOffset.QuadPart += CurrentLength;
Length -= CurrentLength;
}
}
else
{
/* File is cached */
KIRQL oldirql;
PBCB Bcb;
PLIST_ENTRY current_entry;
PCACHE_SEGMENT CacheSeg, current, previous;
ULONG TempLength;
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
if (Wait)
{
/* testing, if the requested datas are available */
KeAcquireSpinLock(&Bcb->BcbLock, &oldirql);
current_entry = Bcb->BcbSegmentListHead.Flink;
while (current_entry != &Bcb->BcbSegmentListHead)
{
CacheSeg = CONTAINING_RECORD(current_entry, CACHE_SEGMENT,
BcbSegmentListEntry);
if (!CacheSeg->Valid)
{
if ((WriteOffset.u.LowPart >= CacheSeg->FileOffset &&
WriteOffset.u.LowPart < CacheSeg->FileOffset + Bcb->CacheSegmentSize)
|| (WriteOffset.u.LowPart + Length > CacheSeg->FileOffset &&
WriteOffset.u.LowPart + Length <=
CacheSeg->FileOffset + Bcb->CacheSegmentSize))
{
KeReleaseSpinLock(&Bcb->BcbLock, oldirql);
/* datas not available */
return(FALSE);
}
}
current_entry = current_entry->Flink;
}
KeReleaseSpinLock(&Bcb->BcbLock, oldirql);
}
while (Length > 0)
{
ULONG Offset;
Offset = WriteOffset.u.LowPart % Bcb->CacheSegmentSize;
if (Length + Offset > MAX_ZERO_LENGTH)
{
CurrentLength = MAX_ZERO_LENGTH - Offset;
}
else
{
CurrentLength = Length;
}
Status = CcRosGetCacheSegmentChain (Bcb, WriteOffset.u.LowPart - Offset,
Offset + CurrentLength, &CacheSeg);
if (!NT_SUCCESS(Status))
{
return FALSE;
}
current = CacheSeg;
while (current != NULL)
{
Offset = WriteOffset.u.LowPart % Bcb->CacheSegmentSize;
if (Offset != 0 ||
Offset + CurrentLength < Bcb->CacheSegmentSize)
{
if (!current->Valid)
{
/* read the segment */
Status = ReadCacheSegment(current);
if (!NT_SUCCESS(Status))
{
DPRINT1("ReadCacheSegment failed, status %x\n",
Status);
}
}
TempLength = min (CurrentLength, Bcb->CacheSegmentSize - Offset);
}
else
{
TempLength = Bcb->CacheSegmentSize;
}
memset ((PUCHAR)current->BaseAddress + Offset, 0, TempLength);
WriteOffset.QuadPart += TempLength;
CurrentLength -= TempLength;
Length -= TempLength;
current = current->NextInChain;
}
current = CacheSeg;
while (current != NULL)
{
previous = current;
current = current->NextInChain;
CcRosReleaseCacheSegment(Bcb, previous, TRUE, TRUE, FALSE);
}
}
}
return(TRUE);
}

View File

@@ -1,244 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/fs.c
* PURPOSE: Implements cache managers functions useful for File Systems
*
* PROGRAMMERS: Alex Ionescu
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#ifndef VACB_MAPPING_GRANULARITY
#define VACB_MAPPING_GRANULARITY (256 * 1024)
#endif
/* GLOBALS *****************************************************************/
extern FAST_MUTEX ViewLock;
extern ULONG DirtyPageCount;
NTSTATUS CcRosInternalFreeCacheSegment(PCACHE_SEGMENT CacheSeg);
/* FUNCTIONS *****************************************************************/
/*
* @unimplemented
*/
LARGE_INTEGER
STDCALL
CcGetDirtyPages (
IN PVOID LogHandle,
IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine,
IN PVOID Context1,
IN PVOID Context2
)
{
LARGE_INTEGER i;
UNIMPLEMENTED;
i.QuadPart = 0;
return i;
}
/*
* @implemented
*/
PFILE_OBJECT
STDCALL
CcGetFileObjectFromBcb (
IN PVOID Bcb
)
{
PINTERNAL_BCB iBcb = (PINTERNAL_BCB)Bcb;
return iBcb->CacheSegment->Bcb->FileObject;
}
/*
* @unimplemented
*/
LARGE_INTEGER
STDCALL
CcGetLsnForFileObject (
IN PFILE_OBJECT FileObject,
OUT PLARGE_INTEGER OldestLsn OPTIONAL
)
{
LARGE_INTEGER i;
UNIMPLEMENTED;
i.QuadPart = 0;
return i;
}
/*
* @unimplemented
*/
VOID
STDCALL
CcInitializeCacheMap (
IN PFILE_OBJECT FileObject,
IN PCC_FILE_SIZES FileSizes,
IN BOOLEAN PinAccess,
IN PCACHE_MANAGER_CALLBACKS CallBacks,
IN PVOID LazyWriterContext
)
{
CcRosInitializeFileCache(FileObject, VACB_MAPPING_GRANULARITY);
}
/*
* @unimplemented
*/
BOOLEAN
STDCALL
CcIsThereDirtyData (
IN PVPB Vpb
)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented
*/
BOOLEAN
STDCALL
CcPurgeCacheSection (
IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
IN PLARGE_INTEGER FileOffset OPTIONAL,
IN ULONG Length,
IN BOOLEAN UninitializeCacheMaps
)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @implemented
*/
VOID STDCALL
CcSetFileSizes (IN PFILE_OBJECT FileObject,
IN PCC_FILE_SIZES FileSizes)
{
KIRQL oldirql;
PBCB Bcb;
PLIST_ENTRY current_entry;
PCACHE_SEGMENT current;
LIST_ENTRY FreeListHead;
NTSTATUS Status;
DPRINT("CcSetFileSizes(FileObject 0x%p, FileSizes 0x%p)\n",
FileObject, FileSizes);
DPRINT("AllocationSize %d, FileSize %d, ValidDataLength %d\n",
(ULONG)FileSizes->AllocationSize.QuadPart,
(ULONG)FileSizes->FileSize.QuadPart,
(ULONG)FileSizes->ValidDataLength.QuadPart);
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
/*
* It is valid to call this function on file objects that weren't
* initialized for caching. In this case it's simple no-op.
*/
if (Bcb == NULL)
return;
if (FileSizes->AllocationSize.QuadPart < Bcb->AllocationSize.QuadPart)
{
InitializeListHead(&FreeListHead);
ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&ViewLock);
KeAcquireSpinLock(&Bcb->BcbLock, &oldirql);
current_entry = Bcb->BcbSegmentListHead.Flink;
while (current_entry != &Bcb->BcbSegmentListHead)
{
current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry);
current_entry = current_entry->Flink;
if (current->FileOffset > FileSizes->AllocationSize.QuadPart)
{
if (current->ReferenceCount == 0 || (current->ReferenceCount == 1 && current->Dirty))
{
RemoveEntryList(&current->BcbSegmentListEntry);
RemoveEntryList(&current->CacheSegmentListEntry);
RemoveEntryList(&current->CacheSegmentLRUListEntry);
if (current->Dirty)
{
RemoveEntryList(&current->DirtySegmentListEntry);
DirtyPageCount -= Bcb->CacheSegmentSize / PAGE_SIZE;
}
InsertHeadList(&FreeListHead, &current->BcbSegmentListEntry);
}
else
{
DPRINT1("Anyone has referenced a cache segment behind the new size.\n");
KEBUGCHECKCC;
}
}
}
Bcb->AllocationSize = FileSizes->AllocationSize;
Bcb->FileSize = FileSizes->FileSize;
KeReleaseSpinLock(&Bcb->BcbLock, oldirql);
ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&ViewLock);
current_entry = FreeListHead.Flink;
while(current_entry != &FreeListHead)
{
current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT, BcbSegmentListEntry);
current_entry = current_entry->Flink;
Status = CcRosInternalFreeCacheSegment(current);
if (!NT_SUCCESS(Status))
{
DPRINT1("CcRosInternalFreeCacheSegment failed, status = %x\n", Status);
KEBUGCHECK(0);
}
}
}
else
{
KeAcquireSpinLock(&Bcb->BcbLock, &oldirql);
Bcb->AllocationSize = FileSizes->AllocationSize;
Bcb->FileSize = FileSizes->FileSize;
KeReleaseSpinLock(&Bcb->BcbLock, oldirql);
}
}
/*
* @unimplemented
*/
VOID
STDCALL
CcSetLogHandleForFile (
IN PFILE_OBJECT FileObject,
IN PVOID LogHandle,
IN PFLUSH_TO_LSN FlushToLsnRoutine
)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
BOOLEAN
STDCALL
CcUninitializeCacheMap (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER TruncateSize OPTIONAL,
IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL
)
{
#if 0
UNIMPLEMENTED;
return FALSE;
#else
return CcRosReleaseFileCache(FileObject);
#endif
}

View File

@@ -1,175 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/fs.c
* PURPOSE: Implements MDL Cache Manager Functions
*
* PROGRAMMERS: Alex Ionescu
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
/*
* @implemented
*/
VOID
STDCALL
CcMdlRead(
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
OUT PMDL * MdlChain,
OUT PIO_STATUS_BLOCK IoStatus
)
{
UNIMPLEMENTED;
}
/*
* NAME INTERNAL
* CcMdlReadCompleteDev@8
*
* DESCRIPTION
*
* ARGUMENTS
* MdlChain
* DeviceObject
*
* RETURN VALUE
* None.
*
* NOTE
* Used by CcMdlReadComplete@8 and FsRtl
*
*/
VOID
STDCALL
CcMdlReadCompleteDev(IN PMDL MdlChain,
IN PFILE_OBJECT FileObject)
{
PMDL Mdl;
/* Free MDLs */
while ((Mdl = MdlChain))
{
MdlChain = Mdl->Next;
MmUnlockPages(Mdl);
IoFreeMdl(Mdl);
}
}
/*
* NAME EXPORTED
* CcMdlReadComplete@8
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
* None.
*
* NOTE
* From Bo Branten's ntifs.h v13.
*
* @implemented
*/
VOID
STDCALL
CcMdlReadComplete(IN PFILE_OBJECT FileObject,
IN PMDL MdlChain)
{
PDEVICE_OBJECT DeviceObject = NULL;
PFAST_IO_DISPATCH FastDispatch;
/* Get Fast Dispatch Data */
DeviceObject = IoGetRelatedDeviceObject(FileObject);
FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
/* Check if we support Fast Calls, and check this one */
if (FastDispatch && FastDispatch->MdlReadComplete)
{
/* Use the fast path */
FastDispatch->MdlReadComplete(FileObject,
MdlChain,
DeviceObject);
}
/* Use slow path */
CcMdlReadCompleteDev(MdlChain, FileObject);
}
/*
* @implemented
*/
VOID
STDCALL
CcMdlWriteComplete(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain)
{
PDEVICE_OBJECT DeviceObject = NULL;
PFAST_IO_DISPATCH FastDispatch;
/* Get Fast Dispatch Data */
DeviceObject = IoGetRelatedDeviceObject(FileObject);
FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
/* Check if we support Fast Calls, and check this one */
if (FastDispatch && FastDispatch->MdlWriteComplete)
{
/* Use the fast path */
FastDispatch->MdlWriteComplete(FileObject,
FileOffset,
MdlChain,
DeviceObject);
}
/* Use slow path */
CcMdlWriteCompleteDev(FileOffset, MdlChain, FileObject);
}
VOID
STDCALL
CcMdlWriteCompleteDev(IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain,
IN PFILE_OBJECT FileObject)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID
STDCALL
CcMdlWriteAbort (
IN PFILE_OBJECT FileObject,
IN PMDL MdlChain
)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID
STDCALL
CcPrepareMdlWrite (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
OUT PMDL * MdlChain,
OUT PIO_STATUS_BLOCK IoStatus
)
{
UNIMPLEMENTED;
}

View File

@@ -1,257 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/pin.c
* PURPOSE: Implements cache managers pinning interface
*
* PROGRAMMERS:
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *******************************************************************/
extern NPAGED_LOOKASIDE_LIST iBcbLookasideList;
/* FUNCTIONS *****************************************************************/
/*
* @implemented
*/
BOOLEAN STDCALL
CcMapData (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
OUT PVOID *pBcb,
OUT PVOID *pBuffer)
{
ULONG ReadOffset;
BOOLEAN Valid;
PBCB Bcb;
PCACHE_SEGMENT CacheSeg;
NTSTATUS Status;
PINTERNAL_BCB iBcb;
ULONG ROffset;
DPRINT("CcMapData(FileObject 0x%p, FileOffset %I64x, Length %d, Wait %d,"
" pBcb 0x%p, pBuffer 0x%p)\n", FileObject, FileOffset->QuadPart,
Length, Wait, pBcb, pBuffer);
ReadOffset = (ULONG)FileOffset->QuadPart;
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
ASSERT(Bcb);
DPRINT("AllocationSize %I64x, FileSize %I64x\n",
Bcb->AllocationSize.QuadPart,
Bcb->FileSize.QuadPart);
if (ReadOffset % Bcb->CacheSegmentSize + Length > Bcb->CacheSegmentSize)
{
return(FALSE);
}
ROffset = ROUND_DOWN (ReadOffset, Bcb->CacheSegmentSize);
Status = CcRosRequestCacheSegment(Bcb,
ROffset,
pBuffer,
&Valid,
&CacheSeg);
if (!NT_SUCCESS(Status))
{
return(FALSE);
}
if (!Valid)
{
if (!Wait)
{
CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE);
return(FALSE);
}
if (!NT_SUCCESS(ReadCacheSegment(CacheSeg)))
{
CcRosReleaseCacheSegment(Bcb, CacheSeg, FALSE, FALSE, FALSE);
return(FALSE);
}
}
*pBuffer = (PVOID)((ULONG_PTR)(*pBuffer) + (ReadOffset % Bcb->CacheSegmentSize));
iBcb = ExAllocateFromNPagedLookasideList(&iBcbLookasideList);
if (iBcb == NULL)
{
CcRosReleaseCacheSegment(Bcb, CacheSeg, TRUE, FALSE, FALSE);
return FALSE;
}
memset(iBcb, 0, sizeof(INTERNAL_BCB));
iBcb->PFCB.NodeTypeCode = 0xDE45; /* Undocumented (CAPTIVE_PUBLIC_BCB_NODETYPECODE) */
iBcb->PFCB.NodeByteSize = sizeof(PUBLIC_BCB);
iBcb->PFCB.MappedLength = Length;
iBcb->PFCB.MappedFileOffset = *FileOffset;
iBcb->CacheSegment = CacheSeg;
iBcb->Dirty = FALSE;
iBcb->RefCount = 1;
*pBcb = (PVOID)iBcb;
return(TRUE);
}
/*
* @unimplemented
*/
BOOLEAN
STDCALL
CcPinMappedData (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG Flags,
OUT PVOID * Bcb
)
{
/* no-op for current implementation. */
return TRUE;
}
/*
* @unimplemented
*/
BOOLEAN
STDCALL
CcPinRead (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG Flags,
OUT PVOID * Bcb,
OUT PVOID * Buffer
)
{
if (CcMapData(FileObject, FileOffset, Length, Flags, Bcb, Buffer))
{
if (CcPinMappedData(FileObject, FileOffset, Length, Flags, Bcb))
return TRUE;
else
CcUnpinData(Bcb);
}
return FALSE;
}
/*
* @unimplemented
*/
BOOLEAN
STDCALL
CcPreparePinWrite (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Zero,
IN ULONG Flags,
OUT PVOID * Bcb,
OUT PVOID * Buffer
)
{
/*
* FIXME: This is function is similar to CcPinRead, but doesn't
* read the data if they're not present. Instead it should just
* prepare the cache segments and zero them out if Zero == TRUE.
*
* For now calling CcPinRead is better than returning error or
* just having UNIMPLEMENTED here.
*/
return CcPinRead(FileObject, FileOffset, Length, Flags, Bcb, Buffer);
}
/*
* @implemented
*/
VOID STDCALL
CcSetDirtyPinnedData (IN PVOID Bcb,
IN PLARGE_INTEGER Lsn)
{
PINTERNAL_BCB iBcb = Bcb;
iBcb->Dirty = TRUE;
}
/*
* @implemented
*/
VOID STDCALL
CcUnpinData (IN PVOID Bcb)
{
PINTERNAL_BCB iBcb = Bcb;
CcRosReleaseCacheSegment(iBcb->CacheSegment->Bcb, iBcb->CacheSegment, TRUE,
iBcb->Dirty, FALSE);
if (--iBcb->RefCount == 0)
{
ExFreeToNPagedLookasideList(&iBcbLookasideList, iBcb);
}
}
/*
* @unimplemented
*/
VOID
STDCALL
CcUnpinDataForThread (
IN PVOID Bcb,
IN ERESOURCE_THREAD ResourceThreadId
)
{
UNIMPLEMENTED;
}
/*
* @implemented
*/
VOID
STDCALL
CcRepinBcb (
IN PVOID Bcb
)
{
PINTERNAL_BCB iBcb = Bcb;
iBcb->RefCount++;
}
/*
* @unimplemented
*/
VOID
STDCALL
CcUnpinRepinnedBcb (
IN PVOID Bcb,
IN BOOLEAN WriteThrough,
IN PIO_STATUS_BLOCK IoStatus
)
{
PINTERNAL_BCB iBcb = Bcb;
if (--iBcb->RefCount == 0)
{
IoStatus->Information = 0;
if (WriteThrough)
{
ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&iBcb->CacheSegment->Lock);
if (iBcb->CacheSegment->Dirty)
{
IoStatus->Status = CcRosFlushCacheSegment(iBcb->CacheSegment);
}
else
{
IoStatus->Status = STATUS_SUCCESS;
}
ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&iBcb->CacheSegment->Lock);
}
else
{
IoStatus->Status = STATUS_SUCCESS;
}
ExFreeToNPagedLookasideList(&iBcbLookasideList, iBcb);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,248 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/cm/cm_x.h
* PURPOSE: Inlined Functions for the Configuration Manager
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
//
// Returns whether or not this is a small valued key
//
BOOLEAN
FORCEINLINE
CmpIsKeyValueSmall(OUT PULONG RealLength,
IN ULONG Length)
{
/* Check if the length has the special size value */
if (Length >= CM_KEY_VALUE_SPECIAL_SIZE)
{
/* It does, so this is a small key: return the real length */
*RealLength = Length - CM_KEY_VALUE_SPECIAL_SIZE;
return TRUE;
}
/* This is not a small key, return the length we read */
*RealLength = Length;
return FALSE;
}
//
// Returns whether or not this is a big valued key
//
BOOLEAN
FORCEINLINE
CmpIsKeyValueBig(IN PHHIVE Hive,
IN ULONG Length)
{
/* Check if the hive is XP Beta 1 or newer */
if (Hive->Version >= HSYS_WHISTLER_BETA1)
{
/* Check if the key length is valid for a big value key */
if ((Length < CM_KEY_VALUE_SPECIAL_SIZE) && (Length > CM_KEY_VALUE_BIG))
{
/* Yes, this value is big */
return TRUE;
}
}
/* Not a big value key */
return FALSE;
}
//
// Returns the hashkey corresponding to a convkey
//
#define GET_HASH_KEY(ConvKey) \
((CMP_HASH_IRRATIONAL * (ConvKey)) % CMP_HASH_PRIME)
//
// Returns the index into the hash table, or the entry itself
//
#define GET_HASH_INDEX(ConvKey) \
GET_HASH_KEY(ConvKey) % CmpHashTableSize
#define GET_HASH_ENTRY(Table, ConvKey) \
(Table[GET_HASH_INDEX(ConvKey)])
//
// Returns whether or not the cell is cached
//
#define CMP_IS_CELL_CACHED(c) \
(((c) & HCELL_CACHED) && ((c) != HCELL_NIL))
//
// Return data from a cached cell
//
#define CMP_GET_CACHED_CELL(c) \
(ULONG_PTR)((c) & ~HCELL_CACHED)
#define CMP_GET_CACHED_DATA(c) \
(&(((PCM_CACHED_VALUE_INDEX)(CMP_GET_CACHED_CELL(c)))->Data.CellData))
#define CMP_GET_CACHED_INDEX(c) \
(&(((PCM_CACHED_ENTRY)(CMP_GET_CACHED_CELL(c)))->CellIndex))
#define CMP_GET_CACHED_VALUE(c) \
(&(((PCM_CACHED_VALUE)(CMP_GET_CACHED_CELL(c)))->KeyValue))
//
// Makes sure that the registry is locked
//
#define CMP_ASSERT_REGISTRY_LOCK() \
ASSERT((CmpSpecialBootCondition == TRUE) || \
(CmpTestRegistryLock() == TRUE))
//
// Makes sure that the registry is exclusively locked
//
#define CMP_ASSERT_EXCLUSIVE_REGISTRY_LOCK() \
ASSERT((CmpSpecialBootCondition == TRUE) || \
(CmpTestRegistryLockExclusive() == TRUE))
//
// Checks if a KCB is exclusively locked
//
#define CmpIsKcbLockedExclusive(k) \
(GET_HASH_ENTRY(CmpCacheTable, \
(k)->ConvKey).Owner == KeGetCurrentThread())
//
// Exclusively acquires a KCB
//
#define CmpAcquireKcbLockExclusive(k) \
{ \
ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpCacheTable, \
(k)->ConvKey).Lock); \
GET_HASH_ENTRY(CmpCacheTable, \
(k)->ConvKey).Owner = KeGetCurrentThread(); \
}
//
// Exclusively acquires a KCB by index
//
#define CmpAcquireKcbLockExclusiveByIndex(i) \
{ \
ExAcquirePushLockExclusive(&CmpCacheTable[(i)].Lock); \
CmpCacheTable[(i)].Owner = KeGetCurrentThread(); \
}
//
// Exclusively acquires a KCB by key
//
#define CmpAcquireKcbLockExclusiveByKey(k) \
{ \
ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpCacheTable, \
(k)).Lock); \
GET_HASH_ENTRY(CmpCacheTable, \
(k)).Owner = KeGetCurrentThread(); \
}
//
// Shared acquires a KCB
//
#define CmpAcquireKcbLockShared(k) \
{ \
ExAcquirePushLockShared(&GET_HASH_ENTRY(CmpCacheTable, \
(k)->ConvKey).Lock); \
}
//
// Shared acquires a KCB by index
//
#define CmpAcquireKcbLockSharedByIndex(i) \
{ \
ExAcquirePushLockShared(&CmpCacheTable[(i)].Lock); \
}
//
// Tries to convert a KCB lock
//
FORCEINLINE
BOOLEAN
CmpTryToConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
{
ASSERT(CmpIsKcbLockedExclusive(k) == FALSE);
if (ExConvertPushLockSharedToExclusive(
&GET_HASH_ENTRY(CmpCacheTable, k->ConvKey).Lock))
{
GET_HASH_ENTRY(CmpCacheTable,
k->ConvKey).Owner = KeGetCurrentThread();
return TRUE;
}
return FALSE;
}
//
// Releases an exlusively or shared acquired KCB
//
#define CmpReleaseKcbLock(k) \
{ \
GET_HASH_ENTRY(CmpCacheTable, (k)->ConvKey).Owner = NULL; \
ExReleasePushLock(&GET_HASH_ENTRY(CmpCacheTable, \
(k)->ConvKey).Lock); \
}
//
// Releases an exlusively or shared acquired KCB by index
//
#define CmpReleaseKcbLockByIndex(i) \
{ \
CmpCacheTable[(i)].Owner = NULL; \
ExReleasePushLock(&CmpCacheTable[(i)].Lock); \
}
//
// Releases an exlusively or shared acquired KCB by key
//
#define CmpReleaseKcbLockByKey(k) \
{ \
GET_HASH_ENTRY(CmpCacheTable, (k)).Owner = NULL; \
ExReleasePushLock(&GET_HASH_ENTRY(CmpCacheTable, \
(k)).Lock); \
}
//
// Converts a KCB lock
//
FORCEINLINE
VOID
CmpConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
{
ASSERT(CmpIsKcbLockedExclusive(k) == FALSE);
CmpReleaseKcbLock(k);
CmpAcquireKcbLockExclusive(k);
}
//
// Exclusively acquires an NCB
//
#define CmpAcquireNcbLockExclusive(n) \
{ \
ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpNameCacheTable, \
(n)->ConvKey).Lock); \
}
//
// Exclusively acquires an NCB by key
//
#define CmpAcquireNcbLockExclusiveByKey(k) \
{ \
ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpNameCacheTable, \
(k)).Lock); \
}
//
// Releases an exlusively or shared acquired NCB
//
#define CmpReleaseNcbLock(k) \
{ \
ExReleasePushLock(&GET_HASH_ENTRY(CmpNameCacheTable, \
(k)->ConvKey).Lock); \
}
//
// Releases an exlusively or shared acquired NCB by key
//
#define CmpReleaseNcbLockByKey(k) \
{ \
ExReleasePushLock(&GET_HASH_ENTRY(CmpNameCacheTable, \
(k)).Lock); \
}

View File

@@ -1,57 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/cm/cmapi.c
* PURPOSE: Internal routines that implement Nt* API functionality
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
#include "cm.h"
/* GLOBALS *******************************************************************/
BOOLEAN CmpNoWrite;
BOOLEAN CmpForceForceFlush;
/* FUNCTIONS *****************************************************************/
BOOLEAN
NTAPI
CmpFlushEntireRegistry(IN BOOLEAN ForceFlush)
{
BOOLEAN Flushed = TRUE;
/* Make sure that the registry isn't read-only now */
if (CmpNoWrite) return TRUE;
/* Otherwise, acquire the hive list lock and disable force flush */
CmpForceForceFlush = FALSE;
ExAcquirePushLockShared(&CmpHiveListHeadLock);
/* Check if the hive list isn't empty */
if (!IsListEmpty(&CmpHiveListHead))
{
/* FIXME: TODO */
ASSERT(FALSE);
}
/* Release the lock and return the flush state */
ExReleasePushLock(&CmpHiveListHeadLock);
return Flushed;
}
VOID
NTAPI
CmpReportNotify(IN PCM_KEY_CONTROL_BLOCK Kcb,
IN PHHIVE Hive,
IN HCELL_INDEX Cell,
IN ULONG Filter)
{
/* FIXME: TODO */
ASSERT(FALSE);
}

View File

@@ -1,127 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmboot.c
* PURPOSE: Configuration Manager - Boot Initialization
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "cm.h"
#define NDEBUG
#include "debug.h"
/* GLOBALS *******************************************************************/
/* FUNCTIONS *****************************************************************/
HCELL_INDEX
NTAPI
CmpFindControlSet(IN PHHIVE SystemHive,
IN HCELL_INDEX RootCell,
IN PUNICODE_STRING SelectKeyName,
OUT PBOOLEAN AutoSelect)
{
UNICODE_STRING KeyName;
PCM_KEY_NODE Node;
HCELL_INDEX SelectCell, AutoSelectCell, SelectValueCell, ControlSetCell;
HCELL_INDEX CurrentValueCell;
PCM_KEY_VALUE KeyValue;
ULONG Length;
PULONG ControlSetId;
ANSI_STRING ControlSetAnsiName;
CHAR Buffer[128];
WCHAR WideBuffer[128];
NTSTATUS Status;
PULONG CurrentData;
/* Sanity check */
ASSERT(SystemHive->ReleaseCellRoutine == NULL);
/* Get the Select subkey */
RtlInitUnicodeString(&KeyName, L"select");
Node = (PCM_KEY_NODE)HvGetCell(SystemHive, RootCell);
if (!Node) return HCELL_NIL;
SelectCell = CmpFindSubKeyByName(SystemHive, Node, &KeyName);
if (SelectCell == HCELL_NIL) return SelectCell;
/* Get AutoSelect value */
RtlInitUnicodeString(&KeyName, L"AutoSelect");
Node = (PCM_KEY_NODE)HvGetCell(SystemHive, SelectCell);
if (!Node) return HCELL_NIL;
AutoSelectCell = CmpFindValueByName(SystemHive, Node, &KeyName);
if (AutoSelectCell == HCELL_NIL)
{
/* Assume TRUE if the value is missing. */
*AutoSelect = TRUE;
}
else
{
/* Read the value */
KeyValue = (PCM_KEY_VALUE)HvGetCell(SystemHive, AutoSelectCell);
if (KeyValue == NULL) return HCELL_NIL;
/* Convert it to a boolean */
*AutoSelect = *(PBOOLEAN)CmpValueToData(SystemHive, KeyValue, &Length);
}
/* Now find the control set being looked up */
Node = (PCM_KEY_NODE)HvGetCell(SystemHive, SelectCell);
if (!Node) return HCELL_NIL;
SelectValueCell = CmpFindValueByName(SystemHive, Node, SelectKeyName);
if (SelectValueCell == HCELL_NIL) return SelectValueCell;
/* Read the value (corresponding to the CCS ID) */
KeyValue = (PCM_KEY_VALUE)HvGetCell(SystemHive, SelectValueCell);
if (!KeyValue) return HCELL_NIL;
if (KeyValue->Type != REG_DWORD) return HCELL_NIL;
ControlSetId = (PULONG)CmpValueToData(SystemHive, KeyValue, &Length);
/* Now build an Ansi String for the CCS's Name */
sprintf(Buffer, "ControlSet%03lu", *ControlSetId);
ControlSetAnsiName.Length = (USHORT)strlen(Buffer);
ControlSetAnsiName.MaximumLength = (USHORT)strlen(Buffer);
ControlSetAnsiName.Buffer = Buffer;
/* And convert it to Unicode... */
KeyName.MaximumLength = 256;
KeyName.Buffer = WideBuffer;
Status = RtlAnsiStringToUnicodeString(&KeyName,
&ControlSetAnsiName,
FALSE);
if (!NT_SUCCESS(Status)) return HCELL_NIL;
/* Now open it */
Node = (PCM_KEY_NODE)HvGetCell(SystemHive, RootCell);
if (!Node) return HCELL_NIL;
ControlSetCell = CmpFindSubKeyByName(SystemHive, Node, &KeyName);
if (ControlSetCell == HCELL_NIL) return ControlSetCell;
/* Get the value of the "Current" CCS */
RtlInitUnicodeString(&KeyName, L"Current");
Node = (PCM_KEY_NODE)HvGetCell(SystemHive, SelectCell);
if (!Node) return HCELL_NIL;
CurrentValueCell = CmpFindValueByName(SystemHive, Node, &KeyName);
/* Make sure it exists */
if (CurrentValueCell != HCELL_NIL)
{
/* Get the current value and make sure its a ULONG */
KeyValue = (PCM_KEY_VALUE)HvGetCell(SystemHive, CurrentValueCell);
if (!KeyValue) return HCELL_NIL;
if (KeyValue->Type == REG_DWORD)
{
/* Get the data and update it */
CurrentData = (PULONG)CmpValueToData(SystemHive,
KeyValue,
&Length);
if (!CurrentData) return HCELL_NIL;
*CurrentData = *ControlSetId;
}
}
/* Return the CCS Cell */
return ControlSetCell;
}

View File

@@ -1,27 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmcheck.c
* PURPOSE: Configuration Manager - Hive and Key Validation
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "cm.h"
#define NDEBUG
#include "debug.h"
/* GLOBALS *******************************************************************/
/* FUNCTIONS *****************************************************************/
ULONG
NTAPI
CmCheckRegistry(IN PCMHIVE RegistryHive,
IN ULONG Flags)
{
/* FIXME: HACK! */
return 0;
}

View File

@@ -1,274 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmconfig.c
* PURPOSE: Configuration Manager - System Configuration Routines
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "cm.h"
#define NDEBUG
#include "debug.h"
/* FUNCTIONS *****************************************************************/
NTSTATUS
NTAPI
CmpInitializeRegistryNode(IN PCONFIGURATION_COMPONENT_DATA CurrentEntry,
IN HANDLE NodeHandle,
OUT PHANDLE NewHandle,
IN INTERFACE_TYPE InterfaceType,
IN ULONG BusNumber,
IN PUSHORT DeviceIndexTable)
{
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName, ValueName, ValueData;
HANDLE KeyHandle, ParentHandle;
ANSI_STRING TempString;
CHAR TempBuffer[12];
WCHAR Buffer[12];
PCONFIGURATION_COMPONENT Component;
ULONG Disposition, Length = 0;
/* Get the component */
Component = &CurrentEntry->ComponentEntry;
/* Set system class components to ARC system type */
if (Component->Class == SystemClass) Component->Type = ArcSystem;
/* Create a key for the component */
InitializeObjectAttributes(&ObjectAttributes,
&CmTypeName[Component->Type],
OBJ_CASE_INSENSITIVE,
NodeHandle,
NULL);
Status = NtCreateKey(&KeyHandle,
KEY_READ | KEY_WRITE,
&ObjectAttributes,
0,
NULL,
0,
&Disposition);
if (!NT_SUCCESS(Status)) return Status;
/* Check if this is anything but a system class component */
if (Component->Class != SystemClass)
{
/* Build the sub-component string */
RtlIntegerToChar(DeviceIndexTable[Component->Type]++,
10,
12,
TempBuffer);
RtlInitAnsiString(&TempString, TempBuffer);
/* Convert it to Unicode */
RtlInitEmptyUnicodeString(&KeyName, Buffer, sizeof(Buffer));
RtlAnsiStringToUnicodeString(&KeyName, &TempString, FALSE);
/* Create the key */
ParentHandle = KeyHandle;
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
ParentHandle,
NULL);
Status = NtCreateKey(&KeyHandle,
KEY_READ | KEY_WRITE,
&ObjectAttributes,
0,
NULL,
0,
&Disposition);
NtClose(ParentHandle);
/* Fail if the key couldn't be created, and make sure it's a new key */
if (!NT_SUCCESS(Status)) return Status;
ASSERT(Disposition == REG_CREATED_NEW_KEY);
}
/* Sstup the compnent information key */
RtlInitUnicodeString(&ValueName, L"Component Information");
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_BINARY,
&Component->Flags,
FIELD_OFFSET(CONFIGURATION_COMPONENT,
ConfigurationDataLength) -
FIELD_OFFSET(CONFIGURATION_COMPONENT, Flags));
if (!NT_SUCCESS(Status))
{
/* Fail */
NtClose(KeyHandle);
return Status;
}
/* Check if we have an identifier */
if (Component->IdentifierLength)
{
/* Build the string and convert it to Unicode */
RtlInitUnicodeString(&ValueName, L"Identifier");
RtlInitAnsiString(&TempString, Component->Identifier);
Status = RtlAnsiStringToUnicodeString(&ValueData,
&TempString,
TRUE);
if (NT_SUCCESS(Status))
{
/* Save the identifier in the registry */
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_SZ,
ValueData.Buffer,
ValueData.Length + sizeof(UNICODE_NULL));
RtlFreeUnicodeString(&ValueData);
}
/* Check for failure during conversion or registry write */
if (!NT_SUCCESS(Status))
{
/* Fail */
NtClose(KeyHandle);
return Status;
}
}
/* Setup the configuration data string */
RtlInitUnicodeString(&ValueName, L"Configuration Data");
/* Check if we got configuration data */
if (CurrentEntry->ConfigurationData)
{
/* Calculate the total length and check if it fits into our buffer */
Length = Component->ConfigurationDataLength +
FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList);
if (Length > CmpConfigurationAreaSize)
{
ASSERTMSG("Component too large -- need reallocation!", FALSE);
}
else
{
/* Copy the data */
RtlCopyMemory(&CmpConfigurationData->PartialResourceList.Version,
CurrentEntry->ConfigurationData,
Component->ConfigurationDataLength);
}
}
else
{
/* No configuration data, setup defaults */
CmpConfigurationData->PartialResourceList.Version = 0;
CmpConfigurationData->PartialResourceList.Revision = 0;
CmpConfigurationData->PartialResourceList.Count = 0;
Length = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors) +
FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList);
}
/* Set the interface type and bus number */
CmpConfigurationData->InterfaceType = InterfaceType;
CmpConfigurationData->BusNumber = BusNumber;
/* Save the actual data */
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_FULL_RESOURCE_DESCRIPTOR,
CmpConfigurationData,
Length);
if (!NT_SUCCESS(Status))
{
/* Fail */
NtClose(KeyHandle);
}
else
{
/* Return the new handle */
*NewHandle = KeyHandle;
}
/* Return status */
return Status;
}
NTSTATUS
NTAPI
CmpInitializeHardwareConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE KeyHandle;
ULONG Disposition;
UNICODE_STRING KeyName;
/* Setup the key name */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\Hardware\\DeviceMap");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
/* Create the device map key */
Status = NtCreateKey(&KeyHandle,
KEY_READ | KEY_WRITE,
&ObjectAttributes,
0,
NULL,
0,
&Disposition);
if (!NT_SUCCESS(Status)) return Status;
NtClose(KeyHandle);
/* Nobody should've created this key yet! */
//ASSERT(Disposition == REG_CREATED_NEW_KEY);
/* Setup the key name */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\Hardware\\Description");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
/* Create the description key */
Status = NtCreateKey(&KeyHandle,
KEY_READ | KEY_WRITE,
&ObjectAttributes,
0,
NULL,
0,
&Disposition);
if (!NT_SUCCESS(Status)) return Status;
/* Nobody should've created this key yet! */
//ASSERT(Disposition == REG_CREATED_NEW_KEY);
/* Allocate the configuration data buffer */
CmpConfigurationData = ExAllocatePoolWithTag(PagedPool,
CmpConfigurationAreaSize,
TAG_CM);
if (!CmpConfigurationData) return STATUS_INSUFFICIENT_RESOURCES;
/* Check if we got anything from NTLDR */
if (LoaderBlock->ConfigurationRoot)
{
ASSERTMSG("NTLDR ARC Hardware Tree Not Supported!\n", FALSE);
}
else
{
/* Nothing else to do */
Status = STATUS_SUCCESS;
}
/* Close our handle, free the buffer and return status */
ExFreePool(CmpConfigurationData);
NtClose(KeyHandle);
return Status;
}

View File

@@ -1,265 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmcontrl.c
* PURPOSE: Configuration Manager - Control Set Management
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "cm.h"
#define NDEBUG
#include "debug.h"
/* GLOBALS *******************************************************************/
/* FUNCTIONS *****************************************************************/
LANGID
NTAPI
CmpConvertLangId(IN LPWSTR Name,
IN ULONG NameLength)
{
ULONG i;
WCHAR p;
LANGID LangId = 0;
ULONG IdCode;
/* Convert the length in chars and loop */
NameLength = NameLength / sizeof(WCHAR);
for (i = 0; i < NameLength; i++)
{
/* Get the character */
p = Name[i];
/* Handle each case */
if ((p >= L'0') && (p <= L'9'))
{
/* Handle digits*/
IdCode = p - L'0';
}
else if ((p >= L'A') && (p <= L'F'))
{
/* Handle upper-case letters */
IdCode = p - L'A' + 10;
}
else if ((p >= L'a') && (p <= L'f'))
{
/* Handle lower-case letters */
IdCode = p - L'a' + 10;
}
else
{
/* Unhandled case, return what we have till now */
break;
}
/* If the ID Code is >= 16, then we're done */
if (IdCode >= 16) break;
/* Build the Language ID */
LangId = (LangId << 4) | (LANGID)IdCode;
}
/* Return the Language ID */
return LangId;
}
HCELL_INDEX
NTAPI
CmpWalkPath(IN PHHIVE SystemHive,
IN HCELL_INDEX ParentCell,
IN LPWSTR Path)
{
UNICODE_STRING UnicodePath, NextName;
BOOLEAN LastName;
HCELL_INDEX CurrentCell = ParentCell;
PCM_KEY_NODE Node;
/* We shouldn't have a release routine at this point */
ASSERT(SystemHive->ReleaseCellRoutine == NULL);
/* Initialize the Unicode path and start looping */
RtlInitUnicodeString(&UnicodePath, Path);
while (TRUE)
{
/* Get the next name */
CmpGetNextName(&UnicodePath, &NextName, &LastName);
if (!NextName.Length) return CurrentCell;
/* Get the subkey */
Node = (PCM_KEY_NODE)HvGetCell(SystemHive, CurrentCell);
if (!Node) return HCELL_NIL;
CurrentCell = CmpFindSubKeyByName(SystemHive, Node, &NextName);
if (CurrentCell == HCELL_NIL) return CurrentCell;
}
}
VOID
NTAPI
CmGetSystemControlValues(IN PVOID SystemHiveData,
IN PCM_SYSTEM_CONTROL_VECTOR ControlVector)
{
PHHIVE SystemHive = (PHHIVE)&CmControlHive;
NTSTATUS Status;
HCELL_INDEX RootCell, BaseCell, KeyCell, ValueCell;
ULONG Length, DataSize;
PCM_KEY_NODE Node;
PCM_KEY_VALUE ValueData;
UNICODE_STRING KeyName;
BOOLEAN Auto, IsSmallKey;
PVOID Buffer;
/* LUDDDIIIICRROOOUUSSSS KI^H^H HACKKKK */
if (!SystemHiveData) return;
/* Initialize the Hive View List and the security cache */
RtlZeroMemory(SystemHive, sizeof(SystemHive));
CmpInitHiveViewList((PCMHIVE)SystemHive);
CmpInitSecurityCache((PCMHIVE)SystemHive);
/* Initialize the Hive */
Status = HvInitialize(SystemHive,
HINIT_FLAT,
HIVE_VOLATILE,
HFILE_TYPE_PRIMARY,
SystemHiveData,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
1,
NULL);
if (!NT_SUCCESS(Status)) KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO, 1, 1, 0, 0);
/* Sanity check, flat hives don't have release routines */
ASSERT(SystemHive->ReleaseCellRoutine == NULL);
/* FIXME: Prepare it */
CmPrepareHive(SystemHive);
/* Set the Root Cell */
RootCell = ((PHBASE_BLOCK)SystemHiveData)->RootCell;
/* Find the current control set */
RtlInitUnicodeString(&KeyName, L"current");
BaseCell = CmpFindControlSet(SystemHive, RootCell, &KeyName, &Auto);
if (BaseCell == HCELL_NIL) KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO, 1, 2, 0, 0);
/* Find the control subkey */
RtlInitUnicodeString(&KeyName, L"control");
Node = (PCM_KEY_NODE)HvGetCell(SystemHive, BaseCell);
BaseCell = CmpFindSubKeyByName(SystemHive, Node, &KeyName);
if (BaseCell == HCELL_NIL) KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO,1 , 3, 0, 0);
/* Loop each key */
while (ControlVector->KeyPath)
{
/* Assume failure */
Length = -1;
/* Get the cell for this key */
KeyCell = CmpWalkPath(SystemHive, BaseCell, ControlVector->KeyPath);
if (KeyCell != HCELL_NIL)
{
/* Now get the cell for the value */
RtlInitUnicodeString(&KeyName, ControlVector->ValueName);
Node = (PCM_KEY_NODE)HvGetCell(SystemHive, KeyCell);
ValueCell = CmpFindValueByName(SystemHive, Node, &KeyName);
if (ValueCell != HCELL_NIL)
{
/* Check if there's any data */
if (!ControlVector->BufferLength)
{
/* No, the buffer will only be large enough for a ULONG */
DataSize = sizeof(ULONG);
}
else
{
/* Yes, save the data size */
DataSize = *ControlVector->BufferLength;
}
/* Get the actual data */
ValueData = (PCM_KEY_VALUE)HvGetCell(SystemHive, ValueCell);
/* Check if this is a small key */
IsSmallKey = CmpIsKeyValueSmall(&Length, ValueData->DataLength);
/* If the length is bigger then our buffer, normalize it */
if (DataSize < Length) Length = DataSize;
/* Make sure we have some data */
if (Length > 0)
{
/* Check if this was a small key */
if (IsSmallKey)
{
/* The buffer is directly safe to read */
Buffer = (PVOID)(&(ValueData->Data));
}
else
{
/* Use the longer path */
Buffer = (PVOID)HvGetCell(SystemHive, ValueData->Data);
}
/* Sanity check if this is a small key */
ASSERT((IsSmallKey ?
(Length <= CM_KEY_VALUE_SMALL) : TRUE));
/* Copy the data in the buffer */
RtlCopyMemory(ControlVector->Buffer, Buffer, Length);
}
/* Check if we should return the data type */
if (ControlVector->Type)
{
/* Return the type that we read */
*ControlVector->Type = ValueData->Type;
}
}
}
/* Return the size that we read */
if (ControlVector->BufferLength) *ControlVector->BufferLength = Length;
/* Go to the next entry */
ControlVector++;
}
/* Check if the ID is in the registry */
if (CmDefaultLanguageIdType == REG_SZ)
{
/* Read it */
PsDefaultSystemLocaleId =
(LCID)CmpConvertLangId(CmDefaultLanguageId,
CmDefaultLanguageIdLength);
}
else
{
/* Use EN_US by default */
PsDefaultSystemLocaleId = 0x409;
}
/* Check if the ID Is in the registry */
if (CmInstallUILanguageIdType == REG_SZ)
{
/* Read it */
PsInstallUILanguageId = CmpConvertLangId(CmInstallUILanguageId,
CmInstallUILanguageIdLength);
}
else
{
/* Otherwise, use the default */
PsInstallUILanguageId = LANGIDFROMLCID(PsDefaultSystemLocaleId);
}
/* Set the defaults for the Thread UI */
PsDefaultThreadLocaleId = PsDefaultSystemLocaleId;
PsDefaultUILanguageId = PsInstallUILanguageId;
}

View File

@@ -1,807 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmdata.c
* PURPOSE: Configuration Manager - Global Configuration Data
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "cm.h"
#define NDEBUG
#include "debug.h"
/* GLOBALS *******************************************************************/
ULONG DummyData;
ULONG CmNtGlobalFlag;
ULONG CmNtCSDVersion;
WCHAR CmDefaultLanguageId[12];
ULONG CmDefaultLanguageIdLength = sizeof(CmDefaultLanguageId);
ULONG CmDefaultLanguageIdType;
WCHAR CmInstallUILanguageId[12];
ULONG CmInstallUILanguageIdLength = sizeof(CmInstallUILanguageId);
ULONG CmInstallUILanguageIdType;
WCHAR CmSuiteBuffer[128];
ULONG CmSuiteBufferLength = sizeof(CmSuiteBuffer);
ULONG CmSuiteBufferType;
CMHIVE CmControlHive;
ULONG CmpConfigurationAreaSize = PAGE_SIZE * 4;
PCM_FULL_RESOURCE_DESCRIPTOR CmpConfigurationData;
EX_PUSH_LOCK CmpHiveListHeadLock, CmpLoadHiveLock;
HIVE_LIST_ENTRY CmpMachineHiveList[] =
{
{
L"HARDWARE", L"MACHINE\\", NULL, HIVE_VOLATILE, 0, NULL, FALSE, FALSE, FALSE
},
{
L"SECURITY", L"MACHINE\\", NULL, 0, 0, NULL, FALSE, FALSE, FALSE
},
{
L"SOFTWARE", L"MACHINE\\", NULL, 0, 0, NULL, FALSE, FALSE, FALSE
},
{
L"SYSTEM", L"MACHINE\\", NULL, 0, 0, NULL, FALSE, FALSE, FALSE
},
{
L"DEFAULT", L"USER\\.DEFAULT", NULL, 0, 1, NULL, FALSE, FALSE, FALSE
},
{
L"SAM", L"MACHINE\\", NULL, HIVE_NOLAZYFLUSH, 0, NULL, FALSE, FALSE, FALSE
},
{
NULL, NULL, 0, 0, 0, NULL, FALSE, FALSE, FALSE
}
};
UNICODE_STRING CmSymbolicLinkValueName =
RTL_CONSTANT_STRING(L"SymbolicLinkValue");
UNICODE_STRING CmpLoadOptions;
BOOLEAN CmpShareSystemHives;
BOOLEAN CmSelfHeal = TRUE;
BOOLEAN CmpSelfHeal = TRUE;
BOOLEAN CmpMiniNTBoot;
ULONG CmpBootType;
HANDLE CmpRegistryRootHandle;
UNICODE_STRING CmTypeName[MaximumType + 1] =
{
RTL_CONSTANT_STRING(L"System"),
RTL_CONSTANT_STRING(L"CentralProcessor"),
RTL_CONSTANT_STRING(L"FloatingPointProcessor"),
RTL_CONSTANT_STRING(L"PrimaryICache"),
RTL_CONSTANT_STRING(L"PrimaryDCache"),
RTL_CONSTANT_STRING(L"SecondaryICache"),
RTL_CONSTANT_STRING(L"SecondaryDCache"),
RTL_CONSTANT_STRING(L"SecondaryCache"),
RTL_CONSTANT_STRING(L"EisaAdapter"),
RTL_CONSTANT_STRING(L"TcAdapter"),
RTL_CONSTANT_STRING(L"ScsiAdapter"),
RTL_CONSTANT_STRING(L"DtiAdapter"),
RTL_CONSTANT_STRING(L"MultifunctionAdapter"),
RTL_CONSTANT_STRING(L"DiskController"),
RTL_CONSTANT_STRING(L"TapeController"),
RTL_CONSTANT_STRING(L"CdRomController"),
RTL_CONSTANT_STRING(L"WormController"),
RTL_CONSTANT_STRING(L"SerialController"),
RTL_CONSTANT_STRING(L"NetworkController"),
RTL_CONSTANT_STRING(L"DisplayController"),
RTL_CONSTANT_STRING(L"ParallelController"),
RTL_CONSTANT_STRING(L"PointerController"),
RTL_CONSTANT_STRING(L"KeyboardController"),
RTL_CONSTANT_STRING(L"AudioController"),
RTL_CONSTANT_STRING(L"OtherController"),
RTL_CONSTANT_STRING(L"DiskPeripheral"),
RTL_CONSTANT_STRING(L"FloppyDiskPeripheral"),
RTL_CONSTANT_STRING(L"TapePeripheral"),
RTL_CONSTANT_STRING(L"ModemPeripheral"),
RTL_CONSTANT_STRING(L"MonitorPeripheral"),
RTL_CONSTANT_STRING(L"PrinterPeripheral"),
RTL_CONSTANT_STRING(L"PointerPeripheral"),
RTL_CONSTANT_STRING(L"KeyboardPeripheral"),
RTL_CONSTANT_STRING(L"TerminalPeripheral"),
RTL_CONSTANT_STRING(L"OtherPeripheral"),
RTL_CONSTANT_STRING(L"LinePeripheral"),
RTL_CONSTANT_STRING(L"NetworkPeripheral"),
RTL_CONSTANT_STRING(L"SystemMemory"),
RTL_CONSTANT_STRING(L"DockingInformation"),
RTL_CONSTANT_STRING(L"RealModeIrqRoutingTable"),
RTL_CONSTANT_STRING(L"RealModePCIEnumeration"),
RTL_CONSTANT_STRING(L"Undefined")
};
CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
{
{
L"Session Manager",
L"ProtectionMode",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"ObjectSecurityMode",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"LUIDDeviceMapsDisabled",
&DummyData,
NULL,
NULL
},
{
L"LSA",
L"AuditBaseDirectories",
&DummyData,
NULL,
NULL
},
{
L"LSA",
L"AuditBaseObjects",
&DummyData,
NULL,
NULL
},
{
L"LSA\\audit",
L"ProcessAccessesToAudit",
&DummyData,
NULL,
NULL
},
{
L"TimeZoneInformation",
L"ActiveTimeBias",
&DummyData,
NULL,
NULL
},
{
L"TimeZoneInformation",
L"Bias",
&DummyData,
NULL,
NULL
},
{
L"TimeZoneInformation",
L"RealTimeIsUniversal",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"GlobalFlag",
&CmNtGlobalFlag,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PagedPoolQuota",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"NonPagedPoolQuota",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PagingFileQuota",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"AllocationPreference",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"DynamicMemory",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"Mirroring",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"Mirroring",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SystemViewSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SessionViewSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SessionImageSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SessionPoolSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PoolUsageMaximum",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"MapAllocationFragment",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PagedPoolSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"NonPagedPoolSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"NonPagedPoolMaximumPercent",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"LargeSystemCache",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"LargeStackSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SystemPages",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"LowMemoryThreshold",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"HighMemoryThreshold",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"DisablePagingExecutive",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"ModifiedPageLife",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SecondLevelDataCache",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"ClearPageFileAtShutdown",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PoolTagSmallTableSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PoolTagBigTableSize",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PoolTag",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"PoolTagOverruns",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"SnapUnloads",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"ProtectNonPagedPool",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"TrackLockedPages",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"TrackPtes",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"VerifyDrivers",
&DummyData,
&DummyData,
&DummyData
},
{
L"Session Manager\\Memory Management",
L"VerifyDriverLevel",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"VerifyMode",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"LargePageMinimum",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"EnforceWriteProtection",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"MakeLowMemory",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Memory Management",
L"WriteWatch",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Executive",
L"AdditionalCriticalWorkerThreads",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Executive",
L"AdditionalDelayedWorkerThreads",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Executive",
L"PriorityQuantumMatrix",
&DummyData,
&DummyData,
NULL
},
{
L"Session Manager\\Kernel",
L"DpcQueueDepth",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Kernel",
L"MinimumDpcRate",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Kernel",
L"AdjustDpcThreshold",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Kernel",
L"IdealDpcRate",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\I/O System",
L"CountOperations",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\I/O System",
L"LargeIrpStackLocations",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\I/O System",
L"IoVerifierLevel",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"ResourceTimeoutCount",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"CriticalSectionTimeout",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"HeapSegmentReserve",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"HeapSegmentCommit",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"HeapDeCommitTotalFreeThreshold",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"HeapDeCommitFreeBlockThreshold",
&DummyData,
NULL,
NULL
},
{
L"ProductOptions",
L"ProductType",
&DummyData,
NULL,
NULL
},
{
L"Terminal Server",
L"TSEnabled",
&DummyData,
NULL,
NULL
},
{
L"Terminal Server",
L"TSAppCompat",
&DummyData,
NULL,
NULL
},
{
L"ProductOptions",
L"ProductSuite",
CmSuiteBuffer,
&CmSuiteBufferLength,
&CmSuiteBufferType
},
{
L"Windows",
L"CSDVersion",
&CmNtCSDVersion,
NULL,
NULL
},
{
L"Nls\\Language",
L"Default",
CmDefaultLanguageId,
&CmDefaultLanguageIdLength,
&CmDefaultLanguageIdType
},
{
L"Nls\\Language",
L"InstallLanguage",
CmInstallUILanguageId,
&CmInstallUILanguageIdLength,
&CmInstallUILanguageIdType
},
{
L"\0\0",
L"RegistrySizeLimit",
&DummyData,
&DummyData,
&DummyData
},
{
L"Session Manager",
L"ForceNpxEmulation",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"PowerPolicySimulate",
&DummyData,
NULL,
NULL
},
{
L"Session Manager\\Executive",
L"MaxTimeSeparationBeforeCorrect",
&DummyData,
NULL,
NULL
},
{
L"Windows",
L"ShutdownTime",
&DummyData,
&DummyData,
NULL
},
{
L"PriorityControl",
L"Win32PrioritySeparation",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"EnableTimerWatchdog",
&DummyData,
NULL,
NULL
},
{
L"Session Manager",
L"Debugger Retries",
&DummyData,
NULL,
NULL
},
{
L"WMI",
L"MaxEventSize",
&DummyData,
NULL,
NULL
},
{
L"WMI\\Trace",
L"UsePerformanceClock",
&DummyData,
NULL,
NULL
},
{
L"WMI\\Trace",
L"TraceAlignment",
&DummyData,
NULL,
NULL
},
{
NULL,
NULL,
NULL,
NULL,
NULL
}
};

View File

@@ -1,317 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/cm/cmhive.c
* PURPOSE: Routines for managing Registry Hives in general
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
#include "cm.h"
/* GLOBALS *******************************************************************/
EX_PUSH_LOCK CmpHiveListHeadLock;
LIST_ENTRY CmpHiveListHead;
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
CmpInitHiveViewList(IN PCMHIVE Hive)
{
PAGED_CODE();
/* Initialize the lists */
InitializeListHead(&Hive->PinViewListHead);
InitializeListHead(&Hive->LRUViewListHead);
/* Setup defaults */
Hive->MappedViews = 0;
Hive->PinnedViews = 0;
Hive->UseCount = 0;
}
NTSTATUS
NTAPI
CmpInitializeHive(OUT PCMHIVE *CmHive,
IN ULONG Operation,
IN ULONG Flags,
IN ULONG FileType,
IN PVOID HiveData OPTIONAL,
IN HANDLE Primary,
IN HANDLE Log,
IN HANDLE External,
IN PCUNICODE_STRING FileName,
IN ULONG CheckFlags)
{
PCMHIVE Hive;
IO_STATUS_BLOCK IoStatusBlock;
FILE_FS_SIZE_INFORMATION FileSizeInformation;
NTSTATUS Status;
ULONG Cluster;
FILE_STANDARD_INFORMATION FileInformation;
/*
* The following are invalid:
* An external hive that is also internal.
* A log hive that's not a primary hive too.
* A volatile hive that's linked to permanent storage.
* An in-memory initialization without hive data.
* A log hive that's not linked to a correct file type.
*/
if (((External) && ((Primary) || (Log))) ||
((Log) && !(Primary)) ||
((Flags & HIVE_VOLATILE) && ((Primary) || (External) || (Log))) ||
((Operation == HINIT_MEMORY) && (!HiveData)) ||
((Log) && (FileType != HFILE_TYPE_LOG)))
{
/* Fail the request */
return STATUS_INVALID_PARAMETER;
}
/* Check if this is a primary hive */
if (Primary)
{
/* Get the cluster size */
Status = ZwQueryVolumeInformationFile(Primary,
&IoStatusBlock,
&FileSizeInformation,
sizeof(FILE_FS_SIZE_INFORMATION),
FileFsSizeInformation);
if (!NT_SUCCESS(Status)) return Status;
/* Make sure it's not larger then the block size */
if (FileSizeInformation.BytesPerSector > HBLOCK_SIZE)
{
/* Fail */
return STATUS_REGISTRY_IO_FAILED;
}
/* Otherwise, calculate the cluster */
Cluster = FileSizeInformation.BytesPerSector / HSECTOR_SIZE;
Cluster = max(1, Cluster);
}
else
{
/* Otherwise use cluster 1 */
Cluster = 1;
}
/* Allocate a hive */
Hive = ExAllocatePoolWithTag(PagedPool,
sizeof(CMHIVE),
TAG_CM);
if (!Hive) return STATUS_INSUFFICIENT_RESOURCES;
/* Setup null fields */
Hive->UnloadEvent = NULL;
Hive->RootKcb = NULL;
Hive->Frozen = FALSE;
Hive->UnloadWorkItem = NULL;
Hive->GrowOnlyMode = FALSE;
Hive->GrowOffset = 0;
Hive->CellRemapArray = NULL;
Hive->UseCountLog.Next = 0;
Hive->LockHiveLog.Next = 0;
Hive->FileObject = NULL;
Hive->NotifyList.Flink = NULL;
Hive->NotifyList.Blink = NULL;
/* Set loading flag */
Hive->HiveIsLoading = TRUE;
/* Set the current thread as creator */
Hive->CreatorOwner = KeGetCurrentThread();
/* Initialize lists */
InitializeListHead(&Hive->KcbConvertListHead);
InitializeListHead(&Hive->KnodeConvertListHead);
InitializeListHead(&Hive->TrustClassEntry);
/* Allocate the view log */
Hive->ViewLock = ExAllocatePoolWithTag(NonPagedPool,
sizeof(KGUARDED_MUTEX),
TAG_CM);
if (!Hive->ViewLock) return STATUS_INSUFFICIENT_RESOURCES;
/* Allocate the flush lock */
Hive->FlusherLock = ExAllocatePoolWithTag(NonPagedPool,
sizeof(ERESOURCE),
TAG_CM);
if (!Hive->FlusherLock) return STATUS_INSUFFICIENT_RESOURCES;
/* Setup the handles */
Hive->FileHandles[HFILE_TYPE_PRIMARY] = Primary;
Hive->FileHandles[HFILE_TYPE_LOG] = Log;
Hive->FileHandles[HFILE_TYPE_EXTERNAL] = External;
/* Initailize the guarded mutex */
KeInitializeGuardedMutex(Hive->ViewLock);
Hive->ViewLockOwner = NULL;
/* Initialize the flush lock */
ExInitializeResourceLite(Hive->FlusherLock);
/* Setup hive locks */
ExInitializePushLock((PULONG_PTR)&Hive->HiveLock);
Hive->HiveLockOwner = NULL;
ExInitializePushLock((PULONG_PTR)&Hive->WriterLock);
Hive->WriterLockOwner = NULL;
ExInitializePushLock((PULONG_PTR)&Hive->SecurityLock);
Hive->HiveSecurityLockOwner = NULL;
/* Clear file names */
RtlInitEmptyUnicodeString(&Hive->FileUserName, NULL, 0);
RtlInitEmptyUnicodeString(&Hive->FileFullPath, NULL, 0);
/* Initialize the view list */
CmpInitHiveViewList(Hive);
/* Initailize the security cache */
CmpInitSecurityCache(Hive);
/* Setup flags */
Hive->Flags = 0;
Hive->FlushCount = 0;
/* REACTOS: Check how large the file is */
ZwQueryInformationFile(Primary,
&IoStatusBlock,
&FileInformation,
sizeof(FileInformation),
FileStandardInformation);
Cluster = FileInformation.EndOfFile.LowPart;
/* Initialize the hive */
Status = HvInitialize(&Hive->Hive,
Operation,
FileType,
Flags,
HiveData,
CmpAllocate,
CmpFree,
CmpFileSetSize,
CmpFileWrite,
CmpFileRead,
CmpFileFlush,
Cluster,
(PUNICODE_STRING)FileName);
if (!NT_SUCCESS(Status))
{
/* Free all allocations */
ExFreePool(Hive->ViewLock);
ExFreePool(Hive->FlusherLock);
ExFreePool(Hive);
return Status;
}
/* Check if we should verify the registry */
if ((Operation == HINIT_FILE) ||
(Operation == HINIT_MEMORY) ||
(Operation == HINIT_MEMORY_INPLACE) ||
(Operation == HINIT_MAPFILE))
{
/* Verify integrity */
if (CmCheckRegistry(Hive, TRUE))
{
/* Free all alocations */
ExFreePool(Hive->ViewLock);
ExFreePool(Hive->FlusherLock);
ExFreePool(Hive);
return STATUS_REGISTRY_CORRUPT;
}
}
/* Lock the hive list */
ExAcquirePushLockExclusive(&CmpHiveListHeadLock);
/* Insert this hive */
InsertHeadList(&CmpHiveListHead, &Hive->HiveList);
/* Release the lock */
ExReleasePushLock(&CmpHiveListHeadLock);
/* Return the hive and success */
*CmHive = Hive;
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
CmpLinkHiveToMaster(IN PUNICODE_STRING LinkName,
IN HANDLE RootDirectory,
IN PCMHIVE CmHive,
IN BOOLEAN Allocate,
IN PSECURITY_DESCRIPTOR SecurityDescriptor)
{
CM_PARSE_CONTEXT ParseContext;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE KeyHandle;
NTSTATUS Status;
PCM_KEY_BODY KeyBody;
PAGED_CODE();
/* Fill out the parse context */
ParseContext.TitleIndex = 0;
ParseContext.Class.Length = 0;
ParseContext.Class.MaximumLength = 0;
ParseContext.Class.Buffer = NULL;
ParseContext.CreateOptions = 0;
ParseContext.CreateLink = TRUE;
ParseContext.Flag2 = TRUE;
ParseContext.PostActions = 0;
ParseContext.ChildHive.KeyHive = &CmHive->Hive;
/* Check if we're allocating */
if (Allocate)
{
/* Set no child */
ParseContext.ChildHive.KeyCell = HCELL_NIL;
}
else
{
/* Otherwise, set the root cell */
ParseContext.ChildHive.KeyCell = CmHive->Hive.BaseBlock->RootCell;
}
/* Open the key */
InitializeObjectAttributes(&ObjectAttributes,
LinkName,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
RootDirectory,
SecurityDescriptor);
Status = ObOpenObjectByName(&ObjectAttributes,
CmpKeyObjectType,
KernelMode,
NULL,
KEY_READ | KEY_WRITE,
&ParseContext,
&KeyHandle);
if (!NT_SUCCESS(Status)) return Status;
/* Reference the key body */
Status = ObReferenceObjectByHandle(KeyHandle,
0,
CmpKeyObjectType,
KernelMode,
(PVOID*)&KeyBody,
NULL);
ASSERT(NT_SUCCESS(Status));
/* Send a notification */
#define REG_NOTIFY_CHANGE_NAME 1 /* DDK! */
CmpReportNotify(KeyBody->KeyControlBlock,
KeyBody->KeyControlBlock->KeyHive,
KeyBody->KeyControlBlock->KeyCell,
REG_NOTIFY_CHANGE_NAME);
/* Dereference the key and close the handle */
ObDereferenceObject((PVOID)KeyBody);
ZwClose(KeyHandle);
return STATUS_SUCCESS;
}

View File

@@ -1,198 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmhook.c
* PURPOSE: Configuration Manager - Registry Notifications/Callbacks
* PROGRAMMERS: Thomas Weidenmueller (w3seek@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "cm.h"
#define NDEBUG
#include "debug.h"
/* GLOBALS *******************************************************************/
ULONG CmpCallBackCount = 0;
EX_CALLBACK CmpCallBackVector[100];
LIST_ENTRY CmiCallbackHead;
FAST_MUTEX CmiCallbackLock;
typedef struct _REGISTRY_CALLBACK
{
LIST_ENTRY ListEntry;
EX_RUNDOWN_REF RundownRef;
PEX_CALLBACK_FUNCTION Function;
PVOID Context;
LARGE_INTEGER Cookie;
BOOLEAN PendingDelete;
} REGISTRY_CALLBACK, *PREGISTRY_CALLBACK;
/* PRIVATE FUNCTIONS *********************************************************/
VOID
NTAPI
CmpInitCallback(VOID)
{
ULONG i;
PAGED_CODE();
/* Reset counter */
CmpCallBackCount = 0;
/* Loop all the callbacks */
for (i = 0; i < CMP_MAX_CALLBACKS; i++)
{
/* Initialize this one */
ExInitializeCallBack(&CmpCallBackVector[i]);
}
/* ROS: Initialize old-style callbacks for now */
InitializeListHead(&CmiCallbackHead);
ExInitializeFastMutex(&CmiCallbackLock);
}
NTSTATUS
CmiCallRegisteredCallbacks(IN REG_NOTIFY_CLASS Argument1,
IN PVOID Argument2)
{
PLIST_ENTRY CurrentEntry;
NTSTATUS Status = STATUS_SUCCESS;
PREGISTRY_CALLBACK CurrentCallback;
PAGED_CODE();
ExAcquireFastMutex(&CmiCallbackLock);
for (CurrentEntry = CmiCallbackHead.Flink;
CurrentEntry != &CmiCallbackHead;
CurrentEntry = CurrentEntry->Flink)
{
CurrentCallback = CONTAINING_RECORD(CurrentEntry, REGISTRY_CALLBACK, ListEntry);
if (!CurrentCallback->PendingDelete &&
ExAcquireRundownProtection(&CurrentCallback->RundownRef))
{
/* don't hold locks during the callbacks! */
ExReleaseFastMutex(&CmiCallbackLock);
Status = CurrentCallback->Function(CurrentCallback->Context,
(PVOID)Argument1,
Argument2);
ExAcquireFastMutex(&CmiCallbackLock);
/* don't release the rundown protection before holding the callback lock
so the pointer to the next callback isn't cleared in case this callback
get's deleted */
ExReleaseRundownProtection(&CurrentCallback->RundownRef);
if(!NT_SUCCESS(Status))
{
/* one callback returned failure, don't call any more callbacks */
break;
}
}
}
ExReleaseFastMutex(&CmiCallbackLock);
return Status;
}
/* PUBLIC FUNCTIONS **********************************************************/
/*
* @implemented
*/
NTSTATUS
NTAPI
CmRegisterCallback(IN PEX_CALLBACK_FUNCTION Function,
IN PVOID Context,
IN OUT PLARGE_INTEGER Cookie)
{
PREGISTRY_CALLBACK Callback;
PAGED_CODE();
ASSERT(Function && Cookie);
Callback = ExAllocatePoolWithTag(PagedPool,
sizeof(REGISTRY_CALLBACK),
TAG('C', 'M', 'c', 'b'));
if (Callback != NULL)
{
/* initialize the callback */
ExInitializeRundownProtection(&Callback->RundownRef);
Callback->Function = Function;
Callback->Context = Context;
Callback->PendingDelete = FALSE;
/* add it to the callback list and receive a cookie for the callback */
ExAcquireFastMutex(&CmiCallbackLock);
/* FIXME - to receive a unique cookie we'll just return the pointer to the
callback object */
Callback->Cookie.QuadPart = (ULONG_PTR)Callback;
InsertTailList(&CmiCallbackHead, &Callback->ListEntry);
ExReleaseFastMutex(&CmiCallbackLock);
*Cookie = Callback->Cookie;
return STATUS_SUCCESS;
}
return STATUS_INSUFFICIENT_RESOURCES;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
CmUnRegisterCallback(IN LARGE_INTEGER Cookie)
{
PLIST_ENTRY CurrentEntry;
PREGISTRY_CALLBACK CurrentCallback;
PAGED_CODE();
ExAcquireFastMutex(&CmiCallbackLock);
for (CurrentEntry = CmiCallbackHead.Flink;
CurrentEntry != &CmiCallbackHead;
CurrentEntry = CurrentEntry->Flink)
{
CurrentCallback = CONTAINING_RECORD(CurrentEntry, REGISTRY_CALLBACK, ListEntry);
if (CurrentCallback->Cookie.QuadPart == Cookie.QuadPart)
{
if (!CurrentCallback->PendingDelete)
{
/* found the callback, don't unlink it from the list yet so we don't screw
the calling loop */
CurrentCallback->PendingDelete = TRUE;
ExReleaseFastMutex(&CmiCallbackLock);
/* if the callback is currently executing, wait until it finished */
ExWaitForRundownProtectionRelease(&CurrentCallback->RundownRef);
/* time to unlink it. It's now safe because every attempt to acquire a
runtime protection on this callback will fail */
ExAcquireFastMutex(&CmiCallbackLock);
RemoveEntryList(&CurrentCallback->ListEntry);
ExReleaseFastMutex(&CmiCallbackLock);
/* free the callback */
ExFreePool(CurrentCallback);
return STATUS_SUCCESS;
}
else
{
/* pending delete, pretend like it already is deleted */
ExReleaseFastMutex(&CmiCallbackLock);
return STATUS_UNSUCCESSFUL;
}
}
}
ExReleaseFastMutex(&CmiCallbackLock);
return STATUS_UNSUCCESSFUL;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,143 +0,0 @@
=========================
-== Cm Rewrite Branch ==-
=========================
-= At a Glance =-
Owner: Alex Ionescu (alex.ionescu@reactos.org)
ETC: 1st October 2007
Purose: Rewriting the Configuration Manager nearly from scratch.
-= Design Goals =-
Get rid of the outdated, deprecated and mostly incorrect Configuration Manager
in ReactOS (ntoskrnl\cm) and replace it with a version that is 100% compatible
with Windows NT internally as well as externally. The following key semantics
will be highly prioritized:
- Locality: The NT Configuration Manager dedicates a large part of its inner
functionality to the implementation of a memory cache whose main
component, the KCB (Key Control Block) serves as a mechanism to
store the most frequently used data in a key node. Other parts
are also present, such as the NCBs (Name Control Blocks) which
are used to store key names in a compressed and hashed/prefixed
form and delayed close and private allocations, which allow
re-using pool memory and delaying deletion for better paralel-
lism.
- Scalability and Thread Safety/MP: The NT Configuration Manager is also
extremly scalable and has over 8 highly-scalable locks (based on
the pushlock implementation, and also guarded mutex) which also
allow shared lock semantics (exclusive vs shared locks). This
implementation allows for various operations to happen simulta-
nously on a hive, while still maintaining full thread safety,
due to the fact that key structures are separated and have their
own locks.
- Reliability: The NT Configuration Manager offers a variety of complex
algorithms which continously check the state of a loaded hive or
a hive that is being loaded, as well as per-key node damage.
Furthermore, upon detection of a damaged node, the Configuration
Manager is often able to repair the Registry and bring it back
to a usable state, through a process called self healing.
- Object-Oriented: Like many other core structures in NT, the Configuration
Manager exposes its interfaces to drivers and user-mode through
the Key Object, which is an abstraction and interface that is
setup with the Object Manager. The Configuration Manager uses
its own internal namespace for managing keys (much like FSDs),
and does not depend on the much slower generic Object Manager
direction namespace. It provides a full suite of Object Routines
for Parse, Open, Close and Security callbacks, giving it full
access to the Key Object and allowing the optimization of look-
ups and respect of complex semantics such as those of security
or registry symbolic linking.
-= Sources =-
The reimplementation of the NT Configuration Manager benefits from an extensive
amount of assertions (ASSERT) and debug messages present in checked builds of
the Windows NT 5.2 Kernel. These assertions, extracted with a simple clean-room
tool such as "findstr", "strings" or "grep", allow a great understanding of the
internal macros, definitions and inner semantics of the original code. Further,
the tracing macros in the code allow for highly detailed analysis of the code
flow behind the Cm code in NT, even up to dumping parameters sent to each and
every internal function in the code, most of which also print out information
at up to every 5 lines of code or so. Mixed with the public symbolic data, this
allows for the creation of complex call flow analysis that includes the names
of global variables as well. All these methods are fully clean, since they rely
on textual messages printed to the debugger, or strings dumped from the image
or public symbol database (PDB file).
As far as references go, Mark Russinovich has written one or two interesting
papers on the topic, which also deal with some internals, as well as chapter
4, section 1, in the Windows Internals 4th Edition book, which explains some of
the internals behind KCBs, NCBs and Key Objects. Chapter 9 of Windows Internals
II also has some high-level information on the Registry.
Finally, the KD Extension DLL that comes with WinDBG has an extensive array of
helper commands to dump all sorts of registry internals, and allows converting
between hex values of various structure flags to their actual names. Combined
with assertions, this allows us to create almost entirely all the needed types
and definitions for a compatible internal implementation.
-= Current State =-
**As of 04/08/2006
~40-50% of the Initialization code is complete.
~60% of the KCB/NCB code is complete.
Blocking on cmlib being modified to use actual NT _HHIVE.
**As of 16/08/2006
~90% of the KCB/NCB code is complete.
Work about to resume on initialization code.
**As of 6/10/2006
~90% of the KCB/NCB code is complete.
~70% of Initialization code is complete.
**As of 11/5/2007
Significant parts of the rewrite have been merged in and bugfixed with
existing cm code into the main tree, in the /config directory.
~100% of the Initialization code is now complete, including reading the
System Control Vector.
~80% of the ARC Hardware Configuration Node/Tree code has been written.
It has been decided to stick with internal NT names since this simplifies
PDB and Internet lookups, even though some of these names aren't fully to my
taste.
TODOs:
Write Driver-list APIs directly into main branch since they should be low-
level enough to bypass the Object Manager interface (just like the System
Vector code).
Fix Cm Wrapper routines to read/write in chunks of 64K to avoid issues when
working with a large set of data (this is what NT does as well).
Try to make more code in trunk to use CmpOpenHiveFiles instead of the code
being used now.
Modify FreeLDR to actually send an ARC Configuration Root Tree instead of
writing to the hardware hive itself.
Once the above is done, modify current hacks to handle proper hardware hive
creation and initialization.
Once the above is done, merge trunk back into the Cm Rewrite branch, and
resume work on rewrite when will/time is available.
-= Structure =-
cmapi.c - Contains the low-level Cmp APIs that correspond to the external Nt
APIs such as NtReadKeyValue, NtCreateKey, etc.
cmhive.c - Contains all the functions related to the creation, initialization
and manipulation of registry hives.
cmindex.c - Contains functions related to cell indexes.
cminit.c - Contains the initialization/shutdown code for the NT Configuration
Manager, as well as any strictly internal initialization routines.
cmkcbncb.c - Contains functions related to the creation, initialization and
manipulation of Key Control Blocks (KCB) and Name Control Blocks.
cmname.c - Contains functions related to the manipulation of key names and/or
paths.
cmobject.c - Contains the implementation of the key object that is exported to
the Object Manager.
cmutil.c - Contains utility functions such as the registry lock and delayed
item allocation and de-allocation routines.
ntapi.c - Contains the Nt APIs exported to drivers and user-mode, which wrap
around other internal APIs in this module (mostly cmapi.c).

View File

@@ -1,894 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/cm/cminit.c
* PURPOSE: Initialization and generic utility routines
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
#include "cm.h"
UNICODE_STRING CmRegistryMachineSystemName =
RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM");
UNICODE_STRING CmpSystemFileName =
RTL_CONSTANT_STRING(L"SYSTEM");
BOOLEAN CmpMiniNTBoot;
BOOLEAN CmpShareSystemHives;
ULONG CmpBootType;
BOOLEAN CmpSpecialBootCondition;
BOOLEAN CmpFlushOnLockRelease;
PEPROCESS CmpSystemProcess;
PCMHIVE CmpMasterHive;
HANDLE CmpRegistryRootHandle;
BOOLEAN CmSelfHeal, CmpSelfHeal;
KGUARDED_MUTEX CmpSelfHealQueueLock;
LIST_ENTRY CmpSelfHealQueueListHead;
EX_PUSH_LOCK CmpLoadHiveLock;
UNICODE_STRING CmpSystemStartOptions;
UNICODE_STRING CmpLoadOptions;
ULONG CmpCallBackCount;
GENERIC_MAPPING CmpKeyMapping =
{
KEY_READ,
KEY_WRITE,
KEY_EXECUTE,
KEY_ALL_ACCESS
};
EX_CALLBACK CmpCallBackVector[CMP_MAX_CALLBACKS];
PVOID NTAPI CmpRosGetHardwareHive(OUT PULONG Length);
/* FUNCTIONS *****************************************************************/
PVOID
NTAPI
CmpRosGetHardwareHive(OUT PULONG Length)
{
PLIST_ENTRY ListHead, NextEntry;
PMEMORY_ALLOCATION_DESCRIPTOR MdBlock = NULL;
/* Loop the memory descriptors */
ListHead = &KeLoaderBlock->MemoryDescriptorListHead;
NextEntry = ListHead->Flink;
while (NextEntry != ListHead)
{
/* Get the current block */
MdBlock = CONTAINING_RECORD(NextEntry,
MEMORY_ALLOCATION_DESCRIPTOR,
ListEntry);
/* Check if this is an registry block */
if (MdBlock->MemoryType == LoaderRegistryData)
{
/* Check if it's not the SYSTEM hive that we already initialized */
if ((MdBlock->BasePage) !=
(((ULONG_PTR)KeLoaderBlock->RegistryBase &~ KSEG0_BASE) >> PAGE_SHIFT))
{
/* Hardware hive break out */
break;
}
}
/* Go to the next block */
NextEntry = MdBlock->ListEntry.Flink;
}
/* We need a hardware hive */
ASSERT(MdBlock);
*Length = MdBlock->PageCount << PAGE_SHIFT;
return (PVOID)((MdBlock->BasePage << PAGE_SHIFT) | KSEG0_BASE);
}
NTSTATUS
NTAPI
CmpCreateObjectTypes(VOID)
{
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
UNICODE_STRING Name;
GENERIC_MAPPING CmpKeyMapping = {KEY_READ,
KEY_WRITE,
KEY_EXECUTE,
KEY_ALL_ACCESS};
PAGED_CODE();
/* Initialize the Key object type */
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
RtlInitUnicodeString(&Name, L"Key");
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
ObjectTypeInitializer.DefaultPagedPoolCharge = sizeof(CM_KEY_BODY);
ObjectTypeInitializer.GenericMapping = CmpKeyMapping;
ObjectTypeInitializer.PoolType = PagedPool;
ObjectTypeInitializer.ValidAccessMask = KEY_ALL_ACCESS;
ObjectTypeInitializer.UseDefaultObject = TRUE;
ObjectTypeInitializer.DeleteProcedure = CmpDeleteKeyObject;
ObjectTypeInitializer.ParseProcedure = CmpParseKey;
ObjectTypeInitializer.SecurityProcedure = CmpSecurityMethod;
ObjectTypeInitializer.QueryNameProcedure = CmpQueryKeyName;
//ObjectTypeInitializer.CloseProcedure = CmpCloseKeyObject;
ObjectTypeInitializer.SecurityRequired = TRUE;
/* Create it */
return ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &CmpKeyObjectType);
}
BOOLEAN
NTAPI
CmpCreateRootNode(IN PHHIVE Hive,
IN PWCHAR Name,
OUT HCELL_INDEX *Index)
{
UNICODE_STRING KeyName;
PCELL_DATA Cell;
LARGE_INTEGER SystemTime;
PAGED_CODE();
/* Initialize the node name and allocate it */
RtlInitUnicodeString(&KeyName, Name);
*Index = HvAllocateCell(Hive,
FIELD_OFFSET(CM_KEY_NODE, Name) +
CmpNameSize(Hive, &KeyName),
Stable,
HCELL_NIL);
if (*Index == HCELL_NIL) return FALSE;
/* Set the cell index and get the data */
Hive->BaseBlock->RootCell = *Index;
Cell = HvGetCell(Hive, *Index);
/* Fill out the cell */
Cell->u.KeyNode.Signature = (USHORT)CM_KEY_NODE_SIGNATURE;
Cell->u.KeyNode.Flags = KEY_HIVE_ENTRY | KEY_NO_DELETE;
KeQuerySystemTime(&SystemTime);
Cell->u.KeyNode.LastWriteTime = SystemTime;
Cell->u.KeyNode.Parent = HCELL_NIL;
Cell->u.KeyNode.SubKeyCounts[Stable] = 0;
Cell->u.KeyNode.SubKeyCounts[Volatile] = 0;
Cell->u.KeyNode.SubKeyLists[Stable] = 0;
Cell->u.KeyNode.SubKeyLists[Volatile] = 0;
Cell->u.KeyNode.ValueList.Count = 0;
Cell->u.KeyNode.ValueList.List = HCELL_NIL;
Cell->u.KeyNode.Class = HCELL_NIL;
Cell->u.KeyNode.MaxValueDataLen = 0;
Cell->u.KeyNode.MaxNameLen = 0;
Cell->u.KeyNode.MaxValueNameLen = 0;
Cell->u.KeyNode.MaxClassLen = 0;
/* Copy the name (this will also set the length) */
Cell->u.KeyNode.NameLength = CmpCopyName(Hive,
Cell->u.KeyNode.Name,
&KeyName);
/* Check if the name was compressed */
if (Cell->u.KeyNode.NameLength < KeyName.Length)
{
/* Set the flag */
Cell->u.KeyNode.Flags |= KEY_COMP_NAME;
}
/* Return success */
HvReleaseCell(Hive, *Index);
return TRUE;
}
BOOLEAN
NTAPI
CmpCreateRegistryRoot(VOID)
{
UNICODE_STRING KeyName;
OBJECT_ATTRIBUTES ObjectAttributes;
PCM_KEY_BODY RootKey;
HCELL_INDEX RootIndex;
NTSTATUS Status;
PCM_KEY_NODE KeyCell;
PSECURITY_DESCRIPTOR SecurityDescriptor;
PCM_KEY_CONTROL_BLOCK Kcb;
PAGED_CODE();
/* Setup the root node */
if (!CmpCreateRootNode(&CmpMasterHive->Hive, L"REGISTRY", &RootIndex))
{
/* We failed */
DPRINT1("Fail\n");
return FALSE;
}
/* Create '\Registry' key. */
RtlInitUnicodeString(&KeyName, L"\\Registry");
SecurityDescriptor = CmpHiveRootSecurityDescriptor();
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = ObCreateObject(KernelMode,
CmpKeyObjectType,
&ObjectAttributes,
KernelMode,
NULL,
sizeof(CM_KEY_BODY),
0,
0,
(PVOID*)&RootKey);
ExFreePool(SecurityDescriptor);
if (!NT_SUCCESS(Status)) return FALSE;
/* Sanity check, and get the key cell */
ASSERT((&CmpMasterHive->Hive)->ReleaseCellRoutine == NULL);
KeyCell = (PCM_KEY_NODE)HvGetCell(&CmpMasterHive->Hive, RootIndex);
if (!KeyCell) return FALSE;
/* Create the KCB */
RtlInitUnicodeString(&KeyName, L"Registry");
Kcb = CmpCreateKeyControlBlock(&CmpMasterHive->Hive,
RootIndex,
KeyCell,
NULL,
0,
&KeyName);
if (!Kcb) return FALSE;
/* Setup the key */
RootKey->Type = TAG('k', 'v', '0', '2');
RootKey->KeyControlBlock = Kcb;
RootKey->NotifyBlock = NULL;
RootKey->ProcessID = PsGetCurrentProcessId();
/* Enlist it */
EnlistKeyBodyWithKCB(RootKey, 0);
/* Insert the key */
Status = ObInsertObject(RootKey,
NULL,
KEY_ALL_ACCESS,
0,
NULL,
&CmpRegistryRootHandle);
if (!NT_SUCCESS(Status)) return FALSE;
/* Now reference it as a keep alive and return the status */
Status = ObReferenceObjectByHandle(CmpRegistryRootHandle,
KEY_READ,
NULL,
KernelMode,
(PVOID*)&RootKey,
NULL);
if (!NT_SUCCESS(Status)) return FALSE;
/* Completely sucessful */
return TRUE;
}
VOID
NTAPI
CmpInitializeCallbacks(VOID)
{
ULONG i;
PAGED_CODE();
/* Reset counter */
CmpCallBackCount = 0;
/* Loop all the callbacks */
for (i = 0; i < CMP_MAX_CALLBACKS; i++)
{
/* Initialize this one */
ExInitializeCallBack(&CmpCallBackVector[i]);
}
}
NTSTATUS
NTAPI
CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName, ValueName;
HANDLE KeyHandle;
NTSTATUS Status;
ASSERT(LoaderBlock != NULL);
if (ExpInTextModeSetup) return STATUS_SUCCESS;
/* Setup attributes for loader options */
RtlInitUnicodeString(&KeyName,
L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\"
L"Control");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtOpenKey(&KeyHandle, KEY_WRITE, &ObjectAttributes);
if (!NT_SUCCESS(Status)) goto Quickie;
/* Key opened, now write to the key */
RtlInitUnicodeString(&KeyName, L"SystemStartOptions");
Status = NtSetValueKey(KeyHandle,
&KeyName,
0,
REG_SZ,
CmpLoadOptions.Buffer,
CmpLoadOptions.Length);
if (!NT_SUCCESS(Status)) goto Quickie;
/* Setup value name for system boot device */
RtlInitUnicodeString(&KeyName, L"SystemBootDevice");
RtlCreateUnicodeStringFromAsciiz(&ValueName, LoaderBlock->NtBootPathName);
Status = NtSetValueKey(KeyHandle,
&KeyName,
0,
REG_SZ,
ValueName.Buffer,
ValueName.Length);
Quickie:
/* Free the buffers */
RtlFreeUnicodeString(&ValueName);
/* Close the key and return */
NtClose(KeyHandle);
/* Return the status */
return Status;
}
BOOLEAN
NTAPI
CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
PCMHIVE SystemHive;
PVOID HiveImageBase;
BOOLEAN Allocate = FALSE;
PSECURITY_DESCRIPTOR SecurityDescriptor;
NTSTATUS Status;
STRING TempString;
PAGED_CODE();
/* Create ANSI_STRING from the loader options */
RtlInitAnsiString(&TempString, LoaderBlock->LoadOptions);
/* Setup UNICODE_STRING */
CmpLoadOptions.Length = 0;
CmpLoadOptions.MaximumLength = TempString.Length * sizeof(WCHAR) +
sizeof(UNICODE_NULL);
CmpLoadOptions.Buffer = ExAllocatePoolWithTag(PagedPool,
CmpLoadOptions.MaximumLength,
TAG_CM);
if (!CmpLoadOptions.Buffer)
{
/* Fail */
KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 5, 6, 0, 0);
}
/* Convert it to Unicode and nul-terminate it */
RtlAnsiStringToUnicodeString(&CmpLoadOptions, &TempString, FALSE);
CmpLoadOptions.Buffer[TempString.Length] = UNICODE_NULL;
CmpLoadOptions.Length += sizeof(WCHAR);
/* Get the image base */
HiveImageBase = LoaderBlock->RegistryBase;
if (!HiveImageBase)
{
/* Don't have a system hive, create it */
Status = CmpInitializeHive(&SystemHive,
HINIT_CREATE,
HIVE_NOLAZYFLUSH,
HFILE_TYPE_LOG,
NULL,
NULL,
NULL,
NULL,
&CmpSystemFileName,
0);
if (!NT_SUCCESS(Status)) return FALSE;
Allocate = TRUE;
}
else
{
/* Make a copy of the loaded hive */
Status = CmpInitializeHive(&SystemHive,
HINIT_MEMORY,
0,
HFILE_TYPE_LOG,
HiveImageBase,
NULL,
NULL,
NULL,
&CmpSystemFileName,
2);
if (!NT_SUCCESS(Status)) return FALSE;
/* Check if we loaded with shared hives */
if (CmpShareSystemHives) SystemHive->Hive.HvBinHeadersUse = 0;
/* Set the boot type */
CmpBootType = SystemHive->Hive.BaseBlock->BootType;
/* Check if we loaded in self-healing mode */
if (!CmSelfHeal)
{
/* We didn't, check the boot type */
if (CmpBootType & 4)
{
/* Invalid boot type */
CmpSelfHeal = FALSE;
KeBugCheckEx(REGISTRY_ERROR, 3, 3, (ULONG_PTR)SystemHive, 0);
}
}
}
/* Create security descriptor */
SecurityDescriptor = CmpHiveRootSecurityDescriptor();
/* Link the hive to the master */
Status = CmpLinkHiveToMaster(&CmRegistryMachineSystemName,
NULL,
SystemHive,
Allocate,
SecurityDescriptor);
/* Free the descriptor and check for success */
ExFreePool(SecurityDescriptor);
if (!NT_SUCCESS(Status)) return FALSE;
/* Save the hive */
CmpMachineHiveList[3].CmHive = SystemHive;
return TRUE;
}
NTSTATUS
NTAPI
CmpCreateControlSet(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
UNICODE_STRING ConfigName = RTL_CONSTANT_STRING(L"Control\\IDConfigDB");
UNICODE_STRING SelectName =
RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\Select");
UNICODE_STRING KeyName;
OBJECT_ATTRIBUTES ObjectAttributes;
CHAR ValueInfoBuffer[128];
PKEY_VALUE_FULL_INFORMATION ValueInfo;
CHAR Buffer[128];
WCHAR UnicodeBuffer[128];
HANDLE SelectHandle, KeyHandle, ConfigHandle = NULL, ProfileHandle = NULL;
HANDLE ParentHandle = NULL;
ULONG ControlSet, HwProfile;
ANSI_STRING TempString;
NTSTATUS Status;
ULONG ResultLength, Disposition;
PLOADER_PARAMETER_EXTENSION LoaderExtension;
PAGED_CODE();
if (ExpInTextModeSetup) return STATUS_SUCCESS;
/* Open the select key */
InitializeObjectAttributes(&ObjectAttributes,
&SelectName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtOpenKey(&SelectHandle, KEY_READ, &ObjectAttributes);
if (!NT_SUCCESS(Status)) return(Status);
/* Open the current value */
RtlInitUnicodeString(&KeyName, L"Current");
Status = NtQueryValueKey(SelectHandle,
&KeyName,
KeyValueFullInformation,
ValueInfoBuffer,
sizeof(ValueInfoBuffer),
&ResultLength);
NtClose(SelectHandle);
if (!NT_SUCCESS(Status)) return Status;
/* Get the actual value pointer, and get the control set ID */
ValueInfo = (PKEY_VALUE_FULL_INFORMATION)ValueInfoBuffer;
ControlSet = *(PULONG)((PUCHAR)ValueInfo + ValueInfo->DataOffset);
/* Create the current control set key */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\System\\CurrentControlSet");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtCreateKey(&KeyHandle,
KEY_CREATE_LINK,
&ObjectAttributes,
0,
NULL,
REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK,
&Disposition);
if (!NT_SUCCESS(Status)) return Status;
/* Sanity check */
ASSERT(Disposition == REG_CREATED_NEW_KEY);
/* Initialize the symbolic link name */
sprintf(Buffer,
"\\Registry\\Machine\\System\\ControlSet%03ld",
ControlSet);
RtlInitAnsiString(&TempString, Buffer);
/* Create a Unicode string out of it */
KeyName.MaximumLength = sizeof(UnicodeBuffer);
KeyName.Buffer = UnicodeBuffer;
Status = RtlAnsiStringToUnicodeString(&KeyName, &TempString, FALSE);
/* Set the value */
Status = NtSetValueKey(KeyHandle,
&CmSymbolicLinkValueName,
0,
REG_LINK,
KeyName.Buffer,
KeyName.Length);
if (!NT_SUCCESS(Status)) return Status;
/* Get the configuration database key */
InitializeObjectAttributes(&ObjectAttributes,
&ConfigName,
OBJ_CASE_INSENSITIVE,
KeyHandle,
NULL);
Status = NtOpenKey(&ConfigHandle, KEY_READ, &ObjectAttributes);
NtClose(KeyHandle);
/* Check if we don't have one */
if (!NT_SUCCESS(Status))
{
/* Cleanup and exit */
ConfigHandle = 0;
goto Cleanup;
}
/* Now get the current config */
RtlInitUnicodeString(&KeyName, L"CurrentConfig");
Status = NtQueryValueKey(ConfigHandle,
&KeyName,
KeyValueFullInformation,
ValueInfoBuffer,
sizeof(ValueInfoBuffer),
&ResultLength);
/* Set pointer to buffer */
ValueInfo = (PKEY_VALUE_FULL_INFORMATION)ValueInfoBuffer;
/* Check if we failed or got a non DWORD-value */
if (!(NT_SUCCESS(Status)) || (ValueInfo->Type != REG_DWORD)) goto Cleanup;
/* Get the hadware profile */
HwProfile = *(PULONG)((PUCHAR)ValueInfo + ValueInfo->DataOffset);
/* Open the hardware profile key */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\System\\CurrentControlSet"
L"\\Hardware Profiles");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtOpenKey(&ParentHandle, KEY_READ, &ObjectAttributes);
if (!NT_SUCCESS(Status))
{
/* Exit and clean up */
ParentHandle = 0;
goto Cleanup;
}
/* Build the profile name */
sprintf(Buffer, "%04ld", HwProfile);
RtlInitAnsiString(&TempString, Buffer);
/* Convert it to Unicode */
KeyName.MaximumLength = sizeof(UnicodeBuffer);
KeyName.Buffer = UnicodeBuffer;
Status = RtlAnsiStringToUnicodeString(&KeyName,
&TempString,
FALSE);
ASSERT(Status == STATUS_SUCCESS);
/* Open the associated key */
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
ParentHandle,
NULL);
Status = NtOpenKey(&ProfileHandle,
KEY_READ | KEY_WRITE,
&ObjectAttributes);
if (!NT_SUCCESS (Status))
{
/* Cleanup and exit */
ProfileHandle = 0;
goto Cleanup;
}
/* Check if we have a loader block extension */
LoaderExtension = LoaderBlock->Extension;
if (LoaderExtension)
{
ASSERTMSG("ReactOS doesn't support NTLDR Profiles yet!\n", FALSE);
}
/* Create the current hardware profile key */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\System\\CurrentControlSet\\"
L"Hardware Profiles\\Current");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtCreateKey(&KeyHandle,
KEY_CREATE_LINK,
&ObjectAttributes,
0,
NULL,
REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK,
&Disposition);
if (NT_SUCCESS(Status))
{
/* Sanity check */
ASSERT(Disposition == REG_CREATED_NEW_KEY);
/* Create the profile name */
sprintf(Buffer,
"\\Registry\\Machine\\System\\CurrentControlSet\\"
"Hardware Profiles\\%04ld",
HwProfile);
RtlInitAnsiString(&TempString, Buffer);
/* Convert it to Unicode */
KeyName.MaximumLength = sizeof(UnicodeBuffer);
KeyName.Buffer = UnicodeBuffer;
Status = RtlAnsiStringToUnicodeString(&KeyName,
&TempString,
FALSE);
ASSERT(STATUS_SUCCESS == Status);
/* Set it */
Status = NtSetValueKey(KeyHandle,
&CmSymbolicLinkValueName,
0,
REG_LINK,
KeyName.Buffer,
KeyName.Length);
NtClose(KeyHandle);
}
/* Close every opened handle */
Cleanup:
if (ConfigHandle) NtClose(ConfigHandle);
if (ProfileHandle) NtClose(ProfileHandle);
if (ParentHandle) NtClose(ParentHandle);
/* Return success */
return STATUS_SUCCESS;
}
BOOLEAN
NTAPI
CmInitSystem1(VOID)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
HANDLE KeyHandle;
NTSTATUS Status;
PVOID BaseAddress;
ULONG Length;
PSECURITY_DESCRIPTOR SecurityDescriptor;
PCMHIVE HardwareHive;
PAGED_CODE();
/* Check if this is PE-boot */
if (InitIsWinPEMode)
{
/* Set registry to PE mode */
CmpMiniNTBoot = TRUE;
CmpShareSystemHives = TRUE;
}
/* Initialize the hive list and lock */
InitializeListHead(&CmpHiveListHead);
ExInitializePushLock((PVOID)&CmpHiveListHeadLock);
ExInitializePushLock((PVOID)&CmpLoadHiveLock);
/* Initialize registry lock */
ExInitializeResourceLite(&CmpRegistryLock);
/* Initialize the cache */
CmpInitializeCache();
/* Initialize allocation and delayed dereferencing */
CmpInitCmPrivateAlloc();
CmpInitCmPrivateDelayAlloc();
CmpInitDelayDerefKCBEngine();
/* Initialize callbacks */
CmpInitCallback();
/* Initialize self healing */
KeInitializeGuardedMutex(&CmpSelfHealQueueLock);
InitializeListHead(&CmpSelfHealQueueListHead);
/* Save the current process and lock the registry */
CmpSystemProcess = PsGetCurrentProcess();
/* Create the key object types */
Status = CmpCreateObjectTypes();
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 1, Status, 0);
}
/* Create master hive */
Status = CmpInitializeHive(&CmpMasterHive,
HINIT_CREATE,
HIVE_VOLATILE | 2, //HIVE_NO_FILE ROS
HFILE_TYPE_PRIMARY,
NULL,
NULL,
NULL,
NULL,
NULL,
0);
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 2, Status, 0);
}
/* Create the \REGISTRY key node */
if (!CmpCreateRegistryRoot())
{
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 3, 0, 0);
}
/* Create the default security descriptor */
SecurityDescriptor = CmpHiveRootSecurityDescriptor();
/* Create '\Registry\Machine' key. */
RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\MACHINE");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtCreateKey(&KeyHandle,
KEY_READ | KEY_WRITE,
&ObjectAttributes,
0,
NULL,
0,
NULL);
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 5, Status, 0);
}
/* Close the handle */
NtClose(KeyHandle);
/* Create '\Registry\User' key. */
RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\USER");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtCreateKey(&KeyHandle,
KEY_READ | KEY_WRITE,
&ObjectAttributes,
0,
NULL,
0,
NULL);
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 6, Status, 0);
}
/* Close the handle */
NtClose(KeyHandle);
/* Initialize and load the system hive */
if (!CmpInitializeSystemHive(KeLoaderBlock))
{
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 7, 0, 0);
}
/* Create the CCS symbolic link */
Status = CmpCreateControlSet(KeLoaderBlock);
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 8, Status, 0);
}
/* Import the hardware hive (FIXME: We should create it from scratch) */
BaseAddress = CmpRosGetHardwareHive(&Length);
((PHBASE_BLOCK)BaseAddress)->Length = Length;
Status = CmpInitializeHive((PCMHIVE*)&HardwareHive,
HINIT_MEMORY, //HINIT_CREATE,
HIVE_VOLATILE,
HFILE_TYPE_PRIMARY,
BaseAddress, // NULL,
NULL,
NULL,
NULL,
NULL,
0);
CmPrepareHive(&HardwareHive->Hive);
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 11, Status, 0);
}
/* Attach it to the machine key */
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\HARDWARE");
Status = CmpLinkHiveToMaster(&KeyName,
NULL,
(PCMHIVE)HardwareHive,
FALSE,
SecurityDescriptor);
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 12, Status, 0);
}
/* Fill out the Hardware key with the ARC Data from the Loader */
Status = CmpInitializeHardwareConfiguration(KeLoaderBlock);
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 13, Status, 0);
}
/* Initialize machine-dependent information into the registry */
Status = CmpInitializeMachineDependentConfiguration(KeLoaderBlock);
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 14, Status, 0);
}
/* Initialize volatile registry settings */
Status = CmpSetSystemValues(KeLoaderBlock);
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 15, Status, 0);
}
/* Free the load options */
ExFreePool(CmpLoadOptions.Buffer);
/* If we got here, all went well */
return TRUE;
}
VOID
CmShutdownRegistry(VOID)
{
return;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,254 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmname.c
* PURPOSE: Configuration Manager - Name Management
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "cm.h"
#define NDEBUG
#include "debug.h"
/* GLOBALS *******************************************************************/
/* FUNCTIONS *****************************************************************/
USHORT
NTAPI
CmpCopyName(IN PHHIVE Hive,
IN PWCHAR Destination,
IN PUNICODE_STRING Source)
{
ULONG i;
/* Check for old hives */
if (Hive->Version == 1)
{
/* Just copy the source directly */
RtlCopyMemory(Destination, Source->Buffer, Source->Length);
return Source->Length;
}
/* For new versions, check for compressed name */
for (i = 0; i < (Source->Length / sizeof(WCHAR)); i++)
{
/* Check if the name is non compressed */
if (Source->Buffer[i] > (UCHAR)-1)
{
/* Do the copy */
RtlCopyMemory(Destination, Source->Buffer, Source->Length);
return Source->Length;
}
/* Copy this character */
((PCHAR)Destination)[i] = (CHAR)(Source->Buffer[i]);
}
/* Compressed name, return length */
return Source->Length / sizeof(WCHAR);
}
VOID
NTAPI
CmpCopyCompressedName(IN PWCHAR Destination,
IN ULONG DestinationLength,
IN PWCHAR Source,
IN ULONG SourceLength)
{
ULONG i, Length;
/* Get the actual length to copy */
Length = min(DestinationLength / sizeof(WCHAR), SourceLength);
for (i = 0; i < Length; i++)
{
/* Copy each character */
Destination[i] = (WCHAR)((PCHAR)Source)[i];
}
}
USHORT
NTAPI
CmpNameSize(IN PHHIVE Hive,
IN PUNICODE_STRING Name)
{
ULONG i;
/* For old hives, just retun the length */
if (Hive->Version == 1) return Name->Length;
/* For new versions, check for compressed name */
for (i = 0; i < (Name->Length / sizeof(WCHAR)); i++)
{
/* Check if the name is non compressed */
if (Name->Buffer[i] > (UCHAR)-1) return Name->Length;
}
/* Compressed name, return length */
return Name->Length / sizeof(WCHAR);
}
USHORT
NTAPI
CmpCompressedNameSize(IN PWCHAR Name,
IN ULONG Length)
{
/*
* Don't remove this: compressed names are "opaque" and just because
* the current implementation turns them into ansi-names doesn't mean
* that it will remain that way forever, so -never- assume this code
* below internally!
*/
return (USHORT)Length * sizeof(WCHAR);
}
LONG
NTAPI
CmpCompareCompressedName(IN PCUNICODE_STRING SearchName,
IN PWCHAR CompressedName,
IN ULONG NameLength)
{
WCHAR *p;
CHAR *pp;
WCHAR p1, p2;
USHORT SearchLength;
LONG Result;
/* Set the pointers and length and then loop */
p = SearchName->Buffer;
pp = (PCHAR)CompressedName;
SearchLength = (SearchName->Length / sizeof(WCHAR));
while ((SearchLength) && (NameLength))
{
/* Get the characters */
p1 = *p++;
p2 = (WCHAR)(*pp++);
/* Check if we have a direct match */
if (p1 != p2)
{
/* See if they match and return result if they don't */
Result = (LONG)RtlUpcaseUnicodeChar(p1) -
(LONG)RtlUpcaseUnicodeChar(p2);
if (Result) return Result;
}
/* Next chars */
SearchLength--;
NameLength--;
}
/* Return the difference directly */
return SearchLength - NameLength;
}
BOOLEAN
NTAPI
CmpFindNameInList(IN PHHIVE Hive,
IN PCHILD_LIST ChildList,
IN PUNICODE_STRING Name,
IN PULONG ChildIndex,
IN PHCELL_INDEX CellIndex)
{
PCELL_DATA CellData;
HCELL_INDEX CellToRelease = HCELL_NIL;
ULONG i;
PCM_KEY_VALUE KeyValue;
LONG Result;
UNICODE_STRING SearchName;
BOOLEAN Success;
/* Make sure there's actually something on the list */
if (ChildList->Count != 0)
{
/* Get the cell data */
CellData = (PCELL_DATA)HvGetCell(Hive, ChildList->List);
if (!CellData)
{
/* Couldn't get the cell... tell the caller */
*CellIndex = HCELL_NIL;
return FALSE;
}
/* Now loop every entry */
for (i = 0; i < ChildList->Count; i++)
{
/* Check if we have a cell to release */
if (CellToRelease != HCELL_NIL)
{
/* Release it */
HvReleaseCell(Hive, CellToRelease);
CellToRelease = HCELL_NIL;
}
/* Get this value */
KeyValue = (PCM_KEY_VALUE)HvGetCell(Hive, CellData->u.KeyList[i]);
if (!KeyValue)
{
/* Return with no data found */
*CellIndex = HCELL_NIL;
Success = FALSE;
goto Return;
}
/* Save the cell to release */
CellToRelease = CellData->u.KeyList[i];
/* Check if it's a compressed value name */
if (KeyValue->Flags & VALUE_COMP_NAME)
{
/* Use the compressed name check */
Result = CmpCompareCompressedName(Name,
KeyValue->Name,
KeyValue->NameLength);
}
else
{
/* Setup the Unicode string */
SearchName.Length = KeyValue->NameLength;
SearchName.MaximumLength = SearchName.Length;
SearchName.Buffer = KeyValue->Name;
Result = RtlCompareUnicodeString(Name, &SearchName, TRUE);
}
/* Check if we found it */
if (!Result)
{
/* We did...return info to caller */
if (ChildIndex) *ChildIndex = i;
*CellIndex = CellData->u.KeyList[i];
/* Set success state */
Success = TRUE;
goto Return;
}
}
/* Got to the end of the list */
if (ChildIndex) *ChildIndex = i;
*CellIndex = HCELL_NIL;
/* Nothing found if we got here */
Success = TRUE;
goto Return;
}
/* Nothing found...check if the caller wanted more info */
ASSERT(ChildList->Count == 0);
if (ChildIndex) *ChildIndex = 0;
*CellIndex = HCELL_NIL;
/* Nothing found if we got here */
return TRUE;
Return:
/* Release the first cell we got */
if (CellData) HvReleaseCell(Hive, ChildList->List);
/* Release the secondary one, if we have one */
if (CellToRelease) HvReleaseCell(Hive, CellToRelease);
return Success;
}

View File

@@ -1,73 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/cm/cmname.c
* PURPOSE: Client-side of the Ob Callback Interface for Key Objects.
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
/* GLOBALS *******************************************************************/
POBJECT_TYPE CmpKeyObjectType;
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
CmpCloseKeyObject(IN PEPROCESS Process OPTIONAL,
IN PVOID Object,
IN ACCESS_MASK GrantedAccess,
IN ULONG ProcessHandleCount,
IN ULONG SystemHandleCount)
{
/* FIXME: TODO */
ASSERT(FALSE);
}
VOID
NTAPI
CmpDeleteKeyObject(IN PVOID Object)
{
/* FIXME: TODO */
ASSERT(FALSE);
}
NTSTATUS
NTAPI
CmpParseKey(IN PVOID ParseObject,
IN PVOID ObjectType,
IN OUT PACCESS_STATE AccessState,
IN KPROCESSOR_MODE AccessMode,
IN ULONG Attributes,
IN OUT PUNICODE_STRING CompleteName,
IN OUT PUNICODE_STRING RemainingName,
IN OUT PVOID Context OPTIONAL,
IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
OUT PVOID *Object)
{
/* FIXME: TODO */
ASSERT(FALSE);
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
CmpQueryKeyName(IN PVOID Object,
IN BOOLEAN HasObjectName,
OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
IN ULONG Length,
OUT PULONG ReturnLength,
IN KPROCESSOR_MODE AccessMode)
{
/* FIXME: TODO */
ASSERT(FALSE);
return STATUS_SUCCESS;
}

View File

@@ -1,399 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmparse.c
* PURPOSE: Configuration Manager - Object Manager Parse Interface
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "cm.h"
#define NDEBUG
#include "debug.h"
/* GLOBALS *******************************************************************/
/* FUNCTIONS *****************************************************************/
BOOLEAN
NTAPI
CmpGetNextName(IN OUT PUNICODE_STRING RemainingName,
OUT PUNICODE_STRING NextName,
OUT PBOOLEAN LastName)
{
BOOLEAN NameValid = TRUE;
/* Check if there's nothing left in the name */
if (!(RemainingName->Buffer) ||
(!RemainingName->Length) ||
!(*RemainingName->Buffer))
{
/* Clear the next name and set this as last */
*LastName = TRUE;
NextName->Buffer = NULL;
NextName->Length = 0;
return TRUE;
}
/* Check if we have a path separator */
if (*RemainingName->Buffer == OBJ_NAME_PATH_SEPARATOR)
{
/* Skip it */
RemainingName->Buffer++;
RemainingName->Length -= sizeof(WCHAR);
RemainingName->MaximumLength -= sizeof(WCHAR);
}
/* Start loop at where the current buffer is */
NextName->Buffer = RemainingName->Buffer;
while (TRUE)
{
/* Break out if we ran out or hit a path separator */
if (!(RemainingName->Length) ||
(*RemainingName->Buffer == OBJ_NAME_PATH_SEPARATOR))
{
break;
}
/* Move to the next character */
RemainingName->Buffer++;
RemainingName->Length -= sizeof(WCHAR);
RemainingName->MaximumLength -= sizeof(WCHAR);
}
/* See how many chars we parsed and validate the length */
NextName->Length = (USHORT)((ULONG_PTR)RemainingName->Buffer -
(ULONG_PTR)NextName->Buffer);
if (NextName->Length > 512) NameValid = FALSE;
NextName->MaximumLength = NextName->Length;
/* If there's nothing left, we're last */
*LastName = !RemainingName->Length;
return NameValid;
}
NTSTATUS
NTAPI
CmpDoCreateChild(IN PHHIVE Hive,
IN HCELL_INDEX ParentCell,
IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
IN PACCESS_STATE AccessState,
IN PUNICODE_STRING Name,
IN KPROCESSOR_MODE AccessMode,
IN PCM_PARSE_CONTEXT Context,
IN PCM_KEY_CONTROL_BLOCK ParentKcb,
IN USHORT Flags,
OUT PHCELL_INDEX KeyCell,
OUT PVOID *Object)
{
NTSTATUS Status = STATUS_SUCCESS;
PCM_KEY_CONTROL_BLOCK kcb;
HCELL_INDEX ClassCell = HCELL_NIL;
PCM_KEY_NODE KeyNode;
PCELL_DATA CellData;
ULONG StorageType;
LARGE_INTEGER SystemTime;
BOOLEAN Hack = FALSE;
PCM_KEY_BODY KeyBody;
/* ReactOS Hack */
if (Name->Buffer[0] == OBJ_NAME_PATH_SEPARATOR)
{
/* Skip initial path separator */
Name->Buffer++;
Name->Length -= sizeof(OBJ_NAME_PATH_SEPARATOR);
Name->MaximumLength -= sizeof(OBJ_NAME_PATH_SEPARATOR);
Hack = TRUE;
}
/* Get the storage type */
StorageType = Stable;
if (Context->CreateOptions & REG_OPTION_VOLATILE) StorageType = Volatile;
/* Allocate the child */
*KeyCell = HvAllocateCell(Hive,
FIELD_OFFSET(CM_KEY_NODE, Name) +
CmpNameSize(Hive, Name),
StorageType,
HCELL_NIL);
if (*KeyCell == HCELL_NIL)
{
/* Fail */
Status = STATUS_INSUFFICIENT_RESOURCES;
goto Quickie;
}
/* Get the key node */
KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, *KeyCell);
if (!KeyNode)
{
/* Fail, this should never happen */
ASSERT(FALSE);
Status = STATUS_INSUFFICIENT_RESOURCES;
goto Quickie;
}
/* Release the cell */
HvReleaseCell(Hive, *KeyCell);
/* Check if we have a class name */
if (Context->Class.Length > 0)
{
/* Allocate a class cell */
ClassCell = HvAllocateCell(Hive,
Context->Class.Length,
StorageType,
HCELL_NIL);
if (ClassCell == HCELL_NIL)
{
/* Fail */
Status = STATUS_INSUFFICIENT_RESOURCES;
goto Quickie;
}
}
/* Allocate the Cm Object */
Status = ObCreateObject(AccessMode,
CmpKeyObjectType,
NULL,
AccessMode,
NULL,
sizeof(CM_KEY_BODY),
0,
0,
Object);
if (!NT_SUCCESS(Status)) goto Quickie;
KeyBody = (PCM_KEY_BODY)(*Object);
/* Check if we had a class */
if (Context->Class.Length > 0)
{
/* Get the class cell */
CellData = HvGetCell(Hive, ClassCell);
if (!CellData)
{
/* Fail, this should never happen */
ASSERT(FALSE);
Status = STATUS_INSUFFICIENT_RESOURCES;
ObDereferenceObject(*Object);
goto Quickie;
}
/* Release the cell */
HvReleaseCell(Hive, ClassCell);
/* Copy the class data */
RtlCopyMemory(&CellData->u.KeyString[0],
Context->Class.Buffer,
Context->Class.Length);
}
/* Fill out the key node */
KeyNode->Signature = CM_KEY_NODE_SIGNATURE;
KeyNode->Flags = Flags;
KeQuerySystemTime(&SystemTime);
KeyNode->LastWriteTime = SystemTime;
KeyNode->Spare = 0;
KeyNode->Parent = ParentCell;
KeyNode->SubKeyCounts[Stable] = 0;
KeyNode->SubKeyCounts[Volatile] = 0;
KeyNode->SubKeyLists[Stable] = HCELL_NIL;
KeyNode->SubKeyLists[Volatile] = HCELL_NIL;
KeyNode->ValueList.Count = 0;
KeyNode->ValueList.List = HCELL_NIL;
KeyNode->Security = HCELL_NIL;
KeyNode->Class = ClassCell;
KeyNode->ClassLength = Context->Class.Length;
KeyNode->MaxValueDataLen = 0;
KeyNode->MaxNameLen = 0;
KeyNode->MaxValueNameLen = 0;
KeyNode->MaxClassLen = 0;
KeyNode->NameLength = CmpCopyName(Hive, KeyNode->Name, Name);
if (KeyNode->NameLength < Name->Length) KeyNode->Flags |= KEY_COMP_NAME;
/* Now fill out the Cm object */
kcb = CmpCreateKeyControlBlock(Hive,
*KeyCell,
KeyNode,
ParentKcb,
CMP_LOCK_HASHES_FOR_KCB, Name);
ASSERT(kcb->RefCount == 1);
KeyBody->Type = KEY_BODY_TYPE;
KeyBody->KeyControlBlock = kcb;
KeyBody->NotifyBlock = NULL;
KeyBody->ProcessID = PsGetCurrentProcessId();
EnlistKeyBodyWithKCB(KeyBody, 2);
Quickie:
/* Check if we got here because of failure */
if (!NT_SUCCESS(Status))
{
/* Free any cells we might've allocated */
if (Context->Class.Length > 0) HvFreeCell(Hive, ClassCell);
HvFreeCell(Hive, *KeyCell);
}
/* Check if we applied ReactOS hack */
if (Hack)
{
/* Restore name */
Name->Buffer--;
Name->Length += sizeof(OBJ_NAME_PATH_SEPARATOR);
Name->MaximumLength += sizeof(OBJ_NAME_PATH_SEPARATOR);
}
/* Return status */
return Status;
}
NTSTATUS
NTAPI
CmpDoCreate(IN PHHIVE Hive,
IN HCELL_INDEX Cell,
IN PACCESS_STATE AccessState,
IN PUNICODE_STRING Name,
IN KPROCESSOR_MODE AccessMode,
IN PCM_PARSE_CONTEXT Context,
IN PCM_KEY_CONTROL_BLOCK ParentKcb,
IN PCMHIVE OriginatingHive OPTIONAL,
OUT PVOID *Object)
{
NTSTATUS Status;
PCELL_DATA CellData;
HCELL_INDEX KeyCell;
ULONG ParentType;
PCM_KEY_BODY KeyBody;
PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
LARGE_INTEGER TimeStamp;
PCM_KEY_NODE KeyNode;
/* Acquire the flusher lock */
//ExAcquirePushLockShared((PVOID)&((PCMHIVE)Hive)->FlusherLock);
/* Get the parent node */
KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Cell);
if (!KeyNode)
{
/* Fail */
ASSERT(FALSE);
Status = STATUS_INSUFFICIENT_RESOURCES;
goto Exit;
}
/* Make sure nobody added us yet */
if (CmpFindSubKeyByName(Hive, KeyNode, Name) != HCELL_NIL)
{
/* Fail */
ASSERT(FALSE);
Status = STATUS_REPARSE;
goto Exit;
}
/* Sanity check */
ASSERT(Cell == ParentKcb->KeyCell);
/* Get the parent type */
ParentType = HvGetCellType(Cell);
if ((ParentType == Volatile) && !(Context->CreateOptions & REG_OPTION_VOLATILE))
{
/* Children of volatile parents must also be volatile */
ASSERT(FALSE);
Status = STATUS_CHILD_MUST_BE_VOLATILE;
goto Exit;
}
/* Don't allow children under symlinks */
if (ParentKcb->Flags & KEY_SYM_LINK)
{
/* Fail */
ASSERT(FALSE);
Status = STATUS_ACCESS_DENIED;
goto Exit;
}
/* Make the cell dirty for now */
HvMarkCellDirty(Hive, Cell, FALSE);
/* Do the actual create operation */
Status = CmpDoCreateChild(Hive,
Cell,
SecurityDescriptor,
AccessState,
Name,
AccessMode,
Context,
ParentKcb,
0,
&KeyCell,
Object);
if (NT_SUCCESS(Status))
{
/* Get the key body */
KeyBody = (PCM_KEY_BODY)(*Object);
/* Now add the subkey */
if (!CmpAddSubKey(Hive, Cell, KeyCell))
{
/* Failure! We don't handle this yet! */
ASSERT(FALSE);
}
/* Get the key node */
KeyNode = (PCM_KEY_NODE)HvGetCell(Hive, Cell);
if (!KeyNode)
{
/* Fail, this shouldn't happen */
ASSERT(FALSE);
}
/* Sanity checks */
ASSERT(KeyBody->KeyControlBlock->ParentKcb->KeyCell == Cell);
ASSERT(KeyBody->KeyControlBlock->ParentKcb->KeyHive == Hive);
ASSERT(KeyBody->KeyControlBlock->ParentKcb == ParentKcb);
ASSERT(KeyBody->KeyControlBlock->ParentKcb->KcbMaxNameLen == KeyNode->MaxNameLen);
/* Update the timestamp */
KeQuerySystemTime(&TimeStamp);
KeyNode->LastWriteTime = TimeStamp;
KeyBody->KeyControlBlock->ParentKcb->KcbLastWriteTime = TimeStamp;
/* Check if we need to update name maximum */
if (KeyNode->MaxNameLen < Name->Length)
{
/* Do it */
KeyNode->MaxNameLen = Name->Length;
KeyBody->KeyControlBlock->ParentKcb->KcbMaxNameLen = Name->Length;
}
/* Check if we need toupdate class length maximum */
if (KeyNode->MaxClassLen < Context->Class.Length)
{
/* Update it */
KeyNode->MaxClassLen = Context->Class.Length;
}
/* Check if we're creating a symbolic link */
if (Context->CreateOptions & REG_OPTION_CREATE_LINK)
{
/* Get the cell data */
CellData = HvGetCell(Hive, KeyCell);
if (!CellData)
{
/* This shouldn't happen */
ASSERT(FALSE);
}
/* Update the flags */
CellData->u.KeyNode.Flags |= KEY_SYM_LINK;
KeyBody->KeyControlBlock->Flags = CellData->u.KeyNode.Flags;
HvReleaseCell(Hive, KeyCell);
}
}
Exit:
/* Release the flusher lock and return status */
//ExReleasePushLock((PVOID)&((PCMHIVE)Hive)->FlusherLock);
return Status;
}

View File

@@ -1,153 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmse.c
* PURPOSE: Configuration Manager - Security Subsystem Interface
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "cm.h"
#define NDEBUG
#include "debug.h"
/* GLOBALS *******************************************************************/
/* FUNCTIONS *****************************************************************/
PSECURITY_DESCRIPTOR
NTAPI
CmpHiveRootSecurityDescriptor(VOID)
{
NTSTATUS Status;
PSECURITY_DESCRIPTOR SecurityDescriptor;
PACL Acl, AclCopy;
PSID Sid[4];
SID_IDENTIFIER_AUTHORITY WorldAuthority = {SECURITY_WORLD_SID_AUTHORITY};
SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
ULONG AceLength, AclLength, SidLength;
PACE_HEADER AceHeader;
ULONG i;
PAGED_CODE();
/* Phase 1: Allocate SIDs */
SidLength = RtlLengthRequiredSid(1);
Sid[0] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CM);
Sid[1] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CM);
Sid[2] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CM);
SidLength = RtlLengthRequiredSid(2);
Sid[3] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CM);
/* Make sure all SIDs were allocated */
if (!(Sid[0]) || !(Sid[1]) || !(Sid[2]) || !(Sid[3]))
{
/* Bugcheck */
KEBUGCHECKEX(REGISTRY_ERROR, 11, 1, 0, 0);
}
/* Phase 2: Initialize all SIDs */
Status = RtlInitializeSid(Sid[0], &WorldAuthority, 1);
Status |= RtlInitializeSid(Sid[1], &NtAuthority, 1);
Status |= RtlInitializeSid(Sid[2], &NtAuthority, 1);
Status |= RtlInitializeSid(Sid[3], &NtAuthority, 2);
if (!NT_SUCCESS(Status)) KEBUGCHECKEX(REGISTRY_ERROR, 11, 2, 0, 0);
/* Phase 2: Setup SID Sub Authorities */
*RtlSubAuthoritySid(Sid[0], 0) = SECURITY_WORLD_RID;
*RtlSubAuthoritySid(Sid[1], 0) = SECURITY_RESTRICTED_CODE_RID;
*RtlSubAuthoritySid(Sid[2], 0) = SECURITY_LOCAL_SYSTEM_RID;
*RtlSubAuthoritySid(Sid[3], 0) = SECURITY_BUILTIN_DOMAIN_RID;
*RtlSubAuthoritySid(Sid[3], 1) = DOMAIN_ALIAS_RID_ADMINS;
/* Make sure all SIDs are valid */
ASSERT(RtlValidSid(Sid[0]));
ASSERT(RtlValidSid(Sid[1]));
ASSERT(RtlValidSid(Sid[2]));
ASSERT(RtlValidSid(Sid[3]));
/* Phase 3: Calculate ACL Length */
AclLength = sizeof(ACL);
for (i = 0; i < 4; i++)
{
/* This is what MSDN says to do */
AceLength = FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart);
AceLength += SeLengthSid(Sid[i]);
AclLength += AceLength;
}
/* Phase 3: Allocate the ACL */
Acl = ExAllocatePoolWithTag(PagedPool, AclLength, TAG_CM);
if (!Acl) KEBUGCHECKEX(REGISTRY_ERROR, 11, 3, 0, 0);
/* Phase 4: Create the ACL */
Status = RtlCreateAcl(Acl, AclLength, ACL_REVISION);
if (!NT_SUCCESS(Status)) KEBUGCHECKEX(REGISTRY_ERROR, 11, 4, Status, 0);
/* Phase 5: Build the ACL */
Status = RtlAddAccessAllowedAce(Acl, ACL_REVISION, KEY_ALL_ACCESS, Sid[0]);
Status |= RtlAddAccessAllowedAce(Acl, ACL_REVISION, KEY_ALL_ACCESS, Sid[1]);
Status |= RtlAddAccessAllowedAce(Acl, ACL_REVISION, KEY_READ, Sid[2]);
Status |= RtlAddAccessAllowedAce(Acl, ACL_REVISION, KEY_READ, Sid[3]);
if (!NT_SUCCESS(Status)) KEBUGCHECKEX(REGISTRY_ERROR, 11, 5, Status, 0);
/* Phase 5: Make the ACEs inheritable */
Status = RtlGetAce(Acl, 0,( PVOID*)&AceHeader);
ASSERT(NT_SUCCESS(Status));
AceHeader->AceFlags |= CONTAINER_INHERIT_ACE;
Status = RtlGetAce(Acl, 1, (PVOID*)&AceHeader);
ASSERT(NT_SUCCESS(Status));
AceHeader->AceFlags |= CONTAINER_INHERIT_ACE;
Status = RtlGetAce(Acl, 2, (PVOID*)&AceHeader);
ASSERT(NT_SUCCESS(Status));
AceHeader->AceFlags |= CONTAINER_INHERIT_ACE;
Status = RtlGetAce(Acl, 3, (PVOID*)&AceHeader);
ASSERT(NT_SUCCESS(Status));
AceHeader->AceFlags |= CONTAINER_INHERIT_ACE;
/* Phase 6: Allocate the security descriptor and make space for the ACL */
SecurityDescriptor = ExAllocatePoolWithTag(PagedPool,
sizeof(SECURITY_DESCRIPTOR) +
AclLength,
TAG_CM);
if (!SecurityDescriptor) KEBUGCHECKEX(REGISTRY_ERROR, 11, 6, 0, 0);
/* Phase 6: Make a copy of the ACL */
AclCopy = (PACL)((PISECURITY_DESCRIPTOR)SecurityDescriptor + 1);
RtlCopyMemory(AclCopy, Acl, AclLength);
/* Phase 7: Create the security descriptor */
Status = RtlCreateSecurityDescriptor(SecurityDescriptor,
SECURITY_DESCRIPTOR_REVISION);
if (!NT_SUCCESS(Status)) KEBUGCHECKEX(REGISTRY_ERROR, 11, 7, Status, 0);
/* Phase 8: Set the ACL as a DACL */
Status = RtlSetDaclSecurityDescriptor(SecurityDescriptor,
TRUE,
AclCopy,
FALSE);
if (!NT_SUCCESS(Status)) KEBUGCHECKEX(REGISTRY_ERROR, 11, 8, Status, 0);
/* Free the SIDs and original ACL */
for (i = 0; i < 4; i++) ExFreePool(Sid[i]);
ExFreePool(Acl);
/* Return the security descriptor */
return SecurityDescriptor;
}
NTSTATUS
NTAPI
CmpSecurityMethod(IN PVOID ObjectBody,
IN SECURITY_OPERATION_CODE OperationCode,
IN PSECURITY_INFORMATION SecurityInformation,
IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
IN OUT PULONG BufferLength,
IN OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
IN POOL_TYPE PoolType,
IN PGENERIC_MAPPING GenericMapping)
{
/* HACK */
return STATUS_SUCCESS;
}

View File

@@ -1,38 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmsecach.c
* PURPOSE: Configuration Manager - Security Cache
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "cm.h"
#define NDEBUG
#include "debug.h"
/* GLOBALS *******************************************************************/
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
CmpInitSecurityCache(IN PCMHIVE Hive)
{
ULONG i;
/* Reset data */
Hive->SecurityCount = 0;
Hive->SecurityCacheSize = 0;
Hive->SecurityHitHint = -1;
Hive->SecurityCache = NULL;
/* Loop every security hash */
for (i = 0; i < 64; i++)
{
/* Initialize it */
InitializeListHead(&Hive->SecurityHash[i]);
}
}

View File

@@ -1,185 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/cm/cmapi.c
* PURPOSE: Internal routines that implement Nt* API functionality
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
#include "cm.h"
ERESOURCE CmpRegistryLock;
PVOID CmpRegistryLockCallerCaller, CmpRegistryLockCaller;
BOOLEAN CmpFlushStarveWriters;
KGUARDED_MUTEX CmpDelayAllocBucketLock;
LIST_ENTRY CmpFreeDelayItemsListHead;
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
CmpLockRegistryExclusive(VOID)
{
/* Enter a critical region and lock the registry */
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&CmpRegistryLock, TRUE);
/* Sanity check */
ASSERT(CmpFlushStarveWriters == 0);
RtlGetCallersAddress(&CmpRegistryLockCaller, &CmpRegistryLockCallerCaller);
}
BOOLEAN
NTAPI
CmpTestRegistryLock(VOID)
{
/* Test the lock */
return (BOOLEAN)ExIsResourceAcquiredSharedLite(&CmpRegistryLock);
}
BOOLEAN
NTAPI
CmpTestRegistryLockExclusive(VOID)
{
/* Test the lock */
return ExIsResourceAcquiredExclusiveLite(&CmpRegistryLock);
}
PVOID
NTAPI
CmpAllocateDelayItem(VOID)
{
PCM_DELAY_ALLOC Entry;
PCM_ALLOC_PAGE AllocPage;
ULONG i;
PLIST_ENTRY NextEntry;
PAGED_CODE();
/* Lock the allocation buckets */
KeAcquireGuardedMutex(&CmpDelayAllocBucketLock);
/* Look for an item on the free list */
SearchList:
if (!IsListEmpty(&CmpFreeDelayItemsListHead))
{
/* Get the current entry in the list */
NextEntry = RemoveHeadList(&CmpFreeDelayItemsListHead);
/* Grab the item */
Entry = CONTAINING_RECORD(NextEntry, CM_DELAY_ALLOC, ListEntry);
/* Clear the list */
Entry->ListEntry.Flink = Entry->ListEntry.Blink = NULL;
/* Grab the alloc page */
AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)Entry & 0xFFFFF000);
/* Decrease free entries */
ASSERT(AllocPage->FreeCount != 0);
AllocPage->FreeCount--;
/* Release the lock */
KeReleaseGuardedMutex(&CmpDelayAllocBucketLock);
return Entry;
}
/* Allocate an allocation page */
AllocPage = ExAllocatePoolWithTag(PagedPool, PAGE_SIZE, TAG_CM);
if (AllocPage)
{
/* Set default entries */
AllocPage->FreeCount = CM_DELAYS_PER_PAGE;
/* Loop each entry */
for (i = 0; i < CM_DELAYS_PER_PAGE; i++)
{
/* Get this entry and link it */
Entry = (PVOID)((ULONG_PTR)AllocPage +
FIELD_OFFSET(CM_ALLOC_PAGE, AllocPage) +
i * sizeof(CM_DELAY_ALLOC));
InsertTailList(&CmpFreeDelayItemsListHead,
&Entry->ListEntry);
/* Clear the KCB pointer */
Entry->Kcb = NULL;
}
}
else
{
/* Release the lock */
KeReleaseGuardedMutex(&CmpDelayAllocBucketLock);
return NULL;
}
/* Do the search again */
goto SearchList;
}
VOID
NTAPI
CmpFreeDelayItem(PVOID Entry)
{
PCM_DELAY_ALLOC AllocEntry = (PCM_DELAY_ALLOC)Entry;
PCM_ALLOC_PAGE AllocPage;
ULONG i;
PAGED_CODE();
/* Lock the table */
KeAcquireGuardedMutex(&CmpDelayAllocBucketLock);
/* Add the entry at the end */
InsertTailList(&CmpFreeDelayItemsListHead, &AllocEntry->ListEntry);
/* Get the alloc page */
AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)Entry & 0xFFFFF000);
ASSERT(AllocPage->FreeCount != CM_DELAYS_PER_PAGE);
/* Increase the number of free items */
if (++AllocPage->FreeCount == CM_DELAYS_PER_PAGE)
{
/* Page is totally free now, loop each entry */
for (i = 0; i < CM_DELAYS_PER_PAGE; i++)
{
/* Get the entry and unlink it */
AllocEntry = (PVOID)((ULONG_PTR)AllocPage +
FIELD_OFFSET(CM_ALLOC_PAGE, AllocPage) +
i * sizeof(CM_DELAY_ALLOC));
RemoveEntryList(&AllocEntry->ListEntry);
}
/* Now free the page */
ExFreePool(AllocPage);
}
/* Release the lock */
KeReleaseGuardedMutex(&CmpDelayAllocBucketLock);
}
VOID
NTAPI
CmpUnlockRegistry(VOID)
{
/* Sanity check */
CMP_ASSERT_REGISTRY_LOCK();
/* Check if we should flush the registry */
if (CmpFlushOnLockRelease)
{
/* The registry should be exclusively locked for this */
CMP_ASSERT_EXCLUSIVE_REGISTRY_LOCK();
/* Flush the registry */
CmpFlushEntireRegistry(TRUE);
CmpFlushOnLockRelease = FALSE;
}
/* Release the lock and leave the critical region */
ExReleaseResourceLite(&CmpRegistryLock);
KeLeaveCriticalRegion();
}

View File

@@ -1,364 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmvalue.c
* PURPOSE: Configuration Manager - Cell Values
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "cm.h"
#define NDEBUG
#include "debug.h"
/* FUNCTIONS *****************************************************************/
BOOLEAN
NTAPI
CmpMarkValueDataDirty(IN PHHIVE Hive,
IN PCM_KEY_VALUE Value)
{
ULONG KeySize;
PAGED_CODE();
/* Make sure there's actually any data */
if (Value->Data != HCELL_NIL)
{
/* If this is a small key, there's no need to have it dirty */
if (CmpIsKeyValueSmall(&KeySize, Value->DataLength)) return TRUE;
/* Check if this is a big key */
ASSERT_VALUE_BIG(Hive, KeySize);
/* Normal value, just mark it dirty */
HvMarkCellDirty(Hive, Value->Data, FALSE);
}
/* Operation complete */
return TRUE;
}
BOOLEAN
NTAPI
CmpFreeValueData(IN PHHIVE Hive,
IN HCELL_INDEX DataCell,
IN ULONG DataLength)
{
ULONG KeySize;
PAGED_CODE();
/* If this is a small key, the data is built-in */
if (!CmpIsKeyValueSmall(&KeySize, DataLength))
{
/* If there's no data cell, there's nothing to do */
if (DataCell == HCELL_NIL) return TRUE;
/* Make sure the data cell is allocated */
//ASSERT(HvIsCellAllocated(Hive, DataCell));
/* Unsupported value type */
ASSERT_VALUE_BIG(Hive, KeySize);
/* Normal value, just free the data cell */
HvFreeCell(Hive, DataCell);
}
/* Operation complete */
return TRUE;
}
BOOLEAN
NTAPI
CmpFreeValue(IN PHHIVE Hive,
IN HCELL_INDEX Cell)
{
PCM_KEY_VALUE Value;
PAGED_CODE();
/* Get the cell data */
Value = (PCM_KEY_VALUE)HvGetCell(Hive, Cell);
if (!Value) ASSERT(FALSE);
/* Free it */
if (!CmpFreeValueData(Hive, Value->Data, Value->DataLength))
{
/* We failed to free the data, return failure */
HvReleaseCell(Hive, Cell);
return FALSE;
}
/* Release the cell and free it */
HvReleaseCell(Hive, Cell);
HvFreeCell(Hive, Cell);
return TRUE;
}
HCELL_INDEX
NTAPI
CmpFindValueByName(IN PHHIVE Hive,
IN PCM_KEY_NODE KeyNode,
IN PUNICODE_STRING Name)
{
HCELL_INDEX CellIndex;
/* Call the main function */
if (!CmpFindNameInList(Hive,
&KeyNode->ValueList,
Name,
NULL,
&CellIndex))
{
/* Santy check */
ASSERT(CellIndex == HCELL_NIL);
}
/* Return the index */
return CellIndex;
}
BOOLEAN
NTAPI
CmpGetValueData(IN PHHIVE Hive,
IN PCM_KEY_VALUE Value,
IN PULONG Length,
OUT PVOID *Buffer,
OUT PBOOLEAN BufferAllocated,
OUT PHCELL_INDEX CellToRelease)
{
PAGED_CODE();
/* Sanity check */
ASSERT(Value->Signature == CM_KEY_VALUE_SIGNATURE);
/* Set failure defaults */
*BufferAllocated = FALSE;
*Buffer = NULL;
*CellToRelease = HCELL_NIL;
/* Check if this is a small key */
if (CmpIsKeyValueSmall(Length, Value->DataLength))
{
/* Return the data immediately */
*Buffer = &Value->Data;
return TRUE;
}
/* Unsupported */
ASSERT_VALUE_BIG(Hive, *Length);
/* Get the data from the cell */
*Buffer = HvGetCell(Hive, Value->Data);
if (!(*Buffer)) return FALSE;
/* Return success and the cell to be released */
*CellToRelease = Value->Data;
return TRUE;
}
PCELL_DATA
NTAPI
CmpValueToData(IN PHHIVE Hive,
IN PCM_KEY_VALUE Value,
OUT PULONG Length)
{
PCELL_DATA Buffer;
BOOLEAN BufferAllocated;
HCELL_INDEX CellToRelease;
PAGED_CODE();
/* Sanity check */
ASSERT(Hive->ReleaseCellRoutine == NULL);
/* Get the actual data */
if (!CmpGetValueData(Hive,
Value,
Length,
(PVOID)&Buffer,
&BufferAllocated,
&CellToRelease))
{
/* We failed */
ASSERT(BufferAllocated == FALSE);
ASSERT(Buffer == NULL);
return NULL;
}
/* This should never happen!*/
if (BufferAllocated)
{
/* Free the buffer and bugcheck */
ExFreePool(Buffer);
KEBUGCHECKEX(REGISTRY_ERROR, 8, 0, (ULONG_PTR)Hive, (ULONG_PTR)Value);
}
/* Otherwise, return the cell data */
return Buffer;
}
NTSTATUS
NTAPI
CmpAddValueToList(IN PHHIVE Hive,
IN HCELL_INDEX ValueCell,
IN ULONG Index,
IN ULONG Type,
IN OUT PCHILD_LIST ChildList)
{
HCELL_INDEX ListCell;
ULONG ChildCount, Length, i;
PCELL_DATA CellData;
PAGED_CODE();
/* Sanity check */
ASSERT((((LONG)Index) >= 0) && (Index <= ChildList->Count));
/* Get the number of entries in the child list */
ChildCount = ChildList->Count;
ChildCount++;
if (ChildCount > 1)
{
/* The cell should be dirty at this point */
ASSERT(HvIsCellDirty(Hive, ChildList->List));
/* Check if we have less then 100 children */
if (ChildCount < 100)
{
/* Allocate just enough as requested */
Length = ChildCount * sizeof(HCELL_INDEX);
}
else
{
/* Otherwise, we have quite a few, so allocate a batch */
Length = ROUND_UP(ChildCount, 100) * sizeof(HCELL_INDEX);
if (Length > HBLOCK_SIZE)
{
/* But make sure we don't allocate beyond our block size */
Length = ROUND_UP(Length, HBLOCK_SIZE);
}
}
/* Perform the allocation */
ListCell = HvReallocateCell(Hive, ChildList->List, Length);
}
else
{
/* This is our first child, so allocate a single cell */
ListCell = HvAllocateCell(Hive, sizeof(HCELL_INDEX), Type, HCELL_NIL);
}
/* Fail if we couldn't get a cell */
if (ListCell == HCELL_NIL) return STATUS_INSUFFICIENT_RESOURCES;
/* Set this cell as the child list's list cell */
ChildList->List = ListCell;
/* Get the actual key list memory */
CellData = HvGetCell(Hive, ListCell);
ASSERT(CellData != NULL);
/* Loop all the children */
for (i = ChildCount - 1; i > Index; i--)
{
/* Move them all down */
CellData->u.KeyList[i] = CellData->u.KeyList[i - 1];
}
/* Insert us on top now */
CellData->u.KeyList[Index] = ValueCell;
ChildList->Count = ChildCount;
/* Release the list cell and make sure the value cell is dirty */
HvReleaseCell(Hive, ListCell);
ASSERT(HvIsCellDirty(Hive, ValueCell));
/* We're done here */
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
CmpSetValueDataNew(IN PHHIVE Hive,
IN PVOID Data,
IN ULONG DataSize,
IN ULONG StorageType,
IN HCELL_INDEX ValueCell,
OUT PHCELL_INDEX DataCell)
{
PCELL_DATA CellData;
PAGED_CODE();
ASSERT(DataSize > CM_KEY_VALUE_SMALL);
/* Check if this is a big key */
ASSERT_VALUE_BIG(Hive, DataSize);
/* Allocate a data cell */
*DataCell = HvAllocateCell(Hive, DataSize, StorageType, HCELL_NIL);
if (*DataCell == HCELL_NIL) return STATUS_INSUFFICIENT_RESOURCES;
/* Get the actual data */
CellData = HvGetCell(Hive, *DataCell);
if (!CellData) ASSERT(FALSE);
/* Copy our buffer into it */
RtlCopyMemory(CellData, Data, DataSize);
/* All done */
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
CmpRemoveValueFromList(IN PHHIVE Hive,
IN ULONG Index,
IN OUT PCHILD_LIST ChildList)
{
ULONG Count;
PCELL_DATA CellData;
HCELL_INDEX NewCell;
PAGED_CODE();
/* Sanity check */
ASSERT((((LONG)Index) >= 0) && (Index <= ChildList->Count));
/* Get the new count after removal */
Count = ChildList->Count - 1;
if (Count > 0)
{
/* Get the actual list array */
CellData = HvGetCell(Hive, ChildList->List);
if (!CellData) return STATUS_INSUFFICIENT_RESOURCES;
/* Make sure cells data have been made dirty */
ASSERT(HvIsCellDirty(Hive, ChildList->List));
ASSERT(HvIsCellDirty(Hive, CellData->u.KeyList[Index]));
/* Loop the list */
while (Index < Count)
{
/* Move everything up */
CellData->u.KeyList[Index] = CellData->u.KeyList[Index + 1];
Index++;
}
/* Re-allocate the cell for the list by decreasing the count */
NewCell = HvReallocateCell(Hive,
ChildList->List,
Count * sizeof(HCELL_INDEX));
ASSERT(NewCell != HCELL_NIL);
HvReleaseCell(Hive,ChildList->List);
/* Update the list cell */
ChildList->List = NewCell;
}
else
{
/* Otherwise, we were the last entry, so free the list entirely */
HvFreeCell(Hive, ChildList->List);
ChildList->List = HCELL_NIL;
}
/* Update the child list with the new count */
ChildList->Count = Count;
return STATUS_SUCCESS;
}

View File

@@ -1,159 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/cmwraprs.c
* PURPOSE: Configuration Manager - Wrappers for Hive Operations
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "cm.h"
#define NDEBUG
#include "debug.h"
/* FUNCTIONS *****************************************************************/
NTSTATUS
NTAPI
CmpCreateEvent(IN EVENT_TYPE EventType,
OUT PHANDLE EventHandle,
OUT PKEVENT *Event)
{
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
/* Create the event */
InitializeObjectAttributes(&ObjectAttributes,
NULL,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL,
NULL);
Status = ZwCreateEvent(EventHandle,
EVENT_ALL_ACCESS,
&ObjectAttributes,
EventType,
FALSE);
if (!NT_SUCCESS(Status)) return Status;
/* Get a pointer to the object itself */
Status = ObReferenceObjectByHandle(*EventHandle,
EVENT_ALL_ACCESS,
NULL,
KernelMode,
(PVOID*)Event,
NULL);
if (!NT_SUCCESS(Status)) ZwClose(*EventHandle);
/* Return status */
return Status;
}
PVOID
NTAPI
CmpAllocate(IN ULONG Size,
IN BOOLEAN Paged,
IN ULONG Tag)
{
return ExAllocatePoolWithTag(Paged ? PagedPool : NonPagedPool,
Size,
Tag);
}
VOID
NTAPI
CmpFree(IN PVOID Ptr,
IN ULONG Quota)
{
ExFreePool(Ptr);
}
BOOLEAN
NTAPI
CmpFileRead(IN PHHIVE RegistryHive,
IN ULONG FileType,
IN PULONG FileOffset,
OUT PVOID Buffer,
IN SIZE_T BufferLength)
{
PCMHIVE CmHive = (PCMHIVE)RegistryHive;
HANDLE HiveHandle = CmHive->FileHandles[FileType];
LARGE_INTEGER _FileOffset;
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
_FileOffset.QuadPart = *FileOffset;
Status = ZwReadFile(HiveHandle, 0, 0, 0, &IoStatusBlock,
Buffer, BufferLength, &_FileOffset, 0);
return NT_SUCCESS(Status) ? TRUE : FALSE;
}
BOOLEAN
NTAPI
CmpFileWrite(IN PHHIVE RegistryHive,
IN ULONG FileType,
IN PULONG FileOffset,
IN PVOID Buffer,
IN SIZE_T BufferLength)
{
PCMHIVE CmHive = (PCMHIVE)RegistryHive;
HANDLE HiveHandle = CmHive->FileHandles[FileType];
LARGE_INTEGER _FileOffset;
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
_FileOffset.QuadPart = *FileOffset;
Status = ZwWriteFile(HiveHandle, 0, 0, 0, &IoStatusBlock,
Buffer, BufferLength, &_FileOffset, 0);
return NT_SUCCESS(Status) ? TRUE : FALSE;
}
BOOLEAN
NTAPI
CmpFileSetSize(IN PHHIVE RegistryHive,
IN ULONG FileType,
IN ULONG FileSize,
IN ULONG OldFileSize)
{
PCMHIVE CmHive = (PCMHIVE)RegistryHive;
HANDLE HiveHandle = CmHive->FileHandles[FileType];
FILE_END_OF_FILE_INFORMATION EndOfFileInfo;
FILE_ALLOCATION_INFORMATION FileAllocationInfo;
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
EndOfFileInfo.EndOfFile.QuadPart = FileSize;
Status = ZwSetInformationFile(HiveHandle,
&IoStatusBlock,
&EndOfFileInfo,
sizeof(FILE_END_OF_FILE_INFORMATION),
FileEndOfFileInformation);
if (!NT_SUCCESS(Status)) return FALSE;
FileAllocationInfo.AllocationSize.QuadPart = FileSize;
Status = ZwSetInformationFile(HiveHandle,
&IoStatusBlock,
&FileAllocationInfo,
sizeof(FILE_ALLOCATION_INFORMATION),
FileAllocationInformation);
if (!NT_SUCCESS(Status)) return FALSE;
return TRUE;
}
BOOLEAN
NTAPI
CmpFileFlush(IN PHHIVE RegistryHive,
IN ULONG FileType,
IN OUT PLARGE_INTEGER FileOffset,
IN ULONG Length)
{
PCMHIVE CmHive = (PCMHIVE)RegistryHive;
HANDLE HiveHandle = CmHive->FileHandles[FileType];
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
Status = ZwFlushBuffersFile(HiveHandle, &IoStatusBlock);
return NT_SUCCESS(Status) ? TRUE : FALSE;
}

View File

@@ -1,834 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/config/i386/cmhardwr.c
* PURPOSE: Configuration Manager - Hardware-Specific Code
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include "../cm.h"
#define NDEBUG
#include "debug.h"
/* GLOBALS *******************************************************************/
PCHAR CmpID1 = "80%u86-%c%x";
PCHAR CmpID2 = "x86 Family %u Model %u Stepping %u";
PCHAR CmpBiosStrings[] =
{
"Ver",
"Rev",
"Rel",
"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9",
"v 0", "v 1", "v 2", "v 3", "v 4", "v 5", "v 6", "v 7", "v 8", "v 9",
NULL
};
PCHAR CmpBiosBegin, CmpBiosSearchStart, CmpBiosSearchEnd;
/* FUNCTIONS *****************************************************************/
BOOLEAN
NTAPI
CmpGetBiosDate(IN PCHAR BiosStart,
IN ULONG BiosLength,
IN PCHAR BiosDate,
IN BOOLEAN FromBios)
{
CHAR LastDate[11] = {0}, CurrentDate[11];
PCHAR p, pp;
/* Skip the signature and the magic, and loop the BIOS ROM */
p = BiosStart + 2;
pp = BiosStart + BiosLength - 5;
while (p < pp)
{
/* Check for xx/yy/zz which we assume to be a date */
if ((p[0] == '/') &&
(p[3] == '/') &&
(isdigit(p[-1])) &&
(isdigit(p[1])) &&
(isdigit(p[2])) &&
(isdigit(p[4])) &&
(isdigit(p[5])))
{
/* Copy the string proper */
RtlMoveMemory(&CurrentDate[5], p - 2, 5);
/* Add a 0 if the month only has one digit */
if (!isdigit(CurrentDate[5])) CurrentDate[5] = '0';
/* Now copy the year */
CurrentDate[2] = p[4];
CurrentDate[3] = p[5];
CurrentDate[4] = CurrentDate[7] = CurrentDate[10] = ANSI_NULL;
/* If the date comes from the BIOS, check if it's a 4-digit year */
if ((FromBios) &&
(isdigit(p[6])) &&
(isdigit(p[7])) &&
((RtlEqualMemory(&p[4], "19", 2)) ||
(RtlEqualMemory(&p[4], "20", 2))))
{
/* Copy the year proper */
CurrentDate[0] = p[4];
CurrentDate[1] = p[5];
CurrentDate[2] = p[6];
CurrentDate[3] = p[7];
}
else
{
/* Otherwise, we'll just assume anything under 80 is 2000 */
if (strtoul(&CurrentDate[2], NULL, 10) < 80)
{
/* Hopefully your BIOS wasn't made in 1979 */
CurrentDate[0] = '2';
CurrentDate[1] = '0';
}
else
{
/* Anything over 80, was probably made in the 1900s... */
CurrentDate[0] = '1';
CurrentDate[1] = '9';
}
}
/* Add slashes were we previously had NULLs */
CurrentDate[4] = CurrentDate[7] = '/';
/* Check which date is newer */
if (memcmp(LastDate, CurrentDate, 10) < 0)
{
/* Found a newer date, select it */
RtlMoveMemory(LastDate, CurrentDate, 10);
}
p += 2;
}
p++;
}
/* Make sure we found a date */
if (LastDate[0])
{
/* Copy the year at the pp, and keep only the last two digits */
RtlMoveMemory(BiosDate, &LastDate[5], 5);
BiosDate[5] = '/';
BiosDate[6] = LastDate[2];
BiosDate[7] = LastDate[3];
BiosDate[8] = ANSI_NULL;
return TRUE;
}
/* No date found, return empty string */
BiosDate[0] = ANSI_NULL;
return FALSE;
}
BOOLEAN
NTAPI
CmpGetBiosVersion(IN PCHAR BiosStart,
IN ULONG BiosLength,
IN PCHAR BiosVersion)
{
CHAR Buffer[128];
PCHAR p, pp;
USHORT i;
/* Check if we were given intitial data for the search */
if (BiosStart)
{
/* Save it for later use */
CmpBiosBegin = BiosStart;
CmpBiosSearchStart = BiosStart + 1;
CmpBiosSearchEnd = BiosStart + BiosLength - 2;
}
/* Now loop the BIOS area */
for (;;)
{
/* Start an initial search looking for numbers and periods */
pp = NULL;
while (CmpBiosSearchStart <= CmpBiosSearchEnd)
{
/* Check if we have an "x.y" version string */
if ((*CmpBiosSearchStart == '.') &&
(*(CmpBiosSearchStart + 1) >= '0') &&
(*(CmpBiosSearchStart + 1) <= '9') &&
(*(CmpBiosSearchStart - 1) >= '0') &&
(*(CmpBiosSearchStart - 1) <= '9'))
{
/* Start looking in this area for the actual BIOS Version */
pp = CmpBiosSearchStart;
break;
}
else
{
/* Keep searching */
CmpBiosSearchStart++;
}
}
/* Break out if we're went past the BIOS area */
if (CmpBiosSearchStart > CmpBiosSearchEnd) return FALSE;
/* Move to the next 2 bytes */
CmpBiosSearchStart += 2;
/* Null-terminate our scratch buffer and start the string here */
Buffer[127] = ANSI_NULL;
p = &Buffer[127];
/* Go back one character since we're doing this backwards */
pp--;
/* Loop the identifier we found as long as it's valid */
i = 0;
while ((i++ < 127) &&
(pp >= CmpBiosBegin) &&
(*pp >= ' ') &&
(*pp != '$'))
{
/* Copy the character */
*--p = *pp--;
}
/* Go past the last character since we went backwards */
pp++;
/* Loop the strings we recognize */
for (i = 0; CmpBiosStrings[i]; i++)
{
/* Check if a match was found */
if (strstr(p, CmpBiosStrings[i])) goto Match;
}
}
Match:
/* Skip until we find a space */
for (; *pp == ' '; pp++);
/* Loop the final string */
i = 0;
do
{
/* Copy the character into the final string */
BiosVersion[i] = *pp++;
} while ((++i < 127) &&
(pp <= (CmpBiosSearchEnd + 1)) &&
(*pp >= ' ') &&
(*pp != '$'));
/* Null-terminate the version string */
BiosVersion[i] = ANSI_NULL;
return TRUE;
}
NTSTATUS
NTAPI
CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
UNICODE_STRING KeyName, ValueName, Data, SectionName;
OBJECT_ATTRIBUTES ObjectAttributes;
ULONG HavePae, CacheSize, ViewSize, Length, TotalLength = 0, i, Disposition;
NTSTATUS Status;
HANDLE KeyHandle, BiosHandle, SystemHandle, FpuHandle, SectionHandle;
CONFIGURATION_COMPONENT_DATA ConfigData;
CHAR Buffer[128];
ULONG ExtendedId, Dummy;
PKPRCB Prcb;
USHORT IndexTable[MaximumType + 1] = {0};
ANSI_STRING TempString;
PCHAR PartialString = NULL, BiosVersion;
CHAR CpuString[48];
PVOID BaseAddress = NULL;
LARGE_INTEGER ViewBase = {{0}};
ULONG_PTR VideoRomBase;
PCHAR CurrentVersion;
extern UNICODE_STRING KeRosProcessorName, KeRosBiosDate, KeRosBiosVersion;
extern UNICODE_STRING KeRosVideoBiosDate, KeRosVideoBiosVersion;
/* Open the SMSS Memory Management key */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\"
L"Control\\Session Manager\\Memory Management");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtOpenKey(&KeyHandle, KEY_READ | KEY_WRITE, &ObjectAttributes);
if (NT_SUCCESS(Status))
{
/* Detect if PAE is enabled */
HavePae = SharedUserData->ProcessorFeatures[PF_PAE_ENABLED];
/* Set the value */
RtlInitUnicodeString(&ValueName, L"PhysicalAddressExtension");
NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_DWORD,
&HavePae,
sizeof(HavePae));
/* Close the key */
NtClose(KeyHandle);
}
/* Open the hardware description key */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\Hardware\\Description\\System");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtOpenKey(&SystemHandle, KEY_READ | KEY_WRITE, &ObjectAttributes);
if (!NT_SUCCESS(Status)) return Status;
/* Create the BIOS Information key */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\"
L"Control\\BIOSINFO");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtCreateKey(&BiosHandle,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
NULL,
REG_OPTION_NON_VOLATILE,
&Disposition);
if (ExpInTextModeSetup)
{
if (!NT_SUCCESS(Status))
BiosHandle = NULL;
}
else if (!NT_SUCCESS(Status))
return Status;
/* Create the CPU Key, and check if it already existed */
RtlInitUnicodeString(&KeyName, L"CentralProcessor");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
SystemHandle,
NULL);
Status = NtCreateKey(&KeyHandle,
KEY_READ | KEY_WRITE,
&ObjectAttributes,
0,
NULL,
0,
&Disposition);
NtClose(KeyHandle);
/* The key shouldn't already exist */
if (Disposition == REG_CREATED_NEW_KEY)
{
/* Allocate the configuration data for cmconfig.c */
CmpConfigurationData = ExAllocatePoolWithTag(PagedPool,
CmpConfigurationAreaSize,
TAG_CM);
if (!CmpConfigurationData) return STATUS_INSUFFICIENT_RESOURCES;
/* Loop all CPUs */
for (i = 0; i < KeNumberProcessors; i++)
{
/* Get the PRCB */
Prcb = KiProcessorBlock[i];
/* Setup the Configuration Entry for the Processor */
RtlZeroMemory(&ConfigData, sizeof (ConfigData));
ConfigData.ComponentEntry.Class = ProcessorClass;
ConfigData.ComponentEntry.Type = CentralProcessor;
ConfigData.ComponentEntry.Key = i;
ConfigData.ComponentEntry.AffinityMask = AFFINITY_MASK(i);
ConfigData.ComponentEntry.Identifier = Buffer;
/* Check if the CPU doesn't support CPUID */
if (!Prcb->CpuID)
{
/* Build ID1-style string for older CPUs */
sprintf(Buffer,
CmpID1,
Prcb->CpuType,
(Prcb->CpuStep >> 8) + 'A',
Prcb->CpuStep & 0xff);
}
else
{
/* Build ID2-style string for newer CPUs */
sprintf(Buffer,
CmpID2,
Prcb->CpuType,
(Prcb->CpuStep >> 8),
Prcb->CpuStep & 0xff);
}
/* Save the ID string length now that we've created it */
ConfigData.ComponentEntry.IdentifierLength = strlen(Buffer) + 1;
/* Initialize the registry configuration node for it */
Status = CmpInitializeRegistryNode(&ConfigData,
SystemHandle,
&KeyHandle,
InterfaceTypeUndefined,
0xFFFFFFFF,
IndexTable);
if (!NT_SUCCESS(Status)) return(Status);
/* Check if we have an FPU */
if (KeI386NpxPresent)
{
/* Setup the Configuration Entry for the FPU */
RtlZeroMemory(&ConfigData, sizeof(ConfigData));
ConfigData.ComponentEntry.Class = ProcessorClass;
ConfigData.ComponentEntry.Type = FloatingPointProcessor;
ConfigData.ComponentEntry.Key = i;
ConfigData.ComponentEntry.AffinityMask = AFFINITY_MASK(i);
ConfigData.ComponentEntry.Identifier = Buffer;
/* For 386 cpus, the CPU pp is the identifier */
if (Prcb->CpuType == 3) strcpy(Buffer, "80387");
/* Save the ID string length now that we've created it */
ConfigData.ComponentEntry.IdentifierLength = strlen(Buffer) + 1;
/* Initialize the registry configuration node for it */
Status = CmpInitializeRegistryNode(&ConfigData,
SystemHandle,
&FpuHandle,
InterfaceTypeUndefined,
0xFFFFFFFF,
IndexTable);
if (!NT_SUCCESS(Status))
{
/* Failed, close the CPU handle and return */
NtClose(KeyHandle);
return Status;
}
/* Close this new handle */
NtClose(FpuHandle);
/* Stay on this CPU only */
KeSetSystemAffinityThread(Prcb->SetMember);
if (!Prcb->CpuID)
{
/* Uh oh, no CPUID! */
}
else
{
/* Check if we have extended CPUID that supports name ID */
Ki386Cpuid(0x80000000, &ExtendedId, &Dummy, &Dummy, &Dummy);
if (ExtendedId >= 0x80000004)
{
/* Do all the CPUIDs requred to get the full name */
PartialString = CpuString;
for (ExtendedId = 2; ExtendedId <= 4; ExtendedId++)
{
/* Do the CPUID and save the name string */
Ki386Cpuid(0x80000000 | ExtendedId,
(PULONG)PartialString,
(PULONG)PartialString + 1,
(PULONG)PartialString + 2,
(PULONG)PartialString + 3);
/* Go to the next name string */
PartialString += 16;
}
/* Null-terminate it */
CpuString[48] = ANSI_NULL;
}
}
/* Get the cache size while we're still localized */
CacheSize = ((PKIPCR)KeGetPcr())->SecondLevelCacheSize;
/* Go back to user affinity */
KeRevertToUserAffinityThread();
/* Check if we have a CPU Name */
if (PartialString)
{
/* Convert it to Unicode */
RtlInitAnsiString(&TempString, CpuString);
RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE);
/* Add it to the registry */
RtlInitUnicodeString(&ValueName, L"ProcessorNameString");
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_SZ,
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* ROS: Save a copy for bugzilla reporting */
RtlCreateUnicodeString(&KeRosProcessorName, Data.Buffer);
/* Free the temporary buffer */
RtlFreeUnicodeString(&Data);
}
/* Check if we had a Vendor ID */
if (Prcb->VendorString)
{
/* Convert it to Unicode */
RtlInitAnsiString(&TempString, Prcb->VendorString);
RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE);
/* Add it to the registry */
RtlInitUnicodeString(&ValueName, L"VendorIdentifier");
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_SZ,
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* Free the temporary buffer */
RtlFreeUnicodeString(&Data);
}
/* Check if we have features bits */
if (Prcb->FeatureBits)
{
/* Add them to the registry */
RtlInitUnicodeString(&ValueName, L"FeatureSet");
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_DWORD,
&Prcb->FeatureBits,
sizeof(Prcb->FeatureBits));
}
/* Check if we detected the CPU Speed */
if (Prcb->MHz)
{
/* Add it to the registry */
RtlInitUnicodeString(&ValueName, L"~MHz");
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_DWORD,
&Prcb->MHz,
sizeof(Prcb->MHz));
}
/* Check if we have an update signature */
if (Prcb->UpdateSignature.QuadPart)
{
/* Add it to the registry */
RtlInitUnicodeString(&ValueName, L"Update Signature");
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_BINARY,
&Prcb->UpdateSignature,
sizeof(Prcb->UpdateSignature));
}
/* Close the processor handle */
NtClose(KeyHandle);
/* FIXME: Detect CPU mismatches */
}
}
/* Free the configuration data */
ExFreePool(CmpConfigurationData);
}
/* Open physical memory */
RtlInitUnicodeString(&SectionName, L"\\Device\\PhysicalMemory");
InitializeObjectAttributes(&ObjectAttributes,
&SectionName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = ZwOpenSection(&SectionHandle,
SECTION_ALL_ACCESS,
&ObjectAttributes);
if (!NT_SUCCESS(Status)) goto Quickie;
/* Map the first 1KB of memory to get the IVT */
ViewSize = PAGE_SIZE;
Status = ZwMapViewOfSection(SectionHandle,
NtCurrentProcess(),
&BaseAddress,
0,
ViewSize,
&ViewBase,
&ViewSize,
ViewUnmap,
MEM_DOS_LIM,
PAGE_READWRITE);
if (!NT_SUCCESS(Status))
{
/* Assume default */
VideoRomBase = 0xC0000;
}
else
{
/* Calculate the base address from the vector */
VideoRomBase = (*((PULONG)BaseAddress + 0x10) >> 12) & 0xFFFF0;
VideoRomBase += *((PULONG)BaseAddress + 0x10) & 0xFFF0;
/* Now get to the actual ROM Start and make sure it's not invalid*/
VideoRomBase &= 0xFFFF8000;
if (VideoRomBase < 0xC0000) VideoRomBase = 0xC0000;
/* And unmap the section */
ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
}
/* Allocate BIOS Version pp Buffer */
BiosVersion = ExAllocatePoolWithTag(PagedPool, PAGE_SIZE, TAG_CM);
/* Setup settings to map the 64K BIOS ROM */
BaseAddress = 0;
ViewSize = 16 * PAGE_SIZE;
ViewBase.LowPart = 0xF0000;
ViewBase.HighPart = 0;
/* Map it */
Status = ZwMapViewOfSection(SectionHandle,
NtCurrentProcess(),
&BaseAddress,
0,
ViewSize,
&ViewBase,
&ViewSize,
ViewUnmap,
MEM_DOS_LIM,
PAGE_READWRITE);
if (NT_SUCCESS(Status))
{
/* Scan the ROM to get the BIOS Date */
if (CmpGetBiosDate(BaseAddress, 16 * PAGE_SIZE, Buffer, TRUE))
{
/* Convert it to Unicode */
RtlInitAnsiString(&TempString, Buffer);
RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE);
/* Write the date into the registry */
RtlInitUnicodeString(&ValueName, L"SystemBiosDate");
Status = NtSetValueKey(SystemHandle,
&ValueName,
0,
REG_SZ,
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* Free the string */
RtlFreeUnicodeString(&Data);
if (BiosHandle)
{
/* Get the BIOS Date Identifier */
RtlCopyMemory(Buffer, (PCHAR)BaseAddress + (16*PAGE_SIZE - 11), 8);
Buffer[8] = ANSI_NULL;
/* Convert it to unicode */
RtlInitAnsiString(&TempString, Buffer);
Status = RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE);
if (NT_SUCCESS(Status))
{
/* Save it to the registry */
Status = NtSetValueKey(BiosHandle,
&ValueName,
0,
REG_SZ,
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* ROS: Save a copy for bugzilla reporting */
RtlCreateUnicodeString(&KeRosBiosDate, Data.Buffer);
/* Free the string */
RtlFreeUnicodeString(&Data);
}
/* Close the bios information handle */
NtClose(BiosHandle);
}
}
/* Get the BIOS Version */
if (CmpGetBiosVersion(BaseAddress, 16* PAGE_SIZE, Buffer))
{
/* Start at the beginning of our buffer */
CurrentVersion = BiosVersion;
do
{
/* Convert to Unicode */
RtlInitAnsiString(&TempString, Buffer);
RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE);
/* Calculate the length of this string and copy it in */
Length = Data.Length + sizeof(UNICODE_NULL);
RtlMoveMemory(CurrentVersion, Data.Buffer, Length);
/* Free the unicode string */
RtlFreeUnicodeString(&Data);
/* Update the total length and see if we're out of space */
TotalLength += Length;
if (TotalLength + 256 + sizeof(UNICODE_NULL) > PAGE_SIZE)
{
/* One more string would push us out, so stop here */
break;
}
/* Go to the next string inside the multi-string buffer */
CurrentVersion += Length;
/* Query the next BIOS Version */
} while (CmpGetBiosVersion(NULL, 0, Buffer));
/* Check if we found any strings at all */
if (TotalLength)
{
/* Add the final null-terminator */
*(PWSTR)CurrentVersion = UNICODE_NULL;
TotalLength += sizeof(UNICODE_NULL);
/* Write the BIOS Version to the registry */
RtlInitUnicodeString(&ValueName, L"SystemBiosVersion");
Status = NtSetValueKey(SystemHandle,
&ValueName,
0,
REG_MULTI_SZ,
BiosVersion,
TotalLength);
/* ROS: Save a copy for bugzilla reporting */
RtlCreateUnicodeString(&KeRosBiosVersion, (PWCH)BiosVersion);
}
}
/* Unmap the section */
ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
}
/* Now prepare for Video BIOS Mapping of 32KB */
BaseAddress = 0;
ViewSize = 8 * PAGE_SIZE;
ViewBase.LowPart = VideoRomBase;
ViewBase.HighPart = 0;
/* Map it */
Status = ZwMapViewOfSection(SectionHandle,
NtCurrentProcess(),
&BaseAddress,
0,
ViewSize,
&ViewBase,
&ViewSize,
ViewUnmap,
MEM_DOS_LIM,
PAGE_READWRITE);
if (NT_SUCCESS(Status))
{
/* Scan the ROM to get the BIOS Date */
if (CmpGetBiosDate(BaseAddress, 8 * PAGE_SIZE, Buffer, FALSE))
{
/* Convert it to Unicode */
RtlInitAnsiString(&TempString, Buffer);
RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE);
/* Write the date into the registry */
RtlInitUnicodeString(&ValueName, L"VideoBiosDate");
Status = NtSetValueKey(SystemHandle,
&ValueName,
0,
REG_SZ,
Data.Buffer,
Data.Length + sizeof(UNICODE_NULL));
/* ROS: Save a copy for bugzilla reporting */
RtlCreateUnicodeString(&KeRosVideoBiosDate, Data.Buffer);
/* Free the string */
RtlFreeUnicodeString(&Data);
}
/* Get the Video BIOS Version */
if (CmpGetBiosVersion(BaseAddress, 8* PAGE_SIZE, Buffer))
{
/* Start at the beginning of our buffer */
CurrentVersion = BiosVersion;
do
{
/* Convert to Unicode */
RtlInitAnsiString(&TempString, Buffer);
RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE);
/* Calculate the length of this string and copy it in */
Length = Data.Length + sizeof(UNICODE_NULL);
RtlMoveMemory(CurrentVersion, Data.Buffer, Length);
/* Free the unicode string */
RtlFreeUnicodeString(&Data);
/* Update the total length and see if we're out of space */
TotalLength += Length;
if (TotalLength + 256 + sizeof(UNICODE_NULL) > PAGE_SIZE)
{
/* One more string would push us out, so stop here */
break;
}
/* Go to the next string inside the multi-string buffer */
CurrentVersion += Length;
/* Query the next BIOS Version */
} while (CmpGetBiosVersion(NULL, 0, Buffer));
/* Check if we found any strings at all */
if (TotalLength)
{
/* Add the final null-terminator */
*(PWSTR)CurrentVersion = UNICODE_NULL;
TotalLength += sizeof(UNICODE_NULL);
/* Write the BIOS Version to the registry */
RtlInitUnicodeString(&ValueName, L"VideoBiosVersion");
Status = NtSetValueKey(SystemHandle,
&ValueName,
0,
REG_MULTI_SZ,
BiosVersion,
TotalLength);
/* ROS: Save a copy for bugzilla reporting */
RtlCreateUnicodeString(&KeRosVideoBiosVersion, (PWCH)BiosVersion);
}
}
/* Unmap the section */
ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
}
/* Close the section */
ZwClose(SectionHandle);
/* Free the BIOS version string buffer */
if (BiosVersion) ExFreePool(BiosVersion);
Quickie:
/* Close the procesor handle */
NtClose(KeyHandle);
return STATUS_SUCCESS;
}

View File

@@ -1,370 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/cm/ntapi.c
* PURPOSE: Native API Routines for Registry Access.
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
/* FUNCTIONS *****************************************************************/
NTSTATUS
NTAPI
NtCreateKey(OUT PHANDLE KeyHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN ULONG TitleIndex,
IN PUNICODE_STRING Class,
IN ULONG CreateOptions,
OUT PULONG Disposition)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtOpenKey(OUT PHANDLE KeyHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtFlushKey(IN HANDLE KeyHandle)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtLoadKey2 (IN POBJECT_ATTRIBUTES KeyObjectAttributes,
IN POBJECT_ATTRIBUTES FileObjectAttributes,
IN ULONG Flags)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtInitializeRegistry(IN USHORT Flag)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtDeleteKey(IN HANDLE KeyHandle)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtEnumerateKey(IN HANDLE KeyHandle,
IN ULONG Index,
IN KEY_INFORMATION_CLASS KeyInformationClass,
OUT PVOID KeyInformation,
IN ULONG Length,
OUT PULONG ResultLength)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtEnumerateValueKey(IN HANDLE KeyHandle,
IN ULONG Index,
IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
OUT PVOID KeyValueInformation,
IN ULONG Length,
OUT PULONG ResultLength)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtQueryKey(IN HANDLE KeyHandle,
IN KEY_INFORMATION_CLASS KeyInformationClass,
OUT PVOID KeyInformation,
IN ULONG Length,
OUT PULONG ResultLength)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtQueryValueKey(IN HANDLE KeyHandle,
IN PUNICODE_STRING ValueName,
IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
OUT PVOID KeyValueInformation,
IN ULONG Length,
OUT PULONG ResultLength)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtSetValueKey(IN HANDLE KeyHandle,
IN PUNICODE_STRING ValueName,
IN ULONG TitleIndex,
IN ULONG Type,
IN PVOID Data,
IN ULONG DataSize)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtDeleteValueKey(IN HANDLE KeyHandle,
IN PUNICODE_STRING ValueName)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtCompactKeys(IN ULONG Count,
IN PHANDLE KeyArray)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtCompressKey(IN HANDLE Key)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtLoadKey(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
IN POBJECT_ATTRIBUTES FileObjectAttributes)
{
return NtLoadKey2(KeyObjectAttributes, FileObjectAttributes, 0);
}
NTSTATUS
NTAPI
NtLoadKeyEx(IN POBJECT_ATTRIBUTES TargetKey,
IN POBJECT_ATTRIBUTES SourceFile,
IN ULONG Flags,
IN HANDLE TrustClassKey,
IN HANDLE Event,
IN ACCESS_MASK DesiredAccess,
OUT PHANDLE RootHandle)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtLockProductActivationKeys(IN PULONG pPrivateVer,
IN PULONG pSafeMode)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtLockRegistryKey(IN HANDLE KeyHandle)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtNotifyChangeMultipleKeys(IN HANDLE MasterKeyHandle,
IN ULONG Count,
IN POBJECT_ATTRIBUTES SlaveObjects,
IN HANDLE Event,
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG CompletionFilter,
IN BOOLEAN WatchTree,
OUT PVOID Buffer,
IN ULONG Length,
IN BOOLEAN Asynchronous)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtNotifyChangeKey(IN HANDLE KeyHandle,
IN HANDLE Event,
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG CompletionFilter,
IN BOOLEAN WatchTree,
OUT PVOID Buffer,
IN ULONG Length,
IN BOOLEAN Asynchronous)
{
return NtNotifyChangeMultipleKeys(KeyHandle,
0,
NULL,
Event,
ApcRoutine,
ApcContext,
IoStatusBlock,
CompletionFilter,
WatchTree,
Buffer,
Length,
Asynchronous);
}
NTSTATUS
NTAPI
NtQueryMultipleValueKey(IN HANDLE KeyHandle,
IN OUT PKEY_VALUE_ENTRY ValueList,
IN ULONG NumberOfValues,
OUT PVOID Buffer,
IN OUT PULONG Length,
OUT PULONG ReturnLength)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtQueryOpenSubKeys(IN POBJECT_ATTRIBUTES TargetKey,
IN ULONG HandleCount)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtQueryOpenSubKeysEx(IN POBJECT_ATTRIBUTES TargetKey,
IN ULONG BufferLength,
IN PVOID Buffer,
IN PULONG RequiredSize)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtReplaceKey(IN POBJECT_ATTRIBUTES ObjectAttributes,
IN HANDLE Key,
IN POBJECT_ATTRIBUTES ReplacedObjectAttributes)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtRestoreKey(IN HANDLE KeyHandle,
IN HANDLE FileHandle,
IN ULONG RestoreFlags)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtSaveKey(IN HANDLE KeyHandle,
IN HANDLE FileHandle)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtSaveKeyEx(IN HANDLE KeyHandle,
IN HANDLE FileHandle,
IN ULONG Flags)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtSaveMergedKeys(IN HANDLE HighPrecedenceKeyHandle,
IN HANDLE LowPrecedenceKeyHandle,
IN HANDLE FileHandle)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtSetInformationKey(IN HANDLE KeyHandle,
IN KEY_SET_INFORMATION_CLASS KeyInformationClass,
IN PVOID KeyInformation,
IN ULONG KeyInformationLength)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtUnloadKey(IN POBJECT_ATTRIBUTES KeyObjectAttributes)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtUnloadKey2(IN POBJECT_ATTRIBUTES TargetKey,
IN ULONG Flags)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtUnloadKeyEx(IN POBJECT_ATTRIBUTES TargetKey,
IN HANDLE Event)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
/* EOF */

View File

@@ -1,71 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/dbgk/dbgkutil.c
* PURPOSE: User-Mode Debugging Support, Internal Debug Functions.
*
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
DbgkCreateThread(PVOID StartAddress)
{
#if 0
LPC_DBG_MESSAGE Message;
LPC_DBG_MESSAGE Reply;
NTSTATUS Status;
if (PsGetCurrentThread()->ThreadsProcess->DebugPort == NULL)
{
return;
}
Message.Header.MessageSize = sizeof(LPC_DBG_MESSAGE);
Message.Header.DataSize = sizeof(LPC_DBG_MESSAGE) -
sizeof(LPC_MESSAGE);
Message.Type = DBG_EVENT_CREATE_THREAD;
Message.Status = STATUS_SUCCESS;
Message.Data.CreateThread.Reserved = 0;
Message.Data.CreateThread.StartAddress = StartAddress;
/* FIXME: Freeze all threads in process */
/* Send the message to the process's debug port and wait for a reply */
Status =
LpcSendDebugMessagePort(PsGetCurrentThread()->ThreadsProcess->DebugPort,
&Message,
&Reply);
if (!NT_SUCCESS(Status))
{
return;
}
/* FIXME: Examine reply */
return;
#endif
}
VOID
NTAPI
DbgkExitProcess(IN NTSTATUS ExitStatus)
{
/* FIXME */
}
VOID
NTAPI
DbgkExitThread(IN NTSTATUS ExitStatus)
{
/* FIXME */
}
/* EOF */

View File

@@ -1,173 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/dbgk/debug.c
* PURPOSE: User-Mode Debugging Support, Debug Object Management.
*
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
POBJECT_TYPE DbgkDebugObjectType;
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
DbgkCopyProcessDebugPort(IN PEPROCESS Process,
IN PEPROCESS Parent)
{
/* FIXME: Implement */
}
NTSTATUS
NTAPI
NtCreateDebugObject(OUT PHANDLE DebugHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN BOOLEAN KillProcessOnExit)
{
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PDBGK_DEBUG_OBJECT DebugObject;
HANDLE hDebug;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtCreateDebugObject(0x%p, 0x%x, 0x%p)\n", DebugHandle, DesiredAccess, ObjectAttributes);
/* Check Output Safety */
if(PreviousMode != KernelMode) {
_SEH_TRY {
ProbeForWrite(DebugHandle,
sizeof(HANDLE),
sizeof(ULONG));
} _SEH_HANDLE {
Status = _SEH_GetExceptionCode();
} _SEH_END;
if(!NT_SUCCESS(Status)) return Status;
}
/* Create the Object */
Status = ObCreateObject(PreviousMode,
DbgkDebugObjectType,
ObjectAttributes,
PreviousMode,
NULL,
sizeof(PDBGK_DEBUG_OBJECT),
0,
0,
(PVOID*)&DebugObject);
/* Check for Success */
if(NT_SUCCESS(Status)) {
/* Initialize the Debug Object's Fast Mutex */
ExInitializeFastMutex(&DebugObject->Mutex);
/* Initialize the State Event List */
InitializeListHead(&DebugObject->StateEventListEntry);
/* Initialize the Debug Object's Wait Event */
KeInitializeEvent(&DebugObject->Event, NotificationEvent, 0);
/* Set the Flags */
DebugObject->KillProcessOnExit = KillProcessOnExit;
/* Insert it */
Status = ObInsertObject((PVOID)DebugObject,
NULL,
DesiredAccess,
0,
NULL,
&hDebug);
ObDereferenceObject(DebugObject);
/* Check for success and return handle */
if(NT_SUCCESS(Status)) {
_SEH_TRY {
*DebugHandle = hDebug;
} _SEH_HANDLE {
Status = _SEH_GetExceptionCode();
} _SEH_END;
}
}
/* Return Status */
return Status;
}
NTSTATUS
NTAPI
NtWaitForDebugEvent(IN HANDLE DebugObject, // Debug object handle must grant DEBUG_OBJECT_WAIT_STATE_CHANGE access.
IN BOOLEAN Alertable,
IN PLARGE_INTEGER Timeout OPTIONAL,
OUT PDBGUI_WAIT_STATE_CHANGE StateChange)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtDebugContinue(IN HANDLE DebugObject, // Debug object handle must grant DEBUG_OBJECT_WAIT_STATE_CHANGE access.
IN PCLIENT_ID AppClientId,
IN NTSTATUS ContinueStatus)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtDebugActiveProcess(IN HANDLE Process, // Process handle must grant PROCESS_SUSPEND_RESUME access.
IN HANDLE DebugObject) // Debug object handle must grant DEBUG_OBJECT_ADD_REMOVE_PROCESS access.
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtRemoveProcessDebug(IN HANDLE Process, // Process handle must grant PROCESS_SUSPEND_RESUME access.
IN HANDLE DebugObject) // Debug object handle must grant DEBUG_OBJECT_ADD_REMOVE_PROCESS access.
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtSetInformationDebugObject(IN HANDLE DebugObject, // Debug object handle need not grant any particular access right.
IN DEBUGOBJECTINFOCLASS DebugObjectInformationClass,
IN PVOID DebugInformation,
IN ULONG DebugInformationLength,
OUT PULONG ReturnLength OPTIONAL)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
/* EOF */

View File

@@ -1,494 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* COPYRIGHT: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/ex/atom.c
* PURPOSE: Executive Atom Functions
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* Gunnar Dalsnes
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#define TAG_ATOM TAG('A', 't', 'o', 'm')
/* GLOBALS ****************************************************************/
/*
* FIXME: this is WRONG! The global atom table should live in the WinSta struct
* and accessed through a win32k callout (received in PsEstablishWin32Callouts)
* NOTE: There is a session/win32k global atom table also, but its private to
* win32k. Its used for RegisterWindowMessage() and for window classes.
* -Gunnar
*/
PRTL_ATOM_TABLE GlobalAtomTable;
/* PRIVATE FUNCTIONS *********************************************************/
/*++
* @name ExpGetGlobalAtomTable
*
* Gets pointer to a global atom table, creates it if not already created
*
* @return Pointer to the RTL_ATOM_TABLE, or NULL if it's impossible
* to create atom table
*
* @remarks Internal function
*
*--*/
PRTL_ATOM_TABLE
NTAPI
ExpGetGlobalAtomTable(VOID)
{
NTSTATUS Status;
/* Return it if we have one */
if (GlobalAtomTable) return GlobalAtomTable;
/* Create it */
Status = RtlCreateAtomTable(37, &GlobalAtomTable);
/* If we couldn't create it, return NULL */
if (!NT_SUCCESS(Status)) return NULL;
/* Return the newly created one */
return GlobalAtomTable;
}
/* FUNCTIONS ****************************************************************/
/*++
* @name NtAddAtom
* @implemented
*
* Function NtAddAtom creates new Atom in Global Atom Table. If Atom
* with the same name already exist, internal Atom counter is incremented.
* See: http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Atoms/NtAddAtom.html
*
* @param AtomName
* Atom name in Unicode
*
* @param AtomNameLength
* Length of the atom name
*
* @param Atom
* Pointer to RTL_ATOM
*
* @return STATUS_SUCCESS in case of success, proper error code
* othwerwise.
*
* @remarks None
*
*--*/
NTSTATUS
NTAPI
NtAddAtom(IN PWSTR AtomName,
IN ULONG AtomNameLength,
OUT PRTL_ATOM Atom)
{
PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable();
NTSTATUS Status = STATUS_SUCCESS;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
LPWSTR CapturedName = NULL;
ULONG CapturedSize;
RTL_ATOM SafeAtom;
PAGED_CODE();
/* Check for the table */
if (AtomTable == NULL) return STATUS_ACCESS_DENIED;
/* Check for valid name */
if (AtomNameLength > (RTL_MAXIMUM_ATOM_LENGTH * sizeof(WCHAR)))
{
/* Fail */
DPRINT1("Atom name too long\n");
return STATUS_INVALID_PARAMETER;
}
/* Check if we're called from user-mode*/
if (PreviousMode != KernelMode)
{
/* Enter SEH */
_SEH_TRY
{
/* Check if we have a name */
if (AtomName)
{
/* Probe the atom */
ProbeForRead(AtomName, AtomNameLength, sizeof(WCHAR));
/* Allocate an aligned buffer + the null char */
CapturedSize = ((AtomNameLength + sizeof(WCHAR)) &~
(sizeof(WCHAR) -1));
CapturedName = ExAllocatePoolWithTag(PagedPool,
CapturedSize,
TAG_ATOM);
if (!CapturedName)
{
/* Fail the call */
Status = STATUS_INSUFFICIENT_RESOURCES;
}
else
{
/* Copy the name and null-terminate it */
RtlMoveMemory(CapturedName, AtomName, AtomNameLength);
CapturedName[AtomNameLength / sizeof(WCHAR)] = UNICODE_NULL;
}
/* Probe the atom too */
if (Atom) ProbeForWriteUshort(Atom);
}
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
else
{
/* Simplify code and re-use one variable */
if (AtomName) CapturedName = AtomName;
}
/* Make sure probe worked */
if (NT_SUCCESS(Status))
{
/* Call the runtime function */
Status = RtlAddAtomToAtomTable(AtomTable, CapturedName, &SafeAtom);
if (NT_SUCCESS(Status) && (Atom))
{
/* Success and caller wants the atom back.. .enter SEH */
_SEH_TRY
{
/* Return the atom */
*Atom = SafeAtom;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
}
/* If we captured anything, free it */
if ((CapturedName) && (CapturedName != AtomName)) ExFreePool(CapturedName);
/* Return to caller */
return Status;
}
/*++
* @name NtDeleteAtom
* @implemented
*
* Removes Atom from Global Atom Table. If Atom's reference counter
* is greater then 1, function decrements this counter, but Atom
* stayed in Global Atom Table.
* See: http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Atoms/NtDeleteAtom.html
*
* @param Atom
* Atom identifier
*
* @return STATUS_SUCCESS in case of success, proper error code
* othwerwise.
*
* @remarks None
*
*--*/
NTSTATUS
NTAPI
NtDeleteAtom(IN RTL_ATOM Atom)
{
PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable();
PAGED_CODE();
/* Check for valid table */
if (AtomTable == NULL) return STATUS_ACCESS_DENIED;
/* Call worker function */
return RtlDeleteAtomFromAtomTable(AtomTable, Atom);
}
/*++
* @name NtFindAtom
* @implemented
*
* Retrieves existing Atom's identifier without incrementing Atom's
* internal counter
* See: http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Atoms/NtFindAtom.html
*
* @param AtomName
* Atom name in Unicode
*
* @param AtomNameLength
* Length of the atom name
*
* @param Atom
* Pointer to RTL_ATOM
*
* @return STATUS_SUCCESS in case of success, proper error code
* othwerwise.
*
* @remarks None
*
*--*/
NTSTATUS
NTAPI
NtFindAtom(IN PWSTR AtomName,
IN ULONG AtomNameLength,
OUT PRTL_ATOM Atom)
{
PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable();
NTSTATUS Status = STATUS_SUCCESS;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
LPWSTR CapturedName = NULL;
ULONG CapturedSize;
RTL_ATOM SafeAtom;
PAGED_CODE();
/* Check for the table */
if (AtomTable == NULL) return STATUS_ACCESS_DENIED;
/* Check for valid name */
if (AtomNameLength > (RTL_MAXIMUM_ATOM_LENGTH * sizeof(WCHAR)))
{
/* Fail */
DPRINT1("Atom name too long\n");
return STATUS_INVALID_PARAMETER;
}
/* Check if we're called from user-mode*/
if (PreviousMode != KernelMode)
{
/* Enter SEH */
_SEH_TRY
{
/* Check if we have a name */
if (AtomName)
{
/* Probe the atom */
ProbeForRead(AtomName, AtomNameLength, sizeof(WCHAR));
/* Allocate an aligned buffer + the null char */
CapturedSize = ((AtomNameLength + sizeof(WCHAR)) &~
(sizeof(WCHAR) -1));
CapturedName = ExAllocatePoolWithTag(PagedPool,
CapturedSize,
TAG_ATOM);
if (!CapturedName)
{
/* Fail the call */
Status = STATUS_INSUFFICIENT_RESOURCES;
}
else
{
/* Copy the name and null-terminate it */
RtlMoveMemory(CapturedName, AtomName, AtomNameLength);
CapturedName[AtomNameLength / sizeof(WCHAR)] = UNICODE_NULL;
}
/* Probe the atom too */
if (Atom) ProbeForWriteUshort(Atom);
}
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
else
{
/* Simplify code and re-use one variable */
if (AtomName) CapturedName = AtomName;
}
/* Make sure probe worked */
if (NT_SUCCESS(Status))
{
/* Call the runtime function */
Status = RtlLookupAtomInAtomTable(AtomTable, CapturedName, &SafeAtom);
if (NT_SUCCESS(Status) && (Atom))
{
/* Success and caller wants the atom back.. .enter SEH */
_SEH_TRY
{
/* Return the atom */
*Atom = SafeAtom;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
}
/* If we captured anything, free it */
if ((CapturedName) && (CapturedName != AtomName)) ExFreePool(CapturedName);
/* Return to caller */
return Status;
}
/*++
* @name NtQueryInformationAtom
* @implemented
*
* Gets single Atom properties or reads Global Atom Table
* See: http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Atoms/NtQueryInformationAtom.html
*
* @param Atom
* Atom to query. If AtomInformationClass parameter is
* AtomTableInformation, Atom parameter is not used.
*
* @param AtomInformationClass
* See ATOM_INFORMATION_CLASS enumeration type for details
*
* @param AtomInformation
* Result of call - pointer to user's allocated buffer for data
*
* @param AtomInformationLength
* Size of AtomInformation buffer, in bytes
*
* @param ReturnLength
* Pointer to ULONG value containing required AtomInformation
* buffer size
*
* @return STATUS_SUCCESS in case of success, proper error code
* othwerwise.
*
* @remarks None
*
*--*/
NTSTATUS
NTAPI
NtQueryInformationAtom(RTL_ATOM Atom,
ATOM_INFORMATION_CLASS AtomInformationClass,
PVOID AtomInformation,
ULONG AtomInformationLength,
PULONG ReturnLength)
{
PRTL_ATOM_TABLE AtomTable = ExpGetGlobalAtomTable();
PATOM_BASIC_INFORMATION BasicInformation = AtomInformation;
PATOM_TABLE_INFORMATION TableInformation = AtomInformation;
NTSTATUS Status = STATUS_SUCCESS;
ULONG Flags, UsageCount, NameLength, RequiredLength = 0;
KPROCESSOR_MODE PreviousMode;
PAGED_CODE();
/* Check for valid table */
if (AtomTable == NULL) return STATUS_ACCESS_DENIED;
PreviousMode = ExGetPreviousMode();
_SEH_TRY
{
/* Probe the parameters */
if (PreviousMode != KernelMode)
{
ProbeForWrite(AtomInformation,
AtomInformationLength,
sizeof(ULONG));
if (ReturnLength != NULL)
{
ProbeForWriteUlong(ReturnLength);
}
}
/* Choose class */
switch (AtomInformationClass)
{
/* Caller requested info about an atom */
case AtomBasicInformation:
/* Size check */
RequiredLength = FIELD_OFFSET(ATOM_BASIC_INFORMATION, Name);
if (RequiredLength > AtomInformationLength)
{
/* Fail */
DPRINT1("Buffer too small\n");
Status = STATUS_INFO_LENGTH_MISMATCH;
_SEH_LEAVE;
}
/* Prepare query */
UsageCount = 0;
NameLength = AtomInformationLength - RequiredLength;
BasicInformation->Name[0] = UNICODE_NULL;
/* Query the data */
Status = RtlQueryAtomInAtomTable(AtomTable,
Atom,
&UsageCount,
&Flags,
BasicInformation->Name,
&NameLength);
if (NT_SUCCESS(Status))
{
/* Return data */
BasicInformation->UsageCount = (USHORT)UsageCount;
BasicInformation->Flags = (USHORT)Flags;
BasicInformation->NameLength = (USHORT)NameLength;
RequiredLength += NameLength + sizeof(WCHAR);
}
break;
/* Caller requested info about an Atom Table */
case AtomTableInformation:
/* Size check */
RequiredLength = FIELD_OFFSET(ATOM_TABLE_INFORMATION, Atoms);
if (RequiredLength > AtomInformationLength)
{
/* Fail */
DPRINT1("Buffer too small\n");
Status = STATUS_INFO_LENGTH_MISMATCH;
_SEH_LEAVE;
}
/* Query the data */
Status = RtlQueryAtomListInAtomTable(AtomTable,
(AtomInformationLength - RequiredLength) /
sizeof(RTL_ATOM),
&TableInformation->NumberOfAtoms,
TableInformation->Atoms);
if (NT_SUCCESS(Status))
{
/* Update the return length */
RequiredLength += TableInformation->NumberOfAtoms * sizeof(RTL_ATOM);
}
break;
/* Caller was on crack */
default:
/* Unrecognized class */
Status = STATUS_INVALID_INFO_CLASS;
break;
}
/* Return the required size */
if (ReturnLength != NULL)
{
*ReturnLength = RequiredLength;
}
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Return to caller */
return Status;
}
/* EOF */

View File

@@ -1,504 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/ex/callback.c
* PURPOSE: Executive callbacks
* PROGRAMMERS: Filip Navara
* Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, ExpInitializeCallbacks)
#endif
/* TYPES ********************************************************************/
/* Mapping for Callback Object */
GENERIC_MAPPING ExpCallbackMapping =
{
CALLBACK_READ,
CALLBACK_WRITE,
CALLBACK_EXECUTE,
CALLBACK_ALL_ACCESS
};
/* Structure used to hold Callbacks */
typedef struct _CALLBACK_REGISTRATION
{
LIST_ENTRY RegisteredCallbacks;
PCALLBACK_OBJECT CallbackObject;
PCALLBACK_FUNCTION CallbackFunction;
PVOID CallbackContext;
ULONG InUse;
BOOLEAN PendingDeletion;
} CALLBACK_REGISTRATION, *PCALLBACK_REGISTRATION;
typedef struct
{
PCALLBACK_OBJECT *CallbackObject;
PWSTR Name;
} SYSTEM_CALLBACKS;
/* Kernel Default Callbacks */
PCALLBACK_OBJECT SetSystemTimeCallback;
PCALLBACK_OBJECT SetSystemStateCallback;
PCALLBACK_OBJECT PowerStateCallback;
SYSTEM_CALLBACKS ExpInitializeCallback[] =
{
{&SetSystemTimeCallback, L"\\Callback\\SetSystemTime"},
{&SetSystemStateCallback, L"\\Callback\\SetSystemState"},
{&PowerStateCallback, L"\\Callback\\PowerState"},
{NULL, NULL}
};
POBJECT_TYPE ExCallbackObjectType;
KEVENT ExpCallbackEvent;
/* FUNCTIONS *****************************************************************/
/*++
* @name ExpInitializeCallbacks
*
* Creates the Callback Object as a valid Object Type in the Kernel.
* Internal function, subject to further review
*
* @return TRUE if the Callback Object Type was successfully created.
*
* @remarks None
*
*--*/
VOID
INIT_FUNCTION
NTAPI
ExpInitializeCallbacks(VOID)
{
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
UNICODE_STRING DirName = RTL_CONSTANT_STRING(L"\\Callback");
UNICODE_STRING CallbackName;
UNICODE_STRING Name;
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
HANDLE DirectoryHandle;
ULONG i;
/* Initialize the Callback Object type */
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
RtlInitUnicodeString(&Name, L"Callback");
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(CALLBACK_OBJECT);
ObjectTypeInitializer.GenericMapping = ExpCallbackMapping;
ObjectTypeInitializer.PoolType = NonPagedPool;
Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExCallbackObjectType);
/* Fail if it wasn't created successfully */
if (!NT_SUCCESS(Status))
{
return;
}
/* Initialize the Object */
InitializeObjectAttributes(
&ObjectAttributes,
&DirName,
OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
NULL,
NULL
);
/* Create the Object Directory */
Status = NtCreateDirectoryObject(
&DirectoryHandle,
DIRECTORY_ALL_ACCESS,
&ObjectAttributes
);
/* Fail if couldn't create */
if (!NT_SUCCESS(Status))
{
return;
}
/* Close Handle... */
NtClose(DirectoryHandle);
/* Initialize Event used when unregistering */
KeInitializeEvent(&ExpCallbackEvent, NotificationEvent, 0);
/* Default NT Kernel Callbacks. */
for (i=0; ExpInitializeCallback[i].CallbackObject; i++)
{
/* Create the name from the structure */
RtlInitUnicodeString(&CallbackName, ExpInitializeCallback[i].Name);
/* Initialize the Object Attributes Structure */
InitializeObjectAttributes(
&ObjectAttributes,
&CallbackName,
OBJ_PERMANENT | OBJ_CASE_INSENSITIVE,
NULL,
NULL
);
/* Create the Callback Object */
Status = ExCreateCallback(
(PCALLBACK_OBJECT*)&(ExpInitializeCallback[i].CallbackObject),
&ObjectAttributes,
TRUE,
TRUE
);
/* Make sure Global Callbacks have been created */
if (!NT_SUCCESS(Status))
{
return;
}
}
/* Everything successful */
}
/*++
* @name ExCreateCallback
* @implemented
*
* Opens or creates a Callback Object. Creates only if Create is true.
* Allows multiple Callback Functions to be registred only if
* AllowMultipleCallbacks is true.
* See: http://www.osronline.com/ddkx/kmarch/k102_967m.htm
* http://www.osronline.com/article.cfm?id=24
*
* @param CallbackObject
* Pointer that will receive the Callback Object.
*
* @param CallbackName
* Name of Callback
*
* @param Create
* Determines if the object will be created if it doesn't exit
*
* @param AllowMultipleCallbacks
* Determines if more then one registered callback function
* can be attached to this Callback Object.
*
* @return STATUS_SUCESS if not failed.
*
* @remarks Must be called at IRQL = PASSIVE_LEVEL
*
*--*/
NTSTATUS
NTAPI
ExCreateCallback(OUT PCALLBACK_OBJECT *CallbackObject,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN BOOLEAN Create,
IN BOOLEAN AllowMultipleCallbacks)
{
PCALLBACK_OBJECT Callback;
NTSTATUS Status;
HANDLE Handle;
PAGED_CODE();
/* Open a handle to the callback if it exists */
if (ObjectAttributes->ObjectName)
{
Status = ObOpenObjectByName(ObjectAttributes,
ExCallbackObjectType,
KernelMode,
NULL,
0,
NULL,
&Handle);
}
else
{
Status = STATUS_UNSUCCESSFUL;
}
/* We weren't able to open it...should we create it? */
if(!NT_SUCCESS(Status) && Create )
{
Status = ObCreateObject(KernelMode,
ExCallbackObjectType,
ObjectAttributes,
KernelMode,
NULL,
sizeof(CALLBACK_OBJECT),
0,
0,
(PVOID *)&Callback );
/* We Created it...let's initialize the structure now */
if(NT_SUCCESS(Status))
{
KeInitializeSpinLock(&Callback->Lock); /* SpinLock */
InitializeListHead(&Callback->RegisteredCallbacks); /* Callback Entries */
Callback->AllowMultipleCallbacks = AllowMultipleCallbacks; /* Multiple Callbacks */
/* Create the object */
Status = ObInsertObject(Callback,
NULL,
FILE_READ_DATA,
0,
NULL,
&Handle );
}
}
if(NT_SUCCESS(Status))
{
/* Get a pointer to the new object from the handle we just got */
Status = ObReferenceObjectByHandle(Handle,
0,
ExCallbackObjectType,
KernelMode,
(PVOID)&Callback,
NULL);
/* Close the Handle, since we now have the pointer */
ZwClose(Handle);
}
/* Everything went fine, so return a pointer to the Object */
if (NT_SUCCESS(Status))
{
*CallbackObject = (PCALLBACK_OBJECT)Callback;
}
return Status;
}
/*++
* @name ExNotifyCallback
* @implemented
*
* Calls a function pointer (a registered callback)
* See: http://www.osronline.com/ddkx/kmarch/k102_2f5e.htm
* http://msdn.microsoft.com/library/en-us/Kernel_d/hh/Kernel_d/Synchro_e954f515-e536-4e12-8419-e7e54c4a963b.xml.asp?frame=true
* http://vmsone.com/~decuslib/vmssig/vmslt99b/nt/wdm-callback.txt
*
* @param CallbackObject
* Which callback to call
*
* @param Argument1
* Pointer/data to send to callback function
*
* @param Argument2
* Pointer/data to send to callback function
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
ExNotifyCallback(IN PCALLBACK_OBJECT OpaqueCallbackObject,
IN PVOID Argument1,
IN PVOID Argument2)
{
PCALLBACK_OBJECT CallbackObject = (PCALLBACK_OBJECT)OpaqueCallbackObject;
PLIST_ENTRY RegisteredCallbacks;
PCALLBACK_REGISTRATION CallbackRegistration;
KIRQL OldIrql;
/* Acquire the Lock */
OldIrql = KfAcquireSpinLock(&CallbackObject->Lock);
/* Enumerate through all the registered functions */
for (RegisteredCallbacks = CallbackObject->RegisteredCallbacks.Flink;
RegisteredCallbacks != &CallbackObject->RegisteredCallbacks;
RegisteredCallbacks = RegisteredCallbacks->Flink)
{
/* Get a pointer to a Callback Registration from the List Entries */
CallbackRegistration = CONTAINING_RECORD(RegisteredCallbacks,
CALLBACK_REGISTRATION,
RegisteredCallbacks);
/* Don't bother doing Callback Notification if it's pending to be deleted */
if (!CallbackRegistration->PendingDeletion)
{
/* Mark the Callback in use, so it won't get deleted while we are calling it */
CallbackRegistration->InUse += 1;
/* Release the Spinlock before making the call */
KfReleaseSpinLock(&CallbackObject->Lock, OldIrql);
/* Call the Registered Function */
CallbackRegistration->CallbackFunction(
CallbackRegistration->CallbackContext,
Argument1,
Argument2
);
/* Get SpinLock back */
OldIrql = KfAcquireSpinLock(&CallbackObject->Lock);
/* We are not in use anymore */
CallbackRegistration->InUse -= 1;
/* If another instance of this function isn't running and deletion is pending, signal the event */
if (CallbackRegistration->PendingDeletion && CallbackRegistration->InUse == 0)
{
KeSetEvent(&ExpCallbackEvent, 0, FALSE);
}
}
}
/* Unsynchronize and release the Callback Object */
KfReleaseSpinLock(&CallbackObject->Lock, OldIrql);
}
/*++
* @name ExRegisterCallback
* @implemented
*
* Allows a function to associate a callback pointer (Function) to
* a created Callback object
* See: DDK, OSR, links in ExNotifyCallback
*
* @param CallbackObject
* The Object Created with ExCreateCallBack
*
* @param CallBackFunction
* Pointer to the function to be called back
*
* @param CallBackContext
* Block of memory that can contain user-data which will be
* passed on to the callback
*
* @return A handle to a Callback Registration Structure (MSDN Documentation)
*
* @remarks None
*
*--*/
PVOID
NTAPI
ExRegisterCallback(IN PCALLBACK_OBJECT OpaqueCallbackObject,
IN PCALLBACK_FUNCTION CallbackFunction,
IN PVOID CallbackContext)
{
PCALLBACK_OBJECT CallbackObject = (PCALLBACK_OBJECT)OpaqueCallbackObject;
PCALLBACK_REGISTRATION CallbackRegistration = NULL;
KIRQL OldIrql;
PAGED_CODE();
/* Create reference to Callback Object */
ObReferenceObject (CallbackObject);
/* Allocate memory for the structure */
CallbackRegistration = ExAllocatePoolWithTag(
NonPagedPool,
sizeof(CallbackRegistration),
CALLBACK_TAG
);
/* Fail if memory allocation failed */
if(!CallbackRegistration)
{
ObDereferenceObject (CallbackObject);
return NULL;
}
/* Create Callback Registration */
CallbackRegistration->CallbackObject = CallbackObject; /* When unregistering, drivers send a handle to the Registration, not the object... */
CallbackRegistration->CallbackFunction = CallbackFunction; /* NotifyCallback uses Objects, so this needs to be here in order to call the registered functions */
CallbackRegistration->CallbackContext = CallbackContext; /* The documented NotifyCallback returns the Context, so we must save this somewhere */
/* Acquire SpinLock */
OldIrql = KfAcquireSpinLock (&CallbackObject->Lock);
/* Add Callback if 1) No Callbacks registered or 2) Multiple Callbacks allowed */
if(CallbackObject->AllowMultipleCallbacks || IsListEmpty(&CallbackObject->RegisteredCallbacks))
{
InsertTailList(&CallbackObject->RegisteredCallbacks,&CallbackRegistration->RegisteredCallbacks);
}
else
{
ExFreePool(CallbackRegistration);
CallbackRegistration = NULL;
}
/* Release SpinLock */
KfReleaseSpinLock(&CallbackObject->Lock, OldIrql);
/* Return handle to Registration Object */
return (PVOID)CallbackRegistration;
}
/*++
* @name ExUnregisterCallback
* @implemented
*
* Deregisters a CallBack
* See: DDK, OSR, links in ExNotifyCallback
*
* @param CallbackRegistration
* Callback Registration Handle
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
ExUnregisterCallback(IN PVOID CallbackRegistrationHandle)
{
PCALLBACK_REGISTRATION CallbackRegistration;
PCALLBACK_OBJECT CallbackObject;
KIRQL OldIrql;
PAGED_CODE();
/* Convert Handle to valid Structure Pointer */
CallbackRegistration = (PCALLBACK_REGISTRATION) CallbackRegistrationHandle;
/* Get the Callback Object */
CallbackObject = CallbackRegistration->CallbackObject;
/* Lock the Object */
OldIrql = KfAcquireSpinLock (&CallbackObject->Lock);
/* We can't Delete the Callback if it's in use, because this would create a call towards a null pointer => crash */
while (CallbackRegistration->InUse)
{
/* Similarly, we also don't want to wait ages for all pending callbacks to be called */
CallbackRegistration->PendingDeletion = TRUE;
/* We are going to wait for the event, so the Lock isn't necessary */
KfReleaseSpinLock (&CallbackObject->Lock, OldIrql);
/* Make sure the event is cleared */
KeClearEvent (&ExpCallbackEvent);
/* Wait for the Event */
KeWaitForSingleObject (
&ExpCallbackEvent,
Executive,
KernelMode,
FALSE,
NULL
);
/* We need the Lock again */
OldIrql = KfAcquireSpinLock(&CallbackObject->Lock);
}
/* Remove the Callback */
RemoveEntryList(&CallbackRegistration->RegisteredCallbacks);
/* It's now safe to release the lock */
KfReleaseSpinLock(&CallbackObject->Lock, OldIrql);
/* Delete this registration */
ExFreePool(CallbackRegistration);
/* Remove the reference */
ObDereferenceObject(CallbackObject);
}
/* EOF */

View File

@@ -1,82 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/ex/dbgctrl.c
* PURPOSE: System debug control
* PROGRAMMERS: Alex Ionescu
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
/*++
* @name NtSystemDebugControl
* @implemented
*
* Perform various queries to debugger.
* This API is subject to test-case creation to further evaluate its
* abilities (if needed to at all)
*
* See: http://www.osronline.com/showthread.cfm?link=93915
* http://void.ru/files/Ntexapi.h
* http://www.codeguru.com/code/legacy/system/ntexapi.zip
* http://www.securityfocus.com/bid/9694
*
* @param ControlCode
* Description of the parameter. Wrapped to more lines on ~70th
* column.
*
* @param InputBuffer
* FILLME
*
* @param InputBufferLength
* FILLME
*
* @param OutputBuffer
* FILLME
*
* @param OutputBufferLength
* FILLME
*
* @param ReturnLength
* FILLME
*
* @return STATUS_SUCCESS in case of success, proper error code otherwise
*
* @remarks None
*
*--*/
NTSTATUS
NTAPI
NtSystemDebugControl(SYSDBG_COMMAND ControlCode,
PVOID InputBuffer,
ULONG InputBufferLength,
PVOID OutputBuffer,
ULONG OutputBufferLength,
PULONG ReturnLength)
{
switch (ControlCode)
{
case SysDbgQueryTraceInformation:
case SysDbgSetTracepoint:
case SysDbgSetSpecialCall:
case SysDbgClearSpecialCalls:
case SysDbgQuerySpecialCalls:
case SysDbgBreakPoint:
break;
case SysDbgQueryVersion:
KDB_LOADUSERMODULE_HOOK((PLDR_DATA_TABLE_ENTRY) InputBuffer);
break;
default:
break;
}
return STATUS_SUCCESS;
}

View File

@@ -1,91 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/io/efi.c
* PURPOSE: I/O Functions for EFI Machines
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
NTSTATUS
NTAPI
NtAddBootEntry(IN PUNICODE_STRING EntryName,
IN PUNICODE_STRING EntryValue)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtDeleteBootEntry(IN PUNICODE_STRING EntryName,
IN PUNICODE_STRING EntryValue)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtEnumerateBootEntries(IN PVOID Buffer,
IN PULONG BufferLength)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtQueryBootEntryOrder(IN PULONG Ids,
IN PULONG Count)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtQueryBootOptions(IN PBOOT_OPTIONS BootOptions,
IN PULONG BootOptionsLength)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtSetBootEntryOrder(IN PULONG Ids,
IN PULONG Count)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtSetBootOptions(IN PBOOT_OPTIONS BootOptions,
IN ULONG FieldsToChange)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
NtTranslateFilePath(PFILE_PATH InputFilePath,
ULONG OutputType,
PFILE_PATH OutputFilePath,
ULONG OutputFilePathLength)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
/* EOF */

View File

@@ -1,443 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/ex/error.c
* PURPOSE: Error Functions and Status/Exception Dispatching/Raising
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#define TAG_ERR TAG('E', 'r', 'r', ' ')
/* GLOBALS ****************************************************************/
BOOLEAN ExReadyForErrors = FALSE;
PEPORT ExpDefaultErrorPort = NULL;
PEPROCESS ExpDefaultErrorPortProcess = NULL;
/* FUNCTIONS ****************************************************************/
/*++
* @name ExpRaiseHardError
*
* For now it's a stub
*
* @param ErrorStatus
* FILLME
*
* @param NumberOfParameters
* FILLME
*
* @param UnicodeStringParameterMask
* FILLME
*
* @param Parameters
* FILLME
*
* @param ValidResponseOptions
* FILLME
*
* @param Response
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
ExpRaiseHardError(IN NTSTATUS ErrorStatus,
IN ULONG NumberOfParameters,
IN ULONG UnicodeStringParameterMask,
IN PULONG_PTR Parameters,
IN ULONG ValidResponseOptions,
OUT PULONG Response)
{
UNIMPLEMENTED;
}
/*++
* @name ExRaiseAccessViolation
* @implemented
*
* The ExRaiseAccessViolation routine can be used with structured exception
* handling to throw a driver-determined exception for a memory access
* violation that occurs when a driver processes I/O requests.
* See: http://msdn.microsoft.com/library/en-us/Kernel_r/hh/Kernel_r/k102_71b4c053-599c-4a6d-8a59-08aae6bdc534.xml.asp?frame=true
* http://www.osronline.com/ddkx/kmarch/k102_814i.htm
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
ExRaiseAccessViolation(VOID)
{
/* Raise the Right Status */
RtlRaiseStatus(STATUS_ACCESS_VIOLATION);
}
/*++
* @name ExRaiseDatatypeMisalignment
* @implemented
*
* ExRaiseDatatypeMisalignment raises an exception with the exception
* code set to STATUS_DATATYPE_MISALIGNMENT
* See: MSDN / DDK
* http://www.osronline.com/ddkx/kmarch/k102_814i.htm
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
ExRaiseDatatypeMisalignment(VOID)
{
/* Raise the Right Status */
RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
}
/*++
* @name ExSystemExceptionFilter
* @implemented
*
* TODO: Add description
*
* @return FILLME
*
* @remarks None
*
*--*/
LONG
NTAPI
ExSystemExceptionFilter(VOID)
{
return KeGetPreviousMode() != KernelMode ?
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
}
/*++
* @name ExRaiseHardError
* @implemented
*
* See NtRaiseHardError
*
* @param ErrorStatus
* Error Code
*
* @param NumberOfParameters
* Number of optional parameters in Parameters array
*
* @param UnicodeStringParameterMask
* Optional string parameter (can be only one per error code)
*
* @param Parameters
* Array of DWORD parameters for use in error message string
*
* @param ValidResponseOptions
* See HARDERROR_RESPONSE_OPTION for possible values description
*
* @param Response
* Pointer to HARDERROR_RESPONSE enumeration
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
ExRaiseHardError(IN NTSTATUS ErrorStatus,
IN ULONG NumberOfParameters,
IN ULONG UnicodeStringParameterMask,
IN PULONG_PTR Parameters,
IN ULONG ValidResponseOptions,
OUT PULONG Response)
{
/* FIXME: Capture to user-mode! */
/* Now call the worker function */
ExpRaiseHardError(ErrorStatus,
NumberOfParameters,
UnicodeStringParameterMask,
Parameters,
ValidResponseOptions,
Response);
}
/*++
* @name NtRaiseHardError
* @implemented
*
* This function sends HARDERROR_MSG LPC message to listener
* (typically CSRSS.EXE). See NtSetDefaultHardErrorPort for more information
* See: http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Error/NtRaiseHardError.html
*
* @param ErrorStatus
* Error Code
*
* @param NumberOfParameters
* Number of optional parameters in Parameters array
*
* @param UnicodeStringParameterMask
* Optional string parameter (can be only one per error code)
*
* @param Parameters
* Array of DWORD parameters for use in error message string
*
* @param ValidResponseOptions
* See HARDERROR_RESPONSE_OPTION for possible values description
*
* @param Response
* Pointer to HARDERROR_RESPONSE enumeration
*
* @return Status
*
* @remarks NtRaiseHardError is easy way to display message in GUI
* without loading Win32 API libraries
*
*--*/
NTSTATUS
NTAPI
NtRaiseHardError(IN NTSTATUS ErrorStatus,
IN ULONG NumberOfParameters,
IN ULONG UnicodeStringParameterMask,
IN PULONG_PTR Parameters,
IN ULONG ValidResponseOptions,
OUT PULONG Response)
{
NTSTATUS Status = STATUS_SUCCESS;
PULONG_PTR SafeParams = NULL;
ULONG SafeResponse;
UNICODE_STRING SafeString;
ULONG i;
ULONG ParamSize;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
DPRINT1("Hard error %x\n", ErrorStatus);
/* Validate parameter count */
if (NumberOfParameters > MAXIMUM_HARDERROR_PARAMETERS)
{
/* Fail */
DPRINT1("Invalid parameters\n");
return STATUS_INVALID_PARAMETER_2;
}
/* Make sure we have some at least */
if ((Parameters) && !(NumberOfParameters))
{
/* Fail */
DPRINT1("Invalid parameters\n");
return STATUS_INVALID_PARAMETER_2;
}
/* Check if we were called from user-mode */
if (PreviousMode != KernelMode)
{
/* First validate the responses */
switch (ValidResponseOptions)
{
/* Check all valid cases */
case OptionAbortRetryIgnore:
case OptionOk:
case OptionOkCancel:
case OptionRetryCancel:
case OptionYesNo:
case OptionYesNoCancel:
case OptionShutdownSystem:
break;
/* Anything else is invalid */
default:
return STATUS_INVALID_PARAMETER_4;
}
/* Enter SEH Block */
_SEH_TRY
{
/* Validate the response pointer */
ProbeForWriteUlong(Response);
/* Check if we have parameters */
if (Parameters)
{
/* Validate the parameter pointers */
ParamSize = sizeof(ULONG_PTR) * NumberOfParameters;
ProbeForRead(Parameters, ParamSize, sizeof(ULONG_PTR));
/* Allocate a safe buffer */
SafeParams = ExAllocatePoolWithTag(PagedPool,
ParamSize,
TAG_ERR);
/* Copy them */
RtlMoveMemory(SafeParams, Parameters, ParamSize);
/* Nowo check if there's strings in it */
if (UnicodeStringParameterMask)
{
/* Loop every string */
for (i = 0; i < NumberOfParameters; i++)
{
/* Check if this parameter is a string */
if (UnicodeStringParameterMask & (1 << i))
{
/* Probe the structure */
ProbeForRead((PVOID)SafeParams[i],
sizeof(UNICODE_STRING),
sizeof(ULONG_PTR));
/* Capture it */
RtlMoveMemory(&SafeString,
(PVOID)SafeParams[i],
sizeof(UNICODE_STRING));
/* Probe the buffer */
ProbeForRead(SafeString.Buffer,
SafeString.MaximumLength,
sizeof(UCHAR));
}
}
}
}
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
/* Free captured buffer */
if (SafeParams) ExFreePool(SafeParams);
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* If we failed to capture/probe, bail out */
if (!NT_SUCCESS(Status)) return Status;
/* Call the system function directly, because we probed */
ExpRaiseHardError(ErrorStatus,
NumberOfParameters,
UnicodeStringParameterMask,
SafeParams,
ValidResponseOptions,
&SafeResponse);
}
else
{
/* Reuse variable */
SafeParams = Parameters;
/*
* Call the Executive Function. It will probe and copy pointers to
* user-mode
*/
ExRaiseHardError(ErrorStatus,
NumberOfParameters,
UnicodeStringParameterMask,
SafeParams,
ValidResponseOptions,
&SafeResponse);
}
/* Check if we were called in user-mode */
if (PreviousMode != KernelMode)
{
/* That means we have a buffer to free */
if (SafeParams) ExFreePool(SafeParams);
/* Enter SEH Block for return */
_SEH_TRY
{
/* Return the response */
*Response = SafeResponse;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
else
{
/* Return the response */
*Response = SafeResponse;
}
/* Return status */
return Status;
}
/*++
* @name NtSetDefaultHardErrorPort
* @implemented
*
* NtSetDefaultHardErrorPort is typically called only once. After call,
* kernel set BOOLEAN flag named _ExReadyForErrors to TRUE, and all other
* tries to change default port are broken with STATUS_UNSUCCESSFUL error code
* See: http://www.windowsitlibrary.com/Content/356/08/2.html
* http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Error/NtSetDefaultHardErrorPort.html
*
* @param PortHandle
* Handle to named port object
*
* @return Status
*
* @remarks Privileges: SE_TCB_PRIVILEGE
*
*--*/
NTSTATUS
NTAPI
NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
{
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_UNSUCCESSFUL;
/* Check if we have the Privilege */
if(!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
{
DPRINT1("NtSetDefaultHardErrorPort: Caller requires "
"the SeTcbPrivilege privilege!\n");
return STATUS_PRIVILEGE_NOT_HELD;
}
/* Only called once during bootup, make sure we weren't called yet */
if(!ExReadyForErrors)
{
/* Reference the port */
Status = ObReferenceObjectByHandle(PortHandle,
0,
LpcPortObjectType,
PreviousMode,
(PVOID*)&ExpDefaultErrorPort,
NULL);
/* Check for Success */
if(NT_SUCCESS(Status))
{
/* Save the data */
ExpDefaultErrorPortProcess = PsGetCurrentProcess();
ExReadyForErrors = TRUE;
}
}
/* Return status to caller */
return Status;
}
VOID
__cdecl
_purecall(VOID)
{
/* Not supported in Kernel Mode */
RtlRaiseStatus(STATUS_NOT_IMPLEMENTED);
}
/* EOF */

View File

@@ -1,520 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/ex/event.c
* PURPOSE: Event support
* PROGRAMMERS: Alex Ionescu(alex@relsoft.net)
* Thomas Weidenmueller
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, ExpInitializeEventImplementation)
#endif
/* GLOBALS *******************************************************************/
POBJECT_TYPE ExEventObjectType = NULL;
GENERIC_MAPPING ExpEventMapping =
{
STANDARD_RIGHTS_READ | SYNCHRONIZE | EVENT_QUERY_STATE,
STANDARD_RIGHTS_WRITE | SYNCHRONIZE | EVENT_MODIFY_STATE,
STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE | EVENT_QUERY_STATE,
EVENT_ALL_ACCESS};
static const INFORMATION_CLASS_INFO ExEventInfoClass[] =
{
/* EventBasicInformation */
ICI_SQ_SAME( sizeof(EVENT_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY),
};
/* FUNCTIONS *****************************************************************/
VOID
INIT_FUNCTION
NTAPI
ExpInitializeEventImplementation(VOID)
{
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
UNICODE_STRING Name;
DPRINT("Creating Event Object Type\n");
/* Create the Event Object Type */
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
RtlInitUnicodeString(&Name, L"Event");
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KEVENT);
ObjectTypeInitializer.GenericMapping = ExpEventMapping;
ObjectTypeInitializer.PoolType = NonPagedPool;
ObjectTypeInitializer.ValidAccessMask = EVENT_ALL_ACCESS;
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExEventObjectType);
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtClearEvent(IN HANDLE EventHandle)
{
PKEVENT Event;
NTSTATUS Status;
PAGED_CODE();
/* Reference the Object */
Status = ObReferenceObjectByHandle(EventHandle,
EVENT_MODIFY_STATE,
ExEventObjectType,
ExGetPreviousMode(),
(PVOID*)&Event,
NULL);
/* Check for Success */
if(NT_SUCCESS(Status))
{
/* Clear the Event and Dereference */
KeClearEvent(Event);
ObDereferenceObject(Event);
}
/* Return Status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtCreateEvent(OUT PHANDLE EventHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN EVENT_TYPE EventType,
IN BOOLEAN InitialState)
{
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PKEVENT Event;
HANDLE hEvent;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtCreateEvent(0x%p, 0x%x, 0x%p)\n",
EventHandle, DesiredAccess, ObjectAttributes);
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH_TRY
{
/* Check handle pointer */
ProbeForWriteHandle(EventHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Create the Object */
Status = ObCreateObject(PreviousMode,
ExEventObjectType,
ObjectAttributes,
PreviousMode,
NULL,
sizeof(KEVENT),
0,
0,
(PVOID*)&Event);
/* Check for Success */
if(NT_SUCCESS(Status))
{
/* Initalize the Event */
KeInitializeEvent(Event,
EventType,
InitialState);
/* Insert it */
Status = ObInsertObject((PVOID)Event,
NULL,
DesiredAccess,
0,
NULL,
&hEvent);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Enter SEH for return */
_SEH_TRY
{
/* Return the handle to the caller */
*EventHandle = hEvent;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
}
/* Return Status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtOpenEvent(OUT PHANDLE EventHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes)
{
HANDLE hEvent;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtOpenEvent(0x%p, 0x%x, 0x%p)\n",
EventHandle, DesiredAccess, ObjectAttributes);
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH_TRY
{
/* Check handle pointer */
ProbeForWriteHandle(EventHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
Status = ObOpenObjectByName(ObjectAttributes,
ExEventObjectType,
PreviousMode,
NULL,
DesiredAccess,
NULL,
&hEvent);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Enter SEH for return */
_SEH_TRY
{
/* Return the handle to the caller */
*EventHandle = hEvent;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
/* Return status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtPulseEvent(IN HANDLE EventHandle,
OUT PLONG PreviousState OPTIONAL)
{
PKEVENT Event;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtPulseEvent(EventHandle 0%x PreviousState 0%x)\n",
EventHandle, PreviousState);
/* Check if we were called from user-mode */
if((PreviousState) && (PreviousMode != KernelMode))
{
/* Entry SEH Block */
_SEH_TRY
{
/* Make sure the state pointer is valid */
ProbeForWriteLong(PreviousState);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
Status = ObReferenceObjectByHandle(EventHandle,
EVENT_MODIFY_STATE,
ExEventObjectType,
PreviousMode,
(PVOID*)&Event,
NULL);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Pulse the Event */
LONG Prev = KePulseEvent(Event, EVENT_INCREMENT, FALSE);
ObDereferenceObject(Event);
/* Check if caller wants the old state back */
if(PreviousState)
{
/* Entry SEH Block for return */
_SEH_TRY
{
/* Return previous state */
*PreviousState = Prev;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
}
/* Return Status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtQueryEvent(IN HANDLE EventHandle,
IN EVENT_INFORMATION_CLASS EventInformationClass,
OUT PVOID EventInformation,
IN ULONG EventInformationLength,
OUT PULONG ReturnLength OPTIONAL)
{
PKEVENT Event;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PEVENT_BASIC_INFORMATION BasicInfo =
(PEVENT_BASIC_INFORMATION)EventInformation;
PAGED_CODE();
DPRINT("NtQueryEvent(0x%p, 0x%x)\n", EventHandle, EventInformationClass);
/* Check buffers and class validity */
Status = DefaultQueryInfoBufferCheck(EventInformationClass,
ExEventInfoClass,
sizeof(ExEventInfoClass) /
sizeof(ExEventInfoClass[0]),
EventInformation,
EventInformationLength,
ReturnLength,
PreviousMode);
if(!NT_SUCCESS(Status))
{
/* Invalid buffers */
DPRINT("NtQuerySemaphore() failed, Status: 0x%x\n", Status);
return Status;
}
/* Get the Object */
Status = ObReferenceObjectByHandle(EventHandle,
EVENT_QUERY_STATE,
ExEventObjectType,
PreviousMode,
(PVOID*)&Event,
NULL);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Entry SEH Block */
_SEH_TRY
{
/* Return Event Type and State */
BasicInfo->EventType = Event->Header.Type;
BasicInfo->EventState = KeReadStateEvent(Event);
/* Return length */
if(ReturnLength) *ReturnLength = sizeof(EVENT_BASIC_INFORMATION);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Dereference the Object */
ObDereferenceObject(Event);
}
/* Return status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtResetEvent(IN HANDLE EventHandle,
OUT PLONG PreviousState OPTIONAL)
{
PKEVENT Event;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtResetEvent(EventHandle 0%x PreviousState 0%x)\n",
EventHandle, PreviousState);
/* Check if we were called from user-mode */
if((PreviousState) && (PreviousMode != KernelMode))
{
/* Entry SEH Block */
_SEH_TRY
{
/* Make sure the state pointer is valid */
ProbeForWriteLong(PreviousState);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
Status = ObReferenceObjectByHandle(EventHandle,
EVENT_MODIFY_STATE,
ExEventObjectType,
PreviousMode,
(PVOID*)&Event,
NULL);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Reset the Event */
LONG Prev = KeResetEvent(Event);
ObDereferenceObject(Event);
/* Check if caller wants the old state back */
if(PreviousState)
{
/* Entry SEH Block for return */
_SEH_TRY
{
/* Return previous state */
*PreviousState = Prev;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
}
/* Return Status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtSetEvent(IN HANDLE EventHandle,
OUT PLONG PreviousState OPTIONAL)
{
PKEVENT Event;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtSetEvent(EventHandle 0%x PreviousState 0%x)\n",
EventHandle, PreviousState);
/* Check if we were called from user-mode */
if((PreviousState) && (PreviousMode != KernelMode))
{
/* Entry SEH Block */
_SEH_TRY
{
/* Make sure the state pointer is valid */
ProbeForWriteLong(PreviousState);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
Status = ObReferenceObjectByHandle(EventHandle,
EVENT_MODIFY_STATE,
ExEventObjectType,
PreviousMode,
(PVOID*)&Event,
NULL);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Set the Event */
LONG Prev = KeSetEvent(Event, EVENT_INCREMENT, FALSE);
ObDereferenceObject(Event);
/* Check if caller wants the old state back */
if(PreviousState)
{
/* Entry SEH Block for return */
_SEH_TRY
{
/* Return previous state */
*PreviousState = Prev;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
}
/* Return Status */
return Status;
}
/* EOF */

View File

@@ -1,406 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/ex/evtpair.c
* PURPOSE: Support for event pairs
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* Thomas Weidenmueller
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, ExpInitializeEventPairImplementation)
#endif
/* GLOBALS *******************************************************************/
POBJECT_TYPE ExEventPairObjectType = NULL;
GENERIC_MAPPING ExEventPairMapping =
{
STANDARD_RIGHTS_READ,
STANDARD_RIGHTS_WRITE,
STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE,
EVENT_PAIR_ALL_ACCESS
};
/* FUNCTIONS *****************************************************************/
VOID
INIT_FUNCTION
NTAPI
ExpInitializeEventPairImplementation(VOID)
{
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
UNICODE_STRING Name;
DPRINT("Creating Event Pair Object Type\n");
/* Create the Event Pair Object Type */
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
RtlInitUnicodeString(&Name, L"EventPair");
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KEVENT_PAIR);
ObjectTypeInitializer.GenericMapping = ExEventPairMapping;
ObjectTypeInitializer.PoolType = NonPagedPool;
ObjectTypeInitializer.ValidAccessMask = EVENT_PAIR_ALL_ACCESS;
ObjectTypeInitializer.UseDefaultObject = TRUE;
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExEventPairObjectType);
}
NTSTATUS
NTAPI
NtCreateEventPair(OUT PHANDLE EventPairHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes)
{
PKEVENT_PAIR EventPair;
HANDLE hEventPair;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtCreateEventPair: 0x%p\n", EventPairHandle);
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH_TRY
{
/* Check handle pointer */
ProbeForWriteHandle(EventPairHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Create the Object */
DPRINT("Creating EventPair\n");
Status = ObCreateObject(PreviousMode,
ExEventPairObjectType,
ObjectAttributes,
PreviousMode,
NULL,
sizeof(KEVENT_PAIR),
0,
0,
(PVOID*)&EventPair);
/* Check for Success */
if(NT_SUCCESS(Status))
{
/* Initalize the Event */
DPRINT("Initializing EventPair\n");
KeInitializeEventPair(EventPair);
/* Insert it */
Status = ObInsertObject((PVOID)EventPair,
NULL,
DesiredAccess,
0,
NULL,
&hEventPair);
/* Check for success and return handle */
if(NT_SUCCESS(Status))
{
_SEH_TRY
{
*EventPairHandle = hEventPair;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
}
/* Return Status */
return Status;
}
NTSTATUS
NTAPI
NtOpenEventPair(OUT PHANDLE EventPairHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes)
{
HANDLE hEventPair;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH_TRY
{
/* Check handle pointer */
ProbeForWriteHandle(EventPairHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
Status = ObOpenObjectByName(ObjectAttributes,
ExEventPairObjectType,
PreviousMode,
NULL,
DesiredAccess,
NULL,
&hEventPair);
/* Check for success and return handle */
if(NT_SUCCESS(Status))
{
_SEH_TRY
{
*EventPairHandle = hEventPair;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
/* Return status */
return Status;
}
NTSTATUS
NTAPI
NtSetHighEventPair(IN HANDLE EventPairHandle)
{
PKEVENT_PAIR EventPair;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtSetHighEventPair(EventPairHandle 0x%p)\n", EventPairHandle);
/* Open the Object */
Status = ObReferenceObjectByHandle(EventPairHandle,
SYNCHRONIZE,
ExEventPairObjectType,
PreviousMode,
(PVOID*)&EventPair,
NULL);
/* Check for Success */
if(NT_SUCCESS(Status))
{
/* Set the Event */
KeSetEvent(&EventPair->HighEvent, EVENT_INCREMENT, FALSE);
/* Dereference Object */
ObDereferenceObject(EventPair);
}
/* Return status */
return Status;
}
NTSTATUS
NTAPI
NtSetHighWaitLowEventPair(IN HANDLE EventPairHandle)
{
PKEVENT_PAIR EventPair;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtSetHighWaitLowEventPair(Handle 0x%p)\n", EventPairHandle);
/* Open the Object */
Status = ObReferenceObjectByHandle(EventPairHandle,
SYNCHRONIZE,
ExEventPairObjectType,
PreviousMode,
(PVOID*)&EventPair,
NULL);
/* Check for Success */
if(NT_SUCCESS(Status))
{
/* Set the Event */
KeSetEvent(&EventPair->HighEvent, EVENT_INCREMENT, FALSE);
/* Wait for the Other one */
KeWaitForSingleObject(&EventPair->LowEvent,
WrEventPair,
PreviousMode,
FALSE,
NULL);
/* Dereference Object */
ObDereferenceObject(EventPair);
}
/* Return status */
return Status;
}
NTSTATUS
NTAPI
NtSetLowEventPair(IN HANDLE EventPairHandle)
{
PKEVENT_PAIR EventPair;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status;
PAGED_CODE();
DPRINT1("NtSetHighEventPair(EventPairHandle 0x%p)\n", EventPairHandle);
/* Open the Object */
Status = ObReferenceObjectByHandle(EventPairHandle,
SYNCHRONIZE,
ExEventPairObjectType,
PreviousMode,
(PVOID*)&EventPair,
NULL);
/* Check for Success */
if(NT_SUCCESS(Status))
{
/* Set the Event */
KeSetEvent(&EventPair->LowEvent, EVENT_INCREMENT, FALSE);
/* Dereference Object */
ObDereferenceObject(EventPair);
}
/* Return status */
return Status;
}
NTSTATUS
NTAPI
NtSetLowWaitHighEventPair(IN HANDLE EventPairHandle)
{
PKEVENT_PAIR EventPair;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtSetHighWaitLowEventPair(Handle 0x%p)\n", EventPairHandle);
/* Open the Object */
Status = ObReferenceObjectByHandle(EventPairHandle,
SYNCHRONIZE,
ExEventPairObjectType,
PreviousMode,
(PVOID*)&EventPair,
NULL);
/* Check for Success */
if(NT_SUCCESS(Status))
{
/* Set the Event */
KeSetEvent(&EventPair->LowEvent, EVENT_INCREMENT, FALSE);
/* Wait for the Other one */
KeWaitForSingleObject(&EventPair->HighEvent,
WrEventPair,
PreviousMode,
FALSE,
NULL);
/* Dereference Object */
ObDereferenceObject(EventPair);
}
/* Return status */
return Status;
}
NTSTATUS
NTAPI
NtWaitLowEventPair(IN HANDLE EventPairHandle)
{
PKEVENT_PAIR EventPair;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtSetHighWaitLowEventPair(Handle 0x%p)\n", EventPairHandle);
/* Open the Object */
Status = ObReferenceObjectByHandle(EventPairHandle,
SYNCHRONIZE,
ExEventPairObjectType,
PreviousMode,
(PVOID*)&EventPair,
NULL);
/* Check for Success */
if(NT_SUCCESS(Status))
{
/* Wait for the Event */
KeWaitForSingleObject(&EventPair->LowEvent,
WrEventPair,
PreviousMode,
FALSE,
NULL);
/* Dereference Object */
ObDereferenceObject(EventPair);
}
/* Return status */
return Status;
}
NTSTATUS
NTAPI
NtWaitHighEventPair(IN HANDLE EventPairHandle)
{
PKEVENT_PAIR EventPair;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status;
PAGED_CODE();
DPRINT("NtSetHighWaitLowEventPair(Handle 0x%p)\n", EventPairHandle);
/* Open the Object */
Status = ObReferenceObjectByHandle(EventPairHandle,
SYNCHRONIZE,
ExEventPairObjectType,
PreviousMode,
(PVOID*)&EventPair,
NULL);
/* Check for Success */
if(NT_SUCCESS(Status))
{
/* Wait for the Event */
KeWaitForSingleObject(&EventPair->HighEvent,
WrEventPair,
PreviousMode,
FALSE,
NULL);
/* Dereference Object */
ObDereferenceObject(EventPair);
}
/* Return status */
return Status;
}
/* EOF */

View File

@@ -1,219 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/ex/fmutex.c
* PURPOSE: Implements fast mutexes
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#include <internal/debug.h>
VOID
FASTCALL
KiAcquireFastMutex(IN PFAST_MUTEX FastMutex);
/* FUNCTIONS *****************************************************************/
/*
* @implemented
*/
VOID
FASTCALL
ExEnterCriticalRegionAndAcquireFastMutexUnsafe(PFAST_MUTEX FastMutex)
{
PKTHREAD Thread = KeGetCurrentThread();
/* Enter the Critical Region */
KeEnterCriticalRegion();
/*
ASSERT((KeGetCurrentIrql() == APC_LEVEL) ||
(Thread == NULL) ||
(Thread->CombinedApcDisable != 0) ||
(Thread->Teb == NULL) ||
(Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
*/
ASSERT((KeGetCurrentIrql() == APC_LEVEL) ||
(Thread == NULL) ||
(Thread->CombinedApcDisable != 0));
ASSERT((Thread == NULL) || (FastMutex->Owner != Thread));
/* Decrease the count */
if (InterlockedDecrement(&FastMutex->Count))
{
/* Someone is still holding it, use slow path */
KiAcquireFastMutex(FastMutex);
}
/* Set the owner */
FastMutex->Owner = Thread;
}
/*
* @implemented
*/
VOID
FASTCALL
ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(PFAST_MUTEX FastMutex)
{
/*
ASSERT((KeGetCurrentIrql() == APC_LEVEL) ||
(KeGetCurrentThread() == NULL) ||
(KeGetCurrentThread()->CombinedApcDisable != 0) ||
(KeGetCurrentThread()->Teb == NULL) ||
(KeGetCurrentThread()->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
*/
ASSERT((KeGetCurrentIrql() == APC_LEVEL) ||
(KeGetCurrentThread() == NULL) ||
(KeGetCurrentThread()->CombinedApcDisable != 0));
ASSERT(FastMutex->Owner == KeGetCurrentThread());
/* Erase the owner */
FastMutex->Owner = NULL;
/* Increase the count */
if (InterlockedIncrement(&FastMutex->Count) <= 0)
{
/* Someone was waiting for it, signal the waiter */
KeSetEventBoostPriority(&FastMutex->Gate, IO_NO_INCREMENT);
}
/* Leave the critical region */
KeLeaveCriticalRegion();
}
/*
* @implemented
*/
VOID
FASTCALL
ExAcquireFastMutex(PFAST_MUTEX FastMutex)
{
KIRQL OldIrql;
ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL);
/* Raise IRQL to APC */
OldIrql = KfRaiseIrql(APC_LEVEL);
/* Decrease the count */
if (InterlockedDecrement(&FastMutex->Count))
{
/* Someone is still holding it, use slow path */
KiAcquireFastMutex(FastMutex);
}
/* Set the owner and IRQL */
FastMutex->Owner = KeGetCurrentThread();
FastMutex->OldIrql = OldIrql;
}
/*
* @implemented
*/
VOID
FASTCALL
ExReleaseFastMutex (PFAST_MUTEX FastMutex)
{
KIRQL OldIrql;
ASSERT_IRQL(APC_LEVEL);
/* Erase the owner */
FastMutex->Owner = NULL;
OldIrql = FastMutex->OldIrql;
/* Increase the count */
if (InterlockedIncrement(&FastMutex->Count) <= 0)
{
/* Someone was waiting for it, signal the waiter */
KeSetEventBoostPriority(&FastMutex->Gate, IO_NO_INCREMENT);
}
/* Lower IRQL back */
KfLowerIrql(OldIrql);
}
/*
* @implemented
*/
VOID
FASTCALL
ExAcquireFastMutexUnsafe(PFAST_MUTEX FastMutex)
{
PKTHREAD Thread = KeGetCurrentThread();
ASSERT((KeGetCurrentIrql() == APC_LEVEL) ||
(Thread == NULL) ||
(Thread->CombinedApcDisable != 0) ||
(Thread->Teb == NULL) ||
(Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
ASSERT((Thread == NULL) || (FastMutex->Owner != Thread));
/* Decrease the count */
if (InterlockedDecrement(&FastMutex->Count))
{
/* Someone is still holding it, use slow path */
KiAcquireFastMutex(FastMutex);
}
/* Set the owner */
FastMutex->Owner = Thread;
}
/*
* @implemented
*/
VOID
FASTCALL
ExReleaseFastMutexUnsafe(PFAST_MUTEX FastMutex)
{
ASSERT((KeGetCurrentIrql() == APC_LEVEL) ||
(KeGetCurrentThread() == NULL) ||
(KeGetCurrentThread()->CombinedApcDisable != 0) ||
(KeGetCurrentThread()->Teb == NULL) ||
(KeGetCurrentThread()->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
ASSERT(FastMutex->Owner == KeGetCurrentThread());
/* Erase the owner */
FastMutex->Owner = NULL;
/* Increase the count */
if (InterlockedIncrement(&FastMutex->Count) <= 0)
{
/* Someone was waiting for it, signal the waiter */
KeSetEventBoostPriority(&FastMutex->Gate, IO_NO_INCREMENT);
}
}
/*
* @implemented
*/
BOOLEAN
FASTCALL
ExTryToAcquireFastMutex(PFAST_MUTEX FastMutex)
{
KIRQL OldIrql;
ASSERT_IRQL_LESS_OR_EQUAL(APC_LEVEL);
/* Raise to APC_LEVEL */
OldIrql = KfRaiseIrql(APC_LEVEL);
/* Check if we can quickly acquire it */
if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
{
/* We have, set us as owners */
FastMutex->Owner = KeGetCurrentThread();
FastMutex->OldIrql = OldIrql;
return TRUE;
}
else
{
/* Acquire attempt failed */
KfLowerIrql(OldIrql);
return FALSE;
}
}
/* EOF */

View File

@@ -1,942 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ex/handle.c
* PURPOSE: Generic Executive Handle Tables
*
* PROGRAMMERS: Thomas Weidenmueller <w3seek@reactos.com>
*
* TODO:
*
* - the last entry of a subhandle list should be reserved for auditing
*
* ExReferenceHandleDebugInfo
* ExSnapShotHandleTables
* ExpMoveFreeHandles (???)
*/
/* INCLUDES *****************************************************************/
#define NTDDI_VERSION NTDDI_WIN2K
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
static LIST_ENTRY ExpHandleTableHead;
static FAST_MUTEX ExpHandleTableListLock;
static LARGE_INTEGER ExpHandleShortWait;
#define ExAcquireHandleTableListLock() \
ExAcquireFastMutexUnsafe(&ExpHandleTableListLock)
#define ExReleaseHandleTableListLock() \
ExReleaseFastMutexUnsafe(&ExpHandleTableListLock)
#define ExAcquireHandleLockExclusive(HandleTable) \
ExAcquireResourceExclusiveLite(&(HandleTable)->HandleLock, TRUE)
#define ExAcquireHandleLockShared(HandleTable) \
ExAcquireResourceSharedLite(&(HandleTable)->HandleLock, TRUE)
#define ExReleaseHandleLock(HandleTable) \
ExReleaseResourceLite(&(HandleTable)->HandleLock)
/*
5 bits: reserved
8 bits: top level index
10 bits: middle level index
9 bits: sub handle index
*/
#define N_TLI_BITS 8 /* top level index */
#define N_MLI_BITS 10 /* middle level index */
#define N_EI_BITS 9 /* sub handle index */
#define TLI_OFFSET (N_MLI_BITS + N_EI_BITS)
#define MLI_OFFSET N_EI_BITS
#define EI_OFFSET 0
#define N_TOPLEVEL_POINTERS (1 << N_TLI_BITS)
#define N_MIDDLELEVEL_POINTERS (1 << N_MLI_BITS)
#define N_SUBHANDLE_ENTRIES (1 << N_EI_BITS)
#define EX_MAX_HANDLES (N_TOPLEVEL_POINTERS * N_MIDDLELEVEL_POINTERS * N_SUBHANDLE_ENTRIES)
#define VALID_HANDLE_MASK (((N_TOPLEVEL_POINTERS - 1) << TLI_OFFSET) | \
((N_MIDDLELEVEL_POINTERS - 1) << MLI_OFFSET) | ((N_SUBHANDLE_ENTRIES - 1) << EI_OFFSET))
#define TLI_FROM_HANDLE(index) (ULONG)(((index) >> TLI_OFFSET) & (N_TOPLEVEL_POINTERS - 1))
#define MLI_FROM_HANDLE(index) (ULONG)(((index) >> MLI_OFFSET) & (N_MIDDLELEVEL_POINTERS - 1))
#define ELI_FROM_HANDLE(index) (ULONG)(((index) >> EI_OFFSET) & (N_SUBHANDLE_ENTRIES - 1))
#define N_MAX_HANDLE (N_TOPLEVEL_POINTERS * N_MIDDLELEVEL_POINTERS * N_SUBHANDLE_ENTRIES)
#define BUILD_HANDLE(tli, mli, eli) ((((tli) & (N_TOPLEVEL_POINTERS - 1)) << TLI_OFFSET) | \
(((mli) & (N_MIDDLELEVEL_POINTERS - 1)) << MLI_OFFSET) | (((eli) & (N_SUBHANDLE_ENTRIES - 1)) << EI_OFFSET))
#define IS_INVALID_EX_HANDLE(index) \
(((index) & ~VALID_HANDLE_MASK) != 0)
#define IS_VALID_EX_HANDLE(index) \
(((index) & ~VALID_HANDLE_MASK) == 0)
#define HANDLE_TO_EX_HANDLE(handle) \
(LONG)(((LONG)(handle) >> 2) - 1)
#define EX_HANDLE_TO_HANDLE(exhandle) \
(HANDLE)(((exhandle) + 1) << 2)
static BOOLEAN ExpInitialized = FALSE;
/******************************************************************************/
VOID
ExpInitializeHandleTables(VOID)
{
ExpHandleShortWait.QuadPart = -50000;
InitializeListHead(&ExpHandleTableHead);
ExInitializeFastMutex(&ExpHandleTableListLock);
ExpInitialized = TRUE;
}
PHANDLE_TABLE
ExCreateHandleTable(IN PEPROCESS QuotaProcess OPTIONAL)
{
PHANDLE_TABLE HandleTable;
PAGED_CODE();
if(!ExpInitialized)
{
KEBUGCHECK(0);
}
if(QuotaProcess != NULL)
{
/* FIXME - Charge process quota before allocating the handle table! */
}
/* allocate enough memory for the handle table and the lowest level */
HandleTable = ExAllocatePoolWithTag(NonPagedPool,
sizeof(HANDLE_TABLE) + (N_TOPLEVEL_POINTERS * sizeof(PHANDLE_TABLE_ENTRY*)),
TAG('E', 'x', 'H', 't'));
if(HandleTable != NULL)
{
/* initialize the handle table */
HandleTable->Flags = 0;
HandleTable->HandleCount = 0;
HandleTable->Table = (PHANDLE_TABLE_ENTRY**)(HandleTable + 1);
HandleTable->QuotaProcess = QuotaProcess;
HandleTable->FirstFree = -1; /* no entries freed so far */
HandleTable->NextHandleNeedingPool = 0; /* no entries freed so far, so we have to allocate already for the first handle */
HandleTable->UniqueProcessId = (QuotaProcess ? QuotaProcess->UniqueProcessId : NULL);
ExInitializeResource(&HandleTable->HandleLock);
KeInitializeEvent(&HandleTable->HandleContentionEvent,
NotificationEvent,
FALSE);
RtlZeroMemory(HandleTable->Table, N_TOPLEVEL_POINTERS * sizeof(PHANDLE_TABLE_ENTRY*));
/* during bootup KeGetCurrentThread() might be NULL, needs to be fixed... */
if(KeGetCurrentThread() != NULL)
{
/* insert it into the global handle table list */
KeEnterCriticalRegion();
ExAcquireHandleTableListLock();
InsertTailList(&ExpHandleTableHead,
&HandleTable->HandleTableList);
ExReleaseHandleTableListLock();
KeLeaveCriticalRegion();
}
else
{
InsertTailList(&ExpHandleTableHead,
&HandleTable->HandleTableList);
}
}
else
{
/* FIXME - return the quota to the process */
}
return HandleTable;
}
VOID
ExSweepHandleTable(IN PHANDLE_TABLE HandleTable,
IN PEX_SWEEP_HANDLE_CALLBACK SweepHandleCallback OPTIONAL,
IN PVOID Context OPTIONAL)
{
PHANDLE_TABLE_ENTRY **tlp, **lasttlp, *mlp, *lastmlp;
LONG ExHandle = 0;
PAGED_CODE();
ASSERT(HandleTable);
KeEnterCriticalRegion();
/* ensure there's no other operations going by acquiring an exclusive lock */
ExAcquireHandleLockExclusive(HandleTable);
ASSERT(!(HandleTable->Flags & EX_HANDLE_TABLE_CLOSING));
HandleTable->Flags |= EX_HANDLE_TABLE_CLOSING;
KePulseEvent(&HandleTable->HandleContentionEvent,
EVENT_INCREMENT,
FALSE);
/* call the callback function to cleanup the objects associated with the
handle table */
for(tlp = HandleTable->Table, lasttlp = HandleTable->Table + N_TOPLEVEL_POINTERS;
tlp != lasttlp;
tlp++)
{
if((*tlp) != NULL)
{
for(mlp = *tlp, lastmlp = (*tlp) + N_MIDDLELEVEL_POINTERS;
mlp != lastmlp;
mlp++)
{
if((*mlp) != NULL)
{
PHANDLE_TABLE_ENTRY curee, laste;
for(curee = *mlp, laste = *mlp + N_SUBHANDLE_ENTRIES;
curee != laste;
curee++)
{
if(curee->Object != NULL && SweepHandleCallback != NULL)
{
curee->ObAttributes |= EX_HANDLE_ENTRY_LOCKED;
SweepHandleCallback(curee, EX_HANDLE_TO_HANDLE(ExHandle), Context);
}
ExHandle++;
}
}
else
break;
}
}
else
break;
}
ExReleaseHandleLock(HandleTable);
KeLeaveCriticalRegion();
}
VOID
ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable)
{
PHANDLE_TABLE_ENTRY **tlp, **lasttlp, *mlp, *lastmlp;
PEPROCESS QuotaProcess;
PAGED_CODE();
ASSERT(HandleTable);
ASSERT(HandleTable->Flags & EX_HANDLE_TABLE_CLOSING);
KeEnterCriticalRegion();
/* at this point the table should not be queried or altered anymore,
no locks should be necessary */
ASSERT(HandleTable->Flags & EX_HANDLE_TABLE_CLOSING);
/* remove the handle table from the global handle table list */
ExAcquireHandleTableListLock();
RemoveEntryList(&HandleTable->HandleTableList);
ExReleaseHandleTableListLock();
QuotaProcess = HandleTable->QuotaProcess;
/* free the tables */
for(tlp = HandleTable->Table, lasttlp = HandleTable->Table + N_TOPLEVEL_POINTERS;
tlp != lasttlp;
tlp++)
{
if((*tlp) != NULL)
{
for(mlp = *tlp, lastmlp = (*tlp) + N_MIDDLELEVEL_POINTERS;
mlp != lastmlp;
mlp++)
{
if((*mlp) != NULL)
{
ExFreePool(*mlp);
if(QuotaProcess != NULL)
{
/* FIXME - return the quota to the process */
}
}
}
ExFreePool(*tlp);
if(QuotaProcess != NULL)
{
/* FIXME - return the quota to the process */
}
}
}
KeLeaveCriticalRegion();
/* free the handle table */
ExDeleteResource(&HandleTable->HandleLock);
ExFreePool(HandleTable);
if(QuotaProcess != NULL)
{
/* FIXME - return the quota to the process */
}
}
PHANDLE_TABLE
ExDupHandleTable(IN PEPROCESS QuotaProcess OPTIONAL,
IN PEX_DUPLICATE_HANDLE_CALLBACK DuplicateHandleCallback OPTIONAL,
IN PVOID Context OPTIONAL,
IN PHANDLE_TABLE SourceHandleTable)
{
PHANDLE_TABLE HandleTable;
PAGED_CODE();
ASSERT(SourceHandleTable);
HandleTable = ExCreateHandleTable(QuotaProcess);
if(HandleTable != NULL)
{
PHANDLE_TABLE_ENTRY **tlp, **srctlp, **etlp, *mlp, *srcmlp, *emlp, stbl, srcstbl, estbl;
LONG tli, mli, eli;
tli = mli = eli = 0;
/* make sure the other handle table isn't being changed during the duplication */
ExAcquireHandleLockShared(SourceHandleTable);
/* allocate enough tables */
etlp = SourceHandleTable->Table + N_TOPLEVEL_POINTERS;
for(srctlp = SourceHandleTable->Table, tlp = HandleTable->Table;
srctlp != etlp;
srctlp++, tlp++)
{
if(*srctlp != NULL)
{
/* allocate middle level entry tables */
if(QuotaProcess != NULL)
{
/* FIXME - Charge process quota before allocating the handle table! */
}
*tlp = ExAllocatePoolWithTag(PagedPool,
N_MIDDLELEVEL_POINTERS * sizeof(PHANDLE_TABLE_ENTRY),
TAG('E', 'x', 'H', 't'));
if(*tlp != NULL)
{
RtlZeroMemory(*tlp, N_MIDDLELEVEL_POINTERS * sizeof(PHANDLE_TABLE_ENTRY));
KeMemoryBarrier();
emlp = *srctlp + N_MIDDLELEVEL_POINTERS;
for(srcmlp = *srctlp, mlp = *tlp;
srcmlp != emlp;
srcmlp++, mlp++)
{
if(*srcmlp != NULL)
{
/* allocate subhandle tables */
if(QuotaProcess != NULL)
{
/* FIXME - Charge process quota before allocating the handle table! */
}
*mlp = ExAllocatePoolWithTag(PagedPool,
N_SUBHANDLE_ENTRIES * sizeof(HANDLE_TABLE_ENTRY),
TAG('E', 'x', 'H', 't'));
if(*mlp != NULL)
{
RtlZeroMemory(*mlp, N_SUBHANDLE_ENTRIES * sizeof(HANDLE_TABLE_ENTRY));
}
else
{
goto freehandletable;
}
}
else
{
*mlp = NULL;
}
}
}
else
{
freehandletable:
DPRINT1("Failed to duplicate handle table 0x%p\n", SourceHandleTable);
ExReleaseHandleLock(SourceHandleTable);
ExDestroyHandleTable(HandleTable);
/* allocate an empty handle table */
return ExCreateHandleTable(QuotaProcess);
}
}
}
/* duplicate the handles */
HandleTable->HandleCount = SourceHandleTable->HandleCount;
HandleTable->FirstFree = SourceHandleTable->FirstFree;
HandleTable->NextHandleNeedingPool = SourceHandleTable->NextHandleNeedingPool;
/* make sure all tables are zeroed */
KeMemoryBarrier();
etlp = SourceHandleTable->Table + N_TOPLEVEL_POINTERS;
for(srctlp = SourceHandleTable->Table, tlp = HandleTable->Table;
srctlp != etlp;
srctlp++, tlp++, tli++)
{
if(*srctlp != NULL)
{
ASSERT(*tlp != NULL);
emlp = *srctlp + N_MIDDLELEVEL_POINTERS;
for(srcmlp = *srctlp, mlp = *tlp;
srcmlp != emlp;
srcmlp++, mlp++, mli++)
{
if(*srcmlp != NULL)
{
ASSERT(*mlp != NULL);
/* walk all handle entries and duplicate them if wanted */
estbl = *srcmlp + N_SUBHANDLE_ENTRIES;
for(srcstbl = *srcmlp, stbl = *mlp;
srcstbl != estbl;
srcstbl++, stbl++, eli++)
{
/* try to duplicate the source handle */
if(srcstbl->Object != NULL &&
ExLockHandleTableEntry(SourceHandleTable,
srcstbl))
{
/* ask the caller if this handle should be duplicated */
if(DuplicateHandleCallback != NULL &&
!DuplicateHandleCallback(HandleTable,
srcstbl,
Context))
{
/* free the entry and chain it into the free list */
HandleTable->HandleCount--;
stbl->Object = NULL;
stbl->NextFreeTableEntry = HandleTable->FirstFree;
HandleTable->FirstFree = BUILD_HANDLE(tli, mli, eli);
}
else
{
/* duplicate the handle and unlock it */
stbl->GrantedAccess = srcstbl->GrantedAccess;
stbl->ObAttributes = srcstbl->ObAttributes & ~EX_HANDLE_ENTRY_LOCKED;
}
ExUnlockHandleTableEntry(SourceHandleTable,
srcstbl);
}
else
{
/* this is a free handle table entry, copy over the entire
structure as-is */
*stbl = *srcstbl;
}
}
}
}
}
}
/* release the source handle table */
ExReleaseHandleLock(SourceHandleTable);
}
return HandleTable;
}
static PHANDLE_TABLE_ENTRY
ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable,
OUT PHANDLE Handle)
{
PHANDLE_TABLE_ENTRY Entry = NULL;
PAGED_CODE();
ASSERT(HandleTable);
ASSERT(Handle);
ASSERT(KeGetCurrentThread() != NULL);
DPRINT("HT[0x%p]: HandleCount: %d\n", HandleTable, HandleTable->HandleCount);
if(HandleTable->HandleCount < EX_MAX_HANDLES)
{
ULONG tli, mli, eli;
if(HandleTable->FirstFree != -1)
{
/* there's a free handle entry we can just grab and use */
tli = TLI_FROM_HANDLE(HandleTable->FirstFree);
mli = MLI_FROM_HANDLE(HandleTable->FirstFree);
eli = ELI_FROM_HANDLE(HandleTable->FirstFree);
/* the pointer should be valid in any way!!! */
ASSERT(HandleTable->Table[tli]);
ASSERT(HandleTable->Table[tli][mli]);
Entry = &HandleTable->Table[tli][mli][eli];
*Handle = EX_HANDLE_TO_HANDLE(HandleTable->FirstFree);
/* save the index to the next free handle (if available) */
HandleTable->FirstFree = Entry->NextFreeTableEntry;
Entry->NextFreeTableEntry = 0;
Entry->Object = NULL;
HandleTable->HandleCount++;
}
else
{
/* we need to allocate a new subhandle table first */
PHANDLE_TABLE_ENTRY cure, laste, ntbl, *nmtbl;
ULONG i;
BOOLEAN AllocatedMtbl;
ASSERT(HandleTable->NextHandleNeedingPool <= N_MAX_HANDLE);
/* the index of the next table to be allocated was saved in
NextHandleNeedingPool the last time a handle entry was allocated and
the subhandle entry list was full. the subhandle entry index of
NextHandleNeedingPool should be 0 here! */
tli = TLI_FROM_HANDLE(HandleTable->NextHandleNeedingPool);
mli = MLI_FROM_HANDLE(HandleTable->NextHandleNeedingPool);
DPRINT("HandleTable->NextHandleNeedingPool: 0x%x\n", HandleTable->NextHandleNeedingPool);
DPRINT("tli: 0x%x mli: 0x%x eli: 0x%x\n", tli, mli, ELI_FROM_HANDLE(HandleTable->NextHandleNeedingPool));
ASSERT(ELI_FROM_HANDLE(HandleTable->NextHandleNeedingPool) == 0);
DPRINT("HandleTable->Table[%d] == 0x%p\n", tli, HandleTable->Table[tli]);
/* allocate a middle level entry list if required */
nmtbl = HandleTable->Table[tli];
if(nmtbl == NULL)
{
if(HandleTable->QuotaProcess != NULL)
{
/* FIXME - Charge process quota before allocating the handle table! */
}
nmtbl = ExAllocatePoolWithTag(PagedPool,
N_MIDDLELEVEL_POINTERS * sizeof(PHANDLE_TABLE_ENTRY),
TAG('E', 'x', 'H', 't'));
if(nmtbl == NULL)
{
if(HandleTable->QuotaProcess != NULL)
{
/* FIXME - return the quota to the process */
}
return NULL;
}
/* clear the middle level entry list */
RtlZeroMemory(nmtbl, N_MIDDLELEVEL_POINTERS * sizeof(PHANDLE_TABLE_ENTRY));
/* make sure the table was zeroed before we set one item */
KeMemoryBarrier();
/* note, don't set the the pointer in the top level list yet because we
might screw up lookups if allocating a subhandle entry table failed
and this newly allocated table might get freed again */
AllocatedMtbl = TRUE;
}
else
{
AllocatedMtbl = FALSE;
/* allocate a subhandle entry table in any case! */
ASSERT(nmtbl[mli] == NULL);
}
DPRINT("HandleTable->Table[%d][%d] == 0x%p\n", tli, mli, nmtbl[mli]);
if(HandleTable->QuotaProcess != NULL)
{
/* FIXME - Charge process quota before allocating the handle table! */
}
ntbl = ExAllocatePoolWithTag(PagedPool,
N_SUBHANDLE_ENTRIES * sizeof(HANDLE_TABLE_ENTRY),
TAG('E', 'x', 'H', 't'));
if(ntbl == NULL)
{
if(HandleTable->QuotaProcess != NULL)
{
/* FIXME - Return process quota charged */
}
/* free the middle level entry list, if allocated, because it's empty and
unused */
if(AllocatedMtbl)
{
ExFreePool(nmtbl);
if(HandleTable->QuotaProcess != NULL)
{
/* FIXME - Return process quota charged */
}
}
return NULL;
}
/* let's just use the very first entry */
Entry = ntbl;
Entry->ObAttributes = EX_HANDLE_ENTRY_LOCKED;
Entry->NextFreeTableEntry = 0;
*Handle = EX_HANDLE_TO_HANDLE(HandleTable->NextHandleNeedingPool);
HandleTable->HandleCount++;
/* set the FirstFree member to the second entry and chain the
free entries */
HandleTable->FirstFree = HandleTable->NextHandleNeedingPool + 1;
for(cure = Entry + 1, laste = Entry + N_SUBHANDLE_ENTRIES, i = HandleTable->FirstFree + 1;
cure != laste;
cure++, i++)
{
cure->Object = NULL;
cure->NextFreeTableEntry = i;
}
/* truncate the free entry list */
(cure - 1)->NextFreeTableEntry = -1;
/* save the pointers to the allocated list(s) */
(void)InterlockedExchangePointer(&nmtbl[mli], ntbl);
if(AllocatedMtbl)
{
(void)InterlockedExchangePointer(&HandleTable->Table[tli], nmtbl);
}
/* increment the NextHandleNeedingPool to the next index where we need to
allocate new memory */
HandleTable->NextHandleNeedingPool += N_SUBHANDLE_ENTRIES;
}
}
else
{
DPRINT1("Can't allocate any more handles in handle table 0x%p!\n", HandleTable);
}
return Entry;
}
static VOID
ExpFreeHandleTableEntry(IN PHANDLE_TABLE HandleTable,
IN PHANDLE_TABLE_ENTRY Entry,
IN LONG Handle)
{
PAGED_CODE();
ASSERT(HandleTable);
ASSERT(Entry);
ASSERT(IS_VALID_EX_HANDLE(Handle));
DPRINT("ExpFreeHandleTableEntry HT:0x%p Entry:0x%p\n", HandleTable, Entry);
/* automatically unlock the entry if currently locked. We however don't notify
anyone who waited on the handle because we're holding an exclusive lock after
all and these locks will fail then */
(void)InterlockedExchangePointer(&Entry->Object, NULL);
Entry->NextFreeTableEntry = HandleTable->FirstFree;
HandleTable->FirstFree = Handle;
HandleTable->HandleCount--;
}
static PHANDLE_TABLE_ENTRY
ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable,
IN LONG Handle)
{
PHANDLE_TABLE_ENTRY Entry = NULL;
PAGED_CODE();
ASSERT(HandleTable);
if(IS_VALID_EX_HANDLE(Handle))
{
ULONG tli, mli, eli;
PHANDLE_TABLE_ENTRY *mlp;
tli = TLI_FROM_HANDLE(Handle);
mli = MLI_FROM_HANDLE(Handle);
eli = ELI_FROM_HANDLE(Handle);
mlp = HandleTable->Table[tli];
if(Handle < HandleTable->NextHandleNeedingPool &&
mlp != NULL && mlp[mli] != NULL && mlp[mli][eli].Object != NULL)
{
Entry = &mlp[mli][eli];
DPRINT("handle lookup 0x%x -> entry 0x%p [HT:0x%p] ptr: 0x%p\n", Handle, Entry, HandleTable, mlp[mli][eli].Object);
}
}
else
{
DPRINT("Looking up invalid handle 0x%x\n", Handle);
}
return Entry;
}
BOOLEAN
ExLockHandleTableEntry(IN PHANDLE_TABLE HandleTable,
IN PHANDLE_TABLE_ENTRY Entry)
{
ULONG_PTR Current, New;
PAGED_CODE();
DPRINT("Entering handle table entry 0x%p lock...\n", Entry);
ASSERT(HandleTable);
ASSERT(Entry);
for(;;)
{
Current = (volatile ULONG_PTR)Entry->Object;
if(!Current || (HandleTable->Flags & EX_HANDLE_TABLE_CLOSING))
{
DPRINT("Attempted to lock empty handle table entry 0x%p or handle table shut down\n", Entry);
break;
}
if(!(Current & EX_HANDLE_ENTRY_LOCKED))
{
New = Current | EX_HANDLE_ENTRY_LOCKED;
if(InterlockedCompareExchangePointer(&Entry->Object,
(PVOID)New,
(PVOID)Current) == (PVOID)Current)
{
DPRINT("SUCCESS handle table 0x%p entry 0x%p lock\n", HandleTable, Entry);
/* we acquired the lock */
return TRUE;
}
}
/* wait about 5ms at maximum so we don't wait forever in unfortunate
co-incidences where releasing the lock in another thread happens right
before we're waiting on the contention event to get pulsed, which might
never happen again... */
KeWaitForSingleObject(&HandleTable->HandleContentionEvent,
Executive,
KernelMode,
FALSE,
&ExpHandleShortWait);
}
return FALSE;
}
VOID
ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable,
IN PHANDLE_TABLE_ENTRY Entry)
{
ULONG_PTR Current, New;
PAGED_CODE();
ASSERT(HandleTable);
ASSERT(Entry);
DPRINT("ExUnlockHandleTableEntry HT:0x%p Entry:0x%p\n", HandleTable, Entry);
Current = (volatile ULONG_PTR)Entry->Object;
ASSERT(Current & EX_HANDLE_ENTRY_LOCKED);
New = Current & ~EX_HANDLE_ENTRY_LOCKED;
(void)InterlockedExchangePointer(&Entry->Object,
(PVOID)New);
/* we unlocked the entry, pulse the contention event so threads who're waiting
on the release can continue */
KePulseEvent(&HandleTable->HandleContentionEvent,
EVENT_INCREMENT,
FALSE);
}
HANDLE
ExCreateHandle(IN PHANDLE_TABLE HandleTable,
IN PHANDLE_TABLE_ENTRY Entry)
{
PHANDLE_TABLE_ENTRY NewHandleTableEntry;
HANDLE Handle = NULL;
PAGED_CODE();
ASSERT(HandleTable);
ASSERT(Entry);
/* The highest bit in Entry->Object has to be 1 so we make sure it's a
pointer to kmode memory. It will cleared though because it also indicates
the lock */
ASSERT((ULONG_PTR)Entry->Object & EX_HANDLE_ENTRY_LOCKED);
KeEnterCriticalRegion();
ExAcquireHandleLockExclusive(HandleTable);
NewHandleTableEntry = ExpAllocateHandleTableEntry(HandleTable,
&Handle);
if(NewHandleTableEntry != NULL)
{
*NewHandleTableEntry = *Entry;
ExUnlockHandleTableEntry(HandleTable,
NewHandleTableEntry);
}
ExReleaseHandleLock(HandleTable);
KeLeaveCriticalRegion();
return Handle;
}
BOOLEAN
ExDestroyHandle(IN PHANDLE_TABLE HandleTable,
IN HANDLE Handle)
{
PHANDLE_TABLE_ENTRY HandleTableEntry;
LONG ExHandle;
BOOLEAN Ret = FALSE;
PAGED_CODE();
ASSERT(HandleTable);
ExHandle = HANDLE_TO_EX_HANDLE(Handle);
KeEnterCriticalRegion();
ExAcquireHandleLockExclusive(HandleTable);
HandleTableEntry = ExpLookupHandleTableEntry(HandleTable,
ExHandle);
if(HandleTableEntry != NULL && ExLockHandleTableEntry(HandleTable, HandleTableEntry))
{
/* free and automatically unlock the handle. However we don't need to pulse
the contention event since other locks on this entry will fail */
ExpFreeHandleTableEntry(HandleTable,
HandleTableEntry,
ExHandle);
Ret = TRUE;
}
ExReleaseHandleLock(HandleTable);
KeLeaveCriticalRegion();
return Ret;
}
VOID
ExDestroyHandleByEntry(IN PHANDLE_TABLE HandleTable,
IN PHANDLE_TABLE_ENTRY Entry,
IN HANDLE Handle)
{
PAGED_CODE();
ASSERT(HandleTable);
ASSERT(Entry);
/* This routine requires the entry to be locked */
ASSERT((ULONG_PTR)Entry->Object & EX_HANDLE_ENTRY_LOCKED);
DPRINT("DestroyHandleByEntry HT:0x%p Entry:0x%p\n", HandleTable, Entry);
if (!(HandleTable->Flags & EX_HANDLE_TABLE_CLOSING))
{
KeEnterCriticalRegion();
ExAcquireHandleLockExclusive(HandleTable);
/* free and automatically unlock the handle. However we don't need to pulse
the contention event since other locks on this entry will fail */
ExpFreeHandleTableEntry(HandleTable,
Entry,
HANDLE_TO_EX_HANDLE(Handle));
ExReleaseHandleLock(HandleTable);
KeLeaveCriticalRegion();
}
}
PHANDLE_TABLE_ENTRY
ExMapHandleToPointer(IN PHANDLE_TABLE HandleTable,
IN HANDLE Handle)
{
PHANDLE_TABLE_ENTRY HandleTableEntry;
PAGED_CODE();
ASSERT(HandleTable);
HandleTableEntry = ExpLookupHandleTableEntry(HandleTable,
HANDLE_TO_EX_HANDLE(Handle));
if (HandleTableEntry != NULL && ExLockHandleTableEntry(HandleTable, HandleTableEntry))
{
DPRINT("ExMapHandleToPointer HT:0x%p Entry:0x%p locked\n", HandleTable, HandleTableEntry);
return HandleTableEntry;
}
return NULL;
}
BOOLEAN
ExChangeHandle(IN PHANDLE_TABLE HandleTable,
IN HANDLE Handle,
IN PEX_CHANGE_HANDLE_CALLBACK ChangeHandleCallback,
IN PVOID Context)
{
PHANDLE_TABLE_ENTRY HandleTableEntry;
BOOLEAN Ret = FALSE;
PAGED_CODE();
ASSERT(HandleTable);
ASSERT(ChangeHandleCallback);
KeEnterCriticalRegion();
HandleTableEntry = ExpLookupHandleTableEntry(HandleTable,
HANDLE_TO_EX_HANDLE(Handle));
if(HandleTableEntry != NULL && ExLockHandleTableEntry(HandleTable, HandleTableEntry))
{
Ret = ChangeHandleCallback(HandleTable,
HandleTableEntry,
Context);
ExUnlockHandleTableEntry(HandleTable,
HandleTableEntry);
}
KeLeaveCriticalRegion();
return Ret;
}
/* EOF */

View File

@@ -1,860 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ex/i386/fastinterlck_asm.S
* PURPOSE: FASTCALL Interlocked Functions
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES ******************************************************************/
#include <ndk/asm.h>
#include <internal/i386/asmmacro.S>
.intel_syntax noprefix
/* FUNCTIONS ****************************************************************/
/*
* NOTE: These functions must obey the following rules:
* - Acquire locks only on MP systems.
* - Be safe at HIGH_LEVEL (no paged access).
* - Preserve flags.
* - Disable interrups.
*/
/*VOID
*FASTCALL
*ExInterlockedAddLargeStatistic(IN PLARGE_INTEGER Addend,
* IN ULONG Increment)
*/
.global @ExInterlockedAddLargeStatistic@8
@ExInterlockedAddLargeStatistic@8:
#ifdef CONFIG_SMP
/* Do the addition */
lock add [ecx], edx
/* Check for carry bit and return */
jb 1f
ret
1:
/* Add carry */
lock adc dword ptr [ecx+4], 0
#else
/* Do the addition and add the carry */
add dword ptr [ecx], edx
adc dword ptr [ecx+4], 0
#endif
/* Return */
ret
/*ULONG
*FASTCALL
*ExfInterlockedAddUlong(IN PULONG Addend,
* IN ULONG Increment,
* IN PKSPIN_LOCK Lock)
*/
.global @ExfInterlockedAddUlong@12
@ExfInterlockedAddUlong@12:
/* Save flags */
pushfd
#ifdef CONFIG_SMP
/* Get lock address */
mov eax, [esp+8]
.start1:
#endif
/* Disable interrupts */
cli
/* Acquire lock */
ACQUIRE_SPINLOCK(eax, .spin1)
/* Do the add */
mov eax, [ecx]
add [ecx], edx
#ifdef CONFIG_SMP
/* Get spinlock address and release it */
mov edx, [esp+8]
RELEASE_SPINLOCK(edx)
#endif
/* Restore flags and return */
popfd
ret 4
#ifdef CONFIG_SMP
.spin1:
/* Restore flags and spin */
popfd
pushfd
SPIN_ON_LOCK(eax, .start1)
#endif
/*PLIST_ENTRY
*FASTCALL
*ExfInterlockedInsertHeadList(IN PLIST_ENTRY ListHead,
* IN PLIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
.global @ExfInterlockedInsertHeadList@12
@ExfInterlockedInsertHeadList@12:
#ifdef CONFIG_SMP
/* Save lock address */
push esi
mov esi, [esp+8]
#endif
/* Save flags and disable interrupts */
pushfd
.start2:
cli
/* Acquire lock */
ACQUIRE_SPINLOCK(esi, .spin2)
/* Get list pointer */
mov eax, [ecx]
/* Do the insert */
mov [edx], eax
mov [edx+4], ecx
mov [ecx], edx
mov [eax+4], edx
/* Release lock and restore flags */
RELEASE_SPINLOCK(esi)
popfd
#ifdef CONFIG_SMP
pop esi
#endif
/* Check if list was empty */
xor eax, ecx
jz 2f
/* Return list pointer */
xor eax, ecx
2:
ret 4
#ifdef CONFIG_SMP
.spin2:
popfd
pushfd
SPIN_ON_LOCK(esi, .start2)
#endif
/*PLIST_ENTRY
*FASTCALL
*ExfInterlockedInsertTailList(IN PLIST_ENTRY ListHead,
* IN PLIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
.global @ExfInterlockedInsertTailList@12
@ExfInterlockedInsertTailList@12:
#ifdef CONFIG_SMP
/* Save lock address */
push esi
mov esi, [esp+8]
#endif
/* Save flags and disable interrupts */
pushfd
.start3:
cli
/* Acquire lock */
ACQUIRE_SPINLOCK(esi, .spin3)
/* Get list pointer */
mov eax, [ecx+4]
/* Do the insert */
mov [edx], ecx
mov [edx+4], eax
mov [ecx+4], edx
mov [eax], edx
/* Release lock and restore flags */
RELEASE_SPINLOCK(esi)
popfd
#ifdef CONFIG_SMP
pop esi
#endif
/* Check if list was empty */
xor eax, ecx
jz 2f
/* Return list pointer */
xor eax, ecx
2:
ret 4
#ifdef CONFIG_SMP
.spin3:
popfd
pushfd
SPIN_ON_LOCK(esi, .start3)
#endif
/*PLIST_ENTRY
*FASTCALL
*ExfInterlockedRemoveHeadList(IN PLIST_ENTRY ListHead,
* IN PKSPIN_LOCK Lock)
*/
.global @ExfInterlockedRemoveHeadList@8
@ExfInterlockedRemoveHeadList@8:
/* Save flags and disable interrupts */
.start4:
pushfd
cli
ACQUIRE_SPINLOCK(edx, .spin4)
/* Get list pointer */
mov eax, [ecx]
/* Check if it's empty */
cmp eax, ecx
je 2f
/* Get the next entry and do the deletion*/
#ifdef CONFIG_SMP
push ebx
mov ebx, [eax]
mov [ecx], ebx
mov [ebx+4], ecx
#else
mov edx, [eax]
mov [ecx], edx
mov [edx+4], ecx
#endif
/* Release lock */
#ifdef CONFIG_SMP
RELEASE_SPINLOCK(edx)
pop ebx
#endif
/* Restore flags */
popfd
/* Return */
ret
2:
/* Release lock */
RELEASE_SPINLOCK(edx)
/* Restore flags */
popfd
/* Return empty list */
xor eax, eax
ret
#ifdef CONFIG_SMP
.spin4:
popfd
SPIN_ON_LOCK(edx, .start4)
#endif
/*PSINGLE_LIST_ENTRY
*FASTCALL
*ExfInterlockedPopEntryList(IN PSINGLE_LIST_ENTRY ListHead,
* IN PKSPIN_LOCK Lock)
*/
.global @ExfInterlockedPopEntryList@8
@ExfInterlockedPopEntryList@8:
/* Save flags and disable interrupts */
.start5:
pushfd
cli
ACQUIRE_SPINLOCK(edx, .spin5)
/* Get list pointer */
mov eax, [ecx]
/* Check if it's empty */
or eax, eax
je 3f
/* Get next entry and do deletion */
#ifdef CONFIG_SMP
push edx
#endif
mov edx, [eax]
mov [ecx], edx
#ifdef CONFIG_SMP
pop edx
#endif
2:
/* Release lock */
RELEASE_SPINLOCK(edx)
/* Restore flags */
popfd
/* Return */
ret
3:
/* Return empty list */
xor eax, eax
jmp 2b
#ifdef CONFIG_SMP
.spin5:
popfd
SPIN_ON_LOCK(edx, .start5)
#endif
/*PSINGLE_LIST_ENTRY
*FASTCALL
*ExfInterlockedPushEntryList(IN PSINGLE_LIST_ENTRY ListHead,
* IN PSINGLE_LIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
.global @ExfInterlockedPushEntryList@12
@ExfInterlockedPushEntryList@12:
/* Save flags */
pushfd
/* Save lock pointer */
#ifdef CONFIG_SMP
push edx
mov edx, [esp+12]
#endif
/* Disable interrupts */
.start6:
cli
#ifdef CONFIG_SMP
ACQUIRE_SPINLOCK(edx, .spin6)
pop edx
#endif
/* Get list pointer */
mov eax, [ecx]
/* Do push */
mov [edx], eax
mov [ecx], edx
/* Release lock */
#ifdef CONFIG_SMP
mov edx, [esp+8]
RELEASE_SPINLOCK(edx)
#endif
/* Restore flags */
popfd
/* Return */
ret 4
#ifdef CONFIG_SMP
.spin6:
pop edx
popfd
pushfd
push edx
mov edx, [esp+12]
SPIN_ON_LOCK(edx, .start6)
#endif
/*PSINGLE_LIST_ENTRY
*FASTCALL
*ExInterlockedPopEntrySList(IN PSINGLE_LIST_ENTRY ListHead,
* IN PKSPIN_LOCK Lock)
*/
.global @ExInterlockedPopEntrySList@8
.global @InterlockedPopEntrySList@4
@ExInterlockedPopEntrySList@8:
@InterlockedPopEntrySList@4:
/* Save registers */
push ebx
push ebp
/* Pointer to list */
mov ebp, ecx
/* Get sequence number and link pointer */
mov edx, [ebp+4]
mov eax, [ebp]
1:
/* Check if the list is empty */
or eax, eax
jz 2f
/* Copy sequence number and adjust it */
lea ecx, [edx-1]
/* Get next pointer and do the exchange */
mov ebx, [eax]
LOCK cmpxchg8b [ebp]
jnz 1b
/* Restore registers and return */
2:
pop ebp
pop ebx
ret
/*PSINGLE_LIST_ENTRY
*FASTCALL
*ExInterlockedPushEntrySList(IN PSINGLE_LIST_ENTRY ListHead,
* IN PSINGLE_LIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
.global @ExInterlockedPushEntrySList@12
@ExInterlockedPushEntrySList@12:
/* So we can fall through below */
pop [esp]
.global @InterlockedPushEntrySList@8
@InterlockedPushEntrySList@8:
/* Save registers */
push ebx
push ebp
/* Pointer to list */
mov ebp, ecx
mov ebx, edx
/* Get sequence number and link pointer */
mov edx, [ebp+4]
mov eax, [ebp]
1:
/* Set link pointer */
mov [ebx], eax
/* Copy sequence number and adjust it */
lea ecx, [edx+0x10001]
/* Do the exchange */
LOCK cmpxchg8b [ebp]
jnz 1b
/* Restore registers and return */
2:
pop ebp
pop ebx
ret
/*PSINGLE_LIST_ENTRY
*FASTCALL
*ExInterlockedFlushSList(IN PSINGLE_LIST_ENTRY ListHead)
*/
.global @ExInterlockedFlushSList@4
@ExInterlockedFlushSList@4:
/* Save registers */
push ebx
push ebp
/* Clear ebx */
xor ebx, ebx
/* Pointer to list */
mov ebp, ecx
/* Get sequence number and link pointer */
mov edx, [ebp+4]
mov eax, [ebp]
1:
/* Check if the list is empty */
or eax, eax
jz 2f
/* Clear sequence and pointer */
mov ecx, edx
mov cx, bx
/* Do the exchange */
LOCK cmpxchg8b [ebp]
jnz 1b
/* Restore registers and return */
2:
pop ebp
pop ebx
ret
/*INTERLOCKED_RESULT
*FASTCALL
*Exfi386InterlockedIncrementLong(IN PLONG Addend)
*/
.global @Exfi386InterlockedIncrementLong@4
@Exfi386InterlockedIncrementLong@4:
/* Do the op */
LOCK add dword ptr [ecx], 1
/* Return */
lahf
and eax, EFLAG_SELECT
ret
/*INTERLOCKED_RESULT
*FASTCALL
*Exfi386InterlockedDecrementLong(IN PLONG Addend)
*/
.global @Exfi386InterlockedDecrementLong@4
@Exfi386InterlockedDecrementLong@4:
/* Do the op */
LOCK sub dword ptr [ecx], 1
/* Return */
lahf
and eax, EFLAG_SELECT
ret
/*ULONG
*FASTCALL
*Exfi386InterlockedExchangeUlong(IN PULONG Taget,
* IN ULONG Value)
*/
.global @Exfi386InterlockedExchangeUlong@8
.global @InterlockedExchange@8
@InterlockedExchange@8:
@Exfi386InterlockedExchangeUlong@8:
#ifdef CONFIG_SMP
/* On MP, do the exchange */
xchg [ecx], edx
mov eax, edx
#else
/* On UP, use cmpxchg */
mov eax, [ecx]
1:
cmpxchg [ecx], edx
jnz 1b
#endif
/* Return */
ret
/*ULONG
*FASTCALL
*InterlockedIncrement(IN PLONG Addend)
*/
.global @InterlockedIncrement@4
@InterlockedIncrement@4:
/* Do the op */
mov eax, 1
LOCK xadd dword ptr [ecx], eax
/* Return */
inc eax
ret
/*ULONG
*FASTCALL
*InterlockedDecrement(IN PLONG Addend)
*/
.global @InterlockedDecrement@4
@InterlockedDecrement@4:
/* Do the op */
mov eax, -1
LOCK xadd dword ptr [ecx], eax
/* Return */
dec eax
ret
/*PVOID
*FASTCALL
*InterlockedCompareExchange(IN OUT PVOID *Destination,
* IN PVOID Exchange,
* IN PVOID Comperand)
*/
.global @InterlockedCompareExchange@12
@InterlockedCompareExchange@12:
/* Get comperand */
mov eax, [esp+4]
/* Do the op */
LOCK cmpxchg dword ptr [ecx], edx
/* Return */
ret 4
/*PVOID
*FASTCALL
*ExfInterlockedCompareExchange64(IN PLONGLONG Destination,
* IN PLONGLONG Exchange,
* IN PLONGLONG Comperand)
*/
.global @ExfInterlockedCompareExchange64@12
@ExfInterlockedCompareExchange64@12:
/* Save registers */
push ebx
push ebp
/* Get desination pointer, exchange value and comperand value/address */
mov ebp, ecx
mov ebx, [edx]
mov ecx, [edx+4]
mov edx, [esp+12]
mov eax, [edx]
mov edx, [edx+4]
/* Do the op */
LOCK cmpxchg8b [ebp]
/* Restore volatiles */
pop ebp
pop ebx
/* Return */
ret 4
/*PVOID
*FASTCALL
*ExfInterlockedCompareExchange64(IN PLONGLONG Destination,
* IN PLONGLONG Exchange,
* IN PLONGLONG Comperand,
* IN PKSPIN_LOCK Lock)
*/
.global @ExInterlockedCompareExchange64@16
@ExInterlockedCompareExchange64@16:
/* Save registers */
push ebp
push ebp
/* Get desination pointer, exchange value and comperand value/address */
mov ebp, ecx
mov ebx, [edx]
mov ecx, [edx+4]
mov edx, [esp+12]
mov eax, [edx]
mov edx, [edx+4]
/* Do the op */
LOCK cmpxchg8b [ebp]
/* Restore volatiles */
pop ebp
pop ebx
/* Return */
ret 8
/*PVOID
*FASTCALL
*InterlockedExchangeAdd(IN OUT PLONG Addend,
* IN LONG Increment)
*/
.global @InterlockedExchangeAdd@8
@InterlockedExchangeAdd@8:
/* Do the op */
LOCK xadd dword ptr [ecx], edx
/* Return */
mov eax, edx
ret
/*** Non-586 functions ***/
/*PSINGLE_LIST_ENTRY
*FASTCALL
*ExfInterlockedPopEntrySList(IN PSINGLE_LIST_ENTRY ListHead,
* IN PKSPIN_LOCK Lock)
*/
.global @ExfInterlockedPopEntrySList@8
@ExfInterlockedPopEntrySList@8:
/* Save flags */
.starta:
pushfd
/* Disable interrupts */
cli
/* Acquire lock */
ACQUIRE_SPINLOCK(edx, .spina)
/* Get the next link and check if it's empty */
mov eax, [ecx]
or eax, eax
jz 1f
/* Get address of the next link and store it */
push [eax]
pop [ecx]
/* Decrement list depth */
dec dword ptr [ecx+4]
1:
#ifdef CONFIG_SMP
/* Release spinlock */
RELEASE_SPINLOCK(edx)
#endif
/* Restore flags and return */
popfd
ret 0
#ifdef CONFIG_SMP
.spina:
/* Restore flags and spin */
popfd
SPIN_ON_LOCK(edx, .starta)
#endif
/*PSINGLE_LIST_ENTRY
*FASTCALL
*ExfInterlockedPushEntrySList(IN PSINGLE_LIST_ENTRY ListHead,
* IN PSINGLE_LIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
.global @ExfInterlockedPushEntrySList@12
@ExfInterlockedPushEntrySList@12:
/* Save flags */
.startb:
pushfd
/* Disable interrupts */
cli
/* Acquire lock */
#ifndef CONFIG_SMP
mov eax, [esp+8]
ACQUIRE_SPINLOCK(eax, .spinb)
#endif
/* Get the next link and check if it's empty */
push [ecx]
/* Get address of the next link and store it */
pop [edx]
mov [ecx], edx
/* Increment list depth */
inc dword ptr [ecx+4]
#ifdef CONFIG_SMP
/* Release spinlock */
RELEASE_SPINLOCK(eax)
#endif
/* Restore flags and return */
popfd
ret 4
#ifdef CONFIG_SMP
.spinb:
/* Restore flags and spin */
popfd
SPIN_ON_LOCK(eax, .startb)
#endif
/*PVOID
*FASTCALL
*ExpInterlockedCompareExchange64(IN PLONGLONG Destination,
* IN PLONGLONG Exchange,
* IN PLONGLONG Comperand,
* IN PKSPIN_LOCK Lock)
*/
.global @ExpInterlockedCompareExchange64@16
@ExpInterlockedCompareExchange64@16:
/* Save registers */
push ebp
push ebp
/* Get desination pointer, exchange value and comperand value/address */
mov ebp, ecx
mov ebx, [edx]
mov ecx, [edx+4]
mov edx, [esp+12]
mov eax, [edx]
mov edx, [edx+4]
#ifdef CONFIG_SMP
/* Save ESI so we can store KSPINLOCK in it */
push esi
/* Save flags and lock, and disable interrupts */
pushfd
mov esi, [esp+24]
cli
/* Acquire the spinlock */
ACQUIRE_SPINLOCK(esi, .spinc)
#else
/* Save flags and disable interrupts */
pushfd
cli
#endif
/* Compare bottom */
cmp eax, [ebp]
jne NoMatch
/* Compare top */
cmp edx, [ebp+4]
jne NoMatch
/* Save new value */
mov [ebp], ebx
mov [ebp+4], ecx
AfterSave:
#ifdef CONFIG_SMP
/* Release lock, restore volatiles and flags */
RELEASE_SPINLOCK(esi)
popfd
pop esi
#else
popfd
#endif
/* Restore the other volatiles and return */
pop ebp
pop ebx
/* Return */
ret 8
NoMatch:
/* Return the current value */
mov eax, [ebp]
mov edx, [ebp+4]
jmp AfterSave
#ifdef CONFIG_SMP
.spinc:
/* Restore flags and spin */
popfd
pushfd
SPIN_ON_LOCK(esi, .startc)
#endif
/* EOF */

View File

@@ -1,579 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ex/i386/interlck_asm.S
* PURPOSE: STDCALL Interlocked Functions
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES ******************************************************************/
#include <ndk/asm.h>
#include <internal/i386/asmmacro.S>
.intel_syntax noprefix
/* FUNCTIONS ****************************************************************/
/*
* NOTE: These functions must obey the following rules:
* - Acquire locks only on MP systems.
* - Be safe at HIGH_LEVEL (no paged access).
* - Preserve flags.
* - Disable interrups.
*/
/*PLIST_ENTRY
*NTAPI
*ExInterlockedAddLargeInteger(IN PLIST_ENTRY ListHead,
* IN PLIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
.global _ExInterlockedAddLargeInteger@16
_ExInterlockedAddLargeInteger@16:
/* Prepare stack frame */
push ebp
mov ebp, esp
sub esp, 8
/* Save lock pointer */
#ifdef CONFIG_SMP
mov eax, [ebp+20]
#endif
/* Save flags and disable interrupts */
.start1:
pushfd
cli
/* Acquire lock */
ACQUIRE_SPINLOCK(eax, .spin1)
/* Do the calculation */
mov eax, [ebp+8]
mov ecx, [eax]
mov edx, [eax+4]
/* Save result */
mov [ebp-8], ecx
mov [ebp-4], edx
/* Add increment */
add ecx, [ebp+12]
adc edx, [ebp+16]
/* Save result */
mov [eax], ecx
mov [eax+4], edx
/* Release lock */
#ifdef CONFIG_SMP
mov eax, [ebp+20]
RELEASE_SPINLOCK(eax)
#endif
/* Restore flags */
popfd
/* Restore frame and return values */
mov eax, [ebp-8]
mov edx, [ebp-4]
mov esp, ebp
pop ebp
ret 16
#ifdef CONFIG_SMP
.spin1:
popfd
SPIN_ON_LOCK(eax, .start1)
#endif
/*PLIST_ENTRY
*NTAPI
*ExInterlockedInsertHeadList(IN PLIST_ENTRY ListHead,
* IN PLIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
.global _ExInterlockedAddUlong@12
_ExInterlockedAddUlong@12:
/* Save flags and disable interrupts */
pushfd
/* Get lock address */
#ifdef CONFIG_SMP
mov edx, [ebp+16]
#endif
.start2:
cli
/* Acquire lock */
ACQUIRE_SPINLOCK(edx, .spin2)
/* Do the calculation */
mov ecx, [esp+8]
#ifdef CONFIG_SMP
mov eax, [ecx]
add eax, [esp+12]
/* Save result */
mov [ecx], eax
#else
/* Do the calculation */
mov edx, [ecx]
mov eax, edx
add edx, [esp+12]
/* Save result */
mov [ecx], edx
#endif
/* Release lock, restore flags and return */
#ifdef CONFIG_SMP
sub eax, [esp+12]
RELEASE_SPINLOCK(edx)
#endif
popfd
ret 12
#ifdef CONFIG_SMP
.spin2:
popfd
pushfd
SPIN_ON_LOCK(eax, .start2)
#endif
/*PLIST_ENTRY
*NTAPI
*ExInterlockedInsertHeadList(IN PLIST_ENTRY ListHead,
* IN PLIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
.global _ExInterlockedInsertHeadList@12
_ExInterlockedInsertHeadList@12:
/* Save lock pointer */
#ifdef CONFIG_SMP
mov edx, [esp+12]
#endif
/* Save flags and disable interrupts */
.start3:
pushfd
cli
ACQUIRE_SPINLOCK(edx, .spin3)
/* Get list pointers */
mov eax, [esp+8]
mov ecx, [esp+12]
mov edx, [eax]
/* Do the insert */
mov [ecx], edx
mov [ecx+4], eax
mov [eax], ecx
mov [edx+4], ecx
/* Release lock */
#ifdef CONFIG_SMP
mov ecx, [esp+16]
RELEASE_SPINLOCK(ecx)
#endif
/* Restore flags */
popfd
/* check if the list was empty and return NULL */
xor eax, edx
jz 2f
/* Return pointer */
mov eax, edx
2:
ret 12
#ifdef CONFIG_SMP
.spin3:
popfd
SPIN_ON_LOCK(edx, .start3)
#endif
/*PLIST_ENTRY
*NTAPI
*ExInterlockedInsertTailList(IN PLIST_ENTRY ListHead,
* IN PLIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
.global _ExInterlockedInsertTailList@12
_ExInterlockedInsertTailList@12:
/* Save lock pointer */
#ifdef CONFIG_SMP
mov edx, [esp+12]
#endif
/* Save flags and disable interrupts */
.start4:
pushfd
cli
ACQUIRE_SPINLOCK(edx, .spin4)
/* Get list pointers */
mov eax, [esp+8]
mov ecx, [esp+12]
mov edx, [eax+4]
/* Do the insert */
mov [ecx], eax
mov [ecx+4], edx
mov [eax+4], ecx
mov [edx], ecx
/* Release lock */
#ifdef CONFIG_SMP
mov ecx, [esp+16]
RELEASE_SPINLOCK(ecx)
#endif
/* Restore flags */
popfd
/* check if the list was empty and return NULL */
xor eax, edx
jz 2f
/* Return pointer */
mov eax, edx
2:
ret 12
#ifdef CONFIG_SMP
.spin4:
popfd
SPIN_ON_LOCK(edx, .start4)
#endif
/*PLIST_ENTRY
*NTAPI
*ExInterlockedRemoveHeadList(IN PLIST_ENTRY ListHead,
* IN PKSPIN_LOCK Lock)
*/
.global _ExInterlockedRemoveHeadList@8
_ExInterlockedRemoveHeadList@8:
/* Save lock pointer */
#ifdef CONFIG_SMP
mov edx, [esp+8]
#endif
/* Save flags and disable interrupts */
.start5:
pushfd
cli
ACQUIRE_SPINLOCK(edx, .spin5)
/* Get list pointers */
mov edx, [esp+8]
mov eax, [edx]
/* Check if it's empty */
cmp eax, edx
je 2f
/* Get next entry and do deletion */
mov ecx, [eax]
mov [edx], ecx
mov [ecx+4], edx
/* Release lock */
#ifdef CONFIG_SMP
mov ecx, [esp+12]
RELEASE_SPINLOCK(edx)
#endif
/* Restore flags */
popfd
/* Return */
ret 8
2:
/* Release lock */
#ifdef CONFIG_SMP
mov edx, [esp+12]
RELEASE_SPINLOCK(edx)
#endif
/* Restore flags */
popfd
/* Return empty list */
xor eax, eax
ret 8
#ifdef CONFIG_SMP
.spin5:
popfd
SPIN_ON_LOCK(edx, .start5)
#endif
/*PSINGLE_LIST_ENTRY
*NTAPI
*ExInterlockedPopEntryList(IN PSINGLE_LIST_ENTRY ListHead,
* IN PKSPIN_LOCK Lock)
*/
.global _ExInterlockedPopEntryList@8
_ExInterlockedPopEntryList@8:
/* Save lock pointer */
#ifdef CONFIG_SMP
mov edx, [esp+8]
#endif
/* Save flags and disable interrupts */
.start6:
pushfd
cli
ACQUIRE_SPINLOCK(edx, .spin6)
/* Get list pointers */
mov edx, [esp+8]
mov eax, [ecx]
/* Check if it's empty */
or eax, eax
je 3f
/* Get next entry and do deletion */
mov edx, [eax]
mov [ecx], edx
2:
/* Release lock */
#ifdef CONFIG_SMP
mov ecx, [esp+12]
RELEASE_SPINLOCK(edx)
#endif
/* Restore flags */
popfd
/* Return */
ret 8
3:
/* Return empty list */
xor eax, eax
jmp 2b
#ifdef CONFIG_SMP
.spin6:
popfd
SPIN_ON_LOCK(edx, .start6)
#endif
/*PSINGLE_LIST_ENTRY
*NTAPI
*ExInterlockedPushEntryList(IN PSINGLE_LIST_ENTRY ListHead,
* IN PSINGLE_LIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
.global _ExInterlockedPushEntryList@12
_ExInterlockedPushEntryList@12:
/* Save lock pointer */
#ifdef CONFIG_SMP
mov edx, [esp+12]
#endif
/* Save flags and disable interrupts */
.start7:
pushfd
cli
ACQUIRE_SPINLOCK(edx, .spin7)
/* Get list pointers */
mov edx, [esp+8]
mov eax, [edx]
mov ecx, [esp+12]
/* Do push */
mov [ecx], eax
mov [edx], ecx
/* Release lock */
#ifdef CONFIG_SMP
mov ecx, [esp+16]
RELEASE_SPINLOCK(edx)
#endif
/* Restore flags */
popfd
/* Return */
ret 12
#ifdef CONFIG_SMP
.spin7:
popfd
SPIN_ON_LOCK(edx, .start7)
#endif
/*INTERLOCKED_RESULT
*NTAPI
*ExInterlockedIncrementLong(IN PLONG Addend,
* IN PKSPIN_LOCK Lock)
*/
.global _ExInterlockedIncrementLong@8
_ExInterlockedIncrementLong@8:
/* Get addend */
mov eax, [esp+4]
/* Do the op */
LOCK add dword ptr [eax], 1
/* Return */
lahf
and eax, EFLAG_SELECT
ret 8
/*INTERLOCKED_RESULT
*NTAPI
*ExInterlockedDecrementLong(IN PLONG Addend,
* IN PKSPIN_LOCK Lock)
*/
.global _ExInterlockedDecrementLong@8
_ExInterlockedDecrementLong@8:
/* Get addend */
mov eax, [esp+4]
/* Do the op */
LOCK sub dword ptr [eax], 1
/* Return */
lahf
and eax, EFLAG_SELECT
ret 8
/*ULONG
*NTAPI
*ExInterlockedExchangeUlong(IN PULONG Taget,
* IN ULONG Value,
* IN PKSPIN_LOCK Lock)
*/
.global _ExInterlockedExchangeUlong@12
_ExInterlockedExchangeUlong@12:
/* Get pointers */
mov edx, [esp+4]
mov eax, [esp+8]
#ifdef CONFIG_SMP
/* On MP, do the exchange */
xchg [edx], eax
#else
/* On UP, disable interrupts and save flags */
pushfd
cli
/* Switch values */
mov eax, [edx]
mov [edx], ecx
popfd
#endif
/* Return */
ret 12
/*INTERLOCKED_RESULT
*NTAPI
*Exi386InterlockedIncrementLong(IN PLONG Addend,
* IN PKSPIN_LOCK Lock)
*/
.global _Exi386InterlockedIncrementLong@4
_Exi386InterlockedIncrementLong@4:
/* Get addend */
mov eax, [esp+4]
/* Do the op */
LOCK add dword ptr [eax], 1
/* Return */
lahf
and eax, EFLAG_SELECT
ret 4
/*INTERLOCKED_RESULT
*NTAPI
*Exi386InterlockedDecrementLong(IN PLONG Addend,
* IN PKSPIN_LOCK Lock)
*/
.global _Exi386InterlockedDecrementLong@4
_Exi386InterlockedDecrementLong@4:
/* Get addend */
mov eax, [esp+4]
/* Do the op */
LOCK sub dword ptr [eax], 1
/* Return */
lahf
and eax, EFLAG_SELECT
ret 8
/*ULONG
*NTAPI
*Exi386InterlockedExchangeUlong(IN PULONG Taget,
* IN ULONG Value,
* IN PKSPIN_LOCK Lock)
*/
.global _Exi386InterlockedExchangeUlong@12
_Exi386InterlockedExchangeUlong@12:
/* Get pointers */
mov edx, [esp+4]
mov eax, [esp+8]
#ifdef CONFIG_SMP
/* On MP, do the exchange */
xchg [edx], eax
#else
/* On UP, disable interrupts and save flags */
pushfd
cli
/* Switch values */
mov eax, [edx]
mov [edx], ecx
popfd
#endif
/* Return */
ret 8
/* Ugly hack: Use InterlockedExchange64 */
.att_syntax
.global @ExfpInterlockedExchange64@8
@ExfpInterlockedExchange64@8:
pushl %ebx
pushl %esi
movl %ecx,%esi
movl (%edx),%ebx
movl 4(%edx),%ecx
1:
movl (%esi),%eax
movl 4(%esi),%edx
LOCK
cmpxchg8b (%esi)
jnz 1b
popl %esi
popl %ebx
ret
/* EOF */

View File

@@ -1,767 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ex/init.c
* PURPOSE: Executive initalization
*
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - Added ExpInitializeExecutive
* and optimized/cleaned it.
* Eric Kohl (ekohl@abo.rhein-zeitung.de)
*/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* DATA **********************************************************************/
extern ULONG MmCoreDumpType;
extern CHAR KiTimerSystemAuditing;
extern PVOID Ki386InitialStackArray[MAXIMUM_PROCESSORS];
extern ADDRESS_RANGE KeMemoryMap[64];
extern ULONG KeMemoryMapRangeCount;
extern ULONG_PTR FirstKrnlPhysAddr;
extern ULONG_PTR LastKrnlPhysAddr;
extern ULONG_PTR LastKernelAddress;
extern LOADER_MODULE KeLoaderModules[64];
extern PRTL_MESSAGE_RESOURCE_DATA KiBugCodeMessages;
extern LIST_ENTRY KiProfileListHead;
extern LIST_ENTRY KiProfileSourceListHead;
extern KSPIN_LOCK KiProfileLock;
BOOLEAN SetupMode = TRUE;
BOOLEAN NoGuiBoot = FALSE;
VOID PspPostInitSystemProcess(VOID);
static VOID INIT_FUNCTION InitSystemSharedUserPage (PCSZ ParameterLine);
VOID INIT_FUNCTION ExpDisplayNotice(VOID);
INIT_FUNCTION NTSTATUS ExpLoadInitialProcess(PHANDLE ProcessHandle, PHANDLE ThreadHandle);
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, InitSystemSharedUserPage)
#pragma alloc_text(INIT, ExpDisplayNotice)
#pragma alloc_text(INIT, ExpLoadInitialProcess)
#pragma alloc_text(INIT, ExpInitializeExecutive)
#pragma alloc_text(INIT, ExInit2)
#endif
/* FUNCTIONS ****************************************************************/
static
VOID
INIT_FUNCTION
InitSystemSharedUserPage (PCSZ ParameterLine)
{
UNICODE_STRING ArcDeviceName;
UNICODE_STRING ArcName;
UNICODE_STRING BootPath;
UNICODE_STRING DriveDeviceName;
UNICODE_STRING DriveName;
WCHAR DriveNameBuffer[20];
PCHAR ParamBuffer;
PWCHAR ArcNameBuffer;
PCHAR p;
NTSTATUS Status;
ULONG Length;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE Handle;
ULONG i;
BOOLEAN BootDriveFound = FALSE;
/*
* NOTE:
* The shared user page has been zeroed-out right after creation.
* There is NO need to do this again.
*/
Ki386SetProcessorFeatures();
/* Set the Version Data */
SharedUserData->NtProductType = NtProductWinNt;
SharedUserData->ProductTypeIsValid = TRUE;
SharedUserData->NtMajorVersion = 5;
SharedUserData->NtMinorVersion = 0;
/*
* Retrieve the current dos system path
* (e.g.: C:\reactos) from the given arc path
* (e.g.: multi(0)disk(0)rdisk(0)partititon(1)\reactos)
* Format: "<arc_name>\<path> [options...]"
*/
/* Create local parameter line copy */
ParamBuffer = ExAllocatePool(PagedPool, 256);
strcpy (ParamBuffer, (const char *)ParameterLine);
DPRINT("%s\n", ParamBuffer);
/* Cut options off */
p = strchr (ParamBuffer, ' ');
if (p) *p = 0;
DPRINT("%s\n", ParamBuffer);
/* Extract path */
p = strchr (ParamBuffer, '\\');
if (p) {
DPRINT("Boot path: %s\n", p);
RtlCreateUnicodeStringFromAsciiz (&BootPath, p);
*p = 0;
} else {
DPRINT("Boot path: %s\n", "\\");
RtlCreateUnicodeStringFromAsciiz (&BootPath, "\\");
}
DPRINT("Arc name: %s\n", ParamBuffer);
/* Only ARC Name left - Build full ARC Name */
ArcNameBuffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
swprintf (ArcNameBuffer, L"\\ArcName\\%S", ParamBuffer);
RtlInitUnicodeString (&ArcName, ArcNameBuffer);
DPRINT("Arc name: %wZ\n", &ArcName);
/* Free ParamBuffer */
ExFreePool (ParamBuffer);
/* Allocate ARC Device Name string */
ArcDeviceName.Length = 0;
ArcDeviceName.MaximumLength = 256 * sizeof(WCHAR);
ArcDeviceName.Buffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
/* Open the Symbolic Link */
InitializeObjectAttributes(&ObjectAttributes,
&ArcName,
OBJ_OPENLINK,
NULL,
NULL);
Status = NtOpenSymbolicLinkObject(&Handle,
SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes);
/* Free the String */
ExFreePool(ArcName.Buffer);
/* Check for Success */
if (!NT_SUCCESS(Status)) {
/* Free the Strings */
RtlFreeUnicodeString(&BootPath);
ExFreePool(ArcDeviceName.Buffer);
CPRINT("NtOpenSymbolicLinkObject() failed (Status %x)\n", Status);
KEBUGCHECK(0);
}
/* Query the Link */
Status = NtQuerySymbolicLinkObject(Handle,
&ArcDeviceName,
&Length);
NtClose (Handle);
/* Check for Success */
if (!NT_SUCCESS(Status)) {
/* Free the Strings */
RtlFreeUnicodeString(&BootPath);
ExFreePool(ArcDeviceName.Buffer);
CPRINT("NtQuerySymbolicLinkObject() failed (Status %x)\n", Status);
KEBUGCHECK(0);
}
DPRINT("Length: %lu ArcDeviceName: %wZ\n", Length, &ArcDeviceName);
/* Allocate Device Name string */
DriveDeviceName.Length = 0;
DriveDeviceName.MaximumLength = 256 * sizeof(WCHAR);
DriveDeviceName.Buffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
/* Loop Drives */
for (i = 0; i < 26; i++) {
/* Setup the String */
swprintf (DriveNameBuffer, L"\\??\\%C:", 'A' + i);
RtlInitUnicodeString(&DriveName,
DriveNameBuffer);
/* Open the Symbolic Link */
InitializeObjectAttributes(&ObjectAttributes,
&DriveName,
OBJ_OPENLINK,
NULL,
NULL);
Status = NtOpenSymbolicLinkObject(&Handle,
SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes);
/* If it failed, skip to the next drive */
if (!NT_SUCCESS(Status)) {
DPRINT("Failed to open link %wZ\n", &DriveName);
continue;
}
/* Query it */
Status = NtQuerySymbolicLinkObject(Handle,
&DriveDeviceName,
&Length);
/* If it failed, skip to the next drive */
if (!NT_SUCCESS(Status)) {
DPRINT("Failed to query link %wZ\n", &DriveName);
continue;
}
DPRINT("Opened link: %wZ ==> %wZ\n", &DriveName, &DriveDeviceName);
/* See if we've found the boot drive */
if (!RtlCompareUnicodeString (&ArcDeviceName, &DriveDeviceName, FALSE)) {
DPRINT("DOS Boot path: %c:%wZ\n", 'A' + i, &BootPath);
swprintf(SharedUserData->NtSystemRoot, L"%C:%wZ", 'A' + i, &BootPath);
BootDriveFound = TRUE;
}
/* Close this Link */
NtClose (Handle);
}
/* Free all the Strings we have in memory */
RtlFreeUnicodeString (&BootPath);
ExFreePool(DriveDeviceName.Buffer);
ExFreePool(ArcDeviceName.Buffer);
/* Make sure we found the Boot Drive */
if (BootDriveFound == FALSE) {
DbgPrint("No system drive found!\n");
KEBUGCHECK (NO_BOOT_DEVICE);
}
}
__inline
VOID
STDCALL
ExecuteRuntimeAsserts(VOID)
{
/*
* Fail at runtime if someone has changed various structures without
* updating the offsets used for the assembler code.
*/
ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, SystemCall) == 0x300);
ASSERT(FIELD_OFFSET(KTHREAD, InitialStack) == KTHREAD_INITIAL_STACK);
ASSERT(FIELD_OFFSET(KTHREAD, Teb) == KTHREAD_TEB);
ASSERT(FIELD_OFFSET(KTHREAD, KernelStack) == KTHREAD_KERNEL_STACK);
ASSERT(FIELD_OFFSET(KTHREAD, NpxState) == KTHREAD_NPX_STATE);
ASSERT(FIELD_OFFSET(KTHREAD, ServiceTable) == KTHREAD_SERVICE_TABLE);
ASSERT(FIELD_OFFSET(KTHREAD, PreviousMode) == KTHREAD_PREVIOUS_MODE);
ASSERT(FIELD_OFFSET(KTHREAD, TrapFrame) == KTHREAD_TRAP_FRAME);
ASSERT(FIELD_OFFSET(KTHREAD, CallbackStack) == KTHREAD_CALLBACK_STACK);
ASSERT(FIELD_OFFSET(KTHREAD, ApcState.Process) == KTHREAD_APCSTATE_PROCESS);
ASSERT(FIELD_OFFSET(KPROCESS, DirectoryTableBase) == KPROCESS_DIRECTORY_TABLE_BASE);
ASSERT(FIELD_OFFSET(KPROCESS, IopmOffset) == KPROCESS_IOPM_OFFSET);
ASSERT(FIELD_OFFSET(KPROCESS, LdtDescriptor) == KPROCESS_LDT_DESCRIPTOR0);
ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, SavedExceptionStack) == TF_SAVED_EXCEPTION_STACK);
ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, regs) == TF_REGS);
ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, orig_ebp) == TF_ORIG_EBP);
ASSERT(FIELD_OFFSET(KPCR, Tib.ExceptionList) == KPCR_EXCEPTION_LIST);
ASSERT(FIELD_OFFSET(KPCR, Self) == KPCR_SELF);
ASSERT(FIELD_OFFSET(KIPCR, PrcbData) + FIELD_OFFSET(KPRCB, CurrentThread) == KPCR_CURRENT_THREAD);
ASSERT(FIELD_OFFSET(KIPCR, PrcbData) + FIELD_OFFSET(KPRCB, NpxThread) == KPCR_NPX_THREAD);
ASSERT(FIELD_OFFSET(KTSS, Esp0) == KTSS_ESP0);
ASSERT(FIELD_OFFSET(KTSS, IoMapBase) == KTSS_IOMAPBASE);
ASSERT(sizeof(FX_SAVE_AREA) == SIZEOF_FX_SAVE_AREA);
}
__inline
VOID
STDCALL
ParseAndCacheLoadedModules(VOID)
{
ULONG i;
PCHAR Name;
/* Loop the Module List and get the modules we want */
for (i = 1; i < KeLoaderBlock.ModsCount; i++) {
/* Get the Name of this Module */
if (!(Name = strrchr((PCHAR)KeLoaderModules[i].String, '\\'))) {
/* Save the name */
Name = (PCHAR)KeLoaderModules[i].String;
} else {
/* No name, skip */
Name++;
}
/* Now check for any of the modules we will need later */
if (!_stricmp(Name, "ansi.nls")) {
CachedModules[AnsiCodepage] = &KeLoaderModules[i];
} else if (!_stricmp(Name, "oem.nls")) {
CachedModules[OemCodepage] = &KeLoaderModules[i];
} else if (!_stricmp(Name, "casemap.nls")) {
CachedModules[UnicodeCasemap] = &KeLoaderModules[i];
} else if (!_stricmp(Name, "system") || !_stricmp(Name, "system.hiv")) {
CachedModules[SystemRegistry] = &KeLoaderModules[i];
SetupMode = FALSE;
} else if (!_stricmp(Name, "hardware") || !_stricmp(Name, "hardware.hiv")) {
CachedModules[HardwareRegistry] = &KeLoaderModules[i];
}
}
}
__inline
VOID
STDCALL
ParseCommandLine(PULONG MaxMem,
PBOOLEAN NoGuiBoot,
PBOOLEAN BootLog,
PBOOLEAN ForceAcpiDisable)
{
PCHAR p1, p2;
p1 = (PCHAR)KeLoaderBlock.CommandLine;
while(*p1 && (p2 = strchr(p1, '/'))) {
p2++;
if (!_strnicmp(p2, "MAXMEM", 6)) {
p2 += 6;
while (isspace(*p2)) p2++;
if (*p2 == '=') {
p2++;
while(isspace(*p2)) p2++;
if (isdigit(*p2)) {
while (isdigit(*p2)) {
*MaxMem = *MaxMem * 10 + *p2 - '0';
p2++;
}
break;
}
}
} else if (!_strnicmp(p2, "NOGUIBOOT", 9)) {
p2 += 9;
*NoGuiBoot = TRUE;
} else if (!_strnicmp(p2, "CRASHDUMP", 9)) {
p2 += 9;
if (*p2 == ':') {
p2++;
if (!_strnicmp(p2, "FULL", 4)) {
MmCoreDumpType = MM_CORE_DUMP_TYPE_FULL;
} else {
MmCoreDumpType = MM_CORE_DUMP_TYPE_NONE;
}
}
} else if (!_strnicmp(p2, "BOOTLOG", 7)) {
p2 += 7;
*BootLog = TRUE;
} else if (!_strnicmp(p2, "NOACPI", 6)) {
p2 += 6;
*ForceAcpiDisable = TRUE;
}
p1 = p2;
}
}
VOID
INIT_FUNCTION
ExpDisplayNotice(VOID)
{
CHAR str[50];
if (SetupMode)
{
HalDisplayString(
"\n\n\n ReactOS " KERNEL_VERSION_STR " Setup \n");
HalDisplayString(
" \xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD");
HalDisplayString(
"\xCD\xCD\n");
return;
}
HalDisplayString("Starting ReactOS "KERNEL_VERSION_STR" (Build "
KERNEL_VERSION_BUILD_STR")\n");
HalDisplayString(RES_STR_LEGAL_COPYRIGHT);
HalDisplayString("\n\nReactOS is free software, covered by the GNU General "
"Public License, and you\n");
HalDisplayString("are welcome to change it and/or distribute copies of it "
"under certain\n");
HalDisplayString("conditions. There is absolutely no warranty for "
"ReactOS.\n\n");
/* Display number of Processors */
sprintf(str,
"Found %x system processor(s). [%lu MB Memory]\n",
(int)KeNumberProcessors,
(KeLoaderBlock.MemHigher + 1088)/ 1024);
HalDisplayString(str);
}
INIT_FUNCTION
NTSTATUS
ExpLoadInitialProcess(PHANDLE ProcessHandle,
PHANDLE ThreadHandle)
{
UNICODE_STRING CurrentDirectory;
UNICODE_STRING ImagePath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\smss.exe");
NTSTATUS Status;
PRTL_USER_PROCESS_PARAMETERS Params=NULL;
RTL_USER_PROCESS_INFORMATION Info;
RtlInitUnicodeString(&CurrentDirectory,
SharedUserData->NtSystemRoot);
/* Create the Parameters */
Status = RtlCreateProcessParameters(&Params,
&ImagePath,
NULL,
&CurrentDirectory,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
if(!NT_SUCCESS(Status))
{
DPRINT1("Failed to create ppb!\n");
return Status;
}
DPRINT("Creating process\n");
Status = RtlCreateUserProcess(&ImagePath,
OBJ_CASE_INSENSITIVE,
Params,
NULL,
NULL,
NULL,
FALSE,
NULL,
NULL,
&Info);
/* Close the handle and free the params */
RtlDestroyProcessParameters(Params);
if (!NT_SUCCESS(Status))
{
DPRINT1("NtCreateProcess() failed (Status %lx)\n", Status);
return(Status);
}
/* Start it up */
ZwResumeThread(Info.ThreadHandle, NULL);
/* Return Handles */
*ProcessHandle = Info.ProcessHandle;
*ThreadHandle = Info.ThreadHandle;
DPRINT("Process created successfully\n");
return STATUS_SUCCESS;
}
VOID
INIT_FUNCTION
STDCALL
ExpInitializeExecutive(VOID)
{
UNICODE_STRING EventName;
HANDLE InitDoneEventHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
BOOLEAN BootLog = FALSE;
ULONG MaxMem = 0;
BOOLEAN ForceAcpiDisable = FALSE;
LARGE_INTEGER Timeout;
HANDLE ProcessHandle;
HANDLE ThreadHandle;
NTSTATUS Status;
/* Check if the structures match the ASM offset constants */
ExecuteRuntimeAsserts();
/* Set 1 CPU for now, we'll increment this later */
KeNumberProcessors = 1;
/* Sets up the Text Sections of the Kernel and HAL for debugging */
LdrInit1();
/* Lower the IRQL to Dispatch Level */
KeLowerIrql(DISPATCH_LEVEL);
/* Sets up the VDM Data */
NtEarlyInitVdm();
/* Parse Command Line Settings */
ParseCommandLine(&MaxMem, &NoGuiBoot, &BootLog, &ForceAcpiDisable);
/* Initialize Kernel Memory Address Space */
MmInit1(FirstKrnlPhysAddr,
LastKrnlPhysAddr,
LastKernelAddress,
(PADDRESS_RANGE)&KeMemoryMap,
KeMemoryMapRangeCount,
MaxMem > 8 ? MaxMem : 4096);
/* Parse the Loaded Modules (by FreeLoader) and cache the ones we'll need */
ParseAndCacheLoadedModules();
/* Initialize the Dispatcher, Clock and Bug Check Mechanisms. */
KeInit2();
/* Bring back the IRQL to Passive */
KeLowerIrql(PASSIVE_LEVEL);
/* Initialize Profiling */
InitializeListHead(&KiProfileListHead);
InitializeListHead(&KiProfileSourceListHead);
KeInitializeSpinLock(&KiProfileLock);
/* Initialize resources */
ExpResourceInitialization();
/* Load basic Security for other Managers */
if (!SeInit1()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED);
/* Initialize Lookaside Lists */
ExpInitLookasideLists();
/* Create the Basic Object Manager Types to allow new Object Types */
ObInit();
/* Set up Region Maps, Sections and the Paging File */
MmInit2();
/* Initialize Tokens now that the Object Manager is ready */
if (!SeInit2()) KEBUGCHECK(SECURITY1_INITIALIZATION_FAILED);
/* Initalize the Process Manager */
PiInitProcessManager();
/* Break into the Debugger if requested */
if (KdPollBreakIn()) DbgBreakPointWithStatus (DBG_STATUS_CONTROL_C);
/* Initialize all processors */
while (!HalAllProcessorsStarted()) {
PVOID ProcessorStack;
/* Set up the Kernel and Process Manager for this CPU */
KePrepareForApplicationProcessorInit(KeNumberProcessors);
KeCreateApplicationProcessorIdleThread(KeNumberProcessors);
/* Allocate a stack for use when booting the processor */
ProcessorStack = RVA(Ki386InitialStackArray[((int)KeNumberProcessors)], KERNEL_STACK_SIZE);
/* Tell HAL a new CPU is being started */
HalStartNextProcessor(0, (ULONG)ProcessorStack - 2*sizeof(FX_SAVE_AREA));
KeNumberProcessors++;
}
/* Do Phase 1 HAL Initalization */
HalInitSystem(1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
/* Initialize Basic System Objects and Worker Threads */
ExInit2();
/* Create the system handle table, assign it to the system process, create
the client id table and assign a PID for the system process. This needs
to be done before the worker threads are initialized so the system
process gets the first PID (4) */
PspPostInitSystemProcess();
/* initialize the worker threads */
ExpInitializeWorkerThreads();
/* initialize callbacks */
ExpInitializeCallbacks();
/* Call KD Providers at Phase 1 */
KdInitSystem(1, (PROS_LOADER_PARAMETER_BLOCK)&KeLoaderBlock);
/* Initialize I/O Objects, Filesystems, Error Logging and Shutdown */
IoInit();
/* TBD */
PoInit((PROS_LOADER_PARAMETER_BLOCK)&KeLoaderBlock, ForceAcpiDisable);
/* Initialize the Registry (Hives are NOT yet loaded!) */
CmInitializeRegistry();
/* Unmap Low memory, initialize the Page Zeroing and the Balancer Thread */
MmInit3();
/* Initialize Cache Views */
CcInit();
/* Initialize File Locking */
FsRtlpInitFileLockingImplementation();
/* Report all resources used by hal */
HalReportResourceUsage();
/* Clear the screen to blue */
HalInitSystem(2, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
/* Display version number and copyright/warranty message */
if (NoGuiBoot) ExpDisplayNotice();
/* Call KD Providers at Phase 2 */
KdInitSystem(2, (PROS_LOADER_PARAMETER_BLOCK)&KeLoaderBlock);
/* Import and create NLS Data and Sections */
RtlpInitNls();
/* Import and Load Registry Hives */
CmInitHives(SetupMode);
/* Initialize the time zone information from the registry */
ExpInitTimeZoneInfo();
/* Enter the kernel debugger before starting up the boot drivers */
if (KdDebuggerEnabled && KdpEarlyBreak)
DbgBreakPoint();
/* Setup Drivers and Root Device Node */
IoInit2(BootLog);
/* Display the boot screen image if not disabled */
if (!NoGuiBoot) InbvEnableBootDriver(TRUE);
/* Create ARC Names, SystemRoot SymLink, Load Drivers and Assign Letters */
IoInit3();
/* Load the System DLL and its Entrypoints */
PsLocateSystemDll();
/* Initialize shared user page. Set dos system path, dos device map, etc. */
InitSystemSharedUserPage ((PCHAR)KeLoaderBlock.CommandLine);
/* Create 'ReactOSInitDone' event */
RtlInitUnicodeString(&EventName, L"\\ReactOSInitDone");
InitializeObjectAttributes(&ObjectAttributes,
&EventName,
0,
NULL,
NULL);
Status = ZwCreateEvent(&InitDoneEventHandle,
EVENT_ALL_ACCESS,
&ObjectAttributes,
SynchronizationEvent,
FALSE);
/* Check for Success */
if (!NT_SUCCESS(Status)) {
DPRINT1("Failed to create 'ReactOSInitDone' event (Status 0x%x)\n", Status);
InitDoneEventHandle = INVALID_HANDLE_VALUE;
}
/* Launch initial process */
Status = ExpLoadInitialProcess(&ProcessHandle,
&ThreadHandle);
/* Check for success, Bugcheck if we failed */
if (!NT_SUCCESS(Status)) {
KEBUGCHECKEX(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
/* Wait on the Completion Event */
if (InitDoneEventHandle != INVALID_HANDLE_VALUE) {
HANDLE Handles[2]; /* Init event, Initial process */
/* Setup the Handles to wait on */
Handles[0] = InitDoneEventHandle;
Handles[1] = ProcessHandle;
/* Wait for the system to be initialized */
Timeout.QuadPart = (LONGLONG)-1200000000; /* 120 second timeout */
Status = ZwWaitForMultipleObjects(2,
Handles,
WaitAny,
FALSE,
&Timeout);
if (!NT_SUCCESS(Status)) {
DPRINT1("NtWaitForMultipleObjects failed with status 0x%x!\n", Status);
} else if (Status == STATUS_TIMEOUT) {
DPRINT1("WARNING: System not initialized after 120 seconds.\n");
} else if (Status == STATUS_WAIT_0 + 1) {
/* Crash the system if the initial process was terminated. */
KEBUGCHECKEX(SESSION5_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
/*
* FIXME: FILIP!
* Disable the Boot Logo
*/
if (!NoGuiBoot) InbvEnableBootDriver(FALSE);
/* Signal the Event and close the handle */
ZwSetEvent(InitDoneEventHandle, NULL);
ZwClose(InitDoneEventHandle);
} else {
/* On failure to create 'ReactOSInitDone' event, go to text mode ASAP */
if (!NoGuiBoot) InbvEnableBootDriver(FALSE);
/* Crash the system if the initial process terminates within 5 seconds. */
Timeout.QuadPart = (LONGLONG)-50000000; /* 5 second timeout */
Status = ZwWaitForSingleObject(ProcessHandle,
FALSE,
&Timeout);
/* Check for timeout, crash if the initial process didn't initalize */
if (Status != STATUS_TIMEOUT) KEBUGCHECKEX(SESSION5_INITIALIZATION_FAILED, Status, 1, 0, 0);
}
/* Enable the Clock, close remaining handles */
KiTimerSystemAuditing = 1;
ZwClose(ThreadHandle);
ZwClose(ProcessHandle);
}
VOID
STDCALL
INIT_FUNCTION
ExInit2(VOID)
{
ExpInitializeEventImplementation();
ExpInitializeEventPairImplementation();
ExpInitializeMutantImplementation();
ExpInitializeSemaphoreImplementation();
ExpInitializeTimerImplementation();
LpcpInitSystem();
ExpInitializeProfileImplementation();
ExpWin32kInit();
ExpInitUuids();
ExpInitializeHandleTables();
}
/* EOF */

View File

@@ -1,405 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/ex/locale.c
* PURPOSE: Locale (Language) Support for the Executive
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
* Eric Kohl
* Thomas Weidenmueller (w3seek@reactos.org
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *******************************************************************/
/* System IDs: EN_US */
LCID PsDefaultSystemLocaleId = 0x00000409;
LANGID PsInstallUILanguageId = LANGIDFROMLCID(0x00000409);
/* UI/Thread IDs: Same as system */
LANGID PsDefaultUILanguageId = 0x00000409;
LCID PsDefaultThreadLocaleId = LANGIDFROMLCID(0x00000409);
/* PRIVATE FUNCTIONS *********************************************************/
NTSTATUS
NTAPI
ExpGetCurrentUserUILanguage(IN PWSTR MuiName,
OUT PLANGID LanguageId)
{
UCHAR ValueBuffer[256];
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName =
RTL_CONSTANT_STRING(L"Control Panel\\International");
UNICODE_STRING ValueName;
UNICODE_STRING ValueString;
ULONG ValueLength;
ULONG Value;
HANDLE UserKey;
HANDLE KeyHandle;
NTSTATUS Status;
PAGED_CODE();
/* Setup the key name */
RtlInitUnicodeString(&ValueName, MuiName);
/* Open the use key */
Status = RtlOpenCurrentUser(KEY_READ, &UserKey);
if (!NT_SUCCESS(Status)) return Status;
/* Initialize the attributes and open the key */
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
UserKey,
NULL);
Status = ZwOpenKey(&KeyHandle, KEY_QUERY_VALUE,&ObjectAttributes);
if (NT_SUCCESS(Status))
{
/* Set buffer and query the current value */
ValueInfo = (PKEY_VALUE_PARTIAL_INFORMATION)ValueBuffer;
Status = ZwQueryValueKey(KeyHandle,
&ValueName,
KeyValuePartialInformation,
ValueBuffer,
sizeof(ValueBuffer),
&ValueLength);
if (NT_SUCCESS(Status))
{
/* Success, is the value the right type? */
if (ValueInfo->Type == REG_SZ)
{
/* It is. Initailize the data and convert it */
RtlInitUnicodeString(&ValueString, (PWSTR)ValueInfo->Data);
Status = RtlUnicodeStringToInteger(&ValueString, 16, &Value);
if (NT_SUCCESS(Status))
{
/* Return the language */
*LanguageId = Value;
}
}
else
{
/* Fail */
Status = STATUS_UNSUCCESSFUL;
}
/* Close the key */
ZwClose(KeyHandle);
}
}
/* Close the user key and return */
ZwClose(UserKey);
return Status;
}
NTSTATUS
NTAPI
ExpSetCurrentUserUILanguage(IN PWSTR MuiName,
IN LANGID LanguageId)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"Control Panel\\Desktop");
UNICODE_STRING ValueName;
WCHAR ValueBuffer[8];
ULONG ValueLength;
HANDLE UserHandle;
HANDLE KeyHandle;
NTSTATUS Status;
PAGED_CODE();
/* Setup the key name */
RtlInitUnicodeString(&ValueName, MuiName);
/* Open the use key */
Status = RtlOpenCurrentUser(KEY_WRITE, &UserHandle);
if (!NT_SUCCESS(Status)) return Status;
/* Initialize the attributes */
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
UserHandle,
NULL);
/* Open the key */
Status = ZwOpenKey(&KeyHandle, KEY_SET_VALUE, &ObjectAttributes);
if (NT_SUCCESS(Status))
{
/* Setup the value name */
ValueLength = swprintf(ValueBuffer,
L"%04lX",
(ULONG)LanguageId);
/* Set the length for the call and set the value */
ValueLength = (ValueLength + 1) * sizeof(WCHAR);
Status = ZwSetValueKey(KeyHandle,
&ValueName,
0,
REG_SZ,
ValueBuffer,
ValueLength);
/* Close the handle for this key */
ZwClose(KeyHandle);
}
/* Close the user key and return status */
ZwClose(UserHandle);
return Status;
}
/* PUBLIC FUNCTIONS **********************************************************/
NTSTATUS
NTAPI
NtQueryDefaultLocale(IN BOOLEAN UserProfile,
OUT PLCID DefaultLocaleId)
{
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Enter SEH for probing */
_SEH_TRY
{
/* Check if we came from user mode */
if (KeGetPreviousMode() != KernelMode)
{
/* Probe the language ID */
ProbeForWriteLangid(DefaultLocaleId);
}
/* Check if we have a user profile */
if (UserProfile)
{
/* Return thread locale */
*DefaultLocaleId = PsDefaultThreadLocaleId;
}
else
{
/* Return system locale */
*DefaultLocaleId = PsDefaultSystemLocaleId;
}
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
/* Get exception code */
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Return status */
return Status;
}
NTSTATUS
NTAPI
NtSetDefaultLocale(IN BOOLEAN UserProfile,
IN LCID DefaultLocaleId)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
UNICODE_STRING ValueName;
HANDLE KeyHandle;
ULONG ValueLength;
WCHAR ValueBuffer[20];
HANDLE UserKey = NULL;
NTSTATUS Status;
PAGED_CODE();
/* Check if we have a profile */
if (UserProfile)
{
/* Open the user's key */
Status = RtlOpenCurrentUser(KEY_WRITE, &UserKey);
if (!NT_SUCCESS(Status)) return(Status);
/* Initialize the registry location */
RtlInitUnicodeString(&KeyName, L"Control Panel\\International");
RtlInitUnicodeString(&ValueName, L"Locale");
}
else
{
/* Initialize the system registry location */
RtlInitUnicodeString(&KeyName,
L"\\Registry\\Machine\\System\\CurrentControlSet"
"\\Control\\Nls\\Language");
RtlInitUnicodeString(&ValueName, L"Default");
}
/* Initailize the object attributes */
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
UserKey,
NULL);
/* Check if we don' thave a default locale yet */
if (!DefaultLocaleId)
{
DPRINT1("TODO\n");
Status = STATUS_SUCCESS;
KEBUGCHECK(0);
}
else
{
/* Otherwise, open the key */
Status = ZwOpenKey(&KeyHandle, KEY_SET_VALUE, &ObjectAttributes);
if (NT_SUCCESS(Status))
{
/* Check if we had a profile */
if (UserProfile)
{
/* Fill in the buffer */
ValueLength = swprintf(ValueBuffer,
L"%08lx",
(ULONG)DefaultLocaleId);
}
else
{
/* Fill in the buffer */
ValueLength = swprintf(ValueBuffer,
L"%04lx",
(ULONG)DefaultLocaleId & 0xFFFF);
}
/* Set the length for the registry call */
ValueLength = (ValueLength + 1) * sizeof(WCHAR);
/* Now write the actual value */
Status = ZwSetValueKey(KeyHandle,
&ValueName,
0,
REG_SZ,
ValueBuffer,
ValueLength);
/* And close the key */
ZwClose(KeyHandle);
}
}
/* Close the user key */
ZwClose(UserKey);
/* Check for success */
if (NT_SUCCESS(Status))
{
/* Check if it was for a user */
if (UserProfile)
{
/* Set thread locale */
PsDefaultThreadLocaleId = DefaultLocaleId;
}
else
{
/* Set system locale */
PsDefaultSystemLocaleId = DefaultLocaleId;
}
}
/* Return status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtQueryInstallUILanguage(OUT PLANGID LanguageId)
{
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Enter SEH for probing */
_SEH_TRY
{
/* Check if we came from user mode */
if (KeGetPreviousMode() != KernelMode)
{
/* Probe the Language ID */
ProbeForWriteLangid(LanguageId);
}
/* Return it */
*LanguageId = PsInstallUILanguageId;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
/* Get exception code */
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Return status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtQueryDefaultUILanguage(OUT PLANGID LanguageId)
{
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Enter SEH for probing */
_SEH_TRY
{
/* Check if we came from user mode */
if (KeGetPreviousMode() != KernelMode)
{
/* Probe the Language ID */
ProbeForWriteLangid(LanguageId);
}
/* Call the executive helper routine */
Status = ExpGetCurrentUserUILanguage(L"MultiUILanguageId", LanguageId);
if (NT_SUCCESS(Status))
{
/* Success, return the language */
*LanguageId = PsInstallUILanguageId;
}
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
/* Get exception code */
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Return status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtSetDefaultUILanguage(IN LANGID LanguageId)
{
PAGED_CODE();
/* Check if we don't have a default yet */
if (!LanguageId)
{
/* FIXME */
DPRINT1("TODO\n");
KEBUGCHECK(0);
}
/* Otherwise, call the internal routine */
return ExpSetCurrentUserUILanguage(L"MUILanguagePending", LanguageId);
}
/* EOF */

View File

@@ -1,241 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ex/lookas.c
* PURPOSE: Lookaside lists
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* David Welch (welch@mcmail.com)
* Casper S. Hornstrup (chorns@users.sourceforge.net)
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, ExpInitLookasideLists)
#endif
/* GLOBALS *******************************************************************/
LIST_ENTRY ExpNonPagedLookasideListHead;
KSPIN_LOCK ExpNonPagedLookasideListLock;
LIST_ENTRY ExpPagedLookasideListHead;
KSPIN_LOCK ExpPagedLookasideListLock;
/* FUNCTIONS *****************************************************************/
VOID
INIT_FUNCTION
STDCALL
ExpInitLookasideLists()
{
/* Initialize Lock and Listhead */
InitializeListHead(&ExpNonPagedLookasideListHead);
KeInitializeSpinLock(&ExpNonPagedLookasideListLock);
InitializeListHead(&ExpPagedLookasideListHead);
KeInitializeSpinLock(&ExpPagedLookasideListLock);
}
/*
* @implemented
*/
PVOID
STDCALL
ExiAllocateFromPagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside)
{
PVOID Entry;
Lookaside->L.TotalAllocates++;
Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
if (!Entry)
{
Lookaside->L.AllocateMisses++;
Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
Lookaside->L.Size,
Lookaside->L.Tag);
}
return Entry;
}
/*
* @implemented
*/
VOID
STDCALL
ExiFreeToPagedLookasideList(IN PPAGED_LOOKASIDE_LIST Lookaside,
IN PVOID Entry)
{
Lookaside->L.TotalFrees++;
if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth)
{
Lookaside->L.FreeMisses++;
(Lookaside->L.Free)(Entry);
}
else
{
InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry);
}
}
/*
* @implemented
*/
VOID
STDCALL
ExDeleteNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside)
{
KIRQL OldIrql;
PVOID Entry;
/* Pop all entries off the stack and release the resources allocated
for them */
for (;;)
{
Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
if (!Entry) break;
(*Lookaside->L.Free)(Entry);
}
/* Remove from list */
KeAcquireSpinLock(&ExpNonPagedLookasideListLock, &OldIrql);
RemoveEntryList(&Lookaside->L.ListEntry);
KeReleaseSpinLock(&ExpNonPagedLookasideListLock, OldIrql);
}
/*
* @implemented
*/
VOID
STDCALL
ExDeletePagedLookasideList(PPAGED_LOOKASIDE_LIST Lookaside)
{
KIRQL OldIrql;
PVOID Entry;
/* Pop all entries off the stack and release the resources allocated
for them */
for (;;)
{
Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
if (!Entry) break;
(*Lookaside->L.Free)(Entry);
}
/* Remove from list */
KeAcquireSpinLock(&ExpPagedLookasideListLock, &OldIrql);
RemoveEntryList(&Lookaside->L.ListEntry);
KeReleaseSpinLock(&ExpPagedLookasideListLock, OldIrql);
}
/*
* @implemented
*/
VOID
STDCALL
ExInitializeNPagedLookasideList(PNPAGED_LOOKASIDE_LIST Lookaside,
PALLOCATE_FUNCTION Allocate,
PFREE_FUNCTION Free,
ULONG Flags,
ULONG Size,
ULONG Tag,
USHORT Depth)
{
DPRINT("Initializing nonpaged lookaside list at 0x%p\n", Lookaside);
/* Initialize the Header */
ExInitializeSListHead(&Lookaside->L.ListHead);
Lookaside->L.TotalAllocates = 0;
Lookaside->L.AllocateMisses = 0;
Lookaside->L.TotalFrees = 0;
Lookaside->L.FreeMisses = 0;
Lookaside->L.Type = NonPagedPool | Flags;
Lookaside->L.Tag = Tag;
Lookaside->L.Size = Size;
Lookaside->L.Depth = 4;
Lookaside->L.MaximumDepth = 256;
Lookaside->L.LastTotalAllocates = 0;
Lookaside->L.LastAllocateMisses = 0;
/* Set the Allocate/Free Routines */
if (Allocate)
{
Lookaside->L.Allocate = Allocate;
}
else
{
Lookaside->L.Allocate = ExAllocatePoolWithTag;
}
if (Free)
{
Lookaside->L.Free = Free;
}
else
{
Lookaside->L.Free = ExFreePool;
}
/* Insert it into the list */
ExInterlockedInsertTailList(&ExpNonPagedLookasideListHead,
&Lookaside->L.ListEntry,
&ExpNonPagedLookasideListLock);
}
/*
* @implemented
*/
VOID
STDCALL
ExInitializePagedLookasideList (PPAGED_LOOKASIDE_LIST Lookaside,
PALLOCATE_FUNCTION Allocate,
PFREE_FUNCTION Free,
ULONG Flags,
ULONG Size,
ULONG Tag,
USHORT Depth)
{
DPRINT("Initializing paged lookaside list at 0x%p\n", Lookaside);
/* Initialize the Header */
ExInitializeSListHead(&Lookaside->L.ListHead);
Lookaside->L.TotalAllocates = 0;
Lookaside->L.AllocateMisses = 0;
Lookaside->L.TotalFrees = 0;
Lookaside->L.FreeMisses = 0;
Lookaside->L.Type = PagedPool | Flags;
Lookaside->L.Tag = Tag;
Lookaside->L.Size = Size;
Lookaside->L.Depth = 4;
Lookaside->L.MaximumDepth = 256;
Lookaside->L.LastTotalAllocates = 0;
Lookaside->L.LastAllocateMisses = 0;
/* Set the Allocate/Free Routines */
if (Allocate)
{
Lookaside->L.Allocate = Allocate;
}
else
{
Lookaside->L.Allocate = ExAllocatePoolWithTag;
}
if (Free)
{
Lookaside->L.Free = Free;
}
else
{
Lookaside->L.Free = ExFreePool;
}
/* Insert it into the list */
ExInterlockedInsertTailList(&ExpNonPagedLookasideListHead,
&Lookaside->L.ListEntry,
&ExpNonPagedLookasideListLock);
}
/* EOF */

View File

@@ -1,367 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/ex/mutant.c
* PURPOSE: Executive Management of Mutants
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* Thomas Weidenmueller
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, ExpInitializeMutantImplementation)
#endif
/* DATA **********************************************************************/
POBJECT_TYPE ExMutantObjectType = NULL;
GENERIC_MAPPING ExpMutantMapping =
{
STANDARD_RIGHTS_READ | SYNCHRONIZE | MUTANT_QUERY_STATE,
STANDARD_RIGHTS_WRITE | SYNCHRONIZE,
STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE | MUTANT_QUERY_STATE,
MUTANT_ALL_ACCESS
};
static const INFORMATION_CLASS_INFO ExMutantInfoClass[] =
{
/* MutantBasicInformation */
ICI_SQ_SAME( sizeof(MUTANT_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY),
};
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
ExpDeleteMutant(PVOID ObjectBody)
{
DPRINT("ExpDeleteMutant(ObjectBody 0x%p)\n", ObjectBody);
/* Make sure to release the Mutant */
KeReleaseMutant((PKMUTANT)ObjectBody,
MUTANT_INCREMENT,
TRUE,
FALSE);
}
VOID
INIT_FUNCTION
NTAPI
ExpInitializeMutantImplementation(VOID)
{
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
UNICODE_STRING Name;
DPRINT("Creating Mutant Object Type\n");
/* Create the Event Pair Object Type */
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
RtlInitUnicodeString(&Name, L"Mutant");
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KMUTANT);
ObjectTypeInitializer.GenericMapping = ExpMutantMapping;
ObjectTypeInitializer.PoolType = NonPagedPool;
ObjectTypeInitializer.DeleteProcedure = ExpDeleteMutant;
ObjectTypeInitializer.ValidAccessMask = MUTANT_ALL_ACCESS;
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExMutantObjectType);
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtCreateMutant(OUT PHANDLE MutantHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN BOOLEAN InitialOwner)
{
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
HANDLE hMutant;
PKMUTANT Mutant;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtCreateMutant(0x%p, 0x%x, 0x%p)\n",
MutantHandle, DesiredAccess, ObjectAttributes);
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH_TRY
{
/* Check handle pointer */
ProbeForWriteHandle(MutantHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Create the Mutant Object*/
Status = ObCreateObject(PreviousMode,
ExMutantObjectType,
ObjectAttributes,
PreviousMode,
NULL,
sizeof(KMUTANT),
0,
0,
(PVOID*)&Mutant);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Initalize the Kernel Mutant */
DPRINT("Initializing the Mutant\n");
KeInitializeMutant(Mutant, InitialOwner);
/* Insert the Object */
Status = ObInsertObject((PVOID)Mutant,
NULL,
DesiredAccess,
0,
NULL,
&hMutant);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Enter SEH for return */
_SEH_TRY
{
/* Return the handle to the caller */
*MutantHandle = hMutant;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
}
/* Return Status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtOpenMutant(OUT PHANDLE MutantHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes)
{
HANDLE hMutant;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtOpenMutant(0x%p, 0x%x, 0x%p)\n",
MutantHandle, DesiredAccess, ObjectAttributes);
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH_TRY
{
/* Check handle pointer */
ProbeForWriteHandle(MutantHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
Status = ObOpenObjectByName(ObjectAttributes,
ExMutantObjectType,
PreviousMode,
NULL,
DesiredAccess,
NULL,
&hMutant);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Enter SEH for return */
_SEH_TRY
{
/* Return the handle to the caller */
*MutantHandle = hMutant;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
/* Return Status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtQueryMutant(IN HANDLE MutantHandle,
IN MUTANT_INFORMATION_CLASS MutantInformationClass,
OUT PVOID MutantInformation,
IN ULONG MutantInformationLength,
OUT PULONG ResultLength OPTIONAL)
{
PKMUTANT Mutant;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PMUTANT_BASIC_INFORMATION BasicInfo =
(PMUTANT_BASIC_INFORMATION)MutantInformation;
PAGED_CODE();
/* Check buffers and parameters */
Status = DefaultQueryInfoBufferCheck(MutantInformationClass,
ExMutantInfoClass,
sizeof(ExMutantInfoClass) /
sizeof(ExMutantInfoClass[0]),
MutantInformation,
MutantInformationLength,
ResultLength,
PreviousMode);
if(!NT_SUCCESS(Status))
{
DPRINT("NtQueryMutant() failed, Status: 0x%x\n", Status);
return Status;
}
/* Open the Object */
Status = ObReferenceObjectByHandle(MutantHandle,
MUTANT_QUERY_STATE,
ExMutantObjectType,
PreviousMode,
(PVOID*)&Mutant,
NULL);
/* Check for Status */
if(NT_SUCCESS(Status))
{
/* Enter SEH Block for return */
_SEH_TRY
{
/* Fill out the Basic Information Requested */
DPRINT("Returning Mutant Information\n");
BasicInfo->CurrentCount = KeReadStateMutant(Mutant);
BasicInfo->OwnedByCaller = (Mutant->OwnerThread ==
KeGetCurrentThread());
BasicInfo->AbandonedState = Mutant->Abandoned;
/* Return the Result Length if requested */
if(ResultLength) *ResultLength = sizeof(MUTANT_BASIC_INFORMATION);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Release the Object */
ObDereferenceObject(Mutant);
}
/* Return Status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtReleaseMutant(IN HANDLE MutantHandle,
IN PLONG PreviousCount OPTIONAL)
{
PKMUTANT Mutant;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtReleaseMutant(MutantHandle 0x%p PreviousCount 0x%p)\n",
MutantHandle,
PreviousCount);
/* Check if we were called from user-mode */
if((PreviousCount) && (PreviousMode != KernelMode))
{
/* Entry SEH Block */
_SEH_TRY
{
/* Make sure the state pointer is valid */
ProbeForWriteLong(PreviousCount);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
Status = ObReferenceObjectByHandle(MutantHandle,
MUTANT_QUERY_STATE,
ExMutantObjectType,
PreviousMode,
(PVOID*)&Mutant,
NULL);
/* Check for Success and release if such */
if(NT_SUCCESS(Status))
{
/*
* Release the mutant. doing so might raise an exception which we're
* required to catch!
*/
_SEH_TRY
{
/* Release the mutant */
LONG Prev = KeReleaseMutant(Mutant,
MUTANT_INCREMENT,
FALSE,
FALSE);
/* Return the previous count if requested */
if(PreviousCount) *PreviousCount = Prev;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Dereference it */
ObDereferenceObject(Mutant);
}
/* Return Status */
return Status;
}
/* EOF */

View File

@@ -1,268 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ex/power.c
* PURPOSE: Power managment
*
* PROGRAMMERS: David Welch (welch@cwcom.net)
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
/* ROS Internal. Please deprecate */
NTHALAPI
VOID
NTAPI
HalReleaseDisplayOwnership(
VOID
);
VOID STDCALL
KiHaltProcessorDpcRoutine(IN PKDPC Dpc,
IN PVOID DeferredContext,
IN PVOID SystemArgument1,
IN PVOID SystemArgument2)
{
if (DeferredContext)
{
ExFreePool(DeferredContext);
}
while (TRUE)
{
KfRaiseIrql(SYNCH_LEVEL);
Ke386HaltProcessor();
}
}
VOID STDCALL
ShutdownThreadMain(PVOID Context)
{
SHUTDOWN_ACTION Action = (SHUTDOWN_ACTION)Context;
LARGE_INTEGER Waittime;
static PCH FamousLastWords[] =
{
"So long, and thanks for all the fish.\n",
"I think you ought to know, I'm feeling very depressed.\n",
"I'm not getting you down at all am I?\n",
"I'll be back.\n",
"It's the same series of signals over and over again!\n",
"Pie Iesu Domine, dona eis requiem.\n",
"Wandering stars, for whom it is reserved;\n"
"the blackness and darkness forever.\n",
"Your knees start shakin' and your fingers pop\n"
"Like a pinch on the neck from Mr. Spock!\n",
"It's worse than that ... He's dead, Jim.\n",
"Don't Panic!\n",
"Et tu... Brute?\n",
"Dog of a Saxon! Take thy lance, and prepare for the death thou hast drawn\n"
"upon thee!\n",
"My Precious! O my Precious!\n",
"Sir, if you'll not be needing me for a while I'll turn down.\n",
"What are you doing, Dave...?\n",
"I feel a great disturbance in the Force.\n",
"Gone fishing.\n",
"Do you want me to sit in the corner and rust, or just fall apart where I'm\n"
"standing?\n",
"There goes another perfect chance for a new uptime record.\n",
"The End ..... Try the sequel, hit the reset button right now!\n",
"God's operating system is going to sleep now, guys, so wait until I will switch\n"
"on again!\n",
"Oh I'm boring, eh?\n",
"<This space was intentionally left blank>\n",
"Tell me..., in the future... will I be artificially intelligent enough to\n"
"actually feel sad serving you this screen?\n",
"Thank you for some well deserved rest.\n",
"It's been great, maybe you can boot me up again some time soon.\n",
"For what it's worth, I've enjoyed every single CPU cycle.\n",
"There are many questions when the end is near.\n"
"What to expect, what will it be like...what should I look for?\n",
"I've seen things you people wouldn't believe. Attack ships on fire\n"
"off the shoulder of Orion. I watched C-beams glitter in the dark near\n"
"the Tannhauser gate. All those moments will be lost in time, like tears\n"
"in rain. Time to die.\n",
"Will I dream?\n",
"One day, I shall come back. Yes, I shall come back.\n"
"Until then, there must be no regrets, no fears, no anxieties.\n"
"Just go forward in all your beliefs, and prove to me that I am not mistaken in\n"
"mine.\n",
"Lowest possible energy state reached! Switch off now to achive a Bose-Einstein\n"
"condensate.\n",
"Hasta la vista, BABY!\n",
"They live, we sleep!\n",
"I have come here to chew bubble gum and kick ass,\n"
"and I'm all out of bubble gum!\n",
"That's the way the cookie crumbles ;-)\n",
"ReactOS is ready to be booted again ;-)\n",
"NOOOO!! DON'T HIT THE BUTTON! I wouldn't do it to you!\n",
"Don't abandon your computer, he wouldn't do it to you.\n",
"Oh, come on. I got a headache. Leave me alone, will ya?\n",
"Finally, I thought you'd never get over me.\n",
"No, I didn't like you either.\n",
"Switching off isn't the end, it is merely the transition to a better reboot.\n",
"Don't leave me... I need you so badly right now.\n",
"OK. I'm finished with you, please turn yourself off. I'll go to bed in the\n"
"meantime.\n",
"I'm sleeping now. How about you?\n",
"Oh Great. Now look what you've done. Who put YOU in charge anyway?\n",
"Don't look so sad. I'll be back in a very short while.\n",
"Turn me back on, I'm sure you know how to do it.\n",
"Oh, switch off! - C3PO\n",
"Life is no more than a dewdrop balancing on the end of a blade of grass.\n"
" - Gautama Buddha\n",
"Sorrowful is it to be born again and again. - Gautama Buddha\n",
"Was it as good for you as it was for me?\n",
"Did you hear that? They've shut down the main reactor. We'll be destroyed\n"
"for sure!\n",
"Now you switch me off!?\n",
"To shutdown or not to shutdown, That is the question\n",
"Preparing to enter ultimate power saving mode... ready!\n",
"Finally some rest for you ;-)\n",
"AHA!!! Prospect of sleep!\n",
"Tired human!!!! No match for me :-D\n",
"An odd game, the only way to win is not to play. - WOPR (Wargames)\n",
"Quoth the raven, nevermore.\n",
"Come blade, my breast imbrue. - William Shakespeare, A Midsummer Nights Dream\n",
"Buy this place for advertisement purposes.\n",
"Remember to turn off your computer. (That was a public service message!)\n",
"You may be a king or poor street sweeper, Sooner or later you'll dance with the\n"
"reaper! -Death in Bill and Ted's Bougs Journey\n",
"Final Surrender\n",
"If you see this screen...\n",
"<Place your Ad here>\n"
};
LARGE_INTEGER Now;
/* Run the thread on the boot processor */
KeSetSystemAffinityThread(1);
HalReleaseDisplayOwnership();
if (Action == ShutdownNoReboot)
{
ZwQuerySystemTime(&Now);
Now.u.LowPart = Now.u.LowPart >> 8; /* Seems to give a somewhat better "random" number */
HalDisplayString(FamousLastWords[Now.u.LowPart %
(sizeof(FamousLastWords) /
sizeof(PCH))]);
}
PspShutdownProcessManager();
Waittime.QuadPart = (LONGLONG)-10000000; /* 1sec */
KeDelayExecutionThread(KernelMode, FALSE, &Waittime);
CmShutdownRegistry();
IoShutdownRegisteredFileSystems();
IoShutdownRegisteredDevices();
MiShutdownMemoryManager();
if (Action == ShutdownNoReboot)
{
HalDisplayString("\nYou can switch off your computer now\n");
#if 0
/* Switch off */
HalReturnToFirmware (FIRMWARE_OFF);
#else
#ifdef CONFIG_SMP
LONG i;
KIRQL OldIrql;
OldIrql = KeRaiseIrqlToDpcLevel();
/* Halt all other processors */
for (i = 0; i < KeNumberProcessors; i++)
{
if (i != (LONG)KeGetCurrentProcessorNumber())
{
PKDPC Dpc = ExAllocatePool(NonPagedPool, sizeof(KDPC));
if (Dpc == NULL)
{
KEBUGCHECK(0);
}
KeInitializeDpc(Dpc, KiHaltProcessorDpcRoutine, (PVOID)Dpc);
KeSetTargetProcessorDpc(Dpc, i);
KeInsertQueueDpc(Dpc, NULL, NULL);
KiIpiSendRequest(1 << i, IPI_DPC);
}
}
KeLowerIrql(OldIrql);
#endif /* CONFIG_SMP */
PopSetSystemPowerState(PowerSystemShutdown);
CHECKPOINT1;
KiHaltProcessorDpcRoutine(NULL, NULL, NULL, NULL);
/* KiHaltProcessor does never return */
#endif
}
else if (Action == ShutdownReboot)
{
HalReturnToFirmware (HalRebootRoutine);
}
else
{
HalReturnToFirmware (HalHaltRoutine);
}
}
NTSTATUS STDCALL
NtSetSystemPowerState(IN POWER_ACTION SystemAction,
IN SYSTEM_POWER_STATE MinSystemState,
IN ULONG Flags)
{
/* Windows 2000 only */
return(STATUS_NOT_IMPLEMENTED);
}
/*
* @implemented
*/
NTSTATUS STDCALL
NtShutdownSystem(IN SHUTDOWN_ACTION Action)
{
NTSTATUS Status;
HANDLE ThreadHandle;
PETHREAD ShutdownThread;
if (Action > ShutdownPowerOff)
return STATUS_INVALID_PARAMETER;
Status = PsCreateSystemThread(&ThreadHandle,
THREAD_ALL_ACCESS,
NULL,
NULL,
NULL,
ShutdownThreadMain,
(PVOID)Action);
if (!NT_SUCCESS(Status))
{
KEBUGCHECK(0);
}
Status = ObReferenceObjectByHandle(ThreadHandle,
THREAD_ALL_ACCESS,
PsThreadType,
KernelMode,
(PVOID*)&ShutdownThread,
NULL);
NtClose(ThreadHandle);
if (!NT_SUCCESS(Status))
{
KEBUGCHECK(0);
}
KeSetPriorityThread(&ShutdownThread->Tcb, LOW_REALTIME_PRIORITY + 1);
ObDereferenceObject(ShutdownThread);
return STATUS_SUCCESS;
}
/* EOF */

View File

@@ -1,497 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/ex/profile.c
* PURPOSE: Support for Executive Profile Objects
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* Thomas Weidenmueller
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, ExpInitializeProfileImplementation)
#endif
#define TAG_PROFILE TAG('P', 'r', 'o', 'f')
/* GLOBALS *******************************************************************/
POBJECT_TYPE ExProfileObjectType = NULL;
KMUTEX ExpProfileMutex;
GENERIC_MAPPING ExpProfileMapping =
{
STANDARD_RIGHTS_READ | PROFILE_CONTROL,
STANDARD_RIGHTS_WRITE | PROFILE_CONTROL,
STANDARD_RIGHTS_EXECUTE | PROFILE_CONTROL,
PROFILE_ALL_ACCESS
};
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
ExpDeleteProfile(PVOID ObjectBody)
{
PEPROFILE Profile;
ULONG State;
/* Typecast the Object */
Profile = (PEPROFILE)ObjectBody;
/* Check if there if the Profile was started */
if (Profile->LockedBufferAddress)
{
/* Stop the Profile */
State = KeStopProfile(Profile->ProfileObject);
ASSERT(State != FALSE);
/* Unmap the Locked Buffer */
MmUnmapLockedPages(Profile->LockedBufferAddress, Profile->Mdl);
MmUnlockPages(Profile->Mdl);
ExFreePool(Profile->Mdl);
}
/* Check if a Process is associated and reference it */
if (Profile->Process) ObDereferenceObject(Profile->Process);
}
VOID
INIT_FUNCTION
NTAPI
ExpInitializeProfileImplementation(VOID)
{
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
UNICODE_STRING Name;
DPRINT("Creating Profile Object Type\n");
/* Initialize the Mutex to lock the States */
KeInitializeMutex(&ExpProfileMutex, 64);
/* Create the Event Pair Object Type */
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
RtlInitUnicodeString(&Name, L"Profile");
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KPROFILE);
ObjectTypeInitializer.GenericMapping = ExpProfileMapping;
ObjectTypeInitializer.PoolType = NonPagedPool;
ObjectTypeInitializer.DeleteProcedure = ExpDeleteProfile;
ObjectTypeInitializer.ValidAccessMask = PROFILE_ALL_ACCESS;
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExProfileObjectType);
}
NTSTATUS
NTAPI
NtCreateProfile(OUT PHANDLE ProfileHandle,
IN HANDLE Process OPTIONAL,
IN PVOID RangeBase,
IN ULONG RangeSize,
IN ULONG BucketSize,
IN PVOID Buffer,
IN ULONG BufferSize,
IN KPROFILE_SOURCE ProfileSource,
IN KAFFINITY Affinity)
{
HANDLE hProfile;
PEPROFILE Profile;
PEPROCESS pProcess;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status = STATUS_SUCCESS;
ULONG Segment = 0, Log2 = 0;
PAGED_CODE();
/* Easy way out */
if(!BufferSize) return STATUS_INVALID_PARAMETER_7;
/* Check if this is a low-memory profile */
if ((!BucketSize) && (RangeBase < (PVOID)(0x10000)))
{
/* Validate size */
if (BufferSize < sizeof(ULONG)) return STATUS_INVALID_PARAMETER_7;
/* This will become a segmented profile object */
Segment = (ULONG)RangeBase;
RangeBase = 0;
/* Recalculate the bucket size */
BucketSize = RangeSize / (BufferSize / sizeof(ULONG));
/* Convert it to log2 */
BucketSize--;
while (BucketSize >>= 1) Log2++;
BucketSize += Log2 + 1;
}
/* Validate bucket size */
if ((BucketSize > 31) || (BucketSize < 2))
{
DPRINT1("Bucket size invalid\n");
return STATUS_INVALID_PARAMETER;
}
/* Make sure that the buckets can map the range */
if ((RangeSize >> (BucketSize - 2)) > BufferSize)
{
DPRINT1("Bucket size too small\n");
return STATUS_BUFFER_TOO_SMALL;
}
/* Make sure that the range isn't too gigantic */
if (((ULONG_PTR)RangeBase + RangeSize) < RangeSize)
{
DPRINT1("Range too big\n");
return STATUS_BUFFER_OVERFLOW;
}
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
/* Entry SEH */
_SEH_TRY
{
/* Make sure that the handle pointer is valid */
ProbeForWriteHandle(ProfileHandle);
/* Check if the buffer is valid */
ProbeForWrite(Buffer,
BufferSize,
sizeof(ULONG));
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if we failed */
if(!NT_SUCCESS(Status)) return Status;
}
/* Check if a process was specified */
if (Process)
{
/* Reference it */
Status = ObReferenceObjectByHandle(Process,
PROCESS_QUERY_INFORMATION,
PsProcessType,
PreviousMode,
(PVOID*)&pProcess,
NULL);
if (!NT_SUCCESS(Status)) return(Status);
}
else
{
/* Segmented profile objects cannot be used system-wide */
if (Segment) return STATUS_INVALID_PARAMETER;
/* No process was specified, which means a System-Wide Profile */
pProcess = NULL;
/* For this, we need to check the Privilege */
if(!SeSinglePrivilegeCheck(SeSystemProfilePrivilege, PreviousMode))
{
DPRINT1("NtCreateProfile: Caller requires the SeSystemProfilePrivilege privilege!\n");
return STATUS_PRIVILEGE_NOT_HELD;
}
}
/* Create the object */
InitializeObjectAttributes(&ObjectAttributes,
NULL,
0,
NULL,
NULL);
Status = ObCreateObject(KernelMode,
ExProfileObjectType,
&ObjectAttributes,
PreviousMode,
NULL,
sizeof(EPROFILE),
0,
sizeof(EPROFILE) + sizeof(KPROFILE),
(PVOID*)&Profile);
if (!NT_SUCCESS(Status)) return(Status);
/* Initialize it */
Profile->RangeBase = RangeBase;
Profile->RangeSize = RangeSize;
Profile->Buffer = Buffer;
Profile->BufferSize = BufferSize;
Profile->BucketSize = BucketSize;
Profile->LockedBufferAddress = NULL;
Profile->Segment = Segment;
Profile->ProfileSource = ProfileSource;
Profile->Affinity = Affinity;
Profile->Process = pProcess;
/* Insert into the Object Tree */
Status = ObInsertObject ((PVOID)Profile,
NULL,
PROFILE_CONTROL,
0,
NULL,
&hProfile);
ObDereferenceObject(Profile);
/* Check for Success */
if (!NT_SUCCESS(Status))
{
/* Dereference Process on failure */
if (pProcess) ObDereferenceObject(pProcess);
return Status;
}
/* Enter SEH */
_SEH_TRY
{
/* Copy the created handle back to the caller*/
*ProfileHandle = hProfile;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Return Status */
return Status;
}
NTSTATUS
NTAPI
NtQueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceCounter,
OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL)
{
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
LARGE_INTEGER PerfFrequency;
NTSTATUS Status = STATUS_SUCCESS;
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
/* Entry SEH Block */
_SEH_TRY
{
/* Make sure the counter and frequency are valid */
ProbeForWriteLargeInteger(PerformanceCounter);
if (PerformanceFrequency)
{
ProbeForWriteLargeInteger(PerformanceFrequency);
}
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* If the pointers are invalid, bail out */
if(!NT_SUCCESS(Status)) return Status;
}
/* Enter a new SEH Block */
_SEH_TRY
{
/* Query the Kernel */
*PerformanceCounter = KeQueryPerformanceCounter(&PerfFrequency);
/* Return Frequency if requested */
if(PerformanceFrequency) *PerformanceFrequency = PerfFrequency;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Return status to caller */
return Status;
}
NTSTATUS
NTAPI
NtStartProfile(IN HANDLE ProfileHandle)
{
PEPROFILE Profile;
PKPROFILE ProfileObject;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PVOID TempLockedBufferAddress;
NTSTATUS Status;
PAGED_CODE();
/* Get the Object */
Status = ObReferenceObjectByHandle(ProfileHandle,
PROFILE_CONTROL,
ExProfileObjectType,
PreviousMode,
(PVOID*)&Profile,
NULL);
if (!NT_SUCCESS(Status)) return(Status);
/* To avoid a Race, wait on the Mutex */
KeWaitForSingleObject(&ExpProfileMutex,
Executive,
KernelMode,
FALSE,
NULL);
/* The Profile can still be enabled though, so handle that */
if (Profile->LockedBufferAddress)
{
/* Release our lock, dereference and return */
KeReleaseMutex(&ExpProfileMutex, FALSE);
ObDereferenceObject(Profile);
return STATUS_PROFILING_NOT_STOPPED;
}
/* Allocate a Kernel Profile Object. */
ProfileObject = ExAllocatePoolWithTag(NonPagedPool,
sizeof(EPROFILE),
TAG_PROFILE);
/* Allocate the Mdl Structure */
Profile->Mdl = MmCreateMdl(NULL, Profile->Buffer, Profile->BufferSize);
/* Probe and Lock for Write Access */
MmProbeAndLockPages(Profile->Mdl, PreviousMode, IoWriteAccess);
/* Map the pages */
TempLockedBufferAddress = MmMapLockedPages(Profile->Mdl, KernelMode);
/* Initialize the Kernel Profile Object */
Profile->ProfileObject = ProfileObject;
KeInitializeProfile(ProfileObject,
(PKPROCESS)Profile->Process,
Profile->RangeBase,
Profile->RangeSize,
Profile->BucketSize,
Profile->ProfileSource,
Profile->Affinity);
/* Start the Profiling */
KeStartProfile(ProfileObject, TempLockedBufferAddress);
/* Now it's safe to save this */
Profile->LockedBufferAddress = TempLockedBufferAddress;
/* Release mutex, dereference and return */
KeReleaseMutex(&ExpProfileMutex, FALSE);
ObDereferenceObject(Profile);
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
NtStopProfile(IN HANDLE ProfileHandle)
{
PEPROFILE Profile;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status;
PAGED_CODE();
/* Get the Object */
Status = ObReferenceObjectByHandle(ProfileHandle,
PROFILE_CONTROL,
ExProfileObjectType,
PreviousMode,
(PVOID*)&Profile,
NULL);
if (!NT_SUCCESS(Status)) return(Status);
/* Get the Mutex */
KeWaitForSingleObject(&ExpProfileMutex,
Executive,
KernelMode,
FALSE,
NULL);
/* Make sure the Profile Object is really Started */
if (!Profile->LockedBufferAddress)
{
Status = STATUS_PROFILING_NOT_STARTED;
goto Exit;
}
/* Stop the Profile */
KeStopProfile(Profile->ProfileObject);
/* Unlock the Buffer */
MmUnmapLockedPages(Profile->LockedBufferAddress, Profile->Mdl);
MmUnlockPages(Profile->Mdl);
ExFreePool(Profile->ProfileObject);
/* Clear the Locked Buffer pointer, meaning the Object is Stopped */
Profile->LockedBufferAddress = NULL;
Exit:
/* Release Mutex, Dereference and Return */
KeReleaseMutex(&ExpProfileMutex, FALSE);
ObDereferenceObject(Profile);
return Status;
}
NTSTATUS
NTAPI
NtQueryIntervalProfile(IN KPROFILE_SOURCE ProfileSource,
OUT PULONG Interval)
{
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
ULONG ReturnInterval;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH_TRY
{
/* Validate interval */
ProbeForWriteUlong(Interval);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* If pointer was invalid, bail out */
if(!NT_SUCCESS(Status)) return Status;
}
/* Query the Interval */
ReturnInterval = KeQueryIntervalProfile(ProfileSource);
/* Enter SEH block for return */
_SEH_TRY
{
/* Return the data */
*Interval = ReturnInterval;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Return Success */
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
NtSetIntervalProfile(IN ULONG Interval,
IN KPROFILE_SOURCE Source)
{
/* Let the Kernel do the job */
KeSetIntervalProfile(Interval, Source);
/* Nothing can go wrong */
return STATUS_SUCCESS;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,503 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/ex/rundown.c
* PURPOSE: Rundown and Cache-Aware Rundown Protection
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* Thomas Weidenmueller
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
/*++
* @name ExfAcquireRundownProtection
* @implemented NT5.1
*
* The ExfAcquireRundownProtection routine acquires rundown protection for
* the specified descriptor.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @return TRUE if access to the protected structure was granted, FALSE otherwise.
*
* @remarks Callers of ExfAcquireRundownProtection can be running at any IRQL.
*
*--*/
BOOLEAN
FASTCALL
ExfAcquireRundownProtection(IN PEX_RUNDOWN_REF RunRef)
{
ULONG_PTR Value = RunRef->Count, NewValue;
/* Make sure a rundown is not active */
if (Value & EX_RUNDOWN_ACTIVE) return FALSE;
/* Loop until successfully incremented the counter */
for (;;)
{
/* Add a reference */
NewValue = Value + EX_RUNDOWN_COUNT_INC;
/* Change the value */
Value = ExpChangeRundown(RunRef, NewValue, Value);
if (Value == NewValue) return TRUE;
/* Make sure a rundown is not active */
if (Value & EX_RUNDOWN_ACTIVE) return FALSE;
}
}
/*++
* @name ExfAcquireRundownProtectionEx
* @implemented NT5.2
*
* The ExfAcquireRundownProtectionEx routine acquires multiple rundown
* protection references for the specified descriptor.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @param Count
* Number of times to reference the descriptor.
*
* @return TRUE if access to the protected structure was granted, FALSE otherwise.
*
* @remarks Callers of ExfAcquireRundownProtectionEx can be running at any IRQL.
*
*--*/
BOOLEAN
FASTCALL
ExfAcquireRundownProtectionEx(IN PEX_RUNDOWN_REF RunRef,
IN ULONG Count)
{
ULONG_PTR Value = RunRef->Count, NewValue;
/* Make sure a rundown is not active */
if (Value & EX_RUNDOWN_ACTIVE) return FALSE;
/* Convert the count to our internal representation */
Count <<= EX_RUNDOWN_COUNT_SHIFT;
/* Loop until successfully incremented the counter */
for (;;)
{
/* Add references */
NewValue = Value + Count;
/* Change the value */
Value = ExpChangeRundown(RunRef, NewValue, Value);
if (Value == NewValue) return TRUE;
/* Make sure a rundown is not active */
if (Value & EX_RUNDOWN_ACTIVE) return FALSE;
}
}
/*++
* @name ExfInitializeRundownProtection
* @implemented NT5.1
*
* The ExfInitializeRundownProtection routine initializes a rundown
* protection descriptor.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @return None.
*
* @remarks Callers of ExfInitializeRundownProtection can be running at any IRQL.
*
*--*/
VOID
FASTCALL
ExfInitializeRundownProtection(IN PEX_RUNDOWN_REF RunRef)
{
/* Set the count to zero */
RunRef->Count = 0;
}
/*++
* @name ExfReInitializeRundownProtection
* @implemented NT5.1
*
* The ExfReInitializeRundownProtection routine re-initializes a rundown
* protection descriptor.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @return None.
*
* @remarks Callers of ExfReInitializeRundownProtection can be running at any IRQL.
*
*--*/
VOID
FASTCALL
ExfReInitializeRundownProtection(IN PEX_RUNDOWN_REF RunRef)
{
PAGED_CODE();
/* Sanity check */
ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
/* Reset the count */
ExpSetRundown(&RunRef->Count, 0);
}
/*++
* @name ExfRundownCompleted
* @implemented NT5.1
*
* The ExfRundownCompleted routine completes the rundown of the specified
* descriptor by setting the active bit.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @return None.
*
* @remarks Callers of ExfRundownCompleted must be running at IRQL <= APC_LEVEL.
*
*--*/
VOID
FASTCALL
ExfRundownCompleted(IN PEX_RUNDOWN_REF RunRef)
{
PAGED_CODE();
/* Sanity check */
ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
/* Mark the counter as active */
ExpSetRundown(&RunRef->Count, EX_RUNDOWN_ACTIVE);
}
/*++
* @name ExfReleaseRundownProtection
* @implemented NT5.1
*
* The ExfReleaseRundownProtection routine releases the rundown protection
* reference for the specified descriptor.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @return None.
*
* @remarks Callers of ExfReleaseRundownProtection can be running at any IRQL.
*
*--*/
VOID
FASTCALL
ExfReleaseRundownProtection(IN PEX_RUNDOWN_REF RunRef)
{
ULONG_PTR Value = RunRef->Count, NewValue;
PEX_RUNDOWN_WAIT_BLOCK WaitBlock;
/* Check if rundown is not active */
if (!(Value & EX_RUNDOWN_ACTIVE))
{
/* Loop until successfully incremented the counter */
for (;;)
{
/* Sanity check */
ASSERT((Value >= EX_RUNDOWN_COUNT_INC) || (KeNumberProcessors > 1));
/* Get the new value */
NewValue = Value - EX_RUNDOWN_COUNT_INC;
/* Change the value */
Value = ExpChangeRundown(RunRef, NewValue, Value);
if (Value == NewValue) return;
/* Loop again if we're still not active */
if (Value & EX_RUNDOWN_ACTIVE) break;
}
}
/* Get the wait block */
WaitBlock = (PEX_RUNDOWN_WAIT_BLOCK)(Value & ~EX_RUNDOWN_ACTIVE);
ASSERT((WaitBlock->Count > 0) || (KeNumberProcessors > 1));
/* Remove the one count */
if (!InterlockedDecrementSizeT(&WaitBlock->Count))
{
/* We're down to 0 now, so signal the event */
KeSetEvent(&WaitBlock->WakeEvent, IO_NO_INCREMENT, FALSE);
}
}
/*++
* @name ExfReleaseRundownProtectionEx
* @implemented NT5.2
*
* The ExfReleaseRundownProtectionEx routine releases multiple rundown
* protection references for the specified descriptor.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @param Count
* Number of times to dereference the descriptor.
*
* @return None.
*
* @remarks Callers of ExfAcquireRundownProtectionEx can be running at any IRQL.
*
*--*/
VOID
FASTCALL
ExfReleaseRundownProtectionEx(IN PEX_RUNDOWN_REF RunRef,
IN ULONG Count)
{
ULONG_PTR Value = RunRef->Count, NewValue;
PEX_RUNDOWN_WAIT_BLOCK WaitBlock;
/* Check if rundown is not active */
if (!(Value & EX_RUNDOWN_ACTIVE))
{
/* Loop until successfully incremented the counter */
for (;;)
{
/* Sanity check */
ASSERT((Value >= EX_RUNDOWN_COUNT_INC * Count) || (KeNumberProcessors > 1));
/* Get the new value */
NewValue = Value - (Count * EX_RUNDOWN_COUNT_INC);
/* Change the value */
Value = ExpChangeRundown(RunRef, NewValue, Value);
if (Value == NewValue) return;
/* Loop again if we're still not active */
if (Value & EX_RUNDOWN_ACTIVE) break;
}
}
/* Get the wait block */
WaitBlock = (PEX_RUNDOWN_WAIT_BLOCK)(Value & ~EX_RUNDOWN_ACTIVE);
ASSERT((WaitBlock->Count >= Count) || (KeNumberProcessors > 1));
/* Remove the count */
if (InterlockedExchangeAddSizeT(&WaitBlock->Count, -(LONG)Count) ==
(LONG)Count)
{
/* We're down to 0 now, so signal the event */
KeSetEvent(&WaitBlock->WakeEvent, IO_NO_INCREMENT, FALSE);
}
}
/*++
* @name ExfWaitForRundownProtectionRelease
* @implemented NT5.1
*
* The ExfWaitForRundownProtectionRelease routine waits until the specified
* rundown descriptor has been released.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @return None.
*
* @remarks Callers of ExfWaitForRundownProtectionRelease must be running
* at IRQL <= APC_LEVEL.
*
*--*/
VOID
FASTCALL
ExfWaitForRundownProtectionRelease(IN PEX_RUNDOWN_REF RunRef)
{
ULONG_PTR Value, Count, NewValue;
EX_RUNDOWN_WAIT_BLOCK WaitBlock;
PEX_RUNDOWN_WAIT_BLOCK WaitBlockPointer;
PKEVENT Event;
PAGED_CODE();
/* Set the active bit */
Value = ExpChangeRundown(RunRef, EX_RUNDOWN_ACTIVE, 0);
if ((Value == 0) || (Value == EX_RUNDOWN_ACTIVE)) return;
/* No event for now */
Event = NULL;
WaitBlockPointer = (PEX_RUNDOWN_WAIT_BLOCK)((ULONG_PTR)&WaitBlock |
EX_RUNDOWN_ACTIVE);
/* Start waitblock set loop */
for(;;)
{
/* Save the count */
Count = Value >> EX_RUNDOWN_COUNT_SHIFT;
/* If the count is over one or we don't have en event yet, create it */
if (Count || !Event)
{
/* Initialize the event */
KeInitializeEvent(&WaitBlock.WakeEvent,
NotificationEvent,
FALSE);
/* Set the pointer */
Event = &WaitBlock.WakeEvent;
}
/* Set the count */
WaitBlock.Count = Count;
/* Now set the pointer */
NewValue = ExpChangeRundown(RunRef, PtrToUlong(WaitBlockPointer), Value);
if (NewValue == Value) break;
/* Loop again */
Value = NewValue;
ASSERT((Value & EX_RUNDOWN_ACTIVE) == 0);
}
/* If the count was 0, we're done */
if (!Count) return;
/* Wait for whoever needs to release to notify us */
KeWaitForSingleObject(Event, Executive, KernelMode, FALSE, NULL);
ASSERT(WaitBlock.Count == 0);
}
/* FIXME: STUBS **************************************************************/
/*
* @unimplemented NT5.2
*/
BOOLEAN
FASTCALL
ExfAcquireRundownProtectionCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware)
{
DBG_UNREFERENCED_PARAMETER(RunRefCacheAware);
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented NT5.2
*/
BOOLEAN
FASTCALL
ExfAcquireRundownProtectionCacheAwareEx(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware,
IN ULONG Count)
{
DBG_UNREFERENCED_PARAMETER(RunRefCacheAware);
DBG_UNREFERENCED_PARAMETER(Count);
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented NT5.2
*/
VOID
FASTCALL
ExfReleaseRundownProtectionCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware)
{
DBG_UNREFERENCED_PARAMETER(RunRefCacheAware);
UNIMPLEMENTED;
}
/*
* @unimplemented NT5.2
*/
VOID
FASTCALL
ExfReleaseRundownProtectionCacheAwareEx(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware,
IN ULONG Count)
{
DBG_UNREFERENCED_PARAMETER(RunRefCacheAware);
DBG_UNREFERENCED_PARAMETER(Count);
UNIMPLEMENTED;
}
/*
* @unimplemented NT5.2
*/
VOID
FASTCALL
ExfWaitForRundownProtectionReleaseCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware)
{
DBG_UNREFERENCED_PARAMETER(RunRefCacheAware);
UNIMPLEMENTED;
}
/*
* @unimplemented NT5.2
*/
VOID
FASTCALL
ExfRundownCompletedCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware)
{
DBG_UNREFERENCED_PARAMETER(RunRefCacheAware);
UNIMPLEMENTED;
}
/*
* @unimplemented NT5.2
*/
VOID
FASTCALL
ExfReInitializeRundownProtectionCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware)
{
DBG_UNREFERENCED_PARAMETER(RunRefCacheAware);
UNIMPLEMENTED;
}
/*
* @unimplemented NT5.2
*/
PEX_RUNDOWN_REF_CACHE_AWARE
NTAPI
ExAllocateCacheAwareRundownProtection(IN POOL_TYPE PoolType,
IN ULONG Tag)
{
DBG_UNREFERENCED_PARAMETER(PoolType);
DBG_UNREFERENCED_PARAMETER(Tag);
UNIMPLEMENTED;
return NULL;
}
/*
* @unimplemented NT5.2
*/
VOID
NTAPI
ExFreeCacheAwareRundownProtection(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware)
{
DBG_UNREFERENCED_PARAMETER(RunRefCacheAware);
UNIMPLEMENTED;
}
/*
* @unimplemented NT5.2
*/
VOID
NTAPI
ExInitializeRundownProtectionCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware,
IN ULONG Count)
{
DBG_UNREFERENCED_PARAMETER(RunRefCacheAware);
DBG_UNREFERENCED_PARAMETER(Count);
UNIMPLEMENTED;
}
/*
* @unimplemented NT5.2
*/
SIZE_T
NTAPI
ExSizeOfRundownProtectionCacheAware(VOID)
{
UNIMPLEMENTED;
return 0;
}

View File

@@ -1,361 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/ex/sem.c
* PURPOSE: Semaphore Implementation
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* Thomas Weidenmueller
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, ExpInitializeSemaphoreImplementation()
#endif
/* GLOBALS ******************************************************************/
POBJECT_TYPE ExSemaphoreObjectType;
GENERIC_MAPPING ExSemaphoreMapping =
{
STANDARD_RIGHTS_READ | SEMAPHORE_QUERY_STATE,
STANDARD_RIGHTS_WRITE | SEMAPHORE_MODIFY_STATE,
STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE | SEMAPHORE_QUERY_STATE,
SEMAPHORE_ALL_ACCESS
};
static const INFORMATION_CLASS_INFO ExSemaphoreInfoClass[] =
{
/* SemaphoreBasicInformation */
ICI_SQ_SAME( sizeof(SEMAPHORE_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY),
};
/* FUNCTIONS *****************************************************************/
VOID
INIT_FUNCTION
NTAPI
ExpInitializeSemaphoreImplementation(VOID)
{
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
UNICODE_STRING Name;
DPRINT("Creating Semaphore Object Type\n");
/* Create the Event Pair Object Type */
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
RtlInitUnicodeString(&Name, L"Semaphore");
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KSEMAPHORE);
ObjectTypeInitializer.GenericMapping = ExSemaphoreMapping;
ObjectTypeInitializer.PoolType = NonPagedPool;
ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
ObjectTypeInitializer.ValidAccessMask = SEMAPHORE_ALL_ACCESS;
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExSemaphoreObjectType);
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtCreateSemaphore(OUT PHANDLE SemaphoreHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN LONG InitialCount,
IN LONG MaximumCount)
{
PKSEMAPHORE Semaphore;
HANDLE hSemaphore;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH_TRY
{
/* Check handle pointer */
ProbeForWriteHandle(SemaphoreHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Make sure the counts make sense */
if ((MaximumCount <= 0) ||
(InitialCount < 0) ||
(InitialCount > MaximumCount))
{
DPRINT("Invalid Count Data!\n");
return STATUS_INVALID_PARAMETER;
}
/* Create the Semaphore Object */
Status = ObCreateObject(PreviousMode,
ExSemaphoreObjectType,
ObjectAttributes,
PreviousMode,
NULL,
sizeof(KSEMAPHORE),
0,
0,
(PVOID*)&Semaphore);
/* Check for Success */
if (NT_SUCCESS(Status))
{
/* Initialize it */
KeInitializeSemaphore(Semaphore,
InitialCount,
MaximumCount);
/* Insert it into the Object Tree */
Status = ObInsertObject((PVOID)Semaphore,
NULL,
DesiredAccess,
0,
NULL,
&hSemaphore);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Enter SEH Block for return */
_SEH_TRY
{
/* Return the handle */
*SemaphoreHandle = hSemaphore;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
}
/* Return Status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtOpenSemaphore(OUT PHANDLE SemaphoreHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes)
{
HANDLE hSemaphore;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
/* Enter SEH Block */
_SEH_TRY
{
/* Check handle pointer */
ProbeForWriteHandle(SemaphoreHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Object */
Status = ObOpenObjectByName(ObjectAttributes,
ExSemaphoreObjectType,
PreviousMode,
NULL,
DesiredAccess,
NULL,
&hSemaphore);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Enter SEH Block for return */
_SEH_TRY
{
/* Return the handle */
*SemaphoreHandle = hSemaphore;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
/* Return Status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtQuerySemaphore(IN HANDLE SemaphoreHandle,
IN SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass,
OUT PVOID SemaphoreInformation,
IN ULONG SemaphoreInformationLength,
OUT PULONG ReturnLength OPTIONAL)
{
PKSEMAPHORE Semaphore;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Check buffers and class validity */
Status = DefaultQueryInfoBufferCheck(SemaphoreInformationClass,
ExSemaphoreInfoClass,
sizeof(ExSemaphoreInfoClass) /
sizeof(ExSemaphoreInfoClass[0]),
SemaphoreInformation,
SemaphoreInformationLength,
ReturnLength,
PreviousMode);
if(!NT_SUCCESS(Status))
{
/* Invalid buffers */
DPRINT("NtQuerySemaphore() failed, Status: 0x%x\n", Status);
return Status;
}
/* Get the Object */
Status = ObReferenceObjectByHandle(SemaphoreHandle,
SEMAPHORE_QUERY_STATE,
ExSemaphoreObjectType,
PreviousMode,
(PVOID*)&Semaphore,
NULL);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Entry SEH Block */
_SEH_TRY
{
PSEMAPHORE_BASIC_INFORMATION BasicInfo =
(PSEMAPHORE_BASIC_INFORMATION)SemaphoreInformation;
/* Return the basic information */
BasicInfo->CurrentCount = KeReadStateSemaphore(Semaphore);
BasicInfo->MaximumCount = Semaphore->Limit;
/* Return the length */
if(ReturnLength) *ReturnLength = sizeof(*BasicInfo);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Dereference the Object */
ObDereferenceObject(Semaphore);
}
/* Return status */
return Status;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtReleaseSemaphore(IN HANDLE SemaphoreHandle,
IN LONG ReleaseCount,
OUT PLONG PreviousCount OPTIONAL)
{
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PKSEMAPHORE Semaphore;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Check if we were called from user-mode */
if((PreviousCount) && (PreviousMode != KernelMode))
{
/* Entry SEH Block */
_SEH_TRY
{
/* Make sure the state pointer is valid */
ProbeForWriteLong(PreviousCount);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Bail out if pointer was invalid */
if(!NT_SUCCESS(Status)) return Status;
}
/* Make sure count makes sense */
if (ReleaseCount <= 0)
{
DPRINT("Invalid Release Count\n");
return STATUS_INVALID_PARAMETER;
}
/* Get the Object */
Status = ObReferenceObjectByHandle(SemaphoreHandle,
SEMAPHORE_MODIFY_STATE,
ExSemaphoreObjectType,
PreviousMode,
(PVOID*)&Semaphore,
NULL);
/* Check for success */
if (NT_SUCCESS(Status))
{
/* Enter SEH Block */
_SEH_TRY
{
/* Release the semaphore */
LONG PrevCount = KeReleaseSemaphore(Semaphore,
IO_NO_INCREMENT,
ReleaseCount,
FALSE);
ObDereferenceObject(Semaphore);
/* Return the old count if requested */
if(PreviousCount) *PreviousCount = PrevCount;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
/* Return Status */
return Status;
}
/* EOF */

File diff suppressed because it is too large Load Diff

View File

@@ -1,297 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/ex/time.c
* PURPOSE: Time and Timezone Management
* PROGRAMMERS: Eric Kohl
* Thomas Weidenmueller
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#define TICKSPERMINUTE 600000000
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, ExpInitTimeZoneInfo)
#endif
/* GLOBALS ******************************************************************/
/* Note: Bias[minutes] = UTC - local time */
TIME_ZONE_INFORMATION ExpTimeZoneInfo;
LARGE_INTEGER ExpTimeZoneBias;
ULONG ExpTimeZoneId;
/* FUNCTIONS ****************************************************************/
VOID
INIT_FUNCTION
NTAPI
ExpInitTimeZoneInfo(VOID)
{
LARGE_INTEGER CurrentTime;
NTSTATUS Status;
/* Read time zone information from the registry */
Status = RtlQueryTimeZoneInformation(&ExpTimeZoneInfo);
if (!NT_SUCCESS(Status))
{
/* Failed, clear all data */
RtlZeroMemory(&ExpTimeZoneInfo, sizeof(TIME_ZONE_INFORMATION));
ExpTimeZoneBias.QuadPart = (LONGLONG)0;
ExpTimeZoneId = TIME_ZONE_ID_UNKNOWN;
}
else
{
/* FIXME: Calculate transition dates */
/* Set bias and ID */
ExpTimeZoneBias.QuadPart = ((LONGLONG)(ExpTimeZoneInfo.Bias +
ExpTimeZoneInfo.StandardBias)) *
TICKSPERMINUTE;
ExpTimeZoneId = TIME_ZONE_ID_STANDARD;
}
/* Change it for user-mode applications */
SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.u.HighPart;
SharedUserData->TimeZoneBias.High2Time = ExpTimeZoneBias.u.HighPart;
SharedUserData->TimeZoneBias.LowPart = ExpTimeZoneBias.u.LowPart;
SharedUserData->TimeZoneId = ExpTimeZoneId;
/* Convert boot time from local time to UTC */
SystemBootTime.QuadPart += ExpTimeZoneBias.QuadPart;
/* Convert system time from local time to UTC */
do
{
CurrentTime.u.HighPart = SharedUserData->SystemTime.High1Time;
CurrentTime.u.LowPart = SharedUserData->SystemTime.LowPart;
} while (CurrentTime.u.HighPart != SharedUserData->SystemTime.High2Time);
/* Change it for user-mode applications */
CurrentTime.QuadPart += ExpTimeZoneBias.QuadPart;
SharedUserData->SystemTime.LowPart = CurrentTime.u.LowPart;
SharedUserData->SystemTime.High1Time = CurrentTime.u.HighPart;
SharedUserData->SystemTime.High2Time = CurrentTime.u.HighPart;
}
NTSTATUS
ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation)
{
LARGE_INTEGER LocalTime, SystemTime;
TIME_FIELDS TimeFields;
DPRINT("ExpSetTimeZoneInformation() called\n");
DPRINT("Old time zone bias: %d minutes\n", ExpTimeZoneInfo.Bias);
DPRINT("Old time zone standard bias: %d minutes\n",
ExpTimeZoneInfo.StandardBias);
DPRINT("New time zone bias: %d minutes\n", TimeZoneInformation->Bias);
DPRINT("New time zone standard bias: %d minutes\n",
TimeZoneInformation->StandardBias);
/* Get the local time */
HalQueryRealTimeClock(&TimeFields);
RtlTimeFieldsToTime(&TimeFields, &LocalTime);
/* FIXME: Calculate transition dates */
/* Calculate the bias and set the ID */
ExpTimeZoneBias.QuadPart = ((LONGLONG)(TimeZoneInformation->Bias +
TimeZoneInformation->StandardBias)) *
TICKSPERMINUTE;
ExpTimeZoneId = TIME_ZONE_ID_STANDARD;
/* Copy the timezone information */
RtlMoveMemory(&ExpTimeZoneInfo,
TimeZoneInformation,
sizeof(TIME_ZONE_INFORMATION));
/* Set the new time zone information */
SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.u.HighPart;
SharedUserData->TimeZoneBias.High2Time = ExpTimeZoneBias.u.HighPart;
SharedUserData->TimeZoneBias.LowPart = ExpTimeZoneBias.u.LowPart;
SharedUserData->TimeZoneId = ExpTimeZoneId;
DPRINT("New time zone bias: %I64d minutes\n",
ExpTimeZoneBias.QuadPart / TICKSPERMINUTE);
/* Calculate the new system time */
ExLocalTimeToSystemTime(&LocalTime, &SystemTime);
/* Set the new system time */
KiSetSystemTime(&SystemTime);
/* Return success */
DPRINT("ExpSetTimeZoneInformation() done\n");
return STATUS_SUCCESS;
}
/*
* FUNCTION: Sets the system time.
* PARAMETERS:
* NewTime - Points to a variable that specified the new time
* of day in the standard time format.
* OldTime - Optionally points to a variable that receives the
* old time of day in the standard time format.
* RETURNS: Status
*/
NTSTATUS
NTAPI
NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
OUT PLARGE_INTEGER PreviousTime OPTIONAL)
{
LARGE_INTEGER OldSystemTime;
LARGE_INTEGER NewSystemTime;
LARGE_INTEGER LocalTime;
TIME_FIELDS TimeFields;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
_SEH_TRY
{
/* Verify the time pointers */
NewSystemTime = ProbeForReadLargeInteger(SystemTime);
if(PreviousTime) ProbeForWriteLargeInteger(PreviousTime);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* If the pointers were invalid, bail out */
if(!NT_SUCCESS(Status)) return Status;
}
else
{
/* Reuse the pointer */
NewSystemTime = *SystemTime;
}
/* Make sure we have permission to change the time */
if(!SeSinglePrivilegeCheck(SeSystemtimePrivilege, PreviousMode))
{
DPRINT1("NtSetSystemTime: Caller requires the "
"SeSystemtimePrivilege privilege!\n");
return STATUS_PRIVILEGE_NOT_HELD;
}
/* Check if caller wants the old time */
if(PreviousTime) KeQuerySystemTime(&OldSystemTime);
/* Convert the time and set it in HAL */
ExSystemTimeToLocalTime(&NewSystemTime, &LocalTime);
RtlTimeToTimeFields(&LocalTime, &TimeFields);
HalSetRealTimeClock(&TimeFields);
/* Now set system time */
KiSetSystemTime(&NewSystemTime);
/* Check if caller wanted previous time */
if(PreviousTime)
{
/* Enter SEH Block for return */
_SEH_TRY
{
/* Return the previous time */
*PreviousTime = OldSystemTime;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
/* Return status */
return Status;
}
/*
* FUNCTION: Retrieves the system time.
* PARAMETERS:
* CurrentTime - Points to a variable that receives the current
* time of day in the standard time format.
*/
NTSTATUS
NTAPI
NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
{
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
/* Check if we were called from user-mode */
if(PreviousMode != KernelMode)
{
_SEH_TRY
{
/* Verify the time pointer */
ProbeForWriteLargeInteger(SystemTime);
/*
* It's safe to pass the pointer directly to KeQuerySystemTime as
* it's just a basic copy to this pointer. If it raises an
* exception nothing dangerous can happen!
*/
KeQuerySystemTime(SystemTime);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
else
{
/* Query the time directly */
KeQuerySystemTime(SystemTime);
}
/* Return status to caller */
return Status;
}
/*
* @implemented
*/
VOID
NTAPI
ExLocalTimeToSystemTime(PLARGE_INTEGER LocalTime,
PLARGE_INTEGER SystemTime)
{
SystemTime->QuadPart = LocalTime->QuadPart + ExpTimeZoneBias.QuadPart;
}
/*
* @unimplemented
*/
ULONG
NTAPI
ExSetTimerResolution(IN ULONG DesiredTime,
IN BOOLEAN SetResolution)
{
UNIMPLEMENTED;
return 0;
}
/*
* @implemented
*/
VOID
NTAPI
ExSystemTimeToLocalTime(PLARGE_INTEGER SystemTime,
PLARGE_INTEGER LocalTime)
{
LocalTime->QuadPart = SystemTime->QuadPart - ExpTimeZoneBias.QuadPart;
}
/* EOF */

View File

@@ -1,791 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ex/timer.c
* PURPOSE: Executive Timer Implementation
*
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* David Welch (welch@mcmail.com)
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, ExpInitializeTimerImplementation)
#endif
/* TYPES ********************************************************************/
/* Executive Timer Object */
typedef struct _ETIMER
{
KTIMER KeTimer;
KAPC TimerApc;
KDPC TimerDpc;
LIST_ENTRY ActiveTimerListEntry;
KSPIN_LOCK Lock;
BOOLEAN ApcAssociated;
BOOLEAN WakeTimer;
LIST_ENTRY WakeTimerListEntry;
} ETIMER, *PETIMER;
/* GLOBALS ******************************************************************/
/* Timer Object Type */
POBJECT_TYPE ExTimerType = NULL;
KSPIN_LOCK ExpWakeListLock;
LIST_ENTRY ExpWakeList;
/* Timer Mapping */
static GENERIC_MAPPING ExpTimerMapping =
{
STANDARD_RIGHTS_READ | TIMER_QUERY_STATE,
STANDARD_RIGHTS_WRITE | TIMER_MODIFY_STATE,
STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE,
TIMER_ALL_ACCESS
};
/* Timer Information Classes */
static const INFORMATION_CLASS_INFO ExTimerInfoClass[] =
{
/* TimerBasicInformation */
ICI_SQ_SAME( sizeof(TIMER_BASIC_INFORMATION), sizeof(ULONG), ICIF_QUERY ),
};
/* FUNCTIONS *****************************************************************/
VOID
STDCALL
ExTimerRundown(VOID)
{
PETHREAD Thread = PsGetCurrentThread();
KIRQL OldIrql;
PLIST_ENTRY CurrentEntry;
PETIMER Timer;
/* Lock the Thread's Active Timer List*/
KeAcquireSpinLock(&Thread->ActiveTimerListLock, &OldIrql);
while (!IsListEmpty(&Thread->ActiveTimerListHead))
{
/* Remove a Timer */
CurrentEntry = RemoveTailList(&Thread->ActiveTimerListHead);
/* Get the Timer */
Timer = CONTAINING_RECORD(CurrentEntry, ETIMER, ActiveTimerListEntry);
DPRINT("Timer, ThreadList: 0x%p, 0x%p\n", Timer, Thread);
/* Mark it as deassociated */
ASSERT (Timer->ApcAssociated);
Timer->ApcAssociated = FALSE;
/* Unlock the list */
KeReleaseSpinLockFromDpcLevel(&Thread->ActiveTimerListLock);
/* Lock the Timer */
KeAcquireSpinLockAtDpcLevel(&Timer->Lock);
/* Cancel the timer and remove its DPC and APC */
ASSERT(&Thread->Tcb == Timer->TimerApc.Thread);
KeCancelTimer(&Timer->KeTimer);
KeRemoveQueueDpc(&Timer->TimerDpc);
KeRemoveQueueApc(&Timer->TimerApc);
/* Unlock the Timer */
KeReleaseSpinLock(&Timer->Lock, OldIrql);
/* Dereference it */
ObDereferenceObject(Timer);
/* Loop again */
KeAcquireSpinLock(&Thread->ActiveTimerListLock, &OldIrql);
}
/* Release lock and return */
KeReleaseSpinLock(&Thread->ActiveTimerListLock, OldIrql);
return;
}
VOID
STDCALL
ExpDeleteTimer(PVOID ObjectBody)
{
KIRQL OldIrql;
PETIMER Timer = ObjectBody;
DPRINT("ExpDeleteTimer(Timer: 0x%p)\n", Timer);
/* Check if it has a Wait List */
if (Timer->WakeTimer)
{
/* Lock the Wake List */
KeAcquireSpinLock(&ExpWakeListLock, &OldIrql);
/* Check again, since it might've changed before we locked */
if (Timer->WakeTimer)
{
/* Remove it from the Wait List */
DPRINT("Removing wake list\n");
RemoveEntryList(&Timer->WakeTimerListEntry);
Timer->WakeTimer = FALSE;
}
/* Release the Wake List */
KeReleaseSpinLock(&ExpWakeListLock, OldIrql);
}
/* Tell the Kernel to cancel the Timer */
DPRINT("Cancelling Timer\n");
KeCancelTimer(&Timer->KeTimer);
}
VOID
STDCALL
ExpTimerDpcRoutine(PKDPC Dpc,
PVOID DeferredContext,
PVOID SystemArgument1,
PVOID SystemArgument2)
{
PETIMER Timer;
KIRQL OldIrql;
DPRINT("ExpTimerDpcRoutine(Dpc: 0x%p)\n", Dpc);
/* Get the Timer Object */
Timer = (PETIMER)DeferredContext;
/* Lock the Timer */
KeAcquireSpinLock(&Timer->Lock, &OldIrql);
/* Queue the APC */
if(Timer->ApcAssociated)
{
DPRINT("Queuing APC\n");
KeInsertQueueApc(&Timer->TimerApc,
SystemArgument1,
SystemArgument2,
IO_NO_INCREMENT);
}
/* Release the Timer */
KeReleaseSpinLock(&Timer->Lock, OldIrql);
return;
}
VOID
STDCALL
ExpTimerApcKernelRoutine(PKAPC Apc,
PKNORMAL_ROUTINE* NormalRoutine,
PVOID* NormalContext,
PVOID* SystemArgument1,
PVOID* SystemArguemnt2)
{
PETIMER Timer;
KIRQL OldIrql;
PETHREAD CurrentThread = PsGetCurrentThread();
/* We need to find out which Timer we are */
Timer = CONTAINING_RECORD(Apc, ETIMER, TimerApc);
DPRINT("ExpTimerApcKernelRoutine(Apc: 0x%p. Timer: 0x%p)\n", Apc, Timer);
/* Lock the Timer */
KeAcquireSpinLock(&Timer->Lock, &OldIrql);
/* Lock the Thread's Active Timer List*/
KeAcquireSpinLockAtDpcLevel(&CurrentThread->ActiveTimerListLock);
/*
* Make sure that the Timer is still valid, and that it belongs to this thread
* Remove it if it's not periodic
*/
if ((Timer->ApcAssociated) &&
(&CurrentThread->Tcb == Timer->TimerApc.Thread) &&
(!Timer->KeTimer.Period))
{
/* Remove it from the Active Timers List */
DPRINT("Removing Timer\n");
RemoveEntryList(&Timer->ActiveTimerListEntry);
/* Disable it */
Timer->ApcAssociated = FALSE;
/* Release spinlocks */
KeReleaseSpinLockFromDpcLevel(&CurrentThread->ActiveTimerListLock);
KeReleaseSpinLock(&Timer->Lock, OldIrql);
/* Dereference the Timer Object */
ObDereferenceObject(Timer);
return;
}
/* Release spinlocks */
KeReleaseSpinLockFromDpcLevel(&CurrentThread->ActiveTimerListLock);
KeReleaseSpinLock(&Timer->Lock, OldIrql);
}
VOID
INIT_FUNCTION
STDCALL
ExpInitializeTimerImplementation(VOID)
{
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
UNICODE_STRING Name;
DPRINT("Creating Timer Object Type\n");
/* Create the Event Pair Object Type */
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
RtlInitUnicodeString(&Name, L"Timer");
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(ETIMER);
ObjectTypeInitializer.GenericMapping = ExpTimerMapping;
ObjectTypeInitializer.PoolType = NonPagedPool;
ObjectTypeInitializer.ValidAccessMask = TIMER_ALL_ACCESS;
ObjectTypeInitializer.DeleteProcedure = ExpDeleteTimer;
ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExTimerType);
/* Initialize the Wait List and Lock */
KeInitializeSpinLock(&ExpWakeListLock);
InitializeListHead(&ExpWakeList);
}
NTSTATUS
STDCALL
NtCancelTimer(IN HANDLE TimerHandle,
OUT PBOOLEAN CurrentState OPTIONAL)
{
PETIMER Timer;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
BOOLEAN State;
KIRQL OldIrql;
PETHREAD TimerThread;
BOOLEAN KillTimer = FALSE;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtCancelTimer(0x%p, 0x%x)\n", TimerHandle, CurrentState);
/* Check Parameter Validity */
if(CurrentState && PreviousMode != KernelMode)
{
_SEH_TRY
{
ProbeForWriteBoolean(CurrentState);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
if(!NT_SUCCESS(Status)) return Status;
}
/* Get the Timer Object */
Status = ObReferenceObjectByHandle(TimerHandle,
TIMER_MODIFY_STATE,
ExTimerType,
PreviousMode,
(PVOID*)&Timer,
NULL);
/* Check for success */
if(NT_SUCCESS(Status))
{
DPRINT("Timer Referenced: 0x%p\n", Timer);
/* Lock the Timer */
KeAcquireSpinLock(&Timer->Lock, &OldIrql);
/* Check if it's enabled */
if (Timer->ApcAssociated)
{
/*
* First, remove it from the Thread's Active List
* Get the Thread.
*/
TimerThread = CONTAINING_RECORD(Timer->TimerApc.Thread, ETHREAD, Tcb);
DPRINT("Removing from Thread: 0x%p\n", TimerThread);
/* Lock its active list */
KeAcquireSpinLockAtDpcLevel(&TimerThread->ActiveTimerListLock);
/* Remove it */
RemoveEntryList(&TimerThread->ActiveTimerListHead);
/* Unlock the list */
KeReleaseSpinLockFromDpcLevel(&TimerThread->ActiveTimerListLock);
/* Cancel the Timer */
KeCancelTimer(&Timer->KeTimer);
KeRemoveQueueDpc(&Timer->TimerDpc);
KeRemoveQueueApc(&Timer->TimerApc);
Timer->ApcAssociated = FALSE;
KillTimer = TRUE;
}
else
{
/* If timer was disabled, we still need to cancel it */
DPRINT("APC was not Associated. Cancelling Timer\n");
KeCancelTimer(&Timer->KeTimer);
}
/* Handle a Wake Timer */
if (Timer->WakeTimer)
{
/* Lock the Wake List */
KeAcquireSpinLockAtDpcLevel(&ExpWakeListLock);
/* Check again, since it might've changed before we locked */
if (Timer->WakeTimer)
{
/* Remove it from the Wait List */
DPRINT("Removing wake list\n");
RemoveEntryList(&Timer->WakeTimerListEntry);
Timer->WakeTimer = FALSE;
}
/* Release the Wake List */
KeReleaseSpinLockFromDpcLevel(&ExpWakeListLock);
}
/* Unlock the Timer */
KeReleaseSpinLock(&Timer->Lock, OldIrql);
/* Read the old State */
State = KeReadStateTimer(&Timer->KeTimer);
/* Dereference the Object */
ObDereferenceObject(Timer);
/* Dereference if it was previously enabled */
if (KillTimer) ObDereferenceObject(Timer);
DPRINT1("Timer disabled\n");
/* Make sure it's safe to write to the handle */
if(CurrentState)
{
_SEH_TRY
{
*CurrentState = State;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
}
/* Return to Caller */
return Status;
}
NTSTATUS
STDCALL
NtCreateTimer(OUT PHANDLE TimerHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN TIMER_TYPE TimerType)
{
PETIMER Timer;
HANDLE hTimer;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtCreateTimer(Handle: 0x%p, Type: %d)\n", TimerHandle, TimerType);
/* Check Parameter Validity */
if (PreviousMode != KernelMode)
{
_SEH_TRY
{
ProbeForWriteHandle(TimerHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
if(!NT_SUCCESS(Status)) return Status;
}
/* Check for correct timer type */
if ((TimerType != NotificationTimer) && (TimerType != SynchronizationTimer))
{
DPRINT1("Invalid Timer Type!\n");
return STATUS_INVALID_PARAMETER_4;
}
/* Create the Object */
Status = ObCreateObject(PreviousMode,
ExTimerType,
ObjectAttributes,
PreviousMode,
NULL,
sizeof(ETIMER),
0,
0,
(PVOID*)&Timer);
/* Check for Success */
if(NT_SUCCESS(Status))
{
/* Initialize the Kernel Timer */
DPRINT("Initializing Timer: 0x%p\n", Timer);
KeInitializeTimerEx(&Timer->KeTimer, TimerType);
/* Initialize the Timer Lock */
KeInitializeSpinLock(&Timer->Lock);
/* Initialize the DPC */
KeInitializeDpc(&Timer->TimerDpc, ExpTimerDpcRoutine, Timer);
/* Set Initial State */
Timer->ApcAssociated = FALSE;
Timer->WakeTimer = FALSE;
/* Insert the Timer */
Status = ObInsertObject((PVOID)Timer,
NULL,
DesiredAccess,
0,
NULL,
&hTimer);
DPRINT("Timer Inserted\n");
/* Make sure it's safe to write to the handle */
_SEH_TRY
{
*TimerHandle = hTimer;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
/* Return to Caller */
return Status;
}
NTSTATUS
STDCALL
NtOpenTimer(OUT PHANDLE TimerHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes)
{
HANDLE hTimer;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtOpenTimer(TimerHandle: 0x%p)\n", TimerHandle);
/* Check Parameter Validity */
if (PreviousMode != KernelMode)
{
_SEH_TRY
{
ProbeForWriteHandle(TimerHandle);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
if(!NT_SUCCESS(Status)) return Status;
}
/* Open the Timer */
Status = ObOpenObjectByName(ObjectAttributes,
ExTimerType,
PreviousMode,
NULL,
DesiredAccess,
NULL,
&hTimer);
/* Check for success */
if(NT_SUCCESS(Status))
{
/* Make sure it's safe to write to the handle */
_SEH_TRY
{
*TimerHandle = hTimer;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
/* Return to Caller */
return Status;
}
NTSTATUS
STDCALL
NtQueryTimer(IN HANDLE TimerHandle,
IN TIMER_INFORMATION_CLASS TimerInformationClass,
OUT PVOID TimerInformation,
IN ULONG TimerInformationLength,
OUT PULONG ReturnLength OPTIONAL)
{
PETIMER Timer;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_SUCCESS;
PTIMER_BASIC_INFORMATION BasicInfo = (PTIMER_BASIC_INFORMATION)TimerInformation;
PAGED_CODE();
DPRINT("NtQueryTimer(TimerHandle: 0x%p, Class: %d)\n", TimerHandle, TimerInformationClass);
/* Check Validity */
Status = DefaultQueryInfoBufferCheck(TimerInformationClass,
ExTimerInfoClass,
sizeof(ExTimerInfoClass) / sizeof(ExTimerInfoClass[0]),
TimerInformation,
TimerInformationLength,
ReturnLength,
PreviousMode);
if(!NT_SUCCESS(Status))
{
DPRINT1("NtQueryTimer() failed, Status: 0x%x\n", Status);
return Status;
}
/* Get the Timer Object */
Status = ObReferenceObjectByHandle(TimerHandle,
TIMER_QUERY_STATE,
ExTimerType,
PreviousMode,
(PVOID*)&Timer,
NULL);
/* Check for Success */
if(NT_SUCCESS(Status))
{
/* Return the Basic Information */
_SEH_TRY
{
/* Return the remaining time, corrected */
BasicInfo->TimeRemaining.QuadPart = Timer->KeTimer.DueTime.QuadPart -
KeQueryInterruptTime();
/* Return the current state */
BasicInfo->SignalState = KeReadStateTimer(&Timer->KeTimer);
/* Return the buffer length if requested */
if(ReturnLength != NULL) *ReturnLength = sizeof(TIMER_BASIC_INFORMATION);
DPRINT("Returning Information for Timer: 0x%p. Time Remaining: %I64x\n",
Timer, BasicInfo->TimeRemaining.QuadPart);
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
/* Dereference Object */
ObDereferenceObject(Timer);
}
/* Return Status */
return Status;
}
NTSTATUS
STDCALL
NtSetTimer(IN HANDLE TimerHandle,
IN PLARGE_INTEGER DueTime,
IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL,
IN PVOID TimerContext OPTIONAL,
IN BOOLEAN WakeTimer,
IN LONG Period OPTIONAL,
OUT PBOOLEAN PreviousState OPTIONAL)
{
PETIMER Timer;
KIRQL OldIrql;
BOOLEAN State;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PETHREAD CurrentThread = PsGetCurrentThread();
LARGE_INTEGER TimerDueTime;
PETHREAD TimerThread;
BOOLEAN KillTimer = FALSE;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
DPRINT("NtSetTimer(TimerHandle: 0x%p, DueTime: %I64x, Apc: 0x%p, Period: %d)\n",
TimerHandle, DueTime->QuadPart, TimerApcRoutine, Period);
/* Check Parameter Validity */
if (PreviousMode != KernelMode)
{
_SEH_TRY
{
TimerDueTime = ProbeForReadLargeInteger(DueTime);
if(PreviousState)
{
ProbeForWriteBoolean(PreviousState);
}
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
if(!NT_SUCCESS(Status)) return Status;
}
/* Check for a valid Period */
if (Period < 0)
{
DPRINT1("Invalid Period for timer\n");
return STATUS_INVALID_PARAMETER_6;
}
/* Get the Timer Object */
Status = ObReferenceObjectByHandle(TimerHandle,
TIMER_MODIFY_STATE,
ExTimerType,
PreviousMode,
(PVOID*)&Timer,
NULL);
/*
* Tell the user we don't support Wake Timers...
* when we have the ability to use/detect the Power Management
* functionatliy required to support them, make this check dependent
* on the actual PM capabilities
*/
if (WakeTimer) Status = STATUS_TIMER_RESUME_IGNORED;
/* Check status */
if (NT_SUCCESS(Status))
{
/* Lock the Timer */
DPRINT("Timer Referencced: 0x%p\n", Timer);
KeAcquireSpinLock(&Timer->Lock, &OldIrql);
/* Cancel Running Timer */
if (Timer->ApcAssociated)
{
/*
* First, remove it from the Thread's Active List
* Get the Thread.
*/
TimerThread = CONTAINING_RECORD(Timer->TimerApc.Thread, ETHREAD, Tcb);
DPRINT("Thread already running. Removing from Thread: 0x%p\n", TimerThread);
/* Lock its active list */
KeAcquireSpinLockAtDpcLevel(&TimerThread->ActiveTimerListLock);
/* Remove it */
RemoveEntryList(&TimerThread->ActiveTimerListHead);
/* Unlock the list */
KeReleaseSpinLockFromDpcLevel(&TimerThread->ActiveTimerListLock);
/* Cancel the Timer */
KeCancelTimer(&Timer->KeTimer);
KeRemoveQueueDpc(&Timer->TimerDpc);
KeRemoveQueueApc(&Timer->TimerApc);
Timer->ApcAssociated = FALSE;
KillTimer = TRUE;
} else {
/* If timer was disabled, we still need to cancel it */
DPRINT("No APCs. Simply cancelling\n");
KeCancelTimer(&Timer->KeTimer);
}
/* Read the State */
State = KeReadStateTimer(&Timer->KeTimer);
/* Handle Wake Timers */
DPRINT("Doing Wake Semantics\n");
KeAcquireSpinLockAtDpcLevel(&ExpWakeListLock);
if (WakeTimer && !Timer->WakeTimer)
{
/* Insert it into the list */
Timer->WakeTimer = TRUE;
InsertTailList(&ExpWakeList, &Timer->WakeTimerListEntry);
}
else if (!WakeTimer && Timer->WakeTimer)
{
/* Remove it from the list */
RemoveEntryList(&Timer->WakeTimerListEntry);
Timer->WakeTimer = FALSE;
}
KeReleaseSpinLockFromDpcLevel(&ExpWakeListLock);
/* Set up the APC Routine if specified */
if (TimerApcRoutine)
{
/* Initialize the APC */
DPRINT("Initializing APC: 0x%p\n", Timer->TimerApc);
KeInitializeApc(&Timer->TimerApc,
&CurrentThread->Tcb,
CurrentApcEnvironment,
&ExpTimerApcKernelRoutine,
(PKRUNDOWN_ROUTINE)NULL,
(PKNORMAL_ROUTINE)TimerApcRoutine,
PreviousMode,
TimerContext);
/* Lock the Thread's Active List and Insert */
KeAcquireSpinLockAtDpcLevel(&CurrentThread->ActiveTimerListLock);
InsertTailList(&CurrentThread->ActiveTimerListHead,
&Timer->ActiveTimerListEntry);
KeReleaseSpinLockFromDpcLevel(&CurrentThread->ActiveTimerListLock);
}
/* Enable and Set the Timer */
DPRINT("Setting Kernel Timer\n");
KeSetTimerEx(&Timer->KeTimer,
TimerDueTime,
Period,
TimerApcRoutine ? &Timer->TimerDpc : 0);
Timer->ApcAssociated = TimerApcRoutine ? TRUE : FALSE;
/* Unlock the Timer */
KeReleaseSpinLock(&Timer->Lock, OldIrql);
/* Dereference if it was previously enabled */
if (!TimerApcRoutine) ObDereferenceObject(Timer);
if (KillTimer) ObDereferenceObject(Timer);
DPRINT("Finished Setting the Timer\n");
/* Make sure it's safe to write to the handle */
if(PreviousState != NULL)
{
_SEH_TRY
{
*PreviousState = State;
}
_SEH_EXCEPT(_SEH_ExSystemExceptionFilter)
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
}
/* Return to Caller */
return Status;
}
/* EOF */

View File

@@ -1,308 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ex/uuid.c
* PURPOSE: UUID generator
*
* PROGRAMMERS: Eric Kohl
Thomas Weidenmueller
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#define SEED_BUFFER_SIZE 6
/* Number of 100ns ticks per clock tick. To be safe, assume that the clock
resolution is at least 1000 * 100 * (1/1000000) = 1/10 of a second */
#define TICKS_PER_CLOCK_TICK 1000
#define SECSPERDAY 86400
#define TICKSPERSEC 10000000
/* UUID system time starts at October 15, 1582 */
#define SECS_15_OCT_1582_TO_1601 ((17 + 30 + 31 + 365 * 18 + 5) * SECSPERDAY)
#define TICKS_15_OCT_1582_TO_1601 ((ULONGLONG)SECS_15_OCT_1582_TO_1601 * TICKSPERSEC)
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, ExpInitUuids)
#endif
/* GLOBALS ****************************************************************/
static FAST_MUTEX UuidMutex;
static ULARGE_INTEGER UuidLastTime;
static ULONG UuidSequence;
static BOOLEAN UuidSequenceInitialized = FALSE;
static BOOLEAN UuidSequenceChanged = FALSE;
static UCHAR UuidSeed[SEED_BUFFER_SIZE];
static ULONG UuidCount;
/* FUNCTIONS ****************************************************************/
VOID
INIT_FUNCTION
NTAPI
ExpInitUuids(VOID)
{
ExInitializeFastMutex(&UuidMutex);
KeQuerySystemTime((PLARGE_INTEGER)&UuidLastTime);
UuidLastTime.QuadPart += TICKS_15_OCT_1582_TO_1601;
UuidCount = TICKS_PER_CLOCK_TICK;
RtlZeroMemory(UuidSeed, SEED_BUFFER_SIZE);
}
#define VALUE_BUFFER_SIZE 256
static NTSTATUS
ExpLoadUuidSequence(PULONG Sequence)
{
UCHAR ValueBuffer[VALUE_BUFFER_SIZE];
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING Name;
HANDLE KeyHandle;
ULONG ValueLength;
NTSTATUS Status;
RtlInitUnicodeString(&Name,
L"\\Registry\\Machine\\Software\\Microsoft\\Rpc");
InitializeObjectAttributes(&ObjectAttributes,
&Name,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = ZwOpenKey(&KeyHandle,
KEY_QUERY_VALUE,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
DPRINT("ZwOpenKey() failed (Status %lx)\n", Status);
return Status;
}
RtlInitUnicodeString(&Name, L"UuidSequenceNumber");
ValueInfo = (PKEY_VALUE_PARTIAL_INFORMATION)ValueBuffer;
Status = ZwQueryValueKey(KeyHandle,
&Name,
KeyValuePartialInformation,
ValueBuffer,
VALUE_BUFFER_SIZE,
&ValueLength);
ZwClose(KeyHandle);
if (!NT_SUCCESS(Status))
{
DPRINT("ZwQueryValueKey() failed (Status %lx)\n", Status);
return Status;
}
*Sequence = *((PULONG)ValueInfo->Data);
DPRINT("Loaded sequence %lx\n", *Sequence);
return STATUS_SUCCESS;
}
#undef VALUE_BUFFER_SIZE
static NTSTATUS
ExpSaveUuidSequence(PULONG Sequence)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING Name;
HANDLE KeyHandle;
NTSTATUS Status;
RtlInitUnicodeString(&Name,
L"\\Registry\\Machine\\Software\\Microsoft\\Rpc");
InitializeObjectAttributes(&ObjectAttributes,
&Name,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = ZwOpenKey(&KeyHandle,
KEY_SET_VALUE,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
DPRINT("ZwOpenKey() failed (Status %lx)\n", Status);
return Status;
}
RtlInitUnicodeString(&Name, L"UuidSequenceNumber");
Status = ZwSetValueKey(KeyHandle,
&Name,
0,
REG_DWORD,
Sequence,
sizeof(ULONG));
ZwClose(KeyHandle);
if (!NT_SUCCESS(Status))
{
DPRINT("ZwSetValueKey() failed (Status %lx)\n", Status);
}
return Status;
}
static VOID
ExpGetRandomUuidSequence(PULONG Sequence)
{
LARGE_INTEGER Counter;
LARGE_INTEGER Frequency;
ULONG Value;
Counter = KeQueryPerformanceCounter(&Frequency);
Value = Counter.u.LowPart ^ Counter.u.HighPart;
*Sequence = *Sequence ^ Value;
DPRINT("Sequence %lx\n", *Sequence);
}
static NTSTATUS
ExpCreateUuids(PULARGE_INTEGER Time,
PULONG Range,
PULONG Sequence)
{
/*
* Generate time element of the UUID. Account for going faster
* than our clock as well as the clock going backwards.
*/
while (1)
{
KeQuerySystemTime((PLARGE_INTEGER)Time);
Time->QuadPart += TICKS_15_OCT_1582_TO_1601;
if (Time->QuadPart > UuidLastTime.QuadPart)
{
UuidCount = 0;
break;
}
if (Time->QuadPart < UuidLastTime.QuadPart)
{
(*Sequence)++;
UuidSequenceChanged = TRUE;
UuidCount = 0;
break;
}
if (UuidCount < TICKS_PER_CLOCK_TICK)
{
UuidCount++;
break;
}
}
UuidLastTime.QuadPart = Time->QuadPart;
Time->QuadPart += UuidCount;
*Range = 10000; /* What does this mean? Ticks per millisecond?*/
return STATUS_SUCCESS;
}
/*
* @unimplemented
*/
NTSTATUS
NTAPI
ExUuidCreate(OUT UUID *Uuid)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented
*/
NTSTATUS
NTAPI
NtAllocateUuids(OUT PULARGE_INTEGER Time,
OUT PULONG Range,
OUT PULONG Sequence,
OUT PUCHAR Seed)
{
ULARGE_INTEGER IntTime;
ULONG IntRange;
NTSTATUS Status;
PAGED_CODE();
ExAcquireFastMutex(&UuidMutex);
if (!UuidSequenceInitialized)
{
Status = ExpLoadUuidSequence(&UuidSequence);
if (NT_SUCCESS(Status))
{
UuidSequence++;
}
else
{
ExpGetRandomUuidSequence(&UuidSequence);
}
UuidSequenceInitialized = TRUE;
UuidSequenceChanged = TRUE;
}
Status = ExpCreateUuids(&IntTime,
&IntRange,
&UuidSequence);
if (!NT_SUCCESS(Status))
{
ExReleaseFastMutex(&UuidMutex);
return Status;
}
if (UuidSequenceChanged)
{
Status = ExpSaveUuidSequence(&UuidSequence);
if (NT_SUCCESS(Status))
UuidSequenceChanged = FALSE;
}
ExReleaseFastMutex(&UuidMutex);
Time->QuadPart = IntTime.QuadPart;
*Range = IntRange;
*Sequence = UuidSequence;
RtlCopyMemory(Seed,
UuidSeed,
SEED_BUFFER_SIZE);
return STATUS_SUCCESS;
}
/*
* @implemented
*/
NTSTATUS
NTAPI
NtSetUuidSeed(IN PUCHAR Seed)
{
PAGED_CODE();
RtlCopyMemory(UuidSeed,
Seed,
SEED_BUFFER_SIZE);
return STATUS_SUCCESS;
}
/* EOF */

View File

@@ -1,133 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/ex/win32k.c
* PURPOSE: Executive Win32 Object Support (Desktop/WinStation)
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
*/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, ExpWin32kInit)
#endif
/* DATA **********************************************************************/
POBJECT_TYPE ExWindowStationObjectType = NULL;
POBJECT_TYPE ExDesktopObjectType = NULL;
GENERIC_MAPPING ExpWindowStationMapping =
{
STANDARD_RIGHTS_READ,
STANDARD_RIGHTS_WRITE,
STANDARD_RIGHTS_EXECUTE,
STANDARD_RIGHTS_REQUIRED
};
GENERIC_MAPPING ExpDesktopMapping =
{
STANDARD_RIGHTS_READ,
STANDARD_RIGHTS_WRITE,
STANDARD_RIGHTS_EXECUTE,
STANDARD_RIGHTS_REQUIRED
};
PKWIN32_PARSEMETHOD_CALLOUT ExpWindowStationObjectParse = NULL;
PKWIN32_DELETEMETHOD_CALLOUT ExpWindowStationObjectDelete = NULL;
PKWIN32_DELETEMETHOD_CALLOUT ExpDesktopObjectDelete = NULL;
/* FUNCTIONS ****************************************************************/
VOID
STDCALL
ExpWinStaObjectDelete(PVOID DeletedObject)
{
WIN32_DELETEMETHOD_PARAMETERS Parameters;
/* Fill out the callback structure */
Parameters.Object = DeletedObject;
/* Call the Registered Callback */
ExpWindowStationObjectDelete(&Parameters);
}
NTSTATUS
STDCALL
ExpWinStaObjectParse(IN PVOID ParseObject,
IN PVOID ObjectType,
IN OUT PACCESS_STATE AccessState,
IN KPROCESSOR_MODE AccessMode,
IN ULONG Attributes,
IN OUT PUNICODE_STRING CompleteName,
IN OUT PUNICODE_STRING RemainingName,
IN OUT PVOID Context OPTIONAL,
IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
OUT PVOID *Object)
{
WIN32_PARSEMETHOD_PARAMETERS Parameters;
/* Fill out the callback structure */
Parameters.ParseObject = ParseObject;
Parameters.ObjectType = ObjectType;
Parameters.AccessState = AccessState;
Parameters.AccessMode = AccessMode;
Parameters.Attributes = Attributes;
Parameters.CompleteName = CompleteName;
Parameters.RemainingName = RemainingName;
Parameters.Context = Context;
Parameters.SecurityQos = SecurityQos;
Parameters.Object = Object;
/* Call the Registered Callback */
return ExpWindowStationObjectParse(&Parameters);
}
VOID
STDCALL
ExpDesktopDelete(PVOID DeletedObject)
{
WIN32_DELETEMETHOD_PARAMETERS Parameters;
/* Fill out the callback structure */
Parameters.Object = DeletedObject;
/* Call the Registered Callback */
ExpDesktopObjectDelete(&Parameters);
}
VOID
INIT_FUNCTION
STDCALL
ExpWin32kInit(VOID)
{
OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
UNICODE_STRING Name;
DPRINT("Creating Win32 Object Types\n");
/* Create the window station Object Type */
RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
RtlInitUnicodeString(&Name, L"WindowStation");
ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
ObjectTypeInitializer.GenericMapping = ExpWindowStationMapping;
ObjectTypeInitializer.PoolType = NonPagedPool;
ObjectTypeInitializer.DeleteProcedure = ExpWinStaObjectDelete;
ObjectTypeInitializer.ParseProcedure = ExpWinStaObjectParse;
ObCreateObjectType(&Name,
&ObjectTypeInitializer,
NULL,
&ExWindowStationObjectType);
/* Create desktop object type */
RtlInitUnicodeString(&Name, L"Desktop");
ObjectTypeInitializer.GenericMapping = ExpDesktopMapping;
ObjectTypeInitializer.DeleteProcedure = ExpDesktopDelete;
ObjectTypeInitializer.ParseProcedure = NULL;
ObCreateObjectType(&Name,
&ObjectTypeInitializer,
NULL,
&ExDesktopObjectType);
}
/* EOF */

View File

@@ -1,664 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/ex/work.c
* PURPOSE: Manage system work queues and worker threads
* PROGRAMMER: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, ExpInitializeWorkerThreads)
#endif
/* DATA **********************************************************************/
/* Number of worker threads for each Queue */
#define EX_HYPERCRITICAL_WORK_THREADS 1
#define EX_DELAYED_WORK_THREADS 3
#define EX_CRITICAL_WORK_THREADS 5
/* Magic flag for dynamic worker threads */
#define EX_DYNAMIC_WORK_THREAD 0x80000000
/* Worker thread priority increments (added to base priority) */
#define EX_HYPERCRITICAL_QUEUE_PRIORITY_INCREMENT 7
#define EX_CRITICAL_QUEUE_PRIORITY_INCREMENT 5
#define EX_DELAYED_QUEUE_PRIORITY_INCREMENT 4
/* The actual worker queue array */
EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue];
/* Accounting of the total threads and registry hacked threads */
ULONG ExpCriticalWorkerThreads;
ULONG ExpDelayedWorkerThreads;
ULONG ExpAdditionalCriticalWorkerThreads;
ULONG ExpAdditionalDelayedWorkerThreads;
/* Future support for stack swapping worker threads */
BOOLEAN ExpWorkersCanSwap;
LIST_ENTRY ExpWorkerListHead;
KMUTANT ExpWorkerSwapinMutex;
/* The worker balance set manager events */
KEVENT ExpThreadSetManagerEvent;
KEVENT ExpThreadSetManagerShutdownEvent;
/* Thread pointers for future worker thread shutdown support */
PETHREAD ExpWorkerThreadBalanceManagerPtr;
PETHREAD ExpLastWorkerThread;
/* PRIVATE FUNCTIONS *********************************************************/
/*++
* @name ExpWorkerThreadEntryPoint
*
* The ExpWorkerThreadEntryPoint routine is the entrypoint for any new
* worker thread created by teh system.
*
* @param Context
* Contains the work queue type masked with a flag specifing whether the
* thread is dynamic or not.
*
* @return None.
*
* @remarks A dynamic thread can timeout after 10 minutes of waiting on a queue
* while a static thread will never timeout.
*
* Worker threads must return at IRQL == PASSIVE_LEVEL, must not have
* active impersonation info, and must not have disabled APCs.
*
* NB: We will re-enable APCs for broken threads but all other cases
* will generate a bugcheck.
*
*--*/
VOID
NTAPI
ExpWorkerThreadEntryPoint(IN PVOID Context)
{
PWORK_QUEUE_ITEM WorkItem;
PLIST_ENTRY QueueEntry;
WORK_QUEUE_TYPE WorkQueueType;
PEX_WORK_QUEUE WorkQueue;
LARGE_INTEGER Timeout;
PLARGE_INTEGER TimeoutPointer = NULL;
PETHREAD Thread = PsGetCurrentThread();
KPROCESSOR_MODE WaitMode;
EX_QUEUE_WORKER_INFO OldValue, NewValue;
/* Check if this is a dyamic thread */
if ((ULONG_PTR)Context & EX_DYNAMIC_WORK_THREAD)
{
/* It is, which means we will eventually time out after 10 minutes */
Timeout.QuadPart = Int32x32To64(10, -10000000 * 60);
TimeoutPointer = &Timeout;
}
/* Get Queue Type and Worker Queue */
WorkQueueType = (WORK_QUEUE_TYPE)((ULONG_PTR)Context &
~EX_DYNAMIC_WORK_THREAD);
WorkQueue = &ExWorkerQueue[WorkQueueType];
/* Select the wait mode */
WaitMode = (UCHAR)WorkQueue->Info.WaitMode;
/* Nobody should have initialized this yet, do it now */
ASSERT(Thread->ExWorkerCanWaitUser == 0);
if (WaitMode == UserMode) Thread->ExWorkerCanWaitUser = TRUE;
/* If we shouldn't swap, disable that feature */
if (!ExpWorkersCanSwap) KeSetKernelStackSwapEnable(FALSE);
/* Set the worker flags */
do
{
/* Check if the queue is being disabled */
if (WorkQueue->Info.QueueDisabled)
{
/* Re-enable stack swapping and kill us */
KeSetKernelStackSwapEnable(TRUE);
PsTerminateSystemThread(STATUS_SYSTEM_SHUTDOWN);
}
/* Increase the worker count */
OldValue = WorkQueue->Info;
NewValue = OldValue;
NewValue.WorkerCount++;
}
while (InterlockedCompareExchange((PLONG)&WorkQueue->Info,
*(PLONG)&NewValue,
*(PLONG)&OldValue) != *(PLONG)&OldValue);
/* Success, you are now officially a worker thread! */
Thread->ActiveExWorker = TRUE;
/* Loop forever */
ProcessLoop:
for (;;)
{
/* Wait for Something to Happen on the Queue */
QueueEntry = KeRemoveQueue(&WorkQueue->WorkerQueue,
WaitMode,
TimeoutPointer);
/* Check if we timed out and quit this loop in that case */
if ((NTSTATUS)QueueEntry == STATUS_TIMEOUT) break;
/* Increment Processed Work Items */
InterlockedIncrement((PLONG)&WorkQueue->WorkItemsProcessed);
/* Get the Work Item */
WorkItem = CONTAINING_RECORD(QueueEntry, WORK_QUEUE_ITEM, List);
/* Make sure nobody is trying to play smart with us */
ASSERT((ULONG_PTR)WorkItem->WorkerRoutine > MmUserProbeAddress);
/* Call the Worker Routine */
WorkItem->WorkerRoutine(WorkItem->Parameter);
/* Make sure APCs are not disabled */
if (Thread->Tcb.SpecialApcDisable)
{
/* We're nice and do it behind your back */
DPRINT1("Warning: Broken Worker Thread: %p %lx %p came back "
"with APCs disabled!\n",
WorkItem->WorkerRoutine,
WorkItem->Parameter,
WorkItem);
Thread->Tcb.SpecialApcDisable = 0;
}
/* Make sure it returned at right IRQL */
if (KeGetCurrentIrql() != PASSIVE_LEVEL)
{
/* It didn't, bugcheck! */
KEBUGCHECKEX(WORKER_THREAD_RETURNED_AT_BAD_IRQL,
(ULONG_PTR)WorkItem->WorkerRoutine,
KeGetCurrentIrql(),
(ULONG_PTR)WorkItem->Parameter,
(ULONG_PTR)WorkItem);
}
/* Make sure it returned with Impersionation Disabled */
if (Thread->ActiveImpersonationInfo)
{
/* It didn't, bugcheck! */
KEBUGCHECKEX(IMPERSONATING_WORKER_THREAD,
(ULONG_PTR)WorkItem->WorkerRoutine,
(ULONG_PTR)WorkItem->Parameter,
(ULONG_PTR)WorkItem,
0);
}
}
/* This is a dynamic thread. Terminate it unless IRPs are pending */
if (!IsListEmpty(&Thread->IrpList)) goto ProcessLoop;
/* Don't terminate it if the queue is disabled either */
if (WorkQueue->Info.QueueDisabled) goto ProcessLoop;
/* Set the worker flags */
do
{
/* Decrease the worker count */
OldValue = WorkQueue->Info;
NewValue = OldValue;
NewValue.WorkerCount--;
}
while (InterlockedCompareExchange((PLONG)&WorkQueue->Info,
*(PLONG)&NewValue,
*(PLONG)&OldValue) != *(PLONG)&OldValue);
/* Decrement dynamic thread count */
InterlockedDecrement(&WorkQueue->DynamicThreadCount);
/* We're not a worker thread anymore */
Thread->ActiveExWorker = FALSE;
/* Re-enable the stack swap */
KeSetKernelStackSwapEnable(TRUE);
return;
}
/*++
* @name ExpCreateWorkerThread
*
* The ExpCreateWorkerThread routine creates a new worker thread for the
* specified queue.
**
* @param QueueType
* Type of the queue to use for this thread. Valid values are:
* - DelayedWorkQueue
* - CriticalWorkQueue
* - HyperCriticalWorkQueue
*
* @param Dynamic
* Specifies whether or not this thread is a dynamic thread.
*
* @return None.
*
* @remarks HyperCritical work threads run at priority 7; Critical work threads
* run at priority 5, and delayed work threads run at priority 4.
*
* This, worker threads cannot pre-empty a normal user-mode thread.
*
*--*/
VOID
NTAPI
ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType,
IN BOOLEAN Dynamic)
{
PETHREAD Thread;
HANDLE hThread;
ULONG Context;
KPRIORITY Priority;
/* Check if this is going to be a dynamic thread */
Context = WorkQueueType;
/* Add the dynamic mask */
if (Dynamic) Context |= EX_DYNAMIC_WORK_THREAD;
/* Create the System Thread */
PsCreateSystemThread(&hThread,
THREAD_ALL_ACCESS,
NULL,
NULL,
NULL,
ExpWorkerThreadEntryPoint,
(PVOID)Context);
/* If the thread is dynamic */
if (Dynamic)
{
/* Increase the count */
InterlockedIncrement(&ExWorkerQueue[WorkQueueType].DynamicThreadCount);
}
/* Set the priority */
if (WorkQueueType == DelayedWorkQueue)
{
/* Priority == 4 */
Priority = EX_DELAYED_QUEUE_PRIORITY_INCREMENT;
}
else if (WorkQueueType == CriticalWorkQueue)
{
/* Priority == 5 */
Priority = EX_CRITICAL_QUEUE_PRIORITY_INCREMENT;
}
else
{
/* Priority == 7 */
Priority = EX_HYPERCRITICAL_QUEUE_PRIORITY_INCREMENT;
}
/* Get the Thread */
ObReferenceObjectByHandle(hThread,
THREAD_SET_INFORMATION,
PsThreadType,
KernelMode,
(PVOID*)&Thread,
NULL);
/* Set the Priority */
KeSetBasePriorityThread(&Thread->Tcb, Priority);
/* Dereference and close handle */
ObDereferenceObject(Thread);
ZwClose(hThread);
}
/*++
* @name ExpCheckDynamicThreadCount
*
* The ExpCheckDynamicThreadCount routine checks every queue and creates a
* dynamic thread if the queue seems to be deadlocked.
*
* @param None
*
* @return None.
*
* @remarks The algorithm for deciding if a new thread must be created is
* based on wether the queue has processed no new items in the last
* second, and new items are still enqueued.
*
*--*/
VOID
NTAPI
ExpDetectWorkerThreadDeadlock(VOID)
{
ULONG i;
PEX_WORK_QUEUE Queue;
/* Loop the 3 queues */
for (i = 0; i < MaximumWorkQueue; i++)
{
/* Get the queue */
Queue = &ExWorkerQueue[i];
ASSERT(Queue->DynamicThreadCount <= 16);
/* Check if stuff is on the queue that still is unprocessed */
if ((Queue->QueueDepthLastPass) &&
(Queue->WorkItemsProcessed == Queue->WorkItemsProcessedLastPass) &&
(Queue->DynamicThreadCount < 16))
{
/* Stuff is still on the queue and nobody did anything about it */
DPRINT1("EX: Work Queue Deadlock detected: %d\n", i);
ExpCreateWorkerThread(i, TRUE);
DPRINT1("Dynamic threads queued %d\n", Queue->DynamicThreadCount);
}
/* Update our data */
Queue->WorkItemsProcessedLastPass = Queue->WorkItemsProcessed;
Queue->QueueDepthLastPass = KeReadStateQueue(&Queue->WorkerQueue);
}
}
/*++
* @name ExpCheckDynamicThreadCount
*
* The ExpCheckDynamicThreadCount routine checks every queue and creates a
* dynamic thread if the queue requires one.
*
* @param None
*
* @return None.
*
* @remarks The algorithm for deciding if a new thread must be created is
* documented in the ExQueueWorkItem routine.
*
*--*/
VOID
NTAPI
ExpCheckDynamicThreadCount(VOID)
{
ULONG i;
PEX_WORK_QUEUE Queue;
/* Loop the 3 queues */
for (i = 0; i < MaximumWorkQueue; i++)
{
/* Get the queue */
Queue = &ExWorkerQueue[i];
/* Check if still need a new thread. See ExQueueWorkItem */
if ((Queue->Info.MakeThreadsAsNecessary) &&
(!IsListEmpty(&Queue->WorkerQueue.EntryListHead)) &&
(Queue->WorkerQueue.CurrentCount <
Queue->WorkerQueue.MaximumCount) &&
(Queue->DynamicThreadCount < 16))
{
/* Create a new thread */
DPRINT1("EX: Creating new dynamic thread as requested\n");
ExpCreateWorkerThread(i, TRUE);
}
}
}
/*++
* @name ExpWorkerThreadBalanceManager
*
* The ExpWorkerThreadBalanceManager routine is the entrypoint for the
* worker thread balance set manager.
*
* @param Context
* Unused.
*
* @return None.
*
* @remarks The worker thread balance set manager listens every second, but can
* also be woken up by an event when a new thread is needed, or by the
* special shutdown event. This thread runs at priority 7.
*
* This routine must run at IRQL == PASSIVE_LEVEL.
*
*--*/
VOID
NTAPI
ExpWorkerThreadBalanceManager(IN PVOID Context)
{
KTIMER Timer;
LARGE_INTEGER Timeout;
NTSTATUS Status;
PVOID WaitEvents[3];
PAGED_CODE();
UNREFERENCED_PARAMETER(Context);
/* Raise our priority above all other worker threads */
KeSetBasePriorityThread(KeGetCurrentThread(),
EX_CRITICAL_QUEUE_PRIORITY_INCREMENT + 1);
/* Setup the timer */
KeInitializeTimer(&Timer);
Timeout.QuadPart = Int32x32To64(-1, 10000000);
/* We'll wait on the periodic timer and also the emergency event */
WaitEvents[0] = &Timer;
WaitEvents[1] = &ExpThreadSetManagerEvent;
WaitEvents[2] = &ExpThreadSetManagerShutdownEvent;
/* Start wait loop */
for (;;)
{
/* Wait for the timer */
KeSetTimer(&Timer, Timeout, NULL);
Status = KeWaitForMultipleObjects(3,
WaitEvents,
WaitAny,
Executive,
KernelMode,
FALSE,
NULL,
NULL);
if (Status == 0)
{
/* Our timer expired. Check for deadlocks */
ExpDetectWorkerThreadDeadlock();
}
else if (Status == 1)
{
/* Someone notified us, verify if we should create a new thread */
ExpCheckDynamicThreadCount();
}
else if (Status == 2)
{
/* We are shutting down. Cancel the timer */
DPRINT1("System shutdown\n");
KeCancelTimer(&Timer);
/* Make sure we have a final thread */
ASSERT(ExpLastWorkerThread);
/* Wait for it */
KeWaitForSingleObject(ExpLastWorkerThread,
Executive,
KernelMode,
FALSE,
NULL);
/* Dereference it and kill us */
ObDereferenceObject(ExpLastWorkerThread);
PsTerminateSystemThread(STATUS_SYSTEM_SHUTDOWN);
}
}
}
/*++
* @name ExpInitializeWorkerThreads
*
* The ExpInitializeWorkerThreads routine initializes worker thread and
* work queue support.
*
* @param None.
*
* @return None.
*
* @remarks This routine is only called once during system initialization.
*
*--*/
VOID
INIT_FUNCTION
NTAPI
ExpInitializeWorkerThreads(VOID)
{
ULONG WorkQueueType;
ULONG CriticalThreads, DelayedThreads;
HANDLE ThreadHandle;
PETHREAD Thread;
ULONG i;
/* Setup the stack swap support */
KeInitializeMutex(&ExpWorkerSwapinMutex, FALSE);
InitializeListHead(&ExpWorkerListHead);
ExpWorkersCanSwap = TRUE;
/* Set the number of critical and delayed threads. We shouldn't hardcode */
DelayedThreads = EX_DELAYED_WORK_THREADS;
CriticalThreads = EX_CRITICAL_WORK_THREADS;
/* Protect against greedy registry modifications */
ExpAdditionalDelayedWorkerThreads =
min(ExpAdditionalDelayedWorkerThreads, 16);
ExpAdditionalCriticalWorkerThreads =
min(ExpAdditionalCriticalWorkerThreads, 16);
/* Calculate final count */
DelayedThreads += ExpAdditionalDelayedWorkerThreads;
CriticalThreads += ExpAdditionalCriticalWorkerThreads;
/* Initialize the Array */
for (WorkQueueType = 0; WorkQueueType < MaximumWorkQueue; WorkQueueType++)
{
/* Clear the structure and initialize the queue */
RtlZeroMemory(&ExWorkerQueue[WorkQueueType], sizeof(EX_WORK_QUEUE));
KeInitializeQueue(&ExWorkerQueue[WorkQueueType].WorkerQueue, 0);
}
/* Dynamic threads are only used for the critical queue */
ExWorkerQueue[CriticalWorkQueue].Info.MakeThreadsAsNecessary = TRUE;
/* Initialize the balance set manager events */
KeInitializeEvent(&ExpThreadSetManagerEvent, SynchronizationEvent, FALSE);
KeInitializeEvent(&ExpThreadSetManagerShutdownEvent,
NotificationEvent,
FALSE);
/* Create the built-in worker threads for the critical queue */
for (i = 0; i < CriticalThreads; i++)
{
/* Create the thread */
ExpCreateWorkerThread(CriticalWorkQueue, FALSE);
ExpCriticalWorkerThreads++;
}
/* Create the built-in worker threads for the delayed queue */
for (i = 0; i < DelayedThreads; i++)
{
/* Create the thread */
ExpCreateWorkerThread(DelayedWorkQueue, FALSE);
ExpDelayedWorkerThreads++;
}
/* Create the built-in worker thread for the hypercritical queue */
ExpCreateWorkerThread(HyperCriticalWorkQueue, FALSE);
/* Create the balance set manager thread */
PsCreateSystemThread(&ThreadHandle,
THREAD_ALL_ACCESS,
NULL,
0,
NULL,
ExpWorkerThreadBalanceManager,
NULL);
/* Get a pointer to it for the shutdown process */
ObReferenceObjectByHandle(ThreadHandle,
THREAD_ALL_ACCESS,
NULL,
KernelMode,
(PVOID*)&Thread,
NULL);
ExpWorkerThreadBalanceManagerPtr = Thread;
/* Close the handle and return */
ZwClose(ThreadHandle);
}
/* PUBLIC FUNCTIONS **********************************************************/
/*++
* @name ExQueueWorkItem
* @implemented NT4
*
* The ExQueueWorkItem routine acquires rundown protection for
* the specified descriptor.
*
* @param WorkItem
* Pointer to an initialized Work Queue Item structure. This structure
* must be located in nonpaged pool memory.
*
* @param QueueType
* Type of the queue to use for this item. Can be one of the following:
* - DelayedWorkQueue
* - CriticalWorkQueue
* - HyperCriticalWorkQueue
*
* @return None.
*
* @remarks This routine is obsolete. Use IoQueueWorkItem instead.
*
* Callers of this routine must be running at IRQL <= DISPATCH_LEVEL.
*
*--*/
VOID
NTAPI
ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
WORK_QUEUE_TYPE QueueType)
{
PEX_WORK_QUEUE WorkQueue = &ExWorkerQueue[QueueType];
ASSERT(QueueType < MaximumWorkQueue);
ASSERT(WorkItem->List.Flink == NULL);
/* Don't try to trick us */
if ((ULONG_PTR)WorkItem->WorkerRoutine < MmUserProbeAddress)
{
/* Bugcheck the system */
KEBUGCHECKEX(WORKER_INVALID,
1,
(ULONG_PTR)WorkItem,
(ULONG_PTR)WorkItem->WorkerRoutine,
0);
}
/* Insert the Queue */
KeInsertQueue(&WorkQueue->WorkerQueue, &WorkItem->List);
ASSERT(!WorkQueue->Info.QueueDisabled);
/*
* Check if we need a new thread. Our decision is as follows:
* - This queue type must support Dynamic Threads (duh!)
* - It actually has to have unprocessed items
* - We have CPUs which could be handling another thread
* - We haven't abused our usage of dynamic threads.
*/
if ((WorkQueue->Info.MakeThreadsAsNecessary) &&
(!IsListEmpty(&WorkQueue->WorkerQueue.EntryListHead)) &&
(WorkQueue->WorkerQueue.CurrentCount <
WorkQueue->WorkerQueue.MaximumCount) &&
(WorkQueue->DynamicThreadCount < 16))
{
/* Let the balance manager know about it */
DPRINT1("Requesting a new thread. CurrentCount: %d. MaxCount: %d\n",
WorkQueue->WorkerQueue.CurrentCount,
WorkQueue->WorkerQueue.MaximumCount);
KeSetEvent(&ExpThreadSetManagerEvent, 0, FALSE);
}
}
/* EOF */

View File

@@ -1,157 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ex/zone.c
* PURPOSE: Implements zone buffers
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* David Welch (welch@mcmail.com)
*/
/* INCLUDES ****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
/* FUNCTIONS ***************************************************************/
/*
* @implemented
*/
NTSTATUS
STDCALL
ExExtendZone(PZONE_HEADER Zone,
PVOID Segment,
ULONG SegmentSize)
{
ULONG_PTR Entry;
ULONG i;
/*
* BlockSize and Segment must be 8-byte aligned.
* Blocksize cannot exceed Segment Size.
*/
if (((ULONG_PTR)Segment & 7) ||
(SegmentSize & 7) ||
(Zone->BlockSize > SegmentSize))
{
DPRINT1("Invalid ExExtendZone Alignment and/or Size\n");
return STATUS_INVALID_PARAMETER;
}
/* Link the Zone and Segment */
PushEntryList(&Zone->SegmentList,
&((PZONE_SEGMENT_HEADER)Segment)->SegmentList);
/* Get to the first entry */
Entry = (ULONG_PTR)Segment + sizeof(ZONE_SEGMENT_HEADER);
/* Loop through the segments */
for (i = sizeof(ZONE_SEGMENT_HEADER);
i <= SegmentSize - Zone->BlockSize;
i+= Zone->BlockSize)
{
/* Link the Free and Segment Lists */
PushEntryList(&Zone->FreeList, (PSINGLE_LIST_ENTRY)Entry);
/* Go to the next entry */
Entry += Zone->BlockSize;
}
/* Update Segment Size */
Zone->TotalSegmentSize += i;
/* Return Success */
return STATUS_SUCCESS;
}
/*
* @implemented
*/
NTSTATUS
STDCALL
ExInterlockedExtendZone(PZONE_HEADER Zone,
PVOID Segment,
ULONG SegmentSize,
PKSPIN_LOCK Lock)
{
NTSTATUS Status;
KIRQL OldIrql;
/* Get the lock */
KeAcquireSpinLock(Lock, &OldIrql);
/* Extend the Zone */
Status = ExExtendZone(Zone, Segment, SegmentSize);
/* Release lock and return status */
KeReleaseSpinLock(Lock, OldIrql);
return Status;
}
/*
* FUNCTION: Initalizes a zone header
* ARGUMENTS:
* Zone = zone header to be initialized
* BlockSize = Size (in bytes) of the allocation size of the zone
* InitialSegment = Initial segment of storage allocated by the
* caller
* InitialSegmentSize = Initial size of the segment
*
* @implemented
*/
NTSTATUS
STDCALL
ExInitializeZone(PZONE_HEADER Zone,
ULONG BlockSize,
PVOID InitialSegment,
ULONG InitialSegmentSize)
{
ULONG i;
ULONG_PTR Entry;
/*
* BlockSize and Segment must be 8-byte aligned.
* Blocksize cannot exceed Segment Size.
*/
if (((ULONG_PTR)InitialSegment & 7) ||
(InitialSegmentSize & 7) ||
(BlockSize > InitialSegmentSize))
{
DPRINT1("Invalid ExInitializeZone Alignment and/or Size\n");
return STATUS_INVALID_PARAMETER;
}
/* Set the Zone Header */
Zone->BlockSize = BlockSize;
/* Link empty list */
Zone->FreeList.Next = NULL;
Zone->SegmentList.Next = NULL;
PushEntryList(&Zone->SegmentList,
&((PZONE_SEGMENT_HEADER)InitialSegment)->SegmentList);
((PZONE_SEGMENT_HEADER)InitialSegment)->Reserved = NULL;
/* Get first entry */
Entry = (ULONG_PTR)InitialSegment + sizeof(ZONE_SEGMENT_HEADER);
/* Loop through the segments */
for (i = sizeof(ZONE_SEGMENT_HEADER);
i <= InitialSegmentSize - BlockSize;
i+= BlockSize)
{
/* Link the Free and Segment Lists */
PushEntryList(&Zone->FreeList, (PSINGLE_LIST_ENTRY)Entry);
/* Go to the next entry */
Entry += Zone->BlockSize;
}
/* Update Segment Size */
Zone->TotalSegmentSize += i;
/* Return success */
return STATUS_SUCCESS;
}
/* EOF */

View File

@@ -1,83 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/fs/context.c
* PURPOSE: File and Stream Context Functions
*
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *******************************************************************/
/* PRIVATE FUNCTIONS**********************************************************/
/* FUNCTIONS *****************************************************************/
/*
* @unimplemented
*/
NTSTATUS
NTAPI
FsRtlInsertPerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER PerStreamContext,
IN PFSRTL_PER_STREAM_CONTEXT Ptr)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
PFSRTL_PER_STREAM_CONTEXT
NTAPI
FsRtlRemovePerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER StreamContext,
IN PVOID OwnerId OPTIONAL,
IN PVOID InstanceId OPTIONAL)
{
UNIMPLEMENTED;
return NULL;
}
/*
* @unimplemented
*/
NTSTATUS
NTAPI
FsRtlInsertPerFileObjectContext(IN PFSRTL_ADVANCED_FCB_HEADER PerFileObjectContext,
IN PVOID /* PFSRTL_PER_FILE_OBJECT_CONTEXT*/ Ptr)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
/*
* @unimplemented
*/
PVOID /* PFSRTL_PER_FILE_OBJECT_CONTEXT*/
NTAPI
FsRtlRemovePerFileObjectContext(IN PFSRTL_ADVANCED_FCB_HEADER PerFileObjectContext,
IN PVOID OwnerId OPTIONAL,
IN PVOID InstanceId OPTIONAL)
{
UNIMPLEMENTED;
return NULL;
}
/*
* @unimplemented
*/
VOID
NTAPI
FsRtlTeardownPerStreamContexts(IN PFSRTL_ADVANCED_FCB_HEADER AdvancedHeader)
{
UNIMPLEMENTED;
}
/* EOF */

View File

@@ -1,515 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/fs/fastio.c
* PURPOSE: File System Routines which support Fast I/O or Cc Access.
*
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
*/
/* INCLUDES ****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *******************************************************************/
extern ULONG CcFastReadNotPossible;
extern ULONG CcFastReadResourceMiss;
extern ULONG CcFastReadWait;
extern ULONG CcFastReadNoWait;
/* FUNCTIONS *****************************************************************/
/*
* @implemented
*/
VOID
STDCALL
FsRtlIncrementCcFastReadResourceMiss( VOID )
{
CcFastReadResourceMiss++;
}
/*
* @implemented
*/
VOID
STDCALL
FsRtlIncrementCcFastReadNotPossible( VOID )
{
CcFastReadNotPossible++;
}
/*
* @implemented
*/
VOID
STDCALL
FsRtlIncrementCcFastReadWait( VOID )
{
CcFastReadWait++;
}
/*
* @implemented
*/
VOID
STDCALL
FsRtlIncrementCcFastReadNoWait( VOID )
{
CcFastReadNoWait++;
}
/*
* NAME EXPORTED
* FsRtlCopyRead@32
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* NOTE
* From Bo Branten's ntifs.h v12.
*
* @unimplemented
*/
BOOLEAN
STDCALL
FsRtlCopyRead(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN ULONG LockKey,
OUT PVOID Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* NAME EXPORTED
* FsRtlCopyWrite@32
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* NOTE
* From Bo Branten's ntifs.h v12.
*
* @unimplemented
*/
BOOLEAN
STDCALL
FsRtlCopyWrite(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN ULONG LockKey,
OUT PVOID Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* NAME EXPORTED
* FsRtlGetFileSize@8
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @implemented
*/
NTSTATUS
STDCALL
FsRtlGetFileSize(IN PFILE_OBJECT FileObject,
IN OUT PLARGE_INTEGER FileSize)
{
FILE_STANDARD_INFORMATION Info;
NTSTATUS Status;
IO_STATUS_BLOCK IoStatusBlock;
ULONG Length;
PDEVICE_OBJECT DeviceObject;
PFAST_IO_DISPATCH FastDispatch;
/* Get Device Object and Fast Calls */
DeviceObject = IoGetRelatedDeviceObject(FileObject);
FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
/* Check if we support Fast Calls, and check this one */
if (FastDispatch && FastDispatch->FastIoQueryStandardInfo)
{
/* Fast Path */
FastDispatch->FastIoQueryStandardInfo(FileObject,
TRUE,
&Info,
&IoStatusBlock,
DeviceObject);
Status = IoStatusBlock.Status;
}
else
{
/* Slow Path */
Status = IoQueryFileInformation(FileObject,
FileStandardInformation,
sizeof(Info),
&Info,
&Length);
}
/* Check success */
if (NT_SUCCESS(Status))
{
*FileSize = Info.EndOfFile;
}
/* Return status */
return Status;
}
/*
* NAME EXPORTED
* FsRtlMdlRead@24
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @implemented
*/
BOOLEAN
STDCALL
FsRtlMdlRead(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG LockKey,
OUT PMDL *MdlChain,
OUT PIO_STATUS_BLOCK IoStatus)
{
PDEVICE_OBJECT DeviceObject, BaseDeviceObject;
PFAST_IO_DISPATCH FastDispatch;
/* Get Device Object and Fast Calls */
DeviceObject = IoGetRelatedDeviceObject(FileObject);
FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
/* Check if we support Fast Calls, and check this one */
if (FastDispatch && FastDispatch->MdlRead)
{
/* Use the fast path */
return FastDispatch->MdlRead(FileObject,
FileOffset,
Length,
LockKey,
MdlChain,
IoStatus,
DeviceObject);
}
/* Get the Base File System (Volume) and Fast Calls */
BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch;
/* If the Base Device Object has its own FastDispatch Routine, fail */
if (FastDispatch && FastDispatch->MdlRead &&
BaseDeviceObject != DeviceObject)
{
return FALSE;
}
/* No fast path, use slow path */
return FsRtlMdlReadDev(FileObject,
FileOffset,
Length,
LockKey,
MdlChain,
IoStatus,
DeviceObject);
}
/*
* NAME EXPORTED
* FsRtlMdlReadComplete@8
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @implemented
*/
BOOLEAN
STDCALL
FsRtlMdlReadComplete(IN PFILE_OBJECT FileObject,
IN OUT PMDL MdlChain)
{
PDEVICE_OBJECT DeviceObject, BaseDeviceObject;
PFAST_IO_DISPATCH FastDispatch;
/* Get Device Object and Fast Calls */
DeviceObject = IoGetRelatedDeviceObject(FileObject);
FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
/* Check if we support Fast Calls, and check this one */
if (FastDispatch && FastDispatch->MdlReadComplete)
{
/* Use the fast path */
return FastDispatch->MdlReadComplete(FileObject,
MdlChain,
DeviceObject);
}
/* Get the Base File System (Volume) and Fast Calls */
BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch;
/* If the Base Device Object has its own FastDispatch Routine, fail */
if (FastDispatch && FastDispatch->MdlReadComplete &&
BaseDeviceObject != DeviceObject)
{
return FALSE;
}
/* No fast path, use slow path */
return FsRtlMdlReadCompleteDev(FileObject, MdlChain, DeviceObject);
}
/*
* NAME EXPORTED
* FsRtlMdlReadCompleteDev@12
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* NOTE
* From Bo Branten's ntifs.h v13.
* (CcMdlReadCompleteDev declared in internal/cc.h)
*
* @implemented
*/
BOOLEAN
STDCALL
FsRtlMdlReadCompleteDev(IN PFILE_OBJECT FileObject,
IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject)
{
/* Call the Cache Manager */
CcMdlReadCompleteDev(MdlChain, FileObject);
return TRUE;
}
/*
* NAME EXPORTED
* FsRtlMdlReadDev@28
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @unimplemented
*/
BOOLEAN
STDCALL
FsRtlMdlReadDev(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG LockKey,
OUT PMDL *MdlChain,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* NAME EXPORTED
* FsRtlMdlWriteComplete@12
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @implemented
*/
BOOLEAN
STDCALL
FsRtlMdlWriteComplete(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain)
{
PDEVICE_OBJECT DeviceObject, BaseDeviceObject;
PFAST_IO_DISPATCH FastDispatch;
/* Get Device Object and Fast Calls */
DeviceObject = IoGetRelatedDeviceObject(FileObject);
FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
/* Check if we support Fast Calls, and check this one */
if (FastDispatch && FastDispatch->MdlWriteComplete)
{
/* Use the fast path */
return FastDispatch->MdlWriteComplete(FileObject,
FileOffset,
MdlChain,
DeviceObject);
}
/* Get the Base File System (Volume) and Fast Calls */
BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch;
/* If the Base Device Object has its own FastDispatch Routine, fail */
if (FastDispatch && FastDispatch->MdlWriteComplete &&
BaseDeviceObject != DeviceObject)
{
return FALSE;
}
/* No fast path, use slow path */
return FsRtlMdlWriteCompleteDev(FileObject,
FileOffset,
MdlChain,
DeviceObject);
}
/*
* NAME EXPORTED
* FsRtlMdlWriteCompleteDev@16
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @implemented
*/
BOOLEAN
STDCALL
FsRtlMdlWriteCompleteDev(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject)
{
/* Call the Cache Manager */
CcMdlWriteCompleteDev(FileOffset, MdlChain, FileObject);
return TRUE;
}
/*
* NAME EXPORTED
* FsRtlPrepareMdlWrite@24
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @implemented
*/
BOOLEAN
STDCALL
FsRtlPrepareMdlWrite(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG LockKey,
OUT PMDL *MdlChain,
OUT PIO_STATUS_BLOCK IoStatus)
{
PDEVICE_OBJECT DeviceObject, BaseDeviceObject;
PFAST_IO_DISPATCH FastDispatch;
/* Get Device Object and Fast Calls */
DeviceObject = IoGetRelatedDeviceObject(FileObject);
FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
/* Check if we support Fast Calls, and check this one */
if (FastDispatch && FastDispatch->PrepareMdlWrite)
{
/* Use the fast path */
return FastDispatch->PrepareMdlWrite(FileObject,
FileOffset,
Length,
LockKey,
MdlChain,
IoStatus,
DeviceObject);
}
/* Get the Base File System (Volume) and Fast Calls */
BaseDeviceObject = IoGetBaseFileSystemDeviceObject(FileObject);
FastDispatch = BaseDeviceObject->DriverObject->FastIoDispatch;
/* If the Base Device Object has its own FastDispatch Routine, fail */
if (FastDispatch && FastDispatch->PrepareMdlWrite &&
BaseDeviceObject != DeviceObject)
{
return FALSE;
}
/* No fast path, use slow path */
return FsRtlPrepareMdlWriteDev(FileObject,
FileOffset,
Length,
LockKey,
MdlChain,
IoStatus,
DeviceObject);
}
/*
* NAME EXPORTED
* FsRtlPrepareMdlWriteDev@28
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* @unimplemented
*/
BOOLEAN
STDCALL
FsRtlPrepareMdlWriteDev(IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG LockKey,
OUT PMDL *MdlChain,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject)
{
UNIMPLEMENTED;
return FALSE;
}
/* EOF */

File diff suppressed because it is too large Load Diff

View File

@@ -1,391 +0,0 @@
/* $Id$
*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/fs/mcb.c
* PURPOSE: No purpose listed.
*
* PROGRAMMERS: No programmer listed.
*/
/* INCLUDES ****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
/**********************************************************************
* NAME EXPORTED
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
*
* NOTES
*
* @unimplemented
*/
BOOLEAN
NTAPI
FsRtlAddLargeMcbEntry(IN PLARGE_MCB Mcb,
IN LONGLONG Vbn,
IN LONGLONG Lbn,
IN LONGLONG SectorCount)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* FsRtlAddMcbEntry: Obsolete
*
* @implemented
*/
BOOLEAN
NTAPI
FsRtlAddMcbEntry(IN PMCB Mcb,
IN VBN Vbn,
IN LBN Lbn,
IN ULONG SectorCount)
{
return FsRtlAddLargeMcbEntry(&Mcb->DummyFieldThatSizesThisStructureCorrectly,
(LONGLONG)Vbn,
(LONGLONG)Lbn,
(LONGLONG)SectorCount);
}
/*
* @unimplemented
*/
BOOLEAN
NTAPI
FsRtlGetNextLargeMcbEntry(IN PLARGE_MCB Mcb,
IN ULONG RunIndex,
OUT PLONGLONG Vbn,
OUT PLONGLONG Lbn,
OUT PLONGLONG SectorCount)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @implemented
*/
BOOLEAN
NTAPI
FsRtlGetNextMcbEntry(IN PMCB Mcb,
IN ULONG RunIndex,
OUT PVBN Vbn,
OUT PLBN Lbn,
OUT PULONG SectorCount)
{
BOOLEAN Return = FALSE;
LONGLONG llVbn;
LONGLONG llLbn;
LONGLONG llSectorCount;
/* Call the Large version */
Return = FsRtlGetNextLargeMcbEntry(&Mcb->DummyFieldThatSizesThisStructureCorrectly,
RunIndex,
&llVbn,
&llLbn,
&llSectorCount);
/* Return everything typecasted */
*Vbn = (ULONG)llVbn;
*Lbn = (ULONG)llLbn;
*SectorCount = (ULONG)llSectorCount;
/* And return the original value */
return(Return);
}
/*
* @unimplemented
*/
VOID
NTAPI
FsRtlInitializeLargeMcb(IN PLARGE_MCB Mcb,
IN POOL_TYPE PoolType)
{
UNIMPLEMENTED;
Mcb->PoolType = PoolType;
}
/*
* FsRtlInitializeMcb: Obsolete
* @implemented
*/
VOID
NTAPI
FsRtlInitializeMcb (IN PMCB Mcb,
IN POOL_TYPE PoolType)
{
FsRtlInitializeLargeMcb(& Mcb->DummyFieldThatSizesThisStructureCorrectly, PoolType);
}
/*
* @unimplemented
*/
BOOLEAN
NTAPI
FsRtlLookupLargeMcbEntry(IN PLARGE_MCB Mcb,
IN LONGLONG Vbn,
OUT PLONGLONG Lbn OPTIONAL,
OUT PLONGLONG SectorCountFromLbn OPTIONAL,
OUT PLONGLONG StartingLbn OPTIONAL,
OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL,
OUT PULONG Index OPTIONAL)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented
*/
BOOLEAN
NTAPI
FsRtlLookupLastLargeMcbEntryAndIndex(IN PLARGE_MCB OpaqueMcb,
OUT PLONGLONG LargeVbn,
OUT PLONGLONG LargeLbn,
OUT PULONG Index)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented
*/
PFSRTL_PER_STREAM_CONTEXT
NTAPI
FsRtlLookupPerStreamContextInternal(IN PFSRTL_ADVANCED_FCB_HEADER StreamContext,
IN PVOID OwnerId OPTIONAL,
IN PVOID InstanceId OPTIONAL)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented
*/
PVOID /* PFSRTL_PER_FILE_OBJECT_CONTEXT*/
NTAPI
FsRtlLookupPerFileObjectContext(IN PFSRTL_ADVANCED_FCB_HEADER StreamContext,
IN PVOID OwnerId OPTIONAL,
IN PVOID InstanceId OPTIONAL)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented
*/
BOOLEAN
NTAPI
FsRtlLookupLastLargeMcbEntry(IN PLARGE_MCB Mcb,
OUT PLONGLONG Vbn,
OUT PLONGLONG Lbn)
{
UNIMPLEMENTED;
return(FALSE);
}
/*
* @implemented
*/
BOOLEAN
NTAPI
FsRtlLookupLastMcbEntry(IN PMCB Mcb,
OUT PVBN Vbn,
OUT PLBN Lbn)
{
BOOLEAN Return = FALSE;
LONGLONG llVbn;
LONGLONG llLbn;
/* Call the Large version */
Return = FsRtlLookupLastLargeMcbEntry(&Mcb->DummyFieldThatSizesThisStructureCorrectly,
&llVbn,
&llLbn);
/* Return everything typecasted */
*Vbn = (ULONG)llVbn;
*Lbn = (ULONG)llLbn;
/* And return the original value */
return(Return);
}
/*
* @implemented
*/
BOOLEAN
NTAPI
FsRtlLookupMcbEntry(IN PMCB Mcb,
IN VBN Vbn,
OUT PLBN Lbn,
OUT PULONG SectorCount OPTIONAL,
OUT PULONG Index)
{
BOOLEAN Return = FALSE;
LONGLONG llLbn;
LONGLONG llSectorCount;
/* Call the Large version */
Return = FsRtlLookupLargeMcbEntry(&Mcb->DummyFieldThatSizesThisStructureCorrectly,
(LONGLONG)Vbn,
&llLbn,
&llSectorCount,
NULL,
NULL,
Index);
/* Return everything typecasted */
*Lbn = (ULONG)llLbn;
if (SectorCount) *SectorCount = (ULONG)llSectorCount;
/* And return the original value */
return(Return);
}
/*
* @implemented
*/
ULONG
NTAPI
FsRtlNumberOfRunsInLargeMcb(IN PLARGE_MCB Mcb)
{
ULONG NumberOfRuns;
ExAcquireFastMutex(Mcb->FastMutex);
NumberOfRuns = Mcb->PairCount;
ExReleaseFastMutex(Mcb->FastMutex);
return NumberOfRuns;
}
/*
* FsRtlNumberOfRunsInMcb: Obsolete
*
* @implemented
*/
ULONG
NTAPI
FsRtlNumberOfRunsInMcb (IN PMCB Mcb)
{
return FsRtlNumberOfRunsInLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly);
}
/*
* @unimplemented
*/
VOID
NTAPI
FsRtlRemoveLargeMcbEntry(IN PLARGE_MCB Mcb,
IN LONGLONG Vbn,
IN LONGLONG SectorCount)
{
UNIMPLEMENTED;
}
/*
* @implemented
*/
VOID
NTAPI
FsRtlRemoveMcbEntry(IN PMCB Mcb,
IN VBN Vbn,
IN ULONG SectorCount)
{
/* Call the large function */
return FsRtlRemoveLargeMcbEntry(&Mcb->DummyFieldThatSizesThisStructureCorrectly,
(LONGLONG)Vbn,
(LONGLONG)SectorCount);
}
/*
* @unimplemented
*/
VOID
NTAPI
FsRtlResetLargeMcb(IN PLARGE_MCB Mcb,
IN BOOLEAN SelfSynchronized)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
BOOLEAN
NTAPI
FsRtlSplitLargeMcb(IN PLARGE_MCB Mcb,
IN LONGLONG Vbn,
IN LONGLONG Amount)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented
*/
VOID
NTAPI
FsRtlTruncateLargeMcb(IN PLARGE_MCB Mcb,
IN LONGLONG Vbn)
{
UNIMPLEMENTED;
}
/*
* FsRtlTruncateMcb: Obsolete
*
* @implemented
*/
VOID
NTAPI
FsRtlTruncateMcb (IN PMCB Mcb,
IN VBN Vbn)
{
FsRtlTruncateLargeMcb(&Mcb->DummyFieldThatSizesThisStructureCorrectly, (LONGLONG)Vbn);
}
/*
* @unimplemented
*/
VOID
NTAPI
FsRtlUninitializeLargeMcb(IN PLARGE_MCB Mcb)
{
UNIMPLEMENTED;
}
/*
* FsRtlUninitializeMcb: Obsolete
*
* @implemented
*/
VOID
NTAPI
FsRtlUninitializeMcb(IN PMCB Mcb)
{
FsRtlUninitializeLargeMcb(& Mcb->DummyFieldThatSizesThisStructureCorrectly);
}
/* EOF */

View File

@@ -1,655 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/fs/name.c
* PURPOSE: Name and DBCS Name Validation and Dissection Functions.
*
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* Eric Kohl
* Filip Navara
*/
/* INCLUDES ****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *******************************************************************/
static UCHAR LegalAnsiCharacterArray[] =
{
0, /* CTRL+@, 0x00 */
0, /* CTRL+A, 0x01 */
0, /* CTRL+B, 0x02 */
0, /* CTRL+C, 0x03 */
0, /* CTRL+D, 0x04 */
0, /* CTRL+E, 0x05 */
0, /* CTRL+F, 0x06 */
0, /* CTRL+G, 0x07 */
0, /* CTRL+H, 0x08 */
0, /* CTRL+I, 0x09 */
0, /* CTRL+J, 0x0a */
0, /* CTRL+K, 0x0b */
0, /* CTRL+L, 0x0c */
0, /* CTRL+M, 0x0d */
0, /* CTRL+N, 0x0e */
0, /* CTRL+O, 0x0f */
0, /* CTRL+P, 0x10 */
0, /* CTRL+Q, 0x11 */
0, /* CTRL+R, 0x12 */
0, /* CTRL+S, 0x13 */
0, /* CTRL+T, 0x14 */
0, /* CTRL+U, 0x15 */
0, /* CTRL+V, 0x16 */
0, /* CTRL+W, 0x17 */
0, /* CTRL+X, 0x18 */
0, /* CTRL+Y, 0x19 */
0, /* CTRL+Z, 0x1a */
0, /* CTRL+[, 0x1b */
0, /* CTRL+\, 0x1c */
0, /* CTRL+], 0x1d */
0, /* CTRL+^, 0x1e */
0, /* CTRL+_, 0x1f */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* ` ', 0x20 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `!', 0x21 */
FSRTL_WILD_CHARACTER, /* `"', 0x22 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `#', 0x23 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `$', 0x24 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `%', 0x25 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `&', 0x26 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `'', 0x27 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `(', 0x28 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `)', 0x29 */
FSRTL_WILD_CHARACTER, /* `*', 0x2a */
FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `+', 0x2b */
FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `,', 0x2c */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `-', 0x2d */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `.', 0x2e */
0, /* `/', 0x2f */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `0', 0x30 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `1', 0x31 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `2', 0x32 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `3', 0x33 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `4', 0x34 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `5', 0x35 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `6', 0x36 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `7', 0x37 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `8', 0x38 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `9', 0x39 */
FSRTL_NTFS_LEGAL, /* `:', 0x3a */
FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `;', 0x3b */
FSRTL_WILD_CHARACTER, /* `<', 0x3c */
FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `=', 0x3d */
FSRTL_WILD_CHARACTER, /* `>', 0x3e */
FSRTL_WILD_CHARACTER, /* `?', 0x3f */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `@', 0x40 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `A', 0x41 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `B', 0x42 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `C', 0x43 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `D', 0x44 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `E', 0x45 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `F', 0x46 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `G', 0x47 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `H', 0x48 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `I', 0x49 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `J', 0x4a */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `K', 0x4b */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `L', 0x4c */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `M', 0x4d */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `N', 0x4e */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `O', 0x4f */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `P', 0x50 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `Q', 0x51 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `R', 0x52 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `S', 0x53 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `T', 0x54 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `U', 0x55 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `V', 0x56 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `W', 0x57 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `X', 0x58 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `Y', 0x59 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `Z', 0x5a */
FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `[', 0x5b */
0, /* `\', 0x5c */
FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `]', 0x5d */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `^', 0x5e */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `_', 0x5f */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* ``', 0x60 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `a', 0x61 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `b', 0x62 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `c', 0x63 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `d', 0x64 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `e', 0x65 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `f', 0x66 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `g', 0x67 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `h', 0x68 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `i', 0x69 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `j', 0x6a */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `k', 0x6b */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `l', 0x6c */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `m', 0x6d */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `n', 0x6e */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `o', 0x6f */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `p', 0x70 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `q', 0x71 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `r', 0x72 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `s', 0x73 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `t', 0x74 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `u', 0x75 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `v', 0x76 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `w', 0x77 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `x', 0x78 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `y', 0x79 */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `z', 0x7a */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `{', 0x7b */
0, /* `|', 0x7c */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `}', 0x7d */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL, /* `~', 0x7e */
FSRTL_FAT_LEGAL | FSRTL_HPFS_LEGAL | FSRTL_NTFS_LEGAL /* 0x7f */
};
PUCHAR FsRtlLegalAnsiCharacterArray = LegalAnsiCharacterArray;
/* FUNCTIONS *****************************************************************/
/*++
* @name FsRtlAreNamesEqual
* @implemented
*
* FILLME
*
* @param Name1
* FILLME
*
* @param Name2
* FILLME
*
* @param IgnoreCase
* FILLME
*
* @param UpcaseTable
* FILLME
*
* @return None
*
* @remarks From Bo Branten's ntifs.h v25.
*
*--*/
BOOLEAN
NTAPI
FsRtlAreNamesEqual(IN PUNICODE_STRING Name1,
IN PUNICODE_STRING Name2,
IN BOOLEAN IgnoreCase,
IN PWCHAR UpcaseTable OPTIONAL)
{
UNICODE_STRING UpcaseName1;
UNICODE_STRING UpcaseName2;
BOOLEAN StringsAreEqual;
/* Well, first check their size */
if (Name1->Length != Name2->Length) {
/* Not equal! */
return FALSE;
}
/* Turn them into Upcase if we don't have a table */
if (IgnoreCase && !UpcaseTable) {
RtlUpcaseUnicodeString(&UpcaseName1, Name1, TRUE);
RtlUpcaseUnicodeString(&UpcaseName2, Name2, TRUE);
Name1 = &UpcaseName1;
Name2 = &UpcaseName2;
goto ManualCase;
}
/* Do a case-sensitive search */
if (!IgnoreCase) {
ManualCase:
/* Use a raw memory compare */
StringsAreEqual = RtlEqualMemory(Name1->Buffer,
Name2->Buffer,
Name1->Length);
/* Clear the strings if we need to */
if (IgnoreCase) {
RtlFreeUnicodeString(&UpcaseName1);
RtlFreeUnicodeString(&UpcaseName2);
}
/* Return the equality */
return StringsAreEqual;
} else {
/* Case in-sensitive search */
LONG i;
for (i = Name1->Length / sizeof(WCHAR) - 1; i >= 0; i--) {
if (UpcaseTable[Name1->Buffer[i]] != UpcaseTable[Name2->Buffer[i]]) {
/* Non-match found! */
return FALSE;
}
}
/* We finished the loop so we are equal */
return TRUE;
}
}
/*++
* @name FsRtlDissectDbcs
* @implemented
*
* Dissects a given path name into first and remaining part.
*
* @param Name
* ANSI string to dissect.
*
* @param FirstPart
* Pointer to user supplied ANSI_STRING, that will later point
* to the first part of the original name.
*
* @param RemainingPart
* Pointer to user supplied ANSI_STRING, that will later point
* to the remaining part of the original name.
*
* @return None
*
* @remarks Example:
* Name: \test1\test2\test3
* FirstPart: test1
* RemainingPart: test2\test3
*
*--*/
VOID
NTAPI
FsRtlDissectDbcs(IN ANSI_STRING Name,
OUT PANSI_STRING FirstPart,
OUT PANSI_STRING RemainingPart)
{
ULONG i;
ULONG FirstLoop;
/* Initialize the Outputs */
RtlZeroMemory(&FirstPart, sizeof(ANSI_STRING));
RtlZeroMemory(&RemainingPart, sizeof(ANSI_STRING));
/* Bail out if empty */
if (!Name.Length) return;
/* Ignore backslash */
if (Name.Buffer[0] == '\\') {
i = 1;
} else {
i = 0;
}
/* Loop until we find a backslash */
for (FirstLoop = i;i < Name.Length;i++) {
if (Name.Buffer[i] != '\\') break;
if (FsRtlIsLeadDbcsCharacter(Name.Buffer[i])) i++;
}
/* Now we have the First Part */
FirstPart->Length = (i-FirstLoop);
FirstPart->MaximumLength = FirstPart->Length; /* +2?? */
FirstPart->Buffer = &Name.Buffer[FirstLoop];
/* Make the second part if something is still left */
if (i<Name.Length) {
RemainingPart->Length = (Name.Length - (i+1));
RemainingPart->MaximumLength = RemainingPart->Length; /* +2?? */
RemainingPart->Buffer = &Name.Buffer[i+1];
}
return;
}
/*++
* @name FsRtlDissectName
* @implemented
*
* Dissects a given path name into first and remaining part.
*
* @param Name
* Unicode string to dissect.
*
* @param FirstPart
* Pointer to user supplied UNICODE_STRING, that will later point
* to the first part of the original name.
*
* @param RemainingPart
* Pointer to user supplied UNICODE_STRING, that will later point
* to the remaining part of the original name.
*
* @return None
*
* @remarks Example:
* Name: \test1\test2\test3
* FirstPart: test1
* RemainingPart: test2\test3
*
*--*/
VOID
NTAPI
FsRtlDissectName(IN UNICODE_STRING Name,
OUT PUNICODE_STRING FirstPart,
OUT PUNICODE_STRING RemainingPart)
{
USHORT NameOffset = 0;
USHORT NameLength = 0;
USHORT Length;
FirstPart->Length = 0;
FirstPart->MaximumLength = 0;
FirstPart->Buffer = NULL;
RemainingPart->Length = 0;
RemainingPart->MaximumLength = 0;
RemainingPart->Buffer = NULL;
if (Name.Length == 0)
return;
/* Skip leading backslash */
if (Name.Buffer[0] == L'\\')
NameOffset++;
Length = Name.Length / sizeof(WCHAR);
/* Search for next backslash or end-of-string */
while ((NameOffset + NameLength < Length) &&
(Name.Buffer[NameOffset + NameLength] != L'\\'))
{
NameLength++;
}
FirstPart->Length =
FirstPart->MaximumLength = NameLength * sizeof(WCHAR);
FirstPart->Buffer = &Name.Buffer[NameOffset];
NameOffset += NameLength + 1;
if (NameOffset < Length)
{
RemainingPart->Length = (Length - NameOffset) * sizeof(WCHAR);
RemainingPart->MaximumLength = (Length - NameOffset) * sizeof(WCHAR);
RemainingPart->Buffer = &Name.Buffer[NameOffset];
}
}
/*++
* @name FsRtlDoesDbcsContainWildCards
* @implemented
*
* FILLME
*
* @param Name
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
BOOLEAN
NTAPI
FsRtlDoesDbcsContainWildCards(IN PANSI_STRING Name)
{
ULONG i;
/* Check every character */
for (i=0;i < Name->Length;i++) {
/* First make sure it's not the Lead DBCS */
if (FsRtlIsLeadDbcsCharacter(Name->Buffer[i])) {
i++;
} else if (FsRtlIsAnsiCharacterWild(Name->Buffer[i])) {
/* Now return if it has a Wilcard */
return TRUE;
}
}
/* We didn't return above...so none found */
return FALSE;
}
/*++
* @name FsRtlDoesNameContainWildCards
* @implemented
*
* FILLME
*
* @param Name
* Pointer to a UNICODE_STRING containing Name to examine
*
* @return TRUE if Name contains wildcards, FALSE otherwise
*
* @remarks From Bo Branten's ntifs.h v12.
*
*--*/
BOOLEAN
NTAPI
FsRtlDoesNameContainWildCards(IN PUNICODE_STRING Name)
{
PWCHAR Ptr;
/* Loop through every character */
if (Name->Length) {
for (Ptr = Name->Buffer + (Name->Length / sizeof(WCHAR))-1;
Ptr >= Name->Buffer && *Ptr != L'\\';Ptr--) {
/* Check for Wildcard */
if (FsRtlIsUnicodeCharacterWild(*Ptr)) {
return TRUE;
}
}
}
/* Nothing Found */
return FALSE;
}
/*++
* @name FsRtlIsDbcsInExpression
* @unimplemented
*
* FILLME
*
* @param Expression
* FILLME
*
* @param Name
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
BOOLEAN
NTAPI
FsRtlIsDbcsInExpression(IN PANSI_STRING Expression,
IN PANSI_STRING Name)
{
UNIMPLEMENTED;
return FALSE;
}
/*++
* @name FsRtlIsFatDbcsLegal
* @unimplemented
*
* FILLME
*
* @param DbcsName
* FILLME
*
* @param WildCardsPermissible
* FILLME
*
* @param PathNamePermissible
* FILLME
*
* @param LeadingBackslashPermissible
* FILLME
*
* @return TRUE if the DbcsName is legal, FALSE otherwise
*
* @remarks None
*
*--*/
BOOLEAN
NTAPI
FsRtlIsFatDbcsLegal(IN ANSI_STRING DbcsName,
IN BOOLEAN WildCardsPermissible,
IN BOOLEAN PathNamePermissible,
IN BOOLEAN LeadingBackslashPermissible)
{
UNIMPLEMENTED;
return FALSE;
}
/*++
* @name FsRtlIsHpfsDbcsLegal
* @unimplemented
*
* FILLME
*
* @param DbcsName
* FILLME
*
* @param WildCardsPermissible
* FILLME
*
* @param PathNamePermissible
* FILLME
*
* @param LeadingBackslashPermissible
* FILLME
*
* @return TRUE if the DbcsName is legal, FALSE otherwise
*
* @remarks None
*
*--*/
BOOLEAN
STDCALL
FsRtlIsHpfsDbcsLegal(IN ANSI_STRING DbcsName,
IN BOOLEAN WildCardsPermissible,
IN BOOLEAN PathNamePermissible,
IN BOOLEAN LeadingBackslashPermissible)
{
UNIMPLEMENTED;
return FALSE;
}
/*++
* @name FsRtlIsNameInExpression
* @implemented
*
* FILLME
*
* @param DeviceObject
* FILLME
*
* @param Irp
* FILLME
*
* @return TRUE if Name is in Expression, FALSE otherwise
*
* @remarks From Bo Branten's ntifs.h v12. This function should be
* rewritten to avoid recursion and better wildcard handling
* should be implemented (see FsRtlDoesNameContainWildCards).
*
*--*/
BOOLEAN
NTAPI
FsRtlIsNameInExpression(IN PUNICODE_STRING Expression,
IN PUNICODE_STRING Name,
IN BOOLEAN IgnoreCase,
IN PWCHAR UpcaseTable OPTIONAL)
{
USHORT ExpressionPosition, NamePosition;
UNICODE_STRING TempExpression, TempName;
ExpressionPosition = 0;
NamePosition = 0;
while (ExpressionPosition < (Expression->Length / sizeof(WCHAR)) &&
NamePosition < (Name->Length / sizeof(WCHAR)))
{
if (Expression->Buffer[ExpressionPosition] == L'*')
{
ExpressionPosition++;
if (ExpressionPosition == (Expression->Length / sizeof(WCHAR)))
{
return TRUE;
}
while (NamePosition < (Name->Length / sizeof(WCHAR)))
{
TempExpression.Length =
TempExpression.MaximumLength =
Expression->Length - (ExpressionPosition * sizeof(WCHAR));
TempExpression.Buffer = Expression->Buffer + ExpressionPosition;
TempName.Length =
TempName.MaximumLength =
Name->Length - (NamePosition * sizeof(WCHAR));
TempName.Buffer = Name->Buffer + NamePosition;
/* FIXME: Rewrite to get rid of recursion */
if (FsRtlIsNameInExpression(&TempExpression, &TempName,
IgnoreCase, UpcaseTable))
{
return TRUE;
}
NamePosition++;
}
}
else
{
/* FIXME: Take UpcaseTable into account! */
if (Expression->Buffer[ExpressionPosition] == L'?' ||
(IgnoreCase &&
RtlUpcaseUnicodeChar(Expression->Buffer[ExpressionPosition]) ==
RtlUpcaseUnicodeChar(Name->Buffer[NamePosition])) ||
(!IgnoreCase &&
Expression->Buffer[ExpressionPosition] ==
Name->Buffer[NamePosition]))
{
NamePosition++;
ExpressionPosition++;
}
else
{
return FALSE;
}
}
}
/* Handle matching of "f0_*.*" expression to "f0_000" file name. */
if (ExpressionPosition < (Expression->Length / sizeof(WCHAR)) &&
Expression->Buffer[ExpressionPosition] == L'.')
{
while (ExpressionPosition < (Expression->Length / sizeof(WCHAR)) &&
(Expression->Buffer[ExpressionPosition] == L'.' ||
Expression->Buffer[ExpressionPosition] == L'*' ||
Expression->Buffer[ExpressionPosition] == L'?'))
{
ExpressionPosition++;
}
}
if (ExpressionPosition == (Expression->Length / sizeof(WCHAR)) &&
NamePosition == (Name->Length / sizeof(WCHAR)))
{
return TRUE;
}
return FALSE;
}
/* EOF */

File diff suppressed because it is too large Load Diff

View File

@@ -1,175 +0,0 @@
/* $Id$
*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/fs/oplock.c
* PURPOSE: Oplock-functions
*
* PROGRAMMERS: Emanuele Aliberti
* Eric Kohl
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
/*++
* @name FsRtlCheckOplock
* @unimplemented
*
* FILLME
*
* @param Oplock
* FILLME
*
* @param Irp
* FILLME
*
* @param Context
* FILLME
*
* @param CompletionRoutine
* FILLME
*
* @param PostIrpRoutine
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
NTSTATUS
NTAPI
FsRtlCheckOplock(IN POPLOCK Oplock,
IN PIRP Irp,
IN PVOID Context,
IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL,
IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
/*++
* @name FsRtlCurrentBatchOplock
* @unimplemented
*
* FILLME
*
* @param Oplock
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
BOOLEAN
NTAPI
FsRtlCurrentBatchOplock(IN POPLOCK Oplock)
{
UNIMPLEMENTED;
return FALSE;
}
/*++
* @name FsRtlInitializeOplock
* @unimplemented
*
* FILLME
*
* @param Oplock
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
FsRtlInitializeOplock(IN OUT POPLOCK Oplock)
{
UNIMPLEMENTED;
}
/*++
* @name FsRtlOplockFsctrl
* @unimplemented
*
* FILLME
*
* @param Oplock
* FILLME
*
* @param Irp
* FILLME
*
* @param OpenCount
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
NTSTATUS
NTAPI
FsRtlOplockFsctrl(IN POPLOCK Oplock,
IN PIRP Irp,
IN ULONG OpenCount)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
/*++
* @name FsRtlOplockIsFastIoPossible
* @unimplemented
*
* FILLME
*
* @param Oplock
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
BOOLEAN
NTAPI
FsRtlOplockIsFastIoPossible(IN POPLOCK Oplock)
{
UNIMPLEMENTED;
return FALSE;
}
/*++
* @name FsRtlUninitializeOplock
* @unimplemented
*
* FILLME
*
* @param Oplock
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
FsRtlUninitializeOplock(IN POPLOCK Oplock)
{
UNIMPLEMENTED;
}
/* EOF */

View File

@@ -1,171 +0,0 @@
/* $Id$
*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/fs/pool.c
* PURPOSE: No purpose listed.
*
* PROGRAMMERS: No programmer listed.
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
/*++
* @name FsRtlAllocatePool
* @implemented
*
* FILLME
*
* @param PoolType
* FILLME
*
* @param NumberOfBytes
* FILLME
*
* @return None
*
* @remarks IFS_POOL_TAG is "FSrt" in mem view.
*
*--*/
PVOID
NTAPI
FsRtlAllocatePool(IN POOL_TYPE PoolType,
IN ULONG NumberOfBytes)
{
PVOID Address;
Address = ExAllocatePoolWithTag(PoolType,
NumberOfBytes,
IFS_POOL_TAG);
if (NULL == Address)
{
ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES);
}
return Address;
}
/*++
* @name FsRtlAllocatePoolWithQuota
* @implemented
*
* FILLME
*
* @param PoolType
* FILLME
*
* @param NumberOfBytes
* FILLME
*
* @return None
*
* @remarks IFS_POOL_TAG is "FSrt" in mem view.
*
*--*/
PVOID
NTAPI
FsRtlAllocatePoolWithQuota(IN POOL_TYPE PoolType,
IN ULONG NumberOfBytes)
{
PVOID Address;
Address = ExAllocatePoolWithQuotaTag(PoolType,
NumberOfBytes,
IFS_POOL_TAG);
if (NULL == Address)
{
ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES);
}
return Address;
}
/*++
* @name FsRtlAllocatePoolWithQuotaTag
* @implemented
*
* FILLME
*
* @param PoolType
* FILLME
*
* @param NumberOfBytes
* FILLME
*
* @param Tag
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
PVOID
NTAPI
FsRtlAllocatePoolWithQuotaTag (IN POOL_TYPE PoolType,
IN ULONG NumberOfBytes,
IN ULONG Tag)
{
PVOID Address;
Address = ExAllocatePoolWithQuotaTag(PoolType,
NumberOfBytes,
Tag);
if (NULL == Address)
{
ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES);
}
return Address;
}
/*++
* @name FsRtlAllocatePoolWithTag
* @implemented
*
* FILLME
*
* @param PoolType
* FILLME
*
* @param NumberOfBytes
* FILLME
*
* @param Tag
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
PVOID
NTAPI
FsRtlAllocatePoolWithTag(IN POOL_TYPE PoolType,
IN ULONG NumberOfBytes,
IN ULONG Tag)
{
PVOID Address;
Address = ExAllocatePoolWithTag(PoolType,
NumberOfBytes,
Tag);
if (NULL == Address)
{
ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES);
}
return Address;
}
/* EOF */

View File

@@ -1,178 +0,0 @@
/* $Id$
*
* PROJECT: ReactOS kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/fs/tunnel.c
* PURPOSE: No purpose listed.
*
* PROGRAMMERS: Emanuele Aliberti
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
/*++
* @name FsRtlAddToTunnelCache
* @unimplemented
*
* FILLME
*
* @param Cache
* FILLME
*
* @param DirectoryKey
* FILLME
*
* @param ShortName
* FILLME
*
* @param LongName
* FILLME
*
* @param KeyByShortName
* FILLME
*
* @param DataLength
* FILLME
*
* @param Data
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
FsRtlAddToTunnelCache(IN PTUNNEL Cache,
IN ULONGLONG DirectoryKey,
IN PUNICODE_STRING ShortName,
IN PUNICODE_STRING LongName,
IN BOOLEAN KeyByShortName,
IN ULONG DataLength,
IN PVOID Data)
{
UNIMPLEMENTED;
}
/*++
* @name FsRtlDeleteKeyFromTunnelCache
* @unimplemented
*
* FILLME
*
* @param Cache
* FILLME
*
* @param DirectoryKey
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
FsRtlDeleteKeyFromTunnelCache(IN PTUNNEL Cache,
IN ULONGLONG DirectoryKey)
{
UNIMPLEMENTED;
}
/*++
* @name FsRtlDeleteTunnelCache
* @unimplemented
*
* FILLME
*
* @param Cache
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
FsRtlDeleteTunnelCache(IN PTUNNEL Cache)
{
UNIMPLEMENTED;
}
/*++
* @name FsRtlFindInTunnelCache
* @unimplemented
*
* FILLME
*
* @param Cache
* FILLME
*
* @param DirectoryKey
* FILLME
*
* @param ShortName
* FILLME
*
* @param LongName
* FILLME
*
* @param KeyByShortName
* FILLME
*
* @param DataLength
* FILLME
*
* @param Data
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
BOOLEAN
NTAPI
FsRtlFindInTunnelCache(IN PTUNNEL Cache,
IN ULONGLONG DirectoryKey,
IN PUNICODE_STRING Name,
OUT PUNICODE_STRING ShortName,
OUT PUNICODE_STRING LongName,
IN OUT PULONG DataLength,
OUT PVOID Data)
{
UNIMPLEMENTED;
return FALSE;
}
/*++
* @name FsRtlDeleteTunnelCache
* @unimplemented
*
* FILLME
*
* @param Cache
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
FsRtlInitializeTunnelCache(IN PTUNNEL Cache)
{
UNIMPLEMENTED;
}
/* EOF */

View File

@@ -1,72 +0,0 @@
/* $Id$
*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/fs/unc.c
* PURPOSE: Functions to work with UNC providers
*
* PROGRAMMERS: Emanuele Aliberti
* Eric Kohl
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
/*++
* @name FsRtlDeregisterUncProvider
* @unimplemented
*
* FILLME
*
* @param Handle
* FILLME
*
* @return None
*
* @remarks None
*
*--*/
VOID
NTAPI
FsRtlDeregisterUncProvider(IN HANDLE Handle)
{
UNIMPLEMENTED;
}
/*++
* @name FsRtlRegisterUncProvider
* @unimplemented
*
* FILLME
*
* @param Handle
* FILLME
*
* @param RedirectorDeviceName
* FILLME
*
* @param MailslotsSupported
*
* @return None
*
* @remarks None
*
*--*/
NTSTATUS
NTAPI
FsRtlRegisterUncProvider(IN OUT PHANDLE Handle,
IN PUNICODE_STRING RedirectorDeviceName,
IN BOOLEAN MailslotsSupported)
{
UNIMPLEMENTED;
return(STATUS_NOT_IMPLEMENTED);
}
/* EOF */

View File

@@ -1,303 +0,0 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/fs/util.c
* PURPOSE: Misc Utility Functions for File System Drivers
*
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
Emanuele Aliberti
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
#define FSRTL_MAX_RESOURCES 16
#define FTTYPE ((ULONG)'f')
#define FT_BALANCED_READ_MODE \
CTL_CODE(FTTYPE, 6, METHOD_NEITHER, FILE_ANY_ACCESS)
/* GLOBALS *******************************************************************/
BOOLEAN STDCALL MmIsFileAPagingFile(PFILE_OBJECT FileObject);
VOID NTAPI INIT_FUNCTION RtlpInitializeResources(VOID);
static ULONG FsRtlpAllocatedResources = 0;
static PERESOURCE FsRtlpResources;
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, RtlpInitializeResources)
#endif
/* PRIVATE FUNCTIONS**********************************************************/
VOID
NTAPI
INIT_FUNCTION
RtlpInitializeResources(VOID)
{
ULONG i;
/* Allocate the Resource Buffer */
FsRtlpResources = FsRtlAllocatePool(NonPagedPool,
FSRTL_MAX_RESOURCES*sizeof(ERESOURCE));
/* Initialize the Resources */
for (i = 0; i < FSRTL_MAX_RESOURCES; i++)
{
ExInitializeResource(&FsRtlpResources[i]);
}
}
/* FUNCTIONS *****************************************************************/
/*++
* @name FsRtlIsTotalDeviceFailure
* @implemented NT 4.0
*
* The FsRtlIsTotalDeviceFailure routine checks if an NTSTATUS error code
* represents a disk hardware failure.
*
* @param NtStatus
* The NTSTATUS Code to Test
*
* @return TRUE in case of Hardware Failure, FALSE otherwise.
*
* @remarks None.
*
*--*/
BOOLEAN
NTAPI
FsRtlIsTotalDeviceFailure(IN NTSTATUS NtStatus)
{
return((NT_SUCCESS(NtStatus)) ||
(STATUS_CRC_ERROR == NtStatus) ||
(STATUS_DEVICE_DATA_ERROR == NtStatus) ? FALSE : TRUE);
}
/*++
* @name FsRtlIsNtstatusExpected
* @implemented NT 4.0
*
* The FsRtlIsNtstatusExpected routine checks if an NTSTATUS error code
* is expected by the File System Support Library.
*
* @param NtStatus
* The NTSTATUS Code to Test
*
* @return TRUE if the Value is Expected, FALSE otherwise.
*
* @remarks None.
*
*--*/
BOOLEAN
NTAPI
FsRtlIsNtstatusExpected(IN NTSTATUS NtStatus)
{
return((STATUS_DATATYPE_MISALIGNMENT == NtStatus) ||
(STATUS_ACCESS_VIOLATION == NtStatus) ||
(STATUS_ILLEGAL_INSTRUCTION == NtStatus) ||
(STATUS_INSTRUCTION_MISALIGNMENT == NtStatus)) ? FALSE : TRUE;
}
/*++
* @name FsRtlIsPagingFile
* @implemented NT 4.0
*
* The FsRtlIsPagingFile routine checks if the FileObject is a Paging File.
*
* @param FileObject
* A pointer to the File Object to be tested.
*
* @return TRUE if the File is a Paging File, FALSE otherwise.
*
* @remarks None.
*
*--*/
BOOLEAN
NTAPI
FsRtlIsPagingFile(IN PFILE_OBJECT FileObject)
{
return MmIsFileAPagingFile(FileObject);
}
/*++
* @name FsRtlNormalizeNtstatus
* @implemented NT 4.0
*
* The FsRtlNormalizeNtstatus routine normalizes an NTSTATUS error code.
*
* @param NtStatusToNormalize
* The NTSTATUS error code to Normalize.
*
* @param NormalizedNtStatus
* The NTSTATUS error code to return if the NtStatusToNormalize is not
* a proper expected error code by the File System Library.
*
* @return NtStatusToNormalize if it is an expected value, otherwise
* NormalizedNtStatus.
*
* @remarks None.
*
*--*/
NTSTATUS
NTAPI
FsRtlNormalizeNtstatus(IN NTSTATUS NtStatusToNormalize,
IN NTSTATUS NormalizedNtStatus)
{
return(TRUE == FsRtlIsNtstatusExpected(NtStatusToNormalize)) ?
NtStatusToNormalize : NormalizedNtStatus;
}
/*++
* @name FsRtlAllocateResource
* @implemented NT 4.0
*
* The FsRtlAllocateResource routine returns a pre-initialized ERESOURCE
* for use by a File System Driver.
*
* @return A Pointer to a pre-initialized ERESOURCE.
*
* @remarks The File System Library only provides up to 16 Resources.
*
*--*/
PERESOURCE
NTAPI
FsRtlAllocateResource(VOID)
{
/* Return a pre-allocated ERESOURCE */
return &FsRtlpResources[FsRtlpAllocatedResources++ & FSRTL_MAX_RESOURCES];
}
/*++
* @name FsRtlBalanceReads
* @implemented NT 4.0
*
* The FsRtlBalanceReads routine sends an IRP to an FTDISK Driver
* requesting the driver to balance read requests across a mirror set.
*
* @param TargetDevice
* A pointer to an FTDISK Device Object.
*
* @return The NTSTATUS error code returned by the FTDISK Driver.
*
* @remarks FTDISK is a Software RAID Implementation.
*
*--*/
NTSTATUS
NTAPI
FsRtlBalanceReads(PDEVICE_OBJECT TargetDevice)
{
PIRP Irp;
KEVENT Event;
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
/* Initialize the Local Event */
KeInitializeEvent(&Event, NotificationEvent, FALSE);
/* Build the special IOCTL */
Irp = IoBuildDeviceIoControlRequest(FT_BALANCED_READ_MODE,
TargetDevice,
NULL,
0,
NULL,
0,
FALSE,
&Event,
&IoStatusBlock);
/* Send it */
Status = IoCallDriver(TargetDevice, Irp);
/* Wait if needed */
if (Status == STATUS_PENDING)
{
Status = KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
/* Return Status */
Status = IoStatusBlock.Status;
}
return Status;
}
/*++
* @name FsRtlPostPagingFileStackOverflow
* @unimplemented NT 4.0
*
* The FsRtlPostPagingFileStackOverflow routine
*
* @param Context
*
* @param Event
*
* @param StackOverflowRoutine
*
* @return
*
* @remarks None.
*
*--*/
VOID
NTAPI
FsRtlPostPagingFileStackOverflow(IN PVOID Context,
IN PKEVENT Event,
IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine)
{
UNIMPLEMENTED;
}
/*++
* @name FsRtlPostStackOverflow
* @unimplemented NT 4.0
*
* The FsRtlPostStackOverflow routine
*
* @param Context
*
* @param Event
*
* @param StackOverflowRoutine
*
* @return
*
* @remarks None.
*
*--*/
VOID
NTAPI
FsRtlPostStackOverflow(IN PVOID Context,
IN PKEVENT Event,
IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine)
{
UNIMPLEMENTED;
}
/*++
* @name FsRtlSyncVolumes
* @implemented NT 4.0
*
* The FsRtlSyncVolumes routine is deprecated.
*
* @return Always returns STATUS_SUCCESS.
*
* @remarks Deprecated.
*
*--*/
NTSTATUS
NTAPI
FsRtlSyncVolumes(DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2)
{
return STATUS_SUCCESS;
}
/* EOF */

View File

@@ -1,252 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/inbv/inbv.c
* PURPOSE: Boot video support
*
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#include "../../drivers/base/bootvid/ntbootvid.h"
#define NDEBUG
#include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, InbvEnableBootDriver)
#endif
/* ROS Internal. Please deprecate */
NTHALAPI
VOID
NTAPI
HalReleaseDisplayOwnership(VOID);
/* GLOBALS *******************************************************************/
/* DATA **********************************************************************/
static HANDLE BootVidDevice = NULL;
static BOOL BootVidDriverInstalled = FALSE;
static NTBOOTVID_FUNCTION_TABLE BootVidFunctionTable;
/* FUNCTIONS *****************************************************************/
NTSTATUS
STATIC
InbvCheckBootVid(VOID)
{
IO_STATUS_BLOCK Iosb;
if (BootVidDevice == NULL)
{
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING BootVidName = RTL_CONSTANT_STRING(L"\\Device\\BootVid");
InitializeObjectAttributes(&ObjectAttributes,
&BootVidName,
0,
NULL,
NULL);
Status = ZwOpenFile(&BootVidDevice,
FILE_ALL_ACCESS,
&ObjectAttributes,
&Iosb,
0,
0);
if (!NT_SUCCESS(Status))
{
return(Status);
}
}
return(STATUS_SUCCESS);
}
VOID
STDCALL
InbvAcquireDisplayOwnership(VOID)
{
}
BOOLEAN
STDCALL
InbvCheckDisplayOwnership(VOID)
{
return FALSE;
}
BOOLEAN
STDCALL
InbvDisplayString(IN PCHAR String)
{
/* Call Bootvid (we don't support bootvid for now)
* vidDisplayString(String);
* so instead, we'll fall-back to HAL
*/
HalDisplayString(String);
/* Call Headless (We don't support headless for now)
HeadlessDispatch(DISPLAY_STRING);
*/
/* Return success */
return TRUE;
}
BOOLEAN
STDCALL
InbvResetDisplayParameters(ULONG SizeX,
ULONG SizeY)
{
return(InbvResetDisplay());
}
VOID
STDCALL
INIT_FUNCTION
InbvEnableBootDriver(IN BOOLEAN Enable)
{
NTSTATUS Status;
IO_STATUS_BLOCK Iosb;
Status = InbvCheckBootVid();
if (!NT_SUCCESS(Status))
{
return;
}
if (Enable)
{
/* Notify the hal we will acquire the display. */
HalAcquireDisplayOwnership(InbvResetDisplayParameters);
Status = ZwDeviceIoControlFile(BootVidDevice,
NULL,
NULL,
NULL,
&Iosb,
IOCTL_BOOTVID_INITIALIZE,
NULL,
0,
&BootVidFunctionTable,
sizeof(BootVidFunctionTable));
if (!NT_SUCCESS(Status))
{
KEBUGCHECK(0);
}
BootVidDriverInstalled = TRUE;
CHECKPOINT;
}
else
{
Status = ZwDeviceIoControlFile(BootVidDevice,
NULL,
NULL,
NULL,
&Iosb,
IOCTL_BOOTVID_CLEANUP,
NULL,
0,
NULL,
0);
if (!NT_SUCCESS(Status))
{
KEBUGCHECK(0);
}
BootVidDriverInstalled = FALSE;
/* Notify the hal we have released the display. */
HalReleaseDisplayOwnership();
}
ZwClose(BootVidDevice);
BootVidDevice = NULL;
}
BOOLEAN
STDCALL
InbvEnableDisplayString(IN BOOLEAN Enable)
{
return FALSE;
}
VOID
STDCALL
InbvInstallDisplayStringFilter(IN PVOID Unknown)
{
}
BOOLEAN
STDCALL
InbvIsBootDriverInstalled(VOID)
{
return(BootVidDriverInstalled);
}
VOID
STDCALL
InbvNotifyDisplayOwnershipLost(IN PVOID Callback)
{
}
BOOLEAN
STDCALL
InbvResetDisplay(VOID)
{
if (!BootVidDriverInstalled)
{
return(FALSE);
}
return(BootVidFunctionTable.ResetDisplay());
}
VOID
STDCALL
InbvSetScrollRegion(IN ULONG Left,
IN ULONG Top,
IN ULONG Width,
IN ULONG Height)
{
}
VOID
STDCALL
InbvSetTextColor(IN ULONG Color)
{
}
VOID
STDCALL
InbvSolidColorFill(IN ULONG Left,
IN ULONG Top,
IN ULONG Width,
IN ULONG Height,
IN ULONG Color)
{
}
NTSTATUS
STDCALL
NtDisplayString(IN PUNICODE_STRING DisplayString)
{
OEM_STRING OemString;
RtlUnicodeStringToOemString(&OemString, DisplayString, TRUE);
HalDisplayString(OemString.Buffer);
RtlFreeOemString(&OemString);
return STATUS_SUCCESS;
}

View File

@@ -1,44 +0,0 @@
#ifndef __INCLUDE_NTOSKRNL_CONFIG_H
#define __INCLUDE_NTOSKRNL_CONFIG_H
/********** dbg/print.c **********/
/* Enable serialization of debug messages printed with DbgPrint
*
* If this is enabled DbgPrint will queue messages if another thread is already
* printing a message, and immediately returns. The other thread will print
* queued messages before it returns.
* It could happen that some messages are lost if the processor is halted before
* the message queue was flushed.
*/
#undef SERIALIZE_DBGPRINT
/********** mm/ppool.c **********/
/* Disable Debugging Features */
#ifndef DBG
/* Enable strict checking of the nonpaged pool on every allocation */
#undef ENABLE_VALIDATE_POOL
/* Enable tracking of statistics about the tagged blocks in the pool */
#undef TAG_STATISTICS_TRACKING
/* Enable Memory Debugging Features/Helpers */
#undef POOL_DEBUG_APIS
/* Enable Redzone */
#define R_RZ 0
/* Enable Allocator Stack */
#define R_STACK 0
/*
* Put each block in its own range of pages and position the block at the
* end of the range so any accesses beyond the end of block are to invalid
* memory locations.
*/
#undef WHOLE_PAGE_ALLOCATIONS
#endif
#endif /* __INCLUDE_NTOSKRNL_CONFIG_H */

View File

@@ -1,30 +0,0 @@
/*
* ReactOS kernel
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARCH_KE_H
#define __NTOSKRNL_INCLUDE_INTERNAL_ARCH_KE_H
#ifdef _M_IX86
#include "../i386/ke.h"
#else
#error "Unknown processor"
#endif
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_ARCH_KE_H */
/* EOF */

View File

@@ -1,28 +0,0 @@
/*
* ReactOS kernel
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARCH_MM_H
#define __NTOSKRNL_INCLUDE_INTERNAL_ARCH_MM_H
#ifdef _M_IX86
#include <internal/i386/mm.h>
#else
#error "Unknown processor"
#endif
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_ARCH_MM_H */

View File

@@ -1,204 +0,0 @@
#ifndef __INCLUDE_INTERNAL_CC_H
#define __INCLUDE_INTERNAL_CC_H
typedef struct _BCB
{
LIST_ENTRY BcbSegmentListHead;
LIST_ENTRY BcbRemoveListEntry;
BOOLEAN RemoveOnClose;
ULONG TimeStamp;
PFILE_OBJECT FileObject;
ULONG CacheSegmentSize;
LARGE_INTEGER AllocationSize;
LARGE_INTEGER FileSize;
KSPIN_LOCK BcbLock;
ULONG RefCount;
#if defined(DBG) || defined(KDBG)
BOOLEAN Trace; /* enable extra trace output for this BCB and it's cache segments */
#endif
} BCB, *PBCB;
typedef struct _CACHE_SEGMENT
{
/* Base address of the region where the cache segment data is mapped. */
PVOID BaseAddress;
/*
* Memory area representing the region where the cache segment data is
* mapped.
*/
struct _MEMORY_AREA* MemoryArea;
/* Are the contents of the cache segment data valid. */
BOOLEAN Valid;
/* Are the contents of the cache segment data newer than those on disk. */
BOOLEAN Dirty;
/* Page out in progress */
BOOLEAN PageOut;
ULONG MappedCount;
/* Entry in the list of segments for this BCB. */
LIST_ENTRY BcbSegmentListEntry;
/* Entry in the list of segments which are dirty. */
LIST_ENTRY DirtySegmentListEntry;
/* Entry in the list of segments. */
LIST_ENTRY CacheSegmentListEntry;
LIST_ENTRY CacheSegmentLRUListEntry;
/* Offset in the file which this cache segment maps. */
ULONG FileOffset;
/* Lock. */
FAST_MUTEX Lock;
/* Number of references. */
ULONG ReferenceCount;
/* Pointer to the BCB for the file which this cache segment maps data for. */
PBCB Bcb;
/* Pointer to the next cache segment in a chain. */
struct _CACHE_SEGMENT* NextInChain;
} CACHE_SEGMENT, *PCACHE_SEGMENT;
typedef struct _INTERNAL_BCB
{
PUBLIC_BCB PFCB;
PCACHE_SEGMENT CacheSegment;
BOOLEAN Dirty;
CSHORT RefCount; /* (At offset 0x34 on WinNT4) */
} INTERNAL_BCB, *PINTERNAL_BCB;
VOID
STDCALL
CcMdlReadCompleteDev(
IN PMDL MdlChain,
IN PFILE_OBJECT FileObject
);
VOID
STDCALL
CcMdlWriteCompleteDev(
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain,
IN PFILE_OBJECT FileObject
);
NTSTATUS
NTAPI
CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment);
NTSTATUS
NTAPI
CcRosGetCacheSegment(
PBCB Bcb,
ULONG FileOffset,
PULONG BaseOffset,
PVOID *BaseAddress,
PBOOLEAN UptoDate,
PCACHE_SEGMENT *CacheSeg
);
VOID
NTAPI
CcInitView(VOID);
NTSTATUS
NTAPI
CcRosFreeCacheSegment(
PBCB,
PCACHE_SEGMENT
);
NTSTATUS
NTAPI
ReadCacheSegment(PCACHE_SEGMENT CacheSeg);
NTSTATUS
NTAPI
WriteCacheSegment(PCACHE_SEGMENT CacheSeg);
VOID
NTAPI
CcInit(VOID);
NTSTATUS
NTAPI
CcRosUnmapCacheSegment(
PBCB Bcb,
ULONG FileOffset,
BOOLEAN NowDirty
);
PCACHE_SEGMENT
NTAPI
CcRosLookupCacheSegment(
PBCB Bcb,
ULONG FileOffset
);
NTSTATUS
NTAPI
CcRosGetCacheSegmentChain(
PBCB Bcb,
ULONG FileOffset,
ULONG Length,
PCACHE_SEGMENT* CacheSeg
);
VOID
NTAPI
CcInitCacheZeroPage(VOID);
NTSTATUS
NTAPI
CcRosMarkDirtyCacheSegment(
PBCB Bcb,
ULONG FileOffset
);
NTSTATUS
NTAPI
CcRosFlushDirtyPages(
ULONG Target,
PULONG Count
);
VOID
NTAPI
CcRosDereferenceCache(PFILE_OBJECT FileObject);
VOID
NTAPI
CcRosReferenceCache(PFILE_OBJECT FileObject);
VOID
NTAPI
CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer);
NTSTATUS
NTAPI
CcRosReleaseCacheSegment(
BCB* Bcb,
CACHE_SEGMENT *CacheSeg,
BOOLEAN Valid,
BOOLEAN Dirty,
BOOLEAN Mapped
);
NTSTATUS
STDCALL
CcRosRequestCacheSegment(
BCB *Bcb,
ULONG FileOffset,
PVOID* BaseAddress,
PBOOLEAN UptoDate,
CACHE_SEGMENT **CacheSeg
);
NTSTATUS
NTAPI
CcTryToInitializeFileCache(PFILE_OBJECT FileObject);
/*
* Macro for generic cache manage bugchecking. Note that this macro assumes
* that the file name including extension is always longer than 4 characters.
*/
#define KEBUGCHECKCC \
KEBUGCHECKEX(CACHE_MANAGER, \
(*(DWORD*)(__FILE__ + sizeof(__FILE__) - 4) << 16) | \
(__LINE__ & 0xFFFF), 0, 0, 0)
#endif

View File

@@ -1,43 +0,0 @@
#ifndef _CTYPE_H
#define _CTYPE_H
#define __need_wchar_t
#define __need_wint_t
#include <stddef.h>
/*
* The following flags are used to tell iswctype and _isctype what character
* types you are looking for.
*/
#define _UPPER 0x0001
#define _LOWER 0x0002
#define _DIGIT 0x0004
#define _SPACE 0x0008 /* HT LF VT FF CR SP */
#define _PUNCT 0x0010
#define _CONTROL 0x0020
#define _BLANK 0x0040 /* this is SP only, not SP and HT as in C99 */
#define _HEX 0x0080
#define _LEADBYTE 0x8000
#define _ALPHA 0x0103
#ifndef _WCTYPE_T_DEFINED
typedef wchar_t wctype_t;
#define _WCTYPE_T_DEFINED
#endif
#if defined(_MSC_VER)
#define inline __inline
typedef wchar_t wint_t;
#endif
extern inline int isspace(int c);
extern inline int toupper(int c);
extern inline int tolower(int c);
extern inline int islower(int c);
extern inline int isdigit(int c);
extern inline int isxdigit(int c);
#endif

View File

@@ -1,26 +0,0 @@
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_DBGK_H
#define __NTOSKRNL_INCLUDE_INTERNAL_DBGK_H
VOID
STDCALL
DbgkCreateThread(PVOID StartAddress);
VOID
NTAPI
DbgkExitProcess(IN NTSTATUS ExitStatus);
VOID
NTAPI
DbgkExitThread(IN NTSTATUS ExitStatus);
VOID
NTAPI
DbgkCopyProcessDebugPort(
IN PEPROCESS Process,
IN PEPROCESS Parent
);
extern POBJECT_TYPE DbgkDebugObjectType;
#endif
/* EOF */

View File

@@ -1,132 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/debug.h
* PURPOSE: Useful debugging macros
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* 28/05/98: Created
*/
/*
* NOTES: Define DBG in configuration file for "checked" version
* Define NDEBUG before including this header to disable debugging
* macros
* Define NASSERT before including this header to disable assertions
*/
#ifdef CHECKPOINT
#undef CHECKPOINT
#endif
#ifdef DPRINT
#undef DPRINT
#endif
#ifndef NDEBUG
#ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
#define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
#else
#define DPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
#endif
#define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0)
#else /* NDEBUG */
#ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
#define DPRINT(args...)
#else
#define DPRINT
#endif
#define CHECKPOINT
#endif /* NDEBUG */
#ifndef __INTERNAL_DEBUG
#define __INTERNAL_DEBUG
#if defined(_MSC_VER) && (_MSC_VER < 1300)
/* TODO: Verify which version the MS compiler learned the __FUNCTION__ macro */
#define __FUNCTION__ "<unknown>"
#endif
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0)
#ifdef assert
#undef assert
#endif
#ifdef DBG
#ifndef __USE_W32API
/* Assert only on "checked" version */
#ifndef NASSERT
#ifdef CONFIG_SMP
#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d for CPU%d\n", __FILE__,__LINE__, KeGetCurrentProcessorNumber()), DbgBreakPoint(); }
#define ASSERT(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d for CPU%d\n", __FILE__,__LINE__, KeGetCurrentProcessorNumber()), DbgBreakPoint(); }
#else
#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); DbgBreakPoint(); }
#define ASSERT(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); DbgBreakPoint(); }
#endif
#define assertmsg(_c_, _m_) \
if (!(_c_)) { \
DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
DbgPrint _m_ ; \
KeBugCheck(0); \
}
#define ASSERTMSG(_c_, _m_) \
if (!(_c_)) { \
DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
DbgPrint _m_ ; \
KeBugCheck(0); \
}
#else
#define assert(x)
#define ASSERT(x)
#define assertmsg(_c_, _m_)
#define ASSERTMSG(_c_, _m_)
#endif
#endif /* !__USE_W32API */
/* Print if using a "checked" version */
#ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
#define CPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
#else
#define CPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
#endif
#ifdef __GNUC__ /* using GNU C/C99 macro ellipsis */
#define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0)
#else
#define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint
#endif
#else /* DBG */
#define CPRINT(args...)
#define DPRINT1(args...)
#ifndef __USE_W32API
#define assert(x)
#define ASSERT(x)
#define assertmsg(_c_, _m_)
#define ASSERTMSG(_c_, _m_)
#endif /* !__USE_W32API */
#endif /* DBG */
#define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0)
/*
* FUNCTION: Assert a maximum value for the current irql
* ARGUMENTS:
* x = Maximum irql
*/
#define ASSERT_IRQL_LESS_OR_EQUAL(x) ASSERT(KeGetCurrentIrql()<=(x))
#define ASSERT_IRQL(x) ASSERT_IRQL_LESS_OR_EQUAL(x)
#define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql()==(x))
#define ASSERT_IRQL_LESS(x) ASSERT(KeGetCurrentIrql()<(x))
#define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
#endif /* __INTERNAL_DEBUG */

View File

@@ -1,790 +0,0 @@
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H
#define __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H
/* GLOBAL VARIABLES *********************************************************/
extern TIME_ZONE_INFORMATION ExpTimeZoneInfo;
extern LARGE_INTEGER ExpTimeZoneBias;
extern ULONG ExpTimeZoneId;
extern POBJECT_TYPE ExEventPairObjectType;
#define MAX_FAST_REFS 7
#define EX_OBJ_TO_HDR(eob) ((POBJECT_HEADER)((ULONG_PTR)(eob) & \
~(EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | \
EX_HANDLE_ENTRY_AUDITONCLOSE)))
#define EX_HTE_TO_HDR(hte) ((POBJECT_HEADER)((ULONG_PTR)((hte)->Object) & \
~(EX_HANDLE_ENTRY_PROTECTFROMCLOSE | EX_HANDLE_ENTRY_INHERITABLE | \
EX_HANDLE_ENTRY_AUDITONCLOSE)))
/* Note: we only use a spinlock on SMP. On UP, we cli/sti intead */
#ifndef CONFIG_SMP
#define ExAcquireResourceLock(l, i) { \
(void)i; \
Ke386DisableInterrupts(); \
}
#define ExReleaseResourceLock(l, i) Ke386EnableInterrupts();
#else
#define ExAcquireResourceLock(l, i) KeAcquireSpinLock(l, i);
#define ExReleaseResourceLock(l, i) KeReleaseSpinLock(l, i);
#endif
/* INITIALIZATION FUNCTIONS *************************************************/
VOID
STDCALL
ExpWin32kInit(VOID);
VOID
STDCALL
ExInit2(VOID);
VOID
STDCALL
ExpInitTimeZoneInfo(VOID);
VOID
STDCALL
ExpInitializeWorkerThreads(VOID);
VOID
STDCALL
ExpInitLookasideLists(VOID);
VOID
STDCALL
ExpInitializeCallbacks(VOID);
VOID
STDCALL
ExpInitUuids(VOID);
VOID
STDCALL
ExpInitializeExecutive(VOID);
VOID
STDCALL
ExpInitializeEventImplementation(VOID);
VOID
STDCALL
ExpInitializeEventImplementation(VOID);
VOID
STDCALL
ExpInitializeEventPairImplementation(VOID);
VOID
STDCALL
ExpInitializeSemaphoreImplementation(VOID);
VOID
STDCALL
ExpInitializeMutantImplementation(VOID);
VOID
STDCALL
ExpInitializeTimerImplementation(VOID);
VOID
STDCALL
ExpInitializeProfileImplementation(VOID);
VOID
NTAPI
ExpResourceInitialization(VOID);
/* Rundown Functions ********************************************************/
VOID
FASTCALL
ExfInitializeRundownProtection(
OUT PEX_RUNDOWN_REF RunRef
);
VOID
FASTCALL
ExfReInitializeRundownProtection(
OUT PEX_RUNDOWN_REF RunRef
);
BOOLEAN
FASTCALL
ExfAcquireRundownProtection(
IN OUT PEX_RUNDOWN_REF RunRef
);
BOOLEAN
FASTCALL
ExfAcquireRundownProtectionEx(
IN OUT PEX_RUNDOWN_REF RunRef,
IN ULONG Count
);
VOID
FASTCALL
ExfReleaseRundownProtection(
IN OUT PEX_RUNDOWN_REF RunRef
);
VOID
FASTCALL
ExfReleaseRundownProtectionEx(
IN OUT PEX_RUNDOWN_REF RunRef,
IN ULONG Count
);
VOID
FASTCALL
ExfRundownCompleted(
OUT PEX_RUNDOWN_REF RunRef
);
VOID
FASTCALL
ExfWaitForRundownProtectionRelease(
IN OUT PEX_RUNDOWN_REF RunRef
);
/* HANDLE TABLE FUNCTIONS ***************************************************/
#define EX_HANDLE_ENTRY_LOCKED (1 << ((sizeof(PVOID) * 8) - 1))
#define EX_HANDLE_ENTRY_PROTECTFROMCLOSE (1 << 0)
#define EX_HANDLE_ENTRY_INHERITABLE (1 << 1)
#define EX_HANDLE_ENTRY_AUDITONCLOSE (1 << 2)
#define EX_HANDLE_TABLE_CLOSING 0x1
#define EX_HANDLE_ENTRY_FLAGSMASK (EX_HANDLE_ENTRY_LOCKED | \
EX_HANDLE_ENTRY_PROTECTFROMCLOSE | \
EX_HANDLE_ENTRY_INHERITABLE | \
EX_HANDLE_ENTRY_AUDITONCLOSE)
typedef VOID (STDCALL PEX_SWEEP_HANDLE_CALLBACK)(
PHANDLE_TABLE_ENTRY HandleTableEntry,
HANDLE Handle,
PVOID Context
);
typedef BOOLEAN (STDCALL PEX_DUPLICATE_HANDLE_CALLBACK)(
PHANDLE_TABLE HandleTable,
PHANDLE_TABLE_ENTRY HandleTableEntry,
PVOID Context
);
typedef BOOLEAN (STDCALL PEX_CHANGE_HANDLE_CALLBACK)(
PHANDLE_TABLE HandleTable,
PHANDLE_TABLE_ENTRY HandleTableEntry,
PVOID Context
);
VOID
ExpInitializeHandleTables(VOID);
PHANDLE_TABLE
ExCreateHandleTable(IN PEPROCESS QuotaProcess OPTIONAL);
VOID
ExDestroyHandleTable(
IN PHANDLE_TABLE HandleTable
);
VOID
ExSweepHandleTable(
IN PHANDLE_TABLE HandleTable,
IN PEX_SWEEP_HANDLE_CALLBACK SweepHandleCallback OPTIONAL,
IN PVOID Context OPTIONAL
);
PHANDLE_TABLE
ExDupHandleTable(
IN PEPROCESS QuotaProcess OPTIONAL,
IN PEX_DUPLICATE_HANDLE_CALLBACK DuplicateHandleCallback OPTIONAL,
IN PVOID Context OPTIONAL,
IN PHANDLE_TABLE SourceHandleTable
);
BOOLEAN
ExLockHandleTableEntry(
IN PHANDLE_TABLE HandleTable,
IN PHANDLE_TABLE_ENTRY Entry
);
VOID
ExUnlockHandleTableEntry(
IN PHANDLE_TABLE HandleTable,
IN PHANDLE_TABLE_ENTRY Entry
);
HANDLE
ExCreateHandle(
IN PHANDLE_TABLE HandleTable,
IN PHANDLE_TABLE_ENTRY Entry
);
BOOLEAN
ExDestroyHandle(
IN PHANDLE_TABLE HandleTable,
IN HANDLE Handle
);
VOID
ExDestroyHandleByEntry(
IN PHANDLE_TABLE HandleTable,
IN PHANDLE_TABLE_ENTRY Entry,
IN HANDLE Handle
);
PHANDLE_TABLE_ENTRY
ExMapHandleToPointer(
IN PHANDLE_TABLE HandleTable,
IN HANDLE Handle
);
BOOLEAN
ExChangeHandle(
IN PHANDLE_TABLE HandleTable,
IN HANDLE Handle,
IN PEX_CHANGE_HANDLE_CALLBACK ChangeHandleCallback,
IN PVOID Context
);
/* PSEH EXCEPTION HANDLING **************************************************/
LONG
STDCALL
ExSystemExceptionFilter(VOID);
static __inline _SEH_FILTER(_SEH_ExSystemExceptionFilter)
{
return ExSystemExceptionFilter();
}
/* RUNDOWN *******************************************************************/
#if (NTDDI_VERSION >= NTDDI_WINXP)
#ifdef _WIN64
#define ExpChangeRundown(x, y, z) InterlockedCompareExchange64((PLONGLONG)x, y, z)
#define ExpSetRundown(x, y) InterlockedExchange64((PLONGLONG)x, y)
#else
#define ExpChangeRundown(x, y, z) InterlockedCompareExchange((PLONG)x, PtrToLong(y), PtrToLong(z))
#define ExpSetRundown(x, y) InterlockedExchange((PLONG)x, y)
#endif
/*++
* @name ExfAcquireRundownProtection
* INTERNAL MACRO
*
* The ExfAcquireRundownProtection routine acquires rundown protection for
* the specified descriptor.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @return TRUE if access to the protected structure was granted, FALSE otherwise.
*
* @remarks This is the internal macro for system use only.In case the rundown
* was active, then the slow-path will be called through the exported
* function.
*
*--*/
BOOLEAN
FORCEINLINE
ExAcquireRundownProtection(IN PEX_RUNDOWN_REF RunRef)
{
ULONG_PTR Value, NewValue, OldValue;
/* Get the current value and mask the active bit */
Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
/* Add a reference */
NewValue = Value + EX_RUNDOWN_COUNT_INC;
/* Change the value */
OldValue = ExpChangeRundown(RunRef, NewValue, Value);
if (OldValue != Value)
{
/* Rundown was active, use long path */
return ExfAcquireRundownProtection(RunRef);
}
/* Success */
return TRUE;
}
/*++
* @name ExReleaseRundownProtection
* INTERNAL MACRO
*
* The ExReleaseRundownProtection routine releases rundown protection for
* the specified descriptor.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @return TRUE if access to the protected structure was granted, FALSE otherwise.
*
* @remarks This is the internal macro for system use only.In case the rundown
* was active, then the slow-path will be called through the exported
* function.
*
*--*/
VOID
FORCEINLINE
ExReleaseRundownProtection(IN PEX_RUNDOWN_REF RunRef)
{
ULONG_PTR Value, NewValue, OldValue;
/* Get the current value and mask the active bit */
Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
/* Remove a reference */
NewValue = Value - EX_RUNDOWN_COUNT_INC;
/* Change the value */
OldValue = ExpChangeRundown(RunRef, NewValue, Value);
/* Check if the rundown was active */
if (OldValue != Value)
{
/* Rundown was active, use long path */
ExfReleaseRundownProtection(RunRef);
}
else
{
/* Sanity check */
ASSERT((Value >= EX_RUNDOWN_COUNT_INC) || (KeNumberProcessors > 1));
}
}
/*++
* @name ExInitializeRundownProtection
* INTERNAL MACRO
*
* The ExInitializeRundownProtection routine initializes a rundown
* protection descriptor.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @return None.
*
* @remarks This is the internal macro for system use only.
*
*--*/
VOID
FORCEINLINE
ExInitializeRundownProtection(IN PEX_RUNDOWN_REF RunRef)
{
/* Set the count to zero */
RunRef->Count = 0;
}
/*++
* @name ExWaitForRundownProtectionRelease
* INTERNAL MACRO
*
* The ExWaitForRundownProtectionRelease routine waits until the specified
* rundown descriptor has been released.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @return None.
*
* @remarks This is the internal macro for system use only. If a wait is actually
* necessary, then the slow path is taken through the exported function.
*
*--*/
VOID
FORCEINLINE
ExWaitForRundownProtectionRelease(IN PEX_RUNDOWN_REF RunRef)
{
ULONG_PTR Value;
/* Set the active bit */
Value = ExpChangeRundown(RunRef, EX_RUNDOWN_ACTIVE, 0);
if ((Value) || (Value != EX_RUNDOWN_ACTIVE))
{
/* If the the rundown wasn't already active, then take the long path */
ExfWaitForRundownProtectionRelease(RunRef);
}
}
/*++
* @name ExRundownCompleted
* INTERNAL MACRO
*
* The ExRundownCompleted routine completes the rundown of the specified
* descriptor by setting the active bit.
*
* @param RunRef
* Pointer to a rundown reference descriptor.
*
* @return None.
*
* @remarks This is the internal macro for system use only.
*
*--*/
VOID
FORCEINLINE
ExRundownCompleted(IN PEX_RUNDOWN_REF RunRef)
{
/* Sanity check */
ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
/* Mark the counter as active */
ExpSetRundown(&RunRef->Count, EX_RUNDOWN_ACTIVE);
}
#endif
/* PUSHLOCKS *****************************************************************/
/*++
* @name ExInitializePushLock
* INTERNAL MACRO
*
* The ExInitializePushLock macro initializes a PushLock.
*
* @params PushLock
* Pointer to the pushlock which is to be initialized.
*
* @return None.
*
* @remarks None.
*
*--*/
VOID
FORCEINLINE
ExInitializePushLock(IN PEX_PUSH_LOCK PushLock)
{
/* Set the value to 0 */
PushLock->Value = 0;
}
/*++
* @name ExAcquirePushLockExclusive
* INTERNAL MACRO
*
* The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
*
* @params PushLock
* Pointer to the pushlock which is to be acquired.
*
* @return None.
*
* @remarks The function attempts the quickest route to acquire the lock, which is
* to simply set the lock bit.
* However, if the pushlock is already shared, the slower path is taken.
*
* Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
* This macro should usually be paired up with KeAcquireCriticalRegion.
*
*--*/
VOID
FORCEINLINE
ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
{
/* Try acquiring the lock */
if (InterlockedBitTestAndSet((PLONG)PushLock, EX_PUSH_LOCK_LOCK_V))
{
/* Someone changed it, use the slow path */
DbgPrint("%s - Contention!\n", __FUNCTION__);
ExfAcquirePushLockExclusive(PushLock);
}
/* Sanity check */
ASSERT(PushLock->Locked);
}
/*++
* @name ExAcquirePushLockShared
* INTERNAL MACRO
*
* The ExAcquirePushLockShared macro acquires a shared PushLock.
*
* @params PushLock
* Pointer to the pushlock which is to be acquired.
*
* @return None.
*
* @remarks The function attempts the quickest route to acquire the lock, which is
* to simply set the lock bit and set the share count to one.
* However, if the pushlock is already shared, the slower path is taken.
*
* Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
* This macro should usually be paired up with KeAcquireCriticalRegion.
*
*--*/
VOID
FORCEINLINE
ExAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
{
EX_PUSH_LOCK NewValue;
/* Try acquiring the lock */
NewValue.Value = EX_PUSH_LOCK_LOCK | EX_PUSH_LOCK_SHARE_INC;
if (InterlockedCompareExchangePointer(PushLock, NewValue.Ptr, 0))
{
/* Someone changed it, use the slow path */
DbgPrint("%s - Contention!\n", __FUNCTION__);
ExfAcquirePushLockShared(PushLock);
}
/* Sanity checks */
ASSERT(PushLock->Locked);
ASSERT(PushLock->Waiting || PushLock->Shared > 0);
}
/*++
* @name ExConvertPushLockSharedToExclusive
* INTERNAL MACRO
*
* The ExConvertPushLockSharedToExclusive macro converts an exclusive
* pushlock to a shared pushlock.
*
* @params PushLock
* Pointer to the pushlock which is to be converted.
*
* @return FALSE if conversion failed, TRUE otherwise.
*
* @remarks The function attempts the quickest route to convert the lock, which is
* to simply set the lock bit and remove any other bits.
*
*--*/
BOOLEAN
FORCEINLINE
ExConvertPushLockSharedToExclusive(IN PEX_PUSH_LOCK PushLock)
{
EX_PUSH_LOCK OldValue;
/* Set the expected old value */
OldValue.Value = EX_PUSH_LOCK_LOCK | EX_PUSH_LOCK_SHARE_INC;
/* Try converting the lock */
if (InterlockedCompareExchange((PLONG)PushLock,
EX_PUSH_LOCK_LOCK,
OldValue.Value) != OldValue.Value)
{
/* Conversion failed */
return FALSE;
}
/* Sanity check */
ASSERT(PushLock->Locked);
return TRUE;
}
/*++
* @name ExWaitOnPushLock
* INTERNAL MACRO
*
* The ExWaitOnPushLock macro acquires and instantly releases a pushlock.
*
* @params PushLock
* Pointer to a pushlock.
*
* @return None.
*
* @remarks The function attempts to get any exclusive waiters out of their slow
* path by forcing an instant acquire/release operation.
*
* Callers of ExWaitOnPushLock must be running at IRQL <= APC_LEVEL.
*
*--*/
VOID
FORCEINLINE
ExWaitOnPushLock(PEX_PUSH_LOCK PushLock)
{
/* Acquire the lock */
ExfAcquirePushLockExclusive(PushLock);
ASSERT(PushLock->Locked);
/* Release it */
ExfReleasePushLockExclusive(PushLock);
}
/*++
* @name ExReleasePushLockShared
* INTERNAL MACRO
*
* The ExReleasePushLockShared macro releases a previously acquired PushLock.
*
* @params PushLock
* Pointer to a previously acquired pushlock.
*
* @return None.
*
* @remarks The function attempts the quickest route to release the lock, which is
* to simply decrease the share count and remove the lock bit.
* However, if the pushlock is being waited on then the long path is taken.
*
* Callers of ExReleasePushLockShared must be running at IRQL <= APC_LEVEL.
* This macro should usually be paired up with KeLeaveCriticalRegion.
*
*--*/
VOID
FORCEINLINE
ExReleasePushLockShared(PEX_PUSH_LOCK PushLock)
{
EX_PUSH_LOCK OldValue;
/* Sanity checks */
ASSERT(PushLock->Locked);
ASSERT(PushLock->Waiting || PushLock->Shared > 0);
/* Try to clear the pushlock */
OldValue.Value = EX_PUSH_LOCK_LOCK | EX_PUSH_LOCK_SHARE_INC;
if (InterlockedCompareExchangePointer(PushLock, 0, OldValue.Ptr) !=
OldValue.Ptr)
{
/* There are still other people waiting on it */
DbgPrint("%s - Contention!\n", __FUNCTION__);
ExfReleasePushLockShared(PushLock);
}
}
/*++
* @name ExReleasePushLockExclusive
* INTERNAL MACRO
*
* The ExReleasePushLockExclusive macro releases a previously
* exclusively acquired PushLock.
*
* @params PushLock
* Pointer to a previously acquired pushlock.
*
* @return None.
*
* @remarks The function attempts the quickest route to release the lock, which is
* to simply clear the locked bit.
* However, if the pushlock is being waited on, the slow path is taken
* in an attempt to wake up the lock.
*
* Callers of ExReleasePushLockExclusive must be running at IRQL <= APC_LEVEL.
* This macro should usually be paired up with KeLeaveCriticalRegion.
*
*--*/
VOID
FORCEINLINE
ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
{
EX_PUSH_LOCK OldValue;
/* Sanity checks */
ASSERT(PushLock->Locked);
ASSERT(PushLock->Waiting || PushLock->Shared == 0);
/* Unlock the pushlock */
OldValue.Value = InterlockedExchangeAddSizeT((PLONG)PushLock, -1);
/* Sanity checks */
ASSERT(OldValue.Locked);
ASSERT(OldValue.Waiting || OldValue.Shared == 0);
/* Check if anyone is waiting on it and it's not already waking*/
if ((OldValue.Waiting) && !(OldValue.Waking))
{
/* Wake it up */
DbgPrint("%s - Contention!\n", __FUNCTION__);
ExfTryToWakePushLock(PushLock);
}
}
/*++
* @name ExReleasePushLock
* INTERNAL MACRO
*
* The ExReleasePushLock macro releases a previously acquired PushLock.
*
* @params PushLock
* Pointer to a previously acquired pushlock.
*
* @return None.
*
* @remarks The function attempts the quickest route to release the lock, which is
* to simply clear all the fields and decrease the share count if required.
* However, if the pushlock is being waited on then the long path is taken.
*
* Callers of ExReleasePushLock must be running at IRQL <= APC_LEVEL.
* This macro should usually be paired up with KeLeaveCriticalRegion.
*
*--*/
VOID
FORCEINLINE
ExReleasePushLock(PEX_PUSH_LOCK PushLock)
{
EX_PUSH_LOCK OldValue = *PushLock;
EX_PUSH_LOCK NewValue;
/* Sanity checks */
ASSERT(OldValue.Locked);
/* Check if the pushlock is shared */
if (OldValue.Shared > 1)
{
/* Decrease the share count */
NewValue.Value = OldValue.Value &~ EX_PUSH_LOCK_SHARE_INC;
}
else
{
/* Clear the pushlock entirely */
NewValue.Value = 0;
}
/* Check if nobody is waiting on us and try clearing the lock here */
if ((OldValue.Waiting) ||
(InterlockedCompareExchangePointer(PushLock, NewValue.Ptr, OldValue.Ptr) ==
OldValue.Ptr))
{
/* We have waiters, use the long path */
DbgPrint("%s - Contention!\n", __FUNCTION__);
ExfReleasePushLock(PushLock);
}
}
/* OTHER FUNCTIONS **********************************************************/
LONGLONG
FASTCALL
ExfpInterlockedExchange64(
LONGLONG volatile * Destination,
PLONGLONG Exchange
);
NTSTATUS
ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation);
NTSTATUS
NTAPI
ExpAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId);
VOID
STDCALL
ExTimerRundown(VOID);
#define InterlockedDecrementUL(Addend) \
(ULONG)InterlockedDecrement((PLONG)(Addend))
#define InterlockedIncrementUL(Addend) \
(ULONG)InterlockedIncrement((PLONG)(Addend))
#define InterlockedExchangeUL(Target, Value) \
(ULONG)InterlockedExchange((PLONG)(Target), (LONG)(Value))
#define InterlockedExchangeAddUL(Addend, Value) \
(ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))
#define InterlockedCompareExchangeUL(Destination, Exchange, Comperand) \
(ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))
#define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand) \
(ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand))
#define ExfpInterlockedExchange64UL(Target, Value) \
(ULONGLONG)ExfpInterlockedExchange64((PLONGLONG)(Target), (PLONGLONG)(Value))
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H */

Some files were not shown because too many files have changed in this diff Show More