Commit graph

1281 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto 712f469671
[NTOS:EX] Clarify the situation with the SystemPathInformation class. (#4065)
Since NT 3.51, this information class is trivially implemented.
The path to the NT directory is now stored in KUSER_SHARED_DATA
as the NtSystemRoot member.
Windows Checked builds show the following message and break to
the debugger before failing the function as not implemented:

EX: SystemPathInformation now available via SharedUserData

See https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/query.htm
and https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/ntexapi_x/kuser_shared_data/index.htm
for more information.
2021-11-18 22:37:54 +01:00
Hermès Bélusca-Maïto 1200561fcc
[NTOS:EX] NtQuerySystemInformation: Use same parameter names as documentation. FStatus --> Status. (#4064) 2021-11-18 22:36:07 +01:00
Hermès Bélusca-Maïto d484a68ccb
[NDK][NTOS:EX] Add/fix SAL annotations for Nt/ZwSetSystemInformation + last parameter type. (#4064) 2021-11-18 22:36:07 +01:00
Hermès Bélusca-Maïto 7692a620e7
[NDK][NTOS:EX] Minor formatting. 2021-11-18 22:36:06 +01:00
George Bișoc f909e8762d
[NTOS:SE] Validate the SID lengths when capturing them
SIDs are variadic by nature which means their lengths can vary in a given amount of time and certain factors that allow for this happen. This also especially can lead to issues when capturing SIDs and attributes because SeCaptureSidAndAttributesArray might end up overwriting the buffer during the time it's been called.

Therefore when we're copying the SIDs, validate their lengths. In addition to that, update the documentation header accordingly and add some debug prints in code.
2021-11-16 10:55:44 +01:00
Thomas Faber e8b79e89eb
[NTOS:PS] Fix copypasta in NtQueryInformationJobObject. CID 1441354 2021-11-13 21:23:40 -05:00
Thomas Faber 34f2b7830d
[NTOS:IO] Correctly deal with exceptions when handling FileFsDriverPathInformation. CID 1476847 2021-11-13 21:23:39 -05:00
Thomas Faber a74ff5be17
[NTOS:IO] Don't call IopCompleteRequest with uninitialized context values. CID 716761
NormalContext and NormalRoutine are just for good measure, but
SystemArgument2 is actually used by the function.
And yes, this appears to be a bug in Win 2003.
2021-11-13 21:23:39 -05:00
Thomas Faber 8254585be5
[NTOS:EX] Assert some AcquireResource return values. CID 1321882 2021-11-13 21:23:39 -05:00
Thomas Faber aa9a098196
[NTOS:EX] Correctly handle OOM in NtFindAtom. CID 1237072 2021-11-13 21:23:36 -05:00
George Bișoc 53db5377e2
[NTOS:SE] Implement token filtering
This implements the support of token filtering within the kernel, where the kernel can create restricted tokens of regular ones on demand by the caller. The implementation can be accessed thorough a NT syscall, NtFilterToken, and a kernel mode routine, SeFilterToken.
2021-11-07 14:14:18 +01:00
George Bișoc 05d52aba2b
[NTOS:SE] Partially revert 0129de2
The continue statements do not server any useful purpose in these loops so they're basically pointless. These have been introduced by mistake so my bad.
2021-11-05 10:13:45 +01:00
Serge Gautherie 8110a66b08 [NTOS:MM] MI_IS_*(): Improve documentation
Intel 64 and IA-32 Architectures Software Developer’s Manual
version 075 (June 2021)
2021-11-04 23:20:21 +03:00
Serge Gautherie 94b8095ba2 [NTOS:KE] KiTrap0EHandler(): Use MI_IS_WRITE_ACCESS() 2021-11-04 23:20:21 +03:00
George Bișoc 0129de218b
[NTOS:SE] Mark the token as no longer belonging to admin group upon effective duplication
A scenario where it happens that an access token belongs to an administrators group but it's disabled (that is, SeAliasAdminsSid has no attributes or it doesn't have SE_GROUP_ENABLED turn ON), the function removes this group from the token but still has TOKEN_HAS_ADMIN_GROUP flag which can lead to erratic behavior across the kernel and security modules -- implying that the token still belongs to administrators group.

This is an oversight from my part.
2021-11-04 09:30:00 +01:00
Hervé Poussineau 22d1e7a4e4 [NTOS:IO] Create non volatile registry keys for root devices (as for other devices) 2021-11-01 18:16:25 +01:00
Hervé Poussineau 9967d9aa4c [NTOS:IO] Do not crash when calling IopLegacyResourceAllocation with NULL ResourceRequirements 2021-11-01 18:16:25 +01:00
George Bișoc fdb4205061
[NTOS:SE] Minor cleanup on SepDuplicateToken
The current code that searches for the primary group of token upon duplication is OK as is, remove whatever rest that's no longer needed.
2021-10-23 17:55:12 +02:00
Hervé Poussineau 46fbc6f432 [NTOS:PNP] Fix crash when removing a device without resources
This fixes commit 89fd2b86e4
2021-10-18 22:23:49 +02:00
Hervé Poussineau 89fd2b86e4 [NTOS:PNP] HACK: release resources when device is removed
CORE-17789
2021-10-14 23:39:31 +02:00
Hervé Poussineau 49358f3416 [NTOS:PNP] Fix resource conflict detection
Only resources of HAL were checked against conflicts, not those of PnP Manager

Let IoReportResourceForDetection() make a silent conflict check.
Otherwise IopCheckResourceDescriptor() will always return 'no conflict'.

CORE-17789
2021-10-14 23:39:31 +02:00
Hervé Poussineau a86c3794a6 [NTOS:IO] Remove final NULL char of PDO name before writing to registry
Otherwise, if a PDO has no name (bad!), you'll see two "(Default)" entries
in HKLM\HARDWARE\RESOURCEMAP\PnP Manager\PnpManager
2021-10-14 23:39:30 +02:00
Victor Perevertkin 43f1d91687
[NTOS:PNP] Fix resource conflict detection
Previous code did not detect equal resource ranges as conflicting.
Thanks Hervé Poussineau for pointing this out!

Meanwhile, simplify the code to make it more readable.
2021-10-13 00:00:25 +03:00
Rafał Mikrut 54d5ad7533
[NTOS:KE] Fix copy paste bug in exception helper routine for ARM (#4005) 2021-10-07 23:04:19 +03:00
George Bișoc 9c1c88de3e
[NTOS:SE] Define a name macro for the threshold value
Instead of having this magic value as is, describe it within a macro for readability purposes.
2021-09-27 09:39:23 +02:00
George Bișoc 199f575342
[NTOS:SE] Check the privilege count against the maximum threshold
In SeCaptureLuidAndAttributesArray we must ensure that we don't go onto a potential integer overflow scenario by checking against the maximum limit threshold the kernel states. In addition, write an explicit name macro for the value.
2021-09-27 09:37:28 +02:00
Hermès Bélusca-Maïto 9462350a92
[NTOS:RAWFS] LE JOKE! - Commit 7716bddd (r24564) claimed to "actually create the \\Device names so that user-mode can even talk to it", yet didn't bother to do that!
Certainly due to copy-pasta error from the original code.

A consequence of this oversight, was that the IoGetDeviceObjectPointer()
calls on these device names, in fltmgr!DriverEntry() couldn't work.
(See drivers/filters/fltmgr/Interface.c, line 1880 and below.)
2021-09-26 03:02:58 +02:00
Hermès Bélusca-Maïto 5ccd45ea58
[NTOS:RAWFS] Delete the previously-created devices in case the IoCreateDevice() calls fail. 2021-09-26 03:02:57 +02:00
Hermès Bélusca-Maïto 74513a75ab
[NTOS:OB] Minor refactoring.
- NtQuerySymbolicLinkObject(): Use an intermediate variable for the object header.
- Simplify code in ObpLookupEntryDirectory() by calling ObpReleaseLookupContextObject() instead.
- Use TAG_OBJECT_TYPE instead of hardcoded tag values.
2021-09-25 01:09:01 +02:00
Hermès Bélusca-Maïto 4c63ed5a7a
[NTOS:OB] Clarify and fix the usage of the Obp*DirectoryLock*() and ObpReleaseLookupContextObject() functions.
- Disentangle the usage of ObpAcquireDirectoryLockExclusive() when it's
  used only for accessing a directory structure, or as part of a lookup
  operation.

  The Obp*DirectoryLock*() -- both shared and exclusive -- functions
  are only for locking an OB directory, for reading or writing its
  structure members.

  When performing lookup operations (insertions/deletions of entries
  within a directory), use a ObpAcquireLookupContextLock() function that
  exclusively locks the directory and saves extra lock state, that can
  be used by ObpReleaseLookupContextObject() for cleanup.

- Add documentation for these functions.
2021-09-25 00:47:43 +02:00
George Bișoc 19cdb521d2
[NTOS:OB] Acquire the lock before setting directory's session ID 2021-09-24 19:49:40 +02:00
George Bișoc 0b4763f1b1
[NTOS:SE] Do not set SE_DACL_PRESENT flag that early
The function might assign the flag yet it could possibly fail on creating a DACL and insert an "access allowed" right to the access entry within the DACL. In this case, make sure we actually succeeded on all the tasks and THEN assign the flag that the DACL is truly present.

Also, make sure that the Current buffer size variable gets its new size so that we avoid overidding the memory of the DACL if the security descriptor wants both a DACL and SACL and so that happens that the DACL memory gets overwritten by the SACL.
2021-09-24 19:39:30 +02:00
George Bișoc f341b9080b
[NTOS:SE] Set the SACL to the World security descriptor
Implement the portion chunk of code that is responsible for setting the system access control list (SACL) to the World security descriptor, based from SeWorldSid (World security identifier).
2021-09-24 19:13:16 +02:00
George Bișoc 8e6fc7a5f5
[NTOS:SE] Implement token groups adjusting 2021-09-23 17:38:31 +02:00
George Bișoc 982ee872dd
[NTOS:SE] Privileges adjusting private routine must be paged
SepAdjustPrivileges is a private helper call that must be paged, alongside with its syscall -- NtAdjustPrivilegesToken.
2021-09-21 17:40:53 +02:00
Victor Perevertkin 62d1a2c884
[CMAKE] Fixes for clang-cl build
- User lib.exe instead of llvm-lib due to incompatibility
- Avoid wrapping resource compiler with cmcldeps
- Fix several conditional flags
2021-09-14 17:58:23 +03:00
Hermès Bélusca-Maïto 9393fc320e
[FORMATTING] Remove trailing whitespace. Addendum to 34593d93.
Excluded: 3rd-party code (incl. wine) and most of the win32ss.
2021-09-13 03:52:22 +02:00
Hermès Bélusca-Maïto 9b1edceae1
[REACTOS] Fix some instances of DPRINTs with trailing whitespace before newlines. 2021-09-13 03:52:19 +02:00
Hermès Bélusca-Maïto 6e9ff14e26
[NTOS:KD64,KE] IRQL is automatically adjusted during calls to KdEnterDebugger() and KdExitDebugger(). (#3942)
Addendum to 608032bd and 835c3023.

The IRQL is actually raised by KeFreezeExecution() and lowered by
KeThawExecution(), always to HIGH_IRQL on MP systems, or if necessary
on UP. These functions are called respectively by KdEnterDebugger()
and KdExitDebugger().
2021-09-12 18:20:32 +02:00
Hermès Bélusca-Maïto 05590079cc
[NTOS:KD64] First unlock the KD port then lower the IRQL, instead of doing the reverse. (#3942)
This properly reverses the operation of first raising the IRQL before
locking the KD port.
2021-09-12 18:19:59 +02:00
Hermès Bélusca-Maïto c9f335e996
[NTOS:KD64] KdPollBreakIn(): Use the KeRestoreInterrupts() inline. 2021-09-12 18:16:13 +02:00
George Bișoc fc5bc55fbb
[NTOS:SE] Use the captured security descriptor when access checking
When performing access security check, use the security descriptor that we've captured it to determine based on that descriptor if the client can be granted access or not.
2021-09-12 16:07:44 +02:00
George Bișoc d7255f1584
[NTOS:SE] Explicitly check the auto inherit flags right away
As we now have the SEF_* flags declared within the SDK we can simply check for such flags directly wihout having to check for the hard-coded flag values.
2021-09-09 19:29:53 +02:00
Stanislav Motylkov 3f4c98a425
[ARM] Fix some compilation errors for ARM
CORE-17634 CORE-17604
2021-09-09 19:40:20 +03:00
Hermès Bélusca-Maïto 4795d953c0
[NTOS:IO] Fix an ASSERT. Addendum to commit 1fd730b7. 2021-09-06 01:05:14 +02:00
Hermès Bélusca-Maïto fe9ac14aa3
[NTOS] Move two CODE_SEG("INIT") to a better place. 2021-09-05 21:22:45 +02:00
Hermès Bélusca-Maïto 1fd730b781
[NTOS:IO] IopInitializeDriverModule(): Set the DRVO_LEGACY_DRIVER flag if the driver is not WDM. (#3749) 2021-09-05 20:31:08 +02:00
George Bișoc c407460f6a
[NTOS:SE] Implement effective token option upon duplication
This implements the EffectiveOnly option of SepDuplicateToken routine (used by NtDuplicateToken syscall and other functions alike) which makes the access token effective by removing the disabled parts like privileges and groups.
2021-09-05 17:01:21 +02:00
George Bișoc 84f7bee18f
[NTOS:SE] SepSinglePrivilegeCheck doesn't expect a NT status code value
Fix a wrong returned datatype of the function, as SepSinglePrivilegeCheck calls the internal private SepPrivilegeCheck function which returns a BOOLEAN value.
2021-08-22 11:31:57 +02:00
George Bișoc 8567d8145e
[NTOS:SE] Annotate the remaining functions with SAL 2021-08-22 10:29:58 +02:00