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.

105 lines
2.8 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////////
  2. // Logging functions
  3. void CServiceModule::LogEvent(LPCTSTR pFormat, ...)
  4. {
  5. TCHAR chMsg[256];
  6. HANDLE hEventSource;
  7. LPTSTR lpszStrings[1];
  8. va_list pArg;
  9. va_start(pArg, pFormat);
  10. _vstprintf(chMsg, pFormat, pArg);
  11. va_end(pArg);
  12. lpszStrings[0] = chMsg;
  13. if (m_bService)
  14. {
  15. /* Get a handle to use with ReportEvent(). */
  16. hEventSource = RegisterEventSource(NULL, m_szServiceName);
  17. if (hEventSource != NULL)
  18. {
  19. /* Write to event log. */
  20. ReportEvent(hEventSource, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (LPCTSTR*) &lpszStrings[0], NULL);
  21. DeregisterEventSource(hEventSource);
  22. }
  23. }
  24. else
  25. {
  26. // As we are not running as a service, just write the error to the console.
  27. _putts(chMsg);
  28. }
  29. }
  30. /*BOOL GetParams(TCHAR *FileName, PPARAMSTRUCT dbinfo)
  31. {
  32. IDebugClient *DebugClient;
  33. PDEBUG_CONTROL DebugControl;
  34. HRESULT Hr;
  35. ULONG Code;
  36. ULONG64 Arg1;
  37. ULONG64 Arg2;
  38. ULONG64 Arg3;
  39. ULONG64 Arg4;
  40. ULONG PlatformId;
  41. ULONG Major;
  42. ULONG Minor;
  43. TCHAR ServicePackString[255];
  44. ULONG ServicePackStringSize = 255;
  45. ULONG ServicePackStringUsed;
  46. ULONG ServicePackNumber;
  47. TCHAR BuildString[255];
  48. ULONG BuildStringSize = 255;
  49. ULONG BuildStringUsed;
  50. if ((Hr = DebugCreate(__uuidof(IDebugClient),
  51. (void **)&DebugClient)) == S_OK)
  52. {
  53. if (DebugClient->QueryInterface(__uuidof(IDebugControl),
  54. (void **)&DebugControl) == S_OK)
  55. {
  56. if (DebugClient->OpenDumpFile(FileName) == S_OK)
  57. {
  58. DebugControl->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
  59. Hr = DebugControl->GetSystemVersion(&PlatformId,&Major,&Minor,ServicePackString,ServicePackStringSize,
  60. &ServicePackStringUsed,&ServicePackNumber,BuildString,BuildStringSize,&BuildStringUsed);
  61. Hr = DebugControl->ReadBugCheckData(&Code, &Arg1, &Arg2,
  62. &Arg3, &Arg4);
  63. sprintf(dbinfo->StopCode,"%08x",Code);
  64. sprintf(dbinfo->P1,"0x%08x",(ULONG) Arg1);
  65. sprintf(dbinfo->P2,"0x%08x",(ULONG) Arg2);
  66. sprintf(dbinfo->P3,"0x%08x",(ULONG) Arg3);
  67. sprintf(dbinfo->P4,"0x%08x",(ULONG) Arg4);
  68. dbinfo->BuildNum = Minor;
  69. _ultoa(Minor,dbinfo->BuildNumber,10);
  70. DebugClient->EndSession(DEBUG_END_ACTIVE_TERMINATE);
  71. DebugControl->Release();
  72. }
  73. else
  74. return FALSE;
  75. DebugClient->Release();
  76. }
  77. else
  78. return FALSE;
  79. }
  80. else
  81. {
  82. return FALSE;
  83. }
  84. //return Hr;
  85. return TRUE;
  86. }
  87. */