prefix DEBUG_CONTROL constants with AMD64 as they are architecture specific
[reactos.git] / reactos / include / reactos / windbgkd.h
1 #ifndef _WINDBGKD_
2 #define _WINDBGKD_
3
4 //
5 // Dependencies
6 //
7 #include "wdbgexts.h"
8
9 //
10 // Conversion Macros
11 //
12 #define COPYSE(p64, p32, f) \
13 p64->f = (ULONG64)(LONG64)(LONG)p32->f
14
15 //
16 // Packet Size and Control Stream Size
17 //
18 #define PACKET_MAX_SIZE 4000
19 #define DBGKD_MAXSTREAM 16
20
21 //
22 // Magic Packet IDs
23 //
24 #define INITIAL_PACKET_ID 0x80800000
25 #define SYNC_PACKET_ID 0x00000800
26
27 //
28 // Magic Packet bytes
29 //
30 #define BREAKIN_PACKET 0x62626262
31 #define BREAKIN_PACKET_BYTE 0x62
32 #define PACKET_LEADER 0x30303030
33 #define PACKET_LEADER_BYTE 0x30
34 #define CONTROL_PACKET_LEADER 0x69696969
35 #define CONTROL_PACKET_LEADER_BYTE 0x69
36 #define PACKET_TRAILING_BYTE 0xAA
37
38 //
39 // Packet Types
40 //
41 #define PACKET_TYPE_UNUSED 0
42 #define PACKET_TYPE_KD_STATE_CHANGE32 1
43 #define PACKET_TYPE_KD_STATE_MANIPULATE 2
44 #define PACKET_TYPE_KD_DEBUG_IO 3
45 #define PACKET_TYPE_KD_ACKNOWLEDGE 4
46 #define PACKET_TYPE_KD_RESEND 5
47 #define PACKET_TYPE_KD_RESET 6
48 #define PACKET_TYPE_KD_STATE_CHANGE64 7
49 #define PACKET_TYPE_KD_POLL_BREAKIN 8
50 #define PACKET_TYPE_KD_TRACE_IO 9
51 #define PACKET_TYPE_KD_CONTROL_REQUEST 10
52 #define PACKET_TYPE_KD_FILE_IO 11
53 #define PACKET_TYPE_MAX 12
54
55 //
56 // Wait State Change Types
57 //
58 #define DbgKdMinimumStateChange 0x00003030
59 #define DbgKdExceptionStateChange 0x00003030
60 #define DbgKdLoadSymbolsStateChange 0x00003031
61 #define DbgKdCommandStringStateChange 0x00003032
62 #define DbgKdMaximumStateChange 0x00003033
63
64 //
65 // This is combined with the basic state change code
66 // if the state is from an alternate source
67 //
68 #define DbgKdAlternateStateChange 0x00010000
69
70 //
71 // Manipulate Types
72 //
73 #define DbgKdMinimumManipulate 0x00003130
74 #define DbgKdReadVirtualMemoryApi 0x00003130
75 #define DbgKdWriteVirtualMemoryApi 0x00003131
76 #define DbgKdGetContextApi 0x00003132
77 #define DbgKdSetContextApi 0x00003133
78 #define DbgKdWriteBreakPointApi 0x00003134
79 #define DbgKdRestoreBreakPointApi 0x00003135
80 #define DbgKdContinueApi 0x00003136
81 #define DbgKdReadControlSpaceApi 0x00003137
82 #define DbgKdWriteControlSpaceApi 0x00003138
83 #define DbgKdReadIoSpaceApi 0x00003139
84 #define DbgKdWriteIoSpaceApi 0x0000313A
85 #define DbgKdRebootApi 0x0000313B
86 #define DbgKdContinueApi2 0x0000313C
87 #define DbgKdReadPhysicalMemoryApi 0x0000313D
88 #define DbgKdWritePhysicalMemoryApi 0x0000313E
89 #define DbgKdQuerySpecialCallsApi 0x0000313F
90 #define DbgKdSetSpecialCallApi 0x00003140
91 #define DbgKdClearSpecialCallsApi 0x00003141
92 #define DbgKdSetInternalBreakPointApi 0x00003142
93 #define DbgKdGetInternalBreakPointApi 0x00003143
94 #define DbgKdReadIoSpaceExtendedApi 0x00003144
95 #define DbgKdWriteIoSpaceExtendedApi 0x00003145
96 #define DbgKdGetVersionApi 0x00003146
97 #define DbgKdWriteBreakPointExApi 0x00003147
98 #define DbgKdRestoreBreakPointExApi 0x00003148
99 #define DbgKdCauseBugCheckApi 0x00003149
100 #define DbgKdSwitchProcessor 0x00003150
101 #define DbgKdPageInApi 0x00003151
102 #define DbgKdReadMachineSpecificRegister 0x00003152
103 #define DbgKdWriteMachineSpecificRegister 0x00003153
104 #define OldVlm1 0x00003154
105 #define OldVlm2 0x00003155
106 #define DbgKdSearchMemoryApi 0x00003156
107 #define DbgKdGetBusDataApi 0x00003157
108 #define DbgKdSetBusDataApi 0x00003158
109 #define DbgKdCheckLowMemoryApi 0x00003159
110 #define DbgKdClearAllInternalBreakpointsApi 0x0000315A
111 #define DbgKdFillMemoryApi 0x0000315B
112 #define DbgKdQueryMemoryApi 0x0000315C
113 #define DbgKdSwitchPartition 0x0000315D
114 #define DbgKdMaximumManipulate 0x0000315E
115
116 //
117 // Debug I/O Types
118 //
119 #define DbgKdPrintStringApi 0x00003230
120 #define DbgKdGetStringApi 0x00003231
121
122 //
123 // Trace I/O Types
124 //
125 #define DbgKdPrintTraceApi 0x00003330
126
127 //
128 // Control Request Types
129 //
130 #define DbgKdRequestHardwareBp 0x00004300
131 #define DbgKdReleaseHardwareBp 0x00004301
132
133 //
134 // File I/O Types
135 //
136 #define DbgKdCreateFileApi 0x00003430
137 #define DbgKdReadFileApi 0x00003431
138 #define DbgKdWriteFileApi 0x00003432
139 #define DbgKdCloseFileApi 0x00003433
140
141 //
142 // Control Report Flags
143 //
144 #define REPORT_INCLUDES_SEGS 0x0001
145 #define REPORT_STANDARD_CS 0x0002
146
147 //
148 // Protocol Versions
149 //
150 #define DBGKD_64BIT_PROTOCOL_VERSION1 5
151 #define DBGKD_64BIT_PROTOCOL_VERSION2 6
152
153 //
154 // Query Memory Address Spaces
155 //
156 #define DBGKD_QUERY_MEMORY_VIRTUAL 0
157 #define DBGKD_QUERY_MEMORY_PROCESS 0
158 #define DBGKD_QUERY_MEMORY_SESSION 1
159 #define DBGKD_QUERY_MEMORY_KERNEL 2
160
161 //
162 // Query Memory Flags
163 //
164 #define DBGKD_QUERY_MEMORY_READ 0x01
165 #define DBGKD_QUERY_MEMORY_WRITE 0x02
166 #define DBGKD_QUERY_MEMORY_EXECUTE 0x04
167 #define DBGKD_QUERY_MEMORY_FIXED 0x08
168
169 //
170 // Internal Breakpoint Flags
171 //
172 #define DBGKD_INTERNAL_BP_FLAG_COUNTONLY 0x01
173 #define DBGKD_INTERNAL_BP_FLAG_INVALID 0x02
174 #define DBGKD_INTERNAL_BP_FLAG_SUSPENDED 0x04
175 #define DBGKD_INTERNAL_BP_FLAG_DYING 0x08
176
177 //
178 // Fill Memory Flags
179 //
180 #define DBGKD_FILL_MEMORY_VIRTUAL 0x01
181 #define DBGKD_FILL_MEMORY_PHYSICAL 0x02
182
183 //
184 // Physical Memory Caching Flags
185 //
186 #define DBGKD_CACHING_DEFAULT 0
187 #define DBGKD_CACHING_CACHED 1
188 #define DBGKD_CACHING_UNCACHED 2
189 #define DBGKD_CACHING_WRITE_COMBINED 3
190
191 //
192 // Partition Switch Flags
193 //
194 #define DBGKD_PARTITION_DEFAULT 0x00
195 #define DBGKD_PARTITION_ALTERNATE 0x01
196
197 //
198 // AMD64 Control Space types
199 //
200 #define AMD64_DEBUG_CONTROL_SPACE_KPCR 0
201 #define AMD64_DEBUG_CONTROL_SPACE_KPRCB 1
202 #define AMD64_DEBUG_CONTROL_SPACE_KSPECIAL 2
203 #define AMD64_DEBUG_CONTROL_SPACE_KTHREAD 3
204
205
206 //
207 // KD Packet Structure
208 //
209 typedef struct _KD_PACKET
210 {
211 ULONG PacketLeader;
212 USHORT PacketType;
213 USHORT ByteCount;
214 ULONG PacketId;
215 ULONG Checksum;
216 } KD_PACKET, *PKD_PACKET;
217
218 //
219 // KD Context
220 //
221 typedef struct _KD_CONTEXT
222 {
223 ULONG KdpDefaultRetries;
224 BOOLEAN KdpControlCPending;
225 } KD_CONTEXT, *PKD_CONTEXT;
226
227 //
228 // Control Sets for Supported Architectures
229 //
230 #include <pshpack4.h>
231 typedef struct _X86_DBGKD_CONTROL_SET
232 {
233 ULONG TraceFlag;
234 ULONG Dr7;
235 ULONG CurrentSymbolStart;
236 ULONG CurrentSymbolEnd;
237 } X86_DBGKD_CONTROL_SET, *PX86_DBGKD_CONTROL_SET;
238
239 typedef struct _ALPHA_DBGKD_CONTROL_SET
240 {
241 ULONG __padding;
242 } ALPHA_DBGKD_CONTROL_SET, *PALPHA_DBGKD_CONTROL_SET;
243
244 typedef struct _IA64_DBGKD_CONTROL_SET
245 {
246 ULONG Continue;
247 ULONG64 CurrentSymbolStart;
248 ULONG64 CurrentSymbolEnd;
249 } IA64_DBGKD_CONTROL_SET, *PIA64_DBGKD_CONTROL_SET;
250
251 typedef struct _AMD64_DBGKD_CONTROL_SET
252 {
253 ULONG TraceFlag;
254 ULONG64 Dr7;
255 ULONG64 CurrentSymbolStart;
256 ULONG64 CurrentSymbolEnd;
257 } AMD64_DBGKD_CONTROL_SET, *PAMD64_DBGKD_CONTROL_SET;
258
259 typedef struct _ARM_DBGKD_CONTROL_SET
260 {
261 ULONG Continue;
262 ULONG CurrentSymbolStart;
263 ULONG CurrentSymbolEnd;
264 } ARM_DBGKD_CONTROL_SET, *PARM_DBGKD_CONTROL_SET;
265
266 typedef struct _DBGKD_ANY_CONTROL_SET
267 {
268 union
269 {
270 X86_DBGKD_CONTROL_SET X86ControlSet;
271 ALPHA_DBGKD_CONTROL_SET AlphaControlSet;
272 IA64_DBGKD_CONTROL_SET IA64ControlSet;
273 AMD64_DBGKD_CONTROL_SET Amd64ControlSet;
274 ARM_DBGKD_CONTROL_SET ARMControlSet;
275 };
276 } DBGKD_ANY_CONTROL_SET, *PDBGKD_ANY_CONTROL_SET;
277 #include <poppack.h>
278
279 #if defined(_M_IX86)
280 typedef X86_DBGKD_CONTROL_SET DBGKD_CONTROL_SET, *PDBGKD_CONTROL_SET;
281 #elif defined(_M_AMD64)
282 typedef AMD64_DBGKD_CONTROL_SET DBGKD_CONTROL_SET, *PDBGKD_CONTROL_SET;
283 #elif defined(_M_ARM)
284 typedef ARM_DBGKD_CONTROL_SET DBGKD_CONTROL_SET, *PDBGKD_CONTROL_SET;
285 #else
286 #error Unsupported Architecture
287 #endif
288
289 //
290 // DBGKM Structure for Exceptions
291 //
292 typedef struct _DBGKM_EXCEPTION32
293 {
294 EXCEPTION_RECORD32 ExceptionRecord;
295 ULONG FirstChance;
296 } DBGKM_EXCEPTION32, *PDBGKM_EXCEPTION32;
297
298 typedef struct _DBGKM_EXCEPTION64
299 {
300 EXCEPTION_RECORD64 ExceptionRecord;
301 ULONG FirstChance;
302 } DBGKM_EXCEPTION64, *PDBGKM_EXCEPTION64;
303
304 //
305 // DBGKD Structure for State Change
306 //
307 typedef struct _X86_DBGKD_CONTROL_REPORT
308 {
309 ULONG Dr6;
310 ULONG Dr7;
311 USHORT InstructionCount;
312 USHORT ReportFlags;
313 UCHAR InstructionStream[DBGKD_MAXSTREAM];
314 USHORT SegCs;
315 USHORT SegDs;
316 USHORT SegEs;
317 USHORT SegFs;
318 ULONG EFlags;
319 } X86_DBGKD_CONTROL_REPORT, *PX86_DBGKD_CONTROL_REPORT;
320
321 typedef struct _ALPHA_DBGKD_CONTROL_REPORT
322 {
323 ULONG InstructionCount;
324 UCHAR InstructionStream[DBGKD_MAXSTREAM];
325 } ALPHA_DBGKD_CONTROL_REPORT, *PALPHA_DBGKD_CONTROL_REPORT;
326
327 typedef struct _IA64_DBGKD_CONTROL_REPORT
328 {
329 ULONG InstructionCount;
330 UCHAR InstructionStream[DBGKD_MAXSTREAM];
331 } IA64_DBGKD_CONTROL_REPORT, *PIA64_DBGKD_CONTROL_REPORT;
332
333 typedef struct _AMD64_DBGKD_CONTROL_REPORT
334 {
335 ULONG64 Dr6;
336 ULONG64 Dr7;
337 ULONG EFlags;
338 USHORT InstructionCount;
339 USHORT ReportFlags;
340 UCHAR InstructionStream[DBGKD_MAXSTREAM];
341 USHORT SegCs;
342 USHORT SegDs;
343 USHORT SegEs;
344 USHORT SegFs;
345 } AMD64_DBGKD_CONTROL_REPORT, *PAMD64_DBGKD_CONTROL_REPORT;
346
347 typedef struct _ARM_DBGKD_CONTROL_REPORT
348 {
349 ULONG Cpsr;
350 ULONG InstructionCount;
351 UCHAR InstructionStream[DBGKD_MAXSTREAM];
352 } ARM_DBGKD_CONTROL_REPORT, *PARM_DBGKD_CONTROL_REPORT;
353
354 typedef struct _DBGKD_ANY_CONTROL_REPORT
355 {
356 union
357 {
358 X86_DBGKD_CONTROL_REPORT X86ControlReport;
359 ALPHA_DBGKD_CONTROL_REPORT AlphaControlReport;
360 IA64_DBGKD_CONTROL_REPORT IA64ControlReport;
361 AMD64_DBGKD_CONTROL_REPORT Amd64ControlReport;
362 ARM_DBGKD_CONTROL_REPORT ARMControlReport;
363 };
364 } DBGKD_ANY_CONTROL_REPORT, *PDBGKD_ANY_CONTROL_REPORT;
365
366 #if defined(_M_IX86)
367 typedef X86_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT, *PDBGKD_CONTROL_REPORT;
368 #elif defined(_M_AMD64)
369 typedef AMD64_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT, *PDBGKD_CONTROL_REPORT;
370 #elif defined(_M_ARM)
371 typedef ARM_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT, *PDBGKD_CONTROL_REPORT;
372 #else
373 #error Unsupported Architecture
374 #endif
375
376 //
377 // DBGKD Structure for Debug I/O Type Print String
378 //
379 typedef struct _DBGKD_PRINT_STRING
380 {
381 ULONG LengthOfString;
382 } DBGKD_PRINT_STRING, *PDBGKD_PRINT_STRING;
383
384 //
385 // DBGKD Structure for Debug I/O Type Get String
386 //
387 typedef struct _DBGKD_GET_STRING
388 {
389 ULONG LengthOfPromptString;
390 ULONG LengthOfStringRead;
391 } DBGKD_GET_STRING, *PDBGKD_GET_STRING;
392
393 //
394 // DBGKD Structure for Debug I/O
395 //
396 typedef struct _DBGKD_DEBUG_IO
397 {
398 ULONG ApiNumber;
399 USHORT ProcessorLevel;
400 USHORT Processor;
401 union
402 {
403 DBGKD_PRINT_STRING PrintString;
404 DBGKD_GET_STRING GetString;
405 } u;
406 } DBGKD_DEBUG_IO, *PDBGKD_DEBUG_IO;
407
408 //
409 // DBGkD Structure for Command String
410 //
411 typedef struct _DBGKD_COMMAND_STRING
412 {
413 ULONG Flags;
414 ULONG Reserved1;
415 ULONG64 Reserved2[7];
416 } DBGKD_COMMAND_STRING, *PDBGKD_COMMAND_STRING;
417
418 //
419 // DBGKD Structure for Load Symbols
420 //
421 typedef struct _DBGKD_LOAD_SYMBOLS32
422 {
423 ULONG PathNameLength;
424 ULONG BaseOfDll;
425 ULONG ProcessId;
426 ULONG CheckSum;
427 ULONG SizeOfImage;
428 BOOLEAN UnloadSymbols;
429 } DBGKD_LOAD_SYMBOLS32, *PDBGKD_LOAD_SYMBOLS32;
430
431 typedef struct _DBGKD_LOAD_SYMBOLS64
432 {
433 ULONG PathNameLength;
434 ULONG64 BaseOfDll;
435 ULONG64 ProcessId;
436 ULONG CheckSum;
437 ULONG SizeOfImage;
438 BOOLEAN UnloadSymbols;
439 } DBGKD_LOAD_SYMBOLS64, *PDBGKD_LOAD_SYMBOLS64;
440
441 //
442 // DBGKD Structure for Wait State Change
443 //
444
445 typedef struct _DBGKD_WAIT_STATE_CHANGE32
446 {
447 ULONG NewState;
448 USHORT ProcessorLevel;
449 USHORT Processor;
450 ULONG NumberProcessors;
451 ULONG Thread;
452 ULONG ProgramCounter;
453 union
454 {
455 DBGKM_EXCEPTION32 Exception;
456 DBGKD_LOAD_SYMBOLS32 LoadSymbols;
457 } u;
458 DBGKD_CONTROL_REPORT ControlReport;
459 CONTEXT Context;
460 } DBGKD_WAIT_STATE_CHANGE32, *PDBGKD_WAIT_STATE_CHANGE32;
461
462 typedef struct _DBGKD_WAIT_STATE_CHANGE64
463 {
464 ULONG NewState;
465 USHORT ProcessorLevel;
466 USHORT Processor;
467 ULONG NumberProcessors;
468 ULONG64 Thread;
469 ULONG64 ProgramCounter;
470 union
471 {
472 DBGKM_EXCEPTION64 Exception;
473 DBGKD_LOAD_SYMBOLS64 LoadSymbols;
474 } u;
475 DBGKD_CONTROL_REPORT ControlReport;
476 CONTEXT Context;
477 } DBGKD_WAIT_STATE_CHANGE64, *PDBGKD_WAIT_STATE_CHANGE64;
478
479 typedef struct _DBGKD_ANY_WAIT_STATE_CHANGE
480 {
481 ULONG NewState;
482 USHORT ProcessorLevel;
483 USHORT Processor;
484 ULONG NumberProcessors;
485 ULONG64 Thread;
486 ULONG64 ProgramCounter;
487 union
488 {
489 DBGKM_EXCEPTION64 Exception;
490 DBGKD_LOAD_SYMBOLS64 LoadSymbols;
491 DBGKD_COMMAND_STRING CommandString;
492 } u;
493 union
494 {
495 DBGKD_CONTROL_REPORT ControlReport;
496 DBGKD_ANY_CONTROL_REPORT AnyControlReport;
497 };
498 } DBGKD_ANY_WAIT_STATE_CHANGE, *PDBGKD_ANY_WAIT_STATE_CHANGE;
499
500 //
501 // DBGKD Manipulate Structures
502 //
503 typedef struct _DBGKD_READ_MEMORY32
504 {
505 ULONG TargetBaseAddress;
506 ULONG TransferCount;
507 ULONG ActualBytesRead;
508 } DBGKD_READ_MEMORY32, *PDBGKD_READ_MEMORY32;
509
510 typedef struct _DBGKD_READ_MEMORY64
511 {
512 ULONG64 TargetBaseAddress;
513 ULONG TransferCount;
514 ULONG ActualBytesRead;
515 } DBGKD_READ_MEMORY64, *PDBGKD_READ_MEMORY64;
516
517 typedef struct _DBGKD_WRITE_MEMORY32
518 {
519 ULONG TargetBaseAddress;
520 ULONG TransferCount;
521 ULONG ActualBytesWritten;
522 } DBGKD_WRITE_MEMORY32, *PDBGKD_WRITE_MEMORY32;
523
524 typedef struct _DBGKD_WRITE_MEMORY64
525 {
526 ULONG64 TargetBaseAddress;
527 ULONG TransferCount;
528 ULONG ActualBytesWritten;
529 } DBGKD_WRITE_MEMORY64, *PDBGKD_WRITE_MEMORY64;
530
531 typedef struct _DBGKD_GET_CONTEXT
532 {
533 ULONG Unused;
534 } DBGKD_GET_CONTEXT, *PDBGKD_GET_CONTEXT;
535
536 typedef struct _DBGKD_SET_CONTEXT
537 {
538 ULONG ContextFlags;
539 } DBGKD_SET_CONTEXT, *PDBGKD_SET_CONTEXT;
540
541 typedef struct _DBGKD_WRITE_BREAKPOINT32
542 {
543 ULONG BreakPointAddress;
544 ULONG BreakPointHandle;
545 } DBGKD_WRITE_BREAKPOINT32, *PDBGKD_WRITE_BREAKPOINT32;
546
547 typedef struct _DBGKD_WRITE_BREAKPOINT64
548 {
549 ULONG64 BreakPointAddress;
550 ULONG BreakPointHandle;
551 } DBGKD_WRITE_BREAKPOINT64, *PDBGKD_WRITE_BREAKPOINT64;
552
553 typedef struct _DBGKD_RESTORE_BREAKPOINT
554 {
555 ULONG BreakPointHandle;
556 } DBGKD_RESTORE_BREAKPOINT, *PDBGKD_RESTORE_BREAKPOINT;
557
558 typedef struct _DBGKD_CONTINUE
559 {
560 NTSTATUS ContinueStatus;
561 } DBGKD_CONTINUE, *PDBGKD_CONTINUE;
562
563 #include <pshpack4.h>
564 typedef struct _DBGKD_CONTINUE2
565 {
566 NTSTATUS ContinueStatus;
567 union
568 {
569 DBGKD_CONTROL_SET ControlSet;
570 DBGKD_ANY_CONTROL_SET AnyControlSet;
571 };
572 } DBGKD_CONTINUE2, *PDBGKD_CONTINUE2;
573 #include <poppack.h>
574
575 typedef struct _DBGKD_READ_WRITE_IO32
576 {
577 ULONG IoAddress;
578 ULONG DataSize;
579 ULONG DataValue;
580 } DBGKD_READ_WRITE_IO32, *PDBGKD_READ_WRITE_IO32;
581
582 typedef struct _DBGKD_READ_WRITE_IO64
583 {
584 ULONG64 IoAddress;
585 ULONG DataSize;
586 ULONG DataValue;
587 } DBGKD_READ_WRITE_IO64, *PDBGKD_READ_WRITE_IO64;
588
589 typedef struct _DBGKD_READ_WRITE_IO_EXTENDED32
590 {
591 ULONG DataSize;
592 ULONG InterfaceType;
593 ULONG BusNumber;
594 ULONG AddressSpace;
595 ULONG IoAddress;
596 ULONG DataValue;
597 } DBGKD_READ_WRITE_IO_EXTENDED32, *PDBGKD_READ_WRITE_IO_EXTENDED32;
598
599 typedef struct _DBGKD_READ_WRITE_IO_EXTENDED64
600 {
601 ULONG DataSize;
602 ULONG InterfaceType;
603 ULONG BusNumber;
604 ULONG AddressSpace;
605 ULONG64 IoAddress;
606 ULONG DataValue;
607 } DBGKD_READ_WRITE_IO_EXTENDED64, *PDBGKD_READ_WRITE_IO_EXTENDED64;
608
609 typedef struct _DBGKD_READ_WRITE_MSR
610 {
611 ULONG Msr;
612 ULONG DataValueLow;
613 ULONG DataValueHigh;
614 } DBGKD_READ_WRITE_MSR, *PDBGKD_READ_WRITE_MSR;
615
616 typedef struct _DBGKD_QUERY_SPECIAL_CALLS
617 {
618 ULONG NumberOfSpecialCalls;
619 } DBGKD_QUERY_SPECIAL_CALLS, *PDBGKD_QUERY_SPECIAL_CALLS;
620
621 typedef struct _DBGKD_SET_SPECIAL_CALL32
622 {
623 ULONG SpecialCall;
624 } DBGKD_SET_SPECIAL_CALL32, *PDBGKD_SET_SPECIAL_CALL32;
625
626 typedef struct _DBGKD_SET_SPECIAL_CALL64
627 {
628 ULONG64 SpecialCall;
629 } DBGKD_SET_SPECIAL_CALL64, *PDBGKD_SET_SPECIAL_CALL64;
630
631 typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT32
632 {
633 ULONG BreakpointAddress;
634 ULONG Flags;
635 } DBGKD_SET_INTERNAL_BREAKPOINT32, *PDBGKD_SET_INTERNAL_BREAKPOINT32;
636
637 typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT64
638 {
639 ULONG64 BreakpointAddress;
640 ULONG Flags;
641 } DBGKD_SET_INTERNAL_BREAKPOINT64, *PDBGKD_SET_INTERNAL_BREAKPOINT64;
642
643 typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT32
644 {
645 ULONG BreakpointAddress;
646 ULONG Flags;
647 ULONG Calls;
648 ULONG MaxCallsPerPeriod;
649 ULONG MinInstructions;
650 ULONG MaxInstructions;
651 ULONG TotalInstructions;
652 } DBGKD_GET_INTERNAL_BREAKPOINT32, *PDBGKD_GET_INTERNAL_BREAKPOINT32;
653
654 typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT64
655 {
656 ULONG64 BreakpointAddress;
657 ULONG Flags;
658 ULONG Calls;
659 ULONG MaxCallsPerPeriod;
660 ULONG MinInstructions;
661 ULONG MaxInstructions;
662 ULONG TotalInstructions;
663 } DBGKD_GET_INTERNAL_BREAKPOINT64, *PDBGKD_GET_INTERNAL_BREAKPOINT64;
664
665 typedef struct _DBGKD_BREAKPOINTEX
666 {
667 ULONG BreakPointCount;
668 NTSTATUS ContinueStatus;
669 } DBGKD_BREAKPOINTEX, *PDBGKD_BREAKPOINTEX;
670
671 typedef struct _DBGKD_SEARCH_MEMORY
672 {
673 union
674 {
675 ULONG64 SearchAddress;
676 ULONG64 FoundAddress;
677 };
678 ULONG64 SearchLength;
679 ULONG PatternLength;
680 } DBGKD_SEARCH_MEMORY, *PDBGKD_SEARCH_MEMORY;
681
682 typedef struct _DBGKD_GET_SET_BUS_DATA
683 {
684 ULONG BusDataType;
685 ULONG BusNumber;
686 ULONG SlotNumber;
687 ULONG Offset;
688 ULONG Length;
689 } DBGKD_GET_SET_BUS_DATA, *PDBGKD_GET_SET_BUS_DATA;
690
691 typedef struct _DBGKD_FILL_MEMORY
692 {
693 ULONG64 Address;
694 ULONG Length;
695 USHORT Flags;
696 USHORT PatternLength;
697 } DBGKD_FILL_MEMORY, *PDBGKD_FILL_MEMORY;
698
699 typedef struct _DBGKD_QUERY_MEMORY
700 {
701 ULONG64 Address;
702 ULONG64 Reserved;
703 ULONG AddressSpace;
704 ULONG Flags;
705 } DBGKD_QUERY_MEMORY, *PDBGKD_QUERY_MEMORY;
706
707 typedef struct _DBGKD_SWITCH_PARTITION
708 {
709 ULONG Partition;
710 } DBGKD_SWITCH_PARTITION;
711
712 //
713 // DBGKD Structure for Manipulate
714 //
715 typedef struct _DBGKD_MANIPULATE_STATE32
716 {
717 ULONG ApiNumber;
718 USHORT ProcessorLevel;
719 USHORT Processor;
720 NTSTATUS ReturnStatus;
721 union
722 {
723 DBGKD_READ_MEMORY32 ReadMemory;
724 DBGKD_WRITE_MEMORY32 WriteMemory;
725 DBGKD_READ_MEMORY64 ReadMemory64;
726 DBGKD_WRITE_MEMORY64 WriteMemory64;
727 DBGKD_GET_CONTEXT GetContext;
728 DBGKD_SET_CONTEXT SetContext;
729 DBGKD_WRITE_BREAKPOINT32 WriteBreakPoint;
730 DBGKD_RESTORE_BREAKPOINT RestoreBreakPoint;
731 DBGKD_CONTINUE Continue;
732 DBGKD_CONTINUE2 Continue2;
733 DBGKD_READ_WRITE_IO32 ReadWriteIo;
734 DBGKD_READ_WRITE_IO_EXTENDED32 ReadWriteIoExtended;
735 DBGKD_QUERY_SPECIAL_CALLS QuerySpecialCalls;
736 DBGKD_SET_SPECIAL_CALL32 SetSpecialCall;
737 DBGKD_SET_INTERNAL_BREAKPOINT32 SetInternalBreakpoint;
738 DBGKD_GET_INTERNAL_BREAKPOINT32 GetInternalBreakpoint;
739 DBGKD_GET_VERSION32 GetVersion32;
740 DBGKD_BREAKPOINTEX BreakPointEx;
741 DBGKD_READ_WRITE_MSR ReadWriteMsr;
742 DBGKD_SEARCH_MEMORY SearchMemory;
743 DBGKD_GET_SET_BUS_DATA GetSetBusData;
744 DBGKD_FILL_MEMORY FillMemory;
745 DBGKD_QUERY_MEMORY QueryMemory;
746 DBGKD_SWITCH_PARTITION SwitchPartition;
747 } u;
748 } DBGKD_MANIPULATE_STATE32, *PDBGKD_MANIPULATE_STATE32;
749
750 typedef struct _DBGKD_MANIPULATE_STATE64
751 {
752 ULONG ApiNumber;
753 USHORT ProcessorLevel;
754 USHORT Processor;
755 NTSTATUS ReturnStatus;
756 union
757 {
758 DBGKD_READ_MEMORY64 ReadMemory;
759 DBGKD_WRITE_MEMORY64 WriteMemory;
760 DBGKD_GET_CONTEXT GetContext;
761 DBGKD_SET_CONTEXT SetContext;
762 DBGKD_WRITE_BREAKPOINT64 WriteBreakPoint;
763 DBGKD_RESTORE_BREAKPOINT RestoreBreakPoint;
764 DBGKD_CONTINUE Continue;
765 DBGKD_CONTINUE2 Continue2;
766 DBGKD_READ_WRITE_IO64 ReadWriteIo;
767 DBGKD_READ_WRITE_IO_EXTENDED64 ReadWriteIoExtended;
768 DBGKD_QUERY_SPECIAL_CALLS QuerySpecialCalls;
769 DBGKD_SET_SPECIAL_CALL64 SetSpecialCall;
770 DBGKD_SET_INTERNAL_BREAKPOINT64 SetInternalBreakpoint;
771 DBGKD_GET_INTERNAL_BREAKPOINT64 GetInternalBreakpoint;
772 DBGKD_GET_VERSION64 GetVersion64;
773 DBGKD_BREAKPOINTEX BreakPointEx;
774 DBGKD_READ_WRITE_MSR ReadWriteMsr;
775 DBGKD_SEARCH_MEMORY SearchMemory;
776 DBGKD_GET_SET_BUS_DATA GetSetBusData;
777 DBGKD_FILL_MEMORY FillMemory;
778 DBGKD_QUERY_MEMORY QueryMemory;
779 DBGKD_SWITCH_PARTITION SwitchPartition;
780 } u;
781 } DBGKD_MANIPULATE_STATE64, *PDBGKD_MANIPULATE_STATE64;
782
783 //
784 // File I/O Structure
785 //
786 typedef struct _DBGKD_CREATE_FILE
787 {
788 ULONG DesiredAccess;
789 ULONG FileAttributes;
790 ULONG ShareAccess;
791 ULONG CreateDisposition;
792 ULONG CreateOptions;
793 ULONG64 Handle;
794 ULONG64 Length;
795 } DBGKD_CREATE_FILE, *PDBGKD_CREATE_FILE;
796
797 typedef struct _DBGKD_READ_FILE
798 {
799 ULONG64 Handle;
800 ULONG64 Offset;
801 ULONG Length;
802 } DBGKD_READ_FILE, *PDBGKD_READ_FILE;
803
804 typedef struct _DBGKD_WRITE_FILE
805 {
806 ULONG64 Handle;
807 ULONG64 Offset;
808 ULONG Length;
809 } DBGKD_WRITE_FILE, *PDBGKD_WRITE_FILE;
810
811 typedef struct _DBGKD_CLOSE_FILE
812 {
813 ULONG64 Handle;
814 } DBGKD_CLOSE_FILE, *PDBGKD_CLOSE_FILE;
815
816 typedef struct _DBGKD_FILE_IO
817 {
818 ULONG ApiNumber;
819 ULONG Status;
820 union
821 {
822 ULONG64 ReserveSpace[7];
823 DBGKD_CREATE_FILE CreateFile;
824 DBGKD_READ_FILE ReadFile;
825 DBGKD_WRITE_FILE WriteFile;
826 DBGKD_CLOSE_FILE CloseFile;
827 } u;
828 } DBGKD_FILE_IO, *PDBGKD_FILE_IO;
829
830
831 //
832 // Control Request Structure
833 //
834 typedef struct _DBGKD_REQUEST_BREAKPOINT
835 {
836 ULONG HardwareBreakPointNumber;
837 ULONG Available;
838 } DBGKD_REQUEST_BREAKPOINT, *PDBGKD_REQUEST_BREAKPOINT;
839
840 typedef struct _DBGKD_RELEASE_BREAKPOINT
841 {
842 ULONG HardwareBreakPointNumber;
843 ULONG Released;
844 } DBGKD_RELEASE_BREAKPOINT, *PDBGKD_RELEASE_BREAKPOINT;
845
846 typedef struct _DBGKD_CONTROL_REQUEST
847 {
848 ULONG ApiNumber;
849 union
850 {
851 DBGKD_REQUEST_BREAKPOINT RequestBreakpoint;
852 DBGKD_RELEASE_BREAKPOINT ReleaseBreakpoint;
853 } u;
854 } DBGKD_CONTROL_REQUEST, *PDBGKD_CONTROL_REQUEST;
855
856 //
857 // Trace I/O Structure
858 //
859 typedef struct _DBGKD_PRINT_TRACE
860 {
861 ULONG LengthOfData;
862 } DBGKD_PRINT_TRACE, *PDBGKD_PRINT_TRACE;
863
864 typedef struct _DBGKD_TRACE_IO
865 {
866 ULONG ApiNumber;
867 USHORT ProcessorLevel;
868 USHORT Processor;
869 union
870 {
871 ULONG64 ReserveSpace[7];
872 DBGKD_PRINT_TRACE PrintTrace;
873 } u;
874 } DBGKD_TRACE_IO, *PDBGKD_TRACE_IO;
875
876 #if defined(_M_AMD64)
877
878 #define CopyExceptionRecord(Ex64From, Ex64To) \
879 RtlCopyMemory(Ex64To, Ex64From, sizeof(EXCEPTION_RECORD64))
880
881 #else
882
883 FORCEINLINE
884 VOID
885 ExceptionRecord32To64(IN PEXCEPTION_RECORD32 Ex32,
886 OUT PEXCEPTION_RECORD64 Ex64)
887 {
888 ULONG i;
889
890 Ex64->ExceptionCode = Ex32->ExceptionCode;
891 Ex64->ExceptionFlags = Ex32->ExceptionFlags;
892 Ex64->ExceptionRecord = Ex32->ExceptionRecord;
893 COPYSE(Ex64,Ex32,ExceptionAddress);
894 Ex64->NumberParameters = Ex32->NumberParameters;
895
896 for (i = 0; i < EXCEPTION_MAXIMUM_PARAMETERS; i++)
897 {
898 COPYSE(Ex64,Ex32,ExceptionInformation[i]);
899 }
900 }
901
902 #define CopyExceptionRecord(Ex32From, Ex64To) \
903 ExceptionRecord32To64((PEXCEPTION_RECORD32)Ex32From, Ex64To)
904
905 #endif
906
907 #endif