Commit graph

570 commits

Author SHA1 Message Date
Thomas Faber d3fa3b0ca2
[NTOS:CM] Check for correct status from ZwQueryObject. CORE-15882
Fixes regression in ntdll_apitest:NtLoadUnloadKey from d570482bc7.
2019-05-05 17:57:12 +02:00
Thomas Faber 5706f6e9f4
[NTOS:PNP] Reduce the size of the pool buffer in IopGetParentIdPrefix. CORE-15882 2019-05-05 10:39:29 +02:00
Thomas Faber 2f1fab41fa
[NTOS:CM] Reduce the size of some unnecessarily large stack buffers. CORE-15882 2019-05-05 10:39:26 +02:00
Thomas Faber 047a3bf79a
[NTOS:CM] Simplify CmpGetRegistryPath to avoid unnecessary stack buffers. CORE-15882 2019-05-05 10:39:22 +02:00
Thomas Faber d570482bc7
[NTOS:CM] Avoid a fixed-length stack buffer in CmpCmdHiveOpen. CORE-15882 2019-05-05 10:39:18 +02:00
Thomas Faber 26ab9f8a03
[NTOS:CM] Avoid a fixed-length stack buffer in CmpAddToHiveFileList. CORE-15882 2019-05-05 10:39:14 +02:00
Thomas Faber f3a280f52b
[NTOS] Use correct buffer size when calling MiResolveImageReferences. CORE-15882 2019-05-05 10:39:11 +02:00
Thomas Faber ccb91bebbe
[NTOS:PNP] Avoid a fixed-length stack buffer in IopActionConfigureChildServices. CORE-15882 2019-05-05 10:39:07 +02:00
Thomas Faber e1b20681f5
[NTOS:IO] Avoid a fixed-length buffer in IopGetDriverObject. CORE-15882 2019-05-05 10:39:01 +02:00
Thomas Faber 6fdff1f970
[NTOS:KDBG] Avoid use of MAX_PATH. CORE-15882 2019-05-05 10:38:10 +02:00
Mark Jansen 2450dec427
[NTOS/MM] Ensure ImageBase is not used uninitialized 2019-04-30 18:57:43 +02:00
Hermès Bélusca-Maïto 884db2ea06
[NTOS:CM] In CmpParseKey(), do not assert but instead correctly return failure if CmpHandleExitNode() doesn't return a valid node, or CmpCreateKeyControlBlock() fails. 2019-04-22 21:09:10 +02:00
Hermès Bélusca-Maïto 627b1df579
[NTOS] Fix typos. 2019-04-22 19:41:19 +02:00
Bernhard Feichtinger f5471b7b4b
[NTOS][USERSRV] Silence noisy debug output. 2019-04-22 17:41:17 +02:00
Eric Kohl cfe54aa4b5 [NTOSKRNL] Revert f71588ff as it seems to break the tests 2019-04-20 23:26:57 +02:00
Pierre Schweitzer 335b906ca8
[NTOSKRNL] Drop the useless Timestamp field 2019-04-20 11:31:59 +02:00
Pierre Schweitzer 77b6899d89
[NTOSKRNL] Don't set VACB dirty on release if already dirty
CORE-15954
2019-04-20 11:23:35 +02:00
Pierre Schweitzer bd75947372
[NTOSKRNL] Drop the no longer needed Dirty field
CORE-15954
2019-04-18 08:14:41 +02:00
Pierre Schweitzer 8b6696fcdb
[NTOSKRNL] Don't mark VACB dirty on unpin
This could happen if BCB was marked dirty previously.
Marking VACB dirty on unpin could lead to a double write of
the VACB, even if clean.
Indeed, now that setting BCB dirty leads to marking VACB
dirty, the VACB can be flushed in between by the lazy-writer.
The BCB state is not reset on VACB flush, contrary to the VACB state.
Thus, on unpin even if the VACB was already flushed, we were
setting back the dirty state, leading the VACB to be flushed again.

This could bring a small performance downgrade. Though it remains
limited since this is mostly used for FS metadata.
Possibly it could lead to metadata corruption, but this is likely
less possible.

CORE-15954
2019-04-17 22:35:19 +02:00
Eric Kohl f71588ff7a [NTOSKRNL] NtPowerInformation: Report an AC powered machine by default. 2019-04-16 20:41:21 +02:00
Eric Kohl fb36723066 [NTOSKRNL] Initialize GUID_DEVICE_BATTERY properly 2019-04-08 21:19:57 +02:00
Hervé Poussineau 4d1a8f8f54 [NTOS:FSRTL] Use _SEH2_AbnormalTermination() instead of _abnormal_termination()
We're already using SEH2 macros, so also use SEH2 functions
2019-04-07 19:28:18 +02:00
Eric Kohl 626aaf227c [NTOSKRNL] Use global power capabilities and report button presence
- Add and initialize a global power capabilities variable.
- Return the global power capabilities via NtPowerInformation.SystemPowerCapabilities.
- Report the presence of power button, sleep button and lid.
2019-04-07 16:42:58 +02:00
Jérôme Gardou 979972b900 [CMAKE] unset EXPORT_SYMBOL for modules and shared libraries
We don't use that
2019-04-06 17:43:38 +02:00
Bartosz Brachaczek d256ff6006
[NTOSKRNL] Do not try to access OldBackTracking[-1]
It can be triggered by the existing "F<", "FILE.TXT" case in the tests.

CORE-15902
2019-04-01 08:28:00 +02:00
Bartosz Brachaczek 695e00fbbd
[NTOSKRNL] Unify buffer size calculation in FsRtlIs{Name,Dbcs}InExpression
It better captures the intent now in FsRtlIsNameInExpressionPrivate and
fixes a slight overallotion by 4 bytes in FsRtlIsDbcsInExpression.

While at it, use the ANSI_DOS_DOT macro in the Dbcs version.

CORE-15902
2019-04-01 08:27:59 +02:00
Bartosz Brachaczek e9b438bfaa
[NTOSKRNL] Addendum to 21d2c70: properly start DOS_START loop
Fixes last failing test.

CORE-15902
2019-03-31 19:35:25 +02:00
Maxim Smirnov d29e216f99 [NTOSKRNL] In MmCreateImageSection, properly check whether cache was initialized
This fixes a crash that occurs if nul is typed in cmd.exe
2019-03-31 13:51:06 +02:00
Bartosz Brachaczek 8bc9935fcb
[NTOSKRNL] Properly copy backtracking buffer content on realloc
CORE-15902
2019-03-31 11:44:01 +02:00
Bartosz Brachaczek 21d2c70bb4
[NTOSKRNL] Properly compare position to name length in FsRtlIsNameInExpressionPrivate
CORE-15902
2019-03-31 11:44:00 +02:00
Bartosz Brachaczek 5d5e9c8486
[NTOSKRNL] Don't overflow backtrack stack buffer
CORE-15902
2019-03-31 11:44:00 +02:00
Bartosz Brachaczek b1ae592e7f
[NTOSKRNL] Don't oversize buffer for backtracking in FsRtlIsNameInExpressionPrivate
CORE-15902
2019-03-31 11:44:00 +02:00
Thomas Faber d605b5063f
[NTOS:IO] Send IRPs to the correct device in IoVolumeDeviceToDosName. CORE-15415 2019-03-30 10:13:27 +01:00
Pierre Schweitzer 3a5063948e
[MEH] Forgot that file :-( 2019-03-29 21:51:41 +01:00
Pierre Schweitzer ef8b1a1907
[NTOSKRNL] We don't need an event if we don't issue an IRP 2019-03-29 21:47:34 +01:00
Pierre Schweitzer 28ba29e457
[NTOSKRNL] Implement support for FileFsDriverPathInformation in NtQueryVolumeInformationFile 2019-03-29 21:42:42 +01:00
Pierre Schweitzer 092c37f845
[NTOSKRNL] Do. Not. L. E. A. K. 2019-03-29 19:51:38 +01:00
Pierre Schweitzer d75ccd01f7
[NTOSKRNL] Only allow direct device open for FileFsDeviceInformation 2019-03-28 22:39:38 +01:00
Pierre Schweitzer ce6488df31
[NTOSKRNL] Add a quick path for FileFsDeviceInformation in NtQueryVolumeInformationFile
This allows querying volume information without issuing an IRP to the owner device.
The kernel is supposed to already have all the required information to return
to the caller.

Side effect: this allows querying volume information for devices not implementing
IRP_MJ_QUERY_VOLUME_INFORMATION such as null.sys
This fixes opening null device in Python.

Fix based on debugging by Maxim Smirnov in PR #1442

CORE-14551
2019-03-28 22:39:38 +01:00
Thomas Faber 8c358a4a90
[NTOS:FSTUB] Unfix format string warning until GUID definition is fixed. 2019-03-25 22:40:41 +01:00
Thomas Faber a976ebb031
[NTOS:IO] Avoid an unnecessary stack buffer in OpenRegistryHandlesFromSymbolicLink. CORE-15882 2019-03-25 08:43:47 +01:00
Thomas Faber b0bb3d0041
[NTOS:FSTUB] Fix a clang format string warning. 2019-03-25 08:41:55 +01:00
Thomas Faber 57225adaac
[NTOS:IO] Fix always-false condition in IoCheckEaBufferValidity.
Spotted by clang.
2019-03-25 08:41:51 +01:00
Thomas Faber faaf2dc0e6
[NTOS:KDBG] Fix uninitialized variable usage.
Spotted by clang.
2019-03-25 08:41:44 +01:00
Thomas Faber 938f0e469d
[NTOS:IO] Enable privilege check in NtLoadDriver. 2019-03-11 08:30:14 +01:00
Timo Kreuzer 8a4c5763da [NTOS:PS] Use NULL instead of 0 in ps/kill.c 2019-03-06 00:49:59 +01:00
Timo Kreuzer addc01d90b [NTOS:KE] Add function comments 2019-03-06 00:39:25 +01:00
Timo Kreuzer 42730f9373 [NTOS:EX] Fix 64 bit issues in ExfWaitForRundownProtectionReleaseCacheAware 2019-03-04 21:58:42 +01:00
Pierre Schweitzer 1114b89952
[NTOSKRNL] Fix MSVC2010 build 2019-03-02 11:10:37 +01:00
Pierre Schweitzer c2b6c3a69f
[NTOSKRNL] Fix ClockDiff aka fix MSVC build 2019-03-02 10:45:34 +01:00
Pierre Schweitzer eb8b481cd4
[NTOSKRNL] Rewrite/fix our UUID generation implementation
So that it matches Windows behavior
Also implement ExUuidCreate that will generate UUID version 1

The implementation is based on the RFC 4122
2019-03-01 08:22:48 +01:00
Pierre Schweitzer 2d9673c68f
[NTOSKRNL] Introduce the UUID_CACHED_VALUES_STRUCT structure
Source: https://blog.48bits.com/el-codigo-ntoskvinci/
2019-03-01 08:22:47 +01:00
Pierre Schweitzer 81c88c1029
[NTOSKRNL] UuidMutex -> ExpUuidLock 2019-03-01 08:22:47 +01:00
Mark Jansen 5c05a29d3d
[APPHELP] Implement ShimDumpCache and ShimFlushCache
These functions simply call into the Base* functions,
having a prototype that is compatible with rundll32
CORE-11301
2019-02-25 20:00:34 +01:00
Timo Kreuzer 81727760e4 [NTOS::Mm] Fix inverted check in MiWriteProtectSystemImage 2019-02-24 20:34:02 +01:00
Thomas Faber cf40421041
[NTOS:PNP] Correctly respect data size in PnpRegSzToString. CORE-15766
Spotted by Vadim Galyant.
2019-02-20 12:23:33 +01:00
Hermès Bélusca-Maïto 83fdb9a6d9
[NTOS:CM] Set and reset the CMHIVE HiveIsLoading flag adequately. Fix an assertion in CmFlushKey() and reset the CMHIVE ViewLockOwner when releasing the view lock. 2019-02-17 01:21:35 +01:00
Pierre Schweitzer 63b13ad939
[NTOSKRNL] Simplify object type name printing 2019-02-11 09:03:58 +01:00
Pierre Schweitzer df829f7948
[NTOSKRNL] Also display sections name 2019-02-10 11:23:57 +01:00
Pierre Schweitzer f4320047c3
[NTOSKRNL] Fix parsing loop 2019-02-09 13:59:11 +01:00
Pierre Schweitzer 2991f6e76e
[NTOSKRNL] Add a first implementation of !handle command in KDBG
It allows dumping all the handles (filtered by PID/Process)
and it displays basic information about file and key handles
2019-02-09 13:46:35 +01:00
Serge Gautherie 84e76b1c4c [NTOS:MM] ExFreePoolWithTag(): Accept tag mismatch, on release build only (#1334)
"Release" builds should not BSoD on 'Freeing pool - invalid tag specified' case,
this is compatible with Windows behaviour.
Nothing changes otherwise concerning the "Debug" builds, where pool-tag mismatch
triggers a BSoD as expected.

CORE-15446
2019-02-07 16:57:56 +01:00
Andrew Cook d8e92b5a0a Merge pull request #1335 from ariscop/CMP0065
Fixes for upstream cmake
2019-02-03 12:57:20 +01:00
Thomas Faber 066ee4db3b
[NTOS:MM] Dump pool consumers at most once per second.
This should avoid some log spam during kmtest:ExPools, which
intentionally depletes pool.
2019-02-03 12:54:36 +01:00
Thomas Faber f5fc9e0cf2
[NTOS:OB] Correctly handle OBJ_PROTECT_CLOSE in ObDuplicateObject. 2019-02-02 23:02:50 +01:00
Thomas Faber 63977328b1
[NTOSKRNL] Guard against negative InformationClass enum values. CORE-15651 2019-02-02 22:50:02 +01:00
Pierre Schweitzer a6dc1d69bc
[NTOS:MM] On big pool enumeration, return entry instead of base VA 2019-02-02 10:45:15 +01:00
Serge Gautherie 0483a5a380 [NTOS:OB] Correctly check SeSinglePrivilegeCheck() return value (#1323)
SeSinglePrivilegeCheck() returns a BOOLEAN, not a NTSTATUS.
CORE-14271
2019-01-30 00:43:13 +01:00
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