Simplify definition of PIMAGE_NT_HEADERS
[reactos.git] / 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_WAIT_STATE_CHANGE32, *PDBGKD_WAIT_STATE_CHANGE32;
450
451 typedef struct _DBGKD_WAIT_STATE_CHANGE64
452 {
453 ULONG NewState;
454 USHORT ProcessorLevel;
455 USHORT Processor;
456 ULONG NumberProcessors;
457 ULONG64 Thread;
458 ULONG64 ProgramCounter;
459 union
460 {
461 DBGKM_EXCEPTION64 Exception;
462 DBGKD_LOAD_SYMBOLS64 LoadSymbols;
463 } u;
464 } DBGKD_WAIT_STATE_CHANGE64, *PDBGKD_WAIT_STATE_CHANGE64;
465
466 typedef struct _DBGKD_ANY_WAIT_STATE_CHANGE
467 {
468 ULONG NewState;
469 USHORT ProcessorLevel;
470 USHORT Processor;
471 ULONG NumberProcessors;
472 ULONG64 Thread;
473 ULONG64 ProgramCounter;
474 union
475 {
476 DBGKM_EXCEPTION64 Exception;
477 DBGKD_LOAD_SYMBOLS64 LoadSymbols;
478 DBGKD_COMMAND_STRING CommandString;
479 } u;
480 union
481 {
482 DBGKD_CONTROL_REPORT ControlReport;
483 DBGKD_ANY_CONTROL_REPORT AnyControlReport;
484 };
485 } DBGKD_ANY_WAIT_STATE_CHANGE, *PDBGKD_ANY_WAIT_STATE_CHANGE;
486
487 //
488 // DBGKD Manipulate Structures
489 //
490 typedef struct _DBGKD_READ_MEMORY32
491 {
492 ULONG TargetBaseAddress;
493 ULONG TransferCount;
494 ULONG ActualBytesRead;
495 } DBGKD_READ_MEMORY32, *PDBGKD_READ_MEMORY32;
496
497 typedef struct _DBGKD_READ_MEMORY64
498 {
499 ULONG64 TargetBaseAddress;
500 ULONG TransferCount;
501 ULONG ActualBytesRead;
502 } DBGKD_READ_MEMORY64, *PDBGKD_READ_MEMORY64;
503
504 typedef struct _DBGKD_WRITE_MEMORY32
505 {
506 ULONG TargetBaseAddress;
507 ULONG TransferCount;
508 ULONG ActualBytesWritten;
509 } DBGKD_WRITE_MEMORY32, *PDBGKD_WRITE_MEMORY32;
510
511 typedef struct _DBGKD_WRITE_MEMORY64
512 {
513 ULONG64 TargetBaseAddress;
514 ULONG TransferCount;
515 ULONG ActualBytesWritten;
516 } DBGKD_WRITE_MEMORY64, *PDBGKD_WRITE_MEMORY64;
517
518 typedef struct _DBGKD_GET_CONTEXT
519 {
520 ULONG Unused;
521 } DBGKD_GET_CONTEXT, *PDBGKD_GET_CONTEXT;
522
523 typedef struct _DBGKD_SET_CONTEXT
524 {
525 ULONG ContextFlags;
526 } DBGKD_SET_CONTEXT, *PDBGKD_SET_CONTEXT;
527
528 typedef struct _DBGKD_WRITE_BREAKPOINT32
529 {
530 ULONG BreakPointAddress;
531 ULONG BreakPointHandle;
532 } DBGKD_WRITE_BREAKPOINT32, *PDBGKD_WRITE_BREAKPOINT32;
533
534 typedef struct _DBGKD_WRITE_BREAKPOINT64
535 {
536 ULONG64 BreakPointAddress;
537 ULONG BreakPointHandle;
538 } DBGKD_WRITE_BREAKPOINT64, *PDBGKD_WRITE_BREAKPOINT64;
539
540 typedef struct _DBGKD_RESTORE_BREAKPOINT
541 {
542 ULONG BreakPointHandle;
543 } DBGKD_RESTORE_BREAKPOINT, *PDBGKD_RESTORE_BREAKPOINT;
544
545 typedef struct _DBGKD_CONTINUE
546 {
547 NTSTATUS ContinueStatus;
548 } DBGKD_CONTINUE, *PDBGKD_CONTINUE;
549
550 #include <pshpack4.h>
551 typedef struct _DBGKD_CONTINUE2
552 {
553 NTSTATUS ContinueStatus;
554 union
555 {
556 DBGKD_CONTROL_SET ControlSet;
557 DBGKD_ANY_CONTROL_SET AnyControlSet;
558 };
559 } DBGKD_CONTINUE2, *PDBGKD_CONTINUE2;
560 #include <poppack.h>
561
562 typedef struct _DBGKD_READ_WRITE_IO32
563 {
564 ULONG IoAddress;
565 ULONG DataSize;
566 ULONG DataValue;
567 } DBGKD_READ_WRITE_IO32, *PDBGKD_READ_WRITE_IO32;
568
569 typedef struct _DBGKD_READ_WRITE_IO64
570 {
571 ULONG64 IoAddress;
572 ULONG DataSize;
573 ULONG DataValue;
574 } DBGKD_READ_WRITE_IO64, *PDBGKD_READ_WRITE_IO64;
575
576 typedef struct _DBGKD_READ_WRITE_IO_EXTENDED32
577 {
578 ULONG DataSize;
579 ULONG InterfaceType;
580 ULONG BusNumber;
581 ULONG AddressSpace;
582 ULONG IoAddress;
583 ULONG DataValue;
584 } DBGKD_READ_WRITE_IO_EXTENDED32, *PDBGKD_READ_WRITE_IO_EXTENDED32;
585
586 typedef struct _DBGKD_READ_WRITE_IO_EXTENDED64
587 {
588 ULONG DataSize;
589 ULONG InterfaceType;
590 ULONG BusNumber;
591 ULONG AddressSpace;
592 ULONG64 IoAddress;
593 ULONG DataValue;
594 } DBGKD_READ_WRITE_IO_EXTENDED64, *PDBGKD_READ_WRITE_IO_EXTENDED64;
595
596 typedef struct _DBGKD_READ_WRITE_MSR
597 {
598 ULONG Msr;
599 ULONG DataValueLow;
600 ULONG DataValueHigh;
601 } DBGKD_READ_WRITE_MSR, *PDBGKD_READ_WRITE_MSR;
602
603 typedef struct _DBGKD_QUERY_SPECIAL_CALLS
604 {
605 ULONG NumberOfSpecialCalls;
606 } DBGKD_QUERY_SPECIAL_CALLS, *PDBGKD_QUERY_SPECIAL_CALLS;
607
608 typedef struct _DBGKD_SET_SPECIAL_CALL32
609 {
610 ULONG SpecialCall;
611 } DBGKD_SET_SPECIAL_CALL32, *PDBGKD_SET_SPECIAL_CALL32;
612
613 typedef struct _DBGKD_SET_SPECIAL_CALL64
614 {
615 ULONG64 SpecialCall;
616 } DBGKD_SET_SPECIAL_CALL64, *PDBGKD_SET_SPECIAL_CALL64;
617
618 typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT32
619 {
620 ULONG BreakpointAddress;
621 ULONG Flags;
622 } DBGKD_SET_INTERNAL_BREAKPOINT32, *PDBGKD_SET_INTERNAL_BREAKPOINT32;
623
624 typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT64
625 {
626 ULONG64 BreakpointAddress;
627 ULONG Flags;
628 } DBGKD_SET_INTERNAL_BREAKPOINT64, *PDBGKD_SET_INTERNAL_BREAKPOINT64;
629
630 typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT32
631 {
632 ULONG BreakpointAddress;
633 ULONG Flags;
634 ULONG Calls;
635 ULONG MaxCallsPerPeriod;
636 ULONG MinInstructions;
637 ULONG MaxInstructions;
638 ULONG TotalInstructions;
639 } DBGKD_GET_INTERNAL_BREAKPOINT32, *PDBGKD_GET_INTERNAL_BREAKPOINT32;
640
641 typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT64
642 {
643 ULONG64 BreakpointAddress;
644 ULONG Flags;
645 ULONG Calls;
646 ULONG MaxCallsPerPeriod;
647 ULONG MinInstructions;
648 ULONG MaxInstructions;
649 ULONG TotalInstructions;
650 } DBGKD_GET_INTERNAL_BREAKPOINT64, *PDBGKD_GET_INTERNAL_BREAKPOINT64;
651
652 typedef struct _DBGKD_BREAKPOINTEX
653 {
654 ULONG BreakPointCount;
655 NTSTATUS ContinueStatus;
656 } DBGKD_BREAKPOINTEX, *PDBGKD_BREAKPOINTEX;
657
658 typedef struct _DBGKD_SEARCH_MEMORY
659 {
660 union
661 {
662 ULONG64 SearchAddress;
663 ULONG64 FoundAddress;
664 };
665 ULONG64 SearchLength;
666 ULONG PatternLength;
667 } DBGKD_SEARCH_MEMORY, *PDBGKD_SEARCH_MEMORY;
668
669 typedef struct _DBGKD_GET_SET_BUS_DATA
670 {
671 ULONG BusDataType;
672 ULONG BusNumber;
673 ULONG SlotNumber;
674 ULONG Offset;
675 ULONG Length;
676 } DBGKD_GET_SET_BUS_DATA, *PDBGKD_GET_SET_BUS_DATA;
677
678 typedef struct _DBGKD_FILL_MEMORY
679 {
680 ULONG64 Address;
681 ULONG Length;
682 USHORT Flags;
683 USHORT PatternLength;
684 } DBGKD_FILL_MEMORY, *PDBGKD_FILL_MEMORY;
685
686 typedef struct _DBGKD_QUERY_MEMORY
687 {
688 ULONG64 Address;
689 ULONG64 Reserved;
690 ULONG AddressSpace;
691 ULONG Flags;
692 } DBGKD_QUERY_MEMORY, *PDBGKD_QUERY_MEMORY;
693
694 typedef struct _DBGKD_SWITCH_PARTITION
695 {
696 ULONG Partition;
697 } DBGKD_SWITCH_PARTITION;
698
699 //
700 // DBGKD Structure for Manipulate
701 //
702 typedef struct _DBGKD_MANIPULATE_STATE32
703 {
704 ULONG ApiNumber;
705 USHORT ProcessorLevel;
706 USHORT Processor;
707 NTSTATUS ReturnStatus;
708 union
709 {
710 DBGKD_READ_MEMORY32 ReadMemory;
711 DBGKD_WRITE_MEMORY32 WriteMemory;
712 DBGKD_READ_MEMORY64 ReadMemory64;
713 DBGKD_WRITE_MEMORY64 WriteMemory64;
714 DBGKD_GET_CONTEXT GetContext;
715 DBGKD_SET_CONTEXT SetContext;
716 DBGKD_WRITE_BREAKPOINT32 WriteBreakPoint;
717 DBGKD_RESTORE_BREAKPOINT RestoreBreakPoint;
718 DBGKD_CONTINUE Continue;
719 DBGKD_CONTINUE2 Continue2;
720 DBGKD_READ_WRITE_IO32 ReadWriteIo;
721 DBGKD_READ_WRITE_IO_EXTENDED32 ReadWriteIoExtended;
722 DBGKD_QUERY_SPECIAL_CALLS QuerySpecialCalls;
723 DBGKD_SET_SPECIAL_CALL32 SetSpecialCall;
724 DBGKD_SET_INTERNAL_BREAKPOINT32 SetInternalBreakpoint;
725 DBGKD_GET_INTERNAL_BREAKPOINT32 GetInternalBreakpoint;
726 DBGKD_GET_VERSION32 GetVersion32;
727 DBGKD_BREAKPOINTEX BreakPointEx;
728 DBGKD_READ_WRITE_MSR ReadWriteMsr;
729 DBGKD_SEARCH_MEMORY SearchMemory;
730 DBGKD_GET_SET_BUS_DATA GetSetBusData;
731 DBGKD_FILL_MEMORY FillMemory;
732 DBGKD_QUERY_MEMORY QueryMemory;
733 DBGKD_SWITCH_PARTITION SwitchPartition;
734 } u;
735 } DBGKD_MANIPULATE_STATE32, *PDBGKD_MANIPULATE_STATE32;
736
737 typedef struct _DBGKD_MANIPULATE_STATE64
738 {
739 ULONG ApiNumber;
740 USHORT ProcessorLevel;
741 USHORT Processor;
742 NTSTATUS ReturnStatus;
743 union
744 {
745 DBGKD_READ_MEMORY64 ReadMemory;
746 DBGKD_WRITE_MEMORY64 WriteMemory;
747 DBGKD_GET_CONTEXT GetContext;
748 DBGKD_SET_CONTEXT SetContext;
749 DBGKD_WRITE_BREAKPOINT64 WriteBreakPoint;
750 DBGKD_RESTORE_BREAKPOINT RestoreBreakPoint;
751 DBGKD_CONTINUE Continue;
752 DBGKD_CONTINUE2 Continue2;
753 DBGKD_READ_WRITE_IO64 ReadWriteIo;
754 DBGKD_READ_WRITE_IO_EXTENDED64 ReadWriteIoExtended;
755 DBGKD_QUERY_SPECIAL_CALLS QuerySpecialCalls;
756 DBGKD_SET_SPECIAL_CALL64 SetSpecialCall;
757 DBGKD_SET_INTERNAL_BREAKPOINT64 SetInternalBreakpoint;
758 DBGKD_GET_INTERNAL_BREAKPOINT64 GetInternalBreakpoint;
759 DBGKD_GET_VERSION64 GetVersion64;
760 DBGKD_BREAKPOINTEX BreakPointEx;
761 DBGKD_READ_WRITE_MSR ReadWriteMsr;
762 DBGKD_SEARCH_MEMORY SearchMemory;
763 DBGKD_GET_SET_BUS_DATA GetSetBusData;
764 DBGKD_FILL_MEMORY FillMemory;
765 DBGKD_QUERY_MEMORY QueryMemory;
766 DBGKD_SWITCH_PARTITION SwitchPartition;
767 } u;
768 } DBGKD_MANIPULATE_STATE64, *PDBGKD_MANIPULATE_STATE64;
769
770 //
771 // File I/O Structure
772 //
773 typedef struct _DBGKD_CREATE_FILE
774 {
775 ULONG DesiredAccess;
776 ULONG FileAttributes;
777 ULONG ShareAccess;
778 ULONG CreateDisposition;
779 ULONG CreateOptions;
780 ULONG64 Handle;
781 ULONG64 Length;
782 } DBGKD_CREATE_FILE, *PDBGKD_CREATE_FILE;
783
784 typedef struct _DBGKD_READ_FILE
785 {
786 ULONG64 Handle;
787 ULONG64 Offset;
788 ULONG Length;
789 } DBGKD_READ_FILE, *PDBGKD_READ_FILE;
790
791 typedef struct _DBGKD_WRITE_FILE
792 {
793 ULONG64 Handle;
794 ULONG64 Offset;
795 ULONG Length;
796 } DBGKD_WRITE_FILE, *PDBGKD_WRITE_FILE;
797
798 typedef struct _DBGKD_CLOSE_FILE
799 {
800 ULONG64 Handle;
801 } DBGKD_CLOSE_FILE, *PDBGKD_CLOSE_FILE;
802
803 typedef struct _DBGKD_FILE_IO
804 {
805 ULONG ApiNumber;
806 ULONG Status;
807 union
808 {
809 ULONG64 ReserveSpace[7];
810 DBGKD_CREATE_FILE CreateFile;
811 DBGKD_READ_FILE ReadFile;
812 DBGKD_WRITE_FILE WriteFile;
813 DBGKD_CLOSE_FILE CloseFile;
814 } u;
815 } DBGKD_FILE_IO, *PDBGKD_FILE_IO;
816
817
818 //
819 // Control Request Structure
820 //
821 typedef struct _DBGKD_REQUEST_BREAKPOINT
822 {
823 ULONG HardwareBreakPointNumber;
824 ULONG Available;
825 } DBGKD_REQUEST_BREAKPOINT, *PDBGKD_REQUEST_BREAKPOINT;
826
827 typedef struct _DBGKD_RELEASE_BREAKPOINT
828 {
829 ULONG HardwareBreakPointNumber;
830 ULONG Released;
831 } DBGKD_RELEASE_BREAKPOINT, *PDBGKD_RELEASE_BREAKPOINT;
832
833 typedef struct _DBGKD_CONTROL_REQUEST
834 {
835 ULONG ApiNumber;
836 union
837 {
838 DBGKD_REQUEST_BREAKPOINT RequestBreakpoint;
839 DBGKD_RELEASE_BREAKPOINT ReleaseBreakpoint;
840 } u;
841 } DBGKD_CONTROL_REQUEST, *PDBGKD_CONTROL_REQUEST;
842
843 //
844 // Trace I/O Structure
845 //
846 typedef struct _DBGKD_PRINT_TRACE
847 {
848 ULONG LengthOfData;
849 } DBGKD_PRINT_TRACE, *PDBGKD_PRINT_TRACE;
850
851 typedef struct _DBGKD_TRACE_IO
852 {
853 ULONG ApiNumber;
854 USHORT ProcessorLevel;
855 USHORT Processor;
856 union
857 {
858 ULONG64 ReserveSpace[7];
859 DBGKD_PRINT_TRACE PrintTrace;
860 } u;
861 } DBGKD_TRACE_IO, *PDBGKD_TRACE_IO;
862
863 static
864 __inline
865 VOID
866 NTAPI
867 ExceptionRecord32To64(IN PEXCEPTION_RECORD32 Ex32,
868 OUT PEXCEPTION_RECORD64 Ex64)
869 {
870 ULONG i;
871
872 Ex64->ExceptionCode = Ex32->ExceptionCode;
873 Ex64->ExceptionFlags = Ex32->ExceptionFlags;
874 Ex64->ExceptionRecord = Ex32->ExceptionRecord;
875 COPYSE(Ex64,Ex32,ExceptionAddress);
876 Ex64->NumberParameters = Ex32->NumberParameters;
877
878 for (i = 0; i < EXCEPTION_MAXIMUM_PARAMETERS; i++)
879 {
880 COPYSE(Ex64,Ex32,ExceptionInformation[i]);
881 }
882 }
883
884 #endif