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.

135 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. kdctrace.c
  5. Abstract:
  6. Include file to contain variables required for event tracing of kerberos
  7. server
  8. Author:
  9. 07-May-1998 JeePang
  10. Revision History:
  11. --*/
  12. //
  13. //
  14. //
  15. #include <kdcsvr.hxx>
  16. #include <wmistr.h>
  17. #define INITGUID
  18. #include "kdctrace.h"
  19. #include "debug.hxx"
  20. #define RESOURCE_NAME __TEXT("MofResource")
  21. #define IMAGE_PATH __TEXT("kdcsvc.dll")
  22. unsigned long KdcEventTraceFlag = FALSE;
  23. TRACEHANDLE KdcTraceRegistrationHandle = (TRACEHANDLE) 0;
  24. TRACEHANDLE KdcTraceLoggerHandle = (TRACEHANDLE) 0;
  25. ULONG
  26. KdcTraceControlCallback(
  27. IN WMIDPREQUESTCODE RequestCode,
  28. IN PVOID RequestContext,
  29. IN OUT ULONG *InOutBufferSize,
  30. IN OUT PVOID Buffer
  31. );
  32. TRACE_GUID_REGISTRATION KdcTraceGuids[] =
  33. {
  34. { &KdcGetASTicketGuid, NULL },
  35. { &KdcHandleTGSRequestGuid, NULL },
  36. { &KdcChangePassGuid, NULL }
  37. };
  38. #define KdcGuidCount (sizeof(KdcTraceGuids) / sizeof(TRACE_GUID_REGISTRATION))
  39. ULONG
  40. KdcInitializeTrace(
  41. VOID
  42. )
  43. {
  44. ULONG status;
  45. HMODULE hModule;
  46. TCHAR FileName[MAX_PATH+1];
  47. DWORD nLen = 0;
  48. hModule = GetModuleHandle(IMAGE_PATH);
  49. if (hModule != NULL) {
  50. nLen = GetModuleFileName(hModule, FileName, MAX_PATH);
  51. }
  52. if (nLen == 0) {
  53. lstrcpy(FileName, IMAGE_PATH);
  54. }
  55. status = RegisterTraceGuids(
  56. KdcTraceControlCallback,
  57. NULL,
  58. &KdcControlGuid,
  59. KdcGuidCount,
  60. KdcTraceGuids,
  61. (LPCWSTR) FileName,
  62. (LPCWSTR) RESOURCE_NAME,
  63. &KdcTraceRegistrationHandle);
  64. if (status != ERROR_SUCCESS) {
  65. DebugLog((DEB_TRACE,"Trace registration failed with %x\n",status));
  66. }
  67. return status;
  68. }
  69. ULONG
  70. KdcTraceControlCallback(
  71. IN WMIDPREQUESTCODE RequestCode,
  72. IN PVOID RequestContext,
  73. IN OUT ULONG *InOutBufferSize,
  74. IN OUT PVOID Buffer
  75. )
  76. {
  77. PWNODE_HEADER Wnode = (PWNODE_HEADER)Buffer;
  78. ULONG Status;
  79. ULONG RetSize;
  80. Status = ERROR_SUCCESS;
  81. switch (RequestCode)
  82. {
  83. case WMI_ENABLE_EVENTS:
  84. {
  85. KdcTraceLoggerHandle =
  86. GetTraceLoggerHandle(Buffer);
  87. KdcEventTraceFlag = 1;
  88. RetSize = 0;
  89. break;
  90. }
  91. case WMI_DISABLE_EVENTS:
  92. {
  93. KdcEventTraceFlag = 0;
  94. RetSize = 0;
  95. KdcTraceLoggerHandle = (TRACEHANDLE) 0;
  96. break;
  97. }
  98. default:
  99. {
  100. RetSize = 0;
  101. Status = ERROR_INVALID_PARAMETER;
  102. break;
  103. }
  104. }
  105. *InOutBufferSize = RetSize;
  106. return Status;
  107. } // KdcTraceControlCallback