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.

176 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. cmwmi.c
  5. Abstract:
  6. This module contains support for tracing registry system calls
  7. Author:
  8. Dragos C. Sambotin (dragoss) 05-Mar-1999
  9. Revision History:
  10. --*/
  11. #include "cmp.h"
  12. #pragma hdrstop
  13. #include <evntrace.h>
  14. VOID
  15. CmpWmiDumpKcbTable(
  16. VOID
  17. );
  18. #ifdef ALLOC_DATA_PRAGMA
  19. #pragma data_seg("PAGEDATA")
  20. #endif
  21. PCM_TRACE_NOTIFY_ROUTINE CmpTraceRoutine = NULL;
  22. #ifdef ALLOC_PRAGMA
  23. #pragma alloc_text(PAGE,CmSetTraceNotifyRoutine)
  24. #pragma alloc_text(PAGE,CmpWmiDumpKcbTable)
  25. #pragma alloc_text(PAGE,CmpWmiDumpKcb)
  26. #endif
  27. NTSTATUS
  28. CmSetTraceNotifyRoutine(
  29. IN PCM_TRACE_NOTIFY_ROUTINE NotifyRoutine,
  30. IN BOOLEAN Remove
  31. )
  32. {
  33. if(Remove) {
  34. // we shouldn't be called if the bellow assert fails
  35. // but since we are and the caller think is legitimate
  36. // just remove the assert
  37. //ASSERT(CmpTraceRoutine != NULL);
  38. CmpTraceRoutine = NULL;
  39. } else {
  40. // we shouldn't be called if the bellow assert fails
  41. // but since we are and the caller think is legitimate
  42. // just remove the assert
  43. //ASSERT(CmpTraceRoutine == NULL);
  44. CmpTraceRoutine = NotifyRoutine;
  45. //
  46. // dump active kcbs to WMI
  47. //
  48. CmpWmiDumpKcbTable();
  49. }
  50. return STATUS_SUCCESS;
  51. }
  52. VOID
  53. CmpWmiDumpKcbTable(
  54. VOID
  55. )
  56. /*++
  57. Routine Description:
  58. Sends all kcbs addresses and names from the HashTable to WMI.
  59. Arguments:
  60. none
  61. Return Value:
  62. none
  63. --*/
  64. {
  65. ULONG i;
  66. PCM_KEY_HASH Current;
  67. PCM_KEY_CONTROL_BLOCK kcb;
  68. PUNICODE_STRING KeyName;
  69. PCM_TRACE_NOTIFY_ROUTINE TraceRoutine = CmpTraceRoutine;
  70. PAGED_CODE();
  71. if( TraceRoutine == NULL ) {
  72. return;
  73. }
  74. CmpLockRegistry();
  75. BEGIN_KCB_LOCK_GUARD;
  76. CmpLockKCBTreeExclusive();
  77. for (i=0; i<CmpHashTableSize; i++) {
  78. Current = CmpCacheTable[i];
  79. while (Current) {
  80. kcb = CONTAINING_RECORD(Current, CM_KEY_CONTROL_BLOCK, KeyHash);
  81. KeyName = CmpConstructName(kcb);
  82. if(KeyName != NULL) {
  83. (*TraceRoutine)(STATUS_SUCCESS,
  84. kcb,
  85. 0,
  86. 0,
  87. KeyName,
  88. EVENT_TRACE_TYPE_REGKCBDMP);
  89. ExFreePoolWithTag(KeyName, CM_NAME_TAG | PROTECTED_POOL);
  90. }
  91. Current = Current->NextHash;
  92. }
  93. }
  94. CmpUnlockKCBTree();
  95. END_KCB_LOCK_GUARD;
  96. CmpUnlockRegistry();
  97. }
  98. VOID
  99. CmpWmiDumpKcb(
  100. PCM_KEY_CONTROL_BLOCK kcb
  101. )
  102. /*++
  103. Routine Description:
  104. dumps a single kcb
  105. Arguments:
  106. none
  107. Return Value:
  108. none
  109. --*/
  110. {
  111. PCM_TRACE_NOTIFY_ROUTINE TraceRoutine = CmpTraceRoutine;
  112. PUNICODE_STRING KeyName;
  113. PAGED_CODE();
  114. if( TraceRoutine == NULL ) {
  115. return;
  116. }
  117. KeyName = CmpConstructName(kcb);
  118. if(KeyName != NULL) {
  119. (*TraceRoutine)(STATUS_SUCCESS,
  120. kcb,
  121. 0,
  122. 0,
  123. KeyName,
  124. EVENT_TRACE_TYPE_REGKCBDMP);
  125. ExFreePoolWithTag(KeyName, CM_NAME_TAG | PROTECTED_POOL);
  126. }
  127. }