2009-10-12 03:35:35 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Kernel
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: ntoskrnl/kd64/kddata.c
|
|
|
|
* PURPOSE: Contains all global variables and settings for KD64
|
|
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
|
|
|
#include <ntoskrnl.h>
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
2014-11-10 16:26:55 +00:00
|
|
|
#include <mm/ARM3/miarm.h>
|
2012-02-08 22:23:10 +00:00
|
|
|
#undef MmSystemRangeStart
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
VOID NTAPI RtlpBreakWithStatusInstruction(VOID);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Apply the KIPCR WDK workaround for x86 and AMD64
|
|
|
|
//
|
2015-09-28 14:08:54 +00:00
|
|
|
#if defined(_M_IX86) || defined(_M_AMD64)
|
2009-10-12 03:35:35 +00:00
|
|
|
#define KPCR KIPCR
|
|
|
|
#endif
|
|
|
|
|
2015-09-28 14:08:54 +00:00
|
|
|
#if defined(_M_IX86)
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2017-12-12 11:50:58 +00:00
|
|
|
#define KPCR_SELF_PCR_OFFSET FIELD_OFFSET(KPCR, SelfPcr)
|
2009-10-12 03:35:35 +00:00
|
|
|
#define KPCR_CURRENT_PRCB_OFFSET FIELD_OFFSET(KPCR, Prcb)
|
|
|
|
#define KPCR_CONTAINED_PRCB_OFFSET FIELD_OFFSET(KPCR, PrcbData)
|
2009-11-02 17:45:51 +00:00
|
|
|
#define KPCR_INITIAL_STACK_OFFSET 0
|
|
|
|
#define KPCR_STACK_LIMIT_OFFSET 0
|
|
|
|
#define KPRCB_PCR_PAGE_OFFSET 0
|
2009-11-09 23:19:03 +00:00
|
|
|
#define CBSTACK_FRAME_POINTER Ebp
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2015-09-28 14:08:54 +00:00
|
|
|
#elif defined(_M_AMD64)
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2009-11-02 17:45:51 +00:00
|
|
|
#define KPCR_SELF_PCR_OFFSET FIELD_OFFSET(KPCR, Self)
|
2009-10-12 03:35:35 +00:00
|
|
|
#define KPCR_CURRENT_PRCB_OFFSET FIELD_OFFSET(KPCR, CurrentPrcb)
|
|
|
|
#define KPCR_CONTAINED_PRCB_OFFSET FIELD_OFFSET(KPCR, Prcb)
|
2009-11-02 17:45:51 +00:00
|
|
|
#define KPCR_INITIAL_STACK_OFFSET 0
|
|
|
|
#define KPCR_STACK_LIMIT_OFFSET 0
|
|
|
|
#define KPRCB_PCR_PAGE_OFFSET 0
|
2009-11-09 23:19:03 +00:00
|
|
|
#define CBSTACK_FRAME_POINTER Rbp
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2015-09-28 14:08:54 +00:00
|
|
|
#elif defined(_M_ARM)
|
2009-10-12 03:35:35 +00:00
|
|
|
|
2009-11-02 17:45:51 +00:00
|
|
|
#define KPCR_SELF_PCR_OFFSET 0
|
2015-05-14 22:31:58 +00:00
|
|
|
#define KPCR_CURRENT_PRCB_OFFSET FIELD_OFFSET(KIPCR, Prcb)
|
2009-10-31 13:46:16 +00:00
|
|
|
#define KPCR_CONTAINED_PRCB_OFFSET 0
|
2009-11-02 17:45:51 +00:00
|
|
|
#define KPCR_INITIAL_STACK_OFFSET FIELD_OFFSET(KPCR, InitialStack)
|
|
|
|
#define KPCR_STACK_LIMIT_OFFSET FIELD_OFFSET(KPCR, StackLimit)
|
|
|
|
#define KPRCB_PCR_PAGE_OFFSET FIELD_OFFSET(KPRCB, PcrPage)
|
2009-11-09 23:19:03 +00:00
|
|
|
#define CBSTACK_FRAME_POINTER DummyFramePointer
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
#error Unsupported Architecture
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
|
|
|
//
|
|
|
|
// Debugger State
|
|
|
|
//
|
|
|
|
KD_CONTEXT KdpContext;
|
|
|
|
BOOLEAN KdpPortLocked;
|
|
|
|
KSPIN_LOCK KdpDebuggerLock;
|
|
|
|
BOOLEAN KdpControlCPressed;
|
2009-11-02 17:45:51 +00:00
|
|
|
BOOLEAN KdpContextSent;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Debug Trap Handlers
|
|
|
|
//
|
|
|
|
PKDEBUG_ROUTINE KiDebugRoutine = KdpStub;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Debugger Configuration Settings
|
|
|
|
//
|
|
|
|
BOOLEAN KdBreakAfterSymbolLoad;
|
|
|
|
BOOLEAN KdPitchDebugger;
|
2014-05-11 23:11:16 +00:00
|
|
|
BOOLEAN KdDebuggerNotPresent;
|
|
|
|
BOOLEAN KdDebuggerEnabled;
|
2009-10-12 03:35:35 +00:00
|
|
|
BOOLEAN KdAutoEnableOnEvent;
|
2009-10-17 14:31:38 +00:00
|
|
|
BOOLEAN KdBlockEnable;
|
|
|
|
BOOLEAN KdIgnoreUmExceptions;
|
2009-10-12 03:35:35 +00:00
|
|
|
BOOLEAN KdPreviouslyEnabled;
|
|
|
|
BOOLEAN KdpDebuggerStructuresInitialized;
|
|
|
|
BOOLEAN KdEnteredDebugger;
|
|
|
|
ULONG KdDisableCount;
|
|
|
|
LARGE_INTEGER KdPerformanceCounterRate;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Breakpoint Data
|
|
|
|
//
|
|
|
|
BREAKPOINT_ENTRY KdpBreakpointTable[KD_BREAKPOINT_MAX];
|
|
|
|
KD_BREAKPOINT_TYPE KdpBreakpointInstruction = KD_BREAKPOINT_VALUE;
|
|
|
|
BOOLEAN KdpOweBreakpoint;
|
|
|
|
BOOLEAN BreakpointsSuspended;
|
|
|
|
ULONG KdpNumInternalBreakpoints;
|
|
|
|
|
2009-10-17 14:31:38 +00:00
|
|
|
//
|
|
|
|
// Symbol Data
|
|
|
|
//
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
ULONG_PTR KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Tracepoint Data
|
|
|
|
//
|
|
|
|
ULONG TraceDataBuffer[40];
|
|
|
|
ULONG TraceDataBufferPosition = 1;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Time Slip Support
|
|
|
|
//
|
|
|
|
KDPC KdpTimeSlipDpc;
|
|
|
|
KTIMER KdpTimeSlipTimer;
|
|
|
|
WORK_QUEUE_ITEM KdpTimeSlipWorkItem;
|
|
|
|
LONG KdpTimeSlipPending = 1;
|
|
|
|
PKEVENT KdpTimeSlipEvent;
|
|
|
|
KSPIN_LOCK KdpTimeSlipEventLock;
|
|
|
|
LARGE_INTEGER KdTimerStop, KdTimerStart, KdTimerDifference;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Buffers
|
|
|
|
//
|
2022-11-23 17:19:41 +00:00
|
|
|
CHAR KdpMessageBuffer[KDP_MSG_BUFFER_SIZE];
|
|
|
|
CHAR KdpPathBuffer[KDP_MSG_BUFFER_SIZE];
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// KdPrint Buffers
|
|
|
|
//
|
2009-11-02 17:45:51 +00:00
|
|
|
CHAR KdPrintDefaultCircularBuffer[KD_DEFAULT_LOG_BUFFER_SIZE];
|
2009-10-12 03:35:35 +00:00
|
|
|
PCHAR KdPrintWritePointer = KdPrintDefaultCircularBuffer;
|
|
|
|
ULONG KdPrintRolloverCount;
|
|
|
|
PCHAR KdPrintCircularBuffer = KdPrintDefaultCircularBuffer;
|
|
|
|
ULONG KdPrintBufferSize = sizeof(KdPrintDefaultCircularBuffer);
|
|
|
|
ULONG KdPrintBufferChanges = 0;
|
[NTOS:KD64] Implement KdLogDbgPrint() for the WinDbg !dbgprint command.
See this command's documentation:
https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/-dbgprint
and the section "DbgPrint buffer and the debugger"
https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/reading-and-filtering-debugging-messages#dbgprint-buffer-and-the-debugger
for more details.
- Loosely implement the function, based on our existing circular printout
buffers in kdio.c.
- Enable its usage in the KdpPrint() and KdpPrompt() functions.
Notice that this function will *only* capture the strings being sent **to**
the debugger, and not the strings the debugger itself produce. (This means
that we cannot use the KdPrintCircularBuffer as a replacement for our
KDBG dmesg one, for example...)
How to test:
Run ReactOS under WinDbg, and use the !dbgprint command to view the
buffer. You can also use the Memory Window, place yourself at the
address pointed by KdPrintCircularBuffer and KdPrintWritePointer, and
read its contents.
What you should observe:
Prior notice: The circular buffer in debug builds of ReactOS and Windows
is 0x8000 bytes large. In release builds, its size is down to 0x1000.
1- When you start e.g. the 2nd-stage GUI installation of ReactOS, going
past the initial "devices installation" and letting it stabilize on
the Welcome page, break into WinDbg and run the !dbgprint command. You
should notice that the end of its output is weirdly truncated, compared
to what has been actually emitted to the debug output. Comparing this
with the actual contents of the circular buffer (via Memory Window),
shows that the buffer contents is actually correct.
2- Copy all the text that has been output by the !dbgprint command and
paste it in an editor; count the number of all characters appearing +
newlines (only CR or LF), and observe that this number is "mysteriously"
equal to 16384 == 0x4000.
3- Continue running ReactOS installation for a little while, breaking back
back into WinDbg and looking at !dbgprint again. Its output seems to be
still stopping at the same place as before (but the actual buffer memory
contents shows otherwise). Continue running ROS installation, and break
into the debugger when ROS is about to restart. You should now observe
that the dbgprint buffer rolled over:
dd nt!KdPrintRolloverCount shows 1.
Carefully analysing the output of !dbgprint, however, you will notice
that it looks a bit garbage-y: the first part of the output is actually
truncated after 16384 characters, then you get a second part of the
buffer showing what ReactOS was printing while shutting down. Then
you get again what was shown at the top of the !dbgprint output.
(Of course, comparing with the actual contents of the circular buffer
in memory shows that its contents are fine...)
The reason of these strange observations, is because there is an intrinsic
bug in the !dbgprint command implementation (in kdexts.dll). Essentially,
it displays the contents of the circular buffer in two single dprintf()
calls: one for the "older" (bottom) part of the buffer:
[WritePointer, EndOfBuffer]
and one for the "newer" (upper) part of the buffer:
[CircularBuffer, WritePointer[ .
The first aspect of the bug (causing observation 3), is that those two
parts are not necessarily NULL-terminated strings (especially after
rollover), so for example, displaying the upper part of the buffer, will
potentially also display part of the buffer's bottom part.
The second aspect of the bug (explaining observations 1 and 2), is due
to the implementation of the dprintf() function (callback in dbgenv.dll).
There, it uses a fixed-sized buffer of size 0x4000 == 16384 characters.
Since the output of the circular buffer is not done by little chunks,
but by the two large parts, if any of those are larger than 0x4000 they
get truncated on display.
(This last observation is confirmed in a completely different context by
https://community.osr.com/discussion/112439/dprintf-s-max-string-length .)
2022-11-23 22:24:59 +00:00
|
|
|
KSPIN_LOCK KdpPrintSpinLock;
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Debug Filter Masks
|
|
|
|
//
|
|
|
|
ULONG Kd_WIN2000_Mask = 1;
|
|
|
|
ULONG Kd_SYSTEM_Mask;
|
|
|
|
ULONG Kd_SMSS_Mask;
|
|
|
|
ULONG Kd_SETUP_Mask;
|
|
|
|
ULONG Kd_NTFS_Mask;
|
|
|
|
ULONG Kd_FSTUB_Mask;
|
|
|
|
ULONG Kd_CRASHDUMP_Mask;
|
|
|
|
ULONG Kd_CDAUDIO_Mask;
|
|
|
|
ULONG Kd_CDROM_Mask;
|
|
|
|
ULONG Kd_CLASSPNP_Mask;
|
|
|
|
ULONG Kd_DISK_Mask;
|
|
|
|
ULONG Kd_REDBOOK_Mask;
|
|
|
|
ULONG Kd_STORPROP_Mask;
|
|
|
|
ULONG Kd_SCSIPORT_Mask;
|
|
|
|
ULONG Kd_SCSIMINIPORT_Mask;
|
|
|
|
ULONG Kd_CONFIG_Mask;
|
|
|
|
ULONG Kd_I8042PRT_Mask;
|
|
|
|
ULONG Kd_SERMOUSE_Mask;
|
|
|
|
ULONG Kd_LSERMOUS_Mask;
|
|
|
|
ULONG Kd_KBDHID_Mask;
|
|
|
|
ULONG Kd_MOUHID_Mask;
|
|
|
|
ULONG Kd_KBDCLASS_Mask;
|
|
|
|
ULONG Kd_MOUCLASS_Mask;
|
|
|
|
ULONG Kd_TWOTRACK_Mask;
|
|
|
|
ULONG Kd_WMILIB_Mask;
|
|
|
|
ULONG Kd_ACPI_Mask;
|
|
|
|
ULONG Kd_AMLI_Mask;
|
|
|
|
ULONG Kd_HALIA64_Mask;
|
|
|
|
ULONG Kd_VIDEO_Mask;
|
|
|
|
ULONG Kd_SVCHOST_Mask;
|
|
|
|
ULONG Kd_VIDEOPRT_Mask;
|
|
|
|
ULONG Kd_TCPIP_Mask;
|
|
|
|
ULONG Kd_DMSYNTH_Mask;
|
|
|
|
ULONG Kd_NTOSPNP_Mask;
|
|
|
|
ULONG Kd_FASTFAT_Mask;
|
|
|
|
ULONG Kd_SAMSS_Mask;
|
|
|
|
ULONG Kd_PNPMGR_Mask;
|
|
|
|
ULONG Kd_NETAPI_Mask;
|
|
|
|
ULONG Kd_SCSERVER_Mask;
|
|
|
|
ULONG Kd_SCCLIENT_Mask;
|
|
|
|
ULONG Kd_SERIAL_Mask;
|
|
|
|
ULONG Kd_SERENUM_Mask;
|
|
|
|
ULONG Kd_UHCD_Mask;
|
|
|
|
ULONG Kd_RPCPROXY_Mask;
|
|
|
|
ULONG Kd_AUTOCHK_Mask;
|
|
|
|
ULONG Kd_DCOMSS_Mask;
|
|
|
|
ULONG Kd_UNIMODEM_Mask;
|
|
|
|
ULONG Kd_SIS_Mask;
|
|
|
|
ULONG Kd_FLTMGR_Mask;
|
|
|
|
ULONG Kd_WMICORE_Mask;
|
|
|
|
ULONG Kd_BURNENG_Mask;
|
|
|
|
ULONG Kd_IMAPI_Mask;
|
|
|
|
ULONG Kd_SXS_Mask;
|
|
|
|
ULONG Kd_FUSION_Mask;
|
|
|
|
ULONG Kd_IDLETASK_Mask;
|
|
|
|
ULONG Kd_SOFTPCI_Mask;
|
|
|
|
ULONG Kd_TAPE_Mask;
|
|
|
|
ULONG Kd_MCHGR_Mask;
|
|
|
|
ULONG Kd_IDEP_Mask;
|
|
|
|
ULONG Kd_PCIIDE_Mask;
|
|
|
|
ULONG Kd_FLOPPY_Mask;
|
|
|
|
ULONG Kd_FDC_Mask;
|
|
|
|
ULONG Kd_TERMSRV_Mask;
|
|
|
|
ULONG Kd_W32TIME_Mask;
|
|
|
|
ULONG Kd_PREFETCHER_Mask;
|
|
|
|
ULONG Kd_RSFILTER_Mask;
|
|
|
|
ULONG Kd_FCPORT_Mask;
|
|
|
|
ULONG Kd_PCI_Mask;
|
|
|
|
ULONG Kd_DMIO_Mask;
|
|
|
|
ULONG Kd_DMCONFIG_Mask;
|
|
|
|
ULONG Kd_DMADMIN_Mask;
|
|
|
|
ULONG Kd_WSOCKTRANSPORT_Mask;
|
|
|
|
ULONG Kd_VSS_Mask;
|
|
|
|
ULONG Kd_PNPMEM_Mask;
|
|
|
|
ULONG Kd_PROCESSOR_Mask;
|
|
|
|
ULONG Kd_DMSERVER_Mask;
|
|
|
|
ULONG Kd_SR_Mask;
|
|
|
|
ULONG Kd_INFINIBAND_Mask;
|
|
|
|
ULONG Kd_IHVDRIVER_Mask;
|
|
|
|
ULONG Kd_IHVVIDEO_Mask;
|
|
|
|
ULONG Kd_IHVAUDIO_Mask;
|
|
|
|
ULONG Kd_IHVNETWORK_Mask;
|
|
|
|
ULONG Kd_IHVSTREAMING_Mask;
|
|
|
|
ULONG Kd_IHVBUS_Mask;
|
|
|
|
ULONG Kd_HPS_Mask;
|
|
|
|
ULONG Kd_RTLTHREADPOOL_Mask;
|
|
|
|
ULONG Kd_LDR_Mask;
|
|
|
|
ULONG Kd_TCPIP6_Mask;
|
|
|
|
ULONG Kd_ISAPNP_Mask;
|
|
|
|
ULONG Kd_SHPC_Mask;
|
|
|
|
ULONG Kd_STORPORT_Mask;
|
|
|
|
ULONG Kd_STORMINIPORT_Mask;
|
|
|
|
ULONG Kd_PRINTSPOOLER_Mask;
|
|
|
|
ULONG Kd_VSSDYNDISK_Mask;
|
|
|
|
ULONG Kd_VERIFIER_Mask;
|
|
|
|
ULONG Kd_VDS_Mask;
|
|
|
|
ULONG Kd_VDSBAS_Mask;
|
2019-11-17 16:16:55 +00:00
|
|
|
ULONG Kd_VDSDYN_Mask; // Specified in Vista+
|
2009-10-12 03:35:35 +00:00
|
|
|
ULONG Kd_VDSDYNDR_Mask;
|
2019-11-17 16:16:55 +00:00
|
|
|
ULONG Kd_VDSLDR_Mask; // Specified in Vista+
|
2009-10-12 03:35:35 +00:00
|
|
|
ULONG Kd_VDSUTIL_Mask;
|
|
|
|
ULONG Kd_DFRGIFC_Mask;
|
|
|
|
ULONG Kd_DEFAULT_Mask;
|
|
|
|
ULONG Kd_MM_Mask;
|
|
|
|
ULONG Kd_DFSC_Mask;
|
|
|
|
ULONG Kd_WOW64_Mask;
|
2019-11-17 16:16:55 +00:00
|
|
|
//
|
|
|
|
// Components specified in Vista+, some of which we also use in ReactOS
|
|
|
|
//
|
|
|
|
ULONG Kd_ALPC_Mask;
|
|
|
|
ULONG Kd_WDI_Mask;
|
|
|
|
ULONG Kd_PERFLIB_Mask;
|
|
|
|
ULONG Kd_KTM_Mask;
|
|
|
|
ULONG Kd_IOSTRESS_Mask;
|
|
|
|
ULONG Kd_HEAP_Mask;
|
|
|
|
ULONG Kd_WHEA_Mask;
|
|
|
|
ULONG Kd_USERGDI_Mask;
|
|
|
|
ULONG Kd_MMCSS_Mask;
|
|
|
|
ULONG Kd_TPM_Mask;
|
|
|
|
ULONG Kd_THREADORDER_Mask;
|
|
|
|
ULONG Kd_ENVIRON_Mask;
|
|
|
|
ULONG Kd_EMS_Mask;
|
|
|
|
ULONG Kd_WDT_Mask;
|
|
|
|
ULONG Kd_FVEVOL_Mask;
|
|
|
|
ULONG Kd_NDIS_Mask;
|
|
|
|
ULONG Kd_NVCTRACE_Mask;
|
|
|
|
ULONG Kd_LUAFV_Mask;
|
|
|
|
ULONG Kd_APPCOMPAT_Mask;
|
|
|
|
ULONG Kd_USBSTOR_Mask;
|
|
|
|
ULONG Kd_SBP2PORT_Mask;
|
|
|
|
ULONG Kd_COVERAGE_Mask;
|
|
|
|
ULONG Kd_CACHEMGR_Mask;
|
|
|
|
ULONG Kd_MOUNTMGR_Mask;
|
|
|
|
ULONG Kd_CFR_Mask;
|
|
|
|
ULONG Kd_TXF_Mask;
|
|
|
|
ULONG Kd_KSECDD_Mask;
|
|
|
|
ULONG Kd_FLTREGRESS_Mask;
|
|
|
|
ULONG Kd_MPIO_Mask;
|
|
|
|
ULONG Kd_MSDSM_Mask;
|
|
|
|
ULONG Kd_UDFS_Mask;
|
|
|
|
ULONG Kd_PSHED_Mask;
|
|
|
|
ULONG Kd_STORVSP_Mask;
|
|
|
|
ULONG Kd_LSASS_Mask;
|
|
|
|
ULONG Kd_SSPICLI_Mask;
|
|
|
|
ULONG Kd_CNG_Mask;
|
|
|
|
ULONG Kd_EXFAT_Mask;
|
|
|
|
ULONG Kd_FILETRACE_Mask;
|
|
|
|
ULONG Kd_XSAVE_Mask;
|
|
|
|
ULONG Kd_SE_Mask;
|
|
|
|
ULONG Kd_DRIVEEXTENDER_Mask;
|
2020-07-18 14:25:45 +00:00
|
|
|
//
|
|
|
|
// Components specified in Windows 8
|
|
|
|
//
|
|
|
|
ULONG Kd_POWER_Mask;
|
|
|
|
ULONG Kd_CRASHDUMPXHCI_Mask;
|
|
|
|
ULONG Kd_GPIO_Mask;
|
|
|
|
ULONG Kd_REFS_Mask;
|
|
|
|
ULONG Kd_WER_Mask;
|
|
|
|
//
|
|
|
|
// Components specified in Windows 10
|
|
|
|
//
|
|
|
|
ULONG Kd_CAPIMG_Mask;
|
|
|
|
ULONG Kd_VPCI_Mask;
|
|
|
|
ULONG Kd_STORAGECLASSMEMORY_Mask;
|
|
|
|
ULONG Kd_FSLIB_Mask;
|
2019-11-17 16:16:55 +00:00
|
|
|
// End Mask
|
2009-10-12 03:35:35 +00:00
|
|
|
ULONG Kd_ENDOFTABLE_Mask;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Debug Filter Component Table
|
|
|
|
//
|
2019-11-17 16:16:55 +00:00
|
|
|
PULONG KdComponentTable[MAX_KD_COMPONENT_TABLE_ENTRIES] =
|
2009-10-12 03:35:35 +00:00
|
|
|
{
|
|
|
|
&Kd_SYSTEM_Mask,
|
|
|
|
&Kd_SMSS_Mask,
|
|
|
|
&Kd_SETUP_Mask,
|
|
|
|
&Kd_NTFS_Mask,
|
|
|
|
&Kd_FSTUB_Mask,
|
|
|
|
&Kd_CRASHDUMP_Mask,
|
|
|
|
&Kd_CDAUDIO_Mask,
|
|
|
|
&Kd_CDROM_Mask,
|
|
|
|
&Kd_CLASSPNP_Mask,
|
|
|
|
&Kd_DISK_Mask,
|
|
|
|
&Kd_REDBOOK_Mask,
|
|
|
|
&Kd_STORPROP_Mask,
|
|
|
|
&Kd_SCSIPORT_Mask,
|
|
|
|
&Kd_SCSIMINIPORT_Mask,
|
|
|
|
&Kd_CONFIG_Mask,
|
|
|
|
&Kd_I8042PRT_Mask,
|
|
|
|
&Kd_SERMOUSE_Mask,
|
|
|
|
&Kd_LSERMOUS_Mask,
|
|
|
|
&Kd_KBDHID_Mask,
|
|
|
|
&Kd_MOUHID_Mask,
|
|
|
|
&Kd_KBDCLASS_Mask,
|
|
|
|
&Kd_MOUCLASS_Mask,
|
|
|
|
&Kd_TWOTRACK_Mask,
|
|
|
|
&Kd_WMILIB_Mask,
|
|
|
|
&Kd_ACPI_Mask,
|
|
|
|
&Kd_AMLI_Mask,
|
|
|
|
&Kd_HALIA64_Mask,
|
|
|
|
&Kd_VIDEO_Mask,
|
|
|
|
&Kd_SVCHOST_Mask,
|
|
|
|
&Kd_VIDEOPRT_Mask,
|
|
|
|
&Kd_TCPIP_Mask,
|
|
|
|
&Kd_DMSYNTH_Mask,
|
|
|
|
&Kd_NTOSPNP_Mask,
|
|
|
|
&Kd_FASTFAT_Mask,
|
|
|
|
&Kd_SAMSS_Mask,
|
|
|
|
&Kd_PNPMGR_Mask,
|
|
|
|
&Kd_NETAPI_Mask,
|
|
|
|
&Kd_SCSERVER_Mask,
|
|
|
|
&Kd_SCCLIENT_Mask,
|
|
|
|
&Kd_SERIAL_Mask,
|
|
|
|
&Kd_SERENUM_Mask,
|
|
|
|
&Kd_UHCD_Mask,
|
|
|
|
&Kd_RPCPROXY_Mask,
|
|
|
|
&Kd_AUTOCHK_Mask,
|
|
|
|
&Kd_DCOMSS_Mask,
|
|
|
|
&Kd_UNIMODEM_Mask,
|
|
|
|
&Kd_SIS_Mask,
|
|
|
|
&Kd_FLTMGR_Mask,
|
|
|
|
&Kd_WMICORE_Mask,
|
|
|
|
&Kd_BURNENG_Mask,
|
|
|
|
&Kd_IMAPI_Mask,
|
|
|
|
&Kd_SXS_Mask,
|
|
|
|
&Kd_FUSION_Mask,
|
|
|
|
&Kd_IDLETASK_Mask,
|
|
|
|
&Kd_SOFTPCI_Mask,
|
|
|
|
&Kd_TAPE_Mask,
|
|
|
|
&Kd_MCHGR_Mask,
|
|
|
|
&Kd_IDEP_Mask,
|
|
|
|
&Kd_PCIIDE_Mask,
|
|
|
|
&Kd_FLOPPY_Mask,
|
|
|
|
&Kd_FDC_Mask,
|
|
|
|
&Kd_TERMSRV_Mask,
|
|
|
|
&Kd_W32TIME_Mask,
|
|
|
|
&Kd_PREFETCHER_Mask,
|
|
|
|
&Kd_RSFILTER_Mask,
|
|
|
|
&Kd_FCPORT_Mask,
|
|
|
|
&Kd_PCI_Mask,
|
|
|
|
&Kd_DMIO_Mask,
|
|
|
|
&Kd_DMCONFIG_Mask,
|
|
|
|
&Kd_DMADMIN_Mask,
|
|
|
|
&Kd_WSOCKTRANSPORT_Mask,
|
|
|
|
&Kd_VSS_Mask,
|
|
|
|
&Kd_PNPMEM_Mask,
|
|
|
|
&Kd_PROCESSOR_Mask,
|
|
|
|
&Kd_DMSERVER_Mask,
|
|
|
|
&Kd_SR_Mask,
|
|
|
|
&Kd_INFINIBAND_Mask,
|
|
|
|
&Kd_IHVDRIVER_Mask,
|
|
|
|
&Kd_IHVVIDEO_Mask,
|
|
|
|
&Kd_IHVAUDIO_Mask,
|
|
|
|
&Kd_IHVNETWORK_Mask,
|
|
|
|
&Kd_IHVSTREAMING_Mask,
|
|
|
|
&Kd_IHVBUS_Mask,
|
|
|
|
&Kd_HPS_Mask,
|
|
|
|
&Kd_RTLTHREADPOOL_Mask,
|
|
|
|
&Kd_LDR_Mask,
|
|
|
|
&Kd_TCPIP6_Mask,
|
|
|
|
&Kd_ISAPNP_Mask,
|
|
|
|
&Kd_SHPC_Mask,
|
|
|
|
&Kd_STORPORT_Mask,
|
|
|
|
&Kd_STORMINIPORT_Mask,
|
|
|
|
&Kd_PRINTSPOOLER_Mask,
|
|
|
|
&Kd_VSSDYNDISK_Mask,
|
|
|
|
&Kd_VERIFIER_Mask,
|
|
|
|
&Kd_VDS_Mask,
|
|
|
|
&Kd_VDSBAS_Mask,
|
2019-11-17 16:16:55 +00:00
|
|
|
&Kd_VDSDYN_Mask, // Specified in Vista+
|
2009-10-12 03:35:35 +00:00
|
|
|
&Kd_VDSDYNDR_Mask,
|
2019-11-17 16:16:55 +00:00
|
|
|
&Kd_VDSLDR_Mask, // Specified in Vista+
|
2009-10-12 03:35:35 +00:00
|
|
|
&Kd_VDSUTIL_Mask,
|
|
|
|
&Kd_DFRGIFC_Mask,
|
|
|
|
&Kd_DEFAULT_Mask,
|
|
|
|
&Kd_MM_Mask,
|
|
|
|
&Kd_DFSC_Mask,
|
|
|
|
&Kd_WOW64_Mask,
|
2019-11-17 16:16:55 +00:00
|
|
|
//
|
|
|
|
// Components specified in Vista+, some of which we also use in ReactOS
|
|
|
|
//
|
|
|
|
&Kd_ALPC_Mask,
|
|
|
|
&Kd_WDI_Mask,
|
|
|
|
&Kd_PERFLIB_Mask,
|
|
|
|
&Kd_KTM_Mask,
|
|
|
|
&Kd_IOSTRESS_Mask,
|
|
|
|
&Kd_HEAP_Mask,
|
|
|
|
&Kd_WHEA_Mask,
|
|
|
|
&Kd_USERGDI_Mask,
|
|
|
|
&Kd_MMCSS_Mask,
|
|
|
|
&Kd_TPM_Mask,
|
|
|
|
&Kd_THREADORDER_Mask,
|
|
|
|
&Kd_ENVIRON_Mask,
|
|
|
|
&Kd_EMS_Mask,
|
|
|
|
&Kd_WDT_Mask,
|
|
|
|
&Kd_FVEVOL_Mask,
|
|
|
|
&Kd_NDIS_Mask,
|
|
|
|
&Kd_NVCTRACE_Mask,
|
|
|
|
&Kd_LUAFV_Mask,
|
|
|
|
&Kd_APPCOMPAT_Mask,
|
|
|
|
&Kd_USBSTOR_Mask,
|
|
|
|
&Kd_SBP2PORT_Mask,
|
|
|
|
&Kd_COVERAGE_Mask,
|
|
|
|
&Kd_CACHEMGR_Mask,
|
|
|
|
&Kd_MOUNTMGR_Mask,
|
|
|
|
&Kd_CFR_Mask,
|
|
|
|
&Kd_TXF_Mask,
|
|
|
|
&Kd_KSECDD_Mask,
|
|
|
|
&Kd_FLTREGRESS_Mask,
|
|
|
|
&Kd_MPIO_Mask,
|
|
|
|
&Kd_MSDSM_Mask,
|
|
|
|
&Kd_UDFS_Mask,
|
|
|
|
&Kd_PSHED_Mask,
|
|
|
|
&Kd_STORVSP_Mask,
|
|
|
|
&Kd_LSASS_Mask,
|
|
|
|
&Kd_SSPICLI_Mask,
|
|
|
|
&Kd_CNG_Mask,
|
|
|
|
&Kd_EXFAT_Mask,
|
|
|
|
&Kd_FILETRACE_Mask,
|
|
|
|
&Kd_XSAVE_Mask,
|
|
|
|
&Kd_SE_Mask,
|
|
|
|
&Kd_DRIVEEXTENDER_Mask,
|
2020-07-18 14:25:45 +00:00
|
|
|
//
|
|
|
|
// Components specified in Windows 8
|
|
|
|
//
|
|
|
|
&Kd_POWER_Mask,
|
|
|
|
&Kd_CRASHDUMPXHCI_Mask,
|
|
|
|
&Kd_GPIO_Mask,
|
|
|
|
&Kd_REFS_Mask,
|
|
|
|
&Kd_WER_Mask,
|
|
|
|
//
|
|
|
|
// Components specified in Windows 10
|
|
|
|
//
|
|
|
|
&Kd_CAPIMG_Mask,
|
|
|
|
&Kd_VPCI_Mask,
|
|
|
|
&Kd_STORAGECLASSMEMORY_Mask,
|
|
|
|
&Kd_FSLIB_Mask,
|
|
|
|
// End Mask
|
2009-10-12 03:35:35 +00:00
|
|
|
&Kd_ENDOFTABLE_Mask,
|
|
|
|
};
|
|
|
|
|
2020-07-18 14:25:45 +00:00
|
|
|
ULONG KdComponentTableSize = RTL_NUMBER_OF(KdComponentTable);
|
2009-10-12 03:35:35 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Debugger Data
|
|
|
|
//
|
|
|
|
LIST_ENTRY KdpDebuggerDataListHead;
|
|
|
|
KSPIN_LOCK KdpDataSpinLock;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Debugger Version and Data Block
|
|
|
|
//
|
|
|
|
DBGKD_GET_VERSION64 KdVersionBlock =
|
|
|
|
{
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
DBGKD_64BIT_PROTOCOL_VERSION2,
|
|
|
|
CURRENT_KD_SECONDARY_VERSION,
|
2015-09-28 14:08:54 +00:00
|
|
|
#if defined(_M_AMD64) || defined(_M_ARM64)
|
2009-10-12 03:35:35 +00:00
|
|
|
DBGKD_VERS_FLAG_DATA | DBGKD_VERS_FLAG_PTR64,
|
|
|
|
#else
|
|
|
|
DBGKD_VERS_FLAG_DATA,
|
|
|
|
#endif
|
2010-12-22 16:14:58 +00:00
|
|
|
IMAGE_FILE_MACHINE_NATIVE,
|
2009-10-12 03:35:35 +00:00
|
|
|
PACKET_TYPE_MAX,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
DBGKD_SIMULATION_NONE,
|
|
|
|
{0},
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
};
|
2022-11-23 05:16:17 +00:00
|
|
|
|
|
|
|
#if (NTDDI_VERSION >= NTDDI_WS03)
|
|
|
|
C_ASSERT(sizeof(KDDEBUGGER_DATA64) >= 0x318);
|
|
|
|
#endif
|
|
|
|
|
2022-11-24 02:22:39 +00:00
|
|
|
#if !defined(_WIN64) && (defined(__GNUC__) || defined(__clang__))
|
|
|
|
/* Minimal hackery for GCC/Clang, see commit b9cd3f2d9 (r25845) and de81021ba */
|
[PSDK][NTOS:KD64] Rename GCC_ULONG64 to ULPTR64 to self-document the fact it stores a pointer as a 64-bit quantity.
But the underlying GCC stupidity is still there (15 years later).
However, enable it only in 32-bit GCC builds, not in 64-bits nor with MSVC.
See commit b9cd3f2d9 (r25845) for some details.
GCC is indeed still incapable of casting 32-bit pointers up to 64-bits,
when static-initializing arrays (**outside** a function) without emitting
the error:
"error: initializer element is not constant"
(which might somehow indicate it actually tries to generate executable
code for casting the pointers, instead of doing it at compile-time).
Going down the rabbit hole, other stupidities show up:
Our PVOID64 type and the related POINTER_64 (in 32-bit archs), or the
PVOID32 and POINTER_32 (in 64-bit archs), are all silently broken in
GCC builds, because the pointer size attributes __ptr64 and __ptr32,
which are originally MSVC-specific, are defined to nothing in _mingw.h.
(And similarly for the __uptr and __sptr sign-extension attributes.)
Clang and other sane ompilers has since then implemented those (enabled
with -fms-extensions), but not GCC. The closest thing that could exist
for GCC is to do:
#define __ptr64 __attribute__((mode(DI)))
in order to get a 64-bit-sized pointer type with
typedef void* __ptr64 PVOID64;
but even this does not work, with the error:
"error: invalid pointer mode 'DI'"
2022-11-23 15:46:35 +00:00
|
|
|
#define PtrToUL64(x) ((ULPTR64)(ULONG_PTR)(x))
|
|
|
|
#else
|
|
|
|
#define PtrToUL64(x) ((ULPTR64)(x))
|
|
|
|
#endif
|
2009-10-12 03:35:35 +00:00
|
|
|
KDDEBUGGER_DATA64 KdDebuggerDataBlock =
|
|
|
|
{
|
|
|
|
{{0}},
|
|
|
|
0,
|
[PSDK][NTOS:KD64] Rename GCC_ULONG64 to ULPTR64 to self-document the fact it stores a pointer as a 64-bit quantity.
But the underlying GCC stupidity is still there (15 years later).
However, enable it only in 32-bit GCC builds, not in 64-bits nor with MSVC.
See commit b9cd3f2d9 (r25845) for some details.
GCC is indeed still incapable of casting 32-bit pointers up to 64-bits,
when static-initializing arrays (**outside** a function) without emitting
the error:
"error: initializer element is not constant"
(which might somehow indicate it actually tries to generate executable
code for casting the pointers, instead of doing it at compile-time).
Going down the rabbit hole, other stupidities show up:
Our PVOID64 type and the related POINTER_64 (in 32-bit archs), or the
PVOID32 and POINTER_32 (in 64-bit archs), are all silently broken in
GCC builds, because the pointer size attributes __ptr64 and __ptr32,
which are originally MSVC-specific, are defined to nothing in _mingw.h.
(And similarly for the __uptr and __sptr sign-extension attributes.)
Clang and other sane ompilers has since then implemented those (enabled
with -fms-extensions), but not GCC. The closest thing that could exist
for GCC is to do:
#define __ptr64 __attribute__((mode(DI)))
in order to get a 64-bit-sized pointer type with
typedef void* __ptr64 PVOID64;
but even this does not work, with the error:
"error: invalid pointer mode 'DI'"
2022-11-23 15:46:35 +00:00
|
|
|
PtrToUL64(RtlpBreakWithStatusInstruction),
|
2009-10-12 03:35:35 +00:00
|
|
|
0,
|
|
|
|
FIELD_OFFSET(KTHREAD, CallbackStack),
|
2015-05-02 23:12:19 +00:00
|
|
|
#if defined(_M_ARM) || defined(_M_AMD64)
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
#else
|
2009-11-09 23:19:03 +00:00
|
|
|
FIELD_OFFSET(KCALLOUT_FRAME, CallbackStack),
|
|
|
|
FIELD_OFFSET(KCALLOUT_FRAME, CBSTACK_FRAME_POINTER),
|
2015-05-02 23:12:19 +00:00
|
|
|
#endif
|
2009-10-12 03:35:35 +00:00
|
|
|
FALSE,
|
[PSDK][NTOS:KD64] Rename GCC_ULONG64 to ULPTR64 to self-document the fact it stores a pointer as a 64-bit quantity.
But the underlying GCC stupidity is still there (15 years later).
However, enable it only in 32-bit GCC builds, not in 64-bits nor with MSVC.
See commit b9cd3f2d9 (r25845) for some details.
GCC is indeed still incapable of casting 32-bit pointers up to 64-bits,
when static-initializing arrays (**outside** a function) without emitting
the error:
"error: initializer element is not constant"
(which might somehow indicate it actually tries to generate executable
code for casting the pointers, instead of doing it at compile-time).
Going down the rabbit hole, other stupidities show up:
Our PVOID64 type and the related POINTER_64 (in 32-bit archs), or the
PVOID32 and POINTER_32 (in 64-bit archs), are all silently broken in
GCC builds, because the pointer size attributes __ptr64 and __ptr32,
which are originally MSVC-specific, are defined to nothing in _mingw.h.
(And similarly for the __uptr and __sptr sign-extension attributes.)
Clang and other sane ompilers has since then implemented those (enabled
with -fms-extensions), but not GCC. The closest thing that could exist
for GCC is to do:
#define __ptr64 __attribute__((mode(DI)))
in order to get a 64-bit-sized pointer type with
typedef void* __ptr64 PVOID64;
but even this does not work, with the error:
"error: invalid pointer mode 'DI'"
2022-11-23 15:46:35 +00:00
|
|
|
PtrToUL64(KiCallUserMode),
|
|
|
|
0,
|
|
|
|
PtrToUL64(&PsLoadedModuleList),
|
|
|
|
PtrToUL64(&PsActiveProcessHead),
|
|
|
|
PtrToUL64(&PspCidTable),
|
|
|
|
PtrToUL64(&ExpSystemResourcesList),
|
|
|
|
PtrToUL64(ExpPagedPoolDescriptor),
|
|
|
|
PtrToUL64(&ExpNumberOfPagedPools),
|
|
|
|
PtrToUL64(&KeTimeIncrement),
|
|
|
|
PtrToUL64(&KeBugcheckCallbackListHead),
|
|
|
|
PtrToUL64(KiBugCheckData),
|
|
|
|
PtrToUL64(&IopErrorLogListHead),
|
|
|
|
PtrToUL64(&ObpRootDirectoryObject),
|
|
|
|
PtrToUL64(&ObpTypeObjectType),
|
|
|
|
PtrToUL64(&MmSystemCacheStart),
|
|
|
|
PtrToUL64(&MmSystemCacheEnd),
|
|
|
|
PtrToUL64(&MmSystemCacheWs),
|
|
|
|
PtrToUL64(&MmPfnDatabase),
|
|
|
|
PtrToUL64(MmSystemPtesStart),
|
|
|
|
PtrToUL64(MmSystemPtesEnd),
|
|
|
|
PtrToUL64(&MmSubsectionBase),
|
|
|
|
PtrToUL64(&MmNumberOfPagingFiles),
|
|
|
|
PtrToUL64(&MmLowestPhysicalPage),
|
|
|
|
PtrToUL64(&MmHighestPhysicalPage),
|
|
|
|
PtrToUL64(&MmNumberOfPhysicalPages),
|
|
|
|
PtrToUL64(&MmMaximumNonPagedPoolInBytes),
|
|
|
|
PtrToUL64(&MmNonPagedSystemStart),
|
|
|
|
PtrToUL64(&MmNonPagedPoolStart),
|
|
|
|
PtrToUL64(&MmNonPagedPoolEnd),
|
|
|
|
PtrToUL64(&MmPagedPoolStart),
|
|
|
|
PtrToUL64(&MmPagedPoolEnd),
|
|
|
|
PtrToUL64(&MmPagedPoolInfo),
|
2009-10-12 03:35:35 +00:00
|
|
|
PAGE_SIZE,
|
[PSDK][NTOS:KD64] Rename GCC_ULONG64 to ULPTR64 to self-document the fact it stores a pointer as a 64-bit quantity.
But the underlying GCC stupidity is still there (15 years later).
However, enable it only in 32-bit GCC builds, not in 64-bits nor with MSVC.
See commit b9cd3f2d9 (r25845) for some details.
GCC is indeed still incapable of casting 32-bit pointers up to 64-bits,
when static-initializing arrays (**outside** a function) without emitting
the error:
"error: initializer element is not constant"
(which might somehow indicate it actually tries to generate executable
code for casting the pointers, instead of doing it at compile-time).
Going down the rabbit hole, other stupidities show up:
Our PVOID64 type and the related POINTER_64 (in 32-bit archs), or the
PVOID32 and POINTER_32 (in 64-bit archs), are all silently broken in
GCC builds, because the pointer size attributes __ptr64 and __ptr32,
which are originally MSVC-specific, are defined to nothing in _mingw.h.
(And similarly for the __uptr and __sptr sign-extension attributes.)
Clang and other sane ompilers has since then implemented those (enabled
with -fms-extensions), but not GCC. The closest thing that could exist
for GCC is to do:
#define __ptr64 __attribute__((mode(DI)))
in order to get a 64-bit-sized pointer type with
typedef void* __ptr64 PVOID64;
but even this does not work, with the error:
"error: invalid pointer mode 'DI'"
2022-11-23 15:46:35 +00:00
|
|
|
PtrToUL64(&MmSizeOfPagedPoolInBytes),
|
|
|
|
PtrToUL64(&MmTotalCommitLimit),
|
|
|
|
PtrToUL64(&MmTotalCommittedPages),
|
|
|
|
PtrToUL64(&MmSharedCommit),
|
|
|
|
PtrToUL64(&MmDriverCommit),
|
|
|
|
PtrToUL64(&MmProcessCommit),
|
|
|
|
PtrToUL64(&MmPagedPoolCommit),
|
|
|
|
PtrToUL64(0),
|
|
|
|
PtrToUL64(&MmZeroedPageListHead),
|
|
|
|
PtrToUL64(&MmFreePageListHead),
|
|
|
|
PtrToUL64(&MmStandbyPageListHead),
|
|
|
|
PtrToUL64(&MmModifiedPageListHead),
|
|
|
|
PtrToUL64(&MmModifiedNoWritePageListHead),
|
|
|
|
PtrToUL64(&MmAvailablePages),
|
|
|
|
PtrToUL64(&MmResidentAvailablePages),
|
|
|
|
PtrToUL64(&PoolTrackTable),
|
|
|
|
PtrToUL64(&NonPagedPoolDescriptor),
|
|
|
|
PtrToUL64(&MmHighestUserAddress),
|
|
|
|
PtrToUL64(&MmSystemRangeStart),
|
|
|
|
PtrToUL64(&MmUserProbeAddress),
|
|
|
|
PtrToUL64(KdPrintDefaultCircularBuffer),
|
2022-11-23 17:19:41 +00:00
|
|
|
PtrToUL64(KdPrintDefaultCircularBuffer + sizeof(KdPrintDefaultCircularBuffer)),
|
[PSDK][NTOS:KD64] Rename GCC_ULONG64 to ULPTR64 to self-document the fact it stores a pointer as a 64-bit quantity.
But the underlying GCC stupidity is still there (15 years later).
However, enable it only in 32-bit GCC builds, not in 64-bits nor with MSVC.
See commit b9cd3f2d9 (r25845) for some details.
GCC is indeed still incapable of casting 32-bit pointers up to 64-bits,
when static-initializing arrays (**outside** a function) without emitting
the error:
"error: initializer element is not constant"
(which might somehow indicate it actually tries to generate executable
code for casting the pointers, instead of doing it at compile-time).
Going down the rabbit hole, other stupidities show up:
Our PVOID64 type and the related POINTER_64 (in 32-bit archs), or the
PVOID32 and POINTER_32 (in 64-bit archs), are all silently broken in
GCC builds, because the pointer size attributes __ptr64 and __ptr32,
which are originally MSVC-specific, are defined to nothing in _mingw.h.
(And similarly for the __uptr and __sptr sign-extension attributes.)
Clang and other sane ompilers has since then implemented those (enabled
with -fms-extensions), but not GCC. The closest thing that could exist
for GCC is to do:
#define __ptr64 __attribute__((mode(DI)))
in order to get a 64-bit-sized pointer type with
typedef void* __ptr64 PVOID64;
but even this does not work, with the error:
"error: invalid pointer mode 'DI'"
2022-11-23 15:46:35 +00:00
|
|
|
PtrToUL64(&KdPrintWritePointer),
|
|
|
|
PtrToUL64(&KdPrintRolloverCount),
|
|
|
|
PtrToUL64(&MmLoadedUserImageList),
|
|
|
|
PtrToUL64(&NtBuildLab),
|
|
|
|
PtrToUL64(0),
|
|
|
|
PtrToUL64(KiProcessorBlock),
|
|
|
|
PtrToUL64(&MmUnloadedDrivers),
|
|
|
|
PtrToUL64(&MmLastUnloadedDrivers),
|
|
|
|
PtrToUL64(&MmTriageActionTaken),
|
|
|
|
PtrToUL64(&MmSpecialPoolTag),
|
|
|
|
PtrToUL64(&KernelVerifier),
|
|
|
|
PtrToUL64(&MmVerifierData),
|
|
|
|
PtrToUL64(&MmAllocatedNonPagedPool),
|
|
|
|
PtrToUL64(&MmPeakCommitment),
|
|
|
|
PtrToUL64(&MmtotalCommitLimitMaximum),
|
|
|
|
PtrToUL64(&CmNtCSDVersion),
|
|
|
|
PtrToUL64(&MmPhysicalMemoryBlock),
|
|
|
|
PtrToUL64(&MmSessionBase),
|
|
|
|
PtrToUL64(&MmSessionSize),
|
|
|
|
PtrToUL64(0),
|
|
|
|
PtrToUL64(0),
|
2009-10-12 03:35:35 +00:00
|
|
|
FIELD_OFFSET(KTHREAD, NextProcessor),
|
|
|
|
FIELD_OFFSET(KTHREAD, Teb),
|
|
|
|
FIELD_OFFSET(KTHREAD, KernelStack),
|
|
|
|
FIELD_OFFSET(KTHREAD, InitialStack),
|
|
|
|
FIELD_OFFSET(KTHREAD, ApcState.Process),
|
|
|
|
FIELD_OFFSET(KTHREAD, State),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
sizeof(EPROCESS),
|
|
|
|
FIELD_OFFSET(EPROCESS, Peb),
|
|
|
|
FIELD_OFFSET(EPROCESS, InheritedFromUniqueProcessId),
|
|
|
|
FIELD_OFFSET(EPROCESS, Pcb.DirectoryTableBase),
|
|
|
|
sizeof(KPRCB),
|
|
|
|
FIELD_OFFSET(KPRCB, DpcRoutineActive),
|
|
|
|
FIELD_OFFSET(KPRCB, CurrentThread),
|
|
|
|
FIELD_OFFSET(KPRCB, MHz),
|
|
|
|
FIELD_OFFSET(KPRCB, CpuType),
|
|
|
|
FIELD_OFFSET(KPRCB, VendorString),
|
|
|
|
FIELD_OFFSET(KPRCB, ProcessorState.ContextFrame),
|
|
|
|
FIELD_OFFSET(KPRCB, Number),
|
|
|
|
sizeof(ETHREAD),
|
2022-11-23 17:19:41 +00:00
|
|
|
PtrToUL64(&KdPrintCircularBuffer),
|
[PSDK][NTOS:KD64] Rename GCC_ULONG64 to ULPTR64 to self-document the fact it stores a pointer as a 64-bit quantity.
But the underlying GCC stupidity is still there (15 years later).
However, enable it only in 32-bit GCC builds, not in 64-bits nor with MSVC.
See commit b9cd3f2d9 (r25845) for some details.
GCC is indeed still incapable of casting 32-bit pointers up to 64-bits,
when static-initializing arrays (**outside** a function) without emitting
the error:
"error: initializer element is not constant"
(which might somehow indicate it actually tries to generate executable
code for casting the pointers, instead of doing it at compile-time).
Going down the rabbit hole, other stupidities show up:
Our PVOID64 type and the related POINTER_64 (in 32-bit archs), or the
PVOID32 and POINTER_32 (in 64-bit archs), are all silently broken in
GCC builds, because the pointer size attributes __ptr64 and __ptr32,
which are originally MSVC-specific, are defined to nothing in _mingw.h.
(And similarly for the __uptr and __sptr sign-extension attributes.)
Clang and other sane ompilers has since then implemented those (enabled
with -fms-extensions), but not GCC. The closest thing that could exist
for GCC is to do:
#define __ptr64 __attribute__((mode(DI)))
in order to get a 64-bit-sized pointer type with
typedef void* __ptr64 PVOID64;
but even this does not work, with the error:
"error: invalid pointer mode 'DI'"
2022-11-23 15:46:35 +00:00
|
|
|
PtrToUL64(&KdPrintBufferSize),
|
|
|
|
PtrToUL64(&KeLoaderBlock),
|
2009-10-31 13:46:16 +00:00
|
|
|
sizeof(KPCR),
|
2009-11-02 17:45:51 +00:00
|
|
|
KPCR_SELF_PCR_OFFSET,
|
2009-10-12 03:35:35 +00:00
|
|
|
KPCR_CURRENT_PRCB_OFFSET,
|
|
|
|
KPCR_CONTAINED_PRCB_OFFSET,
|
|
|
|
0,
|
|
|
|
0,
|
2015-05-14 22:31:58 +00:00
|
|
|
#if defined(_M_ARM)
|
|
|
|
_WARN("KPCR_INITIAL_STACK_OFFSET, KPCR_STACK_LIMIT_OFFSET and KPRCB_PCR_PAGE_OFFSET not properly defined on ARM")
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
#else
|
2009-11-02 17:45:51 +00:00
|
|
|
KPCR_INITIAL_STACK_OFFSET,
|
|
|
|
KPCR_STACK_LIMIT_OFFSET,
|
|
|
|
KPRCB_PCR_PAGE_OFFSET,
|
2015-05-14 22:31:58 +00:00
|
|
|
#endif
|
2009-10-12 03:35:35 +00:00
|
|
|
FIELD_OFFSET(KPRCB, ProcessorState.SpecialRegisters),
|
2015-09-28 14:08:54 +00:00
|
|
|
#if defined(_M_IX86)
|
2009-10-12 03:35:35 +00:00
|
|
|
//
|
|
|
|
// x86 GDT/LDT/TSS constants
|
|
|
|
//
|
|
|
|
KGDT_R0_CODE,
|
|
|
|
KGDT_R0_DATA,
|
|
|
|
KGDT_R0_PCR,
|
|
|
|
KGDT_R3_CODE,
|
|
|
|
KGDT_R3_DATA,
|
|
|
|
KGDT_R3_TEB,
|
|
|
|
KGDT_LDT,
|
|
|
|
KGDT_TSS,
|
|
|
|
0,
|
|
|
|
0,
|
2015-09-28 14:08:54 +00:00
|
|
|
#elif defined(_M_AMD64)
|
2009-10-12 03:35:35 +00:00
|
|
|
//
|
|
|
|
// AMD64 GDT/LDT/TSS constants
|
|
|
|
//
|
2010-07-15 11:24:17 +00:00
|
|
|
KGDT64_R0_CODE,
|
|
|
|
KGDT64_R3_DATA,
|
|
|
|
KGDT64_R3_DATA,
|
|
|
|
KGDT64_R3_CODE,
|
|
|
|
KGDT64_R3_DATA,
|
|
|
|
KGDT64_R3_DATA,
|
2009-10-12 03:35:35 +00:00
|
|
|
0,
|
2010-07-15 11:24:17 +00:00
|
|
|
KGDT64_SYS_TSS,
|
2009-10-12 03:35:35 +00:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
#else
|
|
|
|
//
|
|
|
|
// No GDT/LDT/TSS on other architectures
|
|
|
|
//
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
#endif
|
[PSDK][NTOS:KD64] Rename GCC_ULONG64 to ULPTR64 to self-document the fact it stores a pointer as a 64-bit quantity.
But the underlying GCC stupidity is still there (15 years later).
However, enable it only in 32-bit GCC builds, not in 64-bits nor with MSVC.
See commit b9cd3f2d9 (r25845) for some details.
GCC is indeed still incapable of casting 32-bit pointers up to 64-bits,
when static-initializing arrays (**outside** a function) without emitting
the error:
"error: initializer element is not constant"
(which might somehow indicate it actually tries to generate executable
code for casting the pointers, instead of doing it at compile-time).
Going down the rabbit hole, other stupidities show up:
Our PVOID64 type and the related POINTER_64 (in 32-bit archs), or the
PVOID32 and POINTER_32 (in 64-bit archs), are all silently broken in
GCC builds, because the pointer size attributes __ptr64 and __ptr32,
which are originally MSVC-specific, are defined to nothing in _mingw.h.
(And similarly for the __uptr and __sptr sign-extension attributes.)
Clang and other sane ompilers has since then implemented those (enabled
with -fms-extensions), but not GCC. The closest thing that could exist
for GCC is to do:
#define __ptr64 __attribute__((mode(DI)))
in order to get a 64-bit-sized pointer type with
typedef void* __ptr64 PVOID64;
but even this does not work, with the error:
"error: invalid pointer mode 'DI'"
2022-11-23 15:46:35 +00:00
|
|
|
PtrToUL64(&IopNumTriageDumpDataBlocks),
|
|
|
|
PtrToUL64(IopTriageDumpDataBlocks),
|
2022-11-23 05:16:17 +00:00
|
|
|
|
|
|
|
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
|
|
|
|
#error KdDebuggerDataBlock requires other fields for this NT version!
|
|
|
|
#endif
|
2009-10-12 03:35:35 +00:00
|
|
|
};
|