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.

80 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. log.c
  5. Abstract:
  6. This module contains functions to generate event log
  7. entries for the service.
  8. Author:
  9. Jeffrey C. Venable, Sr. (jeffv) 01-Jun-2001
  10. Revision History:
  11. --*/
  12. #include "precomp.h"
  13. void
  14. TftpdLogEvent(WORD type, DWORD request, WORD numStrings) {
  15. // Register the event source if necessary.
  16. if (globals.service.hEventLogSource == NULL) {
  17. /*
  18. UCHAR szBuf[80];
  19. DWORD dwData;
  20. HKEY key;
  21. // Create the event-source registry keys if necessary
  22. if (RegCreateKey(HKEY_LOCAL_MACHINE,
  23. "SYSTEM\\CurrentControlSet\\Services\\"
  24. "EventLog\\Application\\Tftpd", &key))
  25. return;
  26. // Set the name of the message file.
  27. strcpy(szBuf, "%SystemRoot%\\System\\SamplApp.dll");
  28. // Add the name to the EventMessageFile subkey.
  29. if (RegSetValueEx(key, // subkey handle
  30. "EventMessageFile", // value name
  31. 0, // must be zero
  32. REG_EXPAND_SZ, // value type
  33. (LPBYTE) szBuf, // pointer to value data
  34. strlen(szBuf) + 1)) // length of value data
  35. return;
  36. // Set the supported event types in the TypesSupported subkey.
  37. dwData = (EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE);
  38. if (RegSetValueEx(key, // subkey handle
  39. "TypesSupported", // value name
  40. 0, // must be zero
  41. REG_DWORD, // value type
  42. (LPBYTE) &dwData, // pointer to value data
  43. sizeof(DWORD))) // length of value data
  44. return;
  45. RegCloseKey(key);
  46. */
  47. globals.service.hEventLogSource = RegisterEventSource(NULL, "NLA");
  48. } // if (globals.service.hEventLogSource == NULL)
  49. // If registration failed, we don't own the process, and can't
  50. // report errors anyways ... silent failure.
  51. if (globals.service.hEventLogSource == NULL)
  52. return;
  53. ReportEvent(globals.service.hEventLogSource, type, 0,
  54. request, NULL, numStrings, 0, NULL, NULL);
  55. } // TftpdLogEvent()