Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4346 lines
136 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntdbg.h
  5. Abstract:
  6. This module contains the public data structures, data types,
  7. and procedures exported by the NT Dbg subsystem.
  8. Revision History:
  9. --*/
  10. #ifndef _NTDBG_
  11. #define _NTDBG_
  12. #if _MSC_VER > 1000
  13. #pragma once
  14. #endif
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. //
  19. // The following are explicitly sized versions of common system
  20. // structures which appear in the kernel debugger API.
  21. //
  22. // All of the debugger structures which are exposed to both
  23. // sides of the KD API are declared below in explicitly sized
  24. // versions as well, with inline converter functions.
  25. //
  26. //
  27. // Macro for sign extending 32 bit addresses into 64 bits
  28. //
  29. #define COPYSE(p64,p32,f) p64->f = (ULONG64)(LONG64)(LONG)p32->f
  30. __inline
  31. void
  32. ExceptionRecord32To64(
  33. IN PEXCEPTION_RECORD32 Ex32,
  34. OUT PEXCEPTION_RECORD64 Ex64
  35. )
  36. {
  37. ULONG i;
  38. Ex64->ExceptionCode = Ex32->ExceptionCode;
  39. Ex64->ExceptionFlags = Ex32->ExceptionFlags;
  40. Ex64->ExceptionRecord = Ex32->ExceptionRecord;
  41. COPYSE(Ex64,Ex32,ExceptionAddress);
  42. Ex64->NumberParameters = Ex32->NumberParameters;
  43. for (i = 0; i < EXCEPTION_MAXIMUM_PARAMETERS; i++) {
  44. COPYSE(Ex64,Ex32,ExceptionInformation[i]);
  45. }
  46. }
  47. __inline
  48. void
  49. ExceptionRecord64To32(
  50. IN PEXCEPTION_RECORD64 Ex64,
  51. OUT PEXCEPTION_RECORD32 Ex32
  52. )
  53. {
  54. ULONG i;
  55. Ex32->ExceptionCode = Ex64->ExceptionCode;
  56. Ex32->ExceptionFlags = Ex64->ExceptionFlags;
  57. Ex32->ExceptionRecord = (ULONG) Ex64->ExceptionRecord;
  58. Ex32->ExceptionAddress = (ULONG) Ex64->ExceptionAddress;
  59. Ex32->NumberParameters = Ex64->NumberParameters;
  60. for (i = 0; i < EXCEPTION_MAXIMUM_PARAMETERS; i++) {
  61. Ex32->ExceptionInformation[i] = (ULONG) Ex64->ExceptionInformation[i];
  62. }
  63. }
  64. //
  65. // DbgKm Apis are from the kernel component (Dbgk) through a process
  66. // debug port.
  67. //
  68. #define DBGKM_MSG_OVERHEAD \
  69. (FIELD_OFFSET(DBGKM_APIMSG, u.Exception) - sizeof(PORT_MESSAGE))
  70. #define DBGKM_API_MSG_LENGTH(TypeSize) \
  71. ((sizeof(DBGKM_APIMSG) << 16) | (DBGKM_MSG_OVERHEAD + (TypeSize)))
  72. #define DBGKM_FORMAT_API_MSG(m,Number,TypeSize) \
  73. (m).h.u1.Length = DBGKM_API_MSG_LENGTH((TypeSize)); \
  74. (m).h.u2.ZeroInit = LPC_DEBUG_EVENT; \
  75. (m).ApiNumber = (Number)
  76. typedef enum _DBGKM_APINUMBER {
  77. DbgKmExceptionApi,
  78. DbgKmCreateThreadApi,
  79. DbgKmCreateProcessApi,
  80. DbgKmExitThreadApi,
  81. DbgKmExitProcessApi,
  82. DbgKmLoadDllApi,
  83. DbgKmUnloadDllApi,
  84. DbgKmMaxApiNumber
  85. } DBGKM_APINUMBER;
  86. #if !DBG_NO_PORTABLE_TYPES
  87. typedef struct _DBGKM_EXCEPTION {
  88. EXCEPTION_RECORD ExceptionRecord;
  89. ULONG FirstChance;
  90. } DBGKM_EXCEPTION, *PDBGKM_EXCEPTION;
  91. #endif
  92. typedef struct _DBGKM_EXCEPTION32 {
  93. EXCEPTION_RECORD32 ExceptionRecord;
  94. ULONG FirstChance;
  95. } DBGKM_EXCEPTION32, *PDBGKM_EXCEPTION32;
  96. typedef struct _DBGKM_EXCEPTION64 {
  97. EXCEPTION_RECORD64 ExceptionRecord;
  98. ULONG FirstChance;
  99. } DBGKM_EXCEPTION64, *PDBGKM_EXCEPTION64;
  100. __inline
  101. void
  102. DbgkmException32To64(
  103. IN PDBGKM_EXCEPTION32 E32,
  104. OUT PDBGKM_EXCEPTION64 E64
  105. )
  106. {
  107. ExceptionRecord32To64(&E32->ExceptionRecord, &E64->ExceptionRecord);
  108. E64->FirstChance = E32->FirstChance;
  109. }
  110. __inline
  111. void
  112. DbgkmException64To32(
  113. IN PDBGKM_EXCEPTION64 E64,
  114. OUT PDBGKM_EXCEPTION32 E32
  115. )
  116. {
  117. ExceptionRecord64To32(&E64->ExceptionRecord, &E32->ExceptionRecord);
  118. E32->FirstChance = E64->FirstChance;
  119. }
  120. //
  121. // The DbgSS, DbgKm and DbgSs stuff is not needed in the portable debugger,
  122. // and some of the following types and prototypes use portable types, so just
  123. // turn them all off when building the debugger.
  124. //
  125. #if !DBG_NO_PORTABLE_TYPES
  126. typedef struct _DBGKM_CREATE_THREAD {
  127. ULONG SubSystemKey;
  128. PVOID StartAddress;
  129. } DBGKM_CREATE_THREAD, *PDBGKM_CREATE_THREAD;
  130. typedef struct _DBGKM_CREATE_PROCESS {
  131. ULONG SubSystemKey;
  132. HANDLE FileHandle;
  133. PVOID BaseOfImage;
  134. ULONG DebugInfoFileOffset;
  135. ULONG DebugInfoSize;
  136. DBGKM_CREATE_THREAD InitialThread;
  137. } DBGKM_CREATE_PROCESS, *PDBGKM_CREATE_PROCESS;
  138. typedef struct _DBGKM_EXIT_THREAD {
  139. NTSTATUS ExitStatus;
  140. } DBGKM_EXIT_THREAD, *PDBGKM_EXIT_THREAD;
  141. typedef struct _DBGKM_EXIT_PROCESS {
  142. NTSTATUS ExitStatus;
  143. } DBGKM_EXIT_PROCESS, *PDBGKM_EXIT_PROCESS;
  144. typedef struct _DBGKM_LOAD_DLL {
  145. HANDLE FileHandle;
  146. PVOID BaseOfDll;
  147. ULONG DebugInfoFileOffset;
  148. ULONG DebugInfoSize;
  149. PVOID NamePointer;
  150. } DBGKM_LOAD_DLL, *PDBGKM_LOAD_DLL;
  151. typedef struct _DBGKM_UNLOAD_DLL {
  152. PVOID BaseAddress;
  153. } DBGKM_UNLOAD_DLL, *PDBGKM_UNLOAD_DLL;
  154. typedef struct _DBGKM_APIMSG {
  155. PORT_MESSAGE h;
  156. DBGKM_APINUMBER ApiNumber;
  157. NTSTATUS ReturnedStatus;
  158. union {
  159. DBGKM_EXCEPTION Exception;
  160. DBGKM_CREATE_THREAD CreateThread;
  161. DBGKM_CREATE_PROCESS CreateProcessInfo;
  162. DBGKM_EXIT_THREAD ExitThread;
  163. DBGKM_EXIT_PROCESS ExitProcess;
  164. DBGKM_LOAD_DLL LoadDll;
  165. DBGKM_UNLOAD_DLL UnloadDll;
  166. } u;
  167. } DBGKM_APIMSG, *PDBGKM_APIMSG;
  168. //
  169. // DbgSrv Messages are from Dbg subsystem to emulation subsystem.
  170. // The only defined message at this time is continue
  171. //
  172. #define DBGSRV_MSG_OVERHEAD \
  173. (sizeof(DBGSRV_APIMSG) - sizeof(PORT_MESSAGE))
  174. #define DBGSRV_API_MSG_LENGTH(TypeSize) \
  175. ((sizeof(DBGSRV_APIMSG) << 16) | (DBGSRV_MSG_OVERHEAD))
  176. #define DBGSRV_FORMAT_API_MSG(m,Number,TypeSize,CKey) \
  177. (m).h.u1.Length = DBGSRV_API_MSG_LENGTH((TypeSize)); \
  178. (m).h.u2.ZeroInit = 0L; \
  179. (m).ApiNumber = (Number); \
  180. (m).ContinueKey = (PVOID)(CKey)
  181. typedef enum _DBGSRV_APINUMBER {
  182. DbgSrvContinueApi,
  183. DbgSrvMaxApiNumber
  184. } DBGSRV_APINUMBER;
  185. typedef struct _DBGSRV_APIMSG {
  186. PORT_MESSAGE h;
  187. DBGSRV_APINUMBER ApiNumber;
  188. NTSTATUS ReturnedStatus;
  189. PVOID ContinueKey;
  190. } DBGSRV_APIMSG, *PDBGSRV_APIMSG;
  191. //
  192. //
  193. // DbgSs Apis are from the system service emulation subsystems to the Dbg
  194. // subsystem
  195. //
  196. typedef enum _DBG_STATE {
  197. DbgIdle,
  198. DbgReplyPending,
  199. DbgCreateThreadStateChange,
  200. DbgCreateProcessStateChange,
  201. DbgExitThreadStateChange,
  202. DbgExitProcessStateChange,
  203. DbgExceptionStateChange,
  204. DbgBreakpointStateChange,
  205. DbgSingleStepStateChange,
  206. DbgLoadDllStateChange,
  207. DbgUnloadDllStateChange
  208. } DBG_STATE, *PDBG_STATE;
  209. #define DBGSS_MSG_OVERHEAD \
  210. (FIELD_OFFSET(DBGSS_APIMSG, u.Exception) - sizeof(PORT_MESSAGE))
  211. #define DBGSS_API_MSG_LENGTH(TypeSize) \
  212. ((sizeof(DBGSS_APIMSG) << 16) | (DBGSS_MSG_OVERHEAD + (TypeSize)))
  213. #define DBGSS_FORMAT_API_MSG(m,Number,TypeSize,pApp,CKey) \
  214. (m).h.u1.Length = DBGSS_API_MSG_LENGTH((TypeSize)); \
  215. (m).h.u2.ZeroInit = 0L; \
  216. (m).ApiNumber = (Number); \
  217. (m).AppClientId = *(pApp); \
  218. (m).ContinueKey = (PVOID)(CKey)
  219. typedef enum _DBGSS_APINUMBER {
  220. DbgSsExceptionApi,
  221. DbgSsCreateThreadApi,
  222. DbgSsCreateProcessApi,
  223. DbgSsExitThreadApi,
  224. DbgSsExitProcessApi,
  225. DbgSsLoadDllApi,
  226. DbgSsUnloadDllApi,
  227. DbgSsMaxApiNumber
  228. } DBGSS_APINUMBER;
  229. typedef struct _DBGSS_CREATE_PROCESS {
  230. CLIENT_ID DebugUiClientId;
  231. DBGKM_CREATE_PROCESS NewProcess;
  232. } DBGSS_CREATE_PROCESS, *PDBGSS_CREATE_PROCESS;
  233. typedef struct _DBGSS_APIMSG {
  234. PORT_MESSAGE h;
  235. DBGKM_APINUMBER ApiNumber;
  236. NTSTATUS ReturnedStatus;
  237. CLIENT_ID AppClientId;
  238. PVOID ContinueKey;
  239. union {
  240. DBGKM_EXCEPTION Exception;
  241. DBGKM_CREATE_THREAD CreateThread;
  242. DBGSS_CREATE_PROCESS CreateProcessInfo;
  243. DBGKM_EXIT_THREAD ExitThread;
  244. DBGKM_EXIT_PROCESS ExitProcess;
  245. DBGKM_LOAD_DLL LoadDll;
  246. DBGKM_UNLOAD_DLL UnloadDll;
  247. } u;
  248. } DBGSS_APIMSG, *PDBGSS_APIMSG;
  249. #define DBGUI_MSG_OVERHEAD \
  250. (FIELD_OFFSET(DBGUI_APIMSG, u.Continue) - sizeof(PORT_MESSAGE))
  251. #define DBGUI_API_MSG_LENGTH(TypeSize) \
  252. ((sizeof(DBGUI_APIMSG) << 16) | (DBGUI_MSG_OVERHEAD + (TypeSize)))
  253. #define DBGUI_FORMAT_API_MSG(m,Number,TypeSize) \
  254. (m).h.u1.Length = DBGUI_API_MSG_LENGTH((TypeSize)); \
  255. (m).h.u2.ZeroInit = 0L; \
  256. (m).ApiNumber = (Number)
  257. typedef enum _DBGUI_APINUMBER {
  258. DbgUiWaitStateChangeApi,
  259. DbgUiContinueApi,
  260. DbgUiStopDebugApi,
  261. DbgUiMaxApiNumber
  262. } DBGUI_APINUMBER;
  263. typedef struct _DBGUI_CREATE_THREAD {
  264. HANDLE HandleToThread;
  265. DBGKM_CREATE_THREAD NewThread;
  266. } DBGUI_CREATE_THREAD, *PDBGUI_CREATE_THREAD;
  267. typedef struct _DBGUI_CREATE_PROCESS {
  268. HANDLE HandleToProcess;
  269. HANDLE HandleToThread;
  270. DBGKM_CREATE_PROCESS NewProcess;
  271. } DBGUI_CREATE_PROCESS, *PDBGUI_CREATE_PROCESS;
  272. typedef struct _DBGUI_WAIT_STATE_CHANGE {
  273. DBG_STATE NewState;
  274. CLIENT_ID AppClientId;
  275. union {
  276. DBGKM_EXCEPTION Exception;
  277. DBGUI_CREATE_THREAD CreateThread;
  278. DBGUI_CREATE_PROCESS CreateProcessInfo;
  279. DBGKM_EXIT_THREAD ExitThread;
  280. DBGKM_EXIT_PROCESS ExitProcess;
  281. DBGKM_LOAD_DLL LoadDll;
  282. DBGKM_UNLOAD_DLL UnloadDll;
  283. } StateInfo;
  284. } DBGUI_WAIT_STATE_CHANGE, *PDBGUI_WAIT_STATE_CHANGE;
  285. typedef struct _DBGUI_CONTINUE {
  286. CLIENT_ID AppClientId;
  287. NTSTATUS ContinueStatus;
  288. } DBGUI_CONTINUE, *PDBGUI_CONTINUE;
  289. typedef struct _DBGUI_STOPDEBUG {
  290. ULONG ProcessId;
  291. } DBGUI_STOPDEBUG, *PDBGUI_STOPDEBUG;
  292. typedef struct _DBGUI_APIMSG {
  293. PORT_MESSAGE h;
  294. union {
  295. HANDLE DbgStateChangeSemaphore;
  296. struct {
  297. DBGKM_APINUMBER ApiNumber;
  298. NTSTATUS ReturnedStatus;
  299. union {
  300. DBGUI_CONTINUE Continue;
  301. DBGUI_WAIT_STATE_CHANGE WaitStateChange;
  302. DBGUI_STOPDEBUG StopDebug;
  303. } u;
  304. };
  305. };
  306. } DBGUI_APIMSG, *PDBGUI_APIMSG;
  307. typedef
  308. NTSTATUS
  309. (*PDBGSS_UI_LOOKUP) (
  310. IN PCLIENT_ID AppClientId,
  311. OUT PCLIENT_ID DebugUiClientId
  312. );
  313. typedef
  314. NTSTATUS
  315. (*PDBGSS_DBGKM_APIMSG_FILTER) (
  316. IN OUT PDBGKM_APIMSG ApiMsg
  317. );
  318. typedef
  319. NTSTATUS
  320. (*PDBGSS_SUBSYSTEMKEY_LOOKUP) (
  321. IN PCLIENT_ID AppClientId,
  322. OUT PULONG SubsystemKey,
  323. IN BOOLEAN ProcessKey
  324. );
  325. //
  326. // DbgSs APIs
  327. //
  328. NTSTATUS
  329. NTAPI
  330. DbgSsInitialize(
  331. IN HANDLE KmReplyPort,
  332. IN PDBGSS_UI_LOOKUP UiLookUpRoutine,
  333. IN PDBGSS_SUBSYSTEMKEY_LOOKUP SubsystemKeyLookupRoutine OPTIONAL,
  334. IN PDBGSS_DBGKM_APIMSG_FILTER KmApiMsgFilter OPTIONAL
  335. );
  336. VOID
  337. NTAPI
  338. DbgSsHandleKmApiMsg(
  339. IN PDBGKM_APIMSG ApiMsg,
  340. IN HANDLE ReplyEvent OPTIONAL
  341. );
  342. typedef
  343. NTSTATUS
  344. (*PDBGSS_INITIALIZE_ROUTINE)(
  345. IN HANDLE KmReplyPort,
  346. IN PDBGSS_UI_LOOKUP UiLookUpRoutine,
  347. IN PDBGSS_SUBSYSTEMKEY_LOOKUP SubsystemKeyLookupRoutine OPTIONAL,
  348. IN PDBGSS_DBGKM_APIMSG_FILTER KmApiMsgFilter OPTIONAL
  349. );
  350. typedef
  351. VOID
  352. (*PDBGSS_HANDLE_MSG_ROUTINE)(
  353. IN PDBGKM_APIMSG ApiMsg,
  354. IN HANDLE ReplyEvent OPTIONAL
  355. );
  356. //
  357. // DbgUi APIs
  358. //
  359. NTSTATUS
  360. NTAPI
  361. DbgUiConnectToDbg( VOID );
  362. HANDLE
  363. NTAPI
  364. DbgUiGetThreadDebugObject (
  365. );
  366. VOID
  367. NTAPI
  368. DbgUiSetThreadDebugObject (
  369. IN HANDLE DebugObject
  370. );
  371. NTSTATUS
  372. NTAPI
  373. DbgUiWaitStateChange (
  374. OUT PDBGUI_WAIT_STATE_CHANGE StateChange,
  375. IN PLARGE_INTEGER Timeout OPTIONAL
  376. );
  377. NTSTATUS
  378. NTAPI
  379. DbgUiContinue (
  380. IN PCLIENT_ID AppClientId,
  381. IN NTSTATUS ContinueStatus
  382. );
  383. NTSTATUS
  384. NTAPI
  385. DbgUiStopDebugging (
  386. IN HANDLE Process
  387. );
  388. NTSTATUS
  389. DbgUiDebugActiveProcess (
  390. IN HANDLE Process
  391. );
  392. VOID
  393. DbgUiRemoteBreakin (
  394. IN PVOID Context
  395. );
  396. NTSTATUS
  397. DbgUiIssueRemoteBreakin (
  398. IN HANDLE Process
  399. );
  400. struct _DEBUG_EVENT;
  401. NTSTATUS
  402. DbgUiConvertStateChangeStructure (
  403. IN PDBGUI_WAIT_STATE_CHANGE StateChange,
  404. OUT struct _DEBUG_EVENT *DebugEvent);
  405. #endif // DBG_NO_PORTABLE_TYPES
  406. typedef struct _KAPC_STATE32 {
  407. LIST_ENTRY32 ApcListHead[2];
  408. ULONG Process;
  409. BOOLEAN KernelApcInProgress;
  410. BOOLEAN KernelApcPending;
  411. BOOLEAN UserApcPending;
  412. } KAPC_STATE32;
  413. typedef struct _KAPC_STATE64 {
  414. LIST_ENTRY64 ApcListHead[2];
  415. ULONG64 Process;
  416. BOOLEAN KernelApcInProgress;
  417. BOOLEAN KernelApcPending;
  418. BOOLEAN UserApcPending;
  419. } KAPC_STATE64;
  420. typedef struct _DISPATCHER_HEADER32 {
  421. UCHAR Type;
  422. UCHAR Absolute;
  423. UCHAR Size;
  424. UCHAR Inserted;
  425. LONG SignalState;
  426. LIST_ENTRY32 WaitListHead;
  427. } DISPATCHER_HEADER32;
  428. typedef struct _DISPATCHER_HEADER64 {
  429. UCHAR Type;
  430. UCHAR Absolute;
  431. UCHAR Size;
  432. UCHAR Inserted;
  433. LONG SignalState;
  434. LIST_ENTRY64 WaitListHead;
  435. } DISPATCHER_HEADER64;
  436. typedef struct _KSPIN_LOCK_QUEUE32 {
  437. ULONG Next;
  438. ULONG Lock;
  439. } KSPIN_LOCK_QUEUE32, *PKSPIN_LOCK_QUEUE32;
  440. typedef struct _KSPIN_LOCK_QUEUE64 {
  441. ULONG64 Next;
  442. ULONG64 Lock;
  443. } KSPIN_LOCK_QUEUE64, *PKSPIN_LOCK_QUEUE64;
  444. typedef struct _PP_LOOKASIDE_LIST32 {
  445. ULONG P;
  446. ULONG L;
  447. } PP_LOOKASIDE_LIST32, *PPP_LOOKASIDE_LIST32;
  448. typedef struct _PP_LOOKASIDE_LIST64 {
  449. ULONG P;
  450. ULONG L;
  451. } PP_LOOKASIDE_LIST64, *PPP_LOOKASIDE_LIST64;
  452. #define NT51_POOL_SMALL_LISTS 32
  453. //
  454. // X86 KSWITCHFRAME
  455. //
  456. typedef struct _X86_KSWITCHFRAME {
  457. ULONG ExceptionList;
  458. ULONG Eflags;
  459. ULONG RetAddr;
  460. } X86_KSWITCHFRAME, *PX86_KSWITCHFRAME;
  461. //
  462. // Special Registers for i386
  463. //
  464. typedef struct _X86_DESCRIPTOR {
  465. USHORT Pad;
  466. USHORT Limit;
  467. ULONG Base;
  468. } X86_DESCRIPTOR, *PX86_DESCRIPTOR;
  469. typedef struct _X86_KSPECIAL_REGISTERS {
  470. ULONG Cr0;
  471. ULONG Cr2;
  472. ULONG Cr3;
  473. ULONG Cr4;
  474. ULONG KernelDr0;
  475. ULONG KernelDr1;
  476. ULONG KernelDr2;
  477. ULONG KernelDr3;
  478. ULONG KernelDr6;
  479. ULONG KernelDr7;
  480. X86_DESCRIPTOR Gdtr;
  481. X86_DESCRIPTOR Idtr;
  482. USHORT Tr;
  483. USHORT Ldtr;
  484. ULONG Reserved[6];
  485. } X86_KSPECIAL_REGISTERS, *PX86_KSPECIAL_REGISTERS;
  486. //
  487. // Define the size of the 80387 save area, which is in the context frame.
  488. //
  489. #define X86_SIZE_OF_80387_REGISTERS 80
  490. typedef struct _X86_FLOATING_SAVE_AREA {
  491. ULONG ControlWord;
  492. ULONG StatusWord;
  493. ULONG TagWord;
  494. ULONG ErrorOffset;
  495. ULONG ErrorSelector;
  496. ULONG DataOffset;
  497. ULONG DataSelector;
  498. UCHAR RegisterArea[X86_SIZE_OF_80387_REGISTERS];
  499. ULONG Cr0NpxState;
  500. } X86_FLOATING_SAVE_AREA;
  501. //
  502. // Simulated context structure for the 16-bit environment
  503. //
  504. typedef struct _X86_CONTEXT {
  505. ULONG ContextFlags;
  506. ULONG Dr0;
  507. ULONG Dr1;
  508. ULONG Dr2;
  509. ULONG Dr3;
  510. ULONG Dr6;
  511. ULONG Dr7;
  512. X86_FLOATING_SAVE_AREA FloatSave;
  513. ULONG SegGs;
  514. ULONG SegFs;
  515. ULONG SegEs;
  516. ULONG SegDs;
  517. ULONG Edi;
  518. ULONG Esi;
  519. ULONG Ebx;
  520. ULONG Edx;
  521. ULONG Ecx;
  522. ULONG Eax;
  523. ULONG Ebp;
  524. ULONG Eip;
  525. ULONG SegCs; // MUST BE SANITIZED
  526. ULONG EFlags; // MUST BE SANITIZED
  527. ULONG Esp;
  528. ULONG SegSs;
  529. } X86_CONTEXT, *PX86_CONTEXT;
  530. #define MAXIMUM_SUPPORTED_EXTENSION 512
  531. //
  532. // Define the size of FP registers in the FXSAVE format
  533. //
  534. #define X86_SIZE_OF_FX_REGISTERS 128
  535. typedef struct _X86_FXSAVE_FORMAT {
  536. USHORT ControlWord;
  537. USHORT StatusWord;
  538. USHORT TagWord;
  539. USHORT ErrorOpcode;
  540. ULONG ErrorOffset;
  541. ULONG ErrorSelector;
  542. ULONG DataOffset;
  543. ULONG DataSelector;
  544. ULONG MXCsr;
  545. ULONG Reserved2;
  546. UCHAR RegisterArea[X86_SIZE_OF_FX_REGISTERS];
  547. UCHAR Reserved3[X86_SIZE_OF_FX_REGISTERS];
  548. UCHAR Reserved4[224];
  549. } X86_FXSAVE_FORMAT, *PX86_FXSAVE_FORMAT;
  550. typedef struct _X86_NT5_CONTEXT {
  551. ULONG ContextFlags;
  552. ULONG Dr0;
  553. ULONG Dr1;
  554. ULONG Dr2;
  555. ULONG Dr3;
  556. ULONG Dr6;
  557. ULONG Dr7;
  558. X86_FLOATING_SAVE_AREA FloatSave;
  559. ULONG SegGs;
  560. ULONG SegFs;
  561. ULONG SegEs;
  562. ULONG SegDs;
  563. ULONG Edi;
  564. ULONG Esi;
  565. ULONG Ebx;
  566. ULONG Edx;
  567. ULONG Ecx;
  568. ULONG Eax;
  569. ULONG Ebp;
  570. ULONG Eip;
  571. ULONG SegCs; // MUST BE SANITIZED
  572. ULONG EFlags; // MUST BE SANITIZED
  573. ULONG Esp;
  574. ULONG SegSs;
  575. union {
  576. UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
  577. X86_FXSAVE_FORMAT FxSave;
  578. };
  579. } X86_NT5_CONTEXT, *PX86_NT5_CONTEXT;
  580. typedef struct _ALPHA_CONTEXT {
  581. ULONG FltF0;
  582. ULONG FltF1;
  583. ULONG FltF2;
  584. ULONG FltF3;
  585. ULONG FltF4;
  586. ULONG FltF5;
  587. ULONG FltF6;
  588. ULONG FltF7;
  589. ULONG FltF8;
  590. ULONG FltF9;
  591. ULONG FltF10;
  592. ULONG FltF11;
  593. ULONG FltF12;
  594. ULONG FltF13;
  595. ULONG FltF14;
  596. ULONG FltF15;
  597. ULONG FltF16;
  598. ULONG FltF17;
  599. ULONG FltF18;
  600. ULONG FltF19;
  601. ULONG FltF20;
  602. ULONG FltF21;
  603. ULONG FltF22;
  604. ULONG FltF23;
  605. ULONG FltF24;
  606. ULONG FltF25;
  607. ULONG FltF26;
  608. ULONG FltF27;
  609. ULONG FltF28;
  610. ULONG FltF29;
  611. ULONG FltF30;
  612. ULONG FltF31;
  613. ULONG IntV0; // $0: return value register, v0
  614. ULONG IntT0; // $1: temporary registers, t0 - t7
  615. ULONG IntT1; // $2:
  616. ULONG IntT2; // $3:
  617. ULONG IntT3; // $4:
  618. ULONG IntT4; // $5:
  619. ULONG IntT5; // $6:
  620. ULONG IntT6; // $7:
  621. ULONG IntT7; // $8:
  622. ULONG IntS0; // $9: nonvolatile registers, s0 - s5
  623. ULONG IntS1; // $10:
  624. ULONG IntS2; // $11:
  625. ULONG IntS3; // $12:
  626. ULONG IntS4; // $13:
  627. ULONG IntS5; // $14:
  628. ULONG IntFp; // $15: frame pointer register, fp/s6
  629. ULONG IntA0; // $16: argument registers, a0 - a5
  630. ULONG IntA1; // $17:
  631. ULONG IntA2; // $18:
  632. ULONG IntA3; // $19:
  633. ULONG IntA4; // $20:
  634. ULONG IntA5; // $21:
  635. ULONG IntT8; // $22: temporary registers, t8 - t11
  636. ULONG IntT9; // $23:
  637. ULONG IntT10; // $24:
  638. ULONG IntT11; // $25:
  639. ULONG IntRa; // $26: return address register, ra
  640. ULONG IntT12; // $27: temporary register, t12
  641. ULONG IntAt; // $28: assembler temp register, at
  642. ULONG IntGp; // $29: global pointer register, gp
  643. ULONG IntSp; // $30: stack pointer register, sp
  644. ULONG IntZero; // $31: zero register, zero
  645. ULONG Fpcr; // floating point control register
  646. ULONG SoftFpcr; // software extension to FPCR
  647. ULONG Fir; // (fault instruction) continuation address
  648. ULONG Psr; // processor status
  649. ULONG ContextFlags;
  650. //
  651. // Beginning of the "second half".
  652. // The name "High" parallels the HighPart of a LargeInteger.
  653. //
  654. ULONG HighFltF0;
  655. ULONG HighFltF1;
  656. ULONG HighFltF2;
  657. ULONG HighFltF3;
  658. ULONG HighFltF4;
  659. ULONG HighFltF5;
  660. ULONG HighFltF6;
  661. ULONG HighFltF7;
  662. ULONG HighFltF8;
  663. ULONG HighFltF9;
  664. ULONG HighFltF10;
  665. ULONG HighFltF11;
  666. ULONG HighFltF12;
  667. ULONG HighFltF13;
  668. ULONG HighFltF14;
  669. ULONG HighFltF15;
  670. ULONG HighFltF16;
  671. ULONG HighFltF17;
  672. ULONG HighFltF18;
  673. ULONG HighFltF19;
  674. ULONG HighFltF20;
  675. ULONG HighFltF21;
  676. ULONG HighFltF22;
  677. ULONG HighFltF23;
  678. ULONG HighFltF24;
  679. ULONG HighFltF25;
  680. ULONG HighFltF26;
  681. ULONG HighFltF27;
  682. ULONG HighFltF28;
  683. ULONG HighFltF29;
  684. ULONG HighFltF30;
  685. ULONG HighFltF31;
  686. ULONG HighIntV0; // $0: return value register, v0
  687. ULONG HighIntT0; // $1: temporary registers, t0 - t7
  688. ULONG HighIntT1; // $2:
  689. ULONG HighIntT2; // $3:
  690. ULONG HighIntT3; // $4:
  691. ULONG HighIntT4; // $5:
  692. ULONG HighIntT5; // $6:
  693. ULONG HighIntT6; // $7:
  694. ULONG HighIntT7; // $8:
  695. ULONG HighIntS0; // $9: nonvolatile registers, s0 - s5
  696. ULONG HighIntS1; // $10:
  697. ULONG HighIntS2; // $11:
  698. ULONG HighIntS3; // $12:
  699. ULONG HighIntS4; // $13:
  700. ULONG HighIntS5; // $14:
  701. ULONG HighIntFp; // $15: frame pointer register, fp/s6
  702. ULONG HighIntA0; // $16: argument registers, a0 - a5
  703. ULONG HighIntA1; // $17:
  704. ULONG HighIntA2; // $18:
  705. ULONG HighIntA3; // $19:
  706. ULONG HighIntA4; // $20:
  707. ULONG HighIntA5; // $21:
  708. ULONG HighIntT8; // $22: temporary registers, t8 - t11
  709. ULONG HighIntT9; // $23:
  710. ULONG HighIntT10; // $24:
  711. ULONG HighIntT11; // $25:
  712. ULONG HighIntRa; // $26: return address register, ra
  713. ULONG HighIntT12; // $27: temporary register, t12
  714. ULONG HighIntAt; // $28: assembler temp register, at
  715. ULONG HighIntGp; // $29: global pointer register, gp
  716. ULONG HighIntSp; // $30: stack pointer register, sp
  717. ULONG HighIntZero; // $31: zero register, zero
  718. ULONG HighFpcr; // floating point control register
  719. ULONG HighSoftFpcr; // software extension to FPCR
  720. ULONG HighFir; // processor status
  721. double DoNotUseThisField; // to force quadword structure alignment
  722. ULONG HighFill[2]; // padding for 16-byte stack frame alignment
  723. } ALPHA_CONTEXT, *PALPHA_CONTEXT;
  724. typedef struct _ALPHA_NT5_CONTEXT {
  725. //
  726. // This section is specified/returned if the ContextFlags word contains
  727. // the flag CONTEXT_FLOATING_POINT.
  728. //
  729. ULONGLONG FltF0;
  730. ULONGLONG FltF1;
  731. ULONGLONG FltF2;
  732. ULONGLONG FltF3;
  733. ULONGLONG FltF4;
  734. ULONGLONG FltF5;
  735. ULONGLONG FltF6;
  736. ULONGLONG FltF7;
  737. ULONGLONG FltF8;
  738. ULONGLONG FltF9;
  739. ULONGLONG FltF10;
  740. ULONGLONG FltF11;
  741. ULONGLONG FltF12;
  742. ULONGLONG FltF13;
  743. ULONGLONG FltF14;
  744. ULONGLONG FltF15;
  745. ULONGLONG FltF16;
  746. ULONGLONG FltF17;
  747. ULONGLONG FltF18;
  748. ULONGLONG FltF19;
  749. ULONGLONG FltF20;
  750. ULONGLONG FltF21;
  751. ULONGLONG FltF22;
  752. ULONGLONG FltF23;
  753. ULONGLONG FltF24;
  754. ULONGLONG FltF25;
  755. ULONGLONG FltF26;
  756. ULONGLONG FltF27;
  757. ULONGLONG FltF28;
  758. ULONGLONG FltF29;
  759. ULONGLONG FltF30;
  760. ULONGLONG FltF31;
  761. //
  762. // This section is specified/returned if the ContextFlags word contains
  763. // the flag CONTEXT_INTEGER.
  764. //
  765. // N.B. The registers gp, sp, and ra are defined in this section, but are
  766. // considered part of the control context rather than part of the integer
  767. // context.
  768. //
  769. ULONGLONG IntV0; // $0: return value register, v0
  770. ULONGLONG IntT0; // $1: temporary registers, t0 - t7
  771. ULONGLONG IntT1; // $2:
  772. ULONGLONG IntT2; // $3:
  773. ULONGLONG IntT3; // $4:
  774. ULONGLONG IntT4; // $5:
  775. ULONGLONG IntT5; // $6:
  776. ULONGLONG IntT6; // $7:
  777. ULONGLONG IntT7; // $8:
  778. ULONGLONG IntS0; // $9: nonvolatile registers, s0 - s5
  779. ULONGLONG IntS1; // $10:
  780. ULONGLONG IntS2; // $11:
  781. ULONGLONG IntS3; // $12:
  782. ULONGLONG IntS4; // $13:
  783. ULONGLONG IntS5; // $14:
  784. ULONGLONG IntFp; // $15: frame pointer register, fp/s6
  785. ULONGLONG IntA0; // $16: argument registers, a0 - a5
  786. ULONGLONG IntA1; // $17:
  787. ULONGLONG IntA2; // $18:
  788. ULONGLONG IntA3; // $19:
  789. ULONGLONG IntA4; // $20:
  790. ULONGLONG IntA5; // $21:
  791. ULONGLONG IntT8; // $22: temporary registers, t8 - t11
  792. ULONGLONG IntT9; // $23:
  793. ULONGLONG IntT10; // $24:
  794. ULONGLONG IntT11; // $25:
  795. ULONGLONG IntRa; // $26: return address register, ra
  796. ULONGLONG IntT12; // $27: temporary register, t12
  797. ULONGLONG IntAt; // $28: assembler temp register, at
  798. ULONGLONG IntGp; // $29: global pointer register, gp
  799. ULONGLONG IntSp; // $30: stack pointer register, sp
  800. ULONGLONG IntZero; // $31: zero register, zero
  801. //
  802. // This section is specified/returned if the ContextFlags word contains
  803. // the flag CONTEXT_FLOATING_POINT.
  804. //
  805. ULONGLONG Fpcr; // floating point control register
  806. ULONGLONG SoftFpcr; // software extension to FPCR
  807. //
  808. // This section is specified/returned if the ContextFlags word contains
  809. // the flag CONTEXT_CONTROL.
  810. //
  811. // N.B. The registers gp, sp, and ra are defined in the integer section,
  812. // but are considered part of the control context rather than part of
  813. // the integer context.
  814. //
  815. ULONGLONG Fir; // (fault instruction) continuation address
  816. ULONG Psr; // processor status
  817. //
  818. // The flags values within this flag control the contents of
  819. // a CONTEXT record.
  820. //
  821. // If the context record is used as an input parameter, then
  822. // for each portion of the context record controlled by a flag
  823. // whose value is set, it is assumed that that portion of the
  824. // context record contains valid context. If the context record
  825. // is being used to modify a thread's context, then only that
  826. // portion of the threads context will be modified.
  827. //
  828. // If the context record is used as an IN OUT parameter to capture
  829. // the context of a thread, then only those portions of the thread's
  830. // context corresponding to set flags will be returned.
  831. //
  832. // The context record is never used as an OUT only parameter.
  833. //
  834. ULONG ContextFlags;
  835. ULONG Fill[4]; // padding for 16-byte stack frame alignment
  836. } ALPHA_NT5_CONTEXT, *PALPHA_NT5_CONTEXT;
  837. typedef struct _IA64_KSPECIAL_REGISTERS { // Intel-IA64-Filler
  838. // Kernel debug breakpoint registers // Intel-IA64-Filler
  839. ULONGLONG KernelDbI0; // Instruction debug registers // Intel-IA64-Filler
  840. ULONGLONG KernelDbI1; // Intel-IA64-Filler
  841. ULONGLONG KernelDbI2; // Intel-IA64-Filler
  842. ULONGLONG KernelDbI3; // Intel-IA64-Filler
  843. ULONGLONG KernelDbI4; // Intel-IA64-Filler
  844. ULONGLONG KernelDbI5; // Intel-IA64-Filler
  845. ULONGLONG KernelDbI6; // Intel-IA64-Filler
  846. ULONGLONG KernelDbI7; // Intel-IA64-Filler
  847. ULONGLONG KernelDbD0; // Data debug registers // Intel-IA64-Filler
  848. ULONGLONG KernelDbD1; // Intel-IA64-Filler
  849. ULONGLONG KernelDbD2; // Intel-IA64-Filler
  850. ULONGLONG KernelDbD3; // Intel-IA64-Filler
  851. ULONGLONG KernelDbD4; // Intel-IA64-Filler
  852. ULONGLONG KernelDbD5; // Intel-IA64-Filler
  853. ULONGLONG KernelDbD6; // Intel-IA64-Filler
  854. ULONGLONG KernelDbD7; // Intel-IA64-Filler
  855. // Kernel performance monitor registers // Intel-IA64-Filler
  856. ULONGLONG KernelPfC0; // Performance configuration registers // Intel-IA64-Filler
  857. ULONGLONG KernelPfC1; // Intel-IA64-Filler
  858. ULONGLONG KernelPfC2; // Intel-IA64-Filler
  859. ULONGLONG KernelPfC3; // Intel-IA64-Filler
  860. ULONGLONG KernelPfC4; // Intel-IA64-Filler
  861. ULONGLONG KernelPfC5; // Intel-IA64-Filler
  862. ULONGLONG KernelPfC6; // Intel-IA64-Filler
  863. ULONGLONG KernelPfC7; // Intel-IA64-Filler
  864. ULONGLONG KernelPfD0; // Performance data registers // Intel-IA64-Filler
  865. ULONGLONG KernelPfD1; // Intel-IA64-Filler
  866. ULONGLONG KernelPfD2; // Intel-IA64-Filler
  867. ULONGLONG KernelPfD3; // Intel-IA64-Filler
  868. ULONGLONG KernelPfD4; // Intel-IA64-Filler
  869. ULONGLONG KernelPfD5; // Intel-IA64-Filler
  870. ULONGLONG KernelPfD6; // Intel-IA64-Filler
  871. ULONGLONG KernelPfD7; // Intel-IA64-Filler
  872. // kernel bank shadow (hidden) registers // Intel-IA64-Filler
  873. ULONGLONG IntH16; // Intel-IA64-Filler
  874. ULONGLONG IntH17; // Intel-IA64-Filler
  875. ULONGLONG IntH18; // Intel-IA64-Filler
  876. ULONGLONG IntH19; // Intel-IA64-Filler
  877. ULONGLONG IntH20; // Intel-IA64-Filler
  878. ULONGLONG IntH21; // Intel-IA64-Filler
  879. ULONGLONG IntH22; // Intel-IA64-Filler
  880. ULONGLONG IntH23; // Intel-IA64-Filler
  881. ULONGLONG IntH24; // Intel-IA64-Filler
  882. ULONGLONG IntH25; // Intel-IA64-Filler
  883. ULONGLONG IntH26; // Intel-IA64-Filler
  884. ULONGLONG IntH27; // Intel-IA64-Filler
  885. ULONGLONG IntH28; // Intel-IA64-Filler
  886. ULONGLONG IntH29; // Intel-IA64-Filler
  887. ULONGLONG IntH30; // Intel-IA64-Filler
  888. ULONGLONG IntH31; // Intel-IA64-Filler
  889. // Application Registers // Intel-IA64-Filler
  890. // - CPUID Registers - AR // Intel-IA64-Filler
  891. ULONGLONG ApCPUID0; // Cpuid Register 0 // Intel-IA64-Filler
  892. ULONGLONG ApCPUID1; // Cpuid Register 1 // Intel-IA64-Filler
  893. ULONGLONG ApCPUID2; // Cpuid Register 2 // Intel-IA64-Filler
  894. ULONGLONG ApCPUID3; // Cpuid Register 3 // Intel-IA64-Filler
  895. ULONGLONG ApCPUID4; // Cpuid Register 4 // Intel-IA64-Filler
  896. ULONGLONG ApCPUID5; // Cpuid Register 5 // Intel-IA64-Filler
  897. ULONGLONG ApCPUID6; // Cpuid Register 6 // Intel-IA64-Filler
  898. ULONGLONG ApCPUID7; // Cpuid Register 7 // Intel-IA64-Filler
  899. // - Kernel Registers - AR // Intel-IA64-Filler
  900. ULONGLONG ApKR0; // Kernel Register 0 (User RO) // Intel-IA64-Filler
  901. ULONGLONG ApKR1; // Kernel Register 1 (User RO) // Intel-IA64-Filler
  902. ULONGLONG ApKR2; // Kernel Register 2 (User RO) // Intel-IA64-Filler
  903. ULONGLONG ApKR3; // Kernel Register 3 (User RO) // Intel-IA64-Filler
  904. ULONGLONG ApKR4; // Kernel Register 4 // Intel-IA64-Filler
  905. ULONGLONG ApKR5; // Kernel Register 5 // Intel-IA64-Filler
  906. ULONGLONG ApKR6; // Kernel Register 6 // Intel-IA64-Filler
  907. ULONGLONG ApKR7; // Kernel Register 7 // Intel-IA64-Filler
  908. ULONGLONG ApITC; // Interval Timer Counter // Intel-IA64-Filler
  909. // Global control registers // Intel-IA64-Filler
  910. ULONGLONG ApITM; // Interval Timer Match register // Intel-IA64-Filler
  911. ULONGLONG ApIVA; // Interrupt Vector Address // Intel-IA64-Filler
  912. ULONGLONG ApPTA; // Page Table Address // Intel-IA64-Filler
  913. ULONGLONG ApGPTA; // ia32 Page Table Address // Intel-IA64-Filler
  914. ULONGLONG StISR; // Interrupt status // Intel-IA64-Filler
  915. ULONGLONG StIFA; // Interruption Faulting Address // Intel-IA64-Filler
  916. ULONGLONG StITIR; // Interruption TLB Insertion Register // Intel-IA64-Filler
  917. ULONGLONG StIIPA; // Interruption Instruction Previous Address (RO) // Intel-IA64-Filler
  918. ULONGLONG StIIM; // Interruption Immediate register (RO) // Intel-IA64-Filler
  919. ULONGLONG StIHA; // Interruption Hash Address (RO) // Intel-IA64-Filler
  920. // - External Interrupt control registers (SAPIC) // Intel-IA64-Filler
  921. ULONGLONG SaLID; // Local SAPIC ID // Intel-IA64-Filler
  922. ULONGLONG SaIVR; // Interrupt Vector Register (RO) // Intel-IA64-Filler
  923. ULONGLONG SaTPR; // Task Priority Register // Intel-IA64-Filler
  924. ULONGLONG SaEOI; // End Of Interrupt // Intel-IA64-Filler
  925. ULONGLONG SaIRR0; // Interrupt Request Register 0 (RO) // Intel-IA64-Filler
  926. ULONGLONG SaIRR1; // Interrupt Request Register 1 (RO) // Intel-IA64-Filler
  927. ULONGLONG SaIRR2; // Interrupt Request Register 2 (RO) // Intel-IA64-Filler
  928. ULONGLONG SaIRR3; // Interrupt Request Register 3 (RO) // Intel-IA64-Filler
  929. ULONGLONG SaITV; // Interrupt Timer Vector // Intel-IA64-Filler
  930. ULONGLONG SaPMV; // Performance Monitor Vector // Intel-IA64-Filler
  931. ULONGLONG SaCMCV; // Corrected Machine Check Vector // Intel-IA64-Filler
  932. ULONGLONG SaLRR0; // Local Interrupt Redirection Vector 0 // Intel-IA64-Filler
  933. ULONGLONG SaLRR1; // Local Interrupt Redirection Vector 1 // Intel-IA64-Filler
  934. // System Registers // Intel-IA64-Filler
  935. // - Region registers // Intel-IA64-Filler
  936. ULONGLONG Rr0; // Region register 0 // Intel-IA64-Filler
  937. ULONGLONG Rr1; // Region register 1 // Intel-IA64-Filler
  938. ULONGLONG Rr2; // Region register 2 // Intel-IA64-Filler
  939. ULONGLONG Rr3; // Region register 3 // Intel-IA64-Filler
  940. ULONGLONG Rr4; // Region register 4 // Intel-IA64-Filler
  941. ULONGLONG Rr5; // Region register 5 // Intel-IA64-Filler
  942. ULONGLONG Rr6; // Region register 6 // Intel-IA64-Filler
  943. ULONGLONG Rr7; // Region register 7 // Intel-IA64-Filler
  944. // - Protection Key registers // Intel-IA64-Filler
  945. ULONGLONG Pkr0; // Protection Key register 0 // Intel-IA64-Filler
  946. ULONGLONG Pkr1; // Protection Key register 1 // Intel-IA64-Filler
  947. ULONGLONG Pkr2; // Protection Key register 2 // Intel-IA64-Filler
  948. ULONGLONG Pkr3; // Protection Key register 3 // Intel-IA64-Filler
  949. ULONGLONG Pkr4; // Protection Key register 4 // Intel-IA64-Filler
  950. ULONGLONG Pkr5; // Protection Key register 5 // Intel-IA64-Filler
  951. ULONGLONG Pkr6; // Protection Key register 6 // Intel-IA64-Filler
  952. ULONGLONG Pkr7; // Protection Key register 7 // Intel-IA64-Filler
  953. ULONGLONG Pkr8; // Protection Key register 8 // Intel-IA64-Filler
  954. ULONGLONG Pkr9; // Protection Key register 9 // Intel-IA64-Filler
  955. ULONGLONG Pkr10; // Protection Key register 10 // Intel-IA64-Filler
  956. ULONGLONG Pkr11; // Protection Key register 11 // Intel-IA64-Filler
  957. ULONGLONG Pkr12; // Protection Key register 12 // Intel-IA64-Filler
  958. ULONGLONG Pkr13; // Protection Key register 13 // Intel-IA64-Filler
  959. ULONGLONG Pkr14; // Protection Key register 14 // Intel-IA64-Filler
  960. ULONGLONG Pkr15; // Protection Key register 15 // Intel-IA64-Filler
  961. // - Translation Lookaside buffers // Intel-IA64-Filler
  962. ULONGLONG TrI0; // Instruction Translation Register 0 // Intel-IA64-Filler
  963. ULONGLONG TrI1; // Instruction Translation Register 1 // Intel-IA64-Filler
  964. ULONGLONG TrI2; // Instruction Translation Register 2 // Intel-IA64-Filler
  965. ULONGLONG TrI3; // Instruction Translation Register 3 // Intel-IA64-Filler
  966. ULONGLONG TrI4; // Instruction Translation Register 4 // Intel-IA64-Filler
  967. ULONGLONG TrI5; // Instruction Translation Register 5 // Intel-IA64-Filler
  968. ULONGLONG TrI6; // Instruction Translation Register 6 // Intel-IA64-Filler
  969. ULONGLONG TrI7; // Instruction Translation Register 7 // Intel-IA64-Filler
  970. ULONGLONG TrD0; // Data Translation Register 0 // Intel-IA64-Filler
  971. ULONGLONG TrD1; // Data Translation Register 1 // Intel-IA64-Filler
  972. ULONGLONG TrD2; // Data Translation Register 2 // Intel-IA64-Filler
  973. ULONGLONG TrD3; // Data Translation Register 3 // Intel-IA64-Filler
  974. ULONGLONG TrD4; // Data Translation Register 4 // Intel-IA64-Filler
  975. ULONGLONG TrD5; // Data Translation Register 5 // Intel-IA64-Filler
  976. ULONGLONG TrD6; // Data Translation Register 6 // Intel-IA64-Filler
  977. ULONGLONG TrD7; // Data Translation Register 7 // Intel-IA64-Filler
  978. // - Machine Specific Registers // Intel-IA64-Filler
  979. ULONGLONG SrMSR0; // Machine Specific Register 0 // Intel-IA64-Filler
  980. ULONGLONG SrMSR1; // Machine Specific Register 1 // Intel-IA64-Filler
  981. ULONGLONG SrMSR2; // Machine Specific Register 2 // Intel-IA64-Filler
  982. ULONGLONG SrMSR3; // Machine Specific Register 3 // Intel-IA64-Filler
  983. ULONGLONG SrMSR4; // Machine Specific Register 4 // Intel-IA64-Filler
  984. ULONGLONG SrMSR5; // Machine Specific Register 5 // Intel-IA64-Filler
  985. ULONGLONG SrMSR6; // Machine Specific Register 6 // Intel-IA64-Filler
  986. ULONGLONG SrMSR7; // Machine Specific Register 7 // Intel-IA64-Filler
  987. } IA64_KSPECIAL_REGISTERS, *PIA64_KSPECIAL_REGISTERS; // Intel-IA64-Filler
  988. typedef struct _IA64_CONTEXT {
  989. //
  990. // The flags values within this flag control the contents of
  991. // a CONTEXT record.
  992. //
  993. // If the context record is used as an input parameter, then
  994. // for each portion of the context record controlled by a flag
  995. // whose value is set, it is assumed that that portion of the
  996. // context record contains valid context. If the context record
  997. // is being used to modify a thread's context, then only that
  998. // portion of the threads context will be modified.
  999. //
  1000. // If the context record is used as an IN OUT parameter to capture
  1001. // the context of a thread, then only those portions of the thread's
  1002. // context corresponding to set flags will be returned.
  1003. //
  1004. // The context record is never used as an OUT only parameter.
  1005. //
  1006. ULONG ContextFlags;
  1007. ULONG Fill1[3]; // for alignment of following on 16-byte boundary
  1008. //
  1009. // This section is specified/returned if the ContextFlags word contains
  1010. // the flag CONTEXT_DEBUG.
  1011. //
  1012. // N.B. CONTEXT_DEBUG is *not* part of CONTEXT_FULL.
  1013. //
  1014. ULONGLONG DbI0; // Intel-IA64-Filler
  1015. ULONGLONG DbI1; // Intel-IA64-Filler
  1016. ULONGLONG DbI2; // Intel-IA64-Filler
  1017. ULONGLONG DbI3; // Intel-IA64-Filler
  1018. ULONGLONG DbI4; // Intel-IA64-Filler
  1019. ULONGLONG DbI5; // Intel-IA64-Filler
  1020. ULONGLONG DbI6; // Intel-IA64-Filler
  1021. ULONGLONG DbI7; // Intel-IA64-Filler
  1022. ULONGLONG DbD0; // Intel-IA64-Filler
  1023. ULONGLONG DbD1; // Intel-IA64-Filler
  1024. ULONGLONG DbD2; // Intel-IA64-Filler
  1025. ULONGLONG DbD3; // Intel-IA64-Filler
  1026. ULONGLONG DbD4; // Intel-IA64-Filler
  1027. ULONGLONG DbD5; // Intel-IA64-Filler
  1028. ULONGLONG DbD6; // Intel-IA64-Filler
  1029. ULONGLONG DbD7; // Intel-IA64-Filler
  1030. //
  1031. // This section is specified/returned if the ContextFlags word contains
  1032. // the flag CONTEXT_LOWER_FLOATING_POINT.
  1033. //
  1034. FLOAT128 FltS0; // Intel-IA64-Filler
  1035. FLOAT128 FltS1; // Intel-IA64-Filler
  1036. FLOAT128 FltS2; // Intel-IA64-Filler
  1037. FLOAT128 FltS3; // Intel-IA64-Filler
  1038. FLOAT128 FltT0; // Intel-IA64-Filler
  1039. FLOAT128 FltT1; // Intel-IA64-Filler
  1040. FLOAT128 FltT2; // Intel-IA64-Filler
  1041. FLOAT128 FltT3; // Intel-IA64-Filler
  1042. FLOAT128 FltT4; // Intel-IA64-Filler
  1043. FLOAT128 FltT5; // Intel-IA64-Filler
  1044. FLOAT128 FltT6; // Intel-IA64-Filler
  1045. FLOAT128 FltT7; // Intel-IA64-Filler
  1046. FLOAT128 FltT8; // Intel-IA64-Filler
  1047. FLOAT128 FltT9; // Intel-IA64-Filler
  1048. //
  1049. // This section is specified/returned if the ContextFlags word contains
  1050. // the flag CONTEXT_HIGHER_FLOATING_POINT.
  1051. //
  1052. FLOAT128 FltS4; // Intel-IA64-Filler
  1053. FLOAT128 FltS5; // Intel-IA64-Filler
  1054. FLOAT128 FltS6; // Intel-IA64-Filler
  1055. FLOAT128 FltS7; // Intel-IA64-Filler
  1056. FLOAT128 FltS8; // Intel-IA64-Filler
  1057. FLOAT128 FltS9; // Intel-IA64-Filler
  1058. FLOAT128 FltS10; // Intel-IA64-Filler
  1059. FLOAT128 FltS11; // Intel-IA64-Filler
  1060. FLOAT128 FltS12; // Intel-IA64-Filler
  1061. FLOAT128 FltS13; // Intel-IA64-Filler
  1062. FLOAT128 FltS14; // Intel-IA64-Filler
  1063. FLOAT128 FltS15; // Intel-IA64-Filler
  1064. FLOAT128 FltS16; // Intel-IA64-Filler
  1065. FLOAT128 FltS17; // Intel-IA64-Filler
  1066. FLOAT128 FltS18; // Intel-IA64-Filler
  1067. FLOAT128 FltS19; // Intel-IA64-Filler
  1068. FLOAT128 FltF32; // Intel-IA64-Filler
  1069. FLOAT128 FltF33; // Intel-IA64-Filler
  1070. FLOAT128 FltF34; // Intel-IA64-Filler
  1071. FLOAT128 FltF35; // Intel-IA64-Filler
  1072. FLOAT128 FltF36; // Intel-IA64-Filler
  1073. FLOAT128 FltF37; // Intel-IA64-Filler
  1074. FLOAT128 FltF38; // Intel-IA64-Filler
  1075. FLOAT128 FltF39; // Intel-IA64-Filler
  1076. FLOAT128 FltF40; // Intel-IA64-Filler
  1077. FLOAT128 FltF41; // Intel-IA64-Filler
  1078. FLOAT128 FltF42; // Intel-IA64-Filler
  1079. FLOAT128 FltF43; // Intel-IA64-Filler
  1080. FLOAT128 FltF44; // Intel-IA64-Filler
  1081. FLOAT128 FltF45; // Intel-IA64-Filler
  1082. FLOAT128 FltF46; // Intel-IA64-Filler
  1083. FLOAT128 FltF47; // Intel-IA64-Filler
  1084. FLOAT128 FltF48; // Intel-IA64-Filler
  1085. FLOAT128 FltF49; // Intel-IA64-Filler
  1086. FLOAT128 FltF50; // Intel-IA64-Filler
  1087. FLOAT128 FltF51; // Intel-IA64-Filler
  1088. FLOAT128 FltF52; // Intel-IA64-Filler
  1089. FLOAT128 FltF53; // Intel-IA64-Filler
  1090. FLOAT128 FltF54; // Intel-IA64-Filler
  1091. FLOAT128 FltF55; // Intel-IA64-Filler
  1092. FLOAT128 FltF56; // Intel-IA64-Filler
  1093. FLOAT128 FltF57; // Intel-IA64-Filler
  1094. FLOAT128 FltF58; // Intel-IA64-Filler
  1095. FLOAT128 FltF59; // Intel-IA64-Filler
  1096. FLOAT128 FltF60; // Intel-IA64-Filler
  1097. FLOAT128 FltF61; // Intel-IA64-Filler
  1098. FLOAT128 FltF62; // Intel-IA64-Filler
  1099. FLOAT128 FltF63; // Intel-IA64-Filler
  1100. FLOAT128 FltF64; // Intel-IA64-Filler
  1101. FLOAT128 FltF65; // Intel-IA64-Filler
  1102. FLOAT128 FltF66; // Intel-IA64-Filler
  1103. FLOAT128 FltF67; // Intel-IA64-Filler
  1104. FLOAT128 FltF68; // Intel-IA64-Filler
  1105. FLOAT128 FltF69; // Intel-IA64-Filler
  1106. FLOAT128 FltF70; // Intel-IA64-Filler
  1107. FLOAT128 FltF71; // Intel-IA64-Filler
  1108. FLOAT128 FltF72; // Intel-IA64-Filler
  1109. FLOAT128 FltF73; // Intel-IA64-Filler
  1110. FLOAT128 FltF74; // Intel-IA64-Filler
  1111. FLOAT128 FltF75; // Intel-IA64-Filler
  1112. FLOAT128 FltF76; // Intel-IA64-Filler
  1113. FLOAT128 FltF77; // Intel-IA64-Filler
  1114. FLOAT128 FltF78; // Intel-IA64-Filler
  1115. FLOAT128 FltF79; // Intel-IA64-Filler
  1116. FLOAT128 FltF80; // Intel-IA64-Filler
  1117. FLOAT128 FltF81; // Intel-IA64-Filler
  1118. FLOAT128 FltF82; // Intel-IA64-Filler
  1119. FLOAT128 FltF83; // Intel-IA64-Filler
  1120. FLOAT128 FltF84; // Intel-IA64-Filler
  1121. FLOAT128 FltF85; // Intel-IA64-Filler
  1122. FLOAT128 FltF86; // Intel-IA64-Filler
  1123. FLOAT128 FltF87; // Intel-IA64-Filler
  1124. FLOAT128 FltF88; // Intel-IA64-Filler
  1125. FLOAT128 FltF89; // Intel-IA64-Filler
  1126. FLOAT128 FltF90; // Intel-IA64-Filler
  1127. FLOAT128 FltF91; // Intel-IA64-Filler
  1128. FLOAT128 FltF92; // Intel-IA64-Filler
  1129. FLOAT128 FltF93; // Intel-IA64-Filler
  1130. FLOAT128 FltF94; // Intel-IA64-Filler
  1131. FLOAT128 FltF95; // Intel-IA64-Filler
  1132. FLOAT128 FltF96; // Intel-IA64-Filler
  1133. FLOAT128 FltF97; // Intel-IA64-Filler
  1134. FLOAT128 FltF98; // Intel-IA64-Filler
  1135. FLOAT128 FltF99; // Intel-IA64-Filler
  1136. FLOAT128 FltF100; // Intel-IA64-Filler
  1137. FLOAT128 FltF101; // Intel-IA64-Filler
  1138. FLOAT128 FltF102; // Intel-IA64-Filler
  1139. FLOAT128 FltF103; // Intel-IA64-Filler
  1140. FLOAT128 FltF104; // Intel-IA64-Filler
  1141. FLOAT128 FltF105; // Intel-IA64-Filler
  1142. FLOAT128 FltF106; // Intel-IA64-Filler
  1143. FLOAT128 FltF107; // Intel-IA64-Filler
  1144. FLOAT128 FltF108; // Intel-IA64-Filler
  1145. FLOAT128 FltF109; // Intel-IA64-Filler
  1146. FLOAT128 FltF110; // Intel-IA64-Filler
  1147. FLOAT128 FltF111; // Intel-IA64-Filler
  1148. FLOAT128 FltF112; // Intel-IA64-Filler
  1149. FLOAT128 FltF113; // Intel-IA64-Filler
  1150. FLOAT128 FltF114; // Intel-IA64-Filler
  1151. FLOAT128 FltF115; // Intel-IA64-Filler
  1152. FLOAT128 FltF116; // Intel-IA64-Filler
  1153. FLOAT128 FltF117; // Intel-IA64-Filler
  1154. FLOAT128 FltF118; // Intel-IA64-Filler
  1155. FLOAT128 FltF119; // Intel-IA64-Filler
  1156. FLOAT128 FltF120; // Intel-IA64-Filler
  1157. FLOAT128 FltF121; // Intel-IA64-Filler
  1158. FLOAT128 FltF122; // Intel-IA64-Filler
  1159. FLOAT128 FltF123; // Intel-IA64-Filler
  1160. FLOAT128 FltF124; // Intel-IA64-Filler
  1161. FLOAT128 FltF125; // Intel-IA64-Filler
  1162. FLOAT128 FltF126; // Intel-IA64-Filler
  1163. FLOAT128 FltF127; // Intel-IA64-Filler
  1164. //
  1165. // This section is specified/returned if the ContextFlags word contains
  1166. // the flag CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT | CONTEXT_CONTROL.
  1167. //
  1168. ULONGLONG StFPSR; // Intel-IA64-Filler ; FP status
  1169. //
  1170. // This section is specified/returned if the ContextFlags word contains
  1171. // the flag CONTEXT_INTEGER.
  1172. //
  1173. // N.B. The registers gp, sp, rp are part of the control context
  1174. //
  1175. ULONGLONG IntGp; // Intel-IA64-Filler ; r1, volatile
  1176. ULONGLONG IntT0; // Intel-IA64-Filler ; r2-r3, volatile
  1177. ULONGLONG IntT1; // Intel-IA64-Filler ;
  1178. ULONGLONG IntS0; // Intel-IA64-Filler ; r4-r7, preserved
  1179. ULONGLONG IntS1; // Intel-IA64-Filler
  1180. ULONGLONG IntS2; // Intel-IA64-Filler
  1181. ULONGLONG IntS3; // Intel-IA64-Filler
  1182. ULONGLONG IntV0; // Intel-IA64-Filler ; r8, volatile
  1183. ULONGLONG IntT2; // Intel-IA64-Filler ; r9-r11, volatile
  1184. ULONGLONG IntT3; // Intel-IA64-Filler
  1185. ULONGLONG IntT4; // Intel-IA64-Filler
  1186. ULONGLONG IntSp; // Intel-IA64-Filler ; stack pointer (r12), special
  1187. ULONGLONG IntTeb; // Intel-IA64-Filler ; teb (r13), special
  1188. ULONGLONG IntT5; // Intel-IA64-Filler ; r14-r31, volatile
  1189. ULONGLONG IntT6; // Intel-IA64-Filler
  1190. ULONGLONG IntT7; // Intel-IA64-Filler
  1191. ULONGLONG IntT8; // Intel-IA64-Filler
  1192. ULONGLONG IntT9; // Intel-IA64-Filler
  1193. ULONGLONG IntT10; // Intel-IA64-Filler
  1194. ULONGLONG IntT11; // Intel-IA64-Filler
  1195. ULONGLONG IntT12; // Intel-IA64-Filler
  1196. ULONGLONG IntT13; // Intel-IA64-Filler
  1197. ULONGLONG IntT14; // Intel-IA64-Filler
  1198. ULONGLONG IntT15; // Intel-IA64-Filler
  1199. ULONGLONG IntT16; // Intel-IA64-Filler
  1200. ULONGLONG IntT17; // Intel-IA64-Filler
  1201. ULONGLONG IntT18; // Intel-IA64-Filler
  1202. ULONGLONG IntT19; // Intel-IA64-Filler
  1203. ULONGLONG IntT20; // Intel-IA64-Filler
  1204. ULONGLONG IntT21; // Intel-IA64-Filler
  1205. ULONGLONG IntT22; // Intel-IA64-Filler
  1206. ULONGLONG IntNats; // Intel-IA64-Filler ; Nat bits for r1-r31
  1207. // Intel-IA64-Filler ; r1-r31 in bits 1 thru 31.
  1208. ULONGLONG Preds; // Intel-IA64-Filler ; predicates, preserved
  1209. ULONGLONG BrRp; // Intel-IA64-Filler ; return pointer, b0, preserved
  1210. ULONGLONG BrS0; // Intel-IA64-Filler ; b1-b5, preserved
  1211. ULONGLONG BrS1; // Intel-IA64-Filler
  1212. ULONGLONG BrS2; // Intel-IA64-Filler
  1213. ULONGLONG BrS3; // Intel-IA64-Filler
  1214. ULONGLONG BrS4; // Intel-IA64-Filler
  1215. ULONGLONG BrT0; // Intel-IA64-Filler ; b6-b7, volatile
  1216. ULONGLONG BrT1; // Intel-IA64-Filler
  1217. //
  1218. // This section is specified/returned if the ContextFlags word contains
  1219. // the flag CONTEXT_CONTROL.
  1220. //
  1221. // Other application registers
  1222. ULONGLONG ApUNAT; // Intel-IA64-Filler ; User Nat collection register, preserved
  1223. ULONGLONG ApLC; // Intel-IA64-Filler ; Loop counter register, preserved
  1224. ULONGLONG ApEC; // Intel-IA64-Filler ; Epilog counter register, preserved
  1225. ULONGLONG ApCCV; // Intel-IA64-Filler ; CMPXCHG value register, volatile
  1226. ULONGLONG ApDCR; // Intel-IA64-Filler ; Default control register (TBD)
  1227. // Register stack info
  1228. ULONGLONG RsPFS; // Intel-IA64-Filler ; Previous function state, preserved
  1229. ULONGLONG RsBSP; // Intel-IA64-Filler ; Backing store pointer, preserved
  1230. ULONGLONG RsBSPSTORE; // Intel-IA64-Filler
  1231. ULONGLONG RsRSC; // Intel-IA64-Filler ; RSE configuration, volatile
  1232. ULONGLONG RsRNAT; // Intel-IA64-Filler ; RSE Nat collection register, preserved
  1233. // Trap Status Information
  1234. ULONGLONG StIPSR; // Intel-IA64-Filler ; Interruption Processor Status
  1235. ULONGLONG StIIP; // Intel-IA64-Filler ; Interruption IP
  1236. ULONGLONG StIFS; // Intel-IA64-Filler ; Interruption Function State
  1237. // iA32 related control registers
  1238. ULONGLONG StFCR; // Intel-IA64-Filler ; copy of Ar21
  1239. ULONGLONG Eflag; // Intel-IA64-Filler ; Eflag copy of Ar24
  1240. ULONGLONG SegCSD; // Intel-IA64-Filler ; iA32 CSDescriptor (Ar25)
  1241. ULONGLONG SegSSD; // Intel-IA64-Filler ; iA32 SSDescriptor (Ar26)
  1242. ULONGLONG Cflag; // Intel-IA64-Filler ; Cr0+Cr4 copy of Ar27
  1243. ULONGLONG StFSR; // Intel-IA64-Filler ; x86 FP status (copy of AR28)
  1244. ULONGLONG StFIR; // Intel-IA64-Filler ; x86 FP status (copy of AR29)
  1245. ULONGLONG StFDR; // Intel-IA64-Filler ; x86 FP status (copy of AR30)
  1246. ULONGLONG UNUSEDPACK; // Intel-IA64-Filler ; added to pack StFDR to 16-bytes
  1247. } IA64_CONTEXT, *PIA64_CONTEXT;
  1248. //
  1249. // Special Registers for AMD64.
  1250. //
  1251. typedef struct _AMD64_DESCRIPTOR {
  1252. USHORT Pad[3];
  1253. USHORT Limit;
  1254. ULONG64 Base;
  1255. } AMD64_DESCRIPTOR, *PAMD64_DESCRIPTOR;
  1256. typedef struct _AMD64_KSPECIAL_REGISTERS {
  1257. ULONG64 Cr0;
  1258. ULONG64 Cr2;
  1259. ULONG64 Cr3;
  1260. ULONG64 Cr4;
  1261. ULONG64 KernelDr0;
  1262. ULONG64 KernelDr1;
  1263. ULONG64 KernelDr2;
  1264. ULONG64 KernelDr3;
  1265. ULONG64 KernelDr6;
  1266. ULONG64 KernelDr7;
  1267. AMD64_DESCRIPTOR Gdtr;
  1268. AMD64_DESCRIPTOR Idtr;
  1269. USHORT Tr;
  1270. USHORT Ldtr;
  1271. ULONG MxCsr;
  1272. ULONG64 DebugControl;
  1273. ULONG64 LastBranchToRip;
  1274. ULONG64 LastBranchFromRip;
  1275. ULONG64 LastExceptionToRip;
  1276. ULONG64 LastExceptionFromRip;
  1277. ULONG64 Cr8;
  1278. ULONG64 MsrGsBase;
  1279. ULONG64 MsrGsSwap;
  1280. ULONG64 MsrStar;
  1281. ULONG64 MsrLStar;
  1282. ULONG64 MsrCStar;
  1283. ULONG64 MsrSyscallMask;
  1284. } AMD64_KSPECIAL_REGISTERS, *PAMD64_KSPECIAL_REGISTERS;
  1285. typedef struct _AMD64_KSWITCH_FRAME {
  1286. ULONG64 P1Home;
  1287. ULONG64 P2Home;
  1288. ULONG64 P3Home;
  1289. ULONG64 P4Home;
  1290. ULONG64 P5Home;
  1291. ULONG MxCsr;
  1292. KIRQL ApcBypass;
  1293. UCHAR Fill1[3];
  1294. ULONG64 Rbp;
  1295. ULONG64 Return;
  1296. } AMD64_KSWITCH_FRAME, *PAMD64_KSWITCH_FRAME;
  1297. //
  1298. // Format of data for fnsave/frstor instructions.
  1299. //
  1300. // This structure is used to store the legacy floating point state.
  1301. //
  1302. typedef struct _AMD64_LEGACY_SAVE_AREA {
  1303. USHORT ControlWord;
  1304. USHORT Reserved0;
  1305. USHORT StatusWord;
  1306. USHORT Reserved1;
  1307. USHORT TagWord;
  1308. USHORT Reserved2;
  1309. ULONG ErrorOffset;
  1310. USHORT ErrorSelector;
  1311. USHORT ErrorOpcode;
  1312. ULONG DataOffset;
  1313. USHORT DataSelector;
  1314. USHORT Reserved3;
  1315. UCHAR FloatRegisters[8 * 10];
  1316. } AMD64_LEGACY_SAVE_AREA, *PAMD64_LEGACY_SAVE_AREA;
  1317. typedef struct _AMD64_M128 {
  1318. ULONGLONG Low;
  1319. LONGLONG High;
  1320. } AMD64_M128, *PAMD64_M128;
  1321. // Must be 16-byte aligned.
  1322. typedef struct _AMD64_CONTEXT {
  1323. //
  1324. // Register parameter home addresses.
  1325. //
  1326. ULONG64 P1Home;
  1327. ULONG64 P2Home;
  1328. ULONG64 P3Home;
  1329. ULONG64 P4Home;
  1330. ULONG64 P5Home;
  1331. ULONG64 P6Home;
  1332. //
  1333. // Control flags.
  1334. //
  1335. ULONG ContextFlags;
  1336. ULONG MxCsr;
  1337. //
  1338. // Segment Registers and processor flags.
  1339. //
  1340. USHORT SegCs;
  1341. USHORT SegDs;
  1342. USHORT SegEs;
  1343. USHORT SegFs;
  1344. USHORT SegGs;
  1345. USHORT SegSs;
  1346. ULONG EFlags;
  1347. //
  1348. // Debug registers
  1349. //
  1350. ULONG64 Dr0;
  1351. ULONG64 Dr1;
  1352. ULONG64 Dr2;
  1353. ULONG64 Dr3;
  1354. ULONG64 Dr6;
  1355. ULONG64 Dr7;
  1356. //
  1357. // Integer registers.
  1358. //
  1359. ULONG64 Rax;
  1360. ULONG64 Rcx;
  1361. ULONG64 Rdx;
  1362. ULONG64 Rbx;
  1363. ULONG64 Rsp;
  1364. ULONG64 Rbp;
  1365. ULONG64 Rsi;
  1366. ULONG64 Rdi;
  1367. ULONG64 R8;
  1368. ULONG64 R9;
  1369. ULONG64 R10;
  1370. ULONG64 R11;
  1371. ULONG64 R12;
  1372. ULONG64 R13;
  1373. ULONG64 R14;
  1374. ULONG64 R15;
  1375. //
  1376. // Program counter.
  1377. //
  1378. ULONG64 Rip;
  1379. //
  1380. // MMX/floating point state.
  1381. //
  1382. AMD64_M128 Xmm0;
  1383. AMD64_M128 Xmm1;
  1384. AMD64_M128 Xmm2;
  1385. AMD64_M128 Xmm3;
  1386. AMD64_M128 Xmm4;
  1387. AMD64_M128 Xmm5;
  1388. AMD64_M128 Xmm6;
  1389. AMD64_M128 Xmm7;
  1390. AMD64_M128 Xmm8;
  1391. AMD64_M128 Xmm9;
  1392. AMD64_M128 Xmm10;
  1393. AMD64_M128 Xmm11;
  1394. AMD64_M128 Xmm12;
  1395. AMD64_M128 Xmm13;
  1396. AMD64_M128 Xmm14;
  1397. AMD64_M128 Xmm15;
  1398. //
  1399. // Legacy floating point state.
  1400. //
  1401. AMD64_LEGACY_SAVE_AREA FltSave;
  1402. ULONG Fill;
  1403. //
  1404. // Special debug control registers.
  1405. //
  1406. ULONG64 DebugControl;
  1407. ULONG64 LastBranchToRip;
  1408. ULONG64 LastBranchFromRip;
  1409. ULONG64 LastExceptionToRip;
  1410. ULONG64 LastExceptionFromRip;
  1411. ULONG64 Fill1;
  1412. } AMD64_CONTEXT, *PAMD64_CONTEXT;
  1413. typedef struct _ARM_CONTEXT {
  1414. //
  1415. // The flags values within this flag control the contents of
  1416. // a CONTEXT record.
  1417. //
  1418. // If the context record is used as an input parameter, then
  1419. // for each portion of the context record controlled by a flag
  1420. // whose value is set, it is assumed that that portion of the
  1421. // context record contains valid context. If the context record
  1422. // is being used to modify a thread's context, then only that
  1423. // portion of the threads context will be modified.
  1424. //
  1425. // If the context record is used as an IN OUT parameter to capture
  1426. // the context of a thread, then only those portions of the thread's
  1427. // context corresponding to set flags will be returned.
  1428. //
  1429. // The context record is never used as an OUT only parameter.
  1430. //
  1431. ULONG ContextFlags;
  1432. //
  1433. // This section is specified/returned if the ContextFlags word contains
  1434. // the flag CONTEXT_INTEGER.
  1435. //
  1436. ULONG R0;
  1437. ULONG R1;
  1438. ULONG R2;
  1439. ULONG R3;
  1440. ULONG R4;
  1441. ULONG R5;
  1442. ULONG R6;
  1443. ULONG R7;
  1444. ULONG R8;
  1445. ULONG R9;
  1446. ULONG R10;
  1447. ULONG R11;
  1448. ULONG R12;
  1449. //
  1450. // This section is specified/returned if the ContextFlags word contains
  1451. // the flag CONTEXT_CONTROL.
  1452. //
  1453. ULONG Sp;
  1454. ULONG Lr;
  1455. ULONG Pc;
  1456. ULONG Psr;
  1457. } ARM_CONTEXT, *PARM_CONTEXT;
  1458. typedef struct _CROSS_PLATFORM_CONTEXT {
  1459. union {
  1460. X86_CONTEXT X86Context;
  1461. X86_NT5_CONTEXT X86Nt5Context;
  1462. ALPHA_CONTEXT AlphaContext;
  1463. ALPHA_NT5_CONTEXT AlphaNt5Context;
  1464. IA64_CONTEXT IA64Context;
  1465. AMD64_CONTEXT Amd64Context;
  1466. ARM_CONTEXT ArmContext;
  1467. };
  1468. } CROSS_PLATFORM_CONTEXT, *PCROSS_PLATFORM_CONTEXT;
  1469. typedef struct _CROSS_PLATFORM_KSPECIAL_REGISTERS {
  1470. union {
  1471. X86_KSPECIAL_REGISTERS X86Special;
  1472. IA64_KSPECIAL_REGISTERS IA64Special;
  1473. AMD64_KSPECIAL_REGISTERS Amd64Special;
  1474. };
  1475. } CROSS_PLATFORM_KSPECIAL_REGISTERS, *PCROSS_PLATFORM_KSPECIAL_REGISTERS;
  1476. typedef struct _X86_KPROCESSOR_STATE {
  1477. struct _X86_CONTEXT ContextFrame;
  1478. struct _X86_KSPECIAL_REGISTERS SpecialRegisters;
  1479. } X86_KPROCESSOR_STATE, *PX86_KPROCESSOR_STATE;
  1480. typedef struct _X86_NT5_KPROCESSOR_STATE {
  1481. struct _X86_NT5_CONTEXT ContextFrame;
  1482. struct _X86_KSPECIAL_REGISTERS SpecialRegisters;
  1483. } X86_NT5_KPROCESSOR_STATE, *PX86_NT5_KPROCESSOR_STATE;
  1484. typedef struct _ALPHA_NT5_KPROCESSOR_STATE {
  1485. struct _ALPHA_NT5_CONTEXT ContextFrame;
  1486. } ALPHA_NT5_KPROCESSOR_STATE, *PALPHA_NT5_KPROCESSOR_STATE;
  1487. typedef struct _IA64_KPROCESSOR_STATE {
  1488. struct _IA64_CONTEXT ContextFrame;
  1489. struct _IA64_KSPECIAL_REGISTERS SpecialRegisters;
  1490. } IA64_KPROCESSOR_STATE, *PIA64_KPROCESSOR_STATE;
  1491. typedef struct _AMD64_KPROCESSOR_STATE {
  1492. struct _AMD64_KSPECIAL_REGISTERS SpecialRegisters;
  1493. ULONG64 Fill;
  1494. struct _AMD64_CONTEXT ContextFrame;
  1495. } AMD64_KPROCESSOR_STATE, *PAMD64_KPROCESSOR_STATE;
  1496. typedef struct _X86_FIBER {
  1497. ULONG FiberData;
  1498. //
  1499. // Matches first three DWORDs of TEB
  1500. //
  1501. ULONG ExceptionList;
  1502. ULONG StackBase;
  1503. ULONG StackLimit;
  1504. //
  1505. // Used by base to free a thread's stack
  1506. //
  1507. ULONG DeallocationStack;
  1508. X86_NT5_CONTEXT FiberContext;
  1509. ULONG Wx86Tib;
  1510. } X86_FIBER, *PX86_FIBER;
  1511. typedef struct _IA64_FIBER {
  1512. ULONG64 FiberData;
  1513. //
  1514. // Matches first three DWORDs of TEB
  1515. //
  1516. ULONG64 ExceptionList;
  1517. ULONG64 StackBase;
  1518. ULONG64 StackLimit;
  1519. //
  1520. // Used by base to free a thread's stack
  1521. //
  1522. ULONG64 DeallocationStack;
  1523. IA64_CONTEXT FiberContext;
  1524. ULONG64 Wx86Tib;
  1525. ULONG64 DeallocationBStore;
  1526. ULONG64 BStoreLimit;
  1527. } IA64_FIBER, *PIA64_FIBER;
  1528. typedef struct _AMD64_FIBER {
  1529. ULONG64 FiberData;
  1530. //
  1531. // Matches first three DWORDs of TEB
  1532. //
  1533. ULONG64 ExceptionList;
  1534. ULONG64 StackBase;
  1535. ULONG64 StackLimit;
  1536. //
  1537. // Used by base to free a thread's stack
  1538. //
  1539. ULONG64 DeallocationStack;
  1540. AMD64_CONTEXT FiberContext;
  1541. ULONG64 Wx86Tib;
  1542. } AMD64_FIBER, *PAMD64_FIBER;
  1543. typedef struct _CROSS_PLATFORM_FIBER {
  1544. union {
  1545. X86_FIBER X86Fiber;
  1546. IA64_FIBER IA64Fiber;
  1547. AMD64_FIBER Amd64Fiber;
  1548. };
  1549. } CROSS_PLATFORM_FIBER, *PCROSS_PLATFORM_FIBER;
  1550. #define DBGKD_MAXSTREAM 16
  1551. typedef struct _X86_DBGKD_CONTROL_REPORT {
  1552. ULONG Dr6;
  1553. ULONG Dr7;
  1554. USHORT InstructionCount;
  1555. USHORT ReportFlags;
  1556. UCHAR InstructionStream[DBGKD_MAXSTREAM];
  1557. USHORT SegCs;
  1558. USHORT SegDs;
  1559. USHORT SegEs;
  1560. USHORT SegFs;
  1561. ULONG EFlags;
  1562. } X86_DBGKD_CONTROL_REPORT, *PX86_DBGKD_CONTROL_REPORT;
  1563. #define X86_REPORT_INCLUDES_SEGS 0x0001
  1564. // Indicates the current CS is a standard 32-bit flat segment.
  1565. // This allows the debugger to avoid retrieving the
  1566. // CS descriptor to see if it's 16-bit code or not.
  1567. // Note that the V86 flag in EFlags must also be checked
  1568. // when determining the code type.
  1569. #define X86_REPORT_STANDARD_CS 0x0002
  1570. typedef struct _ALPHA_DBGKD_CONTROL_REPORT {
  1571. ULONG InstructionCount;
  1572. UCHAR InstructionStream[DBGKD_MAXSTREAM];
  1573. } ALPHA_DBGKD_CONTROL_REPORT, *PALPHA_DBGKD_CONTROL_REPORT;
  1574. typedef struct _IA64_DBGKD_CONTROL_REPORT {
  1575. ULONG InstructionCount;
  1576. UCHAR InstructionStream[DBGKD_MAXSTREAM];
  1577. } IA64_DBGKD_CONTROL_REPORT, *PIA64_DBGKD_CONTROL_REPORT;
  1578. typedef struct _AMD64_DBGKD_CONTROL_REPORT {
  1579. ULONG64 Dr6;
  1580. ULONG64 Dr7;
  1581. ULONG EFlags;
  1582. USHORT InstructionCount;
  1583. USHORT ReportFlags;
  1584. UCHAR InstructionStream[DBGKD_MAXSTREAM];
  1585. USHORT SegCs;
  1586. USHORT SegDs;
  1587. USHORT SegEs;
  1588. USHORT SegFs;
  1589. } AMD64_DBGKD_CONTROL_REPORT, *PAMD64_DBGKD_CONTROL_REPORT;
  1590. #define AMD64_REPORT_INCLUDES_SEGS 0x0001
  1591. // Indicates the current CS is a standard 64-bit flat segment.
  1592. // This allows the debugger to avoid retrieving the
  1593. // CS descriptor to see if it's 16- or 32-bit code or not.
  1594. // Note that the V86 flag in EFlags must also be checked
  1595. // when determining the code type.
  1596. #define AMD64_REPORT_STANDARD_CS 0x0002
  1597. typedef struct _DBGKD_ANY_CONTROL_REPORT
  1598. {
  1599. union
  1600. {
  1601. X86_DBGKD_CONTROL_REPORT X86ControlReport;
  1602. ALPHA_DBGKD_CONTROL_REPORT AlphaControlReport;
  1603. IA64_DBGKD_CONTROL_REPORT IA64ControlReport;
  1604. AMD64_DBGKD_CONTROL_REPORT Amd64ControlReport;
  1605. };
  1606. } DBGKD_ANY_CONTROL_REPORT, *PDBGKD_ANY_CONTROL_REPORT;
  1607. // DBGKD_ANY_CONTROL_SET is 32-bit packed with an NTSTATUS in
  1608. // DBGKD_CONTINUE2 so start with a 32-bit value to get the 64-bit
  1609. // values aligned.
  1610. #include <pshpack4.h>
  1611. typedef struct _X86_DBGKD_CONTROL_SET {
  1612. ULONG TraceFlag;
  1613. ULONG Dr7;
  1614. ULONG CurrentSymbolStart;
  1615. ULONG CurrentSymbolEnd;
  1616. } X86_DBGKD_CONTROL_SET, *PX86_DBGKD_CONTROL_SET;
  1617. typedef ULONG ALPHA_DBGKD_CONTROL_SET, *PALPHA_DBGKD_CONTROL_SET;
  1618. #define IA64_DBGKD_CONTROL_SET_CONTINUE_NONE 0x0000
  1619. #define IA64_DBGKD_CONTROL_SET_CONTINUE_TRACE_INSTRUCTION 0x0001
  1620. #define IA64_DBGKD_CONTROL_SET_CONTINUE_TRACE_TAKEN_BRANCH 0x0002
  1621. typedef struct _IA64_DBGKD_CONTROL_SET {
  1622. ULONG Continue;
  1623. ULONG64 CurrentSymbolStart;
  1624. ULONG64 CurrentSymbolEnd;
  1625. } IA64_DBGKD_CONTROL_SET, *PIA64_DBGKD_CONTROL_SET;
  1626. typedef struct _AMD64_DBGKD_CONTROL_SET {
  1627. ULONG TraceFlag;
  1628. ULONG64 Dr7;
  1629. ULONG64 CurrentSymbolStart;
  1630. ULONG64 CurrentSymbolEnd;
  1631. } AMD64_DBGKD_CONTROL_SET, *PAMD64_DBGKD_CONTROL_SET;
  1632. typedef struct _DBGKD_ANY_CONTROL_SET
  1633. {
  1634. union
  1635. {
  1636. X86_DBGKD_CONTROL_SET X86ControlSet;
  1637. ALPHA_DBGKD_CONTROL_SET AlphaControlSet;
  1638. IA64_DBGKD_CONTROL_SET IA64ControlSet;
  1639. AMD64_DBGKD_CONTROL_SET Amd64ControlSet;
  1640. };
  1641. } DBGKD_ANY_CONTROL_SET, *PDBGKD_ANY_CONTROL_SET;
  1642. #include <poppack.h>
  1643. //
  1644. // Deferred Procedure Call (DPC) object
  1645. //
  1646. typedef struct _KDPC32 {
  1647. CSHORT Type;
  1648. UCHAR Number;
  1649. UCHAR Importance;
  1650. LIST_ENTRY32 DpcListEntry;
  1651. ULONG DeferredRoutine;
  1652. ULONG DeferredContext;
  1653. ULONG SystemArgument1;
  1654. ULONG SystemArgument2;
  1655. ULONG Lock;
  1656. } KDPC32;
  1657. typedef struct _KDPC64 {
  1658. CSHORT Type;
  1659. UCHAR Number;
  1660. UCHAR Importance;
  1661. LIST_ENTRY64 DpcListEntry;
  1662. ULONG64 DeferredRoutine;
  1663. ULONG64 DeferredContext;
  1664. ULONG64 SystemArgument1;
  1665. ULONG64 SystemArgument2;
  1666. ULONG64 Lock;
  1667. } KDPC64;
  1668. #define X86_MAX_RING 3
  1669. typedef struct _X86_KTSS {
  1670. // Intel's TSS format
  1671. ULONG Previous;
  1672. struct
  1673. {
  1674. ULONG Esp;
  1675. ULONG Ss;
  1676. } Ring[X86_MAX_RING];
  1677. ULONG Cr3;
  1678. ULONG Eip;
  1679. ULONG EFlags;
  1680. ULONG Eax;
  1681. ULONG Ecx;
  1682. ULONG Edx;
  1683. ULONG Ebx;
  1684. ULONG Esp;
  1685. ULONG Ebp;
  1686. ULONG Esi;
  1687. ULONG Edi;
  1688. ULONG Es;
  1689. ULONG Cs;
  1690. ULONG Ss;
  1691. ULONG Ds;
  1692. ULONG Fs;
  1693. ULONG Gs;
  1694. ULONG Ldt;
  1695. USHORT T;
  1696. USHORT IoMapBase;
  1697. } X86_KTSS, *PX86_KTSS;
  1698. //
  1699. // LDT descriptor entry
  1700. //
  1701. typedef struct _X86_LDT_ENTRY {
  1702. USHORT LimitLow;
  1703. USHORT BaseLow;
  1704. union {
  1705. struct {
  1706. UCHAR BaseMid;
  1707. UCHAR Flags1; // Declare as bytes to avoid alignment
  1708. UCHAR Flags2; // Problems.
  1709. UCHAR BaseHi;
  1710. } Bytes;
  1711. struct {
  1712. ULONG BaseMid : 8;
  1713. ULONG Type : 5;
  1714. ULONG Dpl : 2;
  1715. ULONG Pres : 1;
  1716. ULONG LimitHi : 4;
  1717. ULONG Sys : 1;
  1718. ULONG Reserved_0 : 1;
  1719. ULONG Default_Big : 1;
  1720. ULONG Granularity : 1;
  1721. ULONG BaseHi : 8;
  1722. } Bits;
  1723. } HighWord;
  1724. } X86_LDT_ENTRY, *PX86_LDT_ENTRY;
  1725. typedef struct _X86_DESCRIPTOR_TABLE_ENTRY {
  1726. ULONG Selector;
  1727. X86_LDT_ENTRY Descriptor;
  1728. } X86_DESCRIPTOR_TABLE_ENTRY, *PX86_DESCRIPTOR_TABLE_ENTRY;
  1729. typedef struct _X86_KTRAP_FRAME {
  1730. //
  1731. // Following 4 values are only used and defined for DBG systems,
  1732. // but are always allocated to make switching from DBG to non-DBG
  1733. // and back quicker. They are not DEVL because they have a non-0
  1734. // performance impact.
  1735. //
  1736. ULONG DbgEbp; // Copy of User EBP set up so KB will work.
  1737. ULONG DbgEip; // EIP of caller to system call, again, for KB.
  1738. ULONG DbgArgMark; // Marker to show no args here.
  1739. ULONG DbgArgPointer; // Pointer to the actual args
  1740. //
  1741. // Temporary values used when frames are edited.
  1742. //
  1743. //
  1744. // NOTE: Any code that want's ESP must materialize it, since it
  1745. // is not stored in the frame for kernel mode callers.
  1746. //
  1747. // And code that sets ESP in a KERNEL mode frame, must put
  1748. // the new value in TempEsp, make sure that TempSegCs holds
  1749. // the real SegCs value, and put a special marker value into SegCs.
  1750. //
  1751. ULONG TempSegCs;
  1752. ULONG TempEsp;
  1753. //
  1754. // Debug registers.
  1755. //
  1756. ULONG Dr0;
  1757. ULONG Dr1;
  1758. ULONG Dr2;
  1759. ULONG Dr3;
  1760. ULONG Dr6;
  1761. ULONG Dr7;
  1762. //
  1763. // Segment registers
  1764. //
  1765. ULONG SegGs;
  1766. ULONG SegEs;
  1767. ULONG SegDs;
  1768. //
  1769. // Volatile registers
  1770. //
  1771. ULONG Edx;
  1772. ULONG Ecx;
  1773. ULONG Eax;
  1774. //
  1775. // Nesting state, not part of context record
  1776. //
  1777. ULONG PreviousPreviousMode;
  1778. ULONG ExceptionList;
  1779. // Trash if caller was user mode.
  1780. // Saved exception list if caller
  1781. // was kernel mode or we're in
  1782. // an interrupt.
  1783. //
  1784. // FS is TIB/PCR pointer, is here to make save sequence easy
  1785. //
  1786. ULONG SegFs;
  1787. //
  1788. // Non-volatile registers
  1789. //
  1790. ULONG Edi;
  1791. ULONG Esi;
  1792. ULONG Ebx;
  1793. ULONG Ebp;
  1794. //
  1795. // Control registers
  1796. //
  1797. ULONG ErrCode;
  1798. ULONG Eip;
  1799. ULONG SegCs;
  1800. ULONG EFlags;
  1801. ULONG HardwareEsp; // WARNING - segSS:esp are only here for stacks
  1802. ULONG HardwareSegSs; // that involve a ring transition.
  1803. ULONG V86Es; // these will be present for all transitions from
  1804. ULONG V86Ds; // V86 mode
  1805. ULONG V86Fs;
  1806. ULONG V86Gs;
  1807. } X86_KTRAP_FRAME, *PX86_KTRAP_FRAME;
  1808. typedef struct _AMD64_KTRAP_FRAME {
  1809. //
  1810. // Home address for the parameter registers.
  1811. //
  1812. ULONG64 P1Home;
  1813. ULONG64 P2Home;
  1814. ULONG64 P3Home;
  1815. ULONG64 P4Home;
  1816. ULONG64 P5;
  1817. //
  1818. // Previous processor mode (system services only) and previous IRQL
  1819. // (interrupts only).
  1820. //
  1821. CCHAR PreviousMode;
  1822. KIRQL PreviousIrql;
  1823. //
  1824. // Page fault load/store indicator.
  1825. //
  1826. UCHAR FaultIndicator;
  1827. UCHAR Fill0;
  1828. //
  1829. // Floating point state.
  1830. //
  1831. ULONG MxCsr;
  1832. //
  1833. // Volatile registers.
  1834. //
  1835. // N.B. These registers are only saved on exceptions and interrupts. They
  1836. // are not saved for system calls.
  1837. //
  1838. ULONG64 Rax;
  1839. ULONG64 Rcx;
  1840. ULONG64 Rdx;
  1841. ULONG64 R8;
  1842. ULONG64 R9;
  1843. ULONG64 R10;
  1844. ULONG64 R11;
  1845. ULONG64 Spare0;
  1846. //
  1847. // Volatile floating registers.
  1848. //
  1849. // N.B. These registers are only saved on exceptions and interrupts. They
  1850. // are not saved for system calls.
  1851. //
  1852. AMD64_M128 Xmm0;
  1853. AMD64_M128 Xmm1;
  1854. AMD64_M128 Xmm2;
  1855. AMD64_M128 Xmm3;
  1856. AMD64_M128 Xmm4;
  1857. AMD64_M128 Xmm5;
  1858. //
  1859. // Page fault address.
  1860. //
  1861. ULONG64 FaultAddress;
  1862. //
  1863. // Debug registers.
  1864. //
  1865. ULONG64 Dr0;
  1866. ULONG64 Dr1;
  1867. ULONG64 Dr2;
  1868. ULONG64 Dr3;
  1869. ULONG64 Dr6;
  1870. ULONG64 Dr7;
  1871. //
  1872. // Special debug registers.
  1873. //
  1874. ULONG64 DebugControl;
  1875. ULONG64 LastBranchToRip;
  1876. ULONG64 LastBranchFromRip;
  1877. ULONG64 LastExceptionToRip;
  1878. ULONG64 LastExceptionFromRip;
  1879. //
  1880. // Segment registers
  1881. //
  1882. USHORT SegDs;
  1883. USHORT SegEs;
  1884. USHORT SegFs;
  1885. USHORT SegGs;
  1886. //
  1887. // Previous trap frame address.
  1888. //
  1889. ULONG64 TrapFrame;
  1890. //
  1891. // Saved nonvolatile registers RBX, RDI and RSI. These registers are only
  1892. // saved in system service trap frames.
  1893. //
  1894. ULONG64 Rbx;
  1895. ULONG64 Rdi;
  1896. ULONG64 Rsi;
  1897. //
  1898. // Saved nonvolatile register RBP. This register is used as a frame
  1899. // pointer during trap processing and is saved in all trap frames.
  1900. //
  1901. ULONG64 Rbp;
  1902. //
  1903. // Information pushed by hardware.
  1904. //
  1905. // N.B. The error code is not always pushed by hardware. For those cases
  1906. // where it is not pushed by hardware a dummy error code is allocated
  1907. // on the stack.
  1908. //
  1909. ULONG64 ErrorCode;
  1910. ULONG64 Rip;
  1911. USHORT SegCs;
  1912. USHORT Fill1[3];
  1913. ULONG EFlags;
  1914. ULONG Fill2;
  1915. ULONG64 Rsp;
  1916. USHORT SegSs;
  1917. USHORT Fill3[3];
  1918. } AMD64_KTRAP_FRAME, *PAMD64_KTRAP_FRAME;
  1919. typedef struct _IA64_KNONVOLATILE_CONTEXT_POINTERS {
  1920. PFLOAT128 FltS0; // Intel-IA64-Filler
  1921. PFLOAT128 FltS1; // Intel-IA64-Filler
  1922. PFLOAT128 FltS2; // Intel-IA64-Filler
  1923. PFLOAT128 FltS3; // Intel-IA64-Filler
  1924. PFLOAT128 HighFloatingContext[10]; // Intel-IA64-Filler
  1925. PFLOAT128 FltS4; // Intel-IA64-Filler
  1926. PFLOAT128 FltS5; // Intel-IA64-Filler
  1927. PFLOAT128 FltS6; // Intel-IA64-Filler
  1928. PFLOAT128 FltS7; // Intel-IA64-Filler
  1929. PFLOAT128 FltS8; // Intel-IA64-Filler
  1930. PFLOAT128 FltS9; // Intel-IA64-Filler
  1931. PFLOAT128 FltS10; // Intel-IA64-Filler
  1932. PFLOAT128 FltS11; // Intel-IA64-Filler
  1933. PFLOAT128 FltS12; // Intel-IA64-Filler
  1934. PFLOAT128 FltS13; // Intel-IA64-Filler
  1935. PFLOAT128 FltS14; // Intel-IA64-Filler
  1936. PFLOAT128 FltS15; // Intel-IA64-Filler
  1937. PFLOAT128 FltS16; // Intel-IA64-Filler
  1938. PFLOAT128 FltS17; // Intel-IA64-Filler
  1939. PFLOAT128 FltS18; // Intel-IA64-Filler
  1940. PFLOAT128 FltS19; // Intel-IA64-Filler
  1941. PULONGLONG IntS0; // Intel-IA64-Filler
  1942. PULONGLONG IntS1; // Intel-IA64-Filler
  1943. PULONGLONG IntS2; // Intel-IA64-Filler
  1944. PULONGLONG IntS3; // Intel-IA64-Filler
  1945. PULONGLONG IntSp; // Intel-IA64-Filler
  1946. PULONGLONG IntS0Nat; // Intel-IA64-Filler
  1947. PULONGLONG IntS1Nat; // Intel-IA64-Filler
  1948. PULONGLONG IntS2Nat; // Intel-IA64-Filler
  1949. PULONGLONG IntS3Nat; // Intel-IA64-Filler
  1950. PULONGLONG IntSpNat; // Intel-IA64-Filler
  1951. PULONGLONG Preds; // Intel-IA64-Filler
  1952. PULONGLONG BrRp; // Intel-IA64-Filler
  1953. PULONGLONG BrS0; // Intel-IA64-Filler
  1954. PULONGLONG BrS1; // Intel-IA64-Filler
  1955. PULONGLONG BrS2; // Intel-IA64-Filler
  1956. PULONGLONG BrS3; // Intel-IA64-Filler
  1957. PULONGLONG BrS4; // Intel-IA64-Filler
  1958. PULONGLONG ApUNAT; // Intel-IA64-Filler
  1959. PULONGLONG ApLC; // Intel-IA64-Filler
  1960. PULONGLONG ApEC; // Intel-IA64-Filler
  1961. PULONGLONG RsPFS; // Intel-IA64-Filler
  1962. PULONGLONG StFSR; // Intel-IA64-Filler
  1963. PULONGLONG StFIR; // Intel-IA64-Filler
  1964. PULONGLONG StFDR; // Intel-IA64-Filler
  1965. PULONGLONG Cflag; // Intel-IA64-Filler
  1966. } IA64_KNONVOLATILE_CONTEXT_POINTERS, *PIA64_KNONVOLATILE_CONTEXT_POINTERS;
  1967. typedef struct _IA64_KEXCEPTION_FRAME {
  1968. // Preserved application registers // Intel-IA64-Filler
  1969. ULONGLONG ApEC; // epilogue count // Intel-IA64-Filler
  1970. ULONGLONG ApLC; // loop count // Intel-IA64-Filler
  1971. ULONGLONG IntNats; // Nats for S0-S3; i.e. ar.UNAT after spill // Intel-IA64-Filler
  1972. // Preserved (saved) interger registers, s0-s3 // Intel-IA64-Filler
  1973. ULONGLONG IntS0; // Intel-IA64-Filler
  1974. ULONGLONG IntS1; // Intel-IA64-Filler
  1975. ULONGLONG IntS2; // Intel-IA64-Filler
  1976. ULONGLONG IntS3; // Intel-IA64-Filler
  1977. // Preserved (saved) branch registers, bs0-bs4 // Intel-IA64-Filler
  1978. ULONGLONG BrS0; // Intel-IA64-Filler
  1979. ULONGLONG BrS1; // Intel-IA64-Filler
  1980. ULONGLONG BrS2; // Intel-IA64-Filler
  1981. ULONGLONG BrS3; // Intel-IA64-Filler
  1982. ULONGLONG BrS4; // Intel-IA64-Filler
  1983. // Preserved (saved) floating point registers, f2 - f5, f16 - f31 // Intel-IA64-Filler
  1984. FLOAT128 FltS0; // Intel-IA64-Filler
  1985. FLOAT128 FltS1; // Intel-IA64-Filler
  1986. FLOAT128 FltS2; // Intel-IA64-Filler
  1987. FLOAT128 FltS3; // Intel-IA64-Filler
  1988. FLOAT128 FltS4; // Intel-IA64-Filler
  1989. FLOAT128 FltS5; // Intel-IA64-Filler
  1990. FLOAT128 FltS6; // Intel-IA64-Filler
  1991. FLOAT128 FltS7; // Intel-IA64-Filler
  1992. FLOAT128 FltS8; // Intel-IA64-Filler
  1993. FLOAT128 FltS9; // Intel-IA64-Filler
  1994. FLOAT128 FltS10; // Intel-IA64-Filler
  1995. FLOAT128 FltS11; // Intel-IA64-Filler
  1996. FLOAT128 FltS12; // Intel-IA64-Filler
  1997. FLOAT128 FltS13; // Intel-IA64-Filler
  1998. FLOAT128 FltS14; // Intel-IA64-Filler
  1999. FLOAT128 FltS15; // Intel-IA64-Filler
  2000. FLOAT128 FltS16; // Intel-IA64-Filler
  2001. FLOAT128 FltS17; // Intel-IA64-Filler
  2002. FLOAT128 FltS18; // Intel-IA64-Filler
  2003. FLOAT128 FltS19; // Intel-IA64-Filler
  2004. } IA64_KEXCEPTION_FRAME, *PIA64_KEXCEPTION_FRAME;
  2005. typedef struct _IA64_KSWITCH_FRAME { // Intel-IA64-Filler
  2006. ULONGLONG SwitchPredicates; // Predicates for Switch // Intel-IA64-Filler
  2007. ULONGLONG SwitchRp; // return pointer for Switch // Intel-IA64-Filler
  2008. ULONGLONG SwitchPFS; // PFS for Switch // Intel-IA64-Filler
  2009. ULONGLONG SwitchFPSR; // ProcessorFP status at thread switch // Intel-IA64-Filler
  2010. ULONGLONG SwitchBsp; // Intel-IA64-Filler
  2011. ULONGLONG SwitchRnat; // Intel-IA64-Filler
  2012. // ULONGLONG Pad;
  2013. IA64_KEXCEPTION_FRAME SwitchExceptionFrame; // Intel-IA64-Filler
  2014. } IA64_KSWITCH_FRAME, *PIA64_KSWITCH_FRAME; // Intel-IA64-Filler
  2015. #define IA64_KTRAP_FRAME_ARGUMENTS (8 * 8) // up to 8 in-memory syscall args // Intel-IA64-Filler
  2016. typedef struct _IA64_KTRAP_FRAME {
  2017. //
  2018. // Reserved for additional memory arguments and stack scratch area
  2019. // The size of Reserved[] must be a multiple of 16 bytes.
  2020. //
  2021. ULONGLONG Reserved[(IA64_KTRAP_FRAME_ARGUMENTS+16)/8]; // Intel-IA64-Filler
  2022. // Temporary (volatile) FP registers - f6-f15 (don't use f32+ in kernel) // Intel-IA64-Filler
  2023. FLOAT128 FltT0; // Intel-IA64-Filler
  2024. FLOAT128 FltT1; // Intel-IA64-Filler
  2025. FLOAT128 FltT2; // Intel-IA64-Filler
  2026. FLOAT128 FltT3; // Intel-IA64-Filler
  2027. FLOAT128 FltT4; // Intel-IA64-Filler
  2028. FLOAT128 FltT5; // Intel-IA64-Filler
  2029. FLOAT128 FltT6; // Intel-IA64-Filler
  2030. FLOAT128 FltT7; // Intel-IA64-Filler
  2031. FLOAT128 FltT8; // Intel-IA64-Filler
  2032. FLOAT128 FltT9; // Intel-IA64-Filler
  2033. // Temporary (volatile) interger registers
  2034. ULONGLONG IntGp; // global pointer (r1) // Intel-IA64-Filler
  2035. ULONGLONG IntT0; // Intel-IA64-Filler
  2036. ULONGLONG IntT1; // Intel-IA64-Filler
  2037. // The following 4 registers fill in space of preserved (S0-S3) to align Nats // Intel-IA64-Filler
  2038. ULONGLONG ApUNAT; // ar.UNAT on kernel entry // Intel-IA64-Filler
  2039. ULONGLONG ApCCV; // ar.CCV // Intel-IA64-Filler
  2040. ULONGLONG ApDCR; // DCR register on kernel entry // Intel-IA64-Filler
  2041. ULONGLONG Preds; // Predicates // Intel-IA64-Filler
  2042. ULONGLONG IntV0; // return value (r8) // Intel-IA64-Filler
  2043. ULONGLONG IntT2; // Intel-IA64-Filler
  2044. ULONGLONG IntT3; // Intel-IA64-Filler
  2045. ULONGLONG IntT4; // Intel-IA64-Filler
  2046. ULONGLONG IntSp; // stack pointer (r12) // Intel-IA64-Filler
  2047. ULONGLONG IntTeb; // teb (r13) // Intel-IA64-Filler
  2048. ULONGLONG IntT5; // Intel-IA64-Filler
  2049. ULONGLONG IntT6; // Intel-IA64-Filler
  2050. ULONGLONG IntT7; // Intel-IA64-Filler
  2051. ULONGLONG IntT8; // Intel-IA64-Filler
  2052. ULONGLONG IntT9; // Intel-IA64-Filler
  2053. ULONGLONG IntT10; // Intel-IA64-Filler
  2054. ULONGLONG IntT11; // Intel-IA64-Filler
  2055. ULONGLONG IntT12; // Intel-IA64-Filler
  2056. ULONGLONG IntT13; // Intel-IA64-Filler
  2057. ULONGLONG IntT14; // Intel-IA64-Filler
  2058. ULONGLONG IntT15; // Intel-IA64-Filler
  2059. ULONGLONG IntT16; // Intel-IA64-Filler
  2060. ULONGLONG IntT17; // Intel-IA64-Filler
  2061. ULONGLONG IntT18; // Intel-IA64-Filler
  2062. ULONGLONG IntT19; // Intel-IA64-Filler
  2063. ULONGLONG IntT20; // Intel-IA64-Filler
  2064. ULONGLONG IntT21; // Intel-IA64-Filler
  2065. ULONGLONG IntT22; // Intel-IA64-Filler
  2066. ULONGLONG IntNats; // Temporary (volatile) registers' Nats directly from ar.UNAT at point of spill // Intel-IA64-Filler
  2067. ULONGLONG BrRp; // Return pointer on kernel entry // Intel-IA64-Filler
  2068. ULONGLONG BrT0; // Temporary (volatile) branch registers (b6-b7) // Intel-IA64-Filler
  2069. ULONGLONG BrT1; // Intel-IA64-Filler
  2070. // Register stack info // Intel-IA64-Filler
  2071. ULONGLONG RsRSC; // RSC on kernel entry // Intel-IA64-Filler
  2072. ULONGLONG RsBSP; // BSP on kernel entry // Intel-IA64-Filler
  2073. ULONGLONG RsBSPSTORE; // User BSP Store at point of switch to kernel backing store // Intel-IA64-Filler
  2074. ULONGLONG RsRNAT; // old RNAT at point of switch to kernel backing store // Intel-IA64-Filler
  2075. ULONGLONG RsPFS; // PFS on kernel entry // Intel-IA64-Filler
  2076. // Trap Status Information // Intel-IA64-Filler
  2077. ULONGLONG StIPSR; // Interruption Processor Status Register // Intel-IA64-Filler
  2078. ULONGLONG StIIP; // Interruption IP // Intel-IA64-Filler
  2079. ULONGLONG StIFS; // Interruption Function State // Intel-IA64-Filler
  2080. ULONGLONG StFPSR; // FP status // Intel-IA64-Filler
  2081. ULONGLONG StISR; // Interruption Status Register // Intel-IA64-Filler
  2082. ULONGLONG StIFA; // Interruption Data Address // Intel-IA64-Filler
  2083. ULONGLONG StIIPA; // Last executed bundle address // Intel-IA64-Filler
  2084. ULONGLONG StIIM; // Interruption Immediate // Intel-IA64-Filler
  2085. ULONGLONG StIHA; // Interruption Hash Address // Intel-IA64-Filler
  2086. ULONG OldIrql; // Previous Irql. // Intel-IA64-Filler
  2087. ULONG PreviousMode; // Previous Mode. // Intel-IA64-Filler
  2088. ULONGLONG TrapFrame;// Previous Trap Frame // Intel-IA64-Filler
  2089. // Exception record
  2090. UCHAR ExceptionRecord[(sizeof(EXCEPTION_RECORD64) + 15) & (~15)];
  2091. // End of frame marker (for debugging)
  2092. ULONGLONG Handler; // Handler for this trap
  2093. ULONGLONG EOFMarker;
  2094. } IA64_KTRAP_FRAME, *PIA64_KTRAP_FRAME;
  2095. typedef struct _IA64_UNWIND_INFO { // Intel-IA64-Filler
  2096. USHORT Version; // Intel-IA64-Filler ; Version Number
  2097. USHORT Flags; // Intel-IA64-Filler ; Flags
  2098. ULONG DataLength; // Intel-IA64-Filler ; Length of Descriptor Data
  2099. } IA64_UNWIND_INFO, *PIA64_UNWIND_INFO; // Intel-IA64-Filler
  2100. //
  2101. // Define unwind operation codes.
  2102. //
  2103. typedef enum _AMD64_UNWIND_OP_CODES {
  2104. AMD64_UWOP_PUSH_NONVOL = 0,
  2105. AMD64_UWOP_ALLOC_LARGE,
  2106. AMD64_UWOP_ALLOC_SMALL,
  2107. AMD64_UWOP_SET_FPREG,
  2108. AMD64_UWOP_SAVE_NONVOL,
  2109. AMD64_UWOP_SAVE_NONVOL_FAR,
  2110. AMD64_UWOP_SAVE_XMM,
  2111. AMD64_UWOP_SAVE_XMM_FAR,
  2112. AMD64_UWOP_SAVE_XMM128,
  2113. AMD64_UWOP_SAVE_XMM128_FAR,
  2114. AMD64_UWOP_PUSH_MACHFRAME
  2115. } AMD64_UNWIND_OP_CODES, *PAMD64_UNWIND_OP_CODES;
  2116. //
  2117. // Define unwind code structure.
  2118. //
  2119. typedef union _AMD64_UNWIND_CODE {
  2120. struct {
  2121. UCHAR CodeOffset;
  2122. UCHAR UnwindOp : 4;
  2123. UCHAR OpInfo : 4;
  2124. };
  2125. USHORT FrameOffset;
  2126. } AMD64_UNWIND_CODE, *PAMD64_UNWIND_CODE;
  2127. //
  2128. // Define unwind information flags.
  2129. //
  2130. #define AMD64_UNW_FLAG_NHANDLER 0x0
  2131. #define AMD64_UNW_FLAG_EHANDLER 0x1
  2132. #define AMD64_UNW_FLAG_UHANDLER 0x2
  2133. #define AMD64_UNW_FLAG_CHAININFO 0x4
  2134. //
  2135. // Define unwind information structure.
  2136. //
  2137. typedef struct _AMD64_UNWIND_INFO {
  2138. UCHAR Version : 3;
  2139. UCHAR Flags : 5;
  2140. UCHAR SizeOfProlog;
  2141. UCHAR CountOfCodes;
  2142. UCHAR FrameRegister : 4;
  2143. UCHAR FrameOffset : 4;
  2144. AMD64_UNWIND_CODE UnwindCode[1];
  2145. //
  2146. // The unwind codes are followed by an optional DWORD aligned field that
  2147. // contains the exception handler address or the address of chained unwind
  2148. // information. If an exception handler address is specified, then it is
  2149. // followed by the language specified exception handler data.
  2150. //
  2151. // union {
  2152. // ULONG ExceptionHandler;
  2153. // ULONG FunctionEntry;
  2154. // };
  2155. //
  2156. // ULONG ExceptionData[];
  2157. //
  2158. } AMD64_UNWIND_INFO, *PAMD64_UNWIND_INFO;
  2159. #define IA64_IP_SLOT 2 // Intel-IA64-Filler
  2160. #define Ia64InsertIPSlotNumber(IP, SlotNumber) /* Intel-IA64-Filler */ \
  2161. ((IP) | (SlotNumber << IA64_IP_SLOT)) // Intel-IA64-Filler
  2162. #define IA64_MM_EPC_VA 0xe0000000ffa00000
  2163. #define IA64_STACK_SCRATCH_AREA 16
  2164. #define IA64_SYSCALL_FRAME 0
  2165. #define IA64_INTERRUPT_FRAME 1
  2166. #define IA64_EXCEPTION_FRAME 2
  2167. #define IA64_CONTEXT_FRAME 10
  2168. #define IA64_IFS_IFM 0
  2169. #define IA64_IFS_IFM_LEN 38
  2170. #define IA64_IFS_MBZ0 38
  2171. #define IA64_IFS_MBZ0_V 0x1ffffffi64
  2172. #define IA64_IFS_V 63
  2173. #define IA64_IFS_V_LEN 1
  2174. #define IA64_PFS_EC_SHIFT 52
  2175. #define IA64_PFS_EC_SIZE 6
  2176. #define IA64_PFS_EC_MASK 0x3F
  2177. #define IA64_PFS_SIZE_SHIFT 7
  2178. #define IA64_PFS_SIZE_MASK 0x7F
  2179. #define IA64_NAT_BITS_PER_RNAT_REG 63
  2180. #define IA64_RNAT_ALIGNMENT (IA64_NAT_BITS_PER_RNAT_REG << 3)
  2181. #define IA64_FM_RRB_PR(Fm) (((Fm) >> 32) & 0x3f)
  2182. #define IA64_FM_RRB_FR(Fm) (((Fm) >> 25) & 0x7f)
  2183. #define IA64_FM_RRB_GR(Fm) (((Fm) >> 18) & 0x7f)
  2184. #define IA64_FM_SOR(Fm) (((Fm) >> 14) & 0xf)
  2185. #define IA64_FM_SOF(Fm) ((Fm) & 0x7f)
  2186. #define IA64_FM_FROM_FS(Fs) \
  2187. (((Fs) >> IA64_IFS_IFM) & ((1UI64 << IA64_IFS_IFM_LEN) - 1))
  2188. #define IA64_BREAK_DEBUG_BASE 0x080000
  2189. #define IA64_BREAK_SYSCALL_BASE 0x180000
  2190. #define IA64_BREAK_FASTSYS_BASE 0x1C0000
  2191. #define IA64_DEBUG_STOP_BREAKPOINT (IA64_BREAK_DEBUG_BASE+22)
  2192. #define ALPHA_PSR_USER_MODE 0x1
  2193. #define ALPHA_PSR_MODE 0x0 // Mode bit in PSR (bit 0)
  2194. #define ALPHA_PSR_MODE_MASK 0x1 // Mask (1 bit) for mode in PSR
  2195. #define ALPHA_PSR_IE 0x1 // Interrupt Enable bit in PSR (bit 1)
  2196. #define ALPHA_PSR_IE_MASK 0x1 // Mask (1 bit) for IE in PSR
  2197. #define ALPHA_PSR_IRQL 0x2 // IRQL in PSR (bit 2)
  2198. #define ALPHA_PSR_IRQL_MASK 0x7 // Mask (2 bits) for IRQL in PSR
  2199. #define X86_CONTEXT_X86 0x00010000
  2200. #define ALPHA_CONTEXT_ALPHA 0x00020000
  2201. #define ALPHA_CONTEXT_CONTROL (ALPHA_CONTEXT_ALPHA | 0x00000001L)
  2202. #define ALPHA_CONTEXT_FLOATING_POINT (ALPHA_CONTEXT_ALPHA | 0x00000002L)
  2203. #define ALPHA_CONTEXT_INTEGER (ALPHA_CONTEXT_ALPHA | 0x00000004L)
  2204. #define ALPHA_CONTEXT_FULL \
  2205. (ALPHA_CONTEXT_CONTROL | ALPHA_CONTEXT_FLOATING_POINT | \
  2206. ALPHA_CONTEXT_INTEGER)
  2207. #define IA64_CONTEXT_IA64 0x00080000
  2208. #define IA64_CONTEXT_CONTROL (IA64_CONTEXT_IA64 | 0x00000001L)
  2209. #define IA64_CONTEXT_LOWER_FLOATING_POINT (IA64_CONTEXT_IA64 | 0x00000002L)
  2210. #define IA64_CONTEXT_HIGHER_FLOATING_POINT (IA64_CONTEXT_IA64 | 0x00000004L)
  2211. #define IA64_CONTEXT_INTEGER (IA64_CONTEXT_IA64 | 0x00000008L)
  2212. #define IA64_CONTEXT_DEBUG (IA64_CONTEXT_IA64 | 0x00000010L)
  2213. #define IA64_CONTEXT_IA32_CONTROL (IA64_CONTEXT_IA64 | 0x00000020L)
  2214. #define IA64_CONTEXT_FLOATING_POINT \
  2215. (IA64_CONTEXT_LOWER_FLOATING_POINT | IA64_CONTEXT_HIGHER_FLOATING_POINT)
  2216. #define IA64_CONTEXT_FULL \
  2217. (IA64_CONTEXT_CONTROL | IA64_CONTEXT_FLOATING_POINT | IA64_CONTEXT_INTEGER | IA64_CONTEXT_IA32_CONTROL)
  2218. #define AMD64_CONTEXT_AMD64 0x00100000
  2219. #define AMD64_CONTEXT_CONTROL (AMD64_CONTEXT_AMD64 | 0x1L)
  2220. #define AMD64_CONTEXT_INTEGER (AMD64_CONTEXT_AMD64 | 0x2L)
  2221. #define AMD64_CONTEXT_SEGMENTS (AMD64_CONTEXT_AMD64 | 0x4L)
  2222. #define AMD64_CONTEXT_FLOATING_POINT (AMD64_CONTEXT_AMD64 | 0x8L)
  2223. #define AMD64_CONTEXT_DEBUG_REGISTERS (AMD64_CONTEXT_AMD64 | 0x10L)
  2224. #define AMD64_CONTEXT_FULL \
  2225. (AMD64_CONTEXT_CONTROL | AMD64_CONTEXT_INTEGER | AMD64_CONTEXT_FLOATING_POINT)
  2226. #define ARM_CONTEXT_ARM 0x0000040
  2227. #define ARM_CONTEXT_CONTROL (ARM_CONTEXT_ARM | 0x00000001L)
  2228. #define ARM_CONTEXT_INTEGER (ARM_CONTEXT_ARM | 0x00000002L)
  2229. #define ARM_CONTEXT_FULL (ARM_CONTEXT_CONTROL | ARM_CONTEXT_INTEGER)
  2230. #define X86_NT4_KPRCB_SIZE 0x9F0
  2231. #define X86_NT5_KPRCB_SIZE 0x9F0
  2232. #define X86_NT51_KPRCB_SIZE 0xC50
  2233. #define IA64_KPRCB_SIZE 0x1A40
  2234. #define DEF_KPRCB_CURRENT_THREAD_OFFSET_32 4
  2235. #define DEF_KPRCB_CURRENT_THREAD_OFFSET_64 8
  2236. #define X86_KPRCB_CPU_TYPE 0x18
  2237. #define IA64_KPRCB_PROCESSOR_MODEL 0x50
  2238. #define X86_1387_KPRCB_VENDOR_STRING 0x52D
  2239. #define X86_2087_KPRCB_VENDOR_STRING 0x72D
  2240. #define X86_2251_KPRCB_VENDOR_STRING 0x8AD
  2241. #define X86_2474_KPRCB_VENDOR_STRING 0x900
  2242. #define X86_VENDOR_STRING_SIZE 13
  2243. #define IA64_KPRCB_VENDOR_STRING 0x70
  2244. #define X86_1381_KPRCB_MHZ 0x53c
  2245. #define X86_2195_KPRCB_MHZ 0x73c
  2246. #define X86_2462_KPRCB_MHZ 0x8bc
  2247. #define X86_2505_KPRCB_MHZ 0x910
  2248. #define IA64_2462_KPRCB_MHZ 0x1728
  2249. #define X86_KPRCB_NUMBER 0x10
  2250. #define IA64_KPRCB_NUMBER 0x20
  2251. #define AMD64_KPRCB_NUMBER 4
  2252. #define X86_KPRCB_DPC_ROUTINE_ACTIVE 0x874
  2253. #define IA64_KPRCB_PCR_PAGE 0x38
  2254. #define X86_KPRCB_CONTEXT 0x1c
  2255. #define IA64_KPRCB_CONTEXT 0x190
  2256. #define AMD64_KPRCB_CONTEXT 0x120
  2257. #define X86_KPRCB_SPECIAL_REG 0x2e8
  2258. #define IA64_KPRCB_SPECIAL_REG 0xc00
  2259. #define AMD64_KPRCB_SPECIAL_REG 0x40
  2260. #define X86_1381_KPCR_SIZE 0x7f0
  2261. #define X86_2195_KPCR_SIZE 0xb10
  2262. #define X86_KPCR_SIZE 0xd70
  2263. #define IA64_KPCR_SIZE 0xe28
  2264. #define AMD64_KPCR_SIZE 0x12e0
  2265. #define X86_KPCR_SELF_PCR 0x1c
  2266. #define AMD64_KPCR_SELF 0x18
  2267. #define X86_KPCR_PRCB 0x20
  2268. #define IA64_KPCR_PRCB 0xb18
  2269. #define AMD64_KPCR_CURRENT_PRCB 0x38
  2270. #define X86_KPCR_PRCB_DATA 0x120
  2271. #define AMD64_KPCR_PRCB 0x180
  2272. #define AMD64_KPCR_KD_VERSION_BLOCK 0x108
  2273. #define IA64_KPCR_INITIAL_BSTORE 0xb68
  2274. #define IA64_KPCR_BSTORE_LIMIT 0xb78
  2275. #define IA64_KPCR_INITIAL_STACK 0xb60
  2276. #define IA64_KPCR_STACK_LIMIT 0xb70
  2277. #define X86_NT5_EPROCESS_SIZE 0x288
  2278. #define X86_NT51_EPROCESS_SIZE 0x258
  2279. #define X86_NT511_EPROCESS_SIZE 0x278
  2280. #define IA64_EPROCESS_SIZE 0x410
  2281. #define X86_PEB_IN_EPROCESS 0x1B0
  2282. #define X86_NT4_PEB_IN_EPROCESS 0x18C
  2283. #define IA64_PEB_IN_EPROCESS 0x2D0
  2284. #define IA64_3555_PEB_IN_EPROCESS 0x300
  2285. #define X86_PCID_IN_EPROCESS 0x14C
  2286. #define X86_NT4_PCID_IN_EPROCESS 0x1A4
  2287. #define IA64_PCID_IN_EPROCESS 0x260
  2288. #define IA64_DIRECTORY_TABLE_BASE_IN_EPROCESS 40
  2289. #define X86_DIRECTORY_TABLE_BASE_IN_EPROCESS 24
  2290. #define X86_ETHREAD_SIZE 0x258
  2291. #define X86_NT51_ETHREAD_SIZE 0x260
  2292. #define IA64_ETHREAD_SIZE 0x458
  2293. #define IA64_3555_ETHREAD_SIZE 0x440
  2294. #define X86_KTHREAD_NEXTPROCESSOR_OFFSET 0x11f
  2295. #define X86_2230_KTHREAD_NEXTPROCESSOR_OFFSET 0x123
  2296. #define X86_NT51_KTHREAD_NEXTPROCESSOR_OFFSET 0x12b
  2297. #define X86_3555_KTHREAD_NEXTPROCESSOR_OFFSET 0x107
  2298. #define IA64_KTHREAD_NEXTPROCESSOR_OFFSET 0x23b
  2299. #define IA64_3555_KTHREAD_NEXTPROCESSOR_OFFSET 0x1F7
  2300. #define X86_KTHREAD_TEB_OFFSET 0x020
  2301. #define X86_3555_KTHREAD_TEB_OFFSET 0x02C
  2302. #define IA64_KTHREAD_TEB_OFFSET 0x050
  2303. #define IA64_3555_KTHREAD_TEB_OFFSET 0x068
  2304. #define X86_KTHREAD_INITSTACK_OFFSET 0x018
  2305. #define IA64_KTHREAD_INITSTACK_OFFSET 0x028
  2306. #define X86_KTHREAD_KERNELSTACK_OFFSET 0x028
  2307. #define X86_3555_KTHREAD_KERNELSTACK_OFFSET 0x020
  2308. #define IA64_KTHREAD_KERNELSTACK_OFFSET 0x060
  2309. #define IA64_3555_KTHREAD_KERNELSTACK_OFFSET 0x038
  2310. #define X86_KTHREAD_APCPROCESS_OFFSET 0x044
  2311. #define X86_3555_KTHREAD_APCPROCESS_OFFSET 0x040
  2312. #define IA64_KTHREAD_APCPROCESS_OFFSET 0x098
  2313. #define IA64_3555_KTHREAD_APCPROCESS_OFFSET 0x090
  2314. #define X86_KTHREAD_STATE_OFFSET 0x02d
  2315. #define X86_3555_KTHREAD_STATE_OFFSET 0x028
  2316. #define IA64_KTHREAD_STATE_OFFSET 0x071
  2317. #define IA64_3555_KTHREAD_STATE_OFFSET 0x064
  2318. #define IA64_KTHREAD_BSTORE_OFFSET 0x038
  2319. #define IA64_3555_KTHREAD_BSTORE_OFFSET 0x040
  2320. #define IA64_KTHREAD_BSTORELIMIT_OFFSET 0x040
  2321. #define IA64_3555_KTHREAD_BSTORELIMIT_OFFSET 0x048
  2322. #define PEB_FROM_TEB32 48
  2323. #define PEB_FROM_TEB64 96
  2324. #define STACK_BASE_FROM_TEB32 4
  2325. #define STACK_BASE_FROM_TEB64 8
  2326. #define PEBLDR_FROM_PEB32 12
  2327. #define PEBLDR_FROM_PEB64 24
  2328. #define MODULE_LIST_FROM_PEBLDR32 12
  2329. #define MODULE_LIST_FROM_PEBLDR64 16
  2330. #define IA64_TEB_BSTORE_BASE 0x1788
  2331. #define X86_SHARED_SYSCALL_BASE_LT2412 0x7ffe02e0
  2332. #define X86_SHARED_SYSCALL_BASE_GTE2412 0x7ffe02f8
  2333. #define X86_SHARED_SYSCALL_BASE_GTE2492 0x7ffe0300
  2334. #define X86_SHARED_SYSCALL_SIZE 0x20
  2335. #define X86_KI_USER_SHARED_DATA 0xffdf0000U
  2336. #define IA64_KI_USER_SHARED_DATA 0xe0000000fffe0000UI64
  2337. #define AMD64_KI_USER_SHARED_DATA 0xfffff78000000000UI64
  2338. // Triage dumps contain a KPRCB and the debugger
  2339. // needs a safe address to map it into virtual space
  2340. // so that it's accessible in a way consistent with
  2341. // other dumps and live debugs. The debugger uses
  2342. // an address in the user-shared-memory area on the
  2343. // theory that nothing in that area should be present
  2344. // in a kernel triage dump so it's a safe place to map in.
  2345. #define X86_TRIAGE_PRCB_ADDRESS 0xffdff120U
  2346. #define IA64_TRIAGE_PRCB_ADDRESS 0xe0000000ffff0000UI64
  2347. #define AMD64_TRIAGE_PRCB_ADDRESS 0xfffff780ffff0000UI64
  2348. #define X86_KGDT_NULL 0
  2349. #define X86_KGDT_R0_CODE 8
  2350. #define X86_KGDT_R0_DATA 16
  2351. #define X86_KGDT_R3_CODE 24
  2352. #define X86_KGDT_R3_DATA 32
  2353. #define X86_KGDT_TSS 40
  2354. #define X86_KGDT_R0_PCR 48
  2355. #define X86_KGDT_R3_TEB 56
  2356. #define X86_KGDT_VDM_TILE 64
  2357. #define X86_KGDT_LDT 72
  2358. #define X86_KGDT_DF_TSS 80
  2359. #define X86_KGDT_NMI_TSS 88
  2360. #define X86_FRAME_EDITED 0xfff8
  2361. #define X86_MODE_MASK 1
  2362. #define X86_EFLAGS_V86_MASK 0x00020000
  2363. #define AMD64_KGDT64_NULL (0 * 16) // NULL descriptor
  2364. #define AMD64_KGDT64_R0_CODE (1 * 16) // kernel mode 64-bit code
  2365. #define AMD64_KGDT64_R0_DATA (1 * 16) + 8 // kernel mode 64-bit data (stack)
  2366. #define AMD64_KGDT64_R3_CMCODE (2 * 16) // user mode 32-bit code
  2367. #define AMD64_KGDT64_R3_DATA (2 * 16) + 8 // user mode 32-bit data
  2368. #define AMD64_KGDT64_R3_CODE (3 * 16) // user mode 64-bit code
  2369. #define AMD64_KGDT64_SYS_TSS (4 * 16) // kernel mode system task state
  2370. #define AMD64_KGDT64_R3_CMTEB (5 * 16) // user mode 32-bit TEB
  2371. #define AMD64_KGDT64_LAST (6 * 16)
  2372. //
  2373. // Memory management info
  2374. //
  2375. #define X86_BASE_VIRT 0xc0300000
  2376. #define X86_BASE_VIRT_PAE 0xc0600000
  2377. #define X86_PAGE_SIZE 0x1000
  2378. #define X86_PAGE_SHIFT 12L
  2379. #define X86_MM_PTE_TRANSITION_MASK 0x800
  2380. #define X86_MM_PTE_PROTOTYPE_MASK 0x400
  2381. #define X86_VALID_PFN_MASK 0xFFFFF000
  2382. #define X86_VALID_PFN_MASK_PAE 0x0000000FFFFFF000UI64
  2383. #define X86_VALID_PFN_SHIFT 12
  2384. #define X86_PDPE_SHIFT 30
  2385. #define X86_PDE_SHIFT 22
  2386. #define X86_PDE_SHIFT_PAE 21
  2387. #define X86_PDE_MASK_PAE 0x1ff
  2388. #define X86_PTE_SHIFT 12
  2389. #define X86_PTE_MASK 0x3ff
  2390. #define X86_PTE_MASK_PAE 0x1ff
  2391. #define X86_LARGE_PAGE_MASK 0x80
  2392. #define X86_LARGE_PAGE_SIZE (4 * 1024 * 1024)
  2393. #define X86_LARGE_PAGE_SIZE_PAE (2 * 1024 * 1024)
  2394. #define X86_PDBR_MASK 0xFFFFFFE0
  2395. #define IA64_PAGE_SIZE 0x2000
  2396. #define IA64_PAGE_SHIFT 13L
  2397. #define IA64_MM_PTE_TRANSITION_MASK 0x80
  2398. #define IA64_MM_PTE_PROTOTYPE_MASK 0x02
  2399. #define IA64_VALID_PFN_MASK 0x0007FFFFFFFFE000UI64
  2400. #define IA64_VALID_PFN_SHIFT 13
  2401. #define IA64_PDE1_SHIFT 33
  2402. #define IA64_PDE2_SHIFT 23
  2403. #define IA64_PDE_MASK 0x3ff
  2404. #define IA64_PTE_SHIFT 13
  2405. #define IA64_PTE_MASK 0x3ff
  2406. #define IA64_PHYSICAL1_START 0x8000000000000000UI64
  2407. #define IA64_PHYSICAL1_END 0x80000FFFFFFFFFFFUI64
  2408. #define IA64_PHYSICAL2_START 0xA000000000000000UI64
  2409. #define IA64_PHYSICAL2_END 0xA0000FFFFFFFFFFFUI64
  2410. #define IA64_PHYSICAL3_START 0xE000000080000000UI64
  2411. #define IA64_PHYSICAL3_END 0xE0000000BFFFFFFFUI64
  2412. #define IA64_PTA_BASE_MASK 0x1FFFFFFFFFFF8000UI64
  2413. #define IA64_REGION_MASK 0xE000000000000000UI64
  2414. #define IA64_REGION_SHIFT 61
  2415. #define IA64_REGION_COUNT 8
  2416. #define IA64_REGION_USER 0
  2417. #define IA64_REGION_SESSION 1
  2418. #define IA64_REGION_KERNEL 7
  2419. #define IA64_VHPT_MASK 0x000000FFFFFF8000UI64
  2420. #define IA64_LARGE_PAGE_PDE_MASK 0x1c
  2421. #define IA64_LARGE_PAGE_PDE_MARK 4
  2422. #define IA64_LARGE_PAGE_SIZE 0x800000
  2423. //
  2424. // Memory management info
  2425. //
  2426. #define AMD64_BASE_VIRT 0xFFFFF6FB7DBED000UI64
  2427. #define AMD64_PAGE_SIZE 0x1000
  2428. #define AMD64_PAGE_SHIFT 12L
  2429. #define AMD64_MM_PTE_TRANSITION_MASK 0x800
  2430. #define AMD64_MM_PTE_PROTOTYPE_MASK 0x400
  2431. #define AMD64_VALID_PFN_MASK 0x000000FFFFFFF000UI64
  2432. #define AMD64_VALID_PFN_SHIFT 12
  2433. #define AMD64_PML4E_SHIFT 39
  2434. #define AMD64_PML4E_MASK 0x1ff
  2435. #define AMD64_PDPE_SHIFT 30
  2436. #define AMD64_PDPE_MASK 0x1ff
  2437. #define AMD64_PDE_SHIFT 21
  2438. #define AMD64_PDE_MASK 0x1ff
  2439. #define AMD64_PTE_SHIFT 12
  2440. #define AMD64_PTE_MASK 0x1ff
  2441. #define AMD64_LARGE_PAGE_MASK 0x80
  2442. #define AMD64_LARGE_PAGE_SIZE (2 * 1024 * 1024)
  2443. #define AMD64_PDBR_MASK AMD64_VALID_PFN_MASK
  2444. #define AMD64_PHYSICAL_START 0xFFFFF80000000000UI64
  2445. #define AMD64_PHYSICAL_END 0xFFFFF8FFFFFFFFFFUI64
  2446. #define ARM_PAGE_SIZE 4096
  2447. #define ARM_PAGE_SHIFT 12
  2448. #define IA64_DEBUG_CONTROL_SPACE_PCR 1
  2449. #define IA64_DEBUG_CONTROL_SPACE_PRCB 2
  2450. #define IA64_DEBUG_CONTROL_SPACE_KSPECIAL 3
  2451. #define IA64_DEBUG_CONTROL_SPACE_THREAD 4
  2452. #define ALPHA_DEBUG_CONTROL_SPACE_PCR 1
  2453. #define ALPHA_DEBUG_CONTROL_SPACE_THREAD 2
  2454. #define ALPHA_DEBUG_CONTROL_SPACE_PRCB 3
  2455. #define ALPHA_DEBUG_CONTROL_SPACE_TEB 6
  2456. #define AMD64_DEBUG_CONTROL_SPACE_PCR 0
  2457. #define AMD64_DEBUG_CONTROL_SPACE_PRCB 1
  2458. #define AMD64_DEBUG_CONTROL_SPACE_KSPECIAL 2
  2459. #define AMD64_DEBUG_CONTROL_SPACE_THREAD 3
  2460. typedef enum _IA64_FUNCTION_TABLE_TYPE {
  2461. IA64_RF_SORTED,
  2462. IA64_RF_UNSORTED,
  2463. IA64_RF_CALLBACK
  2464. } IA64_FUNCTION_TABLE_TYPE;
  2465. typedef struct _IA64_DYNAMIC_FUNCTION_TABLE
  2466. {
  2467. LIST_ENTRY64 Links;
  2468. ULONG64 FunctionTable;
  2469. LARGE_INTEGER TimeStamp;
  2470. ULONG64 MinimumAddress;
  2471. ULONG64 MaximumAddress;
  2472. ULONG64 BaseAddress;
  2473. ULONG64 TargetGp;
  2474. ULONG64 Callback;
  2475. ULONG64 Context;
  2476. ULONG64 OutOfProcessCallbackDll;
  2477. IA64_FUNCTION_TABLE_TYPE Type;
  2478. ULONG EntryCount;
  2479. } IA64_DYNAMIC_FUNCTION_TABLE, *PIA64_DYNAMIC_FUNCTION_TABLE;
  2480. #define IA64_RF_BEGIN_ADDRESS(Base,RF) (( (ULONG64) Base + (RF)->BeginAddress) & (0xFFFFFFFFFFFFFFF0)) // Instruction Size 16 bytes
  2481. #define IA64_RF_END_ADDRESS(Base, RF) (((ULONG64) Base + (RF)->EndAddress+15) & (0xFFFFFFFFFFFFFFF0)) // Instruction Size 16 bytes
  2482. typedef enum _AMD64_FUNCTION_TABLE_TYPE {
  2483. AMD64_RF_SORTED,
  2484. AMD64_RF_UNSORTED,
  2485. AMD64_RF_CALLBACK
  2486. } AMD64_FUNCTION_TABLE_TYPE;
  2487. typedef struct _AMD64_DYNAMIC_FUNCTION_TABLE
  2488. {
  2489. LIST_ENTRY64 ListEntry;
  2490. ULONG64 FunctionTable;
  2491. LARGE_INTEGER TimeStamp;
  2492. ULONG64 MinimumAddress;
  2493. ULONG64 MaximumAddress;
  2494. ULONG64 BaseAddress;
  2495. ULONG64 Callback;
  2496. ULONG64 Context;
  2497. ULONG64 OutOfProcessCallbackDll;
  2498. AMD64_FUNCTION_TABLE_TYPE Type;
  2499. ULONG EntryCount;
  2500. } AMD64_DYNAMIC_FUNCTION_TABLE, *PAMD64_DYNAMIC_FUNCTION_TABLE;
  2501. typedef struct _CROSS_PLATFORM_DYNAMIC_FUNCTION_TABLE {
  2502. union {
  2503. IA64_DYNAMIC_FUNCTION_TABLE IA64Table;
  2504. AMD64_DYNAMIC_FUNCTION_TABLE Amd64Table;
  2505. };
  2506. } CROSS_PLATFORM_DYNAMIC_FUNCTION_TABLE, *PCROSS_PLATFORM_DYNAMIC_FUNCTION_TABLE;
  2507. // More stuff currently used by crashdump
  2508. typedef struct _PAE_ADDRESS {
  2509. union {
  2510. struct {
  2511. ULONG Offset : 12; // 0 .. 11
  2512. ULONG Table : 9; // 12 .. 20
  2513. ULONG Directory : 9; // 21 .. 29
  2514. ULONG DirectoryPointer : 2; // 30 .. 31
  2515. };
  2516. struct {
  2517. ULONG Offset : 21 ;
  2518. ULONG Directory : 9 ;
  2519. ULONG DirectoryPointer : 2;
  2520. } LargeAddress;
  2521. ULONG DwordPart;
  2522. };
  2523. } PAE_ADDRESS, * PPAE_ADDRESS;
  2524. typedef struct _X86PAE_HARDWARE_PTE {
  2525. union {
  2526. struct {
  2527. ULONGLONG Valid : 1;
  2528. ULONGLONG Write : 1;
  2529. ULONGLONG Owner : 1;
  2530. ULONGLONG WriteThrough : 1;
  2531. ULONGLONG CacheDisable : 1;
  2532. ULONGLONG Accessed : 1;
  2533. ULONGLONG Dirty : 1;
  2534. ULONGLONG LargePage : 1;
  2535. ULONGLONG Global : 1;
  2536. ULONGLONG CopyOnWrite : 1; // software field
  2537. ULONGLONG Prototype : 1; // software field
  2538. ULONGLONG reserved0 : 1; // software field
  2539. ULONGLONG PageFrameNumber : 24;
  2540. ULONGLONG reserved1 : 28; // software field
  2541. };
  2542. struct {
  2543. ULONG LowPart;
  2544. ULONG HighPart;
  2545. };
  2546. };
  2547. } X86PAE_HARDWARE_PTE, *PX86PAE_HARDWARE_PTE;
  2548. typedef X86PAE_HARDWARE_PTE X86PAE_HARDWARE_PDPTE;
  2549. typedef struct _X86PAE_HARDWARE_PDE {
  2550. union {
  2551. struct _X86PAE_HARDWARE_PTE Pte;
  2552. struct {
  2553. ULONGLONG Valid : 1;
  2554. ULONGLONG Write : 1;
  2555. ULONGLONG Owner : 1;
  2556. ULONGLONG WriteThrough : 1;
  2557. ULONGLONG CacheDisable : 1;
  2558. ULONGLONG Accessed : 1;
  2559. ULONGLONG Dirty : 1;
  2560. ULONGLONG LargePage : 1;
  2561. ULONGLONG Global : 1;
  2562. ULONGLONG CopyOnWrite : 1;
  2563. ULONGLONG Prototype : 1;
  2564. ULONGLONG reserved0 : 1;
  2565. ULONGLONG reserved2 : 9;
  2566. ULONGLONG PageFrameNumber : 15;
  2567. ULONGLONG reserved1 : 28;
  2568. } Large;
  2569. ULONGLONG QuadPart;
  2570. };
  2571. } X86PAE_HARDWARE_PDE;
  2572. #if defined(_X86_)
  2573. typedef X86_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT;
  2574. typedef X86_DBGKD_CONTROL_SET DBGKD_CONTROL_SET;
  2575. #elif defined(_ALPHA_)
  2576. typedef ALPHA_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT;
  2577. typedef ALPHA_DBGKD_CONTROL_SET DBGKD_CONTROL_SET;
  2578. #elif defined(_IA64_)
  2579. typedef IA64_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT;
  2580. typedef IA64_DBGKD_CONTROL_SET DBGKD_CONTROL_SET;
  2581. #elif defined(_AMD64_)
  2582. typedef AMD64_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT;
  2583. typedef AMD64_DBGKD_CONTROL_SET DBGKD_CONTROL_SET;
  2584. #endif
  2585. //
  2586. // DbgKd APIs are for the portable kernel debugger
  2587. //
  2588. //
  2589. // KD_PACKETS are the low level data format used in KD. All packets
  2590. // begin with a packet leader, byte count, packet type. The sequence
  2591. // for accepting a packet is:
  2592. //
  2593. // - read 4 bytes to get packet leader. If read times out (10 seconds)
  2594. // with a short read, or if packet leader is incorrect, then retry
  2595. // the read.
  2596. //
  2597. // - next read 2 byte packet type. If read times out (10 seconds) with
  2598. // a short read, or if packet type is bad, then start again looking
  2599. // for a packet leader.
  2600. //
  2601. // - next read 4 byte packet Id. If read times out (10 seconds)
  2602. // with a short read, or if packet Id is not what we expect, then
  2603. // ask for resend and restart again looking for a packet leader.
  2604. //
  2605. // - next read 2 byte count. If read times out (10 seconds) with
  2606. // a short read, or if byte count is greater than PACKET_MAX_SIZE,
  2607. // then start again looking for a packet leader.
  2608. //
  2609. // - next read 4 byte packet data checksum.
  2610. //
  2611. // - The packet data immediately follows the packet. There should be
  2612. // ByteCount bytes following the packet header. Read the packet
  2613. // data, if read times out (10 seconds) then start again looking for
  2614. // a packet leader.
  2615. //
  2616. typedef struct _KD_PACKET {
  2617. ULONG PacketLeader;
  2618. USHORT PacketType;
  2619. USHORT ByteCount;
  2620. ULONG PacketId;
  2621. ULONG Checksum;
  2622. } KD_PACKET, *PKD_PACKET;
  2623. #define PACKET_MAX_SIZE 4000
  2624. #define INITIAL_PACKET_ID 0x80800000 // Don't use 0
  2625. #define SYNC_PACKET_ID 0x00000800 // Or in with INITIAL_PACKET_ID
  2626. // to force a packet ID reset.
  2627. //
  2628. // BreakIn packet
  2629. //
  2630. #define BREAKIN_PACKET 0x62626262
  2631. #define BREAKIN_PACKET_BYTE 0x62
  2632. //
  2633. // Packet lead in sequence
  2634. //
  2635. #define PACKET_LEADER 0x30303030 //0x77000077
  2636. #define PACKET_LEADER_BYTE 0x30
  2637. #define CONTROL_PACKET_LEADER 0x69696969
  2638. #define CONTROL_PACKET_LEADER_BYTE 0x69
  2639. //
  2640. // Packet Trailing Byte
  2641. //
  2642. #define PACKET_TRAILING_BYTE 0xAA
  2643. //
  2644. // Packet Types
  2645. //
  2646. #define PACKET_TYPE_UNUSED 0
  2647. #define PACKET_TYPE_KD_STATE_CHANGE32 1
  2648. #define PACKET_TYPE_KD_STATE_MANIPULATE 2
  2649. #define PACKET_TYPE_KD_DEBUG_IO 3
  2650. #define PACKET_TYPE_KD_ACKNOWLEDGE 4 // Packet-control type
  2651. #define PACKET_TYPE_KD_RESEND 5 // Packet-control type
  2652. #define PACKET_TYPE_KD_RESET 6 // Packet-control type
  2653. #define PACKET_TYPE_KD_STATE_CHANGE64 7
  2654. #define PACKET_TYPE_KD_POLL_BREAKIN 8
  2655. #define PACKET_TYPE_KD_TRACE_IO 9
  2656. #define PACKET_TYPE_KD_CONTROL_REQUEST 10
  2657. #define PACKET_TYPE_KD_FILE_IO 11
  2658. #define PACKET_TYPE_MAX 12
  2659. //
  2660. // If the packet type is PACKET_TYPE_KD_STATE_CHANGE, then
  2661. // the format of the packet data is as follows:
  2662. //
  2663. #define DbgKdMinimumStateChange 0x00003030L
  2664. #define DbgKdExceptionStateChange 0x00003030L
  2665. #define DbgKdLoadSymbolsStateChange 0x00003031L
  2666. #define DbgKdCommandStringStateChange 0x00003032L
  2667. #define DbgKdMaximumStateChange 0x00003033L
  2668. // If the state change is from an alternate source
  2669. // then this bit is combined with the basic state change code.
  2670. #define DbgKdAlternateStateChange 0x00010000L
  2671. #define KD_REBOOT (-1)
  2672. #define KD_HIBERNATE (-2)
  2673. //
  2674. // Pathname Data follows directly
  2675. //
  2676. typedef struct _DBGKD_LOAD_SYMBOLS32 {
  2677. ULONG PathNameLength;
  2678. ULONG BaseOfDll;
  2679. ULONG ProcessId;
  2680. ULONG CheckSum;
  2681. ULONG SizeOfImage;
  2682. BOOLEAN UnloadSymbols;
  2683. } DBGKD_LOAD_SYMBOLS32, *PDBGKD_LOAD_SYMBOLS32;
  2684. typedef struct _DBGKD_LOAD_SYMBOLS64 {
  2685. ULONG PathNameLength;
  2686. ULONG64 BaseOfDll;
  2687. ULONG64 ProcessId;
  2688. ULONG CheckSum;
  2689. ULONG SizeOfImage;
  2690. BOOLEAN UnloadSymbols;
  2691. } DBGKD_LOAD_SYMBOLS64, *PDBGKD_LOAD_SYMBOLS64;
  2692. __inline
  2693. void
  2694. DbgkdLoadSymbols32To64(
  2695. IN PDBGKD_LOAD_SYMBOLS32 Ls32,
  2696. OUT PDBGKD_LOAD_SYMBOLS64 Ls64
  2697. )
  2698. {
  2699. Ls64->PathNameLength = Ls32->PathNameLength;
  2700. Ls64->ProcessId = Ls32->ProcessId;
  2701. COPYSE(Ls64,Ls32,BaseOfDll);
  2702. Ls64->CheckSum = Ls32->CheckSum;
  2703. Ls64->SizeOfImage = Ls32->SizeOfImage;
  2704. Ls64->UnloadSymbols = Ls32->UnloadSymbols;
  2705. }
  2706. __inline
  2707. void
  2708. LoadSymbols64To32(
  2709. IN PDBGKD_LOAD_SYMBOLS64 Ls64,
  2710. OUT PDBGKD_LOAD_SYMBOLS32 Ls32
  2711. )
  2712. {
  2713. Ls32->PathNameLength = Ls64->PathNameLength;
  2714. Ls32->ProcessId = (ULONG)Ls64->ProcessId;
  2715. Ls32->BaseOfDll = (ULONG)Ls64->BaseOfDll;
  2716. Ls32->CheckSum = Ls64->CheckSum;
  2717. Ls32->SizeOfImage = Ls64->SizeOfImage;
  2718. Ls32->UnloadSymbols = Ls64->UnloadSymbols;
  2719. }
  2720. //
  2721. // This structure is currently all zeroes.
  2722. // It just reserves a structure name for future use.
  2723. //
  2724. typedef struct _DBGKD_COMMAND_STRING {
  2725. ULONG Flags;
  2726. ULONG Reserved1;
  2727. ULONG64 Reserved2[7];
  2728. } DBGKD_COMMAND_STRING, *PDBGKD_COMMAND_STRING;
  2729. #ifdef _IA64_
  2730. #include <pshpck16.h>
  2731. #endif
  2732. typedef struct _DBGKD_WAIT_STATE_CHANGE32 {
  2733. ULONG NewState;
  2734. USHORT ProcessorLevel;
  2735. USHORT Processor;
  2736. ULONG NumberProcessors;
  2737. ULONG Thread;
  2738. ULONG ProgramCounter;
  2739. union {
  2740. DBGKM_EXCEPTION32 Exception;
  2741. DBGKD_LOAD_SYMBOLS32 LoadSymbols;
  2742. } u;
  2743. // A processor-specific control report and context follows.
  2744. } DBGKD_WAIT_STATE_CHANGE32, *PDBGKD_WAIT_STATE_CHANGE32;
  2745. // Protocol version 5 64-bit state change.
  2746. typedef struct _DBGKD_WAIT_STATE_CHANGE64 {
  2747. ULONG NewState;
  2748. USHORT ProcessorLevel;
  2749. USHORT Processor;
  2750. ULONG NumberProcessors;
  2751. ULONG64 Thread;
  2752. ULONG64 ProgramCounter;
  2753. union {
  2754. DBGKM_EXCEPTION64 Exception;
  2755. DBGKD_LOAD_SYMBOLS64 LoadSymbols;
  2756. } u;
  2757. // A processor-specific control report and context follows.
  2758. } DBGKD_WAIT_STATE_CHANGE64, *PDBGKD_WAIT_STATE_CHANGE64;
  2759. // Protocol version 6 state change.
  2760. typedef struct _DBGKD_ANY_WAIT_STATE_CHANGE {
  2761. ULONG NewState;
  2762. USHORT ProcessorLevel;
  2763. USHORT Processor;
  2764. ULONG NumberProcessors;
  2765. ULONG64 Thread;
  2766. ULONG64 ProgramCounter;
  2767. union {
  2768. DBGKM_EXCEPTION64 Exception;
  2769. DBGKD_LOAD_SYMBOLS64 LoadSymbols;
  2770. DBGKD_COMMAND_STRING CommandString;
  2771. } u;
  2772. // The ANY control report is unioned here to
  2773. // ensure that this structure is always large
  2774. // enough to hold any possible state change.
  2775. union {
  2776. DBGKD_CONTROL_REPORT ControlReport;
  2777. DBGKD_ANY_CONTROL_REPORT AnyControlReport;
  2778. };
  2779. } DBGKD_ANY_WAIT_STATE_CHANGE, *PDBGKD_ANY_WAIT_STATE_CHANGE;
  2780. #ifdef _IA64_
  2781. #include <poppack.h>
  2782. #endif
  2783. //
  2784. // If the packet type is PACKET_TYPE_KD_STATE_MANIPULATE, then
  2785. // the format of the packet data is as follows:
  2786. //
  2787. // Api Numbers for state manipulation
  2788. //
  2789. #define DbgKdMinimumManipulate 0x00003130L
  2790. #define DbgKdReadVirtualMemoryApi 0x00003130L
  2791. #define DbgKdWriteVirtualMemoryApi 0x00003131L
  2792. #define DbgKdGetContextApi 0x00003132L
  2793. #define DbgKdSetContextApi 0x00003133L
  2794. #define DbgKdWriteBreakPointApi 0x00003134L
  2795. #define DbgKdRestoreBreakPointApi 0x00003135L
  2796. #define DbgKdContinueApi 0x00003136L
  2797. #define DbgKdReadControlSpaceApi 0x00003137L
  2798. #define DbgKdWriteControlSpaceApi 0x00003138L
  2799. #define DbgKdReadIoSpaceApi 0x00003139L
  2800. #define DbgKdWriteIoSpaceApi 0x0000313AL
  2801. #define DbgKdRebootApi 0x0000313BL
  2802. #define DbgKdContinueApi2 0x0000313CL
  2803. #define DbgKdReadPhysicalMemoryApi 0x0000313DL
  2804. #define DbgKdWritePhysicalMemoryApi 0x0000313EL
  2805. //#define DbgKdQuerySpecialCallsApi 0x0000313FL
  2806. #define DbgKdSetSpecialCallApi 0x00003140L
  2807. #define DbgKdClearSpecialCallsApi 0x00003141L
  2808. #define DbgKdSetInternalBreakPointApi 0x00003142L
  2809. #define DbgKdGetInternalBreakPointApi 0x00003143L
  2810. #define DbgKdReadIoSpaceExtendedApi 0x00003144L
  2811. #define DbgKdWriteIoSpaceExtendedApi 0x00003145L
  2812. #define DbgKdGetVersionApi 0x00003146L
  2813. #define DbgKdWriteBreakPointExApi 0x00003147L
  2814. #define DbgKdRestoreBreakPointExApi 0x00003148L
  2815. #define DbgKdCauseBugCheckApi 0x00003149L
  2816. #define DbgKdSwitchProcessor 0x00003150L
  2817. #define DbgKdPageInApi 0x00003151L // obsolete
  2818. #define DbgKdReadMachineSpecificRegister 0x00003152L
  2819. #define DbgKdWriteMachineSpecificRegister 0x00003153L
  2820. #define OldVlm1 0x00003154L
  2821. #define OldVlm2 0x00003155L
  2822. #define DbgKdSearchMemoryApi 0x00003156L
  2823. #define DbgKdGetBusDataApi 0x00003157L
  2824. #define DbgKdSetBusDataApi 0x00003158L
  2825. #define DbgKdCheckLowMemoryApi 0x00003159L
  2826. #define DbgKdClearAllInternalBreakpointsApi 0x0000315AL
  2827. #define DbgKdFillMemoryApi 0x0000315BL
  2828. #define DbgKdQueryMemoryApi 0x0000315CL
  2829. #define DbgKdSwitchPartition 0x0000315DL
  2830. #define DbgKdMaximumManipulate 0x0000315EL
  2831. //
  2832. // Physical memory caching flags.
  2833. // These flags can be passed in on physical memory
  2834. // access requests in the ActualBytes field.
  2835. //
  2836. #define DBGKD_CACHING_UNKNOWN 0
  2837. #define DBGKD_CACHING_CACHED 1
  2838. #define DBGKD_CACHING_UNCACHED 2
  2839. #define DBGKD_CACHING_WRITE_COMBINED 3
  2840. //
  2841. // Response is a read memory message with data following
  2842. //
  2843. typedef struct _DBGKD_READ_MEMORY32 {
  2844. ULONG TargetBaseAddress;
  2845. ULONG TransferCount;
  2846. ULONG ActualBytesRead;
  2847. } DBGKD_READ_MEMORY32, *PDBGKD_READ_MEMORY32;
  2848. typedef struct _DBGKD_READ_MEMORY64 {
  2849. ULONG64 TargetBaseAddress;
  2850. ULONG TransferCount;
  2851. ULONG ActualBytesRead;
  2852. } DBGKD_READ_MEMORY64, *PDBGKD_READ_MEMORY64;
  2853. __inline
  2854. void
  2855. DbgkdReadMemory32To64(
  2856. IN PDBGKD_READ_MEMORY32 r32,
  2857. OUT PDBGKD_READ_MEMORY64 r64
  2858. )
  2859. {
  2860. COPYSE(r64,r32,TargetBaseAddress);
  2861. r64->TransferCount = r32->TransferCount;
  2862. r64->ActualBytesRead = r32->ActualBytesRead;
  2863. }
  2864. __inline
  2865. void
  2866. DbgkdReadMemory64To32(
  2867. IN PDBGKD_READ_MEMORY64 r64,
  2868. OUT PDBGKD_READ_MEMORY32 r32
  2869. )
  2870. {
  2871. r32->TargetBaseAddress = (ULONG)r64->TargetBaseAddress;
  2872. r32->TransferCount = r64->TransferCount;
  2873. r32->ActualBytesRead = r64->ActualBytesRead;
  2874. }
  2875. //
  2876. // Data follows directly
  2877. //
  2878. typedef struct _DBGKD_WRITE_MEMORY32 {
  2879. ULONG TargetBaseAddress;
  2880. ULONG TransferCount;
  2881. ULONG ActualBytesWritten;
  2882. } DBGKD_WRITE_MEMORY32, *PDBGKD_WRITE_MEMORY32;
  2883. typedef struct _DBGKD_WRITE_MEMORY64 {
  2884. ULONG64 TargetBaseAddress;
  2885. ULONG TransferCount;
  2886. ULONG ActualBytesWritten;
  2887. } DBGKD_WRITE_MEMORY64, *PDBGKD_WRITE_MEMORY64;
  2888. __inline
  2889. void
  2890. DbgkdWriteMemory32To64(
  2891. IN PDBGKD_WRITE_MEMORY32 r32,
  2892. OUT PDBGKD_WRITE_MEMORY64 r64
  2893. )
  2894. {
  2895. COPYSE(r64,r32,TargetBaseAddress);
  2896. r64->TransferCount = r32->TransferCount;
  2897. r64->ActualBytesWritten = r32->ActualBytesWritten;
  2898. }
  2899. __inline
  2900. void
  2901. DbgkdWriteMemory64To32(
  2902. IN PDBGKD_WRITE_MEMORY64 r64,
  2903. OUT PDBGKD_WRITE_MEMORY32 r32
  2904. )
  2905. {
  2906. r32->TargetBaseAddress = (ULONG)r64->TargetBaseAddress;
  2907. r32->TransferCount = r64->TransferCount;
  2908. r32->ActualBytesWritten = r64->ActualBytesWritten;
  2909. }
  2910. //
  2911. // Response is a get context message with a full context record following
  2912. //
  2913. typedef struct _DBGKD_GET_CONTEXT {
  2914. ULONG Unused;
  2915. } DBGKD_GET_CONTEXT, *PDBGKD_GET_CONTEXT;
  2916. //
  2917. // Full Context record follows
  2918. //
  2919. typedef struct _DBGKD_SET_CONTEXT {
  2920. ULONG ContextFlags;
  2921. } DBGKD_SET_CONTEXT, *PDBGKD_SET_CONTEXT;
  2922. #define BREAKPOINT_TABLE_SIZE 32 // max number supported by kernel
  2923. typedef struct _DBGKD_WRITE_BREAKPOINT32 {
  2924. ULONG BreakPointAddress;
  2925. ULONG BreakPointHandle;
  2926. } DBGKD_WRITE_BREAKPOINT32, *PDBGKD_WRITE_BREAKPOINT32;
  2927. typedef struct _DBGKD_WRITE_BREAKPOINT64 {
  2928. ULONG64 BreakPointAddress;
  2929. ULONG BreakPointHandle;
  2930. } DBGKD_WRITE_BREAKPOINT64, *PDBGKD_WRITE_BREAKPOINT64;
  2931. __inline
  2932. void
  2933. DbgkdWriteBreakpoint32To64(
  2934. IN PDBGKD_WRITE_BREAKPOINT32 r32,
  2935. OUT PDBGKD_WRITE_BREAKPOINT64 r64
  2936. )
  2937. {
  2938. COPYSE(r64,r32,BreakPointAddress);
  2939. r64->BreakPointHandle = r32->BreakPointHandle;
  2940. }
  2941. __inline
  2942. void
  2943. DbgkdWriteBreakpoint64To32(
  2944. IN PDBGKD_WRITE_BREAKPOINT64 r64,
  2945. OUT PDBGKD_WRITE_BREAKPOINT32 r32
  2946. )
  2947. {
  2948. r32->BreakPointAddress = (ULONG)r64->BreakPointAddress;
  2949. r32->BreakPointHandle = r64->BreakPointHandle;
  2950. }
  2951. typedef struct _DBGKD_RESTORE_BREAKPOINT {
  2952. ULONG BreakPointHandle;
  2953. } DBGKD_RESTORE_BREAKPOINT, *PDBGKD_RESTORE_BREAKPOINT;
  2954. typedef struct _DBGKD_BREAKPOINTEX {
  2955. ULONG BreakPointCount;
  2956. NTSTATUS ContinueStatus;
  2957. } DBGKD_BREAKPOINTEX, *PDBGKD_BREAKPOINTEX;
  2958. typedef struct _DBGKD_CONTINUE {
  2959. NTSTATUS ContinueStatus;
  2960. } DBGKD_CONTINUE, *PDBGKD_CONTINUE;
  2961. // This structure must be 32-bit packed for
  2962. // for compatibility with older, processor-specific
  2963. // versions of this structure.
  2964. #include <pshpack4.h>
  2965. typedef struct _DBGKD_CONTINUE2 {
  2966. NTSTATUS ContinueStatus;
  2967. // The ANY control set is unioned here to
  2968. // ensure that this structure is always large
  2969. // enough to hold any possible continue.
  2970. union {
  2971. DBGKD_CONTROL_SET ControlSet;
  2972. DBGKD_ANY_CONTROL_SET AnyControlSet;
  2973. };
  2974. } DBGKD_CONTINUE2, *PDBGKD_CONTINUE2;
  2975. #include <poppack.h>
  2976. typedef struct _DBGKD_READ_WRITE_IO32 {
  2977. ULONG DataSize; // 1, 2, 4
  2978. ULONG IoAddress;
  2979. ULONG DataValue;
  2980. } DBGKD_READ_WRITE_IO32, *PDBGKD_READ_WRITE_IO32;
  2981. typedef struct _DBGKD_READ_WRITE_IO64 {
  2982. ULONG64 IoAddress;
  2983. ULONG DataSize; // 1, 2, 4
  2984. ULONG DataValue;
  2985. } DBGKD_READ_WRITE_IO64, *PDBGKD_READ_WRITE_IO64;
  2986. __inline
  2987. void
  2988. DbgkdReadWriteIo32To64(
  2989. IN PDBGKD_READ_WRITE_IO32 r32,
  2990. OUT PDBGKD_READ_WRITE_IO64 r64
  2991. )
  2992. {
  2993. COPYSE(r64,r32,IoAddress);
  2994. r64->DataSize = r32->DataSize;
  2995. r64->DataValue = r32->DataValue;
  2996. }
  2997. __inline
  2998. void
  2999. DbgkdReadWriteIo64To32(
  3000. IN PDBGKD_READ_WRITE_IO64 r64,
  3001. OUT PDBGKD_READ_WRITE_IO32 r32
  3002. )
  3003. {
  3004. r32->IoAddress = (ULONG)r64->IoAddress;
  3005. r32->DataSize = r64->DataSize;
  3006. r32->DataValue = r64->DataValue;
  3007. }
  3008. typedef struct _DBGKD_READ_WRITE_IO_EXTENDED32 {
  3009. ULONG DataSize; // 1, 2, 4
  3010. ULONG InterfaceType;
  3011. ULONG BusNumber;
  3012. ULONG AddressSpace;
  3013. ULONG IoAddress;
  3014. ULONG DataValue;
  3015. } DBGKD_READ_WRITE_IO_EXTENDED32, *PDBGKD_READ_WRITE_IO_EXTENDED32;
  3016. typedef struct _DBGKD_READ_WRITE_IO_EXTENDED64 {
  3017. ULONG DataSize; // 1, 2, 4
  3018. ULONG InterfaceType;
  3019. ULONG BusNumber;
  3020. ULONG AddressSpace;
  3021. ULONG64 IoAddress;
  3022. ULONG DataValue;
  3023. } DBGKD_READ_WRITE_IO_EXTENDED64, *PDBGKD_READ_WRITE_IO_EXTENDED64;
  3024. __inline
  3025. void
  3026. DbgkdReadWriteIoExtended32To64(
  3027. IN PDBGKD_READ_WRITE_IO_EXTENDED32 r32,
  3028. OUT PDBGKD_READ_WRITE_IO_EXTENDED64 r64
  3029. )
  3030. {
  3031. r64->DataSize = r32->DataSize;
  3032. r64->InterfaceType = r32->InterfaceType;
  3033. r64->BusNumber = r32->BusNumber;
  3034. r64->AddressSpace = r32->AddressSpace;
  3035. COPYSE(r64,r32,IoAddress);
  3036. r64->DataValue = r32->DataValue;
  3037. }
  3038. __inline
  3039. void
  3040. DbgkdReadWriteIoExtended64To32(
  3041. IN PDBGKD_READ_WRITE_IO_EXTENDED64 r64,
  3042. OUT PDBGKD_READ_WRITE_IO_EXTENDED32 r32
  3043. )
  3044. {
  3045. r32->DataSize = r64->DataSize;
  3046. r32->InterfaceType = r64->InterfaceType;
  3047. r32->BusNumber = r64->BusNumber;
  3048. r32->AddressSpace = r64->AddressSpace;
  3049. r32->IoAddress = (ULONG)r64-> IoAddress;
  3050. r32->DataValue = r64->DataValue;
  3051. }
  3052. typedef struct _DBGKD_READ_WRITE_MSR {
  3053. ULONG Msr;
  3054. ULONG DataValueLow;
  3055. ULONG DataValueHigh;
  3056. } DBGKD_READ_WRITE_MSR, *PDBGKD_READ_WRITE_MSR;
  3057. typedef struct _DBGKD_QUERY_SPECIAL_CALLS {
  3058. ULONG NumberOfSpecialCalls;
  3059. // ULONG64 SpecialCalls[];
  3060. } DBGKD_QUERY_SPECIAL_CALLS, *PDBGKD_QUERY_SPECIAL_CALLS;
  3061. typedef struct _DBGKD_SET_SPECIAL_CALL32 {
  3062. ULONG SpecialCall;
  3063. } DBGKD_SET_SPECIAL_CALL32, *PDBGKD_SET_SPECIAL_CALL32;
  3064. typedef struct _DBGKD_SET_SPECIAL_CALL64 {
  3065. ULONG64 SpecialCall;
  3066. } DBGKD_SET_SPECIAL_CALL64, *PDBGKD_SET_SPECIAL_CALL64;
  3067. __inline
  3068. void
  3069. DbgkdSetSpecialCall64To32(
  3070. IN PDBGKD_SET_SPECIAL_CALL64 r64,
  3071. OUT PDBGKD_SET_SPECIAL_CALL32 r32
  3072. )
  3073. {
  3074. r32->SpecialCall = (ULONG)r64->SpecialCall;
  3075. }
  3076. #define DBGKD_MAX_INTERNAL_BREAKPOINTS 20
  3077. typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT32 {
  3078. ULONG BreakpointAddress;
  3079. ULONG Flags;
  3080. } DBGKD_SET_INTERNAL_BREAKPOINT32, *PDBGKD_SET_INTERNAL_BREAKPOINT32;
  3081. typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT64 {
  3082. ULONG64 BreakpointAddress;
  3083. ULONG Flags;
  3084. } DBGKD_SET_INTERNAL_BREAKPOINT64, *PDBGKD_SET_INTERNAL_BREAKPOINT64;
  3085. __inline
  3086. void
  3087. DbgkdSetInternalBreakpoint64To32(
  3088. IN PDBGKD_SET_INTERNAL_BREAKPOINT64 r64,
  3089. OUT PDBGKD_SET_INTERNAL_BREAKPOINT32 r32
  3090. )
  3091. {
  3092. r32->BreakpointAddress = (ULONG)r64->BreakpointAddress;
  3093. r32->Flags = r64->Flags;
  3094. }
  3095. typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT32 {
  3096. ULONG BreakpointAddress;
  3097. ULONG Flags;
  3098. ULONG Calls;
  3099. ULONG MaxCallsPerPeriod;
  3100. ULONG MinInstructions;
  3101. ULONG MaxInstructions;
  3102. ULONG TotalInstructions;
  3103. } DBGKD_GET_INTERNAL_BREAKPOINT32, *PDBGKD_GET_INTERNAL_BREAKPOINT32;
  3104. typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT64 {
  3105. ULONG64 BreakpointAddress;
  3106. ULONG Flags;
  3107. ULONG Calls;
  3108. ULONG MaxCallsPerPeriod;
  3109. ULONG MinInstructions;
  3110. ULONG MaxInstructions;
  3111. ULONG TotalInstructions;
  3112. } DBGKD_GET_INTERNAL_BREAKPOINT64, *PDBGKD_GET_INTERNAL_BREAKPOINT64;
  3113. __inline
  3114. void
  3115. DbgkdGetInternalBreakpoint32To64(
  3116. IN PDBGKD_GET_INTERNAL_BREAKPOINT32 r32,
  3117. OUT PDBGKD_GET_INTERNAL_BREAKPOINT64 r64
  3118. )
  3119. {
  3120. COPYSE(r64,r32,BreakpointAddress);
  3121. r64->Flags = r32->Flags;
  3122. r64->Calls = r32->Calls;
  3123. r64->MaxCallsPerPeriod = r32->MaxCallsPerPeriod;
  3124. r64->MinInstructions = r32->MinInstructions;
  3125. r64->MaxInstructions = r32->MaxInstructions;
  3126. r64->TotalInstructions = r32->TotalInstructions;
  3127. }
  3128. __inline
  3129. void
  3130. DbgkdGetInternalBreakpoint64To32(
  3131. IN PDBGKD_GET_INTERNAL_BREAKPOINT64 r64,
  3132. OUT PDBGKD_GET_INTERNAL_BREAKPOINT32 r32
  3133. )
  3134. {
  3135. r32->BreakpointAddress = (ULONG)r64->BreakpointAddress;
  3136. r32->Flags = r64->Flags;
  3137. r32->Calls = r64->Calls;
  3138. r32->MaxCallsPerPeriod = r64->MaxCallsPerPeriod;
  3139. r32->MinInstructions = r64->MinInstructions;
  3140. r32->MaxInstructions = r64->MaxInstructions;
  3141. r32->TotalInstructions = r64->TotalInstructions;
  3142. }
  3143. #define DBGKD_INTERNAL_BP_FLAG_COUNTONLY 0x00000001 // don't count instructions
  3144. #define DBGKD_INTERNAL_BP_FLAG_INVALID 0x00000002 // disabled BP
  3145. #define DBGKD_INTERNAL_BP_FLAG_SUSPENDED 0x00000004 // temporarily suspended
  3146. #define DBGKD_INTERNAL_BP_FLAG_DYING 0x00000008 // kill on exit
  3147. //
  3148. // The packet protocol was widened to 64 bits in version 5.
  3149. // The PTR64 flag allows the debugger to read the right
  3150. // size of pointer when neccessary.
  3151. //
  3152. // The version packet was changed in the same revision, to remove the
  3153. // data that are now available in KDDEBUGGER_DATA.
  3154. //
  3155. // Version 6 adjusted the structures to use
  3156. // cross-platform versions all the time.
  3157. //
  3158. #define DBGKD_64BIT_PROTOCOL_VERSION1 5
  3159. #define DBGKD_64BIT_PROTOCOL_VERSION2 6
  3160. typedef struct _DBGKD_SEARCH_MEMORY {
  3161. union {
  3162. ULONG64 SearchAddress;
  3163. ULONG64 FoundAddress;
  3164. };
  3165. ULONG64 SearchLength;
  3166. ULONG PatternLength;
  3167. } DBGKD_SEARCH_MEMORY, *PDBGKD_SEARCH_MEMORY;
  3168. typedef struct _DBGKD_GET_SET_BUS_DATA {
  3169. ULONG BusDataType;
  3170. ULONG BusNumber;
  3171. ULONG SlotNumber;
  3172. ULONG Offset;
  3173. ULONG Length;
  3174. } DBGKD_GET_SET_BUS_DATA, *PDBGKD_GET_SET_BUS_DATA;
  3175. #define DBGKD_FILL_MEMORY_VIRTUAL 0x00000001
  3176. #define DBGKD_FILL_MEMORY_PHYSICAL 0x00000002
  3177. typedef struct _DBGKD_FILL_MEMORY {
  3178. ULONG64 Address;
  3179. ULONG Length;
  3180. USHORT Flags;
  3181. USHORT PatternLength;
  3182. } DBGKD_FILL_MEMORY, *PDBGKD_FILL_MEMORY;
  3183. // Input AddressSpace values.
  3184. #define DBGKD_QUERY_MEMORY_VIRTUAL 0x00000000
  3185. // Output AddressSpace values.
  3186. #define DBGKD_QUERY_MEMORY_PROCESS 0x00000000
  3187. #define DBGKD_QUERY_MEMORY_SESSION 0x00000001
  3188. #define DBGKD_QUERY_MEMORY_KERNEL 0x00000002
  3189. // Output Flags.
  3190. // Currently the kernel always returns rwx.
  3191. #define DBGKD_QUERY_MEMORY_READ 0x00000001
  3192. #define DBGKD_QUERY_MEMORY_WRITE 0x00000002
  3193. #define DBGKD_QUERY_MEMORY_EXECUTE 0x00000004
  3194. #define DBGKD_QUERY_MEMORY_FIXED 0x00000008
  3195. typedef struct _DBGKD_QUERY_MEMORY {
  3196. ULONG64 Address;
  3197. ULONG64 Reserved;
  3198. ULONG AddressSpace;
  3199. ULONG Flags;
  3200. } DBGKD_QUERY_MEMORY, *PDBGKD_QUERY_MEMORY;
  3201. #define DBGKD_PARTITION_DEFAULT 0x00000000
  3202. #define DBGKD_PARTITION_ALTERNATE 0x00000001
  3203. typedef struct _DBGKD_SWITCH_PARTITION {
  3204. ULONG Partition;
  3205. } DBGKD_SWITCH_PARTITION;
  3206. #include <pshpack4.h>
  3207. typedef struct _DBGKD_MANIPULATE_STATE32 {
  3208. ULONG ApiNumber;
  3209. USHORT ProcessorLevel;
  3210. USHORT Processor;
  3211. NTSTATUS ReturnStatus;
  3212. union {
  3213. DBGKD_READ_MEMORY32 ReadMemory;
  3214. DBGKD_WRITE_MEMORY32 WriteMemory;
  3215. DBGKD_READ_MEMORY64 ReadMemory64;
  3216. DBGKD_WRITE_MEMORY64 WriteMemory64;
  3217. DBGKD_GET_CONTEXT GetContext;
  3218. DBGKD_SET_CONTEXT SetContext;
  3219. DBGKD_WRITE_BREAKPOINT32 WriteBreakPoint;
  3220. DBGKD_RESTORE_BREAKPOINT RestoreBreakPoint;
  3221. DBGKD_CONTINUE Continue;
  3222. DBGKD_CONTINUE2 Continue2;
  3223. DBGKD_READ_WRITE_IO32 ReadWriteIo;
  3224. DBGKD_READ_WRITE_IO_EXTENDED32 ReadWriteIoExtended;
  3225. DBGKD_QUERY_SPECIAL_CALLS QuerySpecialCalls;
  3226. DBGKD_SET_SPECIAL_CALL32 SetSpecialCall;
  3227. DBGKD_SET_INTERNAL_BREAKPOINT32 SetInternalBreakpoint;
  3228. DBGKD_GET_INTERNAL_BREAKPOINT32 GetInternalBreakpoint;
  3229. DBGKD_GET_VERSION32 GetVersion32;
  3230. DBGKD_BREAKPOINTEX BreakPointEx;
  3231. DBGKD_READ_WRITE_MSR ReadWriteMsr;
  3232. DBGKD_SEARCH_MEMORY SearchMemory;
  3233. } u;
  3234. } DBGKD_MANIPULATE_STATE32, *PDBGKD_MANIPULATE_STATE32;
  3235. #include <poppack.h>
  3236. typedef struct _DBGKD_MANIPULATE_STATE64 {
  3237. ULONG ApiNumber;
  3238. USHORT ProcessorLevel;
  3239. USHORT Processor;
  3240. NTSTATUS ReturnStatus;
  3241. union {
  3242. DBGKD_READ_MEMORY64 ReadMemory;
  3243. DBGKD_WRITE_MEMORY64 WriteMemory;
  3244. DBGKD_GET_CONTEXT GetContext;
  3245. DBGKD_SET_CONTEXT SetContext;
  3246. DBGKD_WRITE_BREAKPOINT64 WriteBreakPoint;
  3247. DBGKD_RESTORE_BREAKPOINT RestoreBreakPoint;
  3248. DBGKD_CONTINUE Continue;
  3249. DBGKD_CONTINUE2 Continue2;
  3250. DBGKD_READ_WRITE_IO64 ReadWriteIo;
  3251. DBGKD_READ_WRITE_IO_EXTENDED64 ReadWriteIoExtended;
  3252. DBGKD_QUERY_SPECIAL_CALLS QuerySpecialCalls;
  3253. DBGKD_SET_SPECIAL_CALL64 SetSpecialCall;
  3254. DBGKD_SET_INTERNAL_BREAKPOINT64 SetInternalBreakpoint;
  3255. DBGKD_GET_INTERNAL_BREAKPOINT64 GetInternalBreakpoint;
  3256. DBGKD_GET_VERSION64 GetVersion64;
  3257. DBGKD_BREAKPOINTEX BreakPointEx;
  3258. DBGKD_READ_WRITE_MSR ReadWriteMsr;
  3259. DBGKD_SEARCH_MEMORY SearchMemory;
  3260. DBGKD_GET_SET_BUS_DATA GetSetBusData;
  3261. DBGKD_FILL_MEMORY FillMemory;
  3262. DBGKD_QUERY_MEMORY QueryMemory;
  3263. DBGKD_SWITCH_PARTITION SwitchPartition;
  3264. } u;
  3265. } DBGKD_MANIPULATE_STATE64, *PDBGKD_MANIPULATE_STATE64;
  3266. __inline
  3267. ULONG
  3268. DbgkdManipulateState32To64(
  3269. IN PDBGKD_MANIPULATE_STATE32 r32,
  3270. OUT PDBGKD_MANIPULATE_STATE64 r64,
  3271. OUT PULONG AdditionalDataSize
  3272. )
  3273. {
  3274. r64->ApiNumber = r32->ApiNumber;
  3275. r64->ProcessorLevel = r32->ProcessorLevel;
  3276. r64->Processor = r32->Processor;
  3277. r64->ReturnStatus = r32->ReturnStatus;
  3278. *AdditionalDataSize = 0;
  3279. //
  3280. // translate the messages which may be sent by the kernel
  3281. //
  3282. switch (r64->ApiNumber) {
  3283. case DbgKdSetContextApi:
  3284. case DbgKdRestoreBreakPointApi:
  3285. case DbgKdContinueApi:
  3286. case DbgKdContinueApi2:
  3287. case DbgKdRebootApi:
  3288. case DbgKdClearSpecialCallsApi:
  3289. case DbgKdRestoreBreakPointExApi:
  3290. case DbgKdCauseBugCheckApi:
  3291. case DbgKdSwitchProcessor:
  3292. case DbgKdWriteMachineSpecificRegister:
  3293. case DbgKdWriteIoSpaceApi:
  3294. case DbgKdSetSpecialCallApi:
  3295. case DbgKdSetInternalBreakPointApi:
  3296. case DbgKdWriteIoSpaceExtendedApi:
  3297. break;
  3298. case DbgKdReadMachineSpecificRegister:
  3299. r64->u.ReadWriteMsr = r32->u.ReadWriteMsr;
  3300. break;
  3301. //
  3302. // GetVersion may need to be handled by the calling code;
  3303. // it needs to call DbgkdGetVersion32To64 with the DebuggerDataBlock.
  3304. //
  3305. case DbgKdGetVersionApi:
  3306. break;
  3307. case DbgKdGetContextApi:
  3308. *AdditionalDataSize = sizeof(CONTEXT);
  3309. break;
  3310. //case DbgKdQuerySpecialCallsApi:
  3311. // r64->u.QuerySpecialCalls = r32->u.QuerySpecialCalls;
  3312. // *AdditionalDataSize = r64->u.QuerySpecialCalls.NumberOfSpecialCalls * sizeof(ULONG);
  3313. // break;
  3314. case DbgKdWriteBreakPointExApi:
  3315. r64->u.BreakPointEx = r32->u.BreakPointEx;
  3316. *AdditionalDataSize = r64->u.BreakPointEx.BreakPointCount * sizeof(ULONG);
  3317. break;
  3318. case DbgKdReadVirtualMemoryApi:
  3319. case DbgKdReadPhysicalMemoryApi:
  3320. case DbgKdReadControlSpaceApi:
  3321. DbgkdReadMemory32To64(&r32->u.ReadMemory, &r64->u.ReadMemory);
  3322. if (NT_SUCCESS(r32->ReturnStatus)) {
  3323. *AdditionalDataSize = r64->u.ReadMemory.ActualBytesRead;
  3324. }
  3325. break;
  3326. case DbgKdWriteVirtualMemoryApi:
  3327. case DbgKdWritePhysicalMemoryApi:
  3328. case DbgKdWriteControlSpaceApi:
  3329. DbgkdWriteMemory32To64(&r32->u.WriteMemory, &r64->u.WriteMemory);
  3330. break;
  3331. case DbgKdWriteBreakPointApi:
  3332. DbgkdWriteBreakpoint32To64(&r32->u.WriteBreakPoint, &r64->u.WriteBreakPoint);
  3333. break;
  3334. case DbgKdReadIoSpaceApi:
  3335. DbgkdReadWriteIo32To64(&r32->u.ReadWriteIo, &r64->u.ReadWriteIo);
  3336. break;
  3337. case DbgKdReadIoSpaceExtendedApi:
  3338. DbgkdReadWriteIoExtended32To64(&r32->u.ReadWriteIoExtended, &r64->u.ReadWriteIoExtended);
  3339. break;
  3340. case DbgKdGetInternalBreakPointApi:
  3341. DbgkdGetInternalBreakpoint32To64(&r32->u.GetInternalBreakpoint, &r64->u.GetInternalBreakpoint);
  3342. break;
  3343. case DbgKdSearchMemoryApi:
  3344. r64->u.SearchMemory = r32->u.SearchMemory;
  3345. break;
  3346. }
  3347. return sizeof(DBGKD_MANIPULATE_STATE64);
  3348. }
  3349. __inline
  3350. ULONG
  3351. DbgkdManipulateState64To32(
  3352. IN PDBGKD_MANIPULATE_STATE64 r64,
  3353. OUT PDBGKD_MANIPULATE_STATE32 r32
  3354. )
  3355. {
  3356. r32->ApiNumber = r64->ApiNumber;
  3357. r32->ProcessorLevel = r64->ProcessorLevel;
  3358. r32->Processor = r64->Processor;
  3359. r32->ReturnStatus = r64->ReturnStatus;
  3360. //
  3361. // translate the messages sent by the debugger
  3362. //
  3363. switch (r32->ApiNumber) {
  3364. //
  3365. // These send nothing in the u part.
  3366. case DbgKdGetContextApi:
  3367. case DbgKdSetContextApi:
  3368. case DbgKdClearSpecialCallsApi:
  3369. case DbgKdRebootApi:
  3370. case DbgKdCauseBugCheckApi:
  3371. case DbgKdSwitchProcessor:
  3372. break;
  3373. case DbgKdRestoreBreakPointApi:
  3374. r32->u.RestoreBreakPoint = r64->u.RestoreBreakPoint;
  3375. break;
  3376. case DbgKdContinueApi:
  3377. r32->u.Continue = r64->u.Continue;
  3378. break;
  3379. case DbgKdContinueApi2:
  3380. r32->u.Continue2 = r64->u.Continue2;
  3381. break;
  3382. //case DbgKdQuerySpecialCallsApi:
  3383. // r32->u.QuerySpecialCalls = r64->u.QuerySpecialCalls;
  3384. // break;
  3385. case DbgKdRestoreBreakPointExApi:
  3386. // NYI
  3387. break;
  3388. case DbgKdReadMachineSpecificRegister:
  3389. case DbgKdWriteMachineSpecificRegister:
  3390. r32->u.ReadWriteMsr = r64->u.ReadWriteMsr;
  3391. break;
  3392. case DbgKdGetVersionApi:
  3393. r32->u.GetVersion32.ProtocolVersion = r64->u.GetVersion64.ProtocolVersion;
  3394. break;
  3395. case DbgKdWriteBreakPointExApi:
  3396. r32->u.BreakPointEx = r64->u.BreakPointEx;
  3397. break;
  3398. case DbgKdWriteVirtualMemoryApi:
  3399. DbgkdWriteMemory64To32(&r64->u.WriteMemory, &r32->u.WriteMemory);
  3400. break;
  3401. //
  3402. // 32 bit systems only support 32 bit physical r/w
  3403. //
  3404. case DbgKdReadControlSpaceApi:
  3405. case DbgKdReadVirtualMemoryApi:
  3406. case DbgKdReadPhysicalMemoryApi:
  3407. DbgkdReadMemory64To32(&r64->u.ReadMemory, &r32->u.ReadMemory);
  3408. break;
  3409. case DbgKdWritePhysicalMemoryApi:
  3410. DbgkdWriteMemory64To32(&r64->u.WriteMemory, &r32->u.WriteMemory);
  3411. break;
  3412. case DbgKdWriteBreakPointApi:
  3413. DbgkdWriteBreakpoint64To32(&r64->u.WriteBreakPoint, &r32->u.WriteBreakPoint);
  3414. break;
  3415. case DbgKdWriteControlSpaceApi:
  3416. DbgkdWriteMemory64To32(&r64->u.WriteMemory, &r32->u.WriteMemory);
  3417. break;
  3418. case DbgKdReadIoSpaceApi:
  3419. case DbgKdWriteIoSpaceApi:
  3420. DbgkdReadWriteIo64To32(&r64->u.ReadWriteIo, &r32->u.ReadWriteIo);
  3421. break;
  3422. case DbgKdSetSpecialCallApi:
  3423. DbgkdSetSpecialCall64To32(&r64->u.SetSpecialCall, &r32->u.SetSpecialCall);
  3424. break;
  3425. case DbgKdSetInternalBreakPointApi:
  3426. DbgkdSetInternalBreakpoint64To32(&r64->u.SetInternalBreakpoint, &r32->u.SetInternalBreakpoint);
  3427. break;
  3428. case DbgKdGetInternalBreakPointApi:
  3429. DbgkdGetInternalBreakpoint64To32(&r64->u.GetInternalBreakpoint, &r32->u.GetInternalBreakpoint);
  3430. break;
  3431. case DbgKdReadIoSpaceExtendedApi:
  3432. case DbgKdWriteIoSpaceExtendedApi:
  3433. DbgkdReadWriteIoExtended64To32(&r64->u.ReadWriteIoExtended, &r32->u.ReadWriteIoExtended);
  3434. break;
  3435. case DbgKdSearchMemoryApi:
  3436. r32->u.SearchMemory = r64->u.SearchMemory;
  3437. break;
  3438. }
  3439. return sizeof(DBGKD_MANIPULATE_STATE32);
  3440. }
  3441. //
  3442. // This is the format for the trace data passed back from the kernel to
  3443. // the debugger to describe multiple calls that have returned since the
  3444. // last trip back. The basic format is that there are a bunch of these
  3445. // (4 byte) unions stuck together. Each union is of one of two types: a
  3446. // 4 byte unsigned long integer, or a three field struct, describing a
  3447. // call (where "call" is delimited by returning or exiting the symbol
  3448. // scope). If the number of instructions executed is too big to fit
  3449. // into a USHORT -1, then the Instructions field has
  3450. // TRACE_DATA_INSTRUCTIONS_BIG and the next union is a LongNumber
  3451. // containing the real number of instructions executed.
  3452. //
  3453. // The very first union returned in each callback is a LongNumber
  3454. // containing the number of unions returned (including the "size"
  3455. // record, so it's always at least 1 even if there's no data to return).
  3456. //
  3457. // This is all returned to the debugger when one of two things
  3458. // happens:
  3459. //
  3460. // 1) The pc moves out of all defined symbol ranges
  3461. // 2) The buffer of trace data entries is filled.
  3462. //
  3463. // The "trace done" case is hacked around on the debugger side. It
  3464. // guarantees that the pc address that indicates a trace exit never
  3465. // winds up in a defined symbol range.
  3466. //
  3467. // The only other complexity in this system is handling the SymbolNumber
  3468. // table. This table is kept in parallel by the kernel and the
  3469. // debugger. When the PC exits a known symbol range, the Begin and End
  3470. // symbol ranges are set by the debugger and are allocated to the next
  3471. // symbol slot upon return. "The next symbol slot" means the numerical
  3472. // next slot number, unless we've filled all slots, in which case it is
  3473. // #0. (ie., allocation is cyclic and not LRU or something). The
  3474. // SymbolNumber table is flushed when a SpecialCalls call is made (ie.,
  3475. // at the beginning of the WatchTrace).
  3476. //
  3477. typedef union _DBGKD_TRACE_DATA {
  3478. struct {
  3479. UCHAR SymbolNumber;
  3480. CHAR LevelChange;
  3481. USHORT Instructions;
  3482. } s;
  3483. ULONG LongNumber;
  3484. } DBGKD_TRACE_DATA, *PDBGKD_TRACE_DATA;
  3485. #define TRACE_DATA_INSTRUCTIONS_BIG 0xffff
  3486. #define TRACE_DATA_BUFFER_MAX_SIZE 40
  3487. //
  3488. // If the packet type is PACKET_TYPE_KD_DEBUG_IO, then
  3489. // the format of the packet data is as follows:
  3490. //
  3491. #define DbgKdPrintStringApi 0x00003230L
  3492. #define DbgKdGetStringApi 0x00003231L
  3493. //
  3494. // For print string, the Null terminated string to print
  3495. // immediately follows the message
  3496. //
  3497. typedef struct _DBGKD_PRINT_STRING {
  3498. ULONG LengthOfString;
  3499. } DBGKD_PRINT_STRING, *PDBGKD_PRINT_STRING;
  3500. //
  3501. // For get string, the Null terminated prompt string
  3502. // immediately follows the message. The LengthOfStringRead
  3503. // field initially contains the maximum number of characters
  3504. // to read. Upon reply, this contains the number of bytes actually
  3505. // read. The data read immediately follows the message.
  3506. //
  3507. //
  3508. typedef struct _DBGKD_GET_STRING {
  3509. ULONG LengthOfPromptString;
  3510. ULONG LengthOfStringRead;
  3511. } DBGKD_GET_STRING, *PDBGKD_GET_STRING;
  3512. typedef struct _DBGKD_DEBUG_IO {
  3513. ULONG ApiNumber;
  3514. USHORT ProcessorLevel;
  3515. USHORT Processor;
  3516. union {
  3517. DBGKD_PRINT_STRING PrintString;
  3518. DBGKD_GET_STRING GetString;
  3519. } u;
  3520. } DBGKD_DEBUG_IO, *PDBGKD_DEBUG_IO;
  3521. //
  3522. // If the packet type is PACKET_TYPE_KD_TRACE_IO, then
  3523. // the format of the packet data is as follows:
  3524. //
  3525. #define DbgKdPrintTraceApi 0x00003330L
  3526. //
  3527. // For print trace, the trace buffer data
  3528. // immediately follows the message
  3529. //
  3530. typedef struct _DBGKD_PRINT_TRACE {
  3531. ULONG LengthOfData;
  3532. } DBGKD_PRINT_TRACE, *PDBGKD_PRINT_TRACE;
  3533. typedef struct _DBGKD_TRACE_IO {
  3534. ULONG ApiNumber;
  3535. USHORT ProcessorLevel;
  3536. USHORT Processor;
  3537. union {
  3538. ULONG64 ReserveSpace[7];
  3539. DBGKD_PRINT_TRACE PrintTrace;
  3540. } u;
  3541. } DBGKD_TRACE_IO, *PDBGKD_TRACE_IO;
  3542. //
  3543. // If the packet type is PACKET_TYPE_KD_CONTROL_REQUEST, then
  3544. // the format of the packet data is as follows:
  3545. //
  3546. #define DbgKdRequestHardwareBp 0x00004300L
  3547. #define DbgKdReleaseHardwareBp 0x00004301L
  3548. typedef struct _DBGKD_REQUEST_BREAKPOINT {
  3549. ULONG HardwareBreakPointNumber;
  3550. ULONG Available;
  3551. } DBGKD_REQUEST_BREAKPOINT, *PDBGKD_REQUEST_BREAKPOINT;
  3552. typedef struct _DBGKD_RELEASE_BREAKPOINT {
  3553. ULONG HardwareBreakPointNumber;
  3554. ULONG Released;
  3555. } DBGKD_RELEASE_BREAKPOINT, *PDBGKD_RELEASE_BREAKPOINT;
  3556. typedef struct _DBGKD_CONTROL_REQUEST {
  3557. ULONG ApiNumber;
  3558. union {
  3559. DBGKD_REQUEST_BREAKPOINT RequestBreakpoint;
  3560. DBGKD_RELEASE_BREAKPOINT ReleaseBreakpoint;
  3561. } u;
  3562. } DBGKD_CONTROL_REQUEST, *PDBGKD_CONTROL_REQUEST;
  3563. //
  3564. // If the packet type is PACKET_TYPE_KD_FILE_IO, then
  3565. // the format of the packet data is as follows:
  3566. //
  3567. #define DbgKdCreateFileApi 0x00003430L
  3568. #define DbgKdReadFileApi 0x00003431L
  3569. #define DbgKdWriteFileApi 0x00003432L
  3570. #define DbgKdCloseFileApi 0x00003433L
  3571. // Unicode filename follows as additional data.
  3572. typedef struct _DBGKD_CREATE_FILE {
  3573. ULONG DesiredAccess;
  3574. ULONG FileAttributes;
  3575. ULONG ShareAccess;
  3576. ULONG CreateDisposition;
  3577. ULONG CreateOptions;
  3578. // Return values.
  3579. ULONG64 Handle;
  3580. ULONG64 Length;
  3581. } DBGKD_CREATE_FILE, *PDBGKD_CREATE_FILE;
  3582. // Data is returned as additional data in the response.
  3583. typedef struct _DBGKD_READ_FILE {
  3584. ULONG64 Handle;
  3585. ULONG64 Offset;
  3586. ULONG Length;
  3587. } DBGKD_READ_FILE, *PDBGKD_READ_FILE;
  3588. // Data is given as additional data.
  3589. typedef struct _DBGKD_WRITE_FILE {
  3590. ULONG64 Handle;
  3591. ULONG64 Offset;
  3592. ULONG Length;
  3593. } DBGKD_WRITE_FILE, *PDBGKD_WRITE_FILE;
  3594. typedef struct _DBGKD_CLOSE_FILE {
  3595. ULONG64 Handle;
  3596. } DBGKD_CLOSE_FILE, *PDBGKD_CLOSE_FILE;
  3597. typedef struct _DBGKD_FILE_IO {
  3598. ULONG ApiNumber;
  3599. NTSTATUS Status;
  3600. union {
  3601. ULONG64 ReserveSpace[7];
  3602. DBGKD_CREATE_FILE CreateFile;
  3603. DBGKD_READ_FILE ReadFile;
  3604. DBGKD_WRITE_FILE WriteFile;
  3605. DBGKD_CLOSE_FILE CloseFile;
  3606. } u;
  3607. } DBGKD_FILE_IO, *PDBGKD_FILE_IO;
  3608. //
  3609. // Define debug object access types. No security is present on this object.
  3610. //
  3611. #define DEBUG_READ_EVENT (0x0001)
  3612. #define DEBUG_PROCESS_ASSIGN (0x0002)
  3613. #define DEBUG_SET_INFORMATION (0x0004)
  3614. #define DEBUG_QUERY_INFORMATION (0x0008)
  3615. #define DEBUG_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|DEBUG_READ_EVENT|DEBUG_PROCESS_ASSIGN|\
  3616. DEBUG_SET_INFORMATION|DEBUG_QUERY_INFORMATION)
  3617. #define DEBUG_KILL_ON_CLOSE (0x1) // Kill all debuggees on last handle close
  3618. typedef enum _DEBUGOBJECTINFOCLASS {
  3619. DebugObjectFlags = 1,
  3620. MaxDebugObjectInfoClass
  3621. } DEBUGOBJECTINFOCLASS, *PDEBUGOBJECTINFOCLASS;
  3622. NTSTATUS
  3623. NtRemoveProcessDebug (
  3624. IN HANDLE ProcessHandle,
  3625. IN HANDLE DebugObjectHandle
  3626. );
  3627. NTSTATUS
  3628. NtWaitForDebugEvent (
  3629. IN HANDLE DebugObjectHandle,
  3630. IN BOOLEAN Alertable,
  3631. IN PLARGE_INTEGER Timeout OPTIONAL,
  3632. OUT PDBGUI_WAIT_STATE_CHANGE WaitStateChange
  3633. );
  3634. NTSTATUS
  3635. NtDebugContinue (
  3636. IN HANDLE DebugObjectHandle,
  3637. IN PCLIENT_ID ClientId,
  3638. IN NTSTATUS ContinueStatus
  3639. );
  3640. NTSTATUS
  3641. NtCreateDebugObject (
  3642. OUT PHANDLE DebugObjectHandle,
  3643. IN ACCESS_MASK DesiredAccess,
  3644. IN POBJECT_ATTRIBUTES ObjectAttributes,
  3645. IN ULONG Flags
  3646. );
  3647. NTSTATUS
  3648. NtDebugActiveProcess (
  3649. IN HANDLE ProcessHandle,
  3650. IN HANDLE DebugObjectHandle
  3651. );
  3652. NTSTATUS
  3653. NtSetInformationDebugObject (
  3654. IN HANDLE DebugObjectHandle,
  3655. IN DEBUGOBJECTINFOCLASS DebugObjectInformationClass,
  3656. IN PVOID DebugInformation,
  3657. IN ULONG DebugInformationLength,
  3658. OUT PULONG ReturnLength OPTIONAL
  3659. );
  3660. #ifdef __cplusplus
  3661. }
  3662. #endif
  3663. #endif // _NTDBG_