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