Cleanup isn't necessary after calling the driver in NtQueryDirectoryFile.
[reactos.git] / reactos / ntoskrnl / kdbg / kdb.h
1 #ifndef NTOSKRNL_KDB_H
2 #define NTOSKRNL_KDB_H
3
4 /* DEFINES *******************************************************************/
5
6 #ifndef RTL_NUMBER_OF
7 # define RTL_NUMBER_OF(x) (sizeof(x) / sizeof((x)[0]))
8 #endif
9
10 /* TYPES *********************************************************************/
11
12 /* from kdb.c */
13 typedef struct _KDB_KTRAP_FRAME
14 {
15 KTRAP_FRAME Tf;
16 ULONG Cr0;
17 ULONG Cr1; /* reserved/unused */
18 ULONG Cr2;
19 ULONG Cr3;
20 ULONG Cr4;
21 } KDB_KTRAP_FRAME, *PKDB_KTRAP_FRAME;
22
23 typedef enum _KDB_BREAKPOINT_TYPE
24 {
25 KdbBreakPointNone = 0,
26 KdbBreakPointSoftware,
27 KdbBreakPointHardware,
28 KdbBreakPointTemporary
29 } KDB_BREAKPOINT_TYPE;
30
31 typedef enum _KDB_ACCESS_TYPE
32 {
33 KdbAccessRead,
34 KdbAccessWrite,
35 KdbAccessReadWrite,
36 KdbAccessExec
37 } KDB_ACCESS_TYPE;
38
39 typedef struct _KDB_BREAKPOINT
40 {
41 KDB_BREAKPOINT_TYPE Type; /* Type of breakpoint */
42 BOOLEAN Enabled; /* Whether the bp is enabled */
43 ULONG_PTR Address; /* Address of the breakpoint */
44 BOOLEAN Global; /* Whether the breakpoint is global or local to a process */
45 PEPROCESS Process; /* Owning process */
46 PCHAR ConditionExpression;
47 PVOID Condition;
48 union {
49 /* KdbBreakPointSoftware */
50 UCHAR SavedInstruction;
51 /* KdbBreakPointHardware */
52 struct {
53 UCHAR DebugReg : 2;
54 UCHAR Size : 3;
55 KDB_ACCESS_TYPE AccessType;
56 } Hw;
57 } Data;
58 } KDB_BREAKPOINT, *PKDB_BREAKPOINT;
59
60 typedef enum _KDB_ENTER_CONDITION
61 {
62 KdbDoNotEnter,
63 KdbEnterAlways,
64 KdbEnterFromKmode,
65 KdbEnterFromUmode
66 } KDB_ENTER_CONDITION;
67
68 /* These values MUST be nonzero. They're used as bit masks. */
69 typedef enum _KDB_OUTPUT_SETTINGS
70 {
71 KD_DEBUG_KDSERIAL = 1,
72 KD_DEBUG_KDNOECHO = 2
73 } KDB_OUTPUT_SETTINGS;
74
75 /* FUNCTIONS *****************************************************************/
76
77 /* from i386/i386-dis.c */
78
79 LONG
80 KdbpDisassemble(
81 IN ULONG Address,
82 IN ULONG IntelSyntax);
83
84 LONG
85 KdbpGetInstLength(
86 IN ULONG Address);
87
88 /* from i386/kdb_help.S */
89
90 VOID STDCALL
91 KdbpStackSwitchAndCall(
92 IN PVOID NewStack,
93 IN VOID (*Function)(VOID));
94
95 /* from kdb_cli.c */
96
97 extern PCHAR KdbInitFileBuffer;
98
99 VOID
100 KdbpCliInit();
101
102 VOID
103 KdbpCliMainLoop(
104 IN BOOLEAN EnteredOnSingleStep);
105
106 VOID
107 KdbpCliModuleLoaded(
108 IN PUNICODE_STRING Name);
109
110 VOID
111 KdbpCliInterpretInitFile();
112
113 VOID
114 KdbpPrint(
115 IN PCHAR Format,
116 IN ... OPTIONAL);
117
118 /* from kdb_expr.c */
119
120 BOOLEAN
121 KdbpRpnEvaluateExpression(
122 IN PCHAR Expression,
123 IN PKDB_KTRAP_FRAME TrapFrame,
124 OUT PULONGLONG Result,
125 OUT PLONG ErrOffset OPTIONAL,
126 OUT PCHAR ErrMsg OPTIONAL);
127
128 PVOID
129 KdbpRpnParseExpression(
130 IN PCHAR Expression,
131 OUT PLONG ErrOffset OPTIONAL,
132 OUT PCHAR ErrMsg OPTIONAL);
133
134 BOOLEAN
135 KdbpRpnEvaluateParsedExpression(
136 IN PVOID Expression,
137 IN PKDB_KTRAP_FRAME TrapFrame,
138 OUT PULONGLONG Result,
139 OUT PLONG ErrOffset OPTIONAL,
140 OUT PCHAR ErrMsg OPTIONAL);
141
142 /* from kdb_symbols.c */
143
144 BOOLEAN
145 KdbpSymFindModuleByAddress(IN PVOID Address,
146 OUT PKDB_MODULE_INFO pInfo);
147
148 BOOLEAN
149 KdbpSymFindModuleByName(IN LPCWSTR Name,
150 OUT PKDB_MODULE_INFO pInfo);
151
152 BOOLEAN
153 KdbpSymFindModuleByIndex(IN INT Index,
154 OUT PKDB_MODULE_INFO pInfo);
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 PULONG BreakPointNumber 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 STDCALL
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, UINT Retry);
253
254 #define KdbpGetCharSerial() KdbpTryGetCharSerial(0)
255 CHAR
256 KdbpTryGetCharSerial(UINT 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();
270 VOID
271 KbdEnableMouse();
272
273 #endif /* NTOSKRNL_KDB_H */
274