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.

132 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. kerbtrace.cxx
  5. Abstract:
  6. Set up event tracing for Kerberos
  7. Author:
  8. 15 June 2000 t-ryanj (* largely stolen from kdctrace.cxx *)
  9. Revision History:
  10. --*/
  11. #include <kerb.hxx>
  12. #include <wmistr.h>
  13. #define INITGUID
  14. #include "kerbdbg.h"
  15. #define RESOURCE_NAME __TEXT("MOF_RESOURCE") // kerberos.mof => kerberos.bmf => MOF_RESOURCE
  16. #define IMAGE_PATH __TEXT("kerberos.dll")
  17. BOOLEAN KerbEventTraceFlag = FALSE;
  18. TRACEHANDLE KerbTraceRegistrationHandle = (TRACEHANDLE) 0;
  19. TRACEHANDLE KerbTraceLoggerHandle = (TRACEHANDLE) 0;
  20. ULONG
  21. KerbTraceControlCallback(
  22. IN WMIDPREQUESTCODE RequestCode,
  23. IN PVOID RequestContext,
  24. IN OUT ULONG *InOutBufferSize,
  25. IN OUT PVOID Buffer
  26. );
  27. TRACE_GUID_REGISTRATION KerbTraceGuids[] =
  28. {
  29. { &KerbLogonGuid, NULL },
  30. { &KerbInitSCGuid, NULL },
  31. { &KerbAcceptSCGuid, NULL },
  32. { &KerbSetPassGuid, NULL },
  33. { &KerbChangePassGuid, NULL }
  34. };
  35. #define KerbGuidCount (sizeof(KerbTraceGuids) / sizeof(TRACE_GUID_REGISTRATION))
  36. ULONG
  37. KerbInitializeTrace(
  38. VOID
  39. )
  40. {
  41. ULONG status;
  42. HMODULE hModule;
  43. TCHAR FileName[MAX_PATH+1];
  44. DWORD nLen = 0;
  45. hModule = GetModuleHandle(IMAGE_PATH);
  46. if (hModule != NULL) {
  47. nLen = GetModuleFileName(hModule, FileName, MAX_PATH);
  48. }
  49. if (nLen == 0) {
  50. lstrcpy(FileName, IMAGE_PATH);
  51. }
  52. status = RegisterTraceGuids(
  53. KerbTraceControlCallback,
  54. NULL,
  55. &KerbControlGuid,
  56. KerbGuidCount,
  57. KerbTraceGuids,
  58. (LPCWSTR) FileName,
  59. (LPCWSTR) RESOURCE_NAME,
  60. &KerbTraceRegistrationHandle);
  61. if (status != ERROR_SUCCESS) {
  62. DebugLog((DEB_ERROR,"Trace registration failed with %x\n",status));
  63. }
  64. return status;
  65. }
  66. ULONG
  67. KerbTraceControlCallback(
  68. IN WMIDPREQUESTCODE RequestCode,
  69. IN PVOID RequestContext,
  70. IN OUT ULONG *InOutBufferSize,
  71. IN OUT PVOID Buffer
  72. )
  73. {
  74. ULONG Status;
  75. ULONG RetSize;
  76. Status = ERROR_SUCCESS;
  77. switch (RequestCode)
  78. {
  79. case WMI_ENABLE_EVENTS:
  80. {
  81. KerbTraceLoggerHandle =
  82. GetTraceLoggerHandle(Buffer);
  83. KerbEventTraceFlag = TRUE;
  84. RetSize = 0;
  85. break;
  86. }
  87. case WMI_DISABLE_EVENTS:
  88. {
  89. KerbEventTraceFlag = FALSE;
  90. RetSize = 0;
  91. KerbTraceLoggerHandle = (TRACEHANDLE) 0;
  92. break;
  93. }
  94. default:
  95. {
  96. RetSize = 0;
  97. Status = ERROR_INVALID_PARAMETER;
  98. break;
  99. }
  100. }
  101. *InOutBufferSize = RetSize;
  102. return Status;
  103. }