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.

156 lines
4.3 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. regleaks.hxx
  5. Abstract:
  6. Common stuff for CS debugger extensions
  7. Author:
  8. UShaji (Adapted from rpc extensions, MarioGo, MazharM, JRoberts)
  9. --*/
  10. #ifndef _REGLEAKS_HXX_
  11. #define _REGLEAKS_HXX_
  12. #define MY_DECLARE_API(_x_) \
  13. DECLARE_API( _x_ ) \
  14. { \
  15. DWORD dwAddr; \
  16. INIT_DPRINTF(); \
  17. dwAddr = GetExpression(lpArgumentString); \
  18. if ( !dwAddr ) { \
  19. dprintf("Error: Failure to get address\n"); \
  20. return; \
  21. } \
  22. do_##_x_(dwAddr); \
  23. return;} \
  24. extern
  25. WCHAR *
  26. ReadProcessChar(
  27. unsigned short * Address
  28. );
  29. extern
  30. PCHAR
  31. MapSymbol(DWORD);
  32. #define READ(addr, buffer, length) \
  33. b = GetData((addr),(buffer),(length), NULL); \
  34. if (!b) { \
  35. dprintf("Failed to read address %d, %d bytes", (addr), (length)); \
  36. return; \
  37. } \
  38. extern HANDLE ProcessHandle;
  39. extern BOOL fKernelDebug;
  40. #undef DECLARE_API
  41. #define DECLARE_API(s) \
  42. VOID \
  43. s( \
  44. HANDLE hCurrentProcess, \
  45. HANDLE hCurrentThread, \
  46. DWORD dwCurrentPc, \
  47. PWINDBG_EXTENSION_APIS pExtensionApis, \
  48. LPSTR lpArgumentString \
  49. )
  50. //
  51. // types
  52. //
  53. typedef BOOL (*UEnvReadMemory)( HANDLE, const void*, void*, DWORD, DWORD* );
  54. typedef BOOL (*UEnvWriteMemory)( HANDLE, void*, void*, DWORD, DWORD* );
  55. //
  56. // forwards
  57. //
  58. BOOL
  59. ReadMemoryUserMode( HANDLE hProcess, const void* pAddress, void* pBuffer, DWORD dwSize, DWORD* pdwRead );
  60. BOOL
  61. ReadMemoryKernelMode( HANDLE hProcess, const void* pAddress, void* pBuffer, DWORD dwSize, DWORD* pdwRead );
  62. BOOL
  63. WriteMemoryUserMode( HANDLE hProcess, const void* pAddress, void* pBuffer, DWORD dwSize, DWORD* pdwRead );
  64. BOOL
  65. WriteMemoryKernelMode( HANDLE hProcess, const void* pAddress, void* pBuffer, DWORD dwSize, DWORD* pdwRead );
  66. extern UEnvReadMemory ReadMemoryExt;
  67. extern UEnvReadMemory WriteMemoryExt;
  68. #define INIT_DPRINTF() { if (!fKernelDebug) \
  69. { \
  70. ExtensionApis = *pExtensionApis; \
  71. ReadMemoryExt = ReadMemoryUserMode; \
  72. WriteMemoryExt = WriteMemoryUserMode; \
  73. } \
  74. ProcessHandle = hCurrentProcess; \
  75. } \
  76. extern WINDBG_EXTENSION_APIS ExtensionApis;
  77. #define MIN(x, y) ((x) < (y)) ? x:y
  78. extern
  79. BOOL
  80. GetData(IN DWORD dwAddress, IN LPVOID ptr, IN ULONG size, IN PCSTR type );
  81. #define MAX_SYMBOL_LENGTH (sizeof( IMAGEHLP_SYMBOL ) + 256)
  82. typedef struct _TrackObjectData
  83. {
  84. LIST_ENTRY Links;
  85. HKEY hKey;
  86. DWORD dwStackDepth;
  87. PVOID* rgStack;
  88. } TrackObjectData;
  89. enum
  90. {
  91. LEAK_TRACK_FLAG_NONE = 0,
  92. LEAK_TRACK_FLAG_USER = 1,
  93. LEAK_TRACK_FLAG_ALL = 0xFFFFFFFF
  94. };
  95. typedef struct _RegLeakTable
  96. {
  97. TrackObjectData* pHead;
  98. DWORD cKeys;
  99. DWORD dwFlags;
  100. BOOL bCriticalSectionInitialized;
  101. RTL_CRITICAL_SECTION CriticalSection;
  102. } RegLeakTable;
  103. void TrackObjectDataPrint(TrackObjectData* pKeyData);
  104. void RegLeakTableDump(RegLeakTable* pLeakTable);
  105. NTSTATUS PrintObjectInfo(HANDLE Handle);
  106. /*
  107. void GetSymbolForFrame(
  108. PVOID pAddress,
  109. PUCHAR pchBuffer,
  110. DWORD_PTR *pDisplacement
  111. );*/
  112. #endif