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.

239 lines
6.2 KiB

  1. /*--------------------------------------------------------------------------
  2. *
  3. * Copyright (C) Cyclades Corporation, 1997-2001.
  4. * All rights reserved.
  5. *
  6. * Cyclades-Z Port Driver
  7. *
  8. * This file: cyzlogc.c
  9. *
  10. * Description: This module contains the code related to message logging.
  11. *
  12. * Notes: This code supports Windows 2000 and Windows XP,
  13. * x86 and IA64 processors.
  14. *
  15. * Complies with Cyclades SW Coding Standard rev 1.3.
  16. *
  17. *--------------------------------------------------------------------------
  18. */
  19. /*-------------------------------------------------------------------------
  20. *
  21. * Change History
  22. *
  23. *--------------------------------------------------------------------------
  24. *
  25. *
  26. *--------------------------------------------------------------------------
  27. */
  28. #include "ntddk.h"
  29. #include "precomp.h"
  30. #ifdef ALLOC_PRAGMA
  31. #pragma alloc_text(INIT,CyzILog)
  32. #pragma alloc_text(INIT,CyzILogParam)
  33. #pragma alloc_text(PAGESER,CyzLog)
  34. #pragma alloc_text(PAGESER,CyzLogData)
  35. #endif
  36. VOID
  37. CyzLog(
  38. IN PDRIVER_OBJECT DriverObject,
  39. NTSTATUS msgId
  40. )
  41. /*--------------------------------------------------------------------------
  42. CyzLog()
  43. Description: Log an event (numerical value and string).
  44. Arguments: DriverObject and message id.
  45. Return Value: none
  46. --------------------------------------------------------------------------*/
  47. {
  48. PIO_ERROR_LOG_PACKET pLog;
  49. pLog = IoAllocateErrorLogEntry (DriverObject,
  50. (UCHAR) (sizeof (IO_ERROR_LOG_PACKET)) + 0x20);
  51. if(pLog) {
  52. pLog->MajorFunctionCode = 0;
  53. pLog->RetryCount = 0;
  54. pLog->DumpDataSize = 0;
  55. pLog->NumberOfStrings = 0;
  56. pLog->StringOffset = 0;
  57. pLog->EventCategory = 0;
  58. pLog->ErrorCode = msgId;
  59. pLog->UniqueErrorValue = 0;
  60. pLog->FinalStatus = STATUS_SUCCESS;
  61. pLog->SequenceNumber = 0;
  62. pLog->IoControlCode = 0;
  63. //pLog->DumpData[0] = 0x00000000L;
  64. //pLog->DumpData[1] = 0x00000001L;
  65. //pLog->DumpData[2] = 0x00000002L;
  66. //pLog->DumpData[3] = 0x00000003L;
  67. //pLog->DumpData[4] = 0x00000004L;
  68. IoWriteErrorLogEntry(pLog);
  69. }
  70. }
  71. VOID
  72. CyzLogData(
  73. IN PDRIVER_OBJECT DriverObject,
  74. NTSTATUS msgId,
  75. ULONG dump1,
  76. ULONG dump2
  77. )
  78. /*--------------------------------------------------------------------------
  79. CyzLogData()
  80. Description: Log an event (numerical value and string).
  81. Arguments: DriverObject, message id and parameter.
  82. Return Value: none
  83. --------------------------------------------------------------------------*/
  84. {
  85. #define NUMBER_DUMP_DATA_ENTRIES 3 // 1 signature + 2 variables
  86. PIO_ERROR_LOG_PACKET pLog;
  87. WCHAR stringBuffer[10];
  88. NTSTATUS nt_status;
  89. pLog = IoAllocateErrorLogEntry (DriverObject,
  90. (UCHAR)
  91. (sizeof (IO_ERROR_LOG_PACKET)
  92. + (NUMBER_DUMP_DATA_ENTRIES -1) * sizeof (ULONG)) );
  93. if(pLog) {
  94. pLog->MajorFunctionCode = 0;
  95. pLog->RetryCount = 0;
  96. pLog->DumpDataSize = NUMBER_DUMP_DATA_ENTRIES * sizeof (ULONG);
  97. pLog->NumberOfStrings = 0;
  98. pLog->StringOffset = 0;
  99. pLog->EventCategory = 0;
  100. pLog->ErrorCode = msgId;
  101. pLog->UniqueErrorValue = 0;
  102. pLog->FinalStatus = STATUS_SUCCESS;
  103. pLog->SequenceNumber = 0;
  104. pLog->IoControlCode = 0;
  105. pLog->DumpData[0] = 0x3e2d2d2dL; // It will log "---->"
  106. pLog->DumpData[1] = dump1;
  107. pLog->DumpData[2] = dump2;
  108. IoWriteErrorLogEntry(pLog);
  109. }
  110. }
  111. VOID
  112. CyzILog(
  113. IN PDRIVER_OBJECT DriverObject,
  114. NTSTATUS msgId
  115. )
  116. /*--------------------------------------------------------------------------
  117. CyzILog()
  118. Description: Log an event (numerical value and string).
  119. Arguments: DriverObject and message id.
  120. Return Value: none
  121. --------------------------------------------------------------------------*/
  122. {
  123. PIO_ERROR_LOG_PACKET pLog;
  124. pLog = IoAllocateErrorLogEntry (DriverObject,
  125. (UCHAR) (sizeof (IO_ERROR_LOG_PACKET)) + 0x20);
  126. if(pLog) {
  127. pLog->MajorFunctionCode = 0;
  128. pLog->RetryCount = 0;
  129. pLog->DumpDataSize = 0;
  130. pLog->NumberOfStrings = 0;
  131. pLog->StringOffset = 0;
  132. pLog->EventCategory = 0;
  133. pLog->ErrorCode = msgId;
  134. pLog->UniqueErrorValue = 0;
  135. pLog->FinalStatus = STATUS_SUCCESS;
  136. pLog->SequenceNumber = 0;
  137. pLog->IoControlCode = 0;
  138. //pLog->DumpData[0] = 0x00000000L;
  139. //pLog->DumpData[1] = 0x00000001L;
  140. //pLog->DumpData[2] = 0x00000002L;
  141. //pLog->DumpData[3] = 0x00000003L;
  142. //pLog->DumpData[4] = 0x00000004L;
  143. IoWriteErrorLogEntry(pLog);
  144. }
  145. }
  146. VOID
  147. CyzILogParam(
  148. IN PDRIVER_OBJECT DriverObject,
  149. NTSTATUS msgId,
  150. ULONG dumpParameter,
  151. ULONG base
  152. )
  153. /*--------------------------------------------------------------------------
  154. CyzILogParam()
  155. Description: Log an event (numerical value and string).
  156. Arguments: DriverObject, message id and parameter.
  157. Return Value: none
  158. --------------------------------------------------------------------------*/
  159. {
  160. #define DUMP_ENTRIES 2 // 1 signature + 1 variable
  161. PWCHAR insertionString ;
  162. PIO_ERROR_LOG_PACKET pLog;
  163. UNICODE_STRING uniErrorString;
  164. WCHAR stringBuffer[10];
  165. NTSTATUS nt_status;
  166. uniErrorString.Length = 0;
  167. uniErrorString.MaximumLength = 20;
  168. uniErrorString.Buffer = stringBuffer;
  169. nt_status = RtlIntegerToUnicodeString(dumpParameter,base,&uniErrorString);
  170. pLog = IoAllocateErrorLogEntry (DriverObject,
  171. (UCHAR)
  172. (sizeof (IO_ERROR_LOG_PACKET)
  173. + (DUMP_ENTRIES -1) * sizeof (ULONG)
  174. + uniErrorString.Length + sizeof(WCHAR)));
  175. if(pLog) {
  176. pLog->MajorFunctionCode = 0;
  177. pLog->RetryCount = 0;
  178. pLog->DumpDataSize = DUMP_ENTRIES * sizeof (ULONG);
  179. pLog->NumberOfStrings = 1;
  180. pLog->StringOffset = sizeof(IO_ERROR_LOG_PACKET)
  181. + (DUMP_ENTRIES - 1) * sizeof (ULONG);
  182. pLog->EventCategory = 0;
  183. pLog->ErrorCode = msgId;
  184. pLog->UniqueErrorValue = 0;
  185. pLog->FinalStatus = STATUS_SUCCESS;
  186. pLog->SequenceNumber = 0;
  187. pLog->IoControlCode = 0;
  188. pLog->DumpData[0] = 0x55555555L;
  189. pLog->DumpData[1] = dumpParameter;
  190. insertionString = (PWSTR)
  191. ((PCHAR)(pLog) + pLog->StringOffset) ;
  192. RtlMoveMemory (insertionString, uniErrorString.Buffer,
  193. uniErrorString.Length) ;
  194. *(PWSTR)((PCHAR)insertionString + uniErrorString.Length) = L'\0' ;
  195. IoWriteErrorLogEntry(pLog);
  196. }
  197. }
  198.