#
2046a17e |
| 21-Mar-2023 |
Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> |
[NTOS:KD:KDBG] Integration into KD framework (Part 1/3)
Split KdSendPacket and KdReceivePacket into those that manipulate the KDBG state proper (reside in kdbg/kdbg.c), and those that deal only with
[NTOS:KD:KDBG] Integration into KD framework (Part 1/3)
Split KdSendPacket and KdReceivePacket into those that manipulate the KDBG state proper (reside in kdbg/kdbg.c), and those that deal only with debug input/output that will reside in a KDTERM "KD Terminal Driver" DLL.
Based on some previous preparatory work by Hervé Poussineau in PR #4600. (Equivalents of commits 5162bf106 and partly e9bcf7275.)
show more ...
|
#
eb02a852 |
| 27-Mar-2023 |
Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> |
[NTOS:KD] Split internal/kd.h into a part shared in the whole kernel and a private part only used within ntoskrnl/kd.
|
#
6fafe54f |
| 26-Mar-2023 |
Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> |
[NTOS:KD:KDBG] Move some files to a better place.
|
#
4ce819ca |
| 09-Jan-2023 |
Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> |
[NTOS:KD][KDBG] Rework the BootPhase >= 2 initialization of the KD/KDBG kernel debugger. (#4892) CORE-17470
+ KdpDebugLogInit: Add resources cleanup in failure code paths.
Fix, in an NT-compatible
[NTOS:KD][KDBG] Rework the BootPhase >= 2 initialization of the KD/KDBG kernel debugger. (#4892) CORE-17470
+ KdpDebugLogInit: Add resources cleanup in failure code paths.
Fix, in an NT-compatible manner, how (and when) the KD/KDBG BootPhase >=2 initialization steps are performed. These are necessary for any functionality KDBG needs, that would depend on the NT I/O Manager and the storage and filesystem stacks to be running. This includes, creating the debug log file, and for KDBG, loading its KDBinit initialization file.
As a result, file debug logging is fixed.
The old ReactOS-specific (NT-incompatible) callback we did in the middle of IoInitSystem() is removed, in favor of a runtime mechanism that should work on Windows as well.
The idea for this new mechanism is loosely inspired by the TDL4 rootkit, see http://blog.w4kfu.com/public/tdl4_article/draft_tdl4article.html but contrary to it, a specific hook is used instead, as well as the technique of driver reinitialization: https://web.archive.org/web/20211021050515/https://driverentry.com.br/en/blog/?p=261
Its rationale is as follows:
We want to be able to perform I/O-related initialization (starting a logger thread for file log debugging, loading KDBinit file for KDBG, etc.). A good place for this would be as early as possible, once the I/O Manager has started the storage and the boot filesystem drivers.
Here is an overview of the initialization steps of the NT Kernel and Executive: ---- KiSystemStartup(KeLoaderBlock) if (Cpu == 0) KdInitSystem(0, KeLoaderBlock); KiSwitchToBootStack() -> KiSystemStartupBootStack() -> KiInitializeKernel() -> ExpInitializeExecutive(Cpu, KeLoaderBlock)
(NOTE: Any unexpected debugger break will call KdInitSystem(0, NULL); ) KdInitSystem(0, LoaderBlock) -> KdDebuggerInitialize0(LoaderBlock);
ExpInitializeExecutive(Cpu == 0): ExpInitializationPhase = 0; HalInitSystem(0, KeLoaderBlock); <-- Sets HalInitPnpDriver callback. ... PsInitSystem(LoaderBlock) PsCreateSystemThread(Phase1Initialization)
Phase1Initialization(Discard): ExpInitializationPhase = 1; HalInitSystem(1, KeLoaderBlock); ... Early initialization of Ob, Ex, Ke. KdInitSystem(1, KeLoaderBlock); ... KdDebuggerInitialize1(LoaderBlock); ... IoInitSystem(LoaderBlock); ... ---- As we can see, KdDebuggerInitialize1() is the last KD initialization routine the kernel calls, and is called *before* the I/O Manager starts. Thus, direct Nt/ZwCreateFile ... calls done there would fail. Also, we want to do the I/O initialization as soon as possible. There does not seem to be any exported way to be notified about the I/O manager initialization steps... that is, unless we somehow become a driver and insert ourselves in the flow!
Since we are not a regular driver, we need to invoke IoCreateDriver() to create one. However, remember that we are currently running *before* IoInitSystem(), the I/O subsystem is not initialized yet. Due to this, calling IoCreateDriver(), much like any other IO functions, would lead to a crash, because it calls ObCreateObject(..., IoDriverObjectType, ...), and IoDriverObjectType is non-initialized yet (it's NULL).
The chosen solution is to hook a "known" exported callback: namely, the HalInitPnpDriver() callback (it initializes the "HAL Root Bus Driver"). It is set very early on by the HAL via the HalInitSystem(0, ...) call, and is called early on by IoInitSystem() before any driver is loaded, but after the I/O Manager has been minimally set up so that new drivers can be created. When the hook: KdpInitDriver() is called, we create our driver with IoCreateDriver(), specifying its entrypoint KdpDriverEntry(), then restore and call the original HalInitPnpDriver() callback.
Another possible unexplored alternative, could be to insert ourselves in the KeLoaderBlock->LoadOrderListHead boot modules list, or in the KeLoaderBlock->BootDriverListHead boot-driver list. (Note that while we may be able to do this, because boot-drivers are resident in memory, much like we are, we cannot insert ourselves in the system-driver list however, since those drivers are expected to come from PE image files.)
Once the KdpDriverEntry() driver entrypoint is called, we register KdpDriverReinit() for re-initialization with the I/O Manager, in order to provide more initialization points. KdpDriverReinit() calls the KD providers at BootPhase >= 2, and schedules further reinitializations (at most 3 more) if any of the providers request so.
show more ...
|
#
bf734e53 |
| 10-Jul-2022 |
Hervé Poussineau <hpoussin@reactos.org> |
[NTOS:KD] Move handling of Dmesg buffer from screen provider to KDBG provider. (#5143) CORE-10749
The dmesg command is now available even if screen output is disabled.
Co-authored-by: Hermès Bélusc
[NTOS:KD] Move handling of Dmesg buffer from screen provider to KDBG provider. (#5143) CORE-10749
The dmesg command is now available even if screen output is disabled.
Co-authored-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
show more ...
|
#
dfb6996b |
| 10-Mar-2023 |
Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> |
[NTOS:KDBG] Split KdbInitialize into KdbSymInit and KDBG initialization proper.
- KdbSymInit() in kdb_symbols.c only initializes symbols implementation support. - The rest of KdbInitialize gets mo
[NTOS:KDBG] Split KdbInitialize into KdbSymInit and KDBG initialization proper.
- KdbSymInit() in kdb_symbols.c only initializes symbols implementation support. - The rest of KdbInitialize gets moved into kdb_cli.c and initializes the KDBG debugger itself. - Move KdbDebugPrint to kdb_cli.c as well.
show more ...
|
#
a8b09edd |
| 09-Jan-2023 |
Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> |
[NTOS:KD] Add some annotations.
|
#
c29d6806 |
| 21-Nov-2022 |
Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> |
[NTOS:KD] Remove last remnant of KdpDetectConflicts, deprecated since 2007.
Addendum to commit be2645ad8 (r25987).
|
#
271b9859 |
| 18-Nov-2022 |
Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> |
[NTOS:KD] Cleanup of some old code.
- Remove KdbInit() macro and directly use KdbpCliInit() (since the place where it was used was already within an #ifdef KDBG block).
- Declare KdpKdbgInit() on
[NTOS:KD] Cleanup of some old code.
- Remove KdbInit() macro and directly use KdbpCliInit() (since the place where it was used was already within an #ifdef KDBG block).
- Declare KdpKdbgInit() only when KDBG is defined, move its definition into kdio.c and remove the legacy wrappers/kdbg.c file. And in KdbInitialize(), set KdpInitRoutine directly to the former, instead of using the KdpKdbgInit indirection.
- Don't reset KdComPortInUse in KdpDebugLogInit().
- Minor refactorings: KdpSerialDebugPrint -> KdpSerialPrint and make it static; argument name "Message" -> "String", "StringLength" -> "Length".
show more ...
|
#
98e58536 |
| 18-Nov-2022 |
Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> |
[NTOS:KD] Annotate KdInitSystem and remove redundant declaration in kd.h
|
#
fe777bb5 |
| 20-Jul-2022 |
Timo Kreuzer <timo.kreuzer@reactos.org> |
[NTOS:KDBG] Nuke KdbEnter and KdbpCliModuleLoaded
They are not used anymore. Also clean up some obsolete prototypes.
|
#
cfbb7347 |
| 07-Mar-2022 |
Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> |
[NTOS] Remove ROS-specific __NTOSKRNL__
See https://reactos.org/archives/public/ros-kernel/2004-June/003878.html > In the source files one set of headers is included if __NTDLL__ is defines and onot
[NTOS] Remove ROS-specific __NTOSKRNL__
See https://reactos.org/archives/public/ros-kernel/2004-June/003878.html > In the source files one set of headers is included if __NTDLL__ is defines and onother set if __NTOSKRNL__ is defines (dirty workaround for our messy headers).
show more ...
|
Revision tags: 0.4.14-release, 0.4.15-dev, 0.4.14-RC, 0.4.13-release |
|
#
ba37323a |
| 31-Mar-2020 |
Hervé Poussineau <hpoussin@reactos.org> |
[NTOS:KD] Move some declarations where they belong
|
#
67e9cc00 |
| 31-Mar-2020 |
Hervé Poussineau <hpoussin@reactos.org> |
[NTOS:KD] Remove useless define
KdbEnterDebuggerException() is only called when KDBG is defined.
|
#
95faf65e |
| 28-Mar-2020 |
Hervé Poussineau <hpoussin@reactos.org> |
[NTOS:KD] Remove useless variables/members
Those where only set and never read.
|
#
8d3a3951 |
| 28-Mar-2020 |
Hervé Poussineau <hpoussin@reactos.org> |
[NTOS:KD] Remove Bochs port debugging
You can use serial port debugging instead.
|
#
458f4edf |
| 28-Mar-2020 |
Hervé Poussineau <hpoussin@reactos.org> |
[NTOS:KD] Remove 'support' for Pice. It was only setting a flag.
|
#
0e391eec |
| 28-Mar-2020 |
Hervé Poussineau <hpoussin@reactos.org> |
[NTOS:KD] Remove GDB stubs
drivers/base/kdgdb/ should be used instead.
|
#
a890fc64 |
| 17-Nov-2019 |
Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> |
[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 sam
[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().
show more ...
|
#
9537653e |
| 17-Nov-2019 |
Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org> |
[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"
[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.
show more ...
|
#
73903767 |
| 18-Oct-2019 |
Hervé Poussineau <hpoussin@reactos.org> |
Revert "[NTOS:KDBG] Use CONTEXT instead of KTRAP_FRAME"
This reverts commit e5bffe49da21f5faf2a88a0983ad4876d388e0ea.
CORE-16231
|
Revision tags: 0.4.14-dev, 0.4.13-RC, 0.4.12-release |
|
#
e5bffe49 |
| 23-May-2019 |
Hervé Poussineau <hpoussin@reactos.org> |
[NTOS:KDBG] Use CONTEXT instead of KTRAP_FRAME
Change KdbpTrapFrameToKdbTrapFrame to prefer CONTEXT (if available) over KTRAP_FRAME.
|
#
f7ec84ee |
| 20-May-2019 |
Hervé Poussineau <hpoussin@reactos.org> |
[NTOS:KD] Remove some _WINDK_ usages
- Always include kd64.h - Change KdpPrompt() prototype to be compatible between KDBG and _WINDK_ - Rename KdComponentTable to KdpComponentTable to prevent a conf
[NTOS:KD] Remove some _WINDK_ usages
- Always include kd64.h - Change KdpPrompt() prototype to be compatible between KDBG and _WINDK_ - Rename KdComponentTable to KdpComponentTable to prevent a conflict - Add some functions stubs and global variables
show more ...
|
#
f5e962ff |
| 20-May-2019 |
Hervé Poussineau <hpoussin@reactos.org> |
[NTOS:KD] Remove dead code
|
#
f6cec6d5 |
| 17-May-2019 |
Hervé Poussineau <hpoussin@reactos.org> |
[NTOS:KD] Remove /BREAK support left over, likely broken by 819a0ed90a7c1a5dedff08aa3b3c5501dc58c632
|