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 // AMD64 Control Space types
200 #define AMD64_DEBUG_CONTROL_SPACE_KPCR 0
201 #define AMD64_DEBUG_CONTROL_SPACE_KPRCB 1
202 #define AMD64_DEBUG_CONTROL_SPACE_KSPECIAL 2
203 #define AMD64_DEBUG_CONTROL_SPACE_KTHREAD 3
207 // KD Packet Structure
209 typedef struct _KD_PACKET
216 } KD_PACKET
, *PKD_PACKET
;
221 typedef struct _KD_CONTEXT
223 ULONG KdpDefaultRetries
;
224 BOOLEAN KdpControlCPending
;
225 } KD_CONTEXT
, *PKD_CONTEXT
;
228 // Control Sets for Supported Architectures
230 #include <pshpack4.h>
231 typedef struct _X86_DBGKD_CONTROL_SET
235 ULONG CurrentSymbolStart
;
236 ULONG CurrentSymbolEnd
;
237 } X86_DBGKD_CONTROL_SET
, *PX86_DBGKD_CONTROL_SET
;
239 typedef struct _ALPHA_DBGKD_CONTROL_SET
242 } ALPHA_DBGKD_CONTROL_SET
, *PALPHA_DBGKD_CONTROL_SET
;
244 typedef struct _IA64_DBGKD_CONTROL_SET
247 ULONG64 CurrentSymbolStart
;
248 ULONG64 CurrentSymbolEnd
;
249 } IA64_DBGKD_CONTROL_SET
, *PIA64_DBGKD_CONTROL_SET
;
251 typedef struct _AMD64_DBGKD_CONTROL_SET
255 ULONG64 CurrentSymbolStart
;
256 ULONG64 CurrentSymbolEnd
;
257 } AMD64_DBGKD_CONTROL_SET
, *PAMD64_DBGKD_CONTROL_SET
;
259 typedef struct _ARM_DBGKD_CONTROL_SET
262 ULONG CurrentSymbolStart
;
263 ULONG CurrentSymbolEnd
;
264 } ARM_DBGKD_CONTROL_SET
, *PARM_DBGKD_CONTROL_SET
;
266 typedef struct _DBGKD_ANY_CONTROL_SET
270 X86_DBGKD_CONTROL_SET X86ControlSet
;
271 ALPHA_DBGKD_CONTROL_SET AlphaControlSet
;
272 IA64_DBGKD_CONTROL_SET IA64ControlSet
;
273 AMD64_DBGKD_CONTROL_SET Amd64ControlSet
;
274 ARM_DBGKD_CONTROL_SET ARMControlSet
;
276 } DBGKD_ANY_CONTROL_SET
, *PDBGKD_ANY_CONTROL_SET
;
280 typedef X86_DBGKD_CONTROL_SET DBGKD_CONTROL_SET
, *PDBGKD_CONTROL_SET
;
281 #elif defined(_M_AMD64)
282 typedef AMD64_DBGKD_CONTROL_SET DBGKD_CONTROL_SET
, *PDBGKD_CONTROL_SET
;
283 #elif defined(_M_ARM)
284 typedef ARM_DBGKD_CONTROL_SET DBGKD_CONTROL_SET
, *PDBGKD_CONTROL_SET
;
286 #error Unsupported Architecture
290 // DBGKM Structure for Exceptions
292 typedef struct _DBGKM_EXCEPTION32
294 EXCEPTION_RECORD32 ExceptionRecord
;
296 } DBGKM_EXCEPTION32
, *PDBGKM_EXCEPTION32
;
298 typedef struct _DBGKM_EXCEPTION64
300 EXCEPTION_RECORD64 ExceptionRecord
;
302 } DBGKM_EXCEPTION64
, *PDBGKM_EXCEPTION64
;
305 // DBGKD Structure for State Change
307 typedef struct _X86_DBGKD_CONTROL_REPORT
311 USHORT InstructionCount
;
313 UCHAR InstructionStream
[DBGKD_MAXSTREAM
];
319 } X86_DBGKD_CONTROL_REPORT
, *PX86_DBGKD_CONTROL_REPORT
;
321 typedef struct _ALPHA_DBGKD_CONTROL_REPORT
323 ULONG InstructionCount
;
324 UCHAR InstructionStream
[DBGKD_MAXSTREAM
];
325 } ALPHA_DBGKD_CONTROL_REPORT
, *PALPHA_DBGKD_CONTROL_REPORT
;
327 typedef struct _IA64_DBGKD_CONTROL_REPORT
329 ULONG InstructionCount
;
330 UCHAR InstructionStream
[DBGKD_MAXSTREAM
];
331 } IA64_DBGKD_CONTROL_REPORT
, *PIA64_DBGKD_CONTROL_REPORT
;
333 typedef struct _AMD64_DBGKD_CONTROL_REPORT
338 USHORT InstructionCount
;
340 UCHAR InstructionStream
[DBGKD_MAXSTREAM
];
345 } AMD64_DBGKD_CONTROL_REPORT
, *PAMD64_DBGKD_CONTROL_REPORT
;
347 typedef struct _ARM_DBGKD_CONTROL_REPORT
350 ULONG InstructionCount
;
351 UCHAR InstructionStream
[DBGKD_MAXSTREAM
];
352 } ARM_DBGKD_CONTROL_REPORT
, *PARM_DBGKD_CONTROL_REPORT
;
354 typedef struct _DBGKD_ANY_CONTROL_REPORT
358 X86_DBGKD_CONTROL_REPORT X86ControlReport
;
359 ALPHA_DBGKD_CONTROL_REPORT AlphaControlReport
;
360 IA64_DBGKD_CONTROL_REPORT IA64ControlReport
;
361 AMD64_DBGKD_CONTROL_REPORT Amd64ControlReport
;
362 ARM_DBGKD_CONTROL_REPORT ARMControlReport
;
364 } DBGKD_ANY_CONTROL_REPORT
, *PDBGKD_ANY_CONTROL_REPORT
;
367 typedef X86_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT
, *PDBGKD_CONTROL_REPORT
;
368 #elif defined(_M_AMD64)
369 typedef AMD64_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT
, *PDBGKD_CONTROL_REPORT
;
370 #elif defined(_M_ARM)
371 typedef ARM_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT
, *PDBGKD_CONTROL_REPORT
;
373 #error Unsupported Architecture
377 // DBGKD Structure for Debug I/O Type Print String
379 typedef struct _DBGKD_PRINT_STRING
381 ULONG LengthOfString
;
382 } DBGKD_PRINT_STRING
, *PDBGKD_PRINT_STRING
;
385 // DBGKD Structure for Debug I/O Type Get String
387 typedef struct _DBGKD_GET_STRING
389 ULONG LengthOfPromptString
;
390 ULONG LengthOfStringRead
;
391 } DBGKD_GET_STRING
, *PDBGKD_GET_STRING
;
394 // DBGKD Structure for Debug I/O
396 typedef struct _DBGKD_DEBUG_IO
399 USHORT ProcessorLevel
;
403 DBGKD_PRINT_STRING PrintString
;
404 DBGKD_GET_STRING GetString
;
406 } DBGKD_DEBUG_IO
, *PDBGKD_DEBUG_IO
;
409 // DBGkD Structure for Command String
411 typedef struct _DBGKD_COMMAND_STRING
415 ULONG64 Reserved2
[7];
416 } DBGKD_COMMAND_STRING
, *PDBGKD_COMMAND_STRING
;
419 // DBGKD Structure for Load Symbols
421 typedef struct _DBGKD_LOAD_SYMBOLS32
423 ULONG PathNameLength
;
428 BOOLEAN UnloadSymbols
;
429 } DBGKD_LOAD_SYMBOLS32
, *PDBGKD_LOAD_SYMBOLS32
;
431 typedef struct _DBGKD_LOAD_SYMBOLS64
433 ULONG PathNameLength
;
438 BOOLEAN UnloadSymbols
;
439 } DBGKD_LOAD_SYMBOLS64
, *PDBGKD_LOAD_SYMBOLS64
;
442 // DBGKD Structure for Wait State Change
445 typedef struct _DBGKD_WAIT_STATE_CHANGE32
448 USHORT ProcessorLevel
;
450 ULONG NumberProcessors
;
452 ULONG ProgramCounter
;
455 DBGKM_EXCEPTION32 Exception
;
456 DBGKD_LOAD_SYMBOLS32 LoadSymbols
;
458 } DBGKD_WAIT_STATE_CHANGE32
, *PDBGKD_WAIT_STATE_CHANGE32
;
460 typedef struct _DBGKD_WAIT_STATE_CHANGE64
463 USHORT ProcessorLevel
;
465 ULONG NumberProcessors
;
467 ULONG64 ProgramCounter
;
470 DBGKM_EXCEPTION64 Exception
;
471 DBGKD_LOAD_SYMBOLS64 LoadSymbols
;
473 } DBGKD_WAIT_STATE_CHANGE64
, *PDBGKD_WAIT_STATE_CHANGE64
;
475 typedef struct _DBGKD_ANY_WAIT_STATE_CHANGE
478 USHORT ProcessorLevel
;
480 ULONG NumberProcessors
;
482 ULONG64 ProgramCounter
;
485 DBGKM_EXCEPTION64 Exception
;
486 DBGKD_LOAD_SYMBOLS64 LoadSymbols
;
487 DBGKD_COMMAND_STRING CommandString
;
491 DBGKD_CONTROL_REPORT ControlReport
;
492 DBGKD_ANY_CONTROL_REPORT AnyControlReport
;
494 } DBGKD_ANY_WAIT_STATE_CHANGE
, *PDBGKD_ANY_WAIT_STATE_CHANGE
;
497 // DBGKD Manipulate Structures
499 typedef struct _DBGKD_READ_MEMORY32
501 ULONG TargetBaseAddress
;
503 ULONG ActualBytesRead
;
504 } DBGKD_READ_MEMORY32
, *PDBGKD_READ_MEMORY32
;
506 typedef struct _DBGKD_READ_MEMORY64
508 ULONG64 TargetBaseAddress
;
510 ULONG ActualBytesRead
;
511 } DBGKD_READ_MEMORY64
, *PDBGKD_READ_MEMORY64
;
513 typedef struct _DBGKD_WRITE_MEMORY32
515 ULONG TargetBaseAddress
;
517 ULONG ActualBytesWritten
;
518 } DBGKD_WRITE_MEMORY32
, *PDBGKD_WRITE_MEMORY32
;
520 typedef struct _DBGKD_WRITE_MEMORY64
522 ULONG64 TargetBaseAddress
;
524 ULONG ActualBytesWritten
;
525 } DBGKD_WRITE_MEMORY64
, *PDBGKD_WRITE_MEMORY64
;
527 typedef struct _DBGKD_GET_CONTEXT
530 } DBGKD_GET_CONTEXT
, *PDBGKD_GET_CONTEXT
;
532 typedef struct _DBGKD_SET_CONTEXT
535 } DBGKD_SET_CONTEXT
, *PDBGKD_SET_CONTEXT
;
537 typedef struct _DBGKD_WRITE_BREAKPOINT32
539 ULONG BreakPointAddress
;
540 ULONG BreakPointHandle
;
541 } DBGKD_WRITE_BREAKPOINT32
, *PDBGKD_WRITE_BREAKPOINT32
;
543 typedef struct _DBGKD_WRITE_BREAKPOINT64
545 ULONG64 BreakPointAddress
;
546 ULONG BreakPointHandle
;
547 } DBGKD_WRITE_BREAKPOINT64
, *PDBGKD_WRITE_BREAKPOINT64
;
549 typedef struct _DBGKD_RESTORE_BREAKPOINT
551 ULONG BreakPointHandle
;
552 } DBGKD_RESTORE_BREAKPOINT
, *PDBGKD_RESTORE_BREAKPOINT
;
554 typedef struct _DBGKD_CONTINUE
556 NTSTATUS ContinueStatus
;
557 } DBGKD_CONTINUE
, *PDBGKD_CONTINUE
;
559 #include <pshpack4.h>
560 typedef struct _DBGKD_CONTINUE2
562 NTSTATUS ContinueStatus
;
565 DBGKD_CONTROL_SET ControlSet
;
566 DBGKD_ANY_CONTROL_SET AnyControlSet
;
568 } DBGKD_CONTINUE2
, *PDBGKD_CONTINUE2
;
571 typedef struct _DBGKD_READ_WRITE_IO32
576 } DBGKD_READ_WRITE_IO32
, *PDBGKD_READ_WRITE_IO32
;
578 typedef struct _DBGKD_READ_WRITE_IO64
583 } DBGKD_READ_WRITE_IO64
, *PDBGKD_READ_WRITE_IO64
;
585 typedef struct _DBGKD_READ_WRITE_IO_EXTENDED32
593 } DBGKD_READ_WRITE_IO_EXTENDED32
, *PDBGKD_READ_WRITE_IO_EXTENDED32
;
595 typedef struct _DBGKD_READ_WRITE_IO_EXTENDED64
603 } DBGKD_READ_WRITE_IO_EXTENDED64
, *PDBGKD_READ_WRITE_IO_EXTENDED64
;
605 typedef struct _DBGKD_READ_WRITE_MSR
610 } DBGKD_READ_WRITE_MSR
, *PDBGKD_READ_WRITE_MSR
;
612 typedef struct _DBGKD_QUERY_SPECIAL_CALLS
614 ULONG NumberOfSpecialCalls
;
615 } DBGKD_QUERY_SPECIAL_CALLS
, *PDBGKD_QUERY_SPECIAL_CALLS
;
617 typedef struct _DBGKD_SET_SPECIAL_CALL32
620 } DBGKD_SET_SPECIAL_CALL32
, *PDBGKD_SET_SPECIAL_CALL32
;
622 typedef struct _DBGKD_SET_SPECIAL_CALL64
625 } DBGKD_SET_SPECIAL_CALL64
, *PDBGKD_SET_SPECIAL_CALL64
;
627 typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT32
629 ULONG BreakpointAddress
;
631 } DBGKD_SET_INTERNAL_BREAKPOINT32
, *PDBGKD_SET_INTERNAL_BREAKPOINT32
;
633 typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT64
635 ULONG64 BreakpointAddress
;
637 } DBGKD_SET_INTERNAL_BREAKPOINT64
, *PDBGKD_SET_INTERNAL_BREAKPOINT64
;
639 typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT32
641 ULONG BreakpointAddress
;
644 ULONG MaxCallsPerPeriod
;
645 ULONG MinInstructions
;
646 ULONG MaxInstructions
;
647 ULONG TotalInstructions
;
648 } DBGKD_GET_INTERNAL_BREAKPOINT32
, *PDBGKD_GET_INTERNAL_BREAKPOINT32
;
650 typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT64
652 ULONG64 BreakpointAddress
;
655 ULONG MaxCallsPerPeriod
;
656 ULONG MinInstructions
;
657 ULONG MaxInstructions
;
658 ULONG TotalInstructions
;
659 } DBGKD_GET_INTERNAL_BREAKPOINT64
, *PDBGKD_GET_INTERNAL_BREAKPOINT64
;
661 typedef struct _DBGKD_BREAKPOINTEX
663 ULONG BreakPointCount
;
664 NTSTATUS ContinueStatus
;
665 } DBGKD_BREAKPOINTEX
, *PDBGKD_BREAKPOINTEX
;
667 typedef struct _DBGKD_SEARCH_MEMORY
671 ULONG64 SearchAddress
;
672 ULONG64 FoundAddress
;
674 ULONG64 SearchLength
;
676 } DBGKD_SEARCH_MEMORY
, *PDBGKD_SEARCH_MEMORY
;
678 typedef struct _DBGKD_GET_SET_BUS_DATA
685 } DBGKD_GET_SET_BUS_DATA
, *PDBGKD_GET_SET_BUS_DATA
;
687 typedef struct _DBGKD_FILL_MEMORY
692 USHORT PatternLength
;
693 } DBGKD_FILL_MEMORY
, *PDBGKD_FILL_MEMORY
;
695 typedef struct _DBGKD_QUERY_MEMORY
701 } DBGKD_QUERY_MEMORY
, *PDBGKD_QUERY_MEMORY
;
703 typedef struct _DBGKD_SWITCH_PARTITION
706 } DBGKD_SWITCH_PARTITION
;
709 // DBGKD Structure for Manipulate
711 typedef struct _DBGKD_MANIPULATE_STATE32
714 USHORT ProcessorLevel
;
716 NTSTATUS ReturnStatus
;
719 DBGKD_READ_MEMORY32 ReadMemory
;
720 DBGKD_WRITE_MEMORY32 WriteMemory
;
721 DBGKD_READ_MEMORY64 ReadMemory64
;
722 DBGKD_WRITE_MEMORY64 WriteMemory64
;
723 DBGKD_GET_CONTEXT GetContext
;
724 DBGKD_SET_CONTEXT SetContext
;
725 DBGKD_WRITE_BREAKPOINT32 WriteBreakPoint
;
726 DBGKD_RESTORE_BREAKPOINT RestoreBreakPoint
;
727 DBGKD_CONTINUE Continue
;
728 DBGKD_CONTINUE2 Continue2
;
729 DBGKD_READ_WRITE_IO32 ReadWriteIo
;
730 DBGKD_READ_WRITE_IO_EXTENDED32 ReadWriteIoExtended
;
731 DBGKD_QUERY_SPECIAL_CALLS QuerySpecialCalls
;
732 DBGKD_SET_SPECIAL_CALL32 SetSpecialCall
;
733 DBGKD_SET_INTERNAL_BREAKPOINT32 SetInternalBreakpoint
;
734 DBGKD_GET_INTERNAL_BREAKPOINT32 GetInternalBreakpoint
;
735 DBGKD_GET_VERSION32 GetVersion32
;
736 DBGKD_BREAKPOINTEX BreakPointEx
;
737 DBGKD_READ_WRITE_MSR ReadWriteMsr
;
738 DBGKD_SEARCH_MEMORY SearchMemory
;
739 DBGKD_GET_SET_BUS_DATA GetSetBusData
;
740 DBGKD_FILL_MEMORY FillMemory
;
741 DBGKD_QUERY_MEMORY QueryMemory
;
742 DBGKD_SWITCH_PARTITION SwitchPartition
;
744 } DBGKD_MANIPULATE_STATE32
, *PDBGKD_MANIPULATE_STATE32
;
746 typedef struct _DBGKD_MANIPULATE_STATE64
749 USHORT ProcessorLevel
;
751 NTSTATUS ReturnStatus
;
754 DBGKD_READ_MEMORY64 ReadMemory
;
755 DBGKD_WRITE_MEMORY64 WriteMemory
;
756 DBGKD_GET_CONTEXT GetContext
;
757 DBGKD_SET_CONTEXT SetContext
;
758 DBGKD_WRITE_BREAKPOINT64 WriteBreakPoint
;
759 DBGKD_RESTORE_BREAKPOINT RestoreBreakPoint
;
760 DBGKD_CONTINUE Continue
;
761 DBGKD_CONTINUE2 Continue2
;
762 DBGKD_READ_WRITE_IO64 ReadWriteIo
;
763 DBGKD_READ_WRITE_IO_EXTENDED64 ReadWriteIoExtended
;
764 DBGKD_QUERY_SPECIAL_CALLS QuerySpecialCalls
;
765 DBGKD_SET_SPECIAL_CALL64 SetSpecialCall
;
766 DBGKD_SET_INTERNAL_BREAKPOINT64 SetInternalBreakpoint
;
767 DBGKD_GET_INTERNAL_BREAKPOINT64 GetInternalBreakpoint
;
768 DBGKD_GET_VERSION64 GetVersion64
;
769 DBGKD_BREAKPOINTEX BreakPointEx
;
770 DBGKD_READ_WRITE_MSR ReadWriteMsr
;
771 DBGKD_SEARCH_MEMORY SearchMemory
;
772 DBGKD_GET_SET_BUS_DATA GetSetBusData
;
773 DBGKD_FILL_MEMORY FillMemory
;
774 DBGKD_QUERY_MEMORY QueryMemory
;
775 DBGKD_SWITCH_PARTITION SwitchPartition
;
777 } DBGKD_MANIPULATE_STATE64
, *PDBGKD_MANIPULATE_STATE64
;
780 // File I/O Structure
782 typedef struct _DBGKD_CREATE_FILE
785 ULONG FileAttributes
;
787 ULONG CreateDisposition
;
791 } DBGKD_CREATE_FILE
, *PDBGKD_CREATE_FILE
;
793 typedef struct _DBGKD_READ_FILE
798 } DBGKD_READ_FILE
, *PDBGKD_READ_FILE
;
800 typedef struct _DBGKD_WRITE_FILE
805 } DBGKD_WRITE_FILE
, *PDBGKD_WRITE_FILE
;
807 typedef struct _DBGKD_CLOSE_FILE
810 } DBGKD_CLOSE_FILE
, *PDBGKD_CLOSE_FILE
;
812 typedef struct _DBGKD_FILE_IO
818 ULONG64 ReserveSpace
[7];
819 DBGKD_CREATE_FILE CreateFile
;
820 DBGKD_READ_FILE ReadFile
;
821 DBGKD_WRITE_FILE WriteFile
;
822 DBGKD_CLOSE_FILE CloseFile
;
824 } DBGKD_FILE_IO
, *PDBGKD_FILE_IO
;
828 // Control Request Structure
830 typedef struct _DBGKD_REQUEST_BREAKPOINT
832 ULONG HardwareBreakPointNumber
;
834 } DBGKD_REQUEST_BREAKPOINT
, *PDBGKD_REQUEST_BREAKPOINT
;
836 typedef struct _DBGKD_RELEASE_BREAKPOINT
838 ULONG HardwareBreakPointNumber
;
840 } DBGKD_RELEASE_BREAKPOINT
, *PDBGKD_RELEASE_BREAKPOINT
;
842 typedef struct _DBGKD_CONTROL_REQUEST
847 DBGKD_REQUEST_BREAKPOINT RequestBreakpoint
;
848 DBGKD_RELEASE_BREAKPOINT ReleaseBreakpoint
;
850 } DBGKD_CONTROL_REQUEST
, *PDBGKD_CONTROL_REQUEST
;
853 // Trace I/O Structure
855 typedef struct _DBGKD_PRINT_TRACE
858 } DBGKD_PRINT_TRACE
, *PDBGKD_PRINT_TRACE
;
860 typedef struct _DBGKD_TRACE_IO
863 USHORT ProcessorLevel
;
867 ULONG64 ReserveSpace
[7];
868 DBGKD_PRINT_TRACE PrintTrace
;
870 } DBGKD_TRACE_IO
, *PDBGKD_TRACE_IO
;
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
]);