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