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.

147 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. trace.c
  5. Abstract:
  6. Contains the initialization function for event tracing, the callback function
  7. which enables and disables tracing, plus the handles and trace flag.
  8. Author:
  9. 15-June-2000 Jason Clark
  10. Revision History:
  11. --*/
  12. //
  13. //
  14. //
  15. #define INITGUID
  16. #include <Global.h>
  17. #include "trace.h"
  18. #define IMAGE_PATH L"Msv1_0.dll"
  19. #define RESOURCE_NAME L"MofResource"
  20. BOOL NtlmGlobalEventTraceFlag = FALSE;
  21. TRACEHANDLE NtlmGlobalTraceRegistrationHandle = (TRACEHANDLE) 0;
  22. TRACEHANDLE NtlmGlobalTraceLoggerHandle = (TRACEHANDLE) 0;
  23. ULONG
  24. NtlmTraceControlCallback(
  25. IN WMIDPREQUESTCODE RequestCode,
  26. IN PVOID RequestContext,
  27. IN OUT ULONG *InOutBufferSize,
  28. IN OUT PVOID Buffer
  29. );
  30. TRACE_GUID_REGISTRATION NtlmTraceGuids[] =
  31. {
  32. { &NtlmAcceptGuid,
  33. NULL
  34. },
  35. { &NtlmInitializeGuid,
  36. NULL
  37. },
  38. { &NtlmLogonGuid,
  39. NULL
  40. },
  41. { &NtlmValidateGuid,
  42. NULL
  43. },
  44. { &NtlmGenericPassthroughGuid,
  45. NULL
  46. }
  47. };
  48. #define NtlmGuidCount (sizeof(NtlmTraceGuids) / sizeof(TRACE_GUID_REGISTRATION))
  49. ULONG
  50. NtlmInitializeTrace(
  51. VOID
  52. )
  53. {
  54. ULONG status;
  55. HMODULE hModule;
  56. TCHAR FileName[MAX_PATH+1];
  57. DWORD nLen = 0;
  58. hModule = GetModuleHandle(IMAGE_PATH);
  59. if (hModule != NULL) {
  60. nLen = GetModuleFileName(hModule, FileName, MAX_PATH);
  61. }
  62. if (nLen == 0) {
  63. lstrcpy(FileName, IMAGE_PATH);
  64. }
  65. status = RegisterTraceGuids(
  66. NtlmTraceControlCallback,
  67. NULL,
  68. &NtlmControlGuid,
  69. NtlmGuidCount,
  70. NtlmTraceGuids,
  71. (LPCWSTR) FileName,
  72. (LPCWSTR) RESOURCE_NAME,
  73. &NtlmGlobalTraceRegistrationHandle);
  74. if (status != ERROR_SUCCESS) {
  75. SspPrint((SSP_API, "Trace registration failed with %x\n",status));
  76. //DebugLog((DEB_ERROR,"Trace registration failed with %x\n",status));
  77. }
  78. return status;
  79. }
  80. ULONG
  81. NtlmTraceControlCallback(
  82. IN WMIDPREQUESTCODE RequestCode,
  83. IN PVOID RequestContext,
  84. IN OUT ULONG *InOutBufferSize,
  85. IN OUT PVOID Buffer
  86. )
  87. {
  88. ULONG Status;
  89. ULONG RetSize;
  90. Status = ERROR_SUCCESS;
  91. SspPrint((SSP_API,"NtlmTrace callback\n"));
  92. switch (RequestCode)
  93. {
  94. case WMI_ENABLE_EVENTS:
  95. {
  96. NtlmGlobalTraceLoggerHandle =
  97. GetTraceLoggerHandle(Buffer);
  98. NtlmGlobalEventTraceFlag = TRUE;
  99. RetSize = 0;
  100. break;
  101. }
  102. case WMI_DISABLE_EVENTS:
  103. {
  104. NtlmGlobalEventTraceFlag = FALSE;
  105. RetSize = 0;
  106. NtlmGlobalTraceLoggerHandle = (TRACEHANDLE) 0;
  107. break;
  108. }
  109. default:
  110. {
  111. RetSize = 0;
  112. Status = ERROR_INVALID_PARAMETER;
  113. break;
  114. }
  115. }
  116. *InOutBufferSize = RetSize;
  117. return Status;
  118. } // NtlmTraceControlCallback