Source code of Windows XP (NT5)
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.

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