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