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.

971 lines
18 KiB

  1. /*++
  2. Copyright (c) 1993-1999 Microsoft Corporation
  3. Module Name:
  4. precomp.h
  5. Abstract:
  6. This header file is used to cause the correct machine/platform specific
  7. data structures to be used when compiling for a non-hosted platform.
  8. --*/
  9. #include <nt.h>
  10. #include <ntrtl.h>
  11. #include <nturtl.h>
  12. #include <windows.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. // This is a 64 bit aware debugger extension
  17. #define KDEXT_64BIT
  18. #include <wdbgexts.h>
  19. #include <dbgeng.h>
  20. #include "extsfns.h"
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. //
  25. // undef the wdbgexts
  26. //
  27. #undef DECLARE_API
  28. #define DECLARE_API(extension) \
  29. CPPMOD HRESULT CALLBACK extension(PDEBUG_CLIENT Client, PCSTR args)
  30. #ifndef EXTENSION_API
  31. #define EXTENSION_API( name ) \
  32. HRESULT _EFN_##name
  33. #endif // EXTENSION_API
  34. #define INIT_API() \
  35. HRESULT Status; \
  36. if ((Status = ExtQuery(Client)) != S_OK) return Status;
  37. #define EXIT_API ExtRelease
  38. // Safe release and NULL.
  39. #define EXT_RELEASE(Unk) \
  40. ((Unk) != NULL ? ((Unk)->Release(), (Unk) = NULL) : NULL)
  41. // Global variables initialized by query.
  42. extern PDEBUG_ADVANCED g_ExtAdvanced;
  43. extern PDEBUG_CLIENT g_ExtClient;
  44. extern PDEBUG_CONTROL2 g_ExtControl;
  45. extern PDEBUG_DATA_SPACES g_ExtData;
  46. extern PDEBUG_REGISTERS g_ExtRegisters;
  47. extern PDEBUG_SYMBOLS2 g_ExtSymbols;
  48. extern PDEBUG_SYSTEM_OBJECTS g_ExtSystem;
  49. extern ULONG64 STeip;
  50. extern ULONG64 STebp;
  51. extern ULONG64 STesp;
  52. extern ULONG64 EXPRLastDump;
  53. HRESULT
  54. ExtQuery(PDEBUG_CLIENT Client);
  55. void
  56. ExtRelease(void);
  57. #ifdef DEFINE_GUID
  58. #undef DEFINE_GUID
  59. #endif
  60. #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  61. EXTERN_C const GUID DECLSPEC_SELECTANY name \
  62. = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
  63. //
  64. // Flag definitions used by extensions
  65. //
  66. #include "extflags.h"
  67. #define ADDRESS_NOT_VALID 0
  68. #define ADDRESS_VALID 1
  69. #define ADDRESS_TRANSITION 2
  70. //#define POOL_TYPE_AND_QUOTA_MASK (15)
  71. #define MAXULONG64_PTR (~((ULONG64)0))
  72. #define MAXLONG64_PTR ((LONG64)(MAXULONG64_PTR >> 1))
  73. #define MINLONG64_PTR (~MAXLONG64_PTR)
  74. #define POOL_BIG_TABLE_ENTRY_FREE 0x1
  75. //
  76. // macros to crack the ControllerId field of the socket info structure
  77. //
  78. #define PcmciaClassFromControllerType(type) (((type) & 0xff))
  79. #define PcmciaModelFromControllerType(type) (((type) >> 8) & 0x3ffff)
  80. #define PcmciaRevisionFromControllerType(type) ((type) >> 26)
  81. #ifdef PAGE_SIZE
  82. #undef PAGE_SIZE
  83. #endif
  84. #define DBG_PTR_SIZE (IsPtr64() ? 8 : 4)
  85. extern ULONG PageSize;
  86. extern ULONG BuildNo;
  87. extern ULONG PoolBlockShift;
  88. extern BOOL NewPool;
  89. #define _KB (PageSize/1024)
  90. #define POOL_BLOCK_SHIFT_OLD ((PageSize == 0x4000) ? 6 : (((PageSize == 0x2000) || ((BuildNo < 2257) && (PageSize == 0x1000))) ? 5 : 4))
  91. #define POOL_BLOCK_SHIFT_LAB1_2402 ((PageSize == 0x4000) ? 5 : (((PageSize == 0x2000)) ? 4 : 3))
  92. #define POOL_BLOCK_SHIFT PoolBlockShift
  93. #define PAGE_ALIGN64(Va) ((ULONG64)((Va) & ~((ULONG64) (PageSize - 1))))
  94. #define GetBits(from, pos, num) ((from >> pos) & (((ULONG64) ~0) >> (sizeof(ULONG64)*8 - num)))
  95. extern ULONG64 PaeEnabled;
  96. extern ULONG TargetMachine;
  97. extern ULONG TargetIsDump;
  98. //-----------------------------------------------------------------------------------------
  99. //
  100. // api declaration macros & api access macros
  101. //
  102. //-----------------------------------------------------------------------------------------
  103. extern WINDBG_EXTENSION_APIS ExtensionApis;
  104. __inline
  105. ULONG64
  106. KD_OBJECT_TO_OBJECT_HEADER(
  107. ULONG64 o
  108. )
  109. {
  110. static ULONG Off=0, GotOff=0;
  111. if (!GotOff &&
  112. !GetFieldOffset("nt!_OBJECT_HEADER", "Body", &Off)) {
  113. GotOff = TRUE;
  114. } else if (!GotOff){
  115. return 0;
  116. }
  117. return o - Off;
  118. }
  119. __inline
  120. ULONG64
  121. KD_OBJECT_HEADER_TO_OBJECT(
  122. ULONG64 o
  123. )
  124. {
  125. static ULONG Off=0, GotOff=0;
  126. if (!GotOff &&
  127. !GetFieldOffset("nt!_OBJECT_HEADER", "Body", &Off)) {
  128. GotOff = TRUE;
  129. } else if (!GotOff){
  130. return 0;
  131. }
  132. return o + Off;
  133. }
  134. __inline
  135. VOID
  136. KD_OBJECT_HEADER_TO_QUOTA_INFO(
  137. ULONG64 oh,
  138. PULONG64 pOutH
  139. )
  140. {
  141. ULONG QuotaInfoOffset=0;
  142. GetFieldValue(oh, "nt!_OBJECT_HEADER", "QuotaInfoOffset", QuotaInfoOffset);
  143. *pOutH = (QuotaInfoOffset == 0 ? 0 : ((oh) - QuotaInfoOffset));
  144. }
  145. __inline
  146. VOID
  147. KD_OBJECT_HEADER_TO_HANDLE_INFO (
  148. ULONG64 oh,
  149. PULONG64 pOutH
  150. )
  151. {
  152. ULONG HandleInfoOffset=0;
  153. GetFieldValue(oh, "nt!_OBJECT_HEADER", "HandleInfoOffset", HandleInfoOffset);
  154. *pOutH = (HandleInfoOffset == 0 ? 0 : ((oh) - HandleInfoOffset));
  155. }
  156. __inline
  157. VOID
  158. KD_OBJECT_HEADER_TO_NAME_INFO(
  159. ULONG64 oh,
  160. PULONG64 pOutH
  161. )
  162. {
  163. ULONG NameInfoOffset=0;
  164. GetFieldValue(oh, "nt!_OBJECT_HEADER", "NameInfoOffset", NameInfoOffset);
  165. *pOutH = (NameInfoOffset == 0 ? 0 : ((oh) - NameInfoOffset));
  166. }
  167. __inline
  168. VOID
  169. KD_OBJECT_HEADER_TO_CREATOR_INFO(
  170. ULONG64 oh,
  171. PULONG64 pOutH
  172. )
  173. {
  174. ULONG Flags=0;
  175. GetFieldValue(oh, "_OBJECT_HEADER", "Flags", Flags);
  176. *pOutH = ((Flags & OB_FLAG_CREATOR_INFO) == 0 ? 0 : ((oh) - GetTypeSize("_OBJECT_HEADER_CREATOR_INFO")));
  177. }
  178. //-----------------------------------------------------------------------------------------
  179. //
  180. // prototypes for internal non-exported support functions
  181. //
  182. //-----------------------------------------------------------------------------------------
  183. //
  184. // get data from DebuggerData or GetExpression as appropriate
  185. //
  186. char ___SillyString[];
  187. extern KDDEBUGGER_DATA64 KdDebuggerData;
  188. #define GetNtDebuggerData(NAME) \
  189. (HaveDebuggerData()? (GetDebuggerData(KDBG_TAG, \
  190. &KdDebuggerData, \
  191. sizeof(KdDebuggerData)), \
  192. KdDebuggerData.NAME): \
  193. GetExpression( (strcpy(___SillyString, #NAME), ___SillyString) ))
  194. #define GetNtDebuggerDataValue(NAME) \
  195. (HaveDebuggerData()? \
  196. GetUlongFromAddress((GetDebuggerData(KDBG_TAG, \
  197. &KdDebuggerData, \
  198. sizeof(KdDebuggerData)), \
  199. KdDebuggerData.NAME) \
  200. ): \
  201. GetUlongValue( (strcpy(___SillyString, #NAME), ___SillyString) ))
  202. //
  203. // This is used to read pointer values from address.
  204. //
  205. #define GetNtDebuggerDataPtrValue(NAME) \
  206. (HaveDebuggerData()? \
  207. GetPointerFromAddress((GetDebuggerData(KDBG_TAG, \
  208. &KdDebuggerData, \
  209. sizeof(KdDebuggerData)), \
  210. KdDebuggerData.NAME) \
  211. ): \
  212. GetPointerValue( (strcpy(___SillyString, #NAME), ___SillyString) ))
  213. typedef enum _MODE {
  214. KernelMode,
  215. UserMode,
  216. MaximumMode
  217. } MODE;
  218. extern BOOL
  219. HaveDebuggerData(
  220. VOID
  221. );
  222. BOOL
  223. ReadPcr(
  224. USHORT Processor,
  225. PVOID Pcr,
  226. PULONG AddressOfPcr,
  227. HANDLE hThread
  228. );
  229. ULONG
  230. GetUlongFromAddress (
  231. ULONG64 Location
  232. );
  233. ULONG
  234. GetUlongValue (
  235. PCHAR String
  236. );
  237. ULONG64
  238. GetGlobalFromAddress (
  239. ULONG64 Location,
  240. ULONG Size
  241. );
  242. ULONG64
  243. GetGlobalValue (
  244. PCHAR String
  245. );
  246. HRESULT
  247. GetGlobalEx(
  248. PCHAR String,
  249. PVOID OutValue,
  250. ULONG OutSize
  251. );
  252. #define GetGlobal( _String, _OutValue ) \
  253. GetGlobalEx( (_String), &(_OutValue), sizeof(_OutValue) )
  254. BOOLEAN
  255. ReadMemoryUncached (
  256. ULONG64 Offset,
  257. PVOID Buffer,
  258. ULONG BufferSize,
  259. PULONG BytesRead
  260. );
  261. BOOLEAN
  262. WriteMemoryUncached (
  263. ULONG64 Offset,
  264. PVOID Buffer,
  265. ULONG BufferSize,
  266. PULONG BytesWritten
  267. );
  268. /////////////////////////////////////////////
  269. //
  270. // KdExts.c
  271. //
  272. /////////////////////////////////////////////
  273. BOOL
  274. GetCurrentProcessor(
  275. IN PDEBUG_CLIENT Client,
  276. OPTIONAL OUT PULONG pProcessor,
  277. OPTIONAL OUT PHANDLE phCurrentThread
  278. );
  279. HRESULT
  280. ExecuteCommand(
  281. IN PDEBUG_CLIENT Client,
  282. IN PSTR Command
  283. );
  284. HRESULT
  285. GetExtensionFunction(
  286. IN PCSTR FunctionName,
  287. IN FARPROC *Function
  288. );
  289. /////////////////////////////////////////////
  290. //
  291. // CritSec.c
  292. //
  293. /////////////////////////////////////////////
  294. PLIST_ENTRY
  295. DumpCritSec(
  296. HANDLE hCurrentProcess,
  297. DWORD dwAddrCritSec,
  298. BOOLEAN bDumpIfUnowned
  299. );
  300. /////////////////////////////////////////////
  301. //
  302. // Device.c
  303. //
  304. /////////////////////////////////////////////
  305. VOID
  306. DumpDevice(
  307. ULONG64 DeviceAddress,
  308. ULONG FieldWidth,
  309. BOOLEAN FullDetail
  310. );
  311. HRESULT
  312. GetDevObjInfo(
  313. IN ULONG64 DeviceObject,
  314. OUT PDEBUG_DEVICE_OBJECT_INFO pDevObjInfo
  315. );
  316. /////////////////////////////////////////////
  317. //
  318. // Devnode.c
  319. //
  320. /////////////////////////////////////////////
  321. typedef struct _FLAG_NAME {
  322. ULONG Flag;
  323. PUCHAR Name;
  324. } FLAG_NAME, *PFLAG_NAME;
  325. VOID
  326. DumpDeviceCapabilities(
  327. ULONG64 caps
  328. );
  329. VOID
  330. DumpFlags(
  331. ULONG Depth,
  332. LPSTR FlagDescription,
  333. ULONG Flags,
  334. PFLAG_NAME FlagTable
  335. );
  336. VOID
  337. xdprintf(
  338. ULONG Depth,
  339. PCHAR S,
  340. ...
  341. );
  342. BOOLEAN
  343. xReadMemory (
  344. ULONG64 S,
  345. PVOID D,
  346. ULONG Len
  347. );
  348. /////////////////////////////////////////////
  349. //
  350. // Driver.c
  351. //
  352. /////////////////////////////////////////////
  353. VOID
  354. DumpDriver(
  355. ULONG64 DriverAddress,
  356. ULONG FieldWidth,
  357. ULONG Flags
  358. );
  359. HRESULT
  360. GetDrvObjInfo(
  361. IN ULONG64 DriverObject,
  362. OUT PDEBUG_DRIVER_OBJECT_INFO pDrvObjInfo);
  363. /////////////////////////////////////////////
  364. //
  365. // irp.c
  366. //
  367. /////////////////////////////////////////////
  368. HRESULT
  369. GetIrpInfo(
  370. ULONG64 Irp,
  371. PDEBUG_IRP_INFO pIrp
  372. );
  373. /////////////////////////////////////////////
  374. //
  375. // lock.c
  376. //
  377. /////////////////////////////////////////////
  378. VOID
  379. DumpStaticFastMutex (
  380. IN PCHAR Name
  381. );
  382. /////////////////////////////////////////////
  383. //
  384. // memory.c
  385. //
  386. /////////////////////////////////////////////
  387. VOID
  388. MemoryUsage (
  389. IN ULONG64 PfnStart,
  390. IN ULONG64 LowPage,
  391. IN ULONG64 HighPage,
  392. IN ULONG IgnoreInvalidFrames
  393. );
  394. /////////////////////////////////////////////
  395. //
  396. // Object.c
  397. //
  398. /////////////////////////////////////////////
  399. extern ULONG64 EXPRLastDump;
  400. typedef enum _POOL_TYPE {
  401. NonPagedPool,
  402. PagedPool,
  403. NonPagedPoolMustSucceed,
  404. DontUseThisType,
  405. NonPagedPoolCacheAligned,
  406. PagedPoolCacheAligned,
  407. NonPagedPoolCacheAlignedMustS,
  408. MaxPoolType
  409. // end_wdm
  410. ,
  411. //
  412. // Note these per session types are carefully chosen so that the appropriate
  413. // masking still applies as well as MaxPoolType above.
  414. //
  415. NonPagedPoolSession = 32,
  416. PagedPoolSession = NonPagedPoolSession + 1,
  417. NonPagedPoolMustSucceedSession = PagedPoolSession + 1,
  418. DontUseThisTypeSession = NonPagedPoolMustSucceedSession + 1,
  419. NonPagedPoolCacheAlignedSession = DontUseThisTypeSession + 1,
  420. PagedPoolCacheAlignedSession = NonPagedPoolCacheAlignedSession + 1,
  421. NonPagedPoolCacheAlignedMustSSession = PagedPoolCacheAlignedSession + 1,
  422. // begin_wdm
  423. } POOL_TYPE;
  424. typedef BOOLEAN (*ENUM_TYPE_ROUTINE)(
  425. IN ULONG64 pObjectHeader,
  426. IN PVOID Parameter
  427. );
  428. //
  429. // Object Table Entry Structure
  430. //
  431. typedef struct _OBJECT_TABLE_ENTRY {
  432. ULONG NonPagedObjectHeader;
  433. ACCESS_MASK GrantedAccess;
  434. } OBJECT_TABLE_ENTRY, *POBJECT_TABLE_ENTRY;
  435. #define LOG_OBJECT_TABLE_ENTRY_SIZE 1
  436. BOOLEAN
  437. FetchObjectManagerVariables(
  438. BOOLEAN ForceReload
  439. );
  440. ULONG64
  441. FindObjectByName(
  442. IN PUCHAR Path,
  443. IN ULONG64 RootObject
  444. );
  445. ULONG64
  446. FindObjectType(
  447. IN PUCHAR TypeName
  448. );
  449. BOOLEAN
  450. DumpObject(
  451. IN char *Pad,
  452. IN ULONG64 Object,
  453. // IN POBJECT_HEADER OptObjectHeader OPTIONAL,
  454. IN ULONG Flags
  455. );
  456. BOOLEAN
  457. WalkObjectsByType(
  458. IN PUCHAR ObjectTypeName,
  459. IN ENUM_TYPE_ROUTINE EnumRoutine,
  460. IN PVOID Parameter
  461. );
  462. BOOLEAN
  463. CaptureObjectName(
  464. IN ULONG64 pObjectHeader,
  465. // IN POBJECT_HEADER ObjectHeader,
  466. IN PWSTR Buffer,
  467. IN ULONG BufferSize
  468. );
  469. VOID
  470. DumpObjectName(
  471. ULONG64 ObjectAddress
  472. );
  473. /////////////////////////////////////////////
  474. //
  475. // pcr.c
  476. //
  477. /////////////////////////////////////////////
  478. BOOL
  479. ReadTargetPcr (
  480. OUT PULONG64 PPcr,
  481. IN ULONG Processor
  482. );
  483. /////////////////////////////////////////////
  484. //
  485. // Pool.c
  486. //
  487. /////////////////////////////////////////////
  488. typedef
  489. BOOLEAN
  490. (WINAPI *POOLFILTER) (
  491. PCHAR Tag,
  492. PCHAR Filter,
  493. ULONG Flags,
  494. ULONG64 PoolHeader,
  495. ULONG BlockSize,
  496. ULONG64 Data,
  497. PVOID Context
  498. );
  499. void SearchPool(
  500. ULONG TagName,
  501. ULONG Flags,
  502. ULONG64 RestartAddr,
  503. POOLFILTER Filter,
  504. PVOID Context
  505. );
  506. BOOLEAN
  507. CheckSingleFilter (
  508. PCHAR Tag,
  509. PCHAR Filter
  510. );
  511. LOGICAL
  512. PoolInitializeGlobals(void);
  513. HRESULT
  514. ListPoolPage(
  515. ULONG64 PoolPageToDump,
  516. ULONG Flags,
  517. PDEBUG_POOL_DATA PoolData
  518. );
  519. PSTR
  520. GetPoolTagDescription(
  521. IN ULONG PoolTag
  522. );
  523. void
  524. PrintPoolRegion(
  525. ULONG64 Pool
  526. );
  527. /////////////////////////////////////////////
  528. //
  529. // Process.c
  530. //
  531. /////////////////////////////////////////////
  532. extern CHAR *WaitReasonList[];
  533. BOOL
  534. DumpProcess(
  535. IN char * pad,
  536. IN ULONG64 RealProcessBase,
  537. IN ULONG Flags,
  538. IN OPTIONAL PCHAR ImageFileName
  539. );
  540. BOOL
  541. DumpThread (
  542. IN ULONG Processor,
  543. IN char *Pad,
  544. IN ULONG64 RealThreadBase,
  545. IN ULONG64 Flags
  546. );
  547. BOOL
  548. DumpThreadEx (
  549. IN ULONG Processor,
  550. IN char *Pad,
  551. IN ULONG64 RealThreadBase,
  552. IN ULONG Flags,
  553. IN PDEBUG_CLIENT pDbgClient
  554. );
  555. VOID
  556. dumpSymbolicAddress(
  557. ULONG64 Address,
  558. PCHAR Buffer,
  559. BOOL AlwaysShowHex
  560. );
  561. BOOLEAN
  562. FetchProcessStructureVariables(
  563. VOID
  564. );
  565. ULONG
  566. GetAddressState(
  567. IN ULONG64 VirtualAddress
  568. );
  569. typedef struct _PROCESS_COMMIT_USAGE {
  570. UCHAR ImageFileName[ 16 ];
  571. ULONG64 ClientId;
  572. ULONG64 ProcessAddress;
  573. ULONG64 CommitCharge;
  574. ULONG64 NumberOfPrivatePages;
  575. ULONG64 NumberOfLockedPages;
  576. } PROCESS_COMMIT_USAGE, *PPROCESS_COMMIT_USAGE;
  577. PPROCESS_COMMIT_USAGE
  578. GetProcessCommit (
  579. PULONG64 TotalCommitCharge,
  580. PULONG NumberOfProcesses
  581. );
  582. VOID
  583. DumpMmThreads (
  584. VOID
  585. );
  586. /////////////////////////////////////////////
  587. //
  588. // pte.c
  589. //
  590. /////////////////////////////////////////////
  591. ULONG
  592. DbgGetValid(
  593. ULONG64 Pte
  594. );
  595. ULONG64
  596. DbgGetPdeAddress(
  597. IN ULONG64 VirtualAddress
  598. );
  599. ULONG64
  600. DbgGetPteAddress(
  601. IN ULONG64 VirtualAddress
  602. );
  603. ULONG64
  604. DbgGetFrameNumber(
  605. ULONG64 Pte
  606. );
  607. ULONG64
  608. DbgGetSubsectionAddress(
  609. IN ULONG64 Pte
  610. );
  611. ULONG64
  612. DbgGetVirtualAddressMappedByPte(
  613. IN ULONG64 Pte
  614. );
  615. /////////////////////////////////////////////
  616. //
  617. // Registry.c
  618. //
  619. /////////////////////////////////////////////
  620. USHORT
  621. GetKcbName(
  622. ULONG64 KcbAddr,
  623. PWCHAR NameBuffer,
  624. ULONG BufferSize
  625. );
  626. /////////////////////////////////////////////
  627. //
  628. // sel.c
  629. //
  630. /////////////////////////////////////////////
  631. // X86 only
  632. //
  633. // LDT descriptor entry
  634. //
  635. typedef struct _LDT_ENTRY_X86 {
  636. USHORT LimitLow;
  637. USHORT BaseLow;
  638. union {
  639. struct {
  640. UCHAR BaseMid;
  641. UCHAR Flags1; // Declare as bytes to avoid alignment
  642. UCHAR Flags2; // Problems.
  643. UCHAR BaseHi;
  644. } Bytes;
  645. struct {
  646. ULONG BaseMid : 8;
  647. ULONG Type : 5;
  648. ULONG Dpl : 2;
  649. ULONG Pres : 1;
  650. ULONG LimitHi : 4;
  651. ULONG Sys : 1;
  652. ULONG Reserved_0 : 1;
  653. ULONG Default_Big : 1;
  654. ULONG Granularity : 1;
  655. ULONG BaseHi : 8;
  656. } Bits;
  657. } HighWord;
  658. } LDT_ENTRY_X86, *PLDT_ENTRY_X86;
  659. typedef struct _DESCRIPTOR_TABLE_ENTRY_X86 {
  660. ULONG Selector;
  661. LDT_ENTRY_X86 Descriptor;
  662. } DESCRIPTOR_TABLE_ENTRY_X86, *PDESCRIPTOR_TABLE_ENTRY_X86;
  663. NTSTATUS
  664. LookupSelector(
  665. IN USHORT Processor,
  666. IN OUT PDESCRIPTOR_TABLE_ENTRY_X86 pDescriptorTableEntry
  667. );
  668. /////////////////////////////////////////////
  669. //
  670. // trap.cpp
  671. //
  672. /////////////////////////////////////////////
  673. // IA64 only
  674. typedef enum _DISPLAY_MODE {
  675. DISPLAY_MIN = 0,
  676. DISPLAY_DEFAULT = DISPLAY_MIN,
  677. DISPLAY_MED = 1,
  678. DISPLAY_MAX = 2,
  679. DISPLAY_FULL = DISPLAY_MAX
  680. } DISPLAY_MODE;
  681. typedef struct _EM_REG_FIELD {
  682. const char *SubName;
  683. const char *Name;
  684. unsigned long Length;
  685. unsigned long Shift;
  686. } EM_REG_FIELD, *PEM_REG_FIELD;
  687. VOID
  688. DisplayFullEmRegField(
  689. ULONG64 EmRegValue,
  690. EM_REG_FIELD EmRegFields[],
  691. ULONG Field
  692. );
  693. VOID
  694. DisplayFullEmReg(
  695. IN ULONG64 Val,
  696. IN EM_REG_FIELD EmRegFields[],
  697. IN DISPLAY_MODE DisplayMode
  698. );
  699. /////////////////////////////////////////////
  700. //
  701. // Util.c
  702. //
  703. /////////////////////////////////////////////
  704. typedef VOID
  705. (*PDUMP_SPLAY_NODE_FN)(
  706. ULONG64 RemoteAddress,
  707. ULONG Level
  708. );
  709. ULONG
  710. DumpSplayTree(
  711. IN ULONG64 pSplayLinks,
  712. IN PDUMP_SPLAY_NODE_FN DumpNodeFn
  713. );
  714. BOOLEAN
  715. DbgRtlIsRightChild(
  716. ULONG64 pLinks,
  717. ULONG64 Parent
  718. );
  719. BOOLEAN
  720. DbgRtlIsLeftChild(
  721. ULONG64 pLinks,
  722. ULONG64 Parent
  723. );
  724. ULONG
  725. GetBitFieldOffset (
  726. IN LPSTR Type,
  727. IN LPSTR Field,
  728. OUT PULONG pOffset,
  729. OUT PULONG pSize
  730. );
  731. ULONG
  732. GetFieldOffsetEx ( // returns Offset and Size...
  733. IN LPSTR Type,
  734. IN LPSTR Field,
  735. OUT PULONG pOffset,
  736. OUT PULONG pSize
  737. );
  738. ULONG64
  739. GetPointerFromAddress (
  740. ULONG64 Location
  741. );
  742. VOID
  743. DumpUnicode(
  744. UNICODE_STRING u
  745. );
  746. VOID
  747. DumpUnicode64(
  748. UNICODE_STRING64 u
  749. );
  750. ULONG64
  751. GetPointerValue (
  752. PCHAR String
  753. );
  754. BOOLEAN
  755. IsHexNumber(
  756. const char *szExpression
  757. );
  758. BOOLEAN
  759. IsDecNumber(
  760. const char *szExpression
  761. );
  762. BOOLEAN
  763. CheckSingleFilter (
  764. PCHAR Tag,
  765. PCHAR Filter
  766. );
  767. ULONG64
  768. UtilStringToUlong64 (
  769. UCHAR *String
  770. );
  771. #define ENUM_NAME(val) {val, #val}
  772. typedef struct _ENUM_NAME {
  773. ULONG EnumVal;
  774. const char * Name;
  775. } ENUM_NAME, *PENUM_NAME;
  776. const char *
  777. getEnumName(
  778. ULONG EnumVal,
  779. PENUM_NAME EnumTable
  780. );
  781. #ifdef __cplusplus
  782. }
  783. #endif