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.

91 lines
2.3 KiB

  1. #include "generic.h"
  2. #include "logger.h"
  3. #include "wdmlog.h"
  4. #pragma PAGEDCODE
  5. CWDMLogger::CWDMLogger()
  6. {
  7. m_LoggerName = L"GRClass";
  8. }
  9. #pragma PAGEDCODE
  10. CWDMLogger::CWDMLogger(PWSTR LoggerName)
  11. {
  12. wcscpy(m_LoggerName,LoggerName);
  13. m_Status = STATUS_SUCCESS;
  14. }
  15. #pragma PAGEDCODE
  16. CWDMLogger::~CWDMLogger()
  17. {
  18. }
  19. #pragma PAGEDCODE
  20. VOID CWDMLogger::logEvent(NTSTATUS ErrorCode, PDEVICE_OBJECT fdo)
  21. { // Win98 doesn't support event logging, so don't bother
  22. if (isWin98())
  23. {
  24. switch(ErrorCode)
  25. {
  26. case GRCLASS_START_OK:
  27. DBG_PRINT("Logger: GrClass driver was initialized succesfuly!\n");
  28. break;
  29. case GRCLASS_FAILED_TO_ADD_DEVICE:
  30. DBG_PRINT("Logger: ######### GrClass failed to add device!\n");
  31. break;
  32. case GRCLASS_FAILED_TO_CREATE_INTERFACE:
  33. DBG_PRINT("Logger: ######### GrClass failed to create interface object!\n");
  34. break;
  35. case GRCLASS_FAILED_TO_CREATE_READER:
  36. DBG_PRINT("Logger: ######### GrClass failed to create reader object!\n");
  37. break;
  38. case GRCLASS_BUS_DRIVER_FAILED_REQUEST:
  39. DBG_PRINT("Logger: ######### Bus driver failed GrClass driver request!\n");
  40. break;
  41. }
  42. return;
  43. }
  44. else
  45. {
  46. ULONG packetlen = (wcslen(m_LoggerName) + 1) * sizeof(WCHAR) + sizeof(IO_ERROR_LOG_PACKET) + 4;
  47. // packet will be too big
  48. if (packetlen > ERROR_LOG_MAXIMUM_SIZE) return;
  49. PIO_ERROR_LOG_PACKET p = (PIO_ERROR_LOG_PACKET) IoAllocateErrorLogEntry(fdo, (UCHAR) packetlen);
  50. if (!p) return;
  51. memset(p, 0, sizeof(IO_ERROR_LOG_PACKET));
  52. p->MajorFunctionCode = IRP_MJ_PNP;
  53. p->ErrorCode = ErrorCode;
  54. p->DumpDataSize = 4;
  55. p->DumpData[0] = 0x2A2A2A2A;
  56. p->StringOffset = sizeof(IO_ERROR_LOG_PACKET) + p->DumpDataSize - sizeof(ULONG);
  57. p->NumberOfStrings = 1;
  58. wcscpy((PWSTR) ((PUCHAR) p + p->StringOffset), m_LoggerName);
  59. IoWriteErrorLogEntry(p);
  60. }
  61. }
  62. #pragma PAGEDCODE
  63. CLogger* CWDMLogger::create(VOID)
  64. {
  65. CLogger* logger;
  66. logger = new (NonPagedPool) CWDMLogger;
  67. if (isWin98()) DBG_PRINT("***** New Logger Object was created 0x%x\n",logger);
  68. RETURN_VERIFIED_OBJECT(logger);
  69. }
  70. #pragma PAGEDCODE
  71. VOID CWDMLogger::dispose(VOID)
  72. {
  73. LONG Usage;
  74. Usage = decrementUsage();
  75. if(Usage<=0)
  76. {
  77. if (isWin98()) DBG_PRINT("**** Deleting Logger Object 0x%x\n",this);
  78. self_delete();
  79. }
  80. }