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.

179 lines
5.5 KiB

  1. /*++
  2. Copyright (C) 1999-2001 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. History:
  6. --*/
  7. #include <windows.h>
  8. #include <stdio.h>
  9. #include <string.h>
  10. class CWinMgmtDebugSignal
  11. {
  12. public:
  13. enum { H_ENABLE_LEAK_TRACKING = 0,
  14. H_DISABLE_LEAK_TRACKING = 1,
  15. H_RESET_LEAK_TRACKING = 2,
  16. H_DUMP_LEAK_TRACKING = 3,
  17. H_FAIL_ALLOCATOR = 4,
  18. H_RESTORE_ALLOCATOR = 5,
  19. H_FAIL_NEXT_ALLOC = 6,
  20. H_ENABLE_EXCEPTION_TRACKING = 7,
  21. H_DISABLE_EXCEPTION_TRACKING = 8,
  22. H_DEBUG_BREAK = 9,
  23. H_ENABLE_OBJECT_VALIDATION = 10,
  24. H_DISABLE_OBJECT_VALIDATION = 11,
  25. H_LAST
  26. };
  27. static void Init();
  28. static HANDLE m_hArray[H_LAST];
  29. };
  30. HANDLE CWinMgmtDebugSignal::m_hArray[H_LAST] = {0};
  31. void CWinMgmtDebugSignal::Init()
  32. {
  33. // Set up the IPC signals.
  34. // =======================
  35. m_hArray[H_ENABLE_LEAK_TRACKING] =
  36. OpenEventW(EVENT_ALL_ACCESS, FALSE, L"EVENT_WINMGMT_ENABLE_LEAK_TRACKING");
  37. m_hArray[H_DISABLE_LEAK_TRACKING] =
  38. OpenEventW(EVENT_ALL_ACCESS, FALSE, L"EVENT_WINMGMT_DISABLE_LEAK_TRACKING");
  39. m_hArray[H_RESET_LEAK_TRACKING] =
  40. OpenEventW(EVENT_ALL_ACCESS, FALSE, L"EVENT_WINMGMT_RESET_LEAK_TRACKING");
  41. m_hArray[H_DUMP_LEAK_TRACKING] =
  42. OpenEventW(EVENT_ALL_ACCESS, FALSE, L"EVENT_WINMGMT_DUMP_LEAK_TRACKING");
  43. m_hArray[H_FAIL_ALLOCATOR] =
  44. OpenEventW(EVENT_ALL_ACCESS, FALSE, L"EVENT_WINMGMT_FAIL_ALLOCATOR");
  45. m_hArray[H_RESTORE_ALLOCATOR] =
  46. OpenEventW(EVENT_ALL_ACCESS, FALSE, L"EVENT_WINMGMT_RESTORE_ALLOCATOR");
  47. m_hArray[H_FAIL_NEXT_ALLOC] =
  48. OpenEventW(EVENT_ALL_ACCESS, FALSE, L"EVENT_WINMGMT_FAIL_NEXT_ALLOCATION");
  49. m_hArray[H_ENABLE_EXCEPTION_TRACKING] =
  50. OpenEventW(EVENT_ALL_ACCESS, FALSE, L"EVENT_WINMGMT_ENABLE_EXCEPTION_TRACKING");
  51. m_hArray[H_DISABLE_EXCEPTION_TRACKING] =
  52. OpenEventW(EVENT_ALL_ACCESS, FALSE, L"EVENT_WINMGMT_DISABLE_EXCEPTION_TRACKING");
  53. m_hArray[H_DEBUG_BREAK] =
  54. OpenEventW(EVENT_ALL_ACCESS, FALSE, L"EVENT_WINMGMT_DEBUG_BREAK");
  55. m_hArray[H_ENABLE_OBJECT_VALIDATION] =
  56. OpenEventW(EVENT_ALL_ACCESS, FALSE, L"EVENT_WINMGMT_ENABLE_OBJECT_VALIDATION");
  57. m_hArray[H_DISABLE_OBJECT_VALIDATION] =
  58. OpenEventW(EVENT_ALL_ACCESS, FALSE, L"EVENT_WINMGMT_DISABLE_OBJECT_VALIDATION");
  59. }
  60. void main(int argc, char **argv)
  61. {
  62. CWinMgmtDebugSignal::Init();
  63. if (argc < 2)
  64. {
  65. printf(
  66. "\n\n* WinMgmt Debug Event Signaller [%s]\n\n"
  67. "Usage:\n"
  68. " /ENABLE_LEAK_TRACKING\n"
  69. " /DISABLE_LEAK_TRACKING\n"
  70. " /RESET_LEAK_TRACKING\n"
  71. " /DUMP_LEAK_TRACKING\n"
  72. " /FAIL_ALLOCATOR\n"
  73. " /RESTORE_ALLOCATOR\n"
  74. " /FAIL_NEXT_ALLOC\n"
  75. " /ENABLE_EXCEPTION_TRACKING\n"
  76. " /DISABLE_EXCEPTION_TRACKING\n"
  77. " /DEBUG_BREAK\n"
  78. " /ENABLE_OBJECT_VALIDATION\n"
  79. " /DISABLE_OBJECT_VALIDATION\n"
  80. "\n\n",
  81. __DATE__
  82. );
  83. return;
  84. }
  85. if (_stricmp(argv[1], "/ENABLE_LEAK_TRACKING") == 0)
  86. {
  87. SetEvent(CWinMgmtDebugSignal::m_hArray[CWinMgmtDebugSignal::H_ENABLE_LEAK_TRACKING]);
  88. printf("-> Enable Leak Tracking\n");
  89. }
  90. if (_stricmp(argv[1], "/DISABLE_LEAK_TRACKING") == 0)
  91. {
  92. SetEvent(CWinMgmtDebugSignal::m_hArray[CWinMgmtDebugSignal::H_DISABLE_LEAK_TRACKING]);
  93. printf("-> Disable Leak Tracking\n");
  94. }
  95. if (_stricmp(argv[1], "/RESET_LEAK_TRACKING") == 0)
  96. {
  97. SetEvent(CWinMgmtDebugSignal::m_hArray[CWinMgmtDebugSignal::H_RESET_LEAK_TRACKING]);
  98. printf("-> Reset Leak Tracking\n");
  99. }
  100. if (_stricmp(argv[1], "/DUMP_LEAK_TRACKING") == 0)
  101. {
  102. SetEvent(CWinMgmtDebugSignal::m_hArray[CWinMgmtDebugSignal::H_DUMP_LEAK_TRACKING]);
  103. printf("-> Dump Leak Tracking\n");
  104. }
  105. if (_stricmp(argv[1], "/FAIL_ALLOCATOR") == 0)
  106. {
  107. SetEvent(CWinMgmtDebugSignal::m_hArray[CWinMgmtDebugSignal::H_FAIL_ALLOCATOR]);
  108. printf("-> Fail Allocator\n");
  109. }
  110. if (_stricmp(argv[1], "/RESTORE_ALLOCATOR") == 0)
  111. {
  112. SetEvent(CWinMgmtDebugSignal::m_hArray[CWinMgmtDebugSignal::H_RESTORE_ALLOCATOR]);
  113. printf("-> Restore Allocator\n");
  114. }
  115. if (_stricmp(argv[1], "/FAIL_NEXT_ALLOC") == 0)
  116. {
  117. SetEvent(CWinMgmtDebugSignal::m_hArray[CWinMgmtDebugSignal::H_FAIL_NEXT_ALLOC]);
  118. printf("-> Fail Next Allocation\n");
  119. }
  120. if (_stricmp(argv[1], "/ENABLE_EXCEPTION_TRACKING") == 0)
  121. {
  122. SetEvent(CWinMgmtDebugSignal::m_hArray[CWinMgmtDebugSignal::H_ENABLE_EXCEPTION_TRACKING]);
  123. printf("-> Enable Exception Tracking\n");
  124. }
  125. if (_stricmp(argv[1], "/DISABLE_EXCEPTION_TRACKING") == 0)
  126. {
  127. SetEvent(CWinMgmtDebugSignal::m_hArray[CWinMgmtDebugSignal::H_DISABLE_EXCEPTION_TRACKING]);
  128. printf("-> Disable Exception Tracking\n");
  129. }
  130. if (_stricmp(argv[1], "/DEBUG_BREAK") == 0)
  131. {
  132. SetEvent(CWinMgmtDebugSignal::m_hArray[CWinMgmtDebugSignal::H_DEBUG_BREAK]);
  133. printf("-> Debug Break\n");
  134. }
  135. if (_stricmp(argv[1], "/ENABLE_OBJECT_VALIDATION") == 0)
  136. {
  137. SetEvent(CWinMgmtDebugSignal::m_hArray[CWinMgmtDebugSignal::H_ENABLE_OBJECT_VALIDATION]);
  138. printf("-> Enable Object Validation\n");
  139. }
  140. if (_stricmp(argv[1], "/DISABLE_OBJECT_VALIDATION") == 0)
  141. {
  142. SetEvent(CWinMgmtDebugSignal::m_hArray[CWinMgmtDebugSignal::H_DISABLE_OBJECT_VALIDATION]);
  143. printf("-> Disable Object Validation\n");
  144. }
  145. }