Commit graph

502 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto 06d4fce5ee
[NTOS:MM] Some fixes for NtCreatePagingFile().
- Correctly probe the FileName user pointer before capturing its contents.
- A paging file name with zero length is invalid too.
- Remember (TODO!) in the code that the lower bounds of the Safe*Size values
  need to be checked too!
2019-01-28 22:22:56 +01:00
Yaroslav Kibysh 5910a443c3 [NTOS:INBV] Fix the rotation line bitmap (#1295) 2019-01-23 13:24:40 +01:00
Jérôme Gardou 5d6c286981 [NTOS/KE] Add diagnosis DPRINT for CORE-15642 2019-01-21 09:38:29 +01:00
Thomas Faber 21ea19c40f
[NTOS:KE] Remove unnecessary breakpoint in KiRaiseException. CORE-15640 2019-01-20 09:57:03 +01:00
Timo Kreuzer 3410b25fde [NTOS] Turn broken assert into DPRINT 2019-01-19 13:38:24 +01:00
Timo Kreuzer 65dbfc2868
[NTOS:Mm] Rewrite MiWriteProtectSystemImage (#749)
* The previous version was overcomplicated and broken and therefore disabled.
* The new version also enforces NX protection on x64.
* Now that protecting works, also protect the boot loaded images.
2019-01-18 22:11:43 +01:00
Yaroslav Kibysh 0d86ab6a18 [NTOS:INBV] Update the boot screen's rotation bar's image (#1256)
Make it smoother than what it currently is.
2019-01-17 20:45:40 +01:00
Pierre Schweitzer d9a3fd16d4
[NTOSKRNL] Add support for callback when enumerating large pool allocations 2019-01-15 22:07:35 +01:00
Thomas Faber e7de564bfc
[NTOS:MM] Implement big pool table expansion. CORE-15051 2019-01-09 08:18:38 +01:00
Pierre Schweitzer a3f8813fff
[NTOSKRNL] Add support for large allocations in !poolfind 2019-01-08 08:43:23 +01:00
Pierre Schweitzer e1342127f0
[NTOSKRNL] In !irpfind, add info about current stack major/minor 2019-01-08 08:43:23 +01:00
Pierre Schweitzer e6a1851684
[NTOSKRNL] Misc fixes to !irpfind 2019-01-06 23:21:20 +01:00
Pierre Schweitzer 36f90e7e46
[NTOSKRNL] Move KDBG MM functions implementation to their own file 2019-01-06 22:50:57 +01:00
Pierre Schweitzer 25e14ae2a8
[NTOSKRNL] Fix !irpfind usage message 2019-01-06 13:00:43 +01:00
Pierre Schweitzer 28193399ee
[NTOSKRNL] Properly check for address validity in !poolfind 2019-01-06 12:58:14 +01:00
Pierre Schweitzer 47b48520b5
[NTOSKRNL] Reimplement !irpfind using !poolfind helpers
This allows avoiding one of the previous implementation limits:
leaked IRP not queued to a thread are now totally visible since
we look directly in the memory pool.
2019-01-06 12:49:57 +01:00
Pierre Schweitzer 12e579567c
[NTOSKRNL] Implement !poolfind command in KDBG
For now, it allows searching for pool allocations in
both paged and non paged pool.

It is based on Andreas Schuster work to identify POOL_HEADER
structures.
2019-01-06 11:56:38 +01:00
Timo Kreuzer cfd1647914
[REACTOS] Fix misc 64 bit issues (#783)
* [WIN32K] Fix handle calculation in DbgGdiHTIntegrityCheck
* [NOTEPAD] Fix MSVC warnings
* [PSDK] Simplify *PROC definitions in windef.h
* [VIDEOPRT] Don't try to use NtVdmControl on x64
* [FREELDR] Fix some macros
* [CRT] Make qsort 64 bit compatible
* [NTOS] Use #ifndef _WIN64 instead of #ifdef _M_IX86 around C_ASSERTs
* [FAST486] Fix 64 bit warnings and change DWORD to ULONG, so it can be used in kernel mode
* [APPHELP_APITEST] Fix 64 bit issue
2019-01-05 10:50:11 +01:00
Pierre Schweitzer d6dc1fd231
[NTOSKRNL] Add a raw implementation of !irpfind in kdbg
This is far from perfect, and totally doesn't match the
WinDBG way of doing it. Instead of browsing pool to find
matching 'IRP' tags, we just browse all the processes
to find the queued IRP. This requires the IRPs to be queued,
obviously, and will make us miss the leaked IRPs, for instance.

Proper way to do it would be to implement !poolfind and then
rely on its implementation to find our IRPs.

Perhaps later ;-)
2019-01-01 22:00:56 +01:00
Hermès Bélusca-Maïto 3fc3447f3e
Happy New Year 2019 everybody! 2019-01-01 00:00:00 +01:00
Pierre Schweitzer 1a93d83f92
[SDK] Add PsGetCurrentThreadTeb() to the DDK 2018-12-31 11:19:35 +01:00
Hermès Bélusca-Maïto bf6b5e1ceb
[NTOS] Fix a NULL-pointer access bug. 2018-12-30 15:26:43 +01:00
Hermès Bélusca-Maïto fefb982d64
[NTOS] Don't use TAG_IO_NAME when calling ExFreePoolWithTag() for freeing FileObject->FileName.Buffer .
This may look strange, since this buffer is originally allocated using
the TAG_IO_NAME tag. However, it happens that file-system drivers are
allowed to re-allocate this buffer: this is what the MS' open-sourced
CDFS driver does, see e.g. CdCommonCreate() and CdNormalizeFileNames()
in cdfs/create.c .

This fixes a pool tag mismatch 'mNoI' != 'nFdC' BSOD when resources
are freed when closing a file that has been opened with a relative name
on a CDFS-mounted volume.
2018-12-30 15:26:42 +01:00
Hermès Bélusca-Maïto d3a97e2228
[NTOS] Code formatting only. 2018-12-30 15:26:35 +01:00
Timo Kreuzer 71fefa32db
[NDK][NTOS] Add global definition of INIT_FUNCTION/INIT_SECTION (#779)
* Add an NDK header to define INIT_FUNCTION/INIT_SECTION globally
* Use _declspec(allocate(x)) and _declspec(code_seg(x)) on MSVC versions that support it
* Use INIT_FUNCTION on functions only and INIT_SECTION on data only (required by MSVC)
* Place INIT_FUNCTION before the return type (required by MSVC)
* Make sure declarations and implementations share the same modifiers (required by MSVC)
* Add a global linker option to suppress warnings about defined but unused INIT section
* Merge INIT section into .text in freeldr
2018-12-30 12:19:11 +01:00
Eric Kohl aecc523b6a [NTOS:IO] Fix indentation. No code changes. 2018-12-29 17:49:38 +01:00
Mark Jansen ec5c0c926b
[NTOS] When checking something for NULL, let's initialize it to NULL... 2018-12-27 23:03:22 +01:00
Eric Kohl 079f7027f6 [NTOS:IO] When a device has been started, create an Enum sub key to its service key and add the device instance name to the Enum sub key. 2018-12-25 23:04:27 +01:00
Pierre Schweitzer e16241255d
[NTOSKRNL] Set the MemoryMaker flag when executing write behind 2018-12-23 14:59:42 +01:00
Pierre Schweitzer 7e97071c8b
[NTOSKRNL] Implement write behind in Cc
For now, this is just a split between scan and flush that
were both done during lazy scan previously.
Lazy scan shouldn't perform any write operation, but only
queue a write behind operation.

Our implementation is far from the original, as it seems
our lazy scan should queue a write behind operation per
shared cache map. Right now, we only perform global
operation.
2018-12-23 14:45:38 +01:00
Pierre Schweitzer 1a267045f8
[NTOSKRNL] Honor files that shouldn't be lazy written 2018-12-23 12:10:58 +01:00
Pierre Schweitzer 0917c64812
[NTOSKRNL] When growing a file, invalid the last VACB so that it can be refreshed
This will avoid corruption when a file size is little grown and read afterwards.
Up to now, FSD where reading 0es instead of expected data, causing corruption.

This fixes MS FastFAT not being able to mount a FAT volume in ReactOS, corrupting
the FAT.
This also fixes the CcSetFileSizes kmtest tests.

This is based on a patch by Thomas Faber.

CORE-11819
2018-12-23 11:19:14 +01:00
Serge Gautherie 4d1f13cf77 [NTOS:CC] CcCanIWrite(): Use BYTES_TO_PAGES(Length) 2018-12-21 19:20:59 +01:00
Pierre Schweitzer 1435ff95b4
[NTOSKRNL] Don't call AcquireForLazyWrite with the master lock held
This incorrect behavior was leading to a call at too high IRQL for paged code.
This was triggered by MS FastFAT.

ReleaseFromLazyWrite call was already correctly called to that regard.

CORE-11819
2018-12-21 08:46:40 +01:00
Hermès Bélusca-Maïto b2bad34b9b
[NTOS] Addendum to 03873aee: check that the computed size of the OEM-converted string is less than MAXUSHORT. 2018-12-21 00:34:56 +01:00
Pierre Schweitzer daf9743c7b
[NTOSKRNL] Check that caller has the priviliege to unload a driver
Also, probe the service name when unloading a driver if called from
user-mode. This will avoid that userland applications can trigger an
invalid read in the kernel (and thus, a BSOD).

CORE-15468
2018-12-20 08:50:51 +01:00
Hermès Bélusca-Maïto bc5acd8102
[NTOS] Minor formatting + don't hardcode sizeof(UCHAR) value. 2018-12-20 03:47:46 +01:00
Hermès Bélusca-Maïto f4597b5540
[NTOS] Addendum to d8cb37bf: return the correct Status from NtAllocateUuids(). 2018-12-20 03:47:45 +01:00
Hermès Bélusca-Maïto 03873aeef3
[NTOS] Fixes for NtDisplayString().
- Require the user to have TCB privilege for using this function.
- Probe and capture the user-provided string (and avoid usermode-triggered BSODS ;-)
- Allocate the OEM-converted string in *NonPagedPool* because we are
  going to transmit the buffer to BOOTVID.
2018-12-20 03:47:36 +01:00
Pierre Schweitzer 4f8b041bf0
[NTOSKRNL] Drop the ViewLock mutex in favour of the master spin lock
This will allow Cc calls during DPC, which is required by MS FastFAT

CORE-11819
2018-12-19 22:51:45 +01:00
Eric Kohl b67dbdbea5 [NTOSKRNL] Fix indentation. No code changes. 2018-12-19 19:18:21 +01:00
Eric Kohl 7e56b21ad6 [NTOSKRNL] Fix indentation. No code changes. 2018-12-19 19:18:20 +01:00
Pierre Schweitzer 549793b8a4
[NTOSKRNL] Fix copy/pasta ;-) 2018-12-19 08:15:11 +01:00
Pierre Schweitzer d8cb37bf15
[NTOSKRNL] Probe parameters in NtAllocateUuids() if called from user-mode
This will avoid that userland applications can trigger an invalid write in
the kernel (and thus, a BSOD).

CORE-15462
2018-12-19 08:09:04 +01:00
Pierre Schweitzer 6ca1c55c6e
[NTOSKRNL] Only allow SYSTEM to call NtSetUuidSeed()
Also, validate input buffer before attempting any operation on it.
This will avoid userland applications to be able to trigger an invalid
read in the kernel (and thus a BSOD).

Regarding access restriction, see:
https://stackoverflow.com/questions/1254244/need-access-to-ntsetuuidseed-from-a-non-localsystem-process

CORE-15460
2018-12-18 23:12:41 +01:00
Eric Kohl 167bffd80f [NTOSKRNL] Add and call the CmpSaveBootControlSet() stub. 2018-12-16 12:49:59 +01:00
Eric Kohl e8d16d0a7d [NTOSKRNL] Fix indentation. No code changes. 2018-12-16 10:30:23 +01:00
Andrew Boyarshin 3ba51dc218 [NTOS:MM] Fix typo in MiCheckForUserStackOverflow 2018-12-12 12:57:08 +01:00
Eric Kohl 12fdc129cf [NTOSKRNL] IopGetDeviceProperty: Send an IRP_MN_QUERY_CAPABILITIES request to the device in order to query the power capabilities. 2018-12-10 00:37:04 +01:00
Pierre Schweitzer 962b2fd66a
[NTOSKRNL] Implement SystemDpcBehaviourInformation query 2018-12-09 20:54:40 +01:00
Pierre Schweitzer 13d9d3ebbf
[NTOSKRNL] Also account PRCBs for Io operations counters 2018-12-09 19:30:07 +01:00
Pierre Schweitzer e632375851
[NTOSKRNL] For SystemPerformanceInformation, return some info extracted from PRCB
This notably includes the amount of context switchs and system calls.
2018-12-09 18:56:50 +01:00
Pierre Schweitzer 4d974e56ee
[NTOSKRNL] Return the amount of hits in system lookaside lists in ExQueryPoolUsage() 2018-12-09 18:25:11 +01:00
Timo Kreuzer 431643b9b3 [NTOS:LPC] Add a number of DPRINTs on failure 2018-12-09 03:16:19 +01:00
Pierre Schweitzer 182cc5c5ab
[NTOSKRNL] Don't dereference VACB when allocating its memory area fails
This avoids performing a double-free (even though that's hidden by the
fact we use lookaside allocations for VACB), and it avoids freeing
a memory address at an uninitialized address.
We don't care about references here, the VACB was just allocated, never
linked and we're its only user.

CORE-15413
2018-12-08 19:56:03 +01:00
Pierre Schweitzer 67e7399164
[NTOSKRNL] Use proper enum type for IopCreateSecurityDescriptorPerType() 2018-12-04 19:20:47 +01:00
Pierre Schweitzer 73e7a5d474
[NTOSKRNL] Use the appropriated security descriptor when creating a device
CORE-9176
2018-12-04 19:13:57 +01:00
Pierre Schweitzer 36c38c45ee
[NTOSKRNL] Implement IopCreateDefaultDeviceSecurityDescriptor() and IopCreateSecurityDescriptorPerType()
CORE-9176
2018-12-04 19:13:57 +01:00
Andrew Boyarshin 198601a101 [NTOS:IO] Tiny improvement to debug message
Add quotes around string, since it is often empty, thus confusing in log.
2018-11-25 11:31:12 +01:00
Bernhard Feichtinger 8a0495063b [NTOS:MM] Handle unimplemeted case for MiCheckForUserStackOverflow 2018-11-25 11:29:18 +01:00
Hermès Bélusca-Maïto f87d9caf77 [NTOS:IO] Finally remove the dreadful IopParseDevice() hack! \o/ 2018-11-25 09:00:40 +01:00
Pierre Schweitzer 4f1e9252f1
[NTOSKRNL] ExfReleaseRundownProtectionCacheAware*() functions don't return anything 2018-11-17 17:36:18 +01:00
Pierre Schweitzer 7ed17cd714
[NTOSKRNL] Implement ExfReInitializeRundownProtectionCacheAware()
We're done with cache-aware rundown protections!
2018-11-17 16:44:37 +01:00
Pierre Schweitzer 05cca64448
[NTOSKRNL] Implement ExfRundownCompletedCacheAware() 2018-11-17 16:44:37 +01:00
Pierre Schweitzer fed61c6305
[NTOSKRNL] Replace ExGetRunRefForCurrentProcessor() by a more generic function 2018-11-17 16:44:36 +01:00
Pierre Schweitzer 7e849470af
[NTOSKRNL] Implement ExfWaitForRundownProtectionReleaseCacheAware() 2018-11-17 16:44:36 +01:00
Pierre Schweitzer acdf74aa3b
[NTOSKRNL] Properly align runrefs on SMP in ExInitializeRundownProtectionCacheAware() 2018-11-17 16:44:36 +01:00
Pierre Schweitzer c5db202bdc
[NTOSKRNL] Properly align allocation on SMP in ExAllocateCacheAwareRundownProtection() 2018-11-17 16:44:36 +01:00
Pierre Schweitzer 36fadc2dca
[NTOSKRNL] Implement ExfAcquireRundownProtectionCacheAwareEx(), ExfReleaseRundownProtectionCacheAwareEx() 2018-11-17 16:44:35 +01:00
Pierre Schweitzer afb2214154
[NTOSKRNL] Simplify implementation of ExfAcquireRundownProtectionCacheAware(), ExfReleaseRundownProtectionCacheAware() 2018-11-17 16:44:35 +01:00
Pierre Schweitzer 010b9b5469
[NTOSKRNL] Implement ExGetRunRefForCurrentProcessor() to get runref for a proc 2018-11-17 16:44:35 +01:00
Pierre Schweitzer 7e36e76d5d
[NTOSKRNL] Implement ExfAcquireRundownProtectionCacheAware(), ExfReleaseRundownProtectionCacheAware() 2018-11-17 16:44:35 +01:00
Pierre Schweitzer 47d309b262
[NTOSKRNL] Implement ExSizeOfRundownProtectionCacheAware() 2018-11-17 16:44:35 +01:00
Pierre Schweitzer ce94d37dbe
[NTOSKRNL] Implement ExInitializeRundownProtectionCacheAware() 2018-11-17 16:44:35 +01:00
Pierre Schweitzer bc77f83888
[NTOSKRNL] Implement ExAllocateCacheAwareRundownProtection() and ExFreeCacheAwareRundownProtection() 2018-11-17 16:44:34 +01:00
Pierre Schweitzer a0c33934fc
[NTOSKRNL] Properly check for negative values in IoCheckEaBufferValidity()
CID 1441355, 1441382
2018-11-16 22:07:08 +01:00
Pierre Schweitzer 95bc44e214
[NTOSKRNL] Don't leak DACL
Spotted by Thomas :-)
2018-11-11 23:21:36 +01:00
Hermès Bélusca-Maïto cbaa8e7dfb
[NTOS:IO] RAW-FS: Few improvements.
- Simplify the volume-deletion code in RawCheckForDismount().

- Fixes the OpenCount check in RawClose(): the VCB mutex must be
  released when the volume has not been dismounted, either because
  OpenCount != 0 or because RawCheckForDismount() returned FALSE.

- Explicitly use VCB_STATE_LOCKED instead of hardcoding its value.

- In IRP_MN_VERIFY_VOLUME handling, lock the volume before playing
  with it, and again let the volume be dismounted only if OpenCount == 0
  (and the IoDeleteDevice() call is done by RawCheckForDismount()).
2018-11-11 21:56:18 +01:00
Hermès Bélusca-Maïto a5ead049d9
[NTOS:IO] RAW-FS: Minor code formatting only. 2018-11-11 21:56:17 +01:00
Pierre Schweitzer 6747dacf10
[NTOSKRNL] Create a security descriptor for the \security directory object 2018-11-10 23:25:10 +01:00
Pierre Schweitzer 102ba75f15
[NTOSKRNL] Return security descriptor size when querying object basic info 2018-11-10 10:54:10 +01:00
Pierre Schweitzer 1fb32afefa
[NTOSKRNL] Return quota information when querying object basic info 2018-11-10 10:54:06 +01:00
Jérôme Gardou df25e4e791 [NTOS/MM] Properly handle page faults in regions marked with
PAGE_NOACCESS or PAGE_GUARD

ROSTESTS-110
2018-11-03 12:50:16 +01:00
Jérôme Gardou 47ac7a2b28 [NTOS/MM] Move up MmAlterViewAttributes for later use in MmNotPresentFaultSectionView
No code change
2018-11-03 12:50:16 +01:00
Pierre Schweitzer cf7969fbfa
[NTOSKRNL] Fix refcounting for BCBs
Now, we make sure that we update ref count and BCB list membership
with the BCB lock held, in a row.
This will avoid race conditions where the BCB was removed from the
list, then referenced again, leading to inconsistencies in memory
and crashes later on.
This could notably be triggered while building ReactOS on ReactOS
(one would call this a regression).

CORE-15235
2018-10-28 20:48:01 +01:00
Pierre Schweitzer 03294dd097
[NTOSKRNL] Rewrite IoCheckEaBufferValidity() so that it's less magic
And make its coding style consistent with our rules
2018-10-27 22:16:37 +02:00
Pierre Schweitzer 07e6af6aa1
[NTOSKRNL] Properly handle "big" security descriptors in ObpCaptureObjectCreateInformation() 2018-10-27 19:36:15 +02:00
Pierre Schweitzer 2ce071d19a
[NTOSKRNL] Implement SeComputeQuotaInformationSize() 2018-10-27 19:36:14 +02:00
Pierre Schweitzer 9c6037182c
[NTOSKRNL] Add support for unsecure object names 2018-10-27 12:01:38 +02:00
Pierre Schweitzer 0f36353551
[NTOSKRNL] Implement the ObpIsUnsecureName() helper function 2018-10-27 12:01:38 +02:00
Pierre Schweitzer b9423f07d9
[NTOSKRNL] Add support for the ObUnsecureGlobalNames registry key 2018-10-27 12:01:38 +02:00
Pierre Schweitzer 8e51bb6510
[NTOSKRNL] Reduce noise 2018-10-27 10:04:22 +02:00
Pierre Schweitzer 18f3922725
[NTOSKRNL] Call internal helper to get VACB on mapping
We already properly round our offset
2018-10-27 09:38:55 +02:00
Hermès Bélusca-Maïto 83d5c711b3
[NTOS] Drastically reduce the hackish function CmpGetRegistryPath() for the text-mode setup case (it should ultimately completely disappear).
svn path=/branches/setup_improvements/; revision=75163
2018-10-25 00:40:03 +02:00
Hermès Bélusca-Maïto cb69c4c691
[NTOS] Add some DPRINTs in IopLoadServiceModule() and IopOpenRegistryKeyEx() to investigate why these 1st-stage text-mode hacks may be, or are (respectively) still needed.
svn path=/branches/setup_improvements/; revision=74748
2018-10-25 00:40:03 +02:00
Hermès Bélusca-Maïto 2ed65d1555
[NTOS] Configuration Manager fixes.
- Rework CmpSetSystemValues() and remove its 1st-stage text-mode setup hack, since a real registry hive will be used for 1st-stage either.
- Lock, then unlock the registry in NtInitializeRegistry when initializing the hives & flusher.
- Call CmpInitializeHiveList() (i.e., initialize the other hives like \Software, \User, \.Default) only when we are not in setup-mode.

svn path=/branches/setup_improvements/; revision=74747
2018-10-25 00:40:02 +02:00
Hermès Bélusca-Maïto e2cb7b50b4
[NTOS] Remove some hacks that are not needed anymore, since a real registry hive will be used in 1st-stage as well.
This reverts a7c26408 (r53255) and ff75ae1b (r53694), and a hack from 6075ae9a (r46690).

svn path=/branches/setup_improvements/; revision=74745
svn path=/branches/setup_improvements/; revision=74746
2018-10-25 00:40:00 +02:00
Pierre Schweitzer f3b9beeb39
[NTOSKRNL] Translate pinning flags to mapping flags when first mapping a file 2018-10-23 22:07:53 +02:00
Hermès Bélusca-Maïto 0e6bc236a1
[NTOS:CM] CmpCmdHiveOpen(): Resolve FileAttributes->RootDirectory when a hive file name is provided relative to it.
Fixes registry hive loading. CORE-13448
2018-10-22 00:39:50 +02:00
Hermès Bélusca-Maïto d61c00c252
[NTOS:CM] Implement more support for force-unloading registry hives.
CORE-13448 CORE-10705
2018-10-22 00:05:13 +02:00