1 #pragma once 2 3 #include <cportlib/cportlib.h> 4 5 // 6 // Kernel Debugger Port Definition 7 // 8 struct _KD_DISPATCH_TABLE; 9 10 BOOLEAN 11 NTAPI 12 KdPortInitializeEx( 13 PCPPORT PortInformation, 14 ULONG ComPortNumber 15 ); 16 17 BOOLEAN 18 NTAPI 19 KdPortGetByteEx( 20 PCPPORT PortInformation, 21 PUCHAR ByteReceived); 22 23 VOID 24 NTAPI 25 KdPortPutByteEx( 26 PCPPORT PortInformation, 27 UCHAR ByteToSend 28 ); 29 30 /* SYMBOL ROUTINES **********************************************************/ 31 32 #ifdef _NTOSKRNL_ 33 34 #ifdef KDBG 35 # define KdbInit() KdbpCliInit() 36 #else 37 # define KdbInit() do { } while (0) 38 #endif 39 40 /* KD ROUTINES ***************************************************************/ 41 42 typedef enum _KD_CONTINUE_TYPE 43 { 44 kdContinue = 0, 45 kdDoNotHandleException, 46 kdHandleException 47 } KD_CONTINUE_TYPE; 48 49 typedef 50 VOID 51 (NTAPI*PKDP_INIT_ROUTINE)( 52 struct _KD_DISPATCH_TABLE *DispatchTable, 53 ULONG BootPhase 54 ); 55 56 typedef 57 VOID 58 (NTAPI*PKDP_PRINT_ROUTINE)( 59 PCHAR String, 60 ULONG Length 61 ); 62 63 /* INIT ROUTINES *************************************************************/ 64 65 BOOLEAN 66 NTAPI 67 KdInitSystem( 68 ULONG Reserved, 69 PLOADER_PARAMETER_BLOCK LoaderBlock 70 ); 71 72 VOID 73 KdpScreenAcquire(VOID); 74 75 VOID 76 KdpScreenRelease(VOID); 77 78 VOID 79 NTAPI 80 KdpScreenInit( 81 struct _KD_DISPATCH_TABLE *DispatchTable, 82 ULONG BootPhase 83 ); 84 85 VOID 86 NTAPI 87 KdpSerialInit( 88 struct _KD_DISPATCH_TABLE *DispatchTable, 89 ULONG BootPhase 90 ); 91 92 VOID 93 NTAPI 94 KdpDebugLogInit( 95 struct _KD_DISPATCH_TABLE *DispatchTable, 96 ULONG BootPhase 97 ); 98 99 VOID 100 NTAPI 101 KdpKdbgInit( 102 struct _KD_DISPATCH_TABLE *DispatchTable, 103 ULONG BootPhase); 104 105 106 /* KD ROUTINES ***************************************************************/ 107 108 BOOLEAN 109 NTAPI 110 KdpDetectConflicts(PCM_RESOURCE_LIST DriverList); 111 112 BOOLEAN 113 NTAPI 114 KdpSafeReadMemory( 115 IN ULONG_PTR Addr, 116 IN LONG Len, 117 OUT PVOID Value 118 ); 119 120 BOOLEAN 121 NTAPI 122 KdpSafeWriteMemory( 123 IN ULONG_PTR Addr, 124 IN LONG Len, 125 IN ULONGLONG Value 126 ); 127 128 129 /* KD GLOBALS ***************************************************************/ 130 131 /* Serial debug connection */ 132 #define DEFAULT_DEBUG_PORT 2 /* COM2 */ 133 #define DEFAULT_DEBUG_COM1_IRQ 4 /* COM1 IRQ */ 134 #define DEFAULT_DEBUG_COM2_IRQ 3 /* COM2 IRQ */ 135 #define DEFAULT_DEBUG_BAUD_RATE 115200 /* 115200 Baud */ 136 137 /* KD Native Modes */ 138 #define KdScreen 0 139 #define KdSerial 1 140 #define KdFile 2 141 #define KdKdbg 3 142 #define KdMax 4 143 144 /* KD Private Debug Modes */ 145 typedef struct _KDP_DEBUG_MODE 146 { 147 union 148 { 149 struct 150 { 151 /* Native Modes */ 152 UCHAR Screen :1; 153 UCHAR Serial :1; 154 UCHAR File :1; 155 }; 156 157 /* Generic Value */ 158 ULONG Value; 159 }; 160 } KDP_DEBUG_MODE; 161 162 /* KD Internal Debug Services */ 163 typedef enum _KDP_DEBUG_SERVICE 164 { 165 DumpNonPagedPool = 0x1e, /* a */ 166 ManualBugCheck = 0x30, /* b */ 167 DumpNonPagedPoolStats = 0x2e, /* c */ 168 DumpNewNonPagedPool = 0x20, /* d */ 169 DumpNewNonPagedPoolStats = 0x12, /* e */ 170 DumpAllThreads = 0x21, /* f */ 171 DumpUserThreads = 0x22, /* g */ 172 KdSpare1 = 0x23, /* h */ 173 KdSpare2 = 0x17, /* i */ 174 KdSpare3 = 0x24, /* j */ 175 EnterDebugger = 0x25, /* k */ 176 ThatsWhatSheSaid = 69 /* FIGURE IT OUT */ 177 } KDP_DEBUG_SERVICE; 178 179 /* Dispatch Table for Wrapper Functions */ 180 typedef struct _KD_DISPATCH_TABLE 181 { 182 LIST_ENTRY KdProvidersList; 183 PKDP_INIT_ROUTINE KdpInitRoutine; 184 PKDP_PRINT_ROUTINE KdpPrintRoutine; 185 } KD_DISPATCH_TABLE, *PKD_DISPATCH_TABLE; 186 187 /* The current Debugging Mode */ 188 extern KDP_DEBUG_MODE KdpDebugMode; 189 190 /* Port Information for the Serial Native Mode */ 191 extern ULONG SerialPortNumber; 192 extern CPPORT SerialPortInfo; 193 194 /* Init Functions for Native Providers */ 195 extern PKDP_INIT_ROUTINE InitRoutines[KdMax]; 196 197 /* Dispatch Tables for Native Providers */ 198 extern KD_DISPATCH_TABLE DispatchTable[KdMax]; 199 200 /* The KD Native Provider List */ 201 extern LIST_ENTRY KdProviders; 202 203 #endif 204 205 #if DBG && defined(_M_IX86) && !defined(_WINKD_) // See ke/i386/traphdlr.c 206 #define ID_Win32PreServiceHook 'WSH0' 207 #define ID_Win32PostServiceHook 'WSH1' 208 typedef void (NTAPI *PKDBG_PRESERVICEHOOK)(ULONG, PULONG_PTR); 209 typedef ULONG_PTR (NTAPI *PKDBG_POSTSERVICEHOOK)(ULONG, ULONG_PTR); 210 extern PKDBG_PRESERVICEHOOK KeWin32PreServiceHook; 211 extern PKDBG_POSTSERVICEHOOK KeWin32PostServiceHook; 212 #endif 213