Source code of Windows XP (NT5)
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.

90 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. errorlog.c
  5. Abstract:
  6. This module implements the error logging in the server.
  7. !!! This module must be nonpageable.
  8. Author:
  9. Jameel Hyder (microsoft!jameelh)
  10. Revision History:
  11. 10 Jun 1992 Initial Version
  12. --*/
  13. #define FILENUM FILE_ERRORLOG
  14. #include <afp.h>
  15. VOID
  16. AfpWriteErrorLogEntry(
  17. IN ULONG EventCode, // message number
  18. IN LONG UniqueErrorCode OPTIONAL,
  19. IN NTSTATUS NtStatusCode,
  20. IN PVOID RawDataBuf OPTIONAL,
  21. IN LONG RawDataLen,
  22. IN PUNICODE_STRING pInsertionString OPTIONAL
  23. )
  24. {
  25. PIO_ERROR_LOG_PACKET ErrorLogEntry;
  26. LONG InsertionStringLength = 0;
  27. #ifdef STOP_ON_ERRORS
  28. DBGBRK(DBG_LEVEL_ERR);
  29. #endif
  30. if (ARGUMENT_PRESENT(pInsertionString))
  31. {
  32. InsertionStringLength = pInsertionString->Length;
  33. }
  34. ErrorLogEntry =
  35. (PIO_ERROR_LOG_PACKET)IoAllocateErrorLogEntry(AfpDeviceObject,
  36. (UCHAR)(sizeof(IO_ERROR_LOG_PACKET) + RawDataLen + InsertionStringLength));
  37. if (ErrorLogEntry != NULL)
  38. {
  39. // Fill in the Error log entry
  40. ErrorLogEntry->ErrorCode = EventCode;
  41. ErrorLogEntry->MajorFunctionCode = 0;
  42. ErrorLogEntry->RetryCount = 0;
  43. ErrorLogEntry->UniqueErrorValue = (ULONG)UniqueErrorCode;
  44. ErrorLogEntry->FinalStatus = NtStatusCode;
  45. ErrorLogEntry->IoControlCode = 0;
  46. ErrorLogEntry->DeviceOffset.LowPart = 0;
  47. ErrorLogEntry->DeviceOffset.HighPart = 0;
  48. ErrorLogEntry->DumpDataSize = (USHORT)RawDataLen;
  49. ErrorLogEntry->StringOffset =
  50. (USHORT)(FIELD_OFFSET(IO_ERROR_LOG_PACKET, DumpData) + RawDataLen);
  51. ErrorLogEntry->NumberOfStrings = (ARGUMENT_PRESENT(pInsertionString)) ? 1 : 0;
  52. ErrorLogEntry->SequenceNumber = 0;
  53. if (ARGUMENT_PRESENT(RawDataBuf))
  54. {
  55. RtlCopyMemory(ErrorLogEntry->DumpData, RawDataBuf, RawDataLen);
  56. }
  57. if (ARGUMENT_PRESENT(pInsertionString))
  58. {
  59. RtlCopyMemory((PCHAR)ErrorLogEntry->DumpData + RawDataLen,
  60. pInsertionString->Buffer,
  61. pInsertionString->Length);
  62. }
  63. // Write the entry
  64. IoWriteErrorLogEntry(ErrorLogEntry);
  65. }
  66. INTERLOCKED_INCREMENT_LONG( &AfpServerStatistics.stat_Errors );
  67. }
  68.