xref: /reactos/sdk/include/psdk/wdbgexts.h (revision f7024d6c)
1 #ifndef _WDBGEXTS_
2 #define _WDBGEXTS_
3 
4 #pragma once
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 enum
11 {
12     DBGKD_SIMULATION_NONE,
13     DBGKD_SIMULATION_EXDI
14 };
15 
16 #define KD_SECONDARY_VERSION_DEFAULT                    0
17 #define KD_SECONDARY_VERSION_AMD64_OBSOLETE_CONTEXT_1   0
18 #define KD_SECONDARY_VERSION_AMD64_OBSOLETE_CONTEXT_2   1
19 #define KD_SECONDARY_VERSION_AMD64_CONTEXT              2
20 
21 #if defined(_AMD64_)
22 #define CURRENT_KD_SECONDARY_VERSION                    KD_SECONDARY_VERSION_AMD64_CONTEXT
23 #else
24 #define CURRENT_KD_SECONDARY_VERSION                    KD_SECONDARY_VERSION_DEFAULT
25 #endif
26 
27 #define DBGKD_VERS_FLAG_MP                              0x0001
28 #define DBGKD_VERS_FLAG_DATA                            0x0002
29 #define DBGKD_VERS_FLAG_PTR64                           0x0004
30 #define DBGKD_VERS_FLAG_NOMM                            0x0008
31 #define DBGKD_VERS_FLAG_HSS                             0x0010
32 #define DBGKD_VERS_FLAG_PARTITIONS                      0x0020
33 
34 #define KDBG_TAG                                        'GBDK'
35 
36 typedef enum _DBGKD_MAJOR_TYPES
37 {
38     DBGKD_MAJOR_NT,
39     DBGKD_MAJOR_XBOX,
40     DBGKD_MAJOR_BIG,
41     DBGKD_MAJOR_EXDI,
42     DBGKD_MAJOR_NTBD,
43     DBGKD_MAJOR_EFI,
44     DBGKD_MAJOR_TNT,
45     DBGKD_MAJOR_SINGULARITY,
46     DBGKD_MAJOR_HYPERVISOR,
47     DBGKD_MAJOR_MIDORI,
48     DBGKD_MAJOR_COUNT
49 } DBGKD_MAJOR_TYPES;
50 
51 //
52 // The major type is in the high byte
53 //
54 #define DBGKD_MAJOR_TYPE(MajorVersion) \
55     ((DBGKD_MAJOR_TYPES)((MajorVersion) >> 8))
56 
57 typedef struct _DBGKD_GET_VERSION32
58 {
59     USHORT MajorVersion;
60     USHORT MinorVersion;
61     USHORT ProtocolVersion;
62     USHORT Flags;
63     ULONG KernBase;
64     ULONG PsLoadedModuleList;
65     USHORT MachineType;
66     USHORT ThCallbackStack;
67     USHORT NextCallback;
68     USHORT FramePointer;
69     ULONG KiCallUserMode;
70     ULONG KeUserCallbackDispatcher;
71     ULONG BreakpointWithStatus;
72     ULONG DebuggerDataList;
73 } DBGKD_GET_VERSION32, *PDBGKD_GET_VERSION32;
74 
75 typedef struct _DBGKD_DEBUG_DATA_HEADER32
76 {
77     LIST_ENTRY32 List;
78     ULONG OwnerTag;
79     ULONG Size;
80 } DBGKD_DEBUG_DATA_HEADER32, *PDBGKD_DEBUG_DATA_HEADER32;
81 
82 typedef struct _KDDEBUGGER_DATA32
83 {
84     DBGKD_DEBUG_DATA_HEADER32 Header;
85     ULONG KernBase;
86     ULONG BreakpointWithStatus;
87     ULONG SavedContext;
88     USHORT ThCallbackStack;
89     USHORT NextCallback;
90     USHORT FramePointer;
91     USHORT PaeEnabled:1;
92     ULONG KiCallUserMode;
93     ULONG KeUserCallbackDispatcher;
94     ULONG PsLoadedModuleList;
95     ULONG PsActiveProcessHead;
96     ULONG PspCidTable;
97     ULONG ExpSystemResourcesList;
98     ULONG ExpPagedPoolDescriptor;
99     ULONG ExpNumberOfPagedPools;
100     ULONG KeTimeIncrement;
101     ULONG KeBugCheckCallbackListHead;
102     ULONG KiBugcheckData;
103     ULONG IopErrorLogListHead;
104     ULONG ObpRootDirectoryObject;
105     ULONG ObpTypeObjectType;
106     ULONG MmSystemCacheStart;
107     ULONG MmSystemCacheEnd;
108     ULONG MmSystemCacheWs;
109     ULONG MmPfnDatabase;
110     ULONG MmSystemPtesStart;
111     ULONG MmSystemPtesEnd;
112     ULONG MmSubsectionBase;
113     ULONG MmNumberOfPagingFiles;
114     ULONG MmLowestPhysicalPage;
115     ULONG MmHighestPhysicalPage;
116     ULONG MmNumberOfPhysicalPages;
117     ULONG MmMaximumNonPagedPoolInBytes;
118     ULONG MmNonPagedSystemStart;
119     ULONG MmNonPagedPoolStart;
120     ULONG MmNonPagedPoolEnd;
121     ULONG MmPagedPoolStart;
122     ULONG MmPagedPoolEnd;
123     ULONG MmPagedPoolInformation;
124     ULONG MmPageSize;
125     ULONG MmSizeOfPagedPoolInBytes;
126     ULONG MmTotalCommitLimit;
127     ULONG MmTotalCommittedPages;
128     ULONG MmSharedCommit;
129     ULONG MmDriverCommit;
130     ULONG MmProcessCommit;
131     ULONG MmPagedPoolCommit;
132     ULONG MmExtendedCommit;
133     ULONG MmZeroedPageListHead;
134     ULONG MmFreePageListHead;
135     ULONG MmStandbyPageListHead;
136     ULONG MmModifiedPageListHead;
137     ULONG MmModifiedNoWritePageListHead;
138     ULONG MmAvailablePages;
139     ULONG MmResidentAvailablePages;
140     ULONG PoolTrackTable;
141     ULONG NonPagedPoolDescriptor;
142     ULONG MmHighestUserAddress;
143     ULONG MmSystemRangeStart;
144     ULONG MmUserProbeAddress;
145     ULONG KdPrintCircularBuffer;
146     ULONG KdPrintCircularBufferEnd;
147     ULONG KdPrintWritePointer;
148     ULONG KdPrintRolloverCount;
149     ULONG MmLoadedUserImageList;
150 } KDDEBUGGER_DATA32, *PKDDEBUGGER_DATA32;
151 
152 typedef struct _DBGKD_GET_VERSION64
153 {
154     USHORT MajorVersion;
155     USHORT MinorVersion;
156     UCHAR ProtocolVersion;
157     UCHAR KdSecondaryVersion;
158     USHORT Flags;
159     USHORT MachineType;
160     UCHAR MaxPacketType;
161     UCHAR MaxStateChange;
162     UCHAR MaxManipulate;
163     UCHAR Simulation;
164     USHORT Unused[1];
165     ULONG64 KernBase;
166     ULONG64 PsLoadedModuleList;
167     ULONG64 DebuggerDataList;
168 } DBGKD_GET_VERSION64, *PDBGKD_GET_VERSION64;
169 
170 typedef struct _DBGKD_DEBUG_DATA_HEADER64
171 {
172     LIST_ENTRY64 List;
173     ULONG OwnerTag;
174     ULONG Size;
175 } DBGKD_DEBUG_DATA_HEADER64, *PDBGKD_DEBUG_DATA_HEADER64;
176 
177 /* Self-documenting type: stores a pointer as a 64-bit quantity */
178 #if !defined(_WIN64) && (defined(__GNUC__) || defined(__clang__))
179 /* Minimal hackery for GCC/Clang, see commit b9cd3f2d9 (r25845) and de81021ba */
180 typedef union _ULPTR64
181 {
182     ULONG_PTR ptr;
183     ULONG64 ptr64;
184 } ULPTR64;
185 #else
186 // #define ULPTR64 PVOID64
187 #define ULPTR64 ULONG64
188 #endif
189 
190 typedef struct _KDDEBUGGER_DATA64
191 {
192     DBGKD_DEBUG_DATA_HEADER64 Header;
193     ULONG64 KernBase;
194     ULPTR64 BreakpointWithStatus;
195     ULONG64 SavedContext;
196     USHORT ThCallbackStack;
197     USHORT NextCallback;
198     USHORT FramePointer;
199     USHORT PaeEnabled:1;
200     ULPTR64 KiCallUserMode;
201     ULONG64 KeUserCallbackDispatcher;
202     ULPTR64 PsLoadedModuleList;
203     ULPTR64 PsActiveProcessHead;
204     ULPTR64 PspCidTable;
205     ULPTR64 ExpSystemResourcesList;
206     ULPTR64 ExpPagedPoolDescriptor;
207     ULPTR64 ExpNumberOfPagedPools;
208     ULPTR64 KeTimeIncrement;
209     ULPTR64 KeBugCheckCallbackListHead;
210     ULPTR64 KiBugcheckData;
211     ULPTR64 IopErrorLogListHead;
212     ULPTR64 ObpRootDirectoryObject;
213     ULPTR64 ObpTypeObjectType;
214     ULPTR64 MmSystemCacheStart;
215     ULPTR64 MmSystemCacheEnd;
216     ULPTR64 MmSystemCacheWs;
217     ULPTR64 MmPfnDatabase;
218     ULPTR64 MmSystemPtesStart;
219     ULPTR64 MmSystemPtesEnd;
220     ULPTR64 MmSubsectionBase;
221     ULPTR64 MmNumberOfPagingFiles;
222     ULPTR64 MmLowestPhysicalPage;
223     ULPTR64 MmHighestPhysicalPage;
224     ULPTR64 MmNumberOfPhysicalPages;
225     ULPTR64 MmMaximumNonPagedPoolInBytes;
226     ULPTR64 MmNonPagedSystemStart;
227     ULPTR64 MmNonPagedPoolStart;
228     ULPTR64 MmNonPagedPoolEnd;
229     ULPTR64 MmPagedPoolStart;
230     ULPTR64 MmPagedPoolEnd;
231     ULPTR64 MmPagedPoolInformation;
232     ULONG64 MmPageSize;
233     ULPTR64 MmSizeOfPagedPoolInBytes;
234     ULPTR64 MmTotalCommitLimit;
235     ULPTR64 MmTotalCommittedPages;
236     ULPTR64 MmSharedCommit;
237     ULPTR64 MmDriverCommit;
238     ULPTR64 MmProcessCommit;
239     ULPTR64 MmPagedPoolCommit;
240     ULPTR64 MmExtendedCommit;
241     ULPTR64 MmZeroedPageListHead;
242     ULPTR64 MmFreePageListHead;
243     ULPTR64 MmStandbyPageListHead;
244     ULPTR64 MmModifiedPageListHead;
245     ULPTR64 MmModifiedNoWritePageListHead;
246     ULPTR64 MmAvailablePages;
247     ULPTR64 MmResidentAvailablePages;
248     ULPTR64 PoolTrackTable;
249     ULPTR64 NonPagedPoolDescriptor;
250     ULPTR64 MmHighestUserAddress;
251     ULPTR64 MmSystemRangeStart;
252     ULPTR64 MmUserProbeAddress;
253     ULPTR64 KdPrintCircularBuffer;
254     ULPTR64 KdPrintCircularBufferEnd;
255     ULPTR64 KdPrintWritePointer;
256     ULPTR64 KdPrintRolloverCount;
257     ULPTR64 MmLoadedUserImageList;
258 
259 #if (NTDDI_VERSION >= NTDDI_WINXP)
260     ULPTR64 NtBuildLab;
261     ULPTR64 KiNormalSystemCall;
262 #endif
263 
264 /* NOTE: Documented as "NT 5.0 hotfix (QFE) addition" */
265 #if (NTDDI_VERSION >= NTDDI_WIN2KSP4)
266     ULPTR64 KiProcessorBlock;
267     ULPTR64 MmUnloadedDrivers;
268     ULPTR64 MmLastUnloadedDriver;
269     ULPTR64 MmTriageActionTaken;
270     ULPTR64 MmSpecialPoolTag;
271     ULPTR64 KernelVerifier;
272     ULPTR64 MmVerifierData;
273     ULPTR64 MmAllocatedNonPagedPool;
274     ULPTR64 MmPeakCommitment;
275     ULPTR64 MmTotalCommitLimitMaximum;
276     ULPTR64 CmNtCSDVersion;
277 #endif
278 
279 #if (NTDDI_VERSION >= NTDDI_WINXP)
280     ULPTR64 MmPhysicalMemoryBlock;
281     ULPTR64 MmSessionBase;
282     ULPTR64 MmSessionSize;
283     ULPTR64 MmSystemParentTablePage;
284 #endif
285 
286 #if (NTDDI_VERSION >= NTDDI_WS03)
287     ULPTR64 MmVirtualTranslationBase;
288     USHORT OffsetKThreadNextProcessor;
289     USHORT OffsetKThreadTeb;
290     USHORT OffsetKThreadKernelStack;
291     USHORT OffsetKThreadInitialStack;
292     USHORT OffsetKThreadApcProcess;
293     USHORT OffsetKThreadState;
294     USHORT OffsetKThreadBStore;
295     USHORT OffsetKThreadBStoreLimit;
296     USHORT SizeEProcess;
297     USHORT OffsetEprocessPeb;
298     USHORT OffsetEprocessParentCID;
299     USHORT OffsetEprocessDirectoryTableBase;
300     USHORT SizePrcb;
301     USHORT OffsetPrcbDpcRoutine;
302     USHORT OffsetPrcbCurrentThread;
303     USHORT OffsetPrcbMhz;
304     USHORT OffsetPrcbCpuType;
305     USHORT OffsetPrcbVendorString;
306     USHORT OffsetPrcbProcStateContext;
307     USHORT OffsetPrcbNumber;
308     USHORT SizeEThread;
309     ULPTR64 KdPrintCircularBufferPtr;
310     ULPTR64 KdPrintBufferSize;
311     ULPTR64 KeLoaderBlock;
312     USHORT SizePcr;
313     USHORT OffsetPcrSelfPcr;
314     USHORT OffsetPcrCurrentPrcb;
315     USHORT OffsetPcrContainedPrcb;
316     USHORT OffsetPcrInitialBStore;
317     USHORT OffsetPcrBStoreLimit;
318     USHORT OffsetPcrInitialStack;
319     USHORT OffsetPcrStackLimit;
320     USHORT OffsetPrcbPcrPage;
321     USHORT OffsetPrcbProcStateSpecialReg;
322     USHORT GdtR0Code;
323     USHORT GdtR0Data;
324     USHORT GdtR0Pcr;
325     USHORT GdtR3Code;
326     USHORT GdtR3Data;
327     USHORT GdtR3Teb;
328     USHORT GdtLdt;
329     USHORT GdtTss;
330     USHORT Gdt64R3CmCode;
331     USHORT Gdt64R3CmTeb;
332     ULPTR64 IopNumTriageDumpDataBlocks;
333     ULPTR64 IopTriageDumpDataBlocks;
334 #endif
335 
336 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
337     ULPTR64 VfCrashDataBlock;
338     ULPTR64 MmBadPagesDetected;
339     ULPTR64 MmZeroedPageSingleBitErrorsDetected;
340 #endif
341 
342 #if (NTDDI_VERSION >= NTDDI_WIN7)
343     ULPTR64 EtwpDebuggerData;
344     USHORT OffsetPrcbContext;
345 #endif
346 
347 #if (NTDDI_VERSION >= NTDDI_WIN8)
348     USHORT OffsetPrcbMaxBreakpoints;
349     USHORT OffsetPrcbMaxWatchpoints;
350     ULONG OffsetKThreadStackLimit;
351     ULONG OffsetKThreadStackBase;
352     ULONG OffsetKThreadQueueListEntry;
353     ULONG OffsetEThreadIrpList;
354     USHORT OffsetPrcbIdleThread;
355     USHORT OffsetPrcbNormalDpcState;
356     USHORT OffsetPrcbDpcStack;
357     USHORT OffsetPrcbIsrStack;
358     USHORT SizeKDPC_STACK_FRAME;
359 #endif
360 
361 #if (NTDDI_VERSION >= NTDDI_WINBLUE) // NTDDI_WIN81
362     USHORT OffsetKPriQueueThreadListHead;
363     USHORT OffsetKThreadWaitReason;
364 #endif
365 
366 #if (NTDDI_VERSION >= NTDDI_WIN10_RS1)
367     USHORT Padding;
368     ULPTR64 PteBase;
369 #endif
370 
371 #if (NTDDI_VERSION >= NTDDI_WIN10_RS5)
372     ULPTR64 RetpolineStubFunctionTable;
373     ULONG RetpolineStubFunctionTableSize;
374     ULONG RetpolineStubOffset;
375     ULONG RetpolineStubSize;
376 #endif
377 } KDDEBUGGER_DATA64, *PKDDEBUGGER_DATA64;
378 
379 #ifdef __cplusplus
380 }
381 #endif
382 
383 #endif // _WDBGEXTS_
384