Hermès Bélusca-Maïto
4caf391324
[NTOS][MKHIVE] Minor code formatting.
2018-10-14 15:59:34 +02:00
Pierre Schweitzer
3d13a464f7
[NTOSKRNL] Add the CcPinMappedDataCount counter
2018-10-13 22:51:44 +02:00
Pierre Schweitzer
1afcbbd125
[NTOSKRNL] Rewrite the way we create BCB for pinning
...
We won't reuse a BCB created for mapping, we will now have
our own dedicated BCB.
This allows having a bit more cleaner implementation of CcPinMappedData()
2018-10-13 22:51:44 +02:00
Serge Gautherie
a06b425839
[NTOS:KD] A few trivial code improvements
2018-10-12 08:43:02 +02:00
Serge Gautherie
561a10056b
[NTOS:KD] Remove an unreachable "break;"
...
On behalf of Kudratov Olimjon.
CORE-8545
2018-10-12 08:43:02 +02:00
Pierre Schweitzer
1acb5a9fab
[NTOSKRNL] Don't keep the spin lock hold too long when we lost the BCB race
...
This will avoid a deadlock on unpin.
2018-10-12 08:20:32 +02:00
Pierre Schweitzer
cf8ba3bd9c
[NTOSKRNL] Rewrite BCB handling to be more robust
...
We now handle race conditions when creating BCB to avoid
having duplicated BCB per shared maps.
Also, we already specify whether the memory will be pinned
when creating the BCB, to avoid potential duplications or
BCB misuse.
2018-10-11 23:15:01 +02:00
Pierre Schweitzer
bd39459f89
[NTOSKRNL] Implement support for PIN_IF_BCB flag
2018-10-05 21:26:16 +02:00
Pierre Schweitzer
7fd2751c87
[NTOSKRNL] When pinning data, try to find an already pinned BCB
...
If found, attempt to lock it and return it.
This fixes a lot of CcPinRead tests (and seems to speed up a bit ReactOS)
2018-10-05 21:26:16 +02:00
Pierre Schweitzer
9fc75c1132
[NTOSKRNL] When mapping data, try to find if there's already a BCB
...
If so, return such BCB instead of creating a new one. This will
allow (at some point) to be more consistent in case of concurrent
mapping.
This fixes a few CcMapData tests.
2018-10-05 21:26:16 +02:00
Pierre Schweitzer
f284947622
[NTOSKRNL] Move the PinCount out of the VACB to the BCB
...
Given current ReactOS implementation, a VACB can be pinned
several times, with different BCB. In next commits, a single
BCB will be able to be pinned several times. That would
lead to severe inconsistencies in counting and thus corruption.
2018-10-05 21:26:16 +02:00
Pierre Schweitzer
0b713d4fa0
[NTOSKRNL] On open, verify and validate the hint device object if any
2018-10-05 10:49:59 +02:00
Pierre Schweitzer
779d87b483
[NTOSKRNL] Implement IopCheckTopDeviceHint()
2018-10-05 10:49:59 +02:00
Pierre Schweitzer
670a7ac718
[NTOSKRNL] In IoGetRelatedDeviceObject(), validate hint is on the stack before returning it
2018-10-05 10:49:59 +02:00
Pierre Schweitzer
161b6728ef
[NTOSKRNL] Implement IopVerifyDeviceObjectOnStack()
2018-10-05 10:49:59 +02:00
Pierre Schweitzer
2a182931b6
[NTOSKRNL] A bit of cleanup in Io*FilterContext()
2018-10-04 22:24:52 +02:00
Pierre Schweitzer
5f0d02eb52
[NTOSKRNL] Implement IoChangeFileObjectFilterContext()
2018-10-04 19:30:39 +02:00
Pierre Schweitzer
a43fb5e054
[NTOSKRNL] Implement IoGetFileObjectFilterContext()
2018-10-04 19:30:38 +02:00
Pierre Schweitzer
e19e907a2c
[NTOSKRNL] Quickly check for alignment in NtRead/WriteFile
...
This quick check based on bits and operation is for 2^ based
sector sizes (most of the cases) and will perform faster than
the modulo operation which is still used in fallback in case
the sector size wouldn't be a power of 2.
2018-10-04 10:45:10 +02:00
Pierre Schweitzer
44155053cd
[NTOSKRNL] Use captured variable to check parameters in NtRead/WriteFile
2018-10-04 10:45:10 +02:00
Pierre Schweitzer
bf59669065
[NTOSKRNL] On read/write, also check buffer respects device alignment requirements
2018-10-04 07:56:23 +02:00
Pierre Schweitzer
1bd25c5c24
[NTOSKRNL] When checking for byte offset alignment, tolerate some magic values
2018-10-04 07:53:12 +02:00
Eric Kohl
fd33402104
[NTOSKRNL] NtReadFile/NtWriteFile: If a file has been opened for non-cached access, Length and ByteOffset must be sector size aligned.
...
This fixed two ntdll apitests.
2018-10-04 01:17:58 +02:00
Pierre Schweitzer
d8f22735ed
[NTOSKRNL] In IopQueryNameInternal(), enclose output copy in a SEH statement
2018-10-03 22:55:23 +02:00
Pierre Schweitzer
15b9a6aa4c
[NTOSKRNL] Call IoCreateFileSpecifyDeviceObjectHint with the hint if it was specified
2018-10-03 21:29:12 +02:00
Pierre Schweitzer
520f404e9c
[NTOSKRNL] In IoQueryFileDosDeviceName(), in case of an error, return appropriate status
2018-10-03 17:08:42 +02:00
Pierre Schweitzer
8c6c5a92e8
[NTOSKRNL] Implement DOS name query in IopQueryNameInternal()
2018-10-03 13:56:18 +02:00
Pierre Schweitzer
769157f6ff
[NTOSKRNL] Allow FileNameInformation not to be implemented in storage stack
2018-10-03 13:52:05 +02:00
Pierre Schweitzer
46bda8a4c6
[NTOSKRNL] In IopQueryNameInternal() don't copy name if it's not valid
2018-10-03 13:50:16 +02:00
Pierre Schweitzer
4a7e89770e
[NTOSKRNL] Implement IoQueryFileDosDeviceName()
2018-10-03 11:56:21 +02:00
Pierre Schweitzer
abfddca8bb
[NTOSKRNL] Stub support for querying DOS name when parsing FO name
2018-10-03 11:45:08 +02:00
Pierre Schweitzer
a1401a7577
[NTOSKRNL] Use faster internal helper to query name
...
This only applies if we're called from kernel mode
with a synchronous file.
2018-10-03 10:22:33 +02:00
Pierre Schweitzer
1348f62f20
[NTOSKRNL] Rename IopQueryNameFile to IopQueryNameInternal
2018-10-03 10:22:33 +02:00
Thomas Faber
8fbc488050
[NTOS:IO] Implement IopAcquireFileObjectLock and use it to fix IopLockFileObject
2018-10-02 09:56:55 +02:00
Pierre Schweitzer
fd8893e58f
[NTOSKRNL] Respect PFN cache attribute when required
...
This fixes noisy DPRINT1 being printed while reading
or writing files with NFS.
2018-10-01 20:59:37 +02:00
Pierre Schweitzer
890a293683
[NTOSKRNL] Fix remaining access computation on open
2018-09-30 10:55:44 +02:00
Pierre Schweitzer
6d0c07c44f
[NTOSKRNL] Implement access check for secure open
2018-09-30 10:55:43 +02:00
Pierre Schweitzer
cf25432eed
[NTOSKRNL] Don't lock file object on close if we're not called by Ob
...
IopCloseFile can be called by IopDeleteFile. In that situation, it
doesn't set any process as first parameter. Furthermore, we are in a
situation where it's not required to lock the file object (see the
assert before the call).
2018-09-29 16:25:58 +02:00
Pierre Schweitzer
207ff9444e
[NTOSKRNL] Reference the file object before issuing the unlock all IRP
...
This fixes the last kmode assert triggered by httpd on ReactOS.
CORE-12045
2018-09-29 11:22:22 +02:00
Pierre Schweitzer
5472c1db82
[NTOSKRNL] Unlock file if required on last process handle close
2018-09-28 23:34:28 +02:00
Hermès Bélusca-Maïto
89c5191d3f
[NTOS:PS] In PspSetPrimaryToken(), check also for sibling token to determine whether it is required to have the SeAssignPrimaryTokenPrivilege.
...
In addition, it is the presence or absence of the 'Token' pointer that indicates whether or not we should use instead the provided token handle.
2018-09-28 00:45:03 +02:00
Hermès Bélusca-Maïto
7f9282927b
[NTOS:SE] Fixes for NT tokens.
...
- SeIsTokenChild(): Correctly check whether a caller-provided token
is a child from the current process' primary token by looking at
its ParentTokenId member.
- Add a SeIsTokenSibling() helper to determine whether a caller-provided
token and the current process' primary token are siblings, by comparing
their ParentTokenId's and AuthenticationId's.
NOTE: Children tokens are created through CreateRestrictedToken();
sibling tokens are created through DuplicateToken() (amongst others).
See slide 49 of https://www.slideshare.net/Shakacon/social-engineering-the-windows-kernel-by-james-forshaw
or https://googleprojectzero.blogspot.com/2016/01/raising-dead.html
for some details.
2018-09-28 00:45:01 +02:00
Pierre Schweitzer
2a80ae2bb6
[NTOSKRNL] Properly align VACB writes
...
Also simplify VACB reads alignment code.
Also add some sanity ASSERTs.
2018-09-23 10:32:14 +02:00
Eric Kohl
e32a2cc026
[NTOSKRNL] IoGetDeviceProperty: Add support for the DevicePropertyRemovalPolicy property.
...
This could probably fix CORE-15068.
2018-09-22 11:22:22 +02:00
Eric Kohl
e1b82b5b91
[NTOSKRNL] Create the 'Device Parameters' subkey and add the 'FirmwareIdentified' value for all ACPI-enumerated devices.
2018-09-21 15:37:34 +02:00
Eric Kohl
2550325577
[NTOSKRNL] Fix the indentation of some pnp manager functions.
2018-09-21 15:08:43 +02:00
Pierre Schweitzer
15a3ca08b0
[NTOSKRNL] Avoid integer overflow when computing VACB read/write size
...
This could be triggered when attempting to read/write to really big
files. It was causing an attempt to read 0 bytes in Cc, leading to
asserts failure in the kernel (and corrupted file).
CORE-15067
2018-09-21 08:37:20 +02:00
Pierre Schweitzer
108991a6fb
[NTOSKRNL] Stub IoInitializeCrashDump()
...
Also call it from NtCreatePagingFile() when we have successfully created
a paging file on the system boot partition.
2018-09-18 21:59:59 +02:00
Pierre Schweitzer
02da7b452c
[NTOSKRNL] Move data mapping implementation to an internel helper
2018-09-09 14:02:13 +02:00
Pierre Schweitzer
3dabca398f
[NTOSKRNL] Don't raise a status when parameters are invalid on file mapping
2018-09-05 22:06:29 +02:00