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

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