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.

134 lines
2.8 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. ULONG Status;
  78. ULONG RetSize;
  79. Status = ERROR_SUCCESS;
  80. switch (RequestCode)
  81. {
  82. case WMI_ENABLE_EVENTS:
  83. {
  84. KdcTraceLoggerHandle =
  85. GetTraceLoggerHandle(Buffer);
  86. KdcEventTraceFlag = 1;
  87. RetSize = 0;
  88. break;
  89. }
  90. case WMI_DISABLE_EVENTS:
  91. {
  92. KdcEventTraceFlag = 0;
  93. RetSize = 0;
  94. KdcTraceLoggerHandle = (TRACEHANDLE) 0;
  95. break;
  96. }
  97. default:
  98. {
  99. RetSize = 0;
  100. Status = ERROR_INVALID_PARAMETER;
  101. break;
  102. }
  103. }
  104. *InOutBufferSize = RetSize;
  105. return Status;
  106. } // KdcTraceControlCallback