1 #pragma once 2 3 /* DEFINES *******************************************************************/ 4 5 /* formerly located in kdbg/kdb_symbols.c */ 6 #define TAG_KDBS 'SBDK' 7 #define TAG_KDBG 'GBDK' 8 9 /* TYPES *********************************************************************/ 10 11 /* from kdb.c */ 12 typedef struct _KDB_KTRAP_FRAME 13 { 14 KTRAP_FRAME Tf; 15 ULONG Cr0; 16 ULONG Cr1; /* reserved/unused */ 17 ULONG Cr2; 18 ULONG Cr3; 19 ULONG Cr4; 20 } KDB_KTRAP_FRAME, *PKDB_KTRAP_FRAME; 21 22 typedef enum _KDB_BREAKPOINT_TYPE 23 { 24 KdbBreakPointNone = 0, 25 KdbBreakPointSoftware, 26 KdbBreakPointHardware, 27 KdbBreakPointTemporary 28 } KDB_BREAKPOINT_TYPE; 29 30 typedef enum _KDB_ACCESS_TYPE 31 { 32 KdbAccessRead, 33 KdbAccessWrite, 34 KdbAccessReadWrite, 35 KdbAccessExec 36 } KDB_ACCESS_TYPE; 37 38 typedef struct _KDB_BREAKPOINT 39 { 40 KDB_BREAKPOINT_TYPE Type; /* Type of breakpoint */ 41 BOOLEAN Enabled; /* Whether the bp is enabled */ 42 ULONG_PTR Address; /* Address of the breakpoint */ 43 BOOLEAN Global; /* Whether the breakpoint is global or local to a process */ 44 PEPROCESS Process; /* Owning process */ 45 PCHAR ConditionExpression; 46 PVOID Condition; 47 union { 48 /* KdbBreakPointSoftware */ 49 UCHAR SavedInstruction; 50 /* KdbBreakPointHardware */ 51 struct { 52 UCHAR DebugReg : 2; 53 UCHAR Size : 3; 54 KDB_ACCESS_TYPE AccessType; 55 } Hw; 56 } Data; 57 } KDB_BREAKPOINT, *PKDB_BREAKPOINT; 58 59 typedef enum _KDB_ENTER_CONDITION 60 { 61 KdbDoNotEnter, 62 KdbEnterAlways, 63 KdbEnterFromKmode, 64 KdbEnterFromUmode 65 } KDB_ENTER_CONDITION; 66 67 /* These values MUST be nonzero. They're used as bit masks. */ 68 typedef enum _KDB_OUTPUT_SETTINGS 69 { 70 KD_DEBUG_KDSERIAL = 1, 71 KD_DEBUG_KDNOECHO = 2 72 } KDB_OUTPUT_SETTINGS; 73 74 /* FUNCTIONS *****************************************************************/ 75 76 /* from i386/i386-dis.c */ 77 78 LONG 79 KdbpDisassemble( 80 IN ULONG Address, 81 IN ULONG IntelSyntax); 82 83 LONG 84 KdbpGetInstLength( 85 IN ULONG Address); 86 87 /* from i386/kdb_help.S */ 88 89 VOID NTAPI 90 KdbpStackSwitchAndCall( 91 IN PVOID NewStack, 92 IN VOID (*Function)(VOID)); 93 94 /* from kdb_cli.c */ 95 96 extern PCHAR KdbInitFileBuffer; 97 98 VOID 99 KdbpCliInit(VOID); 100 101 VOID 102 KdbpCliMainLoop( 103 IN BOOLEAN EnteredOnSingleStep); 104 105 VOID 106 KdbpCliModuleLoaded( 107 IN PUNICODE_STRING Name); 108 109 VOID 110 KdbpCliInterpretInitFile(VOID); 111 112 VOID 113 KdbpPrint( 114 IN PCHAR Format, 115 IN ... OPTIONAL); 116 117 BOOLEAN 118 NTAPI 119 KdbpGetHexNumber( 120 IN PCHAR pszNum, 121 OUT ULONG_PTR *pulValue); 122 123 /* from kdb_expr.c */ 124 125 BOOLEAN 126 KdbpRpnEvaluateExpression( 127 IN PCHAR Expression, 128 IN PKDB_KTRAP_FRAME TrapFrame, 129 OUT PULONGLONG Result, 130 OUT PLONG ErrOffset OPTIONAL, 131 OUT PCHAR ErrMsg OPTIONAL); 132 133 PVOID 134 KdbpRpnParseExpression( 135 IN PCHAR Expression, 136 OUT PLONG ErrOffset OPTIONAL, 137 OUT PCHAR ErrMsg OPTIONAL); 138 139 BOOLEAN 140 KdbpRpnEvaluateParsedExpression( 141 IN PVOID Expression, 142 IN PKDB_KTRAP_FRAME TrapFrame, 143 OUT PULONGLONG Result, 144 OUT PLONG ErrOffset OPTIONAL, 145 OUT PCHAR ErrMsg OPTIONAL); 146 147 /* from kdb_symbols.c */ 148 149 BOOLEAN 150 KdbpSymFindModule( 151 IN PVOID Address OPTIONAL, 152 IN LPCWSTR Name OPTIONAL, 153 IN INT Index OPTIONAL, 154 OUT PLDR_DATA_TABLE_ENTRY* pLdrEntry); 155 156 /* from kdb.c */ 157 158 extern PEPROCESS KdbCurrentProcess; 159 extern PETHREAD KdbCurrentThread; 160 extern LONG KdbLastBreakPointNr; 161 extern ULONG KdbNumSingleSteps; 162 extern BOOLEAN KdbSingleStepOver; 163 extern PKDB_KTRAP_FRAME KdbCurrentTrapFrame; 164 extern ULONG KdbDebugState; 165 166 LONG 167 KdbpGetNextBreakPointNr( 168 IN ULONG Start OPTIONAL); 169 170 BOOLEAN 171 KdbpGetBreakPointInfo( 172 IN ULONG BreakPointNr, 173 OUT ULONG_PTR *Address OPTIONAL, 174 OUT KDB_BREAKPOINT_TYPE *Type OPTIONAL, 175 OUT UCHAR *Size OPTIONAL, 176 OUT KDB_ACCESS_TYPE *AccessType OPTIONAL, 177 OUT UCHAR *DebugReg OPTIONAL, 178 OUT BOOLEAN *Enabled OPTIONAL, 179 OUT BOOLEAN *Global OPTIONAL, 180 OUT PEPROCESS *Process OPTIONAL, 181 OUT PCHAR *ConditionExpression OPTIONAL); 182 183 NTSTATUS 184 KdbpInsertBreakPoint( 185 IN ULONG_PTR Address, 186 IN KDB_BREAKPOINT_TYPE Type, 187 IN UCHAR Size OPTIONAL, 188 IN KDB_ACCESS_TYPE AccessType OPTIONAL, 189 IN PCHAR ConditionExpression OPTIONAL, 190 IN BOOLEAN Global, 191 OUT PLONG BreakPointNr OPTIONAL); 192 193 BOOLEAN 194 KdbpDeleteBreakPoint( 195 IN LONG BreakPointNr OPTIONAL, 196 IN OUT PKDB_BREAKPOINT BreakPoint OPTIONAL); 197 198 BOOLEAN 199 KdbpEnableBreakPoint( 200 IN LONG BreakPointNr OPTIONAL, 201 IN OUT PKDB_BREAKPOINT BreakPoint OPTIONAL); 202 203 BOOLEAN 204 KdbpDisableBreakPoint( 205 IN LONG BreakPointNr OPTIONAL, 206 IN OUT PKDB_BREAKPOINT BreakPoint OPTIONAL); 207 208 BOOLEAN 209 KdbpGetEnterCondition( 210 IN LONG ExceptionNr, 211 IN BOOLEAN FirstChance, 212 OUT KDB_ENTER_CONDITION *Condition); 213 214 BOOLEAN 215 KdbpSetEnterCondition( 216 IN LONG ExceptionNr, 217 IN BOOLEAN FirstChance, 218 IN KDB_ENTER_CONDITION Condition); 219 220 BOOLEAN 221 KdbpAttachToThread( 222 PVOID ThreadId); 223 224 BOOLEAN 225 KdbpAttachToProcess( 226 PVOID ProcessId); 227 228 VOID 229 NTAPI 230 KdbpGetCommandLineSettings(PCHAR p1); 231 232 KD_CONTINUE_TYPE 233 KdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord, 234 KPROCESSOR_MODE PreviousMode, 235 PCONTEXT Context, 236 PKTRAP_FRAME TrapFrame, 237 BOOLEAN FirstChance); 238 /* other functions */ 239 240 NTSTATUS 241 KdbpSafeReadMemory(OUT PVOID Dest, 242 IN PVOID Src, 243 IN ULONG Bytes); 244 245 NTSTATUS 246 KdbpSafeWriteMemory(OUT PVOID Dest, 247 IN PVOID Src, 248 IN ULONG Bytes); 249 250 #define KdbpGetCharKeyboard(ScanCode) KdbpTryGetCharKeyboard(ScanCode, 0) 251 CHAR 252 KdbpTryGetCharKeyboard(PULONG ScanCode, ULONG Retry); 253 254 #define KdbpGetCharSerial() KdbpTryGetCharSerial(0) 255 CHAR 256 KdbpTryGetCharSerial(ULONG Retry); 257 258 VOID 259 KdbEnter(VOID); 260 VOID 261 DbgRDebugInit(VOID); 262 VOID 263 DbgShowFiles(VOID); 264 VOID 265 DbgEnableFile(PCH Filename); 266 VOID 267 DbgDisableFile(PCH Filename); 268 VOID 269 KbdDisableMouse(VOID); 270 VOID 271 KbdEnableMouse(VOID); 272