ReactOS  r75214
kd64.h File Reference

Go to the source code of this file.

Classes

struct  _BREAKPOINT_ENTRY
 

Macros

#define KD_DEFAULT_LOG_BUFFER_SIZE   0x1000
 
#define KD_BREAKPOINT_MAX   32
 
#define KD_HIGHEST_USER_BREAKPOINT_ADDRESS   (PVOID)0x60000000
 
#define KD_BREAKPOINT_ACTIVE   0x01
 
#define KD_BREAKPOINT_PENDING   0x02
 
#define KD_BREAKPOINT_SUSPENDED   0x04
 
#define KD_BREAKPOINT_EXPIRED   0x08
 

Typedefs

typedef struct _BREAKPOINT_ENTRY BREAKPOINT_ENTRY
 
typedef struct _BREAKPOINT_ENTRYPBREAKPOINT_ENTRY
 
typedef BOOLEAN(NTAPIPKDEBUG_ROUTINE )(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT Context, IN KPROCESSOR_MODE PreviousMode, IN BOOLEAN SecondChance)
 
typedef BOOLEAN(NTAPIPKDEBUG_SWITCH_ROUTINE )(IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT Context, IN BOOLEAN SecondChance)
 

Functions

BOOLEAN NTAPI KdInitSystem (ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI KdUpdateDataBlock (VOID)
 
BOOLEAN NTAPI KdIsThisAKdTrap (IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT Context, IN KPROCESSOR_MODE PreviousMode)
 
BOOLEAN NTAPI KdpSwitchProcessor (IN PEXCEPTION_RECORD ExceptionRecord, IN OUT PCONTEXT ContextRecord, IN BOOLEAN SecondChanceException)
 
VOID NTAPI KdpTimeSlipWork (IN PVOID Context)
 
VOID NTAPI KdpTimeSlipDpcRoutine (IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
BOOLEAN NTAPI KdpStub (IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT ContextRecord, IN KPROCESSOR_MODE PreviousMode, IN BOOLEAN SecondChanceException)
 
BOOLEAN NTAPI KdpTrap (IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT ContextRecord, IN KPROCESSOR_MODE PreviousMode, IN BOOLEAN SecondChanceException)
 
VOID NTAPI KdpPortLock (VOID)
 
VOID NTAPI KdpPortUnlock (VOID)
 
BOOLEAN NTAPI KdpPollBreakInWithPortLock (VOID)
 
BOOLEAN NTAPI KdEnterDebugger (IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
 
VOID NTAPI KdExitDebugger (IN BOOLEAN Enable)
 
NTSTATUS NTAPI KdEnableDebuggerWithLock (IN BOOLEAN NeedLock)
 
NTSTATUS NTAPI KdDisableDebuggerWithLock (IN BOOLEAN NeedLock)
 
NTSTATUS NTAPI KdpPrint (IN ULONG ComponentId, IN ULONG Level, IN LPSTR String, IN USHORT Length, IN KPROCESSOR_MODE PreviousMode, IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, OUT PBOOLEAN Handled)
 
USHORT NTAPI KdpPrompt (IN LPSTR PromptString, IN USHORT PromptLength, OUT LPSTR ResponseString, IN USHORT MaximumResponseLength, IN KPROCESSOR_MODE PreviousMode, IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
 
VOID NTAPI KdpSymbol (IN PSTRING DllPath, IN PKD_SYMBOLS_INFO SymbolInfo, IN BOOLEAN Unload, IN KPROCESSOR_MODE PreviousMode, IN PCONTEXT ContextRecord, IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
 
VOID NTAPI KdpCommandString (IN PSTRING NameString, IN PSTRING CommandString, IN KPROCESSOR_MODE PreviousMode, IN PCONTEXT ContextRecord, IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
 
VOID NTAPI KdpReportLoadSymbolsStateChange (IN PSTRING PathName, IN PKD_SYMBOLS_INFO SymbolInfo, IN BOOLEAN Unload, IN OUT PCONTEXT Context)
 
VOID NTAPI KdpReportCommandStringStateChange (IN PSTRING NameString, IN PSTRING CommandString, IN OUT PCONTEXT Context)
 
BOOLEAN NTAPI KdpReportExceptionStateChange (IN PEXCEPTION_RECORD ExceptionRecord, IN OUT PCONTEXT Context, IN BOOLEAN SecondChanceException)
 
ULONG NTAPI KdpAddBreakpoint (IN PVOID Address)
 
VOID NTAPI KdSetOwedBreakpoints (VOID)
 
BOOLEAN NTAPI KdpDeleteBreakpoint (IN ULONG BpEntry)
 
BOOLEAN NTAPI KdpDeleteBreakpointRange (IN PVOID Base, IN PVOID Limit)
 
VOID NTAPI KdpSuspendBreakPoint (IN ULONG BpEntry)
 
VOID NTAPI KdpRestoreAllBreakpoints (VOID)
 
VOID NTAPI KdpSuspendAllBreakPoints (VOID)
 
NTSTATUS NTAPI KdpAllowDisable (VOID)
 
NTSTATUS NTAPI KdpCopyMemoryChunks (IN ULONG64 Address, IN PVOID Buffer, IN ULONG TotalSize, IN ULONG ChunkSize, IN ULONG Flags, OUT PULONG ActualSize OPTIONAL)
 
VOID NTAPI KdpMoveMemory (IN PVOID Destination, IN PVOID Source, IN SIZE_T Length)
 
VOID NTAPI KdpZeroMemory (IN PVOID Destination, IN SIZE_T Length)
 
VOID NTAPI KdpSysGetVersion (IN PDBGKD_GET_VERSION64 Version)
 
VOID NTAPI KdpGetStateChange (IN PDBGKD_MANIPULATE_STATE64 State, IN PCONTEXT Context)
 
VOID NTAPI KdpSetContextState (IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange, IN PCONTEXT Context)
 
NTSTATUS NTAPI KdpSysReadMsr (IN ULONG Msr, OUT PLARGE_INTEGER MsrValue)
 
NTSTATUS NTAPI KdpSysWriteMsr (IN ULONG Msr, IN PLARGE_INTEGER MsrValue)
 
NTSTATUS NTAPI KdpSysReadBusData (IN ULONG BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length, OUT PULONG ActualLength)
 
NTSTATUS NTAPI KdpSysWriteBusData (IN ULONG BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length, OUT PULONG ActualLength)
 
NTSTATUS NTAPI KdpSysReadControlSpace (IN ULONG Processor, IN ULONG64 BaseAddress, IN PVOID Buffer, IN ULONG Length, OUT PULONG ActualLength)
 
NTSTATUS NTAPI KdpSysWriteControlSpace (IN ULONG Processor, IN ULONG64 BaseAddress, IN PVOID Buffer, IN ULONG Length, OUT PULONG ActualLength)
 
NTSTATUS NTAPI KdpSysReadIoSpace (IN ULONG InterfaceType, IN ULONG BusNumber, IN ULONG AddressSpace, IN ULONG64 IoAddress, IN PVOID DataValue, IN ULONG DataSize, OUT PULONG ActualDataSize)
 
NTSTATUS NTAPI KdpSysWriteIoSpace (IN ULONG InterfaceType, IN ULONG BusNumber, IN ULONG AddressSpace, IN ULONG64 IoAddress, IN PVOID DataValue, IN ULONG DataSize, OUT PULONG ActualDataSize)
 
NTSTATUS NTAPI KdpSysCheckLowMemory (IN ULONG Flags)
 
VOID __cdecl KdpDprintf (IN PCHAR Format,...)
 

Variables

DBGKD_GET_VERSION64 KdVersionBlock
 
KDDEBUGGER_DATA64 KdDebuggerDataBlock
 
LIST_ENTRY KdpDebuggerDataListHead
 
KSPIN_LOCK KdpDataSpinLock
 
LARGE_INTEGER KdPerformanceCounterRate
 
LARGE_INTEGER KdTimerStart
 
ULONG KdDisableCount
 
KD_CONTEXT KdpContext
 
PKDEBUG_ROUTINE KiDebugRoutine
 
PKDEBUG_SWITCH_ROUTINE KiDebugSwitchRoutine
 
BOOLEAN KdBreakAfterSymbolLoad
 
BOOLEAN KdPitchDebugger
 
BOOLEAN KdAutoEnableOnEvent
 
BOOLEAN KdBlockEnable
 
BOOLEAN KdIgnoreUmExceptions
 
BOOLEAN KdPreviouslyEnabled
 
BOOLEAN KdpDebuggerStructuresInitialized
 
BOOLEAN KdEnteredDebugger
 
KDPC KdpTimeSlipDpc
 
KTIMER KdpTimeSlipTimer
 
WORK_QUEUE_ITEM KdpTimeSlipWorkItem
 
LONG KdpTimeSlipPending
 
PKEVENT KdpTimeSlipEvent
 
KSPIN_LOCK KdpTimeSlipEventLock
 
BOOLEAN KdpPortLocked
 
BOOLEAN KdpControlCPressed
 
BOOLEAN KdpContextSent
 
KSPIN_LOCK KdpDebuggerLock
 
LARGE_INTEGER KdTimerStop
 
LARGE_INTEGER KdTimerDifference
 
ULONG KdComponentTableSize
 
ULONG Kd_WIN2000_Mask
 
PULONG KdComponentTable [104]
 
CHAR KdpMessageBuffer [0x1000]
 
CHAR KdpPathBuffer [0x1000]
 
CHAR KdPrintDefaultCircularBuffer [KD_DEFAULT_LOG_BUFFER_SIZE]
 
BREAKPOINT_ENTRY KdpBreakpointTable [KD_BREAKPOINT_MAX]
 
KD_BREAKPOINT_TYPE KdpBreakpointInstruction
 
BOOLEAN KdpOweBreakpoint
 
BOOLEAN BreakpointsSuspended
 
ULONG KdpNumInternalBreakpoints
 
ULONG_PTR KdpCurrentSymbolStart
 
ULONG_PTR KdpCurrentSymbolEnd
 
ULONG TraceDataBuffer [40]
 
ULONG TraceDataBufferPosition
 

Macro Definition Documentation

#define KD_BREAKPOINT_ACTIVE   0x01
#define KD_BREAKPOINT_EXPIRED   0x08
#define KD_BREAKPOINT_PENDING   0x02
#define KD_BREAKPOINT_SUSPENDED   0x04
#define KD_DEFAULT_LOG_BUFFER_SIZE   0x1000

Definition at line 15 of file kd64.h.

#define KD_HIGHEST_USER_BREAKPOINT_ADDRESS   (PVOID)0x60000000

Definition at line 33 of file kd64.h.

Referenced by KdpAddBreakpoint(), and KdSetOwedBreakpoints().

Typedef Documentation

typedef BOOLEAN(NTAPI * PKDEBUG_ROUTINE)(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT Context, IN KPROCESSOR_MODE PreviousMode, IN BOOLEAN SecondChance)

Definition at line 59 of file kd64.h.

typedef BOOLEAN(NTAPI * PKDEBUG_SWITCH_ROUTINE)(IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT Context, IN BOOLEAN SecondChance)

Definition at line 70 of file kd64.h.

Function Documentation

NTSTATUS NTAPI KdDisableDebuggerWithLock ( IN BOOLEAN  NeedLock)

Definition at line 2035 of file kdapi.c.

Referenced by KdDisableDebugger(), and KdInitSystem().

2036 {
2037  KIRQL OldIrql;
2038  NTSTATUS Status;
2039 
2040 #if defined(__GNUC__)
2041  /* Make gcc happy */
2042  OldIrql = PASSIVE_LEVEL;
2043 #endif
2044 
2045  /*
2046  * If enabling the debugger is blocked
2047  * then there is nothing to disable (duh)
2048  */
2049  if (KdBlockEnable)
2050  {
2051  /* Fail */
2052  return STATUS_ACCESS_DENIED;
2053  }
2054 
2055  /* Check if we need to acquire the lock */
2056  if (NeedLock)
2057  {
2058  /* Lock the port */
2059  KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
2060  KdpPortLock();
2061  }
2062 
2063  /* Check if we're not disabled */
2064  if (!KdDisableCount)
2065  {
2066  /* Check if the debugger was never actually initialized */
2067  if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
2068  {
2069  /* It wasn't, so don't re-enable it later */
2071  }
2072  else
2073  {
2074  /* It was, so we will re-enable it later */
2076  }
2077 
2078  /* Check if we were called from the exported API and are enabled */
2079  if ((NeedLock) && (KdPreviouslyEnabled))
2080  {
2081  /* Check if it is safe to disable the debugger */
2082  Status = KdpAllowDisable();
2083  if (!NT_SUCCESS(Status))
2084  {
2085  /* Release the lock and fail */
2086  KeLowerIrql(OldIrql);
2087  KdpPortUnlock();
2088  return Status;
2089  }
2090  }
2091 
2092  /* Only disable the debugger if it is enabled */
2093  if (KdDebuggerEnabled)
2094  {
2095  /*
2096  * Disable the debugger; suspend breakpoints
2097  * and reset the debug stub
2098  */
2101 
2102  /* We are disabled now */
2104  SharedUserData->KdDebuggerEnabled = FALSE;
2105  }
2106  }
2107 
2108  /* Increment the disable count */
2109  KdDisableCount++;
2110 
2111  /* Check if we had locked the port before */
2112  if (NeedLock)
2113  {
2114  /* Yes, now unlock it */
2115  KeLowerIrql(OldIrql);
2116  KdpPortUnlock();
2117  }
2118 
2119  /* We're done */
2120  return STATUS_SUCCESS;
2121 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
PKDEBUG_ROUTINE KiDebugRoutine
Definition: kdmain.c:471
BOOLEAN NTAPI KdpStub(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT ContextRecord, IN KPROCESSOR_MODE PreviousMode, IN BOOLEAN SecondChanceException)
Definition: kdtrap.c:271
BOOLEAN KdPreviouslyEnabled
Definition: kddata.c:87
BOOLEAN KdBlockEnable
Definition: kddata.c:85
NTSTATUS NTAPI KdpAllowDisable(VOID)
Definition: kdx64.c:364
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
BOOLEAN KdDebuggerEnabled
Definition: kdmain.c:16
VOID NTAPI KdpPortUnlock(VOID)
Definition: kdlock.c:27
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
VOID NTAPI KdpSuspendAllBreakPoints(VOID)
Definition: kdbreak.c:407
#define SharedUserData
ULONG KdDisableCount
Definition: kddata.c:90
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
Status
Definition: gdiplustypes.h:24
BOOLEAN KdPitchDebugger
Definition: kdmain.c:21
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
VOID NTAPI KdpPortLock(VOID)
Definition: kdlock.c:19
NTSTATUS NTAPI KdEnableDebuggerWithLock ( IN BOOLEAN  NeedLock)

Definition at line 1959 of file kdapi.c.

Referenced by KdEnableDebugger(), and KeBugCheckWithTf().

1960 {
1961  KIRQL OldIrql;
1962 
1963 #if defined(__GNUC__)
1964  /* Make gcc happy */
1965  OldIrql = PASSIVE_LEVEL;
1966 #endif
1967 
1968  /* Check if enabling the debugger is blocked */
1969  if (KdBlockEnable)
1970  {
1971  /* It is, fail the enable */
1972  return STATUS_ACCESS_DENIED;
1973  }
1974 
1975  /* Check if we need to acquire the lock */
1976  if (NeedLock)
1977  {
1978  /* Lock the port */
1979  KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
1980  KdpPortLock();
1981  }
1982 
1983  /* Check if we're not disabled */
1984  if (!KdDisableCount)
1985  {
1986  /* Check if we had locked the port before */
1987  if (NeedLock)
1988  {
1989  /* Do the unlock */
1990  KeLowerIrql(OldIrql);
1991  KdpPortUnlock();
1992 
1993  /* Fail: We're already enabled */
1994  return STATUS_INVALID_PARAMETER;
1995  }
1996  else
1997  {
1998  /*
1999  * This can only happen if we are called from a bugcheck
2000  * and were never initialized, so initialize the debugger now.
2001  */
2002  KdInitSystem(0, NULL);
2003 
2004  /* Return success since we initialized */
2005  return STATUS_SUCCESS;
2006  }
2007  }
2008 
2009  /* Decrease the disable count */
2010  if (!(--KdDisableCount))
2011  {
2012  /* We're now enabled again! Were we enabled before, too? */
2013  if (KdPreviouslyEnabled)
2014  {
2015  /* Reinitialize the Debugger */
2016  KdInitSystem(0, NULL);
2018  }
2019  }
2020 
2021  /* Check if we had locked the port before */
2022  if (NeedLock)
2023  {
2024  /* Yes, now unlock it */
2025  KeLowerIrql(OldIrql);
2026  KdpPortUnlock();
2027  }
2028 
2029  /* We're done */
2030  return STATUS_SUCCESS;
2031 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
BOOLEAN KdPreviouslyEnabled
Definition: kddata.c:87
BOOLEAN KdBlockEnable
Definition: kddata.c:85
UCHAR KIRQL
Definition: env_spec_w32.h:591
smooth NULL
Definition: ftsmooth.c:513
VOID NTAPI KdpPortUnlock(VOID)
Definition: kdlock.c:27
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
ULONG KdDisableCount
Definition: kddata.c:90
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
BOOLEAN NTAPI KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kdinit.c:174
VOID NTAPI KdpPortLock(VOID)
Definition: kdlock.c:19
VOID NTAPI KdpRestoreAllBreakpoints(VOID)
Definition: kdbreak.c:368
BOOLEAN NTAPI KdEnterDebugger ( IN PKTRAP_FRAME  TrapFrame,
IN PKEXCEPTION_FRAME  ExceptionFrame 
)

Definition at line 1871 of file kdapi.c.

Referenced by KdpCommandString(), KdpPrint(), KdpPrompt(), KdpReport(), KdpSymbol(), KdRefreshDebuggerNotPresent(), and KdSetOwedBreakpoints().

1873 {
1874  BOOLEAN Enable;
1875 
1876  /* Check if we have a trap frame */
1877  if (TrapFrame)
1878  {
1879  /* Calculate the time difference for the enter */
1883  }
1884  else
1885  {
1886  /* No trap frame, so can't calculate */
1887  KdTimerStop.QuadPart = 0;
1888  }
1889 
1890  /* Save the current IRQL */
1891  KeGetCurrentPrcb()->DebuggerSavedIRQL = KeGetCurrentIrql();
1892 
1893  /* Freeze all CPUs */
1894  Enable = KeFreezeExecution(TrapFrame, ExceptionFrame);
1895 
1896  /* Lock the port, save the state and set debugger entered */
1898  KdSave(FALSE);
1900 
1901  /* Check freeze flag */
1902  if (KiFreezeFlag & 1)
1903  {
1904  /* Print out errror */
1905  KdpDprintf("FreezeLock was jammed! Backup SpinLock was used!\n");
1906  }
1907 
1908  /* Check processor state */
1909  if (KiFreezeFlag & 2)
1910  {
1911  /* Print out errror */
1912  KdpDprintf("Some processors not frozen in debugger!\n");
1913  }
1914 
1915  /* Make sure we acquired the port */
1916  if (!KdpPortLocked) KdpDprintf("Port lock was not acquired!\n");
1917 
1918  /* Return if interrupts needs to be re-enabled */
1919  return Enable;
1920 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define TRUE
Definition: types.h:120
BOOLEAN Enable
Definition: acefiex.h:245
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1054
KSPIN_LOCK KdpDebuggerLock
Definition: kddata.c:67
LARGE_INTEGER KdTimerDifference
Definition: kddata.c:122
LARGE_INTEGER KdTimerStart
Definition: kd64.h:546
LARGE_INTEGER NTAPI KdpQueryPerformanceCounter(IN PKTRAP_FRAME TrapFrame)
Definition: kdapi.c:1854
#define FALSE
Definition: types.h:117
BOOLEAN KdEnteredDebugger
Definition: kdmain.c:17
BOOLEAN NTAPI KeFreezeExecution(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
Definition: freeze.c:26
ULONG KiFreezeFlag
Definition: cpu.c:38
unsigned char BOOLEAN
LARGE_INTEGER KdTimerStop
Definition: kddata.c:122
#define KdpDprintf
Definition: mmdbg.c:19
BOOLEAN KdpPortLocked
Definition: kddata.c:66
NTSTATUS NTAPI KdSave(IN BOOLEAN SleepTransition)
Definition: kdcom.c:102
BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock)
Definition: spinlock.c:303
LONGLONG QuadPart
Definition: typedefs.h:113
VOID NTAPI KdExitDebugger ( IN BOOLEAN  Enable)

Definition at line 1924 of file kdapi.c.

Referenced by KdpCommandString(), KdpPrint(), KdpPrompt(), KdpReport(), KdpSymbol(), KdRefreshDebuggerNotPresent(), and KdSetOwedBreakpoints().

1925 {
1926  ULONG TimeSlip;
1927 
1928  /* Restore the state and unlock the port */
1929  KdRestore(FALSE);
1931 
1932  /* Unfreeze the CPUs */
1934 
1935  /* Compare time with the one from KdEnterDebugger */
1936  if (!KdTimerStop.QuadPart)
1937  {
1938  /* We didn't get a trap frame earlier in so never got the time */
1940  }
1941  else
1942  {
1943  /* Query the timer */
1945  }
1946 
1947  /* Check if a Time Slip was on queue */
1949  if (TimeSlip == 1)
1950  {
1951  /* Queue a DPC for the time slip */
1953  KeInsertQueueDpc(&KdpTimeSlipDpc, NULL, NULL); // FIXME: this can trigger context switches!
1954  }
1955 }
LARGE_INTEGER NTAPI KeQueryPerformanceCounter(IN PLARGE_INTEGER PerformanceFreq)
Definition: timer.c:138
BOOLEAN Enable
Definition: acefiex.h:245
VOID NTAPI KeThawExecution(IN BOOLEAN Enable)
Definition: freeze.c:46
BOOLEAN NTAPI KeInsertQueueDpc(IN PKDPC Dpc, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: dpc.c:724
NTSTATUS NTAPI KdRestore(IN BOOLEAN SleepTransition)
Definition: kdcom.c:110
LONG KdpTimeSlipPending
Definition: kddata.c:119
LARGE_INTEGER KdTimerStart
Definition: kd64.h:546
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:513
VOID NTAPI KdpPortUnlock(VOID)
Definition: kdlock.c:27
LARGE_INTEGER KdTimerStop
Definition: kddata.c:122
KDPC KdpTimeSlipDpc
Definition: kddata.c:116
#define InterlockedIncrement
Definition: armddk.h:53
BOOLEAN KdpPortLocked
Definition: kddata.c:66
unsigned int ULONG
Definition: retypes.h:1
LONGLONG QuadPart
Definition: typedefs.h:113
BOOLEAN NTAPI KdInitSystem ( ULONG  Reserved,
PLOADER_PARAMETER_BLOCK  LoaderBlock 
)

Definition at line 174 of file kdinit.c.

Referenced by IoInitSystem(), KdEnableDebuggerWithLock(), KeEnterKernelDebugger(), KiInitializeSystem(), KiSystemStartup(), KiSystemStartupReal(), and Phase1InitializationDiscard().

176 {
177  ULONG Value;
178  ULONG i;
179  PCHAR CommandLine, Port, BaudRate, Irq;
180 
181  /* Set Default Port Options */
182  if (BootPhase == 0)
183  {
184  /* Get the Command Line */
185  CommandLine = LoaderBlock->LoadOptions;
186 
187  /* Upcase it */
188  _strupr(CommandLine);
189 
190  /* XXX Check for settings that we support */
191  if (strstr(CommandLine, "BREAK")) KdpEarlyBreak = TRUE;
192  if (strstr(CommandLine, "NODEBUG")) KdDebuggerEnabled = FALSE;
193  else if (strstr(CommandLine, "CRASHDEBUG")) KdDebuggerEnabled = FALSE;
194  else if (strstr(CommandLine, "DEBUG"))
195  {
196  /* Enable the kernel debugger */
199 #ifdef KDBG
200  /* Get the KDBG Settings */
202 #endif
203  }
204 
205  /* Let user-mode know our state */
206  SharedUserData->KdDebuggerEnabled = KdDebuggerEnabled;
207 
208  /* Get the port and baud rate */
209  Port = strstr(CommandLine, "DEBUGPORT");
210  BaudRate = strstr(CommandLine, "BAUDRATE");
211  Irq = strstr(CommandLine, "IRQ");
212 
213  /* Check if we got the /DEBUGPORT parameter(s) */
214  while (Port)
215  {
216  /* Move past the actual string, to reach the port*/
217  Port += sizeof("DEBUGPORT") - 1;
218 
219  /* Now get past any spaces and skip the equal sign */
220  while (*Port == ' ') Port++;
221  Port++;
222 
223  /* Get the debug mode and wrapper */
224  Port = KdpGetDebugMode(Port);
225  Port = strstr(Port, "DEBUGPORT");
226  }
227 
228  /* Use serial port then */
229  if (KdDebuggerEnabled && KdpDebugMode.Value == 0)
230  KdpDebugMode.Serial = TRUE;
231 
232  /* Check if we got a baud rate */
233  if (BaudRate)
234  {
235  /* Move past the actual string, to reach the rate */
236  BaudRate += sizeof("BAUDRATE") - 1;
237 
238  /* Now get past any spaces */
239  while (*BaudRate == ' ') BaudRate++;
240 
241  /* And make sure we have a rate */
242  if (*BaudRate)
243  {
244  /* Read and set it */
245  Value = atol(BaudRate + 1);
247  }
248  }
249 
250  /* Check Serial Port Settings [IRQ] */
251  if (Irq)
252  {
253  /* Move past the actual string, to reach the rate */
254  Irq += sizeof("IRQ") - 1;
255 
256  /* Now get past any spaces */
257  while (*Irq == ' ') Irq++;
258 
259  /* And make sure we have an IRQ */
260  if (*Irq)
261  {
262  /* Read and set it */
263  Value = atol(Irq + 1);
264  if (Value) KdpPortIrq = Value;
265  }
266  }
267 
268  /* Call Providers at Phase 0 */
269  for (i = 0; i < KdMax; i++)
270  {
271  InitRoutines[i](&DispatchTable[i], 0);
272  }
273 
274  /* Call Wrapper at Phase 0 */
276  return TRUE;
277  }
278  else /* BootPhase > 0 */
279  {
280 #ifdef _M_IX86
282 #endif
283  }
284 
285  /* Call the Initialization Routines of the Registered Providers */
286  KdpCallInitRoutine(BootPhase);
287 
288  /* Return success */
289  return TRUE;
290 }
CPPORT Port[4]
Definition: headless.c:34
#define TRUE
Definition: types.h:120
VOID NTAPI KdpEnableSafeMem(VOID)
Definition: kdmemsup.c:212
KDP_DEBUG_MODE KdpDebugMode
Definition: kdinit.c:25
VOID NTAPI INIT_FUNCTION KdpCallInitRoutine(ULONG BootPhase)
Definition: kdinit.c:146
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
VOID NTAPI INIT_FUNCTION KdbpGetCommandLineSettings(PCHAR p1)
Definition: kdb.c:1731
BOOLEAN KdpEarlyBreak
Definition: kdinit.c:29
CPPORT PortInfo
Definition: kdinit.c:20
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
KD_DISPATCH_TABLE DispatchTable[KdMax]
Definition: kdinit.c:31
BOOLEAN KdDebuggerEnabled
Definition: kdmain.c:16
PKDP_INIT_ROUTINE InitRoutines[KdMax]
Definition: kdinit.c:33
ULONG KdpPortIrq
Definition: kdinit.c:21
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
#define SharedUserData
UINTN UINT8 Value
Definition: acefiex.h:725
PKDP_INIT_ROUTINE WrapperInitRoutine
Definition: kdinit.c:27
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
ULONG BaudRate
Definition: cportlib.h:30
CPPORT SerialPortInfo
Definition: kdio.c:31
signed char * PCHAR
Definition: retypes.h:7
KD_DISPATCH_TABLE WrapperTable
Definition: kdinit.c:28
unsigned int ULONG
Definition: retypes.h:1
PCHAR NTAPI INIT_FUNCTION KdpGetDebugMode(PCHAR Currentp2)
Definition: kdinit.c:46
BOOLEAN KdDebuggerNotPresent
Definition: kdmain.c:18
BOOLEAN NTAPI KdIsThisAKdTrap ( IN PEXCEPTION_RECORD  ExceptionRecord,
IN PCONTEXT  Context,
IN KPROCESSOR_MODE  PreviousMode 
)

Definition at line 259 of file kdmain.c.

Referenced by KiDispatchException().

262 {
263  /* KDBG has its own mechanism for ignoring user mode exceptions */
264  return FALSE;
265 }
#define FALSE
Definition: types.h:117
ULONG NTAPI KdpAddBreakpoint ( IN PVOID  Address)

Definition at line 20 of file kdbreak.c.

Referenced by KdpWriteBreakpoint().

21 {
22  KD_BREAKPOINT_TYPE Content;
23  ULONG i;
25 
26  /* Check whether we are not setting a breakpoint twice */
27  for (i = 0; i < KD_BREAKPOINT_MAX; i++)
28  {
29  /* Check if the breakpoint is valid */
32  {
33  /* Were we not able to remove it earlier? */
35  {
36  /* Just re-use it! */
37  KdpBreakpointTable[i].Flags &= ~KD_BREAKPOINT_EXPIRED;
38  return i + 1;
39  }
40  else
41  {
42  /* Fail */
43  return 0;
44  }
45  }
46  }
47 
48  /* Find a free entry */
49  for (i = 0; i < KD_BREAKPOINT_MAX; i++)
50  {
51  if (KdpBreakpointTable[i].Flags == 0)
52  break;
53  }
54 
55  /* Fail if no free entry was found */
56  if (i == KD_BREAKPOINT_MAX) return 0;
57 
58  /* Save the breakpoint */
60 
61  /* If we are setting the breakpoint in user space, save the active process context */
63  KdpBreakpointTable[i].DirectoryTableBase = KeGetCurrentThread()->ApcState.Process->DirectoryTableBase[0];
64 
65  /* Try to save the old instruction */
67  &Content,
69  0,
71  NULL);
72  if (NT_SUCCESS(Status))
73  {
74  /* Memory accessible, set the breakpoint */
75  KdpBreakpointTable[i].Content = Content;
77 
78  /* Write the breakpoint */
82  0,
84  NULL);
85  if (!NT_SUCCESS(Status))
86  {
87  /* This should never happen */
88  KdpDprintf("Unable to write breakpoint to address 0x%p\n", Address);
89  }
90  }
91  else
92  {
93  /* Memory is inaccessible now, setting breakpoint is deferred */
94  KdpDprintf("Failed to set breakpoint at address 0x%p, adding deferred breakpoint.\n", Address);
95  KdpBreakpointTable[i].Flags = KD_BREAKPOINT_ACTIVE | KD_BREAKPOINT_PENDING;
97  }
98 
99  /* Return the breakpoint handle */
100  return i + 1;
101 }
#define TRUE
Definition: types.h:120
PVOID ULONG Address
Definition: oprghdlr.h:14
uint32_t ULONG_PTR
Definition: typedefs.h:64
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
GLenum GLclampf GLint i
Definition: glfuncs.h:14
ULONG_PTR DirectoryTableBase
Definition: kd64.h:49
BOOLEAN KdpOweBreakpoint
Definition: kddata.c:98
smooth NULL
Definition: ftsmooth.c:513
#define MMDBG_COPY_WRITE
Definition: mm.h:51
ULONG Flags
Definition: kd64.h:48
#define KD_BREAKPOINT_PENDING
Definition: kd64.h:39
#define KD_HIGHEST_USER_BREAKPOINT_ADDRESS
Definition: kd64.h:33
KD_BREAKPOINT_TYPE Content
Definition: kd64.h:51
KD_BREAKPOINT_TYPE KdpBreakpointInstruction
Definition: kddata.c:97
#define KD_BREAKPOINT_MAX
Definition: kd64.h:21
Status
Definition: gdiplustypes.h:24
#define KD_BREAKPOINT_TYPE
Definition: ke.h:93
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
#define MMDBG_COPY_UNSAFE
Definition: mm.h:53
BREAKPOINT_ENTRY KdpBreakpointTable[KD_BREAKPOINT_MAX]
Definition: kddata.c:96
#define KdpDprintf
Definition: mmdbg.c:19
PVOID Address
Definition: kd64.h:50
unsigned int ULONG
Definition: retypes.h:1
#define KD_BREAKPOINT_SIZE
Definition: ke.h:94
#define KeGetCurrentThread
Definition: hal.h:44
#define KD_BREAKPOINT_EXPIRED
Definition: kd64.h:41
NTSTATUS NTAPI KdpCopyMemoryChunks(IN ULONG64 Address, IN PVOID Buffer, IN ULONG TotalSize, IN ULONG ChunkSize, IN ULONG Flags, OUT PULONG ActualSize OPTIONAL)
Definition: kdapi.c:46
#define KD_BREAKPOINT_ACTIVE
Definition: kd64.h:38
NTSTATUS NTAPI KdpAllowDisable ( VOID  )

Definition at line 364 of file kdx64.c.

Referenced by KdDisableDebuggerWithLock().

365 {
367  return STATUS_ACCESS_DENIED;
368 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:226
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
VOID NTAPI KdpCommandString ( IN PSTRING  NameString,
IN PSTRING  CommandString,
IN KPROCESSOR_MODE  PreviousMode,
IN PCONTEXT  ContextRecord,
IN PKTRAP_FRAME  TrapFrame,
IN PKEXCEPTION_FRAME  ExceptionFrame 
)

Definition at line 133 of file kdprint.c.

Referenced by KdpTrap().

139 {
140  BOOLEAN Enable;
141  PKPRCB Prcb = KeGetCurrentPrcb();
142 
143  /* Check if we need to do anything */
144  if ((PreviousMode != KernelMode) || (KdDebuggerNotPresent)) return;
145 
146  /* Enter the debugger */
147  Enable = KdEnterDebugger(TrapFrame, ExceptionFrame);
148 
149  /* Save the CPU Control State and save the context */
153  sizeof(CONTEXT));
154 
155  /* Send the command string to the debugger */
157  CommandString,
159 
160  /* Restore the processor state */
163  sizeof(CONTEXT));
165 
166  /* Exit the debugger and return */
167  KdExitDebugger(Enable);
168 }
BOOLEAN Enable
Definition: acefiex.h:245
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1054
VOID NTAPI KdExitDebugger(IN BOOLEAN Enable)
Definition: kdapi.c:1924
CONTEXT ContextFrame
Definition: ketypes.h:531
VOID NTAPI KiRestoreProcessorControlState(IN PKPROCESSOR_STATE ProcessorState)
unsigned char BOOLEAN
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
KPROCESSOR_STATE ProcessorState
Definition: ketypes.h:579
_IRQL_requires_same_ _In_ PVOID _Inout_ struct _CONTEXT * ContextRecord
Definition: ntbasedef.h:653
VOID NTAPI KiSaveProcessorControlState(OUT PKPROCESSOR_STATE ProcessorState)
Definition: cpu.c:382
VOID NTAPI KdpMoveMemory(IN PVOID Destination, IN PVOID Source, IN SIZE_T Length)
Definition: kdapi.c:20
BOOLEAN NTAPI KdEnterDebugger(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
Definition: kdapi.c:1871
BOOLEAN KdDebuggerNotPresent
Definition: kdmain.c:18
VOID NTAPI KdpReportCommandStringStateChange(IN PSTRING NameString, IN PSTRING CommandString, IN OUT PCONTEXT Context)
Definition: kdapi.c:1653
NTSTATUS NTAPI KdpCopyMemoryChunks ( IN ULONG64  Address,
IN PVOID  Buffer,
IN ULONG  TotalSize,
IN ULONG  ChunkSize,
IN ULONG  Flags,
OUT PULONG ActualSize  OPTIONAL 
)

Definition at line 46 of file kdapi.c.

Referenced by KdpAddBreakpoint(), KdpLowRestoreBreakpoint(), KdpLowWriteContent(), KdpReadPhysicalmemory(), KdpReadVirtualMemory(), KdpReportCommandStringStateChange(), KdpReportLoadSymbolsStateChange(), KdpSetCommonState(), KdpSysReadControlSpace(), KdpSysWriteControlSpace(), KdpWritePhysicalmemory(), KdpWriteVirtualMemory(), and KdSetOwedBreakpoints().

52 {
54  ULONG RemainingLength, CopyChunk;
55 
56  /* Check if we didn't get a chunk size or if it is too big */
57  if (ChunkSize == 0)
58  {
59  /* Default to 4 byte chunks */
60  ChunkSize = 4;
61  }
62  else if (ChunkSize > MMDBG_COPY_MAX_SIZE)
63  {
64  /* Normalize to maximum size */
66  }
67 
68  /* Copy the whole range in aligned chunks */
69  RemainingLength = TotalSize;
70  CopyChunk = 1;
71  while (RemainingLength > 0)
72  {
73  /*
74  * Determine the best chunk size for this round.
75  * The ideal size is aligned, isn't larger than the
76  * the remaining length and respects the chunk limit.
77  */
78  while (((CopyChunk * 2) <= RemainingLength) &&
79  (CopyChunk < ChunkSize) &&
80  ((Address & ((CopyChunk * 2) - 1)) == 0))
81  {
82  /* Increase it */
83  CopyChunk *= 2;
84  }
85 
86  /*
87  * The chunk size can be larger than the remaining size if this isn't
88  * the first round, so check if we need to shrink it back
89  */
90  while (CopyChunk > RemainingLength)
91  {
92  /* Shrink it */
93  CopyChunk /= 2;
94  }
95 
96  /* Do the copy */
97  Status = MmDbgCopyMemory(Address,
98  Buffer,
99  CopyChunk,
100  Flags);
101  if (!NT_SUCCESS(Status))
102  {
103  /* Copy failed, break out */
104  break;
105  }
106 
107  /* Update pointers and length for the next run */
108  Address = Address + CopyChunk;
109  Buffer = (PVOID)((ULONG_PTR)Buffer + CopyChunk);
110  RemainingLength = RemainingLength - CopyChunk;
111  }
112 
113  /*
114  * We may have modified executable code, flush the instruction cache
115  */
116  KeSweepICache((PVOID)(ULONG_PTR)Address, TotalSize);
117 
118  /*
119  * Return the size we managed to copy
120  * and return success if we could copy the whole range
121  */
122  if (ActualSize) *ActualSize = TotalSize - RemainingLength;
123  return RemainingLength == 0 ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
124 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
PVOID ULONG Address
Definition: oprghdlr.h:14
uint32_t ULONG_PTR
Definition: typedefs.h:64
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Inout_ PUCHAR _In_ PUCHAR _Out_ PUCHAR _Out_ PULONG ChunkSize
Definition: rtlfuncs.h:2276
Definition: bufpool.h:45
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
NTSTATUS NTAPI MmDbgCopyMemory(IN ULONG64 Address, IN PVOID Buffer, IN ULONG Size, IN ULONG Flags)
Definition: mmdbg.c:126
LONG NTSTATUS
Definition: DriverTester.h:11
#define MMDBG_COPY_MAX_SIZE
Definition: mm.h:61
unsigned int ULONG
Definition: retypes.h:1
FORCEINLINE VOID KeSweepICache(IN PVOID BaseAddress, IN SIZE_T FlushSize)
Definition: ke.h:193
BOOLEAN NTAPI KdpDeleteBreakpoint ( IN ULONG  BpEntry)

Definition at line 311 of file kdbreak.c.

Referenced by KdpDeleteBreakpointRange(), and KdpRestoreBreakpoint().

312 {
313  ULONG BpIndex = BpEntry - 1;
314 
315  /* Check for invalid breakpoint entry */
316  if (!BpEntry || (BpEntry > KD_BREAKPOINT_MAX)) return FALSE;
317 
318  /* If the specified breakpoint table entry is not valid, then return FALSE. */
319  if (!KdpBreakpointTable[BpIndex].Flags) return FALSE;
320 
321  /* Check if the breakpoint is suspended */
322  if (KdpBreakpointTable[BpIndex].Flags & KD_BREAKPOINT_SUSPENDED)
323  {
324  /* Check if breakpoint is not being deleted */
325  if (!(KdpBreakpointTable[BpIndex].Flags & KD_BREAKPOINT_EXPIRED))
326  {
327  /* Invalidate it and return success */
328  KdpBreakpointTable[BpIndex].Flags = 0;
329  return TRUE;
330  }
331  }
332 
333  /* Restore original data, then invalidate it and return success */
334  if (KdpLowWriteContent(BpIndex)) KdpBreakpointTable[BpIndex].Flags = 0;
335  return TRUE;
336 }
#define TRUE
Definition: types.h:120
#define KD_BREAKPOINT_SUSPENDED
Definition: kd64.h:40
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI KdpLowWriteContent(IN ULONG BpIndex)
Definition: kdbreak.c:226
ULONG Flags
Definition: kd64.h:48
#define KD_BREAKPOINT_MAX
Definition: kd64.h:21
BREAKPOINT_ENTRY KdpBreakpointTable[KD_BREAKPOINT_MAX]
Definition: kddata.c:96
unsigned int ULONG
Definition: retypes.h:1
#define KD_BREAKPOINT_EXPIRED
Definition: kd64.h:41
BOOLEAN NTAPI KdpDeleteBreakpointRange ( IN PVOID  Base,
IN PVOID  Limit 
)

Definition at line 340 of file kdbreak.c.

Referenced by KdpSetCommonState().

342 {
343  ULONG BpIndex;
344  BOOLEAN DeletedBreakpoints;
345 
346  /* Assume no breakpoints will be deleted */
347  DeletedBreakpoints = FALSE;
348 
349  /* Loop the breakpoint table */
350  for (BpIndex = 0; BpIndex < KD_BREAKPOINT_MAX; BpIndex++)
351  {
352  /* Make sure that the breakpoint is active and matches the range. */
353  if ((KdpBreakpointTable[BpIndex].Flags & KD_BREAKPOINT_ACTIVE) &&
354  ((KdpBreakpointTable[BpIndex].Address >= Base) &&
355  (KdpBreakpointTable[BpIndex].Address <= Limit)))
356  {
357  /* Delete it, and remember if we succeeded at least once */
358  if (KdpDeleteBreakpoint(BpIndex + 1)) DeletedBreakpoints = TRUE;
359  }
360  }
361 
362  /* Return whether we deleted anything */
363  return DeletedBreakpoints;
364 }
#define TRUE
Definition: types.h:120
PVOID ULONG Address
Definition: oprghdlr.h:14
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2327
BOOLEAN NTAPI KdpDeleteBreakpoint(IN ULONG BpEntry)
Definition: kdbreak.c:311
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
#define KD_BREAKPOINT_MAX
Definition: kd64.h:21
BREAKPOINT_ENTRY KdpBreakpointTable[KD_BREAKPOINT_MAX]
Definition: kddata.c:96
unsigned int ULONG
Definition: retypes.h:1
_In_ LONG _In_ LONG Limit
Definition: kefuncs.h:328
#define KD_BREAKPOINT_ACTIVE
Definition: kd64.h:38
VOID __cdecl KdpDprintf ( IN PCHAR  Format,
  ... 
)

Definition at line 412 of file kdprint.c.

414 {
415  STRING String;
416  CHAR Buffer[100];
417  USHORT Length;
418  va_list ap;
419 
420  /* Format the string */
421  va_start(ap, Format);
422  Length = (USHORT)_vsnprintf(Buffer,
423  sizeof(Buffer),
424  Format,
425  ap);
426 
427  /* Set it up */
428  String.Buffer = Buffer;
429  String.Length = Length + 1;
430 
431  /* Send it to the debugger directly */
432  KdpPrintString(&String);
433  va_end(ap);
434 }
BOOLEAN NTAPI KdpPrintString(IN PSTRING Output)
Definition: kdprint.c:20
char CHAR
Definition: xmlstorage.h:175
CHAR16 * String
Definition: acefiex.h:201
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
Definition: bufpool.h:45
UINTN VOID * Buffer
Definition: acefiex.h:370
std::wstring STRING
Definition: fontsub.cpp:33
VOID UINTN Length
Definition: acefiex.h:718
unsigned short USHORT
Definition: pedump.c:61
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define _vsnprintf
Definition: xmlstorage.h:202
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char * Format
Definition: acpixf.h:1195
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
VOID NTAPI KdpGetStateChange ( IN PDBGKD_MANIPULATE_STATE64  State,
IN PCONTEXT  Context 
)

Definition at line 22 of file kdx64.c.

Referenced by KdpSendWaitContinue().

24 {
25  PKPRCB Prcb;
26  ULONG i;
27 
28  /* Check for success */
29  if (NT_SUCCESS(State->u.Continue2.ContinueStatus))
30  {
31  /* Check if we're tracing */
32  if (State->u.Continue2.ControlSet.TraceFlag)
33  {
34  /* Enable TF */
35  Context->EFlags |= EFLAGS_TF;
36  }
37  else
38  {
39  /* Remove it */
40  Context->EFlags &= ~EFLAGS_TF;
41  }
42 
43  /* Loop all processors */
44  for (i = 0; i < KeNumberProcessors; i++)
45  {
46  /* Get the PRCB and update DR7 and DR6 */
47  Prcb = KiProcessorBlock[i];
49  State->u.Continue2.ControlSet.Dr7;
51  }
52 
53  /* Check if we have new symbol information */
54  if (State->u.Continue2.ControlSet.CurrentSymbolStart != 1)
55  {
56  /* Update it */
58  State->u.Continue2.ControlSet.CurrentSymbolStart;
59  KdpCurrentSymbolEnd= State->u.Continue2.ControlSet.CurrentSymbolEnd;
60  }
61  }
62 }
ULONG64 KernelDr7
Definition: ketypes.h:505
KSPECIAL_REGISTERS SpecialRegisters
Definition: ketypes.h:530
GLenum GLclampf GLint i
Definition: glfuncs.h:14
ULONG_PTR KdpCurrentSymbolEnd
Definition: kddata.c:105
KPROCESSOR_STATE ProcessorState
Definition: ketypes.h:579
ULONG_PTR KdpCurrentSymbolStart
Definition: kddata.c:105
#define EFLAGS_TF
Definition: ketypes.h:125
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
PKPRCB KiProcessorBlock[]
Definition: krnlinit.c:32
unsigned int ULONG
Definition: retypes.h:1
ULONG64 KernelDr6
Definition: ketypes.h:504
VOID NTAPI KdpMoveMemory ( IN PVOID  Destination,
IN PVOID  Source,
IN SIZE_T  Length 
)

Definition at line 20 of file kdapi.c.

Referenced by KdpCommandString(), KdpGetContext(), KdpGetContextEx(), KdpPrint(), KdpPrintString(), KdpPrompt(), KdpPromptString(), KdpReport(), KdpReportExceptionStateChange(), KdpSetContext(), KdpSetContextEx(), KdpSymbol(), and KdpSysGetVersion().

23 {
24  PCHAR DestinationBytes, SourceBytes;
25 
26  /* Copy the buffers 1 byte at a time */
27  DestinationBytes = Destination;
28  SourceBytes = Source;
29  while (Length--) *DestinationBytes++ = *SourceBytes++;
30 }
VOID * Source
Definition: acefiex.h:718
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2875
VOID UINTN Length
Definition: acefiex.h:718
signed char * PCHAR
Definition: retypes.h:7
BOOLEAN NTAPI KdpPollBreakInWithPortLock ( VOID  )

Definition at line 35 of file kdlock.c.

Referenced by KdpPrintString().

36 {
37  BOOLEAN DoBreak = FALSE;
38 
39  /* First make sure that KD is enabled */
41  {
42  /* Check if a CTRL-C is in the queue */
44  {
45  /* Set it and prepare for break */
46  DoBreak = TRUE;
48  }
49  else
50  {
51  /* Now get a packet */
53  NULL,
54  NULL,
55  NULL,
57  {
58  /* Successful breakin */
59  DoBreak = TRUE;
60  }
61  }
62  }
63 
64  /* Tell the caller to do a break */
65  return DoBreak;
66 }
#define KdPacketReceived
Definition: kddll.h:5
#define TRUE
Definition: types.h:120
KDP_STATUS NTAPI KdReceivePacket(IN ULONG PacketType, OUT PSTRING MessageHeader, OUT PSTRING MessageData, OUT PULONG DataLength, IN OUT PKD_CONTEXT KdContext)
Definition: kddll.c:80
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:513
BOOLEAN KdDebuggerEnabled
Definition: kdmain.c:16
KD_CONTEXT KdpContext
Definition: kdmain.c:23
unsigned char BOOLEAN
BOOLEAN KdpControlCPending
Definition: windbgkd.h:227
#define PACKET_TYPE_KD_POLL_BREAKIN
Definition: windbgkd.h:49
VOID NTAPI KdpPortLock ( VOID  )

Definition at line 19 of file kdlock.c.

Referenced by KdDisableDebuggerWithLock(), and KdEnableDebuggerWithLock().

20 {
21  /* Acquire the lock */
23 }
KSPIN_LOCK KdpDebuggerLock
Definition: kddata.c:67
VOID FASTCALL KiAcquireSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: ntoskrnl.c:32
VOID NTAPI KdpPortUnlock ( VOID  )

Definition at line 27 of file kdlock.c.

Referenced by KdDisableDebuggerWithLock(), KdEnableDebuggerWithLock(), KdExitDebugger(), and KdPollBreakIn().

28 {
29  /* Release the lock */
31 }
KSPIN_LOCK KdpDebuggerLock
Definition: kddata.c:67
VOID FASTCALL KiReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: ntoskrnl.c:39
NTSTATUS NTAPI KdpPrint ( IN ULONG  ComponentId,
IN ULONG  Level,
IN LPSTR  String,
IN USHORT  Length,
IN KPROCESSOR_MODE  PreviousMode,
IN PKTRAP_FRAME  TrapFrame,
IN PKEXCEPTION_FRAME  ExceptionFrame,
OUT PBOOLEAN  Handled 
)

Definition at line 317 of file kdprint.c.

Referenced by KdpTrap().

325 {
326  NTSTATUS ReturnStatus;
327  BOOLEAN Enable;
328  STRING OutputString;
329  PVOID CapturedString;
330 
331  /* Assume failure */
332  *Handled = FALSE;
333 
334  /* Validate the mask */
335  if (Level < 32) Level = 1 << Level;
336  if (!(Kd_WIN2000_Mask & Level) ||
338  !(*KdComponentTable[ComponentId] & Level)))
339  {
340  /* Mask validation failed */
341  *Handled = TRUE;
342  return STATUS_SUCCESS;
343  }
344 
345  /* Normalize the length */
346  Length = min(Length, 512);
347 
348  /* Check if we need to verify the buffer */
349  if (PreviousMode != KernelMode)
350  {
351  /* Capture user-mode buffers */
352  _SEH2_TRY
353  {
354  /* Probe the string */
356  Length,
357  1);
358 
359  /* Capture it */
360  CapturedString = alloca(Length);
361  KdpMoveMemory(CapturedString,
362  String,
363  Length);
364  String = CapturedString;
365  }
367  {
368  /* Bad pointer, fail the print */
370  }
371  _SEH2_END;
372  }
373 
374  /* Setup the output string */
375  OutputString.Buffer = String;
376  OutputString.Length = Length;
377 
378  /* Log the print */
379  //KdLogDbgPrint(&OutputString);
380 
381  /* Check for a debugger */
383  {
384  /* Fail */
385  *Handled = TRUE;
387  }
388 
389  /* Enter the debugger */
390  Enable = KdEnterDebugger(TrapFrame, ExceptionFrame);
391 
392  /* Print the string */
393  if (KdpPrintString(&OutputString))
394  {
395  /* User pressed CTRL-C, breakpoint on return */
396  ReturnStatus = STATUS_BREAKPOINT;
397  }
398  else
399  {
400  /* String was printed */
401  ReturnStatus = STATUS_SUCCESS;
402  }
403 
404  /* Exit the debugger and return */
405  KdExitDebugger(Enable);
406  *Handled = TRUE;
407  return ReturnStatus;
408 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI KdpPrintString(IN PSTRING Output)
Definition: kdprint.c:20
BOOLEAN Enable
Definition: acefiex.h:245
ULONG KdComponentTableSize
Definition: kddata.c:360
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
VOID NTAPI KdExitDebugger(IN BOOLEAN Enable)
Definition: kdapi.c:1924
#define alloca
Definition: malloc.h:361
CHAR16 * String
Definition: acefiex.h:201
#define FALSE
Definition: types.h:117
#define _SEH2_END
Definition: pseh2_64.h:7
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define STATUS_BREAKPOINT
Definition: ntstatus.h:172
#define STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
unsigned char BOOLEAN
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
_In_ BOOLEAN Handled
Definition: ketypes.h:337
ULONG Kd_WIN2000_Mask
Definition: kdmain.c:24
std::wstring STRING
Definition: fontsub.cpp:33
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID UINTN Length
Definition: acefiex.h:718
LONG NTSTATUS
Definition: DriverTester.h:11
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
#define _SEH2_TRY
Definition: pseh2_64.h:5
#define min(a, b)
Definition: monoChain.cc:55
VOID NTAPI KdpMoveMemory(IN PVOID Destination, IN PVOID Source, IN SIZE_T Length)
Definition: kdapi.c:20
BOOLEAN NTAPI KdEnterDebugger(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
Definition: kdapi.c:1871
PULONG KdComponentTable[104]
Definition: kdmain.c:33
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 const char UINT32 const char const char UINT32 ComponentId
Definition: acpixf.h:1255
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
BOOLEAN KdDebuggerNotPresent
Definition: kdmain.c:18
USHORT NTAPI KdpPrompt ( IN LPSTR  PromptString,
IN USHORT  PromptLength,
OUT LPSTR  ResponseString,
IN USHORT  MaximumResponseLength,
IN KPROCESSOR_MODE  PreviousMode,
IN PKTRAP_FRAME  TrapFrame,
IN PKEXCEPTION_FRAME  ExceptionFrame 
)
VOID NTAPI KdpReportCommandStringStateChange ( IN PSTRING  NameString,
IN PSTRING  CommandString,
IN OUT PCONTEXT  Context 
)

Definition at line 1653 of file kdapi.c.

Referenced by KdpCommandString().

1656 {
1657  STRING Header, Data;
1658  DBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange;
1659  ULONG Length, ActualLength, TotalLength;
1661 
1662  /* Start wait loop */
1663  do
1664  {
1665  /* Build the architecture common parts of the message */
1667  Context,
1668  &WaitStateChange);
1669 
1670  /* Set the context */
1671  KdpSetContextState(&WaitStateChange, Context);
1672 
1673  /* Clear the command string structure */
1674  KdpZeroMemory(&WaitStateChange.u.CommandString,
1675  sizeof(DBGKD_COMMAND_STRING));
1676 
1677  /* Normalize name string to max */
1678  Length = min(128 - 1, NameString->Length);
1679 
1680  /* Copy it to the message buffer */
1681  KdpCopyMemoryChunks((ULONG_PTR)NameString->Buffer,
1683  Length,
1684  0,
1686  &ActualLength);
1687 
1688  /* Null terminate and calculate the total length */
1689  TotalLength = ActualLength;
1690  KdpMessageBuffer[TotalLength++] = ANSI_NULL;
1691 
1692  /* Check if the command string is too long */
1693  Length = CommandString->Length;
1694  if (Length > (PACKET_MAX_SIZE -
1695  sizeof(DBGKD_ANY_WAIT_STATE_CHANGE) - TotalLength))
1696  {
1697  /* Use maximum possible size */
1698  Length = (PACKET_MAX_SIZE -
1699  sizeof(DBGKD_ANY_WAIT_STATE_CHANGE) - TotalLength);
1700  }
1701 
1702  /* Copy it to the message buffer */
1703  KdpCopyMemoryChunks((ULONG_PTR)CommandString->Buffer,
1704  KdpMessageBuffer + TotalLength,
1705  Length,
1706  0,
1708  &ActualLength);
1709 
1710  /* Null terminate and calculate the total length */
1711  TotalLength += ActualLength;
1712  KdpMessageBuffer[TotalLength++] = ANSI_NULL;
1713 
1714  /* Now set up the header and the data */
1715  Header.Length = sizeof(DBGKD_ANY_WAIT_STATE_CHANGE);
1716  Header.Buffer = (PCHAR)&WaitStateChange;
1717  Data.Length = (USHORT)TotalLength;
1718  Data.Buffer = KdpMessageBuffer;
1719 
1720  /* Send State Change packet and wait for a reply */
1722  &Header,
1723  &Data,
1724  Context);
1725  } while (Status == ContinueProcessorReselected);
1726 }
enum _KCONTINUE_STATUS KCONTINUE_STATUS
PVOID ULONG ULONG PULONG Data
Definition: oprghdlr.h:14
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3181 u
_In_ ULONG TotalLength
Definition: usbdlib.h:145
#define PACKET_MAX_SIZE
Definition: windbgkd.h:18
KCONTINUE_STATUS NTAPI KdpSendWaitContinue(IN ULONG PacketType, IN PSTRING SendHeader, IN PSTRING SendData OPTIONAL, IN OUT PCONTEXT Context)
Definition: kdapi.c:1260
CHAR KdpMessageBuffer[0x1000]
Definition: kddata.c:127
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define ANSI_NULL
Definition: Header.h:8
#define DbgKdCommandStringStateChange
Definition: windbgkd.h:61
DBGKD_COMMAND_STRING CommandString
Definition: windbgkd.h:490
VOID NTAPI KdpSetCommonState(IN ULONG NewState, IN PCONTEXT Context, IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange)
Definition: kdapi.c:381
struct _DBGKD_ANY_WAIT_STATE_CHANGE DBGKD_ANY_WAIT_STATE_CHANGE
std::wstring STRING
Definition: fontsub.cpp:33
#define PACKET_TYPE_KD_STATE_CHANGE64
Definition: windbgkd.h:48
VOID UINTN Length
Definition: acefiex.h:718
NTSTATUS NTAPI KdpCopyMemoryChunks(IN ULONG64 Address, IN PVOID Buffer, IN ULONG TotalSize, IN ULONG ChunkSize, IN ULONG Flags, OUT PULONG ActualSize OPTIONAL)
Definition: kdapi.c:46
Status
Definition: gdiplustypes.h:24
unsigned short USHORT
Definition: pedump.c:61
VOID NTAPI KdpSetContextState(IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange, IN PCONTEXT Context)
Definition: kdx64.c:66
#define MMDBG_COPY_UNSAFE
Definition: mm.h:53
#define min(a, b)
Definition: monoChain.cc:55
signed char * PCHAR
Definition: retypes.h:7
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI KdpZeroMemory(IN PVOID Destination, IN SIZE_T Length)
Definition: kdapi.c:34
BOOLEAN NTAPI KdpReportExceptionStateChange ( IN PEXCEPTION_RECORD  ExceptionRecord,
IN OUT PCONTEXT  Context,
IN BOOLEAN  SecondChanceException 
)

Definition at line 1730 of file kdapi.c.

Referenced by KdpReport(), and KdpSwitchProcessor().

1733 {
1734  STRING Header, Data;
1735  DBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange;
1737 
1738  /* Start report loop */
1739  do
1740  {
1741  /* Build the architecture common parts of the message */
1743 
1744 #if !defined(_WIN64)
1745 
1746  /* Convert it and copy it over */
1747  ExceptionRecord32To64((PEXCEPTION_RECORD32)ExceptionRecord,
1748  &WaitStateChange.u.Exception.ExceptionRecord);
1749 
1750 #else
1751 
1752  /* Just copy it directly, no need to convert */
1753  KdpMoveMemory(&WaitStateChange.u.Exception.ExceptionRecord,
1754  ExceptionRecord,
1755  sizeof(EXCEPTION_RECORD));
1756 
1757 #endif
1758 
1759  /* Set the First Chance flag */
1760  WaitStateChange.u.Exception.FirstChance = !SecondChanceException;
1761 
1762  /* Now finish creating the structure */
1763  KdpSetContextState(&WaitStateChange, Context);
1764 
1765  /* Setup the actual header to send to KD */
1766  Header.Length = sizeof(DBGKD_ANY_WAIT_STATE_CHANGE);
1767  Header.Buffer = (PCHAR)&WaitStateChange;
1768 
1769  /* Setup the trace data */
1770  DumpTraceData(&Data);
1771 
1772  /* Send State Change packet and wait for a reply */
1774  &Header,
1775  &Data,
1776  Context);
1777  } while (Status == ContinueProcessorReselected);
1778 
1779  /* Return */
1780  return Status;
1781 }
enum _KCONTINUE_STATUS KCONTINUE_STATUS
VOID NTAPI DumpTraceData(IN PSTRING TraceData)
Definition: kdapi.c:366
PVOID ULONG ULONG PULONG Data
Definition: oprghdlr.h:14
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3181 u
#define DbgKdExceptionStateChange
Definition: windbgkd.h:59
KCONTINUE_STATUS NTAPI KdpSendWaitContinue(IN ULONG PacketType, IN PSTRING SendHeader, IN PSTRING SendData OPTIONAL, IN OUT PCONTEXT Context)
Definition: kdapi.c:1260
Definition: Header.h:8
static __inline VOID NTAPI ExceptionRecord32To64(IN PEXCEPTION_RECORD32 Ex32, OUT PEXCEPTION_RECORD64 Ex64)
Definition: windbgkd.h:897
VOID NTAPI KdpMoveMemory(IN PVOID Destination, IN PVOID Source, IN SIZE_T Length)
Definition: kdapi.c:20
VOID NTAPI KdpSetCommonState(IN ULONG NewState, IN PCONTEXT Context, IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange)
Definition: kdapi.c:381
struct _DBGKD_ANY_WAIT_STATE_CHANGE DBGKD_ANY_WAIT_STATE_CHANGE
std::wstring STRING
Definition: fontsub.cpp:33
EXCEPTION_RECORD64 ExceptionRecord
Definition: windbgkd.h:303
#define PACKET_TYPE_KD_STATE_CHANGE64
Definition: windbgkd.h:48
Status
Definition: gdiplustypes.h:24
VOID NTAPI KdpSetContextState(IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange, IN PCONTEXT Context)
Definition: kdx64.c:66
DBGKM_EXCEPTION64 Exception
Definition: windbgkd.h:488
signed char * PCHAR
Definition: retypes.h:7
VOID NTAPI KdpReportLoadSymbolsStateChange ( IN PSTRING  PathName,
IN PKD_SYMBOLS_INFO  SymbolInfo,
IN BOOLEAN  Unload,
IN OUT PCONTEXT  Context 
)

Definition at line 1581 of file kdapi.c.

Referenced by KdpSymbol().

1585 {
1586  PSTRING ExtraData;
1587  STRING Data, Header;
1588  DBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange;
1589  ULONG PathNameLength;
1591 
1592  /* Start wait loop */
1593  do
1594  {
1595  /* Build the architecture common parts of the message */
1597  Context,
1598  &WaitStateChange);
1599 
1600  /* Now finish creating the structure */
1601  KdpSetContextState(&WaitStateChange, Context);
1602 
1603  /* Fill out load data */
1604  WaitStateChange.u.LoadSymbols.UnloadSymbols = Unload;
1605  WaitStateChange.u.LoadSymbols.BaseOfDll = (ULONG64)(LONG_PTR)SymbolInfo->BaseOfDll;
1606  WaitStateChange.u.LoadSymbols.ProcessId = SymbolInfo->ProcessId;
1607  WaitStateChange.u.LoadSymbols.CheckSum = SymbolInfo->CheckSum;
1608  WaitStateChange.u.LoadSymbols.SizeOfImage = SymbolInfo->SizeOfImage;
1609 
1610  /* Check if we have a path name */
1611  if (PathName)
1612  {
1613  /* Copy it to the path buffer */
1614  KdpCopyMemoryChunks((ULONG_PTR)PathName->Buffer,
1615  KdpPathBuffer,
1616  PathName->Length,
1617  0,
1619  &PathNameLength);
1620 
1621  /* Null terminate */
1622  KdpPathBuffer[PathNameLength++] = ANSI_NULL;
1623 
1624  /* Set the path length */
1625  WaitStateChange.u.LoadSymbols.PathNameLength = PathNameLength;
1626 
1627  /* Set up the data */
1628  Data.Buffer = KdpPathBuffer;
1629  Data.Length = (USHORT)PathNameLength;
1630  ExtraData = &Data;
1631  }
1632  else
1633  {
1634  /* No name */
1635  WaitStateChange.u.LoadSymbols.PathNameLength = 0;
1636  ExtraData = NULL;
1637  }
1638 
1639  /* Setup the header */
1640  Header.Length = sizeof(DBGKD_ANY_WAIT_STATE_CHANGE);
1641  Header.Buffer = (PCHAR)&WaitStateChange;
1642 
1643  /* Send the packet */
1645  &Header,
1646  ExtraData,
1647  Context);
1648  } while (Status == ContinueProcessorReselected);
1649 }
VOID NTAPI Unload(PDRIVER_OBJECT DriverObject)
Definition: csqtest.c:160
enum _KCONTINUE_STATUS KCONTINUE_STATUS
PVOID ULONG ULONG PULONG Data
Definition: oprghdlr.h:14
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3181 u
KCONTINUE_STATUS NTAPI KdpSendWaitContinue(IN ULONG PacketType, IN PSTRING SendHeader, IN PSTRING SendData OPTIONAL, IN OUT PCONTEXT Context)
Definition: kdapi.c:1260
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define ANSI_NULL
CHAR KdpPathBuffer[0x1000]
Definition: kddata.c:128
Definition: Header.h:8
uint64_t ULONG64
Definition: typedefs.h:66
DBGKD_LOAD_SYMBOLS64 LoadSymbols
Definition: windbgkd.h:489
smooth NULL
Definition: ftsmooth.c:513
VOID NTAPI KdpSetCommonState(IN ULONG NewState, IN PCONTEXT Context, IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange)
Definition: kdapi.c:381
#define DbgKdLoadSymbolsStateChange
Definition: windbgkd.h:60
struct _DBGKD_ANY_WAIT_STATE_CHANGE DBGKD_ANY_WAIT_STATE_CHANGE
std::wstring STRING
Definition: fontsub.cpp:33
#define PACKET_TYPE_KD_STATE_CHANGE64
Definition: windbgkd.h:48
NTSTATUS NTAPI KdpCopyMemoryChunks(IN ULONG64 Address, IN PVOID Buffer, IN ULONG TotalSize, IN ULONG ChunkSize, IN ULONG Flags, OUT PULONG ActualSize OPTIONAL)
Definition: kdapi.c:46
Status
Definition: gdiplustypes.h:24
unsigned short USHORT
Definition: pedump.c:61
VOID NTAPI KdpSetContextState(IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange, IN PCONTEXT Context)
Definition: kdx64.c:66
#define MMDBG_COPY_UNSAFE
Definition: mm.h:53
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
signed char * PCHAR
Definition: retypes.h:7
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI KdpRestoreAllBreakpoints ( VOID  )

Definition at line 368 of file kdbreak.c.

Referenced by KdEnableDebuggerWithLock().

369 {
370  ULONG BpIndex;
371 
372  /* No more suspended Breakpoints */
374 
375  /* Loop the breakpoints */
376  for (BpIndex = 0; BpIndex < KD_BREAKPOINT_MAX; BpIndex++)
377  {
378  /* Check if they are valid, suspended breakpoints */
379  if ((KdpBreakpointTable[BpIndex].Flags & KD_BREAKPOINT_ACTIVE) &&
381  {
382  /* Unsuspend them */
383  KdpBreakpointTable[BpIndex].Flags &= ~KD_BREAKPOINT_SUSPENDED;
384  KdpLowRestoreBreakpoint(BpIndex);
385  }
386  }
387 }
#define KD_BREAKPOINT_SUSPENDED
Definition: kd64.h:40
BOOLEAN BreakpointsSuspended
Definition: kddata.c:99
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define FALSE
Definition: types.h:117
ULONG Flags
Definition: kd64.h:48
BOOLEAN NTAPI KdpLowRestoreBreakpoint(IN ULONG BpIndex)
Definition: kdbreak.c:268
#define KD_BREAKPOINT_MAX
Definition: kd64.h:21
BREAKPOINT_ENTRY KdpBreakpointTable[KD_BREAKPOINT_MAX]
Definition: kddata.c:96
unsigned int ULONG
Definition: retypes.h:1
#define KD_BREAKPOINT_ACTIVE
Definition: kd64.h:38
VOID NTAPI KdpSetContextState ( IN PDBGKD_ANY_WAIT_STATE_CHANGE  WaitStateChange,
IN PCONTEXT  Context 
)

Definition at line 66 of file kdx64.c.

Referenced by KdpReportCommandStringStateChange(), KdpReportExceptionStateChange(), and KdpReportLoadSymbolsStateChange().

68 {
69  PKPRCB Prcb = KeGetCurrentPrcb();
70 
71  /* Copy i386 specific debug registers */
72  WaitStateChange->ControlReport.Dr6 = Prcb->ProcessorState.SpecialRegisters.
73  KernelDr6;
74  WaitStateChange->ControlReport.Dr7 = Prcb->ProcessorState.SpecialRegisters.
75  KernelDr7;
76 
77  /* Copy i386 specific segments */
78  WaitStateChange->ControlReport.SegCs = (USHORT)Context->SegCs;
79  WaitStateChange->ControlReport.SegDs = (USHORT)Context->SegDs;
80  WaitStateChange->ControlReport.SegEs = (USHORT)Context->SegEs;
81  WaitStateChange->ControlReport.SegFs = (USHORT)Context->SegFs;
82 
83  /* Copy EFlags */
84  WaitStateChange->ControlReport.EFlags = Context->EFlags;
85 
86  /* Set Report Flags */
87  WaitStateChange->ControlReport.ReportFlags = REPORT_INCLUDES_SEGS;
88  if (WaitStateChange->ControlReport.SegCs == KGDT64_R0_CODE)
89  {
90  WaitStateChange->ControlReport.ReportFlags |= REPORT_STANDARD_CS;
91  }
92 }
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1054
KSPECIAL_REGISTERS SpecialRegisters
Definition: ketypes.h:530
#define REPORT_STANDARD_CS
Definition: windbgkd.h:148
#define KGDT64_R0_CODE
Definition: ketypes.h:72
KPROCESSOR_STATE ProcessorState
Definition: ketypes.h:579
#define REPORT_INCLUDES_SEGS
Definition: windbgkd.h:147
unsigned short USHORT
Definition: pedump.c:61
BOOLEAN NTAPI KdpStub ( IN PKTRAP_FRAME  TrapFrame,
IN PKEXCEPTION_FRAME  ExceptionFrame,
IN PEXCEPTION_RECORD  ExceptionRecord,
IN PCONTEXT  ContextRecord,
IN KPROCESSOR_MODE  PreviousMode,
IN BOOLEAN  SecondChanceException 
)

Definition at line 271 of file kdtrap.c.

Referenced by KdDisableDebuggerWithLock(), and KdInitSystem().

277 {
278  ULONG_PTR ExceptionCommand;
279 
280  /* Check if this was a breakpoint due to DbgPrint or Load/UnloadSymbols */
281  ExceptionCommand = ExceptionRecord->ExceptionInformation[0];
282  if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
283  (ExceptionRecord->NumberParameters > 0) &&
284  ((ExceptionCommand == BREAKPOINT_LOAD_SYMBOLS) ||
285  (ExceptionCommand == BREAKPOINT_UNLOAD_SYMBOLS) ||
286  (ExceptionCommand == BREAKPOINT_COMMAND_STRING) ||
287  (ExceptionCommand == BREAKPOINT_PRINT)))
288  {
289  /* This we can handle: simply bump the Program Counter */
292  return TRUE;
293  }
294  else if (KdPitchDebugger)
295  {
296  /* There's no debugger, fail. */
297  return FALSE;
298  }
299  else if ((KdAutoEnableOnEvent) &&
301  !(KdDebuggerEnabled) &&
304  {
305  /* Debugging was Auto-Enabled. We can now send this to KD. */
306  return KdpTrap(TrapFrame,
307  ExceptionFrame,
308  ExceptionRecord,
310  PreviousMode,
311  SecondChanceException);
312  }
313  else
314  {
315  /* FIXME: All we can do in this case is trace this exception */
316  return FALSE;
317  }
318 }
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI KdpTrap(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT ContextRecord, IN KPROCESSOR_MODE PreviousMode, IN BOOLEAN SecondChanceException)
Definition: kdtrap.c:135
BOOLEAN KdAutoEnableOnEvent
Definition: kddata.c:84
BOOLEAN KdPreviouslyEnabled
Definition: kddata.c:87
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define FALSE
Definition: types.h:117
#define BREAKPOINT_UNLOAD_SYMBOLS
Definition: kdtypes.h:54
#define STATUS_BREAKPOINT
Definition: ntstatus.h:172
BOOLEAN KdDebuggerEnabled
Definition: kdmain.c:16
#define KeGetContextPc(Context)
Definition: ke.h:100
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
NTSTATUS NTAPI KdEnableDebugger(VOID)
Definition: kdmain.c:312
_IRQL_requires_same_ _In_ PVOID _Inout_ struct _CONTEXT * ContextRecord
Definition: ntbasedef.h:653
#define BREAKPOINT_PRINT
Definition: kdtypes.h:51
BOOLEAN KdPitchDebugger
Definition: kdmain.c:21
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
#define BREAKPOINT_LOAD_SYMBOLS
Definition: kdtypes.h:53
#define BREAKPOINT_COMMAND_STRING
Definition: kdtypes.h:55
#define KD_BREAKPOINT_SIZE
Definition: ke.h:94
#define KeSetContextPc(Context, ProgramCounter)
Definition: ke.h:103
VOID NTAPI KdpSuspendAllBreakPoints ( VOID  )

Definition at line 407 of file kdbreak.c.

Referenced by KdDisableDebuggerWithLock().

408 {
409  ULONG BpEntry;
410 
411  /* Breakpoints are suspended */
413 
414  /* Loop every breakpoint */
415  for (BpEntry = 1; BpEntry <= KD_BREAKPOINT_MAX; BpEntry++)
416  {
417  /* Suspend it */
418  KdpSuspendBreakPoint(BpEntry);
419  }
420 }
#define TRUE
Definition: types.h:120
BOOLEAN BreakpointsSuspended
Definition: kddata.c:99
#define KD_BREAKPOINT_MAX
Definition: kd64.h:21
VOID NTAPI KdpSuspendBreakPoint(IN ULONG BpEntry)
Definition: kdbreak.c:391
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI KdpSuspendBreakPoint ( IN ULONG  BpEntry)

Definition at line 391 of file kdbreak.c.

Referenced by KdpSuspendAllBreakPoints().

392 {
393  ULONG BpIndex = BpEntry - 1;
394 
395  /* Check if this is a valid, unsuspended breakpoint */
396  if ((KdpBreakpointTable[BpIndex].Flags & KD_BREAKPOINT_ACTIVE) &&
398  {
399  /* Suspend it */
401  KdpLowWriteContent(BpIndex);
402  }
403 }
#define KD_BREAKPOINT_SUSPENDED
Definition: kd64.h:40
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
BOOLEAN NTAPI KdpLowWriteContent(IN ULONG BpIndex)
Definition: kdbreak.c:226
ULONG Flags
Definition: kd64.h:48
BREAKPOINT_ENTRY KdpBreakpointTable[KD_BREAKPOINT_MAX]
Definition: kddata.c:96
unsigned int ULONG
Definition: retypes.h:1
#define KD_BREAKPOINT_ACTIVE
Definition: kd64.h:38
BOOLEAN NTAPI KdpSwitchProcessor ( IN PEXCEPTION_RECORD  ExceptionRecord,
IN OUT PCONTEXT  ContextRecord,
IN BOOLEAN  SecondChanceException 
)

Definition at line 1833 of file kdapi.c.

Referenced by KdInitSystem().

1836 {
1837  BOOLEAN Status;
1838 
1839  /* Save the port data */
1840  KdSave(FALSE);
1841 
1842  /* Report a state change */
1843  Status = KdpReportExceptionStateChange(ExceptionRecord,
1844  ContextRecord,
1845  SecondChanceException);
1846 
1847  /* Restore the port data and return */
1848  KdRestore(FALSE);
1849  return Status;
1850 }
NTSTATUS NTAPI KdRestore(IN BOOLEAN SleepTransition)
Definition: kdcom.c:110
BOOLEAN NTAPI KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord, IN OUT PCONTEXT Context, IN BOOLEAN SecondChanceException)
Definition: kdapi.c:1730
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
_IRQL_requires_same_ _In_ PVOID _Inout_ struct _CONTEXT * ContextRecord
Definition: ntbasedef.h:653
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI KdSave(IN BOOLEAN SleepTransition)
Definition: kdcom.c:102
VOID NTAPI KdpSymbol ( IN PSTRING  DllPath,
IN PKD_SYMBOLS_INFO  SymbolInfo,
IN BOOLEAN  Unload,
IN KPROCESSOR_MODE  PreviousMode,
IN PCONTEXT  ContextRecord,
IN PKTRAP_FRAME  TrapFrame,
IN PKEXCEPTION_FRAME  ExceptionFrame 
)

Definition at line 172 of file kdprint.c.

Referenced by KdpTrap().

179 {
180  BOOLEAN Enable;
181  PKPRCB Prcb = KeGetCurrentPrcb();
182 
183  /* Check if we need to do anything */
184  if ((PreviousMode != KernelMode) || (KdDebuggerNotPresent)) return;
185 
186  /* Enter the debugger */
187  Enable = KdEnterDebugger(TrapFrame, ExceptionFrame);
188 
189  /* Save the CPU Control State and save the context */
193  sizeof(CONTEXT));
194 
195  /* Report the new state */
197  SymbolInfo,
198  Unload,
200 
201  /* Restore the processor state */
204  sizeof(CONTEXT));
206 
207  /* Exit the debugger and return */
208  KdExitDebugger(Enable);
209 }
BOOLEAN Enable
Definition: acefiex.h:245
VOID NTAPI Unload(PDRIVER_OBJECT DriverObject)
Definition: csqtest.c:160
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1054
VOID NTAPI KdExitDebugger(IN BOOLEAN Enable)
Definition: kdapi.c:1924
CONTEXT ContextFrame
Definition: ketypes.h:531
VOID NTAPI KiRestoreProcessorControlState(IN PKPROCESSOR_STATE ProcessorState)
unsigned char BOOLEAN
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
VOID NTAPI KdpReportLoadSymbolsStateChange(IN PSTRING PathName, IN PKD_SYMBOLS_INFO SymbolInfo, IN BOOLEAN Unload, IN OUT PCONTEXT Context)
Definition: kdapi.c:1581
KPROCESSOR_STATE ProcessorState
Definition: ketypes.h:579
_IRQL_requires_same_ _In_ PVOID _Inout_ struct _CONTEXT * ContextRecord
Definition: ntbasedef.h:653
VOID NTAPI KiSaveProcessorControlState(OUT PKPROCESSOR_STATE ProcessorState)
Definition: cpu.c:382
static const char const char * DllPath
Definition: image.c:34
VOID NTAPI KdpMoveMemory(IN PVOID Destination, IN PVOID Source, IN SIZE_T Length)
Definition: kdapi.c:20
BOOLEAN NTAPI KdEnterDebugger(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
Definition: kdapi.c:1871
BOOLEAN KdDebuggerNotPresent
Definition: kdmain.c:18
NTSTATUS NTAPI KdpSysCheckLowMemory ( IN ULONG  Flags)

Definition at line 356 of file kdx64.c.

Referenced by KdpCheckLowMemory().

357 {
359  return STATUS_UNSUCCESSFUL;
360 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:226
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
VOID NTAPI KdpSysGetVersion ( IN PDBGKD_GET_VERSION64  Version)

Definition at line 428 of file kdapi.c.

Referenced by KdpGetVersion().

429 {
430  /* Copy the version block */
433  sizeof(DBGKD_GET_VERSION64));
434 }
DBGKD_GET_VERSION64 KdVersionBlock
Definition: kddata.c:371
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
VOID NTAPI KdpMoveMemory(IN PVOID Destination, IN PVOID Source, IN SIZE_T Length)
Definition: kdapi.c:20
NTSTATUS NTAPI KdpSysReadBusData ( IN ULONG  BusDataType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN ULONG  Offset,
IN PVOID  Buffer,
IN ULONG  Length,
OUT PULONG  ActualLength 
)

Definition at line 134 of file kdx64.c.

Referenced by KdpGetBusData().

141 {
143  return STATUS_UNSUCCESSFUL;
144 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:226
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS NTAPI KdpSysReadControlSpace ( IN ULONG  Processor,
IN ULONG64  BaseAddress,
IN PVOID  Buffer,
IN ULONG  Length,
OUT PULONG  ActualLength 
)

Definition at line 162 of file kdx64.c.

Referenced by KdpReadControlSpace().

167 {
168  PVOID ControlStart;
170  PKIPCR Pcr = CONTAINING_RECORD(Prcb, KIPCR, Prcb);
171 
172  switch (BaseAddress)
173  {
175  /* Copy a pointer to the Pcr */
176  ControlStart = &Pcr;
177  *ActualLength = sizeof(PVOID);
178  break;
179 
181  /* Copy a pointer to the Prcb */
182  ControlStart = &Prcb;
183  *ActualLength = sizeof(PVOID);
184  break;
185 
187  /* Copy SpecialRegisters */
188  ControlStart = &Prcb->ProcessorState.SpecialRegisters;
189  *ActualLength = sizeof(KSPECIAL_REGISTERS);
190  break;
191 
193  /* Copy a pointer to the current Thread */
194  ControlStart = &Prcb->CurrentThread;
195  *ActualLength = sizeof(PVOID);
196  break;
197 
198  default:
199  *ActualLength = 0;
200  ASSERT(FALSE);
201  return STATUS_UNSUCCESSFUL;
202  }
203 
204  /* Copy the memory */
205  RtlCopyMemory(Buffer, ControlStart, min(Length, *ActualLength));
206 
207  /* Finish up */
208  return STATUS_SUCCESS;
209 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define AMD64_DEBUG_CONTROL_SPACE_KPCR
Definition: windbgkd.h:203
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
_In_ UCHAR Processor
Definition: kefuncs.h:695
KSPECIAL_REGISTERS SpecialRegisters
Definition: ketypes.h:530
#define AMD64_DEBUG_CONTROL_SPACE_KTHREAD
Definition: windbgkd.h:206
#define FALSE
Definition: types.h:117
struct _KTHREAD * CurrentThread
Definition: ketypes.h:566
Definition: bufpool.h:45
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
KPROCESSOR_STATE ProcessorState
Definition: ketypes.h:579
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
VOID UINTN Length
Definition: acefiex.h:718
struct _KSPECIAL_REGISTERS KSPECIAL_REGISTERS
PKPRCB KiProcessorBlock[]
Definition: krnlinit.c:32
#define min(a, b)
Definition: monoChain.cc:55
#define AMD64_DEBUG_CONTROL_SPACE_KSPECIAL
Definition: windbgkd.h:205
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define AMD64_DEBUG_CONTROL_SPACE_KPRCB
Definition: windbgkd.h:204
NTSTATUS NTAPI KdpSysReadIoSpace ( IN ULONG  InterfaceType,
IN ULONG  BusNumber,
IN ULONG  AddressSpace,
IN ULONG64  IoAddress,
IN PVOID  DataValue,
IN ULONG  DataSize,
OUT PULONG  ActualDataSize 
)

Definition at line 108 of file kdarm.c.

Referenced by KdpReadIoSpace(), and KdpReadIoSpaceExtended().

115 {
117  return STATUS_UNSUCCESSFUL;
118 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:226
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS NTAPI KdpSysReadMsr ( IN ULONG  Msr,
OUT PLARGE_INTEGER  MsrValue 
)

Definition at line 96 of file kdx64.c.

Referenced by KdpReadMachineSpecificRegister().

98 {
99  /* Use SEH to protect from invalid MSRs */
100  _SEH2_TRY
101  {
102  MsrValue->QuadPart = __readmsr(Msr);
103  }
105  {
107  }
108  _SEH2_END;
109 
110  return STATUS_SUCCESS;
111 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
#define _SEH2_END
Definition: pseh2_64.h:7
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
PPC_QUAL unsigned long long __readmsr()
Definition: intrin_ppc.h:741
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define _SEH2_TRY
Definition: pseh2_64.h:5
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
NTSTATUS NTAPI KdpSysWriteBusData ( IN ULONG  BusDataType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN ULONG  Offset,
IN PVOID  Buffer,
IN ULONG  Length,
OUT PULONG  ActualLength 
)

Definition at line 148 of file kdx64.c.

Referenced by KdpSetBusData().

155 {
157  return STATUS_UNSUCCESSFUL;
158 }
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:226
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS NTAPI KdpSysWriteControlSpace ( IN ULONG  Processor,
IN ULONG64  BaseAddress,
IN PVOID  Buffer,
IN ULONG  Length,
OUT PULONG  ActualLength 
)

Definition at line 213 of file kdx64.c.

Referenced by KdpWriteControlSpace().

218 {
219  PVOID ControlStart;
221 
222  switch (BaseAddress)
223  {
225  /* Copy SpecialRegisters */
226  ControlStart = &Prcb->ProcessorState.SpecialRegisters;
227  *ActualLength = sizeof(KSPECIAL_REGISTERS);
228  break;
229 
230  default:
231  *ActualLength = 0;
232  ASSERT(FALSE);
233  return STATUS_UNSUCCESSFUL;
234  }
235 
236  /* Copy the memory */
237  RtlCopyMemory(ControlStart, Buffer, min(Length, *ActualLength));
238 
239  return STATUS_SUCCESS;
240 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
_In_ UCHAR Processor
Definition: kefuncs.h:695
KSPECIAL_REGISTERS SpecialRegisters
Definition: ketypes.h:530
#define FALSE
Definition: types.h:117
Definition: bufpool.h:45
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
KPROCESSOR_STATE ProcessorState
Definition: ketypes.h:579
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
VOID UINTN Length
Definition: acefiex.h:718
struct _KSPECIAL_REGISTERS KSPECIAL_REGISTERS
PKPRCB KiProcessorBlock[]
Definition: krnlinit.c:32
#define min(a, b)
Definition: monoChain.cc:55
#define AMD64_DEBUG_CONTROL_SPACE_KSPECIAL
Definition: windbgkd.h:205
NTSTATUS NTAPI KdpSysWriteIoSpace ( IN ULONG  InterfaceType,
IN ULONG  BusNumber,
IN ULONG  AddressSpace,
IN ULONG64  IoAddress,
IN PVOID  DataValue,
IN ULONG  DataSize,
OUT PULONG  ActualDataSize 
)

Definition at line 300 of file kdx64.c.

Referenced by KdpWriteIoSpace(), and KdpWriteIoSpaceExtended().

307 {
308  /* Verify parameters */
309  if (InterfaceType != Isa || BusNumber != 0 || AddressSpace != 1)
310  {
311  /* No data was written */
312  *ActualDataSize = 0;
314  }
315 
316  /* Check for correct alignment */
317  if ((IoAddress & (DataSize - 1)))
318  {
319  /* Invalid alignment */
320  *ActualDataSize = 0;
322  }
323 
324  switch (DataSize)
325  {
326  case sizeof(UCHAR):
327  /* Write one UCHAR */
328  WRITE_PORT_UCHAR((PUCHAR)IoAddress, *(PUCHAR)DataValue);
329  break;
330 
331  case sizeof(USHORT):
332  /* Write one USHORT */
333  WRITE_PORT_USHORT((PUSHORT)IoAddress, *(PUSHORT)DataValue);
334  break;
335 
336  case sizeof(ULONG):
337  /* Write one ULONG */
338  WRITE_PORT_ULONG((PULONG)IoAddress, *(PULONG)DataValue);
339  break;
340 
341  default:
342  /* Invalid data size */
343  *ActualDataSize = 0;
345  }
346 
347  /* Return the size of the data */
348  *ActualDataSize = DataSize;
349 
350  /* Success! */
351  return STATUS_SUCCESS;
352 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
VOID NTAPI WRITE_PORT_USHORT(IN PUSHORT Port, IN USHORT Value)
Definition: portio.c:115
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2268
unsigned char * PUCHAR
Definition: retypes.h:3
VOID NTAPI WRITE_PORT_ULONG(IN PULONG Port, IN ULONG Value)
Definition: portio.c:123
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
ACPI_EFI_GUID ACPI_EFI_INTERFACE_TYPE InterfaceType
Definition: acefiex.h:577
unsigned short * PUSHORT
Definition: retypes.h:2
unsigned char UCHAR
Definition: xmlstorage.h:181
UINT64 UINTN DataSize
Definition: acefiex.h:494
unsigned short USHORT
Definition: pedump.c:61
unsigned int * PULONG
Definition: retypes.h:1
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:171
unsigned int ULONG
Definition: retypes.h:1
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:539
NTSTATUS NTAPI KdpSysWriteMsr ( IN ULONG  Msr,
IN PLARGE_INTEGER  MsrValue 
)

Definition at line 115 of file kdx64.c.

Referenced by KdpWriteMachineSpecificRegister().

117 {
118  /* Use SEH to protect from invalid MSRs */
119  _SEH2_TRY
120  {
121  __writemsr(Msr, MsrValue->QuadPart);
122  }
124  {
126  }
127  _SEH2_END;
128 
129  return STATUS_SUCCESS;
130 }
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
#define _SEH2_END
Definition: pseh2_64.h:7
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
PPC_QUAL void __writemsr(const unsigned long Value)
Definition: intrin_ppc.h:748
#define _SEH2_TRY
Definition: pseh2_64.h:5
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
VOID NTAPI KdpTimeSlipDpcRoutine ( IN PKDPC  Dpc,
IN PVOID  DeferredContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 1785 of file kdapi.c.

Referenced by KdInitSystem().

1789 {
1790  LONG OldSlip, NewSlip, PendingSlip;
1791 
1792  /* Get the current pending slip */
1793  PendingSlip = KdpTimeSlipPending;
1794  do
1795  {
1796  /* Save the old value and either disable or enable it now. */
1797  OldSlip = PendingSlip;
1798  NewSlip = OldSlip > 1 ? 1 : 0;
1799 
1800  /* Try to change the value */
1802  NewSlip,
1803  OldSlip) != OldSlip);
1804 
1805  /* If the New Slip value is 1, then do the Time Slipping */
1807 }
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:716
#define InterlockedCompareExchange
Definition: interlocked.h:104
LONG KdpTimeSlipPending
Definition: kddata.c:119
long LONG
Definition: pedump.c:60
WORK_QUEUE_ITEM KdpTimeSlipWorkItem
Definition: kddata.c:118
VOID NTAPI KdpTimeSlipWork ( IN PVOID  Context)

Definition at line 1811 of file kdapi.c.

Referenced by KdInitSystem().

1812 {
1813  KIRQL OldIrql;
1815 
1816  /* Update the System time from the CMOS */
1820 
1821  /* Check if we have a registered Time Slip Event and signal it */
1825 
1826  /* Delay the DPC until it runs next time */
1827  DueTime.QuadPart = -1800000000;
1829 }
VOID NTAPI ExReleaseTimeRefreshLock(VOID)
Definition: time.c:83
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
_In_ LARGE_INTEGER DueTime
Definition: kefuncs.h:524
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
BOOLEAN NTAPI ExAcquireTimeRefreshLock(IN BOOLEAN Wait)
Definition: time.c:51
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
VOID NTAPI ExUpdateSystemTimeFromCmos(IN BOOLEAN UpdateInterruptTime, IN ULONG MaxSepInSeconds)
Definition: time.c:217
KDPC KdpTimeSlipDpc
Definition: kddata.c:116
PKEVENT KdpTimeSlipEvent
Definition: kddata.c:120
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
KSPIN_LOCK KdpTimeSlipEventLock
Definition: kddata.c:121
KTIMER KdpTimeSlipTimer
Definition: kddata.c:117
LONGLONG QuadPart
Definition: typedefs.h:113
BOOLEAN NTAPI KdpTrap ( IN PKTRAP_FRAME  TrapFrame,
IN PKEXCEPTION_FRAME  ExceptionFrame,
IN PEXCEPTION_RECORD  ExceptionRecord,
IN PCONTEXT  ContextRecord,
IN KPROCESSOR_MODE  PreviousMode,
IN BOOLEAN  SecondChanceException 
)

Definition at line 135 of file kdtrap.c.

Referenced by KdInitSystem(), and KdpStub().

141 {
142  BOOLEAN Unload;
143  ULONG_PTR ProgramCounter;
145  NTSTATUS ReturnStatus;
147 
148  /*
149  * Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or
150  * Load/Unload symbols. Make sure it isn't a software breakpoints as those
151  * are handled by KdpReport.
152  */
153  if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) &&
154  (ExceptionRecord->ExceptionInformation[0] != BREAKPOINT_BREAK))
155  {
156  /* Save Program Counter */
157  ProgramCounter = KeGetContextPc(ContextRecord);
158 
159  /* Check what kind of operation was requested from us */
160  Unload = FALSE;
161  switch (ExceptionRecord->ExceptionInformation[0])
162  {
163  /* DbgPrint */
164  case BREAKPOINT_PRINT:
165 
166  /* Call the worker routine */
167  ReturnStatus = KdpPrint((ULONG)KdpGetParameterThree(ContextRecord),
168  (ULONG)KdpGetParameterFour(ContextRecord),
169  (LPSTR)ExceptionRecord->ExceptionInformation[1],
170  (USHORT)ExceptionRecord->ExceptionInformation[2],
171  PreviousMode,
172  TrapFrame,
173  ExceptionFrame,
174  &Handled);
175 
176  /* Update the return value for the caller */
178  ReturnStatus);
179  break;
180 
181  /* DbgPrompt */
182  case BREAKPOINT_PROMPT:
183 
184  /* Call the worker routine */
185  ReturnLength = KdpPrompt((LPSTR)ExceptionRecord->ExceptionInformation[1],
186  (USHORT)ExceptionRecord->ExceptionInformation[2],
187  (LPSTR)KdpGetParameterThree(ContextRecord),
188  (USHORT)KdpGetParameterFour(ContextRecord),
189  PreviousMode,
190  TrapFrame,
191  ExceptionFrame);
192  Handled = TRUE;
193 
194  /* Update the return value for the caller */
196  break;
197 
198  /* DbgUnLoadImageSymbols */
200 
201  /* Drop into the load case below, with the unload parameter */
202  Unload = TRUE;
203 
204  /* DbgLoadImageSymbols */
206 
207  /* Call the worker routine */
208  KdpSymbol((PSTRING)ExceptionRecord->
209  ExceptionInformation[1],
210  (PKD_SYMBOLS_INFO)ExceptionRecord->
211  ExceptionInformation[2],
212  Unload,
213  PreviousMode,
215  TrapFrame,
216  ExceptionFrame);
217  Handled = TRUE;
218  break;
219 
220  /* DbgCommandString */
222 
223  /* Call the worker routine */
224  KdpCommandString((PSTRING)ExceptionRecord->
225  ExceptionInformation[1],
226  (PSTRING)ExceptionRecord->
227  ExceptionInformation[2],
228  PreviousMode,
230  TrapFrame,
231  ExceptionFrame);
232  Handled = TRUE;
233  break;
234 
235  /* Anything else, do nothing */
236  default:
237 
238  /* Invalid debug service! Don't handle this! */
239  Handled = FALSE;
240  break;
241  }
242 
243  /*
244  * If the PC was not updated, we'll increment it ourselves so execution
245  * continues past the breakpoint.
246  */
247  if (ProgramCounter == KeGetContextPc(ContextRecord))
248  {
249  /* Update it */
251  ProgramCounter + KD_BREAKPOINT_SIZE);
252  }
253  }
254  else
255  {
256  /* Call the worker routine */
257  Handled = KdpReport(TrapFrame,
258  ExceptionFrame,
259  ExceptionRecord,
261  PreviousMode,
262  SecondChanceException);
263  }
264 
265  /* Return TRUE or FALSE to caller */
266  return Handled;
267 }
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
#define TRUE
Definition: types.h:120
VOID NTAPI Unload(PDRIVER_OBJECT DriverObject)
Definition: csqtest.c:160
#define KeSetContextReturnRegister(Context, ReturnValue)
Definition: ke.h:115
USHORT NTAPI KdpPrompt(IN LPSTR PromptString, IN USHORT PromptLength, OUT LPSTR ResponseString, IN USHORT MaximumResponseLength, IN KPROCESSOR_MODE PreviousMode, IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
char * LPSTR
Definition: xmlstorage.h:182
BOOLEAN NTAPI KdpReport(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN PEXCEPTION_RECORD ExceptionRecord, IN PCONTEXT ContextRecord, IN KPROCESSOR_MODE PreviousMode, IN BOOLEAN SecondChanceException)
Definition: kdtrap.c:52
uint32_t ULONG_PTR
Definition: typedefs.h:64
VOID NTAPI KdpCommandString(IN PSTRING NameString, IN PSTRING CommandString, IN KPROCESSOR_MODE PreviousMode, IN PCONTEXT ContextRecord, IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
Definition: kdprint.c:133
#define FALSE
Definition: types.h:117
#define BREAKPOINT_UNLOAD_SYMBOLS
Definition: kdtypes.h:54
#define STATUS_BREAKPOINT
Definition: ntstatus.h:172
#define KeGetContextPc(Context)
Definition: ke.h:100
#define BREAKPOINT_PROMPT
Definition: kdtypes.h:52
unsigned char BOOLEAN
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
VOID NTAPI KdpSymbol(IN PSTRING DllPath, IN PKD_SYMBOLS_INFO SymbolInfo, IN BOOLEAN Unload, IN KPROCESSOR_MODE PreviousMode, IN PCONTEXT ContextRecord, IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
Definition: kdprint.c:172
_In_ BOOLEAN Handled
Definition: ketypes.h:337
_IRQL_requires_same_ _In_ PVOID _Inout_ struct _CONTEXT * ContextRecord
Definition: ntbasedef.h:653
#define BREAKPOINT_PRINT
Definition: kdtypes.h:51
LONG NTSTATUS
Definition: DriverTester.h:11
unsigned short USHORT
Definition: pedump.c:61
#define BREAKPOINT_LOAD_SYMBOLS
Definition: kdtypes.h:53
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI KdpPrint(IN ULONG ComponentId, IN ULONG Level, IN LPSTR String, IN USHORT Length, IN KPROCESSOR_MODE PreviousMode, IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, OUT PBOOLEAN Handled)
Definition: kdprint.c:317
#define BREAKPOINT_COMMAND_STRING
Definition: kdtypes.h:55
#define KD_BREAKPOINT_SIZE
Definition: ke.h:94
#define KeSetContextPc(Context, ProgramCounter)
Definition: ke.h:103
#define BREAKPOINT_BREAK
Definition: kdtypes.h:50
VOID NTAPI KdpZeroMemory ( IN PVOID  Destination,
IN SIZE_T  Length 
)

Definition at line 34 of file kdapi.c.

Referenced by KdpReportCommandStringStateChange(), and KdpSetCommonState().

36 {
37  PCHAR DestinationBytes;
38 
39  /* Zero the buffer 1 byte at a time */
40  DestinationBytes = Destination;
41  while (Length--) *DestinationBytes++ = 0;
42 }
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2875
VOID UINTN Length
Definition: acefiex.h:718
signed char * PCHAR
Definition: retypes.h:7
VOID NTAPI KdSetOwedBreakpoints ( VOID  )

Definition at line 105 of file kdbreak.c.

Referenced by KiTrap0EHandler().

106 {
107  BOOLEAN Enable;
108  KD_BREAKPOINT_TYPE Content;
109  ULONG i;
111 
112  /* If we don't owe any breakpoints, just return */
113  if (!KdpOweBreakpoint) return;
114 
115  /* Enter the debugger */
116  Enable = KdEnterDebugger(NULL, NULL);
117 
118  /*
119  * Suppose we succeed in setting all the breakpoints.
120  * If we fail to do so, the flag will be set again.
121  */
123 
124  /* Loop through current breakpoints and try to set or delete the pending ones */
125  for (i = 0; i < KD_BREAKPOINT_MAX; i++)
126  {
128  {
129  /*
130  * Set the breakpoint only if it is in kernel space, or if it is
131  * in user space and the active process context matches.
132  */
134  KdpBreakpointTable[i].DirectoryTableBase != KeGetCurrentThread()->ApcState.Process->DirectoryTableBase[0])
135  {
137  continue;
138  }
139 
140  /* Try to save the old instruction */
142  &Content,
144  0,
146  NULL);
147  if (!NT_SUCCESS(Status))
148  {
149  /* Memory is still inaccessible, breakpoint setting will be deferred again */
150  // KdpDprintf("Failed to set deferred breakpoint at address 0x%p\n",
151  // KdpBreakpointTable[i].Address);
153  continue;
154  }
155 
156  /* Check if we need to write the breakpoint */
158  {
159  /* Memory accessible, set the breakpoint */
160  KdpBreakpointTable[i].Content = Content;
161 
162  /* Write the breakpoint */
166  0,
168  NULL);
169  if (!NT_SUCCESS(Status))
170  {
171  /* This should never happen */
172  KdpDprintf("Unable to write deferred breakpoint to address 0x%p\n",
175  }
176  else
177  {
179  }
180 
181  continue;
182  }
183 
184  /* Check if we need to restore the original instruction */
186  {
187  /* Write it back */
189  &KdpBreakpointTable[i].Content,
191  0,
193  NULL);
194  if (!NT_SUCCESS(Status))
195  {
196  /* This should never happen */
197  KdpDprintf("Unable to delete deferred breakpoint at address 0x%p\n",
200  }
201  else
202  {
203  /* Check if the breakpoint is suspended */
205  {
206  KdpBreakpointTable[i].Flags = KD_BREAKPOINT_SUSPENDED | KD_BREAKPOINT_ACTIVE;
207  }
208  else
209  {
210  /* Invalidate it */
212  }
213  }
214 
215  continue;
216  }
217  }
218  }
219 
220  /* Exit the debugger */
221  KdExitDebugger(Enable);
222 }
#define TRUE
Definition: types.h:120
PVOID ULONG Address
Definition: oprghdlr.h:14
BOOLEAN Enable
Definition: acefiex.h:245
#define KD_BREAKPOINT_SUSPENDED
Definition: kd64.h:40
VOID NTAPI KdExitDebugger(IN BOOLEAN Enable)
Definition: kdapi.c:1924
uint32_t ULONG_PTR
Definition: typedefs.h:64
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
BOOLEAN KdpOweBreakpoint
Definition: kddata.c:98
smooth NULL
Definition: ftsmooth.c:513
#define MMDBG_COPY_WRITE
Definition: mm.h:51
ULONG Flags
Definition: kd64.h:48
#define KD_BREAKPOINT_PENDING
Definition: kd64.h:39
unsigned char BOOLEAN
#define KD_HIGHEST_USER_BREAKPOINT_ADDRESS
Definition: kd64.h:33
KD_BREAKPOINT_TYPE Content
Definition: kd64.h:51
KD_BREAKPOINT_TYPE KdpBreakpointInstruction
Definition: kddata.c:97
#define KD_BREAKPOINT_MAX
Definition: kd64.h:21
Status
Definition: gdiplustypes.h:24
#define KD_BREAKPOINT_TYPE
Definition: ke.h:93
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
#define MMDBG_COPY_UNSAFE
Definition: mm.h:53
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1415
BREAKPOINT_ENTRY KdpBreakpointTable[KD_BREAKPOINT_MAX]
Definition: kddata.c:96
#define KdpDprintf
Definition: mmdbg.c:19
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN NTAPI KdEnterDebugger(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
Definition: kdapi.c:1871
#define KD_BREAKPOINT_SIZE
Definition: ke.h:94
#define KeGetCurrentThread
Definition: hal.h:44
#define KD_BREAKPOINT_EXPIRED
Definition: kd64.h:41
NTSTATUS NTAPI KdpCopyMemoryChunks(IN ULONG64 Address, IN PVOID Buffer, IN ULONG TotalSize, IN ULONG ChunkSize, IN ULONG Flags, OUT PULONG ActualSize OPTIONAL)
Definition: kdapi.c:46
#define KD_BREAKPOINT_ACTIVE
Definition: kd64.h:38
VOID NTAPI KdUpdateDataBlock ( VOID  )

Definition at line 72 of file kdinit.c.

Referenced by PspInitializeSystemDll().

73 {
74  /* Update the KeUserCallbackDispatcher pointer */
77 }
PVOID KeUserCallbackDispatcher
Definition: ke.h:131
ULONG64 KeUserCallbackDispatcher
Definition: wdbgexts.h:188
KDDEBUGGER_DATA64 * KdDebuggerDataBlock
Definition: kdpacket.c:21
#define ULONG_PTR
Definition: config.h:101

Variable Documentation

BOOLEAN BreakpointsSuspended

Definition at line 99 of file kddata.c.

Referenced by KdpRestoreAllBreakpoints(), and KdpSuspendAllBreakPoints().

ULONG Kd_WIN2000_Mask

Definition at line 24 of file kdmain.c.

Referenced by KdpPrint(), NtQueryDebugFilterState(), and NtSetDebugFilterState().

BOOLEAN KdAutoEnableOnEvent

Definition at line 84 of file kddata.c.

Referenced by KdInitSystem(), and KdpStub().

BOOLEAN KdBlockEnable
BOOLEAN KdBreakAfterSymbolLoad

Definition at line 19 of file kdmain.c.

PULONG KdComponentTable[104]

Definition at line 33 of file kdmain.c.

Referenced by KdpPrint(), NtQueryDebugFilterState(), and NtSetDebugFilterState().

ULONG KdComponentTableSize

Definition at line 360 of file kddata.c.

Referenced by KdpPrint(), NtQueryDebugFilterState(), and NtSetDebugFilterState().

KDDEBUGGER_DATA64 KdDebuggerDataBlock

Definition at line 21 of file kdpacket.c.

ULONG KdDisableCount

Definition at line 90 of file kddata.c.

Referenced by KdDisableDebuggerWithLock(), and KdEnableDebuggerWithLock().

BOOLEAN KdEnteredDebugger

Definition at line 17 of file kdmain.c.

Referenced by KdEnterDebugger().

BOOLEAN KdIgnoreUmExceptions

Definition at line 22 of file kdmain.c.

KD_BREAKPOINT_TYPE KdpBreakpointInstruction
BOOLEAN KdpContextSent
BOOLEAN KdpControlCPressed

Definition at line 68 of file kddata.c.

Referenced by KdPollBreakIn(), and KdpReport().

ULONG_PTR KdpCurrentSymbolEnd

Definition at line 105 of file kddata.c.

Referenced by KdpGetStateChange().

ULONG_PTR KdpCurrentSymbolStart

Definition at line 105 of file kddata.c.

Referenced by KdpGetStateChange().

KSPIN_LOCK KdpDataSpinLock

Definition at line 366 of file kddata.c.

Referenced by KdRegisterDebuggerDataBlock().

LIST_ENTRY KdpDebuggerDataListHead

Definition at line 365 of file kddata.c.

Referenced by KdInitSystem(), and KdRegisterDebuggerDataBlock().

KSPIN_LOCK KdpDebuggerLock

Definition at line 67 of file kddata.c.

Referenced by KdEnterDebugger(), KdPollBreakIn(), KdpPortLock(), and KdpPortUnlock().

BOOLEAN KdpDebuggerStructuresInitialized

Definition at line 88 of file kddata.c.

Referenced by KdInitSystem().

LARGE_INTEGER KdPerformanceCounterRate

Definition at line 91 of file kddata.c.

Referenced by KdInitSystem().

BOOLEAN KdPitchDebugger

Definition at line 21 of file kdmain.c.

CHAR KdpMessageBuffer[0x1000]
ULONG KdpNumInternalBreakpoints

Definition at line 100 of file kddata.c.

Referenced by KdpSendWaitContinue().

CHAR KdpPathBuffer[0x1000]

Definition at line 128 of file kddata.c.

Referenced by KdpReportLoadSymbolsStateChange().

BOOLEAN KdpPortLocked

Definition at line 66 of file kddata.c.

Referenced by KdEnterDebugger(), and KdExitDebugger().

BOOLEAN KdPreviouslyEnabled

Definition at line 87 of file kddata.c.

Referenced by KdDisableDebuggerWithLock(), KdEnableDebuggerWithLock(), and KdpStub().

CHAR KdPrintDefaultCircularBuffer[KD_DEFAULT_LOG_BUFFER_SIZE]

Definition at line 133 of file kddata.c.

KDPC KdpTimeSlipDpc

Definition at line 116 of file kddata.c.

Referenced by KdExitDebugger(), KdInitSystem(), and KdpTimeSlipWork().

PKEVENT KdpTimeSlipEvent

Definition at line 120 of file kddata.c.

Referenced by KdpTimeSlipWork().

KSPIN_LOCK KdpTimeSlipEventLock

Definition at line 121 of file kddata.c.

Referenced by KdpTimeSlipWork().

LONG KdpTimeSlipPending

Definition at line 119 of file kddata.c.

Referenced by KdExitDebugger(), KdpTimeSlipDpcRoutine(), and Phase1InitializationDiscard().

KTIMER KdpTimeSlipTimer

Definition at line 117 of file kddata.c.

Referenced by KdInitSystem(), and KdpTimeSlipWork().

WORK_QUEUE_ITEM KdpTimeSlipWorkItem

Definition at line 118 of file kddata.c.

Referenced by KdInitSystem(), and KdpTimeSlipDpcRoutine().

LARGE_INTEGER KdTimerDifference

Definition at line 122 of file kddata.c.

Referenced by KdEnterDebugger().

LARGE_INTEGER KdTimerStart

Definition at line 546 of file kd64.h.

Referenced by KdEnterDebugger(), KdExitDebugger(), and KdInitSystem().

LARGE_INTEGER KdTimerStop

Definition at line 122 of file kddata.c.

Referenced by KdEnterDebugger(), and KdExitDebugger().

DBGKD_GET_VERSION64 KdVersionBlock

Definition at line 371 of file kddata.c.

Referenced by KdInitSystem(), KdpSysGetVersion(), and KiDispatchException().

PKDEBUG_ROUTINE KiDebugRoutine

Definition at line 471 of file kdmain.c.

Referenced by KdDisableDebuggerWithLock(), KdInitSystem(), and KiDispatchException().

PKDEBUG_SWITCH_ROUTINE KiDebugSwitchRoutine

Definition at line 75 of file kddata.c.

Referenced by KdInitSystem().

ULONG TraceDataBuffer[40]

Definition at line 110 of file kddata.c.

Referenced by DumpTraceData().

ULONG TraceDataBufferPosition

Definition at line 111 of file kddata.c.

Referenced by DumpTraceData().