Commit graph

650 commits

Author SHA1 Message Date
Timo Kreuzer 53f8cbad97 [NTOS:IO] Fix list enumeration in IopShutdownBaseFileSystems 2019-12-30 15:48:38 +01:00
Victor Perevertkin b6e33426bf [NTOS:KD] Fix wrong debug level checking logic in KdpPrint.
Use NtQueryDebugFilterState in that function for consistency.
Thanks Hermès Bélusca-Maïto for help
2019-12-30 05:57:49 +02:00
Eric Kohl 8faf38ed22 [NTOS:IO] Fix indentation. No code changes! 2019-12-29 14:37:13 +01:00
Thomas Faber b6df3c622e
[NTOS:CM] Probe for write in NtLockProductActivationKeys.
This doesn't technically make a difference, but it's good practice.
2019-12-29 10:41:47 +01:00
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