12 #define COPYSE(p64, p32, f) \
13 p64->f = (ULONG64)(LONG64)(LONG)p32->f
16 // Packet Size and Control Stream Size
18 #define PACKET_MAX_SIZE 4000
19 #define DBGKD_MAXSTREAM 16
24 #define INITIAL_PACKET_ID 0x80800000
25 #define SYNC_PACKET_ID 0x00000800
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
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
56 // Wait State Change Types
58 #define DbgKdMinimumStateChange 0x00003030
59 #define DbgKdExceptionStateChange 0x00003030
60 #define DbgKdLoadSymbolsStateChange 0x00003031
61 #define DbgKdCommandStringStateChange 0x00003032
62 #define DbgKdMaximumStateChange 0x00003033
65 // This is combined with the basic state change code
66 // if the state is from an alternate source
68 #define DbgKdAlternateStateChange 0x00010000
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
119 #define DbgKdPrintStringApi 0x00003230
120 #define DbgKdGetStringApi 0x00003231
125 #define DbgKdPrintTraceApi 0x00003330
128 // Control Request Types
130 #define DbgKdRequestHardwareBp 0x00004300
131 #define DbgKdReleaseHardwareBp 0x00004301
136 #define DbgKdCreateFileApi 0x00003430
137 #define DbgKdReadFileApi 0x00003431
138 #define DbgKdWriteFileApi 0x00003432
139 #define DbgKdCloseFileApi 0x00003433
142 // Control Report Flags
144 #define REPORT_INCLUDES_SEGS 0x0001
145 #define REPORT_STANDARD_CS 0x0002
150 #define DBGKD_64BIT_PROTOCOL_VERSION1 5
151 #define DBGKD_64BIT_PROTOCOL_VERSION2 6
154 // Query Memory Address Spaces
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
162 // Query Memory Flags
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
170 // Internal Breakpoint Flags
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
180 #define DBGKD_FILL_MEMORY_VIRTUAL 0x01
181 #define DBGKD_FILL_MEMORY_PHYSICAL 0x02
184 // Physical Memory Caching Flags
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
192 // Partition Switch Flags
194 #define DBGKD_PARTITION_DEFAULT 0x00
195 #define DBGKD_PARTITION_ALTERNATE 0x01
198 // KD Packet Structure
200 typedef struct _KD_PACKET
207 } KD_PACKET
, *PKD_PACKET
;
212 typedef struct _KD_CONTEXT
214 ULONG KdpDefaultRetries
;
215 BOOLEAN KdpControlCPending
;
216 } KD_CONTEXT
, *PKD_CONTEXT
;
219 // Control Sets for Supported Architectures
221 #include <pshpack4.h>
222 typedef struct _X86_DBGKD_CONTROL_SET
226 ULONG CurrentSymbolStart
;
227 ULONG CurrentSymbolEnd
;
228 } X86_DBGKD_CONTROL_SET
, *PX86_DBGKD_CONTROL_SET
;
230 typedef struct _ALPHA_DBGKD_CONTROL_SET
233 } ALPHA_DBGKD_CONTROL_SET
, *PALPHA_DBGKD_CONTROL_SET
;
235 typedef struct _IA64_DBGKD_CONTROL_SET
238 ULONG64 CurrentSymbolStart
;
239 ULONG64 CurrentSymbolEnd
;
240 } IA64_DBGKD_CONTROL_SET
, *PIA64_DBGKD_CONTROL_SET
;
242 typedef struct _AMD64_DBGKD_CONTROL_SET
246 ULONG64 CurrentSymbolStart
;
247 ULONG64 CurrentSymbolEnd
;
248 } AMD64_DBGKD_CONTROL_SET
, *PAMD64_DBGKD_CONTROL_SET
;
250 typedef struct _ARM_DBGKD_CONTROL_SET
253 ULONG CurrentSymbolStart
;
254 ULONG CurrentSymbolEnd
;
255 } ARM_DBGKD_CONTROL_SET
, *PARM_DBGKD_CONTROL_SET
;
257 typedef struct _DBGKD_ANY_CONTROL_SET
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
;
267 } DBGKD_ANY_CONTROL_SET
, *PDBGKD_ANY_CONTROL_SET
;
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
;
277 #error Unsupported Architecture
281 // DBGKM Structure for Exceptions
283 typedef struct _DBGKM_EXCEPTION32
285 EXCEPTION_RECORD32 ExceptionRecord
;
287 } DBGKM_EXCEPTION32
, *PDBGKM_EXCEPTION32
;
289 typedef struct _DBGKM_EXCEPTION64
291 EXCEPTION_RECORD64 ExceptionRecord
;
293 } DBGKM_EXCEPTION64
, *PDBGKM_EXCEPTION64
;
296 // DBGKD Structure for State Change
298 typedef struct _X86_DBGKD_CONTROL_REPORT
302 USHORT InstructionCount
;
304 UCHAR InstructionStream
[DBGKD_MAXSTREAM
];
310 } X86_DBGKD_CONTROL_REPORT
, *PX86_DBGKD_CONTROL_REPORT
;
312 typedef struct _ALPHA_DBGKD_CONTROL_REPORT
314 ULONG InstructionCount
;
315 UCHAR InstructionStream
[DBGKD_MAXSTREAM
];
316 } ALPHA_DBGKD_CONTROL_REPORT
, *PALPHA_DBGKD_CONTROL_REPORT
;
318 typedef struct _IA64_DBGKD_CONTROL_REPORT
320 ULONG InstructionCount
;
321 UCHAR InstructionStream
[DBGKD_MAXSTREAM
];
322 } IA64_DBGKD_CONTROL_REPORT
, *PIA64_DBGKD_CONTROL_REPORT
;
324 typedef struct _AMD64_DBGKD_CONTROL_REPORT
329 USHORT InstructionCount
;
331 UCHAR InstructionStream
[DBGKD_MAXSTREAM
];
336 } AMD64_DBGKD_CONTROL_REPORT
, *PAMD64_DBGKD_CONTROL_REPORT
;
338 typedef struct _ARM_DBGKD_CONTROL_REPORT
341 ULONG InstructionCount
;
342 UCHAR InstructionStream
[DBGKD_MAXSTREAM
];
343 } ARM_DBGKD_CONTROL_REPORT
, *PARM_DBGKD_CONTROL_REPORT
;
345 typedef struct _DBGKD_ANY_CONTROL_REPORT
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
;
355 } DBGKD_ANY_CONTROL_REPORT
, *PDBGKD_ANY_CONTROL_REPORT
;
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
;
364 #error Unsupported Architecture
368 // DBGKD Structure for Debug I/O Type Print String
370 typedef struct _DBGKD_PRINT_STRING
372 ULONG LengthOfString
;
373 } DBGKD_PRINT_STRING
, *PDBGKD_PRINT_STRING
;
376 // DBGKD Structure for Debug I/O Type Get String
378 typedef struct _DBGKD_GET_STRING
380 ULONG LengthOfPromptString
;
381 ULONG LengthOfStringRead
;
382 } DBGKD_GET_STRING
, *PDBGKD_GET_STRING
;
385 // DBGKD Structure for Debug I/O
387 typedef struct _DBGKD_DEBUG_IO
390 USHORT ProcessorLevel
;
394 DBGKD_PRINT_STRING PrintString
;
395 DBGKD_GET_STRING GetString
;
397 } DBGKD_DEBUG_IO
, *PDBGKD_DEBUG_IO
;
400 // DBGkD Structure for Command String
402 typedef struct _DBGKD_COMMAND_STRING
406 ULONG64 Reserved2
[7];
407 } DBGKD_COMMAND_STRING
, *PDBGKD_COMMAND_STRING
;
410 // DBGKD Structure for Load Symbols
412 typedef struct _DBGKD_LOAD_SYMBOLS32
414 ULONG PathNameLength
;
419 BOOLEAN UnloadSymbols
;
420 } DBGKD_LOAD_SYMBOLS32
, *PDBGKD_LOAD_SYMBOLS32
;
422 typedef struct _DBGKD_LOAD_SYMBOLS64
424 ULONG PathNameLength
;
429 BOOLEAN UnloadSymbols
;
430 } DBGKD_LOAD_SYMBOLS64
, *PDBGKD_LOAD_SYMBOLS64
;
433 // DBGKD Structure for Wait State Change
436 typedef struct _DBGKD_WAIT_STATE_CHANGE32
439 USHORT ProcessorLevel
;
441 ULONG NumberProcessors
;
443 ULONG ProgramCounter
;
446 DBGKM_EXCEPTION32 Exception
;
447 DBGKD_LOAD_SYMBOLS32 LoadSymbols
;
449 DBGKD_CONTROL_REPORT ControlReport
;
451 } DBGKD_WAIT_STATE_CHANGE32
, *PDBGKD_WAIT_STATE_CHANGE32
;
453 typedef struct _DBGKD_WAIT_STATE_CHANGE64
456 USHORT ProcessorLevel
;
458 ULONG NumberProcessors
;
460 ULONG64 ProgramCounter
;
463 DBGKM_EXCEPTION64 Exception
;
464 DBGKD_LOAD_SYMBOLS64 LoadSymbols
;
466 DBGKD_CONTROL_REPORT ControlReport
;
468 } DBGKD_WAIT_STATE_CHANGE64
, *PDBGKD_WAIT_STATE_CHANGE64
;
470 typedef struct _DBGKD_ANY_WAIT_STATE_CHANGE
473 USHORT ProcessorLevel
;
475 ULONG NumberProcessors
;
477 ULONG64 ProgramCounter
;
480 DBGKM_EXCEPTION64 Exception
;
481 DBGKD_LOAD_SYMBOLS64 LoadSymbols
;
482 DBGKD_COMMAND_STRING CommandString
;
486 DBGKD_CONTROL_REPORT ControlReport
;
487 DBGKD_ANY_CONTROL_REPORT AnyControlReport
;
489 } DBGKD_ANY_WAIT_STATE_CHANGE
, *PDBGKD_ANY_WAIT_STATE_CHANGE
;
492 // DBGKD Manipulate Structures
494 typedef struct _DBGKD_READ_MEMORY32
496 ULONG TargetBaseAddress
;
498 ULONG ActualBytesRead
;
499 } DBGKD_READ_MEMORY32
, *PDBGKD_READ_MEMORY32
;
501 typedef struct _DBGKD_READ_MEMORY64
503 ULONG64 TargetBaseAddress
;
505 ULONG ActualBytesRead
;
506 } DBGKD_READ_MEMORY64
, *PDBGKD_READ_MEMORY64
;
508 typedef struct _DBGKD_WRITE_MEMORY32
510 ULONG TargetBaseAddress
;
512 ULONG ActualBytesWritten
;
513 } DBGKD_WRITE_MEMORY32
, *PDBGKD_WRITE_MEMORY32
;
515 typedef struct _DBGKD_WRITE_MEMORY64
517 ULONG64 TargetBaseAddress
;
519 ULONG ActualBytesWritten
;
520 } DBGKD_WRITE_MEMORY64
, *PDBGKD_WRITE_MEMORY64
;
522 typedef struct _DBGKD_GET_CONTEXT
525 } DBGKD_GET_CONTEXT
, *PDBGKD_GET_CONTEXT
;
527 typedef struct _DBGKD_SET_CONTEXT
530 } DBGKD_SET_CONTEXT
, *PDBGKD_SET_CONTEXT
;
532 typedef struct _DBGKD_WRITE_BREAKPOINT32
534 ULONG BreakPointAddress
;
535 ULONG BreakPointHandle
;
536 } DBGKD_WRITE_BREAKPOINT32
, *PDBGKD_WRITE_BREAKPOINT32
;
538 typedef struct _DBGKD_WRITE_BREAKPOINT64
540 ULONG64 BreakPointAddress
;
541 ULONG BreakPointHandle
;
542 } DBGKD_WRITE_BREAKPOINT64
, *PDBGKD_WRITE_BREAKPOINT64
;
544 typedef struct _DBGKD_RESTORE_BREAKPOINT
546 ULONG BreakPointHandle
;
547 } DBGKD_RESTORE_BREAKPOINT
, *PDBGKD_RESTORE_BREAKPOINT
;
549 typedef struct _DBGKD_CONTINUE
551 NTSTATUS ContinueStatus
;
552 } DBGKD_CONTINUE
, *PDBGKD_CONTINUE
;
554 #include <pshpack4.h>
555 typedef struct _DBGKD_CONTINUE2
557 NTSTATUS ContinueStatus
;
560 DBGKD_CONTROL_SET ControlSet
;
561 DBGKD_ANY_CONTROL_SET AnyControlSet
;
563 } DBGKD_CONTINUE2
, *PDBGKD_CONTINUE2
;
566 typedef struct _DBGKD_READ_WRITE_IO32
571 } DBGKD_READ_WRITE_IO32
, *PDBGKD_READ_WRITE_IO32
;
573 typedef struct _DBGKD_READ_WRITE_IO64
578 } DBGKD_READ_WRITE_IO64
, *PDBGKD_READ_WRITE_IO64
;
580 typedef struct _DBGKD_READ_WRITE_IO_EXTENDED32
588 } DBGKD_READ_WRITE_IO_EXTENDED32
, *PDBGKD_READ_WRITE_IO_EXTENDED32
;
590 typedef struct _DBGKD_READ_WRITE_IO_EXTENDED64
598 } DBGKD_READ_WRITE_IO_EXTENDED64
, *PDBGKD_READ_WRITE_IO_EXTENDED64
;
600 typedef struct _DBGKD_READ_WRITE_MSR
605 } DBGKD_READ_WRITE_MSR
, *PDBGKD_READ_WRITE_MSR
;
607 typedef struct _DBGKD_QUERY_SPECIAL_CALLS
609 ULONG NumberOfSpecialCalls
;
610 } DBGKD_QUERY_SPECIAL_CALLS
, *PDBGKD_QUERY_SPECIAL_CALLS
;
612 typedef struct _DBGKD_SET_SPECIAL_CALL32
615 } DBGKD_SET_SPECIAL_CALL32
, *PDBGKD_SET_SPECIAL_CALL32
;
617 typedef struct _DBGKD_SET_SPECIAL_CALL64
620 } DBGKD_SET_SPECIAL_CALL64
, *PDBGKD_SET_SPECIAL_CALL64
;
622 typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT32
624 ULONG BreakpointAddress
;
626 } DBGKD_SET_INTERNAL_BREAKPOINT32
, *PDBGKD_SET_INTERNAL_BREAKPOINT32
;
628 typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT64
630 ULONG64 BreakpointAddress
;
632 } DBGKD_SET_INTERNAL_BREAKPOINT64
, *PDBGKD_SET_INTERNAL_BREAKPOINT64
;
634 typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT32
636 ULONG BreakpointAddress
;
639 ULONG MaxCallsPerPeriod
;
640 ULONG MinInstructions
;
641 ULONG MaxInstructions
;
642 ULONG TotalInstructions
;
643 } DBGKD_GET_INTERNAL_BREAKPOINT32
, *PDBGKD_GET_INTERNAL_BREAKPOINT32
;
645 typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT64
647 ULONG64 BreakpointAddress
;
650 ULONG MaxCallsPerPeriod
;
651 ULONG MinInstructions
;
652 ULONG MaxInstructions
;
653 ULONG TotalInstructions
;
654 } DBGKD_GET_INTERNAL_BREAKPOINT64
, *PDBGKD_GET_INTERNAL_BREAKPOINT64
;
656 typedef struct _DBGKD_BREAKPOINTEX
658 ULONG BreakPointCount
;
659 NTSTATUS ContinueStatus
;
660 } DBGKD_BREAKPOINTEX
, *PDBGKD_BREAKPOINTEX
;
662 typedef struct _DBGKD_SEARCH_MEMORY
666 ULONG64 SearchAddress
;
667 ULONG64 FoundAddress
;
669 ULONG64 SearchLength
;
671 } DBGKD_SEARCH_MEMORY
, *PDBGKD_SEARCH_MEMORY
;
673 typedef struct _DBGKD_GET_SET_BUS_DATA
680 } DBGKD_GET_SET_BUS_DATA
, *PDBGKD_GET_SET_BUS_DATA
;
682 typedef struct _DBGKD_FILL_MEMORY
687 USHORT PatternLength
;
688 } DBGKD_FILL_MEMORY
, *PDBGKD_FILL_MEMORY
;
690 typedef struct _DBGKD_QUERY_MEMORY
696 } DBGKD_QUERY_MEMORY
, *PDBGKD_QUERY_MEMORY
;
698 typedef struct _DBGKD_SWITCH_PARTITION
701 } DBGKD_SWITCH_PARTITION
;
704 // DBGKD Structure for Manipulate
706 typedef struct _DBGKD_MANIPULATE_STATE32
709 USHORT ProcessorLevel
;
711 NTSTATUS ReturnStatus
;
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
;
739 } DBGKD_MANIPULATE_STATE32
, *PDBGKD_MANIPULATE_STATE32
;
741 typedef struct _DBGKD_MANIPULATE_STATE64
744 USHORT ProcessorLevel
;
746 NTSTATUS ReturnStatus
;
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
;
772 } DBGKD_MANIPULATE_STATE64
, *PDBGKD_MANIPULATE_STATE64
;
775 // File I/O Structure
777 typedef struct _DBGKD_CREATE_FILE
780 ULONG FileAttributes
;
782 ULONG CreateDisposition
;
786 } DBGKD_CREATE_FILE
, *PDBGKD_CREATE_FILE
;
788 typedef struct _DBGKD_READ_FILE
793 } DBGKD_READ_FILE
, *PDBGKD_READ_FILE
;
795 typedef struct _DBGKD_WRITE_FILE
800 } DBGKD_WRITE_FILE
, *PDBGKD_WRITE_FILE
;
802 typedef struct _DBGKD_CLOSE_FILE
805 } DBGKD_CLOSE_FILE
, *PDBGKD_CLOSE_FILE
;
807 typedef struct _DBGKD_FILE_IO
813 ULONG64 ReserveSpace
[7];
814 DBGKD_CREATE_FILE CreateFile
;
815 DBGKD_READ_FILE ReadFile
;
816 DBGKD_WRITE_FILE WriteFile
;
817 DBGKD_CLOSE_FILE CloseFile
;
819 } DBGKD_FILE_IO
, *PDBGKD_FILE_IO
;
823 // Control Request Structure
825 typedef struct _DBGKD_REQUEST_BREAKPOINT
827 ULONG HardwareBreakPointNumber
;
829 } DBGKD_REQUEST_BREAKPOINT
, *PDBGKD_REQUEST_BREAKPOINT
;
831 typedef struct _DBGKD_RELEASE_BREAKPOINT
833 ULONG HardwareBreakPointNumber
;
835 } DBGKD_RELEASE_BREAKPOINT
, *PDBGKD_RELEASE_BREAKPOINT
;
837 typedef struct _DBGKD_CONTROL_REQUEST
842 DBGKD_REQUEST_BREAKPOINT RequestBreakpoint
;
843 DBGKD_RELEASE_BREAKPOINT ReleaseBreakpoint
;
845 } DBGKD_CONTROL_REQUEST
, *PDBGKD_CONTROL_REQUEST
;
848 // Trace I/O Structure
850 typedef struct _DBGKD_PRINT_TRACE
853 } DBGKD_PRINT_TRACE
, *PDBGKD_PRINT_TRACE
;
855 typedef struct _DBGKD_TRACE_IO
858 USHORT ProcessorLevel
;
862 ULONG64 ReserveSpace
[7];
863 DBGKD_PRINT_TRACE PrintTrace
;
865 } DBGKD_TRACE_IO
, *PDBGKD_TRACE_IO
;
867 #if defined(_M_AMD64)
869 #define CopyExceptionRecord(Ex64From, Ex64To) \
870 RtlCopyMemory(Ex64To, Ex64From, sizeof(EXCEPTION_RECORD64))
876 ExceptionRecord32To64(IN PEXCEPTION_RECORD32 Ex32
,
877 OUT PEXCEPTION_RECORD64 Ex64
)
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
;
887 for (i
= 0; i
< EXCEPTION_MAXIMUM_PARAMETERS
; i
++)
889 COPYSE(Ex64
,Ex32
,ExceptionInformation
[i
]);
893 #define CopyExceptionRecord(Ex32From, Ex64To) \
894 ExceptionRecord32To64((PEXCEPTION_RECORD32)Ex32From, Ex64To)