[KD64]
[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 // Control Space types
199 //
200 #define DEBUG_CONTROL_SPACE_KPCR 0
201 #define DEBUG_CONTROL_SPACE_KPRCB 1
202 #define DEBUG_CONTROL_SPACE_KSPECIAL 2
203 #define DEBUG_CONTROL_SPACE_KTHREAD 3
204 #define X86_DEBUG_CONTROL_SPACE_KSPECIAL 716
205
206
207 //
208 // KD Packet Structure
209 //
210 typedef struct _KD_PACKET
211 {
212 ULONG PacketLeader;
213 USHORT PacketType;
214 USHORT ByteCount;
215 ULONG PacketId;
216 ULONG Checksum;
217 } KD_PACKET, *PKD_PACKET;
218
219 //
220 // KD Context
221 //
222 typedef struct _KD_CONTEXT
223 {
224 ULONG KdpDefaultRetries;
225 BOOLEAN KdpControlCPending;
226 } KD_CONTEXT, *PKD_CONTEXT;
227
228 //
229 // Control Sets for Supported Architectures
230 //
231 #include <pshpack4.h>
232 typedef struct _X86_DBGKD_CONTROL_SET
233 {
234 ULONG TraceFlag;
235 ULONG Dr7;
236 ULONG CurrentSymbolStart;
237 ULONG CurrentSymbolEnd;
238 } X86_DBGKD_CONTROL_SET, *PX86_DBGKD_CONTROL_SET;
239
240 typedef struct _ALPHA_DBGKD_CONTROL_SET
241 {
242 ULONG __padding;
243 } ALPHA_DBGKD_CONTROL_SET, *PALPHA_DBGKD_CONTROL_SET;
244
245 typedef struct _IA64_DBGKD_CONTROL_SET
246 {
247 ULONG Continue;
248 ULONG64 CurrentSymbolStart;
249 ULONG64 CurrentSymbolEnd;
250 } IA64_DBGKD_CONTROL_SET, *PIA64_DBGKD_CONTROL_SET;
251
252 typedef struct _AMD64_DBGKD_CONTROL_SET
253 {
254 ULONG TraceFlag;
255 ULONG64 Dr7;
256 ULONG64 CurrentSymbolStart;
257 ULONG64 CurrentSymbolEnd;
258 } AMD64_DBGKD_CONTROL_SET, *PAMD64_DBGKD_CONTROL_SET;
259
260 typedef struct _ARM_DBGKD_CONTROL_SET
261 {
262 ULONG Continue;
263 ULONG CurrentSymbolStart;
264 ULONG CurrentSymbolEnd;
265 } ARM_DBGKD_CONTROL_SET, *PARM_DBGKD_CONTROL_SET;
266
267 typedef struct _DBGKD_ANY_CONTROL_SET
268 {
269 union
270 {
271 X86_DBGKD_CONTROL_SET X86ControlSet;
272 ALPHA_DBGKD_CONTROL_SET AlphaControlSet;
273 IA64_DBGKD_CONTROL_SET IA64ControlSet;
274 AMD64_DBGKD_CONTROL_SET Amd64ControlSet;
275 ARM_DBGKD_CONTROL_SET ARMControlSet;
276 };
277 } DBGKD_ANY_CONTROL_SET, *PDBGKD_ANY_CONTROL_SET;
278 #include <poppack.h>
279
280 #if defined(_M_IX86)
281 typedef X86_DBGKD_CONTROL_SET DBGKD_CONTROL_SET, *PDBGKD_CONTROL_SET;
282 #elif defined(_M_AMD64)
283 typedef AMD64_DBGKD_CONTROL_SET DBGKD_CONTROL_SET, *PDBGKD_CONTROL_SET;
284 #elif defined(_M_ARM)
285 typedef ARM_DBGKD_CONTROL_SET DBGKD_CONTROL_SET, *PDBGKD_CONTROL_SET;
286 #else
287 #error Unsupported Architecture
288 #endif
289
290 //
291 // DBGKM Structure for Exceptions
292 //
293 typedef struct _DBGKM_EXCEPTION32
294 {
295 EXCEPTION_RECORD32 ExceptionRecord;
296 ULONG FirstChance;
297 } DBGKM_EXCEPTION32, *PDBGKM_EXCEPTION32;
298
299 typedef struct _DBGKM_EXCEPTION64
300 {
301 EXCEPTION_RECORD64 ExceptionRecord;
302 ULONG FirstChance;
303 } DBGKM_EXCEPTION64, *PDBGKM_EXCEPTION64;
304
305 //
306 // DBGKD Structure for State Change
307 //
308 typedef struct _X86_DBGKD_CONTROL_REPORT
309 {
310 ULONG Dr6;
311 ULONG Dr7;
312 USHORT InstructionCount;
313 USHORT ReportFlags;
314 UCHAR InstructionStream[DBGKD_MAXSTREAM];
315 USHORT SegCs;
316 USHORT SegDs;
317 USHORT SegEs;
318 USHORT SegFs;
319 ULONG EFlags;
320 } X86_DBGKD_CONTROL_REPORT, *PX86_DBGKD_CONTROL_REPORT;
321
322 typedef struct _ALPHA_DBGKD_CONTROL_REPORT
323 {
324 ULONG InstructionCount;
325 UCHAR InstructionStream[DBGKD_MAXSTREAM];
326 } ALPHA_DBGKD_CONTROL_REPORT, *PALPHA_DBGKD_CONTROL_REPORT;
327
328 typedef struct _IA64_DBGKD_CONTROL_REPORT
329 {
330 ULONG InstructionCount;
331 UCHAR InstructionStream[DBGKD_MAXSTREAM];
332 } IA64_DBGKD_CONTROL_REPORT, *PIA64_DBGKD_CONTROL_REPORT;
333
334 typedef struct _AMD64_DBGKD_CONTROL_REPORT
335 {
336 ULONG64 Dr6;
337 ULONG64 Dr7;
338 ULONG EFlags;
339 USHORT InstructionCount;
340 USHORT ReportFlags;
341 UCHAR InstructionStream[DBGKD_MAXSTREAM];
342 USHORT SegCs;
343 USHORT SegDs;
344 USHORT SegEs;
345 USHORT SegFs;
346 } AMD64_DBGKD_CONTROL_REPORT, *PAMD64_DBGKD_CONTROL_REPORT;
347
348 typedef struct _ARM_DBGKD_CONTROL_REPORT
349 {
350 ULONG Cpsr;
351 ULONG InstructionCount;
352 UCHAR InstructionStream[DBGKD_MAXSTREAM];
353 } ARM_DBGKD_CONTROL_REPORT, *PARM_DBGKD_CONTROL_REPORT;
354
355 typedef struct _DBGKD_ANY_CONTROL_REPORT
356 {
357 union
358 {
359 X86_DBGKD_CONTROL_REPORT X86ControlReport;
360 ALPHA_DBGKD_CONTROL_REPORT AlphaControlReport;
361 IA64_DBGKD_CONTROL_REPORT IA64ControlReport;
362 AMD64_DBGKD_CONTROL_REPORT Amd64ControlReport;
363 ARM_DBGKD_CONTROL_REPORT ARMControlReport;
364 };
365 } DBGKD_ANY_CONTROL_REPORT, *PDBGKD_ANY_CONTROL_REPORT;
366
367 #if defined(_M_IX86)
368 typedef X86_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT, *PDBGKD_CONTROL_REPORT;
369 #elif defined(_M_AMD64)
370 typedef AMD64_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT, *PDBGKD_CONTROL_REPORT;
371 #elif defined(_M_ARM)
372 typedef ARM_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT, *PDBGKD_CONTROL_REPORT;
373 #else
374 #error Unsupported Architecture
375 #endif
376
377 //
378 // DBGKD Structure for Debug I/O Type Print String
379 //
380 typedef struct _DBGKD_PRINT_STRING
381 {
382 ULONG LengthOfString;
383 } DBGKD_PRINT_STRING, *PDBGKD_PRINT_STRING;
384
385 //
386 // DBGKD Structure for Debug I/O Type Get String
387 //
388 typedef struct _DBGKD_GET_STRING
389 {
390 ULONG LengthOfPromptString;
391 ULONG LengthOfStringRead;
392 } DBGKD_GET_STRING, *PDBGKD_GET_STRING;
393
394 //
395 // DBGKD Structure for Debug I/O
396 //
397 typedef struct _DBGKD_DEBUG_IO
398 {
399 ULONG ApiNumber;
400 USHORT ProcessorLevel;
401 USHORT Processor;
402 union
403 {
404 DBGKD_PRINT_STRING PrintString;
405 DBGKD_GET_STRING GetString;
406 } u;
407 } DBGKD_DEBUG_IO, *PDBGKD_DEBUG_IO;
408
409 //
410 // DBGkD Structure for Command String
411 //
412 typedef struct _DBGKD_COMMAND_STRING
413 {
414 ULONG Flags;
415 ULONG Reserved1;
416 ULONG64 Reserved2[7];
417 } DBGKD_COMMAND_STRING, *PDBGKD_COMMAND_STRING;
418
419 //
420 // DBGKD Structure for Load Symbols
421 //
422 typedef struct _DBGKD_LOAD_SYMBOLS32
423 {
424 ULONG PathNameLength;
425 ULONG BaseOfDll;
426 ULONG ProcessId;
427 ULONG CheckSum;
428 ULONG SizeOfImage;
429 BOOLEAN UnloadSymbols;
430 } DBGKD_LOAD_SYMBOLS32, *PDBGKD_LOAD_SYMBOLS32;
431
432 typedef struct _DBGKD_LOAD_SYMBOLS64
433 {
434 ULONG PathNameLength;
435 ULONG64 BaseOfDll;
436 ULONG64 ProcessId;
437 ULONG CheckSum;
438 ULONG SizeOfImage;
439 BOOLEAN UnloadSymbols;
440 } DBGKD_LOAD_SYMBOLS64, *PDBGKD_LOAD_SYMBOLS64;
441
442 //
443 // DBGKD Structure for Wait State Change
444 //
445
446 typedef struct _DBGKD_WAIT_STATE_CHANGE32
447 {
448 ULONG NewState;
449 USHORT ProcessorLevel;
450 USHORT Processor;
451 ULONG NumberProcessors;
452 ULONG Thread;
453 ULONG ProgramCounter;
454 union
455 {
456 DBGKM_EXCEPTION32 Exception;
457 DBGKD_LOAD_SYMBOLS32 LoadSymbols;
458 } u;
459 DBGKD_CONTROL_REPORT ControlReport;
460 CONTEXT Context;
461 } DBGKD_WAIT_STATE_CHANGE32, *PDBGKD_WAIT_STATE_CHANGE32;
462
463 typedef struct _DBGKD_WAIT_STATE_CHANGE64
464 {
465 ULONG NewState;
466 USHORT ProcessorLevel;
467 USHORT Processor;
468 ULONG NumberProcessors;
469 ULONG64 Thread;
470 ULONG64 ProgramCounter;
471 union
472 {
473 DBGKM_EXCEPTION64 Exception;
474 DBGKD_LOAD_SYMBOLS64 LoadSymbols;
475 } u;
476 DBGKD_CONTROL_REPORT ControlReport;
477 CONTEXT Context;
478 } DBGKD_WAIT_STATE_CHANGE64, *PDBGKD_WAIT_STATE_CHANGE64;
479
480 typedef struct _DBGKD_ANY_WAIT_STATE_CHANGE
481 {
482 ULONG NewState;
483 USHORT ProcessorLevel;
484 USHORT Processor;
485 ULONG NumberProcessors;
486 ULONG64 Thread;
487 ULONG64 ProgramCounter;
488 union
489 {
490 DBGKM_EXCEPTION64 Exception;
491 DBGKD_LOAD_SYMBOLS64 LoadSymbols;
492 DBGKD_COMMAND_STRING CommandString;
493 } u;
494 union
495 {
496 DBGKD_CONTROL_REPORT ControlReport;
497 DBGKD_ANY_CONTROL_REPORT AnyControlReport;
498 };
499 } DBGKD_ANY_WAIT_STATE_CHANGE, *PDBGKD_ANY_WAIT_STATE_CHANGE;
500
501 //
502 // DBGKD Manipulate Structures
503 //
504 typedef struct _DBGKD_READ_MEMORY32
505 {
506 ULONG TargetBaseAddress;
507 ULONG TransferCount;
508 ULONG ActualBytesRead;
509 } DBGKD_READ_MEMORY32, *PDBGKD_READ_MEMORY32;
510
511 typedef struct _DBGKD_READ_MEMORY64
512 {
513 ULONG64 TargetBaseAddress;
514 ULONG TransferCount;
515 ULONG ActualBytesRead;
516 } DBGKD_READ_MEMORY64, *PDBGKD_READ_MEMORY64;
517
518 typedef struct _DBGKD_WRITE_MEMORY32
519 {
520 ULONG TargetBaseAddress;
521 ULONG TransferCount;
522 ULONG ActualBytesWritten;
523 } DBGKD_WRITE_MEMORY32, *PDBGKD_WRITE_MEMORY32;
524
525 typedef struct _DBGKD_WRITE_MEMORY64
526 {
527 ULONG64 TargetBaseAddress;
528 ULONG TransferCount;
529 ULONG ActualBytesWritten;
530 } DBGKD_WRITE_MEMORY64, *PDBGKD_WRITE_MEMORY64;
531
532 typedef struct _DBGKD_GET_CONTEXT
533 {
534 ULONG Unused;
535 } DBGKD_GET_CONTEXT, *PDBGKD_GET_CONTEXT;
536
537 typedef struct _DBGKD_SET_CONTEXT
538 {
539 ULONG ContextFlags;
540 } DBGKD_SET_CONTEXT, *PDBGKD_SET_CONTEXT;
541
542 typedef struct _DBGKD_WRITE_BREAKPOINT32
543 {
544 ULONG BreakPointAddress;
545 ULONG BreakPointHandle;
546 } DBGKD_WRITE_BREAKPOINT32, *PDBGKD_WRITE_BREAKPOINT32;
547
548 typedef struct _DBGKD_WRITE_BREAKPOINT64
549 {
550 ULONG64 BreakPointAddress;
551 ULONG BreakPointHandle;
552 } DBGKD_WRITE_BREAKPOINT64, *PDBGKD_WRITE_BREAKPOINT64;
553
554 typedef struct _DBGKD_RESTORE_BREAKPOINT
555 {
556 ULONG BreakPointHandle;
557 } DBGKD_RESTORE_BREAKPOINT, *PDBGKD_RESTORE_BREAKPOINT;
558
559 typedef struct _DBGKD_CONTINUE
560 {
561 NTSTATUS ContinueStatus;
562 } DBGKD_CONTINUE, *PDBGKD_CONTINUE;
563
564 #include <pshpack4.h>
565 typedef struct _DBGKD_CONTINUE2
566 {
567 NTSTATUS ContinueStatus;
568 union
569 {
570 DBGKD_CONTROL_SET ControlSet;
571 DBGKD_ANY_CONTROL_SET AnyControlSet;
572 };
573 } DBGKD_CONTINUE2, *PDBGKD_CONTINUE2;
574 #include <poppack.h>
575
576 typedef struct _DBGKD_READ_WRITE_IO32
577 {
578 ULONG IoAddress;
579 ULONG DataSize;
580 ULONG DataValue;
581 } DBGKD_READ_WRITE_IO32, *PDBGKD_READ_WRITE_IO32;
582
583 typedef struct _DBGKD_READ_WRITE_IO64
584 {
585 ULONG64 IoAddress;
586 ULONG DataSize;
587 ULONG DataValue;
588 } DBGKD_READ_WRITE_IO64, *PDBGKD_READ_WRITE_IO64;
589
590 typedef struct _DBGKD_READ_WRITE_IO_EXTENDED32
591 {
592 ULONG DataSize;
593 ULONG InterfaceType;
594 ULONG BusNumber;
595 ULONG AddressSpace;
596 ULONG IoAddress;
597 ULONG DataValue;
598 } DBGKD_READ_WRITE_IO_EXTENDED32, *PDBGKD_READ_WRITE_IO_EXTENDED32;
599
600 typedef struct _DBGKD_READ_WRITE_IO_EXTENDED64
601 {
602 ULONG DataSize;
603 ULONG InterfaceType;
604 ULONG BusNumber;
605 ULONG AddressSpace;
606 ULONG64 IoAddress;
607 ULONG DataValue;
608 } DBGKD_READ_WRITE_IO_EXTENDED64, *PDBGKD_READ_WRITE_IO_EXTENDED64;
609
610 typedef struct _DBGKD_READ_WRITE_MSR
611 {
612 ULONG Msr;
613 ULONG DataValueLow;
614 ULONG DataValueHigh;
615 } DBGKD_READ_WRITE_MSR, *PDBGKD_READ_WRITE_MSR;
616
617 typedef struct _DBGKD_QUERY_SPECIAL_CALLS
618 {
619 ULONG NumberOfSpecialCalls;
620 } DBGKD_QUERY_SPECIAL_CALLS, *PDBGKD_QUERY_SPECIAL_CALLS;
621
622 typedef struct _DBGKD_SET_SPECIAL_CALL32
623 {
624 ULONG SpecialCall;
625 } DBGKD_SET_SPECIAL_CALL32, *PDBGKD_SET_SPECIAL_CALL32;
626
627 typedef struct _DBGKD_SET_SPECIAL_CALL64
628 {
629 ULONG64 SpecialCall;
630 } DBGKD_SET_SPECIAL_CALL64, *PDBGKD_SET_SPECIAL_CALL64;
631
632 typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT32
633 {
634 ULONG BreakpointAddress;
635 ULONG Flags;
636 } DBGKD_SET_INTERNAL_BREAKPOINT32, *PDBGKD_SET_INTERNAL_BREAKPOINT32;
637
638 typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT64
639 {
640 ULONG64 BreakpointAddress;
641 ULONG Flags;
642 } DBGKD_SET_INTERNAL_BREAKPOINT64, *PDBGKD_SET_INTERNAL_BREAKPOINT64;
643
644 typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT32
645 {
646 ULONG BreakpointAddress;
647 ULONG Flags;
648 ULONG Calls;
649 ULONG MaxCallsPerPeriod;
650 ULONG MinInstructions;
651 ULONG MaxInstructions;
652 ULONG TotalInstructions;
653 } DBGKD_GET_INTERNAL_BREAKPOINT32, *PDBGKD_GET_INTERNAL_BREAKPOINT32;
654
655 typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT64
656 {
657 ULONG64 BreakpointAddress;
658 ULONG Flags;
659 ULONG Calls;
660 ULONG MaxCallsPerPeriod;
661 ULONG MinInstructions;
662 ULONG MaxInstructions;
663 ULONG TotalInstructions;
664 } DBGKD_GET_INTERNAL_BREAKPOINT64, *PDBGKD_GET_INTERNAL_BREAKPOINT64;
665
666 typedef struct _DBGKD_BREAKPOINTEX
667 {
668 ULONG BreakPointCount;
669 NTSTATUS ContinueStatus;
670 } DBGKD_BREAKPOINTEX, *PDBGKD_BREAKPOINTEX;
671
672 typedef struct _DBGKD_SEARCH_MEMORY
673 {
674 union
675 {
676 ULONG64 SearchAddress;
677 ULONG64 FoundAddress;
678 };
679 ULONG64 SearchLength;
680 ULONG PatternLength;
681 } DBGKD_SEARCH_MEMORY, *PDBGKD_SEARCH_MEMORY;
682
683 typedef struct _DBGKD_GET_SET_BUS_DATA
684 {
685 ULONG BusDataType;
686 ULONG BusNumber;
687 ULONG SlotNumber;
688 ULONG Offset;
689 ULONG Length;
690 } DBGKD_GET_SET_BUS_DATA, *PDBGKD_GET_SET_BUS_DATA;
691
692 typedef struct _DBGKD_FILL_MEMORY
693 {
694 ULONG64 Address;
695 ULONG Length;
696 USHORT Flags;
697 USHORT PatternLength;
698 } DBGKD_FILL_MEMORY, *PDBGKD_FILL_MEMORY;
699
700 typedef struct _DBGKD_QUERY_MEMORY
701 {
702 ULONG64 Address;
703 ULONG64 Reserved;
704 ULONG AddressSpace;
705 ULONG Flags;
706 } DBGKD_QUERY_MEMORY, *PDBGKD_QUERY_MEMORY;
707
708 typedef struct _DBGKD_SWITCH_PARTITION
709 {
710 ULONG Partition;
711 } DBGKD_SWITCH_PARTITION;
712
713 //
714 // DBGKD Structure for Manipulate
715 //
716 typedef struct _DBGKD_MANIPULATE_STATE32
717 {
718 ULONG ApiNumber;
719 USHORT ProcessorLevel;
720 USHORT Processor;
721 NTSTATUS ReturnStatus;
722 union
723 {
724 DBGKD_READ_MEMORY32 ReadMemory;
725 DBGKD_WRITE_MEMORY32 WriteMemory;
726 DBGKD_READ_MEMORY64 ReadMemory64;
727 DBGKD_WRITE_MEMORY64 WriteMemory64;
728 DBGKD_GET_CONTEXT GetContext;
729 DBGKD_SET_CONTEXT SetContext;
730 DBGKD_WRITE_BREAKPOINT32 WriteBreakPoint;
731 DBGKD_RESTORE_BREAKPOINT RestoreBreakPoint;
732 DBGKD_CONTINUE Continue;
733 DBGKD_CONTINUE2 Continue2;
734 DBGKD_READ_WRITE_IO32 ReadWriteIo;
735 DBGKD_READ_WRITE_IO_EXTENDED32 ReadWriteIoExtended;
736 DBGKD_QUERY_SPECIAL_CALLS QuerySpecialCalls;
737 DBGKD_SET_SPECIAL_CALL32 SetSpecialCall;
738 DBGKD_SET_INTERNAL_BREAKPOINT32 SetInternalBreakpoint;
739 DBGKD_GET_INTERNAL_BREAKPOINT32 GetInternalBreakpoint;
740 DBGKD_GET_VERSION32 GetVersion32;
741 DBGKD_BREAKPOINTEX BreakPointEx;
742 DBGKD_READ_WRITE_MSR ReadWriteMsr;
743 DBGKD_SEARCH_MEMORY SearchMemory;
744 DBGKD_GET_SET_BUS_DATA GetSetBusData;
745 DBGKD_FILL_MEMORY FillMemory;
746 DBGKD_QUERY_MEMORY QueryMemory;
747 DBGKD_SWITCH_PARTITION SwitchPartition;
748 } u;
749 } DBGKD_MANIPULATE_STATE32, *PDBGKD_MANIPULATE_STATE32;
750
751 typedef struct _DBGKD_MANIPULATE_STATE64
752 {
753 ULONG ApiNumber;
754 USHORT ProcessorLevel;
755 USHORT Processor;
756 NTSTATUS ReturnStatus;
757 union
758 {
759 DBGKD_READ_MEMORY64 ReadMemory;
760 DBGKD_WRITE_MEMORY64 WriteMemory;
761 DBGKD_GET_CONTEXT GetContext;
762 DBGKD_SET_CONTEXT SetContext;
763 DBGKD_WRITE_BREAKPOINT64 WriteBreakPoint;
764 DBGKD_RESTORE_BREAKPOINT RestoreBreakPoint;
765 DBGKD_CONTINUE Continue;
766 DBGKD_CONTINUE2 Continue2;
767 DBGKD_READ_WRITE_IO64 ReadWriteIo;
768 DBGKD_READ_WRITE_IO_EXTENDED64 ReadWriteIoExtended;
769 DBGKD_QUERY_SPECIAL_CALLS QuerySpecialCalls;
770 DBGKD_SET_SPECIAL_CALL64 SetSpecialCall;
771 DBGKD_SET_INTERNAL_BREAKPOINT64 SetInternalBreakpoint;
772 DBGKD_GET_INTERNAL_BREAKPOINT64 GetInternalBreakpoint;
773 DBGKD_GET_VERSION64 GetVersion64;
774 DBGKD_BREAKPOINTEX BreakPointEx;
775 DBGKD_READ_WRITE_MSR ReadWriteMsr;
776 DBGKD_SEARCH_MEMORY SearchMemory;
777 DBGKD_GET_SET_BUS_DATA GetSetBusData;
778 DBGKD_FILL_MEMORY FillMemory;
779 DBGKD_QUERY_MEMORY QueryMemory;
780 DBGKD_SWITCH_PARTITION SwitchPartition;
781 } u;
782 } DBGKD_MANIPULATE_STATE64, *PDBGKD_MANIPULATE_STATE64;
783
784 //
785 // File I/O Structure
786 //
787 typedef struct _DBGKD_CREATE_FILE
788 {
789 ULONG DesiredAccess;
790 ULONG FileAttributes;
791 ULONG ShareAccess;
792 ULONG CreateDisposition;
793 ULONG CreateOptions;
794 ULONG64 Handle;
795 ULONG64 Length;
796 } DBGKD_CREATE_FILE, *PDBGKD_CREATE_FILE;
797
798 typedef struct _DBGKD_READ_FILE
799 {
800 ULONG64 Handle;
801 ULONG64 Offset;
802 ULONG Length;
803 } DBGKD_READ_FILE, *PDBGKD_READ_FILE;
804
805 typedef struct _DBGKD_WRITE_FILE
806 {
807 ULONG64 Handle;
808 ULONG64 Offset;
809 ULONG Length;
810 } DBGKD_WRITE_FILE, *PDBGKD_WRITE_FILE;
811
812 typedef struct _DBGKD_CLOSE_FILE
813 {
814 ULONG64 Handle;
815 } DBGKD_CLOSE_FILE, *PDBGKD_CLOSE_FILE;
816
817 typedef struct _DBGKD_FILE_IO
818 {
819 ULONG ApiNumber;
820 ULONG Status;
821 union
822 {
823 ULONG64 ReserveSpace[7];
824 DBGKD_CREATE_FILE CreateFile;
825 DBGKD_READ_FILE ReadFile;
826 DBGKD_WRITE_FILE WriteFile;
827 DBGKD_CLOSE_FILE CloseFile;
828 } u;
829 } DBGKD_FILE_IO, *PDBGKD_FILE_IO;
830
831
832 //
833 // Control Request Structure
834 //
835 typedef struct _DBGKD_REQUEST_BREAKPOINT
836 {
837 ULONG HardwareBreakPointNumber;
838 ULONG Available;
839 } DBGKD_REQUEST_BREAKPOINT, *PDBGKD_REQUEST_BREAKPOINT;
840
841 typedef struct _DBGKD_RELEASE_BREAKPOINT
842 {
843 ULONG HardwareBreakPointNumber;
844 ULONG Released;
845 } DBGKD_RELEASE_BREAKPOINT, *PDBGKD_RELEASE_BREAKPOINT;
846
847 typedef struct _DBGKD_CONTROL_REQUEST
848 {
849 ULONG ApiNumber;
850 union
851 {
852 DBGKD_REQUEST_BREAKPOINT RequestBreakpoint;
853 DBGKD_RELEASE_BREAKPOINT ReleaseBreakpoint;
854 } u;
855 } DBGKD_CONTROL_REQUEST, *PDBGKD_CONTROL_REQUEST;
856
857 //
858 // Trace I/O Structure
859 //
860 typedef struct _DBGKD_PRINT_TRACE
861 {
862 ULONG LengthOfData;
863 } DBGKD_PRINT_TRACE, *PDBGKD_PRINT_TRACE;
864
865 typedef struct _DBGKD_TRACE_IO
866 {
867 ULONG ApiNumber;
868 USHORT ProcessorLevel;
869 USHORT Processor;
870 union
871 {
872 ULONG64 ReserveSpace[7];
873 DBGKD_PRINT_TRACE PrintTrace;
874 } u;
875 } DBGKD_TRACE_IO, *PDBGKD_TRACE_IO;
876
877 #if defined(_M_AMD64)
878
879 #define CopyExceptionRecord(Ex64From, Ex64To) \
880 RtlCopyMemory(Ex64To, Ex64From, sizeof(EXCEPTION_RECORD64))
881
882 #else
883
884 FORCEINLINE
885 VOID
886 ExceptionRecord32To64(IN PEXCEPTION_RECORD32 Ex32,
887 OUT PEXCEPTION_RECORD64 Ex64)
888 {
889 ULONG i;
890
891 Ex64->ExceptionCode = Ex32->ExceptionCode;
892 Ex64->ExceptionFlags = Ex32->ExceptionFlags;
893 Ex64->ExceptionRecord = Ex32->ExceptionRecord;
894 COPYSE(Ex64,Ex32,ExceptionAddress);
895 Ex64->NumberParameters = Ex32->NumberParameters;
896
897 for (i = 0; i < EXCEPTION_MAXIMUM_PARAMETERS; i++)
898 {
899 COPYSE(Ex64,Ex32,ExceptionInformation[i]);
900 }
901 }
902
903 #define CopyExceptionRecord(Ex32From, Ex64To) \
904 ExceptionRecord32To64((PEXCEPTION_RECORD32)Ex32From, Ex64To)
905
906 #endif
907
908 #endif