Commit graph

696 commits

Author SHA1 Message Date
Thomas Faber 91cc1c3e4f
[NTOS:CM] Protect user memory access with SEH in NtQueryOpenSubKeys. 2019-12-29 10:41:44 +01:00
Hermès Bélusca-Maïto d32e96d602
This was not meant to be committed!
This reverts commit 5e14dbd648.
2019-12-26 17:19:11 +01:00
Hermès Bélusca-Maïto 5e14dbd648
WIP kdbg work. 2019-12-26 13:53:50 +01:00
Serge Gautherie ad21227ac8
[NTOS:PO] PopShutdownHandler(): Fully screen-center images. Addendum to 55aed4f8.
CORE-16342
2019-12-03 02:10:37 +01:00
Katayama Hirofumi MZ 55aed4f8fa [NTOSKRNL][INBV] Fix IDB_SHUTDOWN_MSG position
Make "shutdown.bmp" (IDB_SHUTDOWN_MSG: 213x11px) horizontally centered.
2019-12-02 16:55:02 +09:00
Timo Kreuzer 21647e2c4e [NTOS] Revert pool debugging code
Revert "[NTOS] On DBG builds, fill pool allocations with 0xCD and freed pool with 0xDD"
This reverts commit 24f240be8a.

Revert "[NTOS] Add compile time option to trace callers of pool allocations"
This reverts commit 8b20755040.

Revert "WIP"
This reverts commit 8cfd5c601f.
2019-11-25 19:32:06 +01:00
Hermès Bélusca-Maïto 28b77a40ca
[NDK][NTOS:INBV] Remove non-exported INBV functions from NDK; do some cleanup in INBV headers; label both InbvSetProgressBarSubset() and InbvSetProgressBarCoordinates() as INIT_FUNCTION since they are used only for the boot splash. And fix MSVC build. 2019-11-25 15:54:45 +01:00
Hermès Bélusca-Maïto 03a9ccce65
[NTOS:KE] Explicitly use IOPM_SIZE for initializing the IO map, that is indeed also equal to PAGE_SIZE * 2 but is self-documented. 2019-11-25 00:41:54 +01:00
Hermès Bélusca-Maïto b2ca7d3ed9
[NTOS:KE] Minor formatting fixes. 2019-11-25 00:41:54 +01:00
Hermès Bélusca-Maïto 592f01a594
[NTOS:INBV] InbvEnableBootDriver() is an export, thus can be called at any time, therefore it must NOT be an INIT_FUNCTION. 2019-11-25 00:41:54 +01:00
Timo Kreuzer 8cfd5c601f WIP 2019-11-24 18:26:19 +01:00
Timo Kreuzer 8b20755040 [NTOS] Add compile time option to trace callers of pool allocations 2019-11-24 18:26:19 +01:00
Timo Kreuzer 24f240be8a [NTOS] On DBG builds, fill pool allocations with 0xCD and freed pool with 0xDD
This matches what the MSVC runtime does with heap allocations on debug builds.
2019-11-24 18:26:19 +01:00
Hermès Bélusca-Maïto 40c57de728
[KDBG] If no parameters are given to the 'filter' command, display the list of available debug filter components. 2019-11-18 01:36:04 +01:00
Hermès Bélusca-Maïto 548393c6e7
[NTOS:KD/KD64] Fix x64 build. 2019-11-18 01:36:04 +01:00
Hermès Bélusca-Maïto ea6d427d10
[I8042PRT] Remove dead commented-out code; Allow sending ROS-specific commands to the kernel debugger since KD64 also support them.
[NTOS:MM] Remove an extra ')' in a DbgPrint() string.
2019-11-17 23:21:55 +01:00
Hermès Bélusca-Maïto a890fc64d1
[NTOS:KD/KD64/KDBG] Share some code between our legacy KD/KDBG and KD64.
Our legacy KD module is slowly being phased out for the more recent KD64
Kernel Debugger that supports WinDbg, but at the same time we must retain
support for GCC debugging and the KDBG interface.

For the time being few #ifdef _WINKD_ have been introduced in KD64 so that
some of its code/data does not completely get shared yet with the legacy KD,
until the latter becomes phased out.

KD Modifications:
=================
- Remove the implementation of NtQueryDebugFilterState() /
  NtSetDebugFilterState() that now comes entirely from KD64.

- Remove KD variables that are now shared with KD64.

- Share common code with KD64: KdpMoveMemory(), KdpZeroMemory(),
  KdpCopyMemoryChunks(), KdpPrint(), KdpPrompt().

- KDBG: Remove the duplicated KdpCopyMemoryChunks() function.

- In KdpServiceDispatcher() and KdpEnterDebuggerException(), call the
  KdpPrint() worker function that correctly probes and captures its arguments.

- Temporarily stub out KdEnterDebugger() and KdExitDebugger() that is used
  by the shared code, until KD is removed and only the KD64 version of these
  functions remain.

- Re-implement the KD/KDBG KdpPrompt() function using a custom KdpPromptString()
  helper compatible with KD64, that is called by the KD64 implementation of
  KdpPrompt(). This KdpPromptString() helper now issues the prompt on all
  the KD loggers: e.g. if you use both at the same time COM-port and SCREEN
  debugging, the prompt will appear on both. Before that the prompt was always
  being displayed on COM port even if e.g. a SCREEN-only debug session was used...

- ppc_irq.c: Fix the prototype of KdpServiceDispatcher().

KD64 Fixes:
===========
- Initialize the MaximumLength member of the counted STRING variables
  before using them elsewhere.

- Get rid of alloca() within SEH block in KdpPrint() (addendum to 7b95fcf9).

- Add the ROS-specific handy dump commands in KdSystemDebugControl().
2019-11-17 23:21:54 +01:00
Hermès Bélusca-Maïto 54c03f6965
[NTOS:KD64] Some code formatting + add SAL2 annotations to the functions that are going to be involved in the next commit.
+ s/ReturnStatus/Status/ , and get rid of Win32 LPSTR and replace by
  PCHAR (since the concerned code deals with counted strings).
2019-11-17 23:21:53 +01:00
Hermès Bélusca-Maïto 6c1aac6948
[NTOS] Complete the support of Debug Filters. CORE-13529
- KD64: Update the list of supported Debug Filter Masks (KdComponentTable)
  with the more up-to-date one from KDBG, that includes some components
  that have been added in Vista+, but some of which we also use in ReactOS.

- NtQueryDebugFilterState(), NtSetDebugFilterState() and KdpPrint():
  Add the Vista+ behaviour or falling back to the DEFAULT component ID
  settings for unknown Components (compiled in only wheen NTDDI_VERSION >= NTDDI_VISTA).
  + Remove redundant comments and update these functions with SAL2 annotations.

- KDBG: Add extra documentation for the debug filter components list.

- CONFIG: Load all the supported Debug Filter Masks settings from the
  registry.
2019-11-17 23:21:53 +01:00
Hermès Bélusca-Maïto 9537653ee7
[NTOS:KD/KDBG] Code enhancements for KDBG/KD.
- Introduce KdpScreenAcquire() / KdpScreenRelease() helpers that allow
  to correctly acquire or release the screen when using INBV for
  "Screen-Mode" debugging.

- Introduce KdpAcquireLock() / KdpReleaseLock() helpers so as to reduce
  the copy-pasted code required when acquiring spin-locks in the KD debug
  logger functions.

- Close the opened KdpLogFileHandle file in the KdpInitDebugLog() logger
  in case we failed to create the logger writer thread.
  Also use explicit kernel-mode handle when opening the log file.

- static-ify some local variables, remove few hardcoded values, and
  minor formatting.

- Correctly define the INIT_FUNCTION's.
2019-11-17 23:21:50 +01:00
Victor Perevertkin 3d046e0ed2 [NTOS:IO] Fix result length for DevicePropertyRemovalPolicy request
in IoGetDeviceProperty.
Classpnp expects it to be sizeof(DEVICE_REMOVAL_POLICY)
see ClasspInitializeHotplugInfo in classpnp.sys

CORE-6264
2019-11-17 18:36:28 +03:00
Hermès Bélusca-Maïto d21ff0ed13
[NTOS:KDBG] Rewrite the TSS handling code in the backtrace function, removing limitations (and bugs) of the original code.
CORE-16448, PR #2003. Supersedes PR #1997.

This commit supersedes commit 6c5c7809 (r54503).

The original code was checking for the NMI or Double-Fault TSS by
comparing the current stack-traced EIP address with their corresponding
trap handler address ranges. That method was actually buggy because
nothing was ensuring that the trap handlers were in the "expected" order
in the kernel binary (and in memory).

Instead, we now can handle completely generic nested TSSes, instead of
just the NMI or the Double-Fault ones.
The way we proceed is by performing the full stack backtrace of the
current TSS, then once finished we check whether this TSS is nested
(has a parent). If so we change the (cached) current TSS to the latter,
restarting the backtrace at the parent TSS' latest EIP.

Examples of stack backtraces:
=============================

- General Protection fault:

<snip>

*** Fatal System Error: 0x0000007f
                       (0x0000000D,0x00000000,0x00000000,0x00000000)

Entered debugger on embedded INT3 at 0x0008:0x80953528.
kdb:> bt
Eip:
<ntoskrnl.exe:153529 (sdk/lib/rtl/i386/debug_asm.S:57 (RtlpBreakWithStatusInstruction))>
Frames:
<ntoskrnl.exe:899b0 (ntoskrnl/ke/bug.c:1136 (KeBugCheckWithTf))>
<ntoskrnl.exe:134826 (ntoskrnl/ke/i386/exp.c:1161 (KeRaiseUserException))>
<ntoskrnl.exe:19ae67 (ntoskrnl/ke/i386/traphdlr.c:1282 (KiTrap0DHandler))>
<ntoskrnl.exe:19a840 (:0 (KiTrap0D))>
<ntoskrnl.exe:1925e6 (ntoskrnl/include/internal/i386/intrin_i.h:45 (KiInitMachineDependent))>
<ntoskrnl.exe:187688 (ntoskrnl/ke/krnlinit.c:305 (KeInitSystem))>
<ntoskrnl.exe:17fb2f (ntoskrnl/ex/init.c:1621 (Phase1InitializationDiscard))>
<ntoskrnl.exe:3247f (ntoskrnl/ex/init.c:2019 (Phase1Initialization))>
<ntoskrnl.exe:11c079 (ntoskrnl/ps/thread.c:156 (PspSystemThreadStartup))>
<ntoskrnl.exe:135c8a (ntoskrnl/ke/i386/thrdini.c:78 (KiThreadStartup))>
<ntoskrnl.exe:11c040 (ntoskrnl/ps/thread.c:141 (PspSystemThreadStartup))>
<5d8950ec>
Couldn't access memory at 0x83E58959!

</snip>

- Double-fault (manually triggered by removing the GP handler):

Note how the backtrace explicitly specifies the crossed TSS boundaries,
and the trace in the parent TSS is indeed consistent with the previous
example. Note also that log2lines (used here to completely resolve the
trace) failed to see KiTrap08Handler(), which has been instead mistaken
for KiTrap09().

<snip>

*** Fatal System Error: 0x0000007f
                       (0x00000008,0x8009C000,0x00000000,0x00000000)

Entered debugger on embedded INT3 at 0x0008:0x80953528.
kdb:> bt
[Active TSS 0x0050 @ 0x80A10CA0]
Eip:
<ntoskrnl.exe:153529 (sdk/lib/rtl/i386/debug_asm.S:57 (RtlpBreakWithStatusInstruction))>
Frames:
<ntoskrnl.exe:899b0 (ntoskrnl/ke/bug.c:1136 (KeBugCheckWithTf))>
<ntoskrnl.exe:19a1d8 (ntoskrnl/ke/i386/traphdlr.c:917 (KiTrap09))>      // <-- Here, log2lines fails to see it's actually KiTrap08Handler.
<ntoskrnl.exe:19a145 (:0 (KiTrap08))>
[Parent TSS 0x0028 @ 0x8009C000]
<ntoskrnl.exe:1925e6 (ntoskrnl/include/internal/i386/intrin_i.h:45 (KiInitMachineDependent))>
<ntoskrnl.exe:187688 (ntoskrnl/ke/krnlinit.c:305 (KeInitSystem))>
<ntoskrnl.exe:17fb2f (ntoskrnl/ex/init.c:1621 (Phase1InitializationDiscard))>
<ntoskrnl.exe:3247f (ntoskrnl/ex/init.c:2019 (Phase1Initialization))>
<ntoskrnl.exe:11c079 (ntoskrnl/ps/thread.c:156 (PspSystemThreadStartup))>
<ntoskrnl.exe:135c8a (ntoskrnl/ke/i386/thrdini.c:78 (KiThreadStartup))>
<ntoskrnl.exe:11c040 (ntoskrnl/ps/thread.c:141 (PspSystemThreadStartup))>
<5d8950ec>
Couldn't access memory at 0x83E58959!

</snip>
2019-11-13 02:14:48 +01:00
Pierre Schweitzer 324285f0b9
[NTOSKRNL] Properly check for Ft volumes
This fixes a regression introduced in 5ab1cfc which
was causing Unix (BtrFS, ExtX, and so on) volumes not
to be assigned a drive letter assigned anymore. And
thus, they were no longer mounted and presented to the
users.

CORE-16499
2019-11-11 21:20:58 +01:00
Hermès Bélusca-Maïto 7e941247bd
[MM:AMD64] Remove the _WINKD_ around MmDebugPte since it's now used by both kd64 (windbg) and KDBG through the usage of mmdbg.c 2019-11-03 23:46:54 +01:00
Hermès Bélusca-Maïto aff644a1a2
[NTOS:KD][KDBG] Get rid of kdmemsup.c as its functionality has been superseded by that implemented in mm/arm3/mmdbg.c.
- Import KdpCopyMemoryChunks() from kd64/kdapi.c, and re-implement
  KdbpSafeReadMemory() and KdbpSafeWriteMemory() around it.
  Note that these functions read virtual memory and are equivalent of
  the kd64 KdpReadVirtualMemory() and KdpWriteVirtualMemory()
  respectively.

- Get rid of the KdpEnableSafeMem() call in KdInitSystem().
- Adjust kd gdbstub.c wrapper in accordance.
2019-11-03 23:46:52 +01:00
Hermès Bélusca-Maïto 384d55e47a
[NTOS:KD64] Whitespace fixes only! 2019-11-03 23:46:51 +01:00
Hermès Bélusca-Maïto 8826ee8ff7
[NTOS:KDBG] Enhance the 'tss' command.
We allow specifying manually the TSS selector number or its descriptor address,
and dump more information from the associated KTSS structure.

Also add the KdbpRetrieveTss() helper to retrieve the PKTSS from its
corresponding selector number. It will also be useful for future improvements.
2019-11-03 05:08:40 +01:00
Hermès Bélusca-Maïto dc0c721ff8
[NTOS:KDBG] Augment the 'cregs' command by also displaying the task segment register. Update the help message. 2019-11-03 05:08:39 +01:00
Hermès Bélusca-Maïto 89b44cfa07
[NTOS:KDBG] Use fixed-length hexadecimal printing for addresses. 2019-11-03 05:08:39 +01:00
Hermès Bélusca-Maïto f0d59e745d
[NTOS:KDBG] Whitespace, minor code style and help-text style fixes. 2019-11-03 05:08:38 +01:00
Hermès Bélusca-Maïto 954f7c0660
[NTOS:KD] Check for valid LoaderBlock and LoaderBlock->LoadOptions pointers when calling KdInitSystem() in BootPhase == 0. 2019-11-03 05:08:33 +01:00
Hermès Bélusca-Maïto ef5f034974
[NTOS:KD] Whitespace fixes + fix helper function name. 2019-11-03 05:07:32 +01:00
Hermès Bélusca-Maïto 3b2f158593
[NTOS][CLASS2][FFS][WIN32SS] Fix some pool tags so that they correctly appear in pool dump lists.
Reminder: in the code they are defined using reverse byte order
(Windows/ReactOS are little-endian OSes).
2019-11-01 19:12:27 +01:00
Hermès Bélusca-Maïto 29f6d02945
[NTOS:KDBG] Fix the display type of GDT TRAPGATE32. 2019-11-01 19:12:27 +01:00
Hermès Bélusca-Maïto f5e86c0fd3
[NTOS] Just go ahead and allow printing all the printable ASCII characters in ExpTagAllowPrint().
As documented in https://docs.microsoft.com/fr-fr/windows-hardware/drivers/ddi/wdm/nf-wdm-exallocatepoolwithtag
pool tag "characters" must be a value in the range 0x20 (space) to 0x7E (tilde),
which happen indeed to be the range of printable (non-extended) ASCII characters.

(The display problem was originally caught while attempting to display
the pool tag 0x3a306847 corresponding to 'Gh0:', a win32ss GDIOBJ pool tag
encoded with macro GDIOBJ_POOL_TAG().)
2019-11-01 19:09:29 +01:00
Stanislav Motylkov 9bf672d4f1 [NTOS:MM] Add debug print to MiAllocateContiguousMemory in out-of-memory case 2019-10-27 06:32:50 +01:00
Timo Kreuzer 56da95671c [NTOS] Fix a bug in the PE loader, which caused images to be loaded up to MmHighestUserAddress, thus overwriting the shared user page.
This is now fixed by using MM_HIGHEST_VAD_ADDRESS as the margin instead.
Should fix CORE-11717
2019-10-26 21:38:13 +02:00
Pierre Schweitzer 5ab1cfc553
[NTOSKRNL] Rewrite IoAssignDriveLetters to make NT5 compliant
The major change with this rewrite is the support for the mount
manager. Fstub will now assume that most of the devices are PnP
and that they are already registered to the mount manager.
It will thus ask the mount manager to assign the drive letter.
Fstub will keep assigning drive letters non mission critical devices
such as CDs, floppies and other removable devices.

See MountMgr:QueryPoints API test that will now return mount points :-).
2019-10-21 18:28:40 +02:00
Pierre Schweitzer 11db7c9e5d
[NTOSKRNL] Define TAG_FSTUB in the dedicated internal header 2019-10-21 14:26:00 +02:00
Pierre Schweitzer 80cc287cf6
[NTOSKRNL] Declare IoRemoteBootClient in internal headers 2019-10-21 14:16:58 +02:00
Hervé Poussineau 7390376753 Revert "[NTOS:KDBG] Use CONTEXT instead of KTRAP_FRAME"
This reverts commit e5bffe49da.

CORE-16231
2019-10-19 00:14:12 +02:00
Serge Gautherie e413df4f4e [NTOS:MM] i386: Fix '_MI_NO_EXECUTE' typo
Addendum to 65dbfc2868.
2019-09-30 10:46:58 +03:00
Pierre Schweitzer 3b78ca210e
[NTOSKRNL] Simplify buffer definition in MiQueryMemorySectionName().
Also take into account the UNICODE_STRING structure while computing whole size
This is based on Thomas' patch.

CORE-12043
2019-09-29 14:16:44 +02:00
Pierre Schweitzer 96ee4509e5
[NTOSKRNL] Implement NtQuerySystemInformation(SystemLogicalProcessorInformation) 2019-09-27 20:36:59 +02:00
Thomas Faber 934484ea3e
[NTOS:PNP] When traversing the device tree, keep a reference to the current device. CORE-15874 2019-09-26 10:26:10 +02:00
Serge Gautherie 0339245859 [NTOS:KE] Fix 'Sert' typo, in a comment (#1929) 2019-09-23 01:13:07 +02:00
Timo Kreuzer 41250d1028 [NTOS:MM] Fix MmspCompareSegments
On x64 the previous implementation would only compare the upper 32 bits and ignore the lower 32 bits.
2019-09-01 14:15:07 +02:00
Eric Kohl 0b129da05c [NTOSKRNL] Fix indentation. No code changes! 2019-08-24 10:02:55 +02:00
Mark Jansen 1539fb1414
[NTOSKRNL] Demote some noisy dprints 2019-08-23 13:03:36 +02:00
Yaroslav Kibysh 238ea69ca0 [NTOS:INBV] Refactor boot screen code and resources (#1649)
* [NTOS:INBV] Move typedefs to the only single file where they are used.

* [NTOS:INBV] Refactor code & resources

Remove garbage

* [NTOS:INBV] Reduce fade time and remove wait for animation.
2019-08-20 01:52:25 +02:00
Pierre Schweitzer e12abf63c5
[NTOSKRNL] Handle symlink parsing when it's bound to a specific object 2019-08-19 10:45:50 +02:00
Serge Gautherie 87a625bd6c [NTOS:IO] iomgr.c: Add a missing '#if defined(KDBG)' 2019-08-17 17:36:49 +02:00
Serge Gautherie 66bf74d228 [NTOSKRNL] Move DPRINT1("Thread wants too much stack\n") around
To KiUserModeCallout() from MmGrowKernelStackEx().

As suggested by Thomas Faber:
"MmGrowKernelStackEx really shouldn't be DPRINT'ing."

CORE-14494
2019-08-15 18:18:59 +02:00
Timo Kreuzer de679e8f33 [NTOS:MM] MmSizeOfSystemCacheInPages is ULONG_PTR, not ULONG
Fixes failed assertion on x64.
2019-08-15 18:04:57 +02:00
Timo Kreuzer adcae016c5 [NTOS:KE:I386] Fix parameter description for KiSwapContext 2019-08-15 18:04:57 +02:00
Timo Kreuzer 98a8e8f862 [NTOS:IO] In IopSynchronousCall first check IrpStack->MajorFunction before checking minor
Minor function indices are not unique, they are subfunctions, so without first checking the major function, they are ambiguous.
2019-08-15 18:04:57 +02:00
Timo Kreuzer fffe4f6385 [NTOS:EX] Use InterlockedExchangeAdd64 instead of InterlockedCompareExchange64 loop in ExAllocateLocallyUniqueId 2019-08-15 18:04:57 +02:00
Timo Kreuzer e50873376d [NTOS:IO] Improve an alignment 2019-08-15 18:04:57 +02:00
Timo Kreuzer 7611cc2b12 [REACTOS] Fix SIZE_T related warnings 2019-08-15 14:20:00 +02:00
Andrew Boyarshin b607e0119f [NTOSKRNL][PS] Implement NtQueueApcThreadEx and use it in NtQueueApcThread
Actually rename NtQueueApcThread to NtQueueApcThreadEx and ignore one additional parameter for now.
2019-08-15 12:32:09 +02:00
Eric Kohl 4614c5b57c [NTOSKRNL] Implement SeRegisterLogonSessionTerminatedRoutine() and SeUnregisterLogonSessionTerminatedRoutine(). 2019-08-04 14:01:26 +02:00
Timo Kreuzer 3af7cb825f [NTOSKRNL] Replace overlapping strcopy with memmove
Fixes 4 GCC 8 warnings of the kind:
ntoskrnl/kdbg/kdb_cli.c:3015:21: error: 'strcpy' accessing 1 byte at offsets 0 and [0, 2147483647] may overlap 1 byte at offset 0 [-Werror=restrict]
                     strcpy(p2, p2 + j);
                     ^~~~~~~~~~~~~~~~~~
2019-07-20 13:56:18 +02:00
Hermès Bélusca-Maïto e2d6f61085
[NTOS:INBV] Fix the bitmaps' palette and recompress them in RLE. (#1649)
They don't need to have a zeroed-out palette now that we can
automatically reset it from within the code.

Co-authored-by: Yaroslav Kibysh <yanet.prod@gmail.com>
2019-07-14 22:23:52 +02:00
Hermès Bélusca-Maïto 64a53b304e
[NTOS:INBV] Express some coordinates in terms of screen size. (#1649) 2019-07-14 22:23:51 +02:00
Yaroslav Kibysh dc2eb409c1
[NTOS:INBV] Implement BitBltPalette() and BitBltAligned() and use them for aligning bitmaps. (#1649)
Co-authored-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
2019-07-14 22:23:50 +02:00
Hermès Bélusca-Maïto 3625238ecb
[NTOS:MM] Add a MmChangeKernelResourceSectionProtection() helper. (#1649)
This allows setting the memory protection of the kernel's resource
section as will. MmMakeKernelResourceSectionWritable() is re-implemented
around this helper.
2019-07-14 22:23:49 +02:00
Hermès Bélusca-Maïto a3e22b99a4
[NTOS:INBV] Classify the bitmap resources. (#1649)
See "How to change Windows XP boot logo" at
http://www.reversing.be/article.php?story=20061209171938444
as well as the "Boot Editor for WinXP" program for more details.
2019-07-14 22:23:48 +02:00
Serge Gautherie ccf8bff3ec [NTOS:MM] Fix MmGetFileNameForAddress() callers. (#1723)
MmGetFileNameForAddress() calls RtlCreateUnicodeString().
This also fixes a leak in MiQueryMemorySectionName().
2019-07-14 00:32:23 +02:00
Thomas Faber 2d419e90f9
[NTOS:PNP] Reduce the default buffer size in EnumerateDevices. CORE-15882 2019-07-10 10:58:47 +02:00
Thomas Faber b8e091a44c
[NTOS:PNP] Handle arbitrary subkey name lengths in EnumerateDevices. CORE-15882
This also makes it necessary to fix a bug in the previous code:
ZwEnumerateKey will not account for space for a null terminator, so to
ensure we have space, we must allocate the additional WCHAR, but not
include it in the buffer size passed to the function.
2019-07-10 10:58:45 +02:00
Thomas Faber 36e9a6f8dd
[CMAKE] Disable INIT section ld scripts for now. CORE-16183 ROSBE-154 2019-07-07 16:06:43 +02:00
Thomas Faber c4d8e2a6e9
[CMAKE] Ensure the INIT section is placed at the end of a module. CORE-14683
For MSVC, marking the section as discardable will do this automatically.
For GCC, we use a linker script that places it after the .reloc section
(which should be the last "real" section, check ld --verbose output for the
default linker script).

This fixes what seems to be a regression from r55835 (!).
2019-07-07 08:18:10 +02:00
Serge Gautherie 6ba611f39e [NTOS:MM] Fix MmSizeOfSystemCacheInPages value on AMD64
And add 'ASSERT(MmSystemCacheEnd == ...);'.

Addendum to d56a249089.
CORE-14259
2019-07-06 09:55:38 +02:00
Serge Gautherie a0d2170729 [NTOS:CC] CcWriteVirtualAddress(): Do not round 'Size'
Revert 'Properly align VACB writes' part of 2a80ae2bb6.

CORE-15384 CORE-16018
2019-07-01 21:30:25 +02:00
Pierre Schweitzer 4fd223729b [NTOSKRNL] When looping again in ObpLookupEntryDirectory, properly init root entry
This fixes looking in global directory for DOS drives that are globally mounted
(such as C: drive)

CORE-16114
2019-06-30 23:07:54 +02:00
Pierre Schweitzer f13b6e025f [NTOSKRNL] Implement support for device maps in ObpLookupObjectName
This allows getting rid of the ?? hack in the kernel but this doesn't
allow enabling LUID device maps as ReactOS can no longer open a
session with them enabled. So, we must remain with device maps at
root

CORE-16114
2019-06-30 23:07:54 +02:00
Hermès Bélusca-Maïto 05616105a5
[NTOS:MM] Fix MiLocateKernelSections() and MmMakeKernelResourceSectionWritable().
- MiLocateKernelSections(): Fix the calculation of MiKernelResourceEndPte,
  MmPoolCodeEnd and MmPteCodeEnd.

- MmMakeKernelResourceSectionWritable(): Fix PTE looping upper limit;
  use MI_MAKE_HARDWARE_PTE_KERNEL to build the updated read-write PTE.
2019-06-26 00:57:53 +02:00
Hermès Bélusca-Maïto f694d12f0c
[NTOS:KE/MM] Some bug-fixes in the bugcheck code.
- Introduce the MmMakeKernelResourceSectionWritable() helper for
  making the kernel resource memory section writable, and use it
  in KeGetBugMessageText(). Indeed, this latter function patches
  in place the bugcheck resource message to trim any trailing
  newlines before displaying the message on screen.

  See also https://github.com/osresearch/uxen/blob/83bad53/dm/introspection-win7.c#L286
  that mentions it too.

  This fixes bugcheck text display (e.g. the MANUALLY_INITIATED_CRASH one)
  when using (at least) MSVC-built ReactOS, avoiding a Page-Fault
  exception during the bugcheck.

- Cover KeGetBugMessageText() in SEH since we are accessing kernel
  resources that could also be corrupted in bugcheck scenarii, and we
  don't want to further bugcheck.

- Fix newline trimming loop.

- KiDoBugCheckCallbacks():
  * Wrap the bugcheck CallbackRoutine call in SEH.
  * Add a FIXME concerning the need of further memory validation of CurrentRecord.

- Add a FIXME concerning the need to run the bugcheck-reason callbacks
  with the KbCallbackReserved1 reason, in KeBugCheckWithTf().
  Mentioned in http://blog.ptsecurity.com/2012/06/customizing-blue-screen-of-death.html
2019-06-25 21:01:49 +02:00
Hermès Bélusca-Maïto 35f800c6e2
[NTOS] Minor formatting enhancements only + typo fixes. 2019-06-25 21:01:48 +02:00
Bișoc George 42ce8519b6 [FASTFAT][FLTMGR][NTOS] Do not explicitly call ObfDereferenceObject() (#1636)
"Most code should not directly call the platform-specific ObfDereferenceObject() function but use the ObDereferenceObject() macro instead."

CORE-16081
2019-06-22 16:20:58 +02:00
Hermès Bélusca-Maïto 4d5a2dd0f3
[NTOS:KE] Use multi-processor-aware KeGetPcr() instead of the legacy PCR. 2019-06-20 19:39:49 +02:00
Hermès Bélusca-Maïto 04906f2abb
[NTOS:KE] Fixup for the NMI task handler: handle NMI recursion. -- Code was lost in commit 2efed8ef (r45040). 2019-06-20 19:39:44 +02:00
Hermès Bélusca-Maïto 3c8f19eb21
[NTOS:KE] Improvements for the Trap02 (NMI) and Trap08 (double-fault) exception handlers.
- Add FRAME_TSS FPO debug information for Trap02 and Trap08.
- Switch the active TSS in Trap08 in the very same way as is done in Trap02.

This allows to correctly debug NMI and double-fault exceptions with WinDbg,
by following the different TSS contexts, as described in:
https://blogs.msdn.microsoft.com/debuggingtoolbox/2008/02/22/special-command-analyzing-and-reconstructing-the-stack-using-the-k-command-and-its-variations/
https://blogs.msdn.microsoft.com/ntdebugging/2009/11/25/part-1-got-stack-no-we-ran-out-of-kernel-mode-stack-and-kv-wont-tell-me-why/
http://www.osronline.com/article.cfm?article=254 and http://www.osronline.com/article.cfm?article=328
2019-06-20 19:38:56 +02:00
Hermès Bélusca-Maïto d15e36a1f1
[NTOS:KE][SDK:ASM] Code formatting/styling only.
- Un-hardcode the RPL_MASK value.
- s/KiUnexpectedInterrupt&Number/KiUnexpectedInterrupt&Vector/
- Use C-style comments in traphdlr.c as everywhere else in the file.
- Update the URLs for the MSDN "FPO" macro documentation.
2019-06-20 18:07:59 +02:00
Eric Kohl 6866c0aede [NTOSKRNL][USETUP][UMPNPMGR] Pass user response data to NtPlugPlayControl(PlugPlayControlUserResponse).
- Windows requires 16 bytes of response data.
- Add the PLUGPLAY_CONTROL_USER_RESPONSE_DATA type.
- Usetup and Umpnpmgr must fail if NtPlugPlayControl(PlugPlayControlUserResponse) does not return STATUS_SUCCESS.
2019-06-12 13:48:27 +02:00
Hermès Bélusca-Maïto 9060b0cb7a
Fix build (forgot a comma ;) 2019-06-11 22:36:10 +02:00
Hermès Bélusca-Maïto 41e7c818d1
[NTOS] IoSetHardErrorOrVerifyDevice(): Check whether the IRP is not associated with any thread. 2019-06-11 22:29:34 +02:00
Pierre Schweitzer f6eb13a969
[NTOSKRNL] Rework ObpDeleteSymbolicLinkName and ObpCreateSymbolicLinkName
So that they handle LUID mappings and process device maps.

Get rid of the ObpParseSymbolicLinkToIoDeviceObject helper and introduce a
new helper ObpProcessDosDeviceSymbolicLink that will do the same things
but also handle name creation/deletion as well as device map handling.
All this is based on previous code (hence the same comments :-)).

What's left to do now is to add support for device maps in ObpLookupObjectName
2019-06-11 21:21:52 +02:00
Pierre Schweitzer 33604e0147
[NTOSKRNL] Fix ObpLUIDDeviceMapsEnabled initialization 2019-06-10 21:17:21 +02:00
Pierre Schweitzer 651ba03c6d
[NTOSKRNL] Taggify some allocs 2019-06-10 14:54:55 +02:00
Pierre Schweitzer a5daa8894d
[NTOSKRNL] Implement SepCleanupLUIDDeviceMapDirectory
This will clean up all the links (drive letters) created
by an user on session deletion once LUID device maps are
in use
2019-06-10 14:49:50 +02:00
Pierre Schweitzer 5ecc05003d
[NTOSKRNL] On session last reference removal, dereference LUID device map 2019-06-10 12:30:49 +02:00
Pierre Schweitzer ad80715b1a
[NTOSKRNL] Implement NtSetInformationProcess:ProcessDeviceMap 2019-06-10 10:35:24 +02:00
Eric Kohl 8319c73e2e [NTOS:IO] Implement the PlugPlayControl.PlugPlayControlEnumerateDevice request
Drivers for Intel Pro/1000 NICs seem to install properly.
2019-06-08 20:42:38 +02:00
Serge Gautherie cf27695269 [NTOS:MM] PeFmtCreateSection(): Improve AMD64 image failure case
Addendum to 98638cc2df.

CORE-15981
2019-06-04 18:22:19 +02:00
Pierre Schweitzer fd4752450f
[NTOSKRNL] Add support for global DOS directory in ObpLookupEntryDirectory
If any exists, we'll loop over in that directory, trying to find the object
2019-06-02 21:46:35 +02:00
Pierre Schweitzer 9c3c0d123b
[NTOSKRNL] In case IopMountVolume call is a success, return its VPB
This fixes an extra (erroneous) reference being set on the VPB.

Based on a patch by Vadim Galyant

CORE-16080
2019-06-02 10:48:35 +02:00
Pierre Schweitzer f8a4d31da4
[NTOSKRNL] On process primary token change, dereference device map 2019-06-02 10:00:17 +02:00
Pierre Schweitzer de17b36037
[NTOSKRNL] Implement ObSetDirectoryDeviceMap 2019-06-01 21:22:30 +02:00
Pierre Schweitzer 7c618faa32
[NTOSKRNL] Implement SeGetLogonIdDeviceMap 2019-06-01 21:09:20 +02:00