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