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.

211 lines
5.1 KiB

  1. /*++
  2. Module Name:
  3. qsfile.c
  4. Environment:
  5. Kernel mode
  6. Revision History :
  7. --*/
  8. #include "precomp.h"
  9. NTSTATUS
  10. MoxaQueryInformationFile(
  11. IN PDEVICE_OBJECT DeviceObject,
  12. IN PIRP Irp
  13. )
  14. /*++
  15. Routine Description:
  16. This routine is used to query the end of file information on
  17. the opened serial port. Any other file information request
  18. is retured with an invalid parameter.
  19. This routine always returns an end of file of 0.
  20. Arguments:
  21. DeviceObject - Pointer to the device object for this device
  22. Irp - Pointer to the IRP for the current request
  23. Return Value:
  24. The function value is the final status of the call
  25. --*/
  26. {
  27. //
  28. // The status that gets returned to the caller and
  29. // set in the Irp.
  30. //
  31. NTSTATUS status;
  32. //
  33. // The current stack location. This contains all of the
  34. // information we need to process this particular request.
  35. //
  36. PIO_STACK_LOCATION irpSp;
  37. PMOXA_DEVICE_EXTENSION Extension = DeviceObject->DeviceExtension;
  38. if (Extension->ControlDevice) { // Control Device
  39. status = STATUS_CANCELLED;
  40. Irp->IoStatus.Information = 0L;
  41. Irp->IoStatus.Status = status;
  42. IoCompleteRequest(
  43. Irp,
  44. 0
  45. );
  46. return status;
  47. }
  48. if ((status = MoxaIRPPrologue(Irp,
  49. (PMOXA_DEVICE_EXTENSION)DeviceObject->
  50. DeviceExtension)) != STATUS_SUCCESS) {
  51. MoxaCompleteRequest((PMOXA_DEVICE_EXTENSION)DeviceObject->
  52. DeviceExtension, Irp, IO_NO_INCREMENT);
  53. return status;
  54. }
  55. if (MoxaCompleteIfError(
  56. DeviceObject,
  57. Irp
  58. ) != STATUS_SUCCESS) {
  59. return STATUS_CANCELLED;
  60. }
  61. irpSp = IoGetCurrentIrpStackLocation(Irp);
  62. Irp->IoStatus.Information = 0L;
  63. status = STATUS_SUCCESS;
  64. if (irpSp->Parameters.QueryFile.FileInformationClass ==
  65. FileStandardInformation) {
  66. PFILE_STANDARD_INFORMATION buf = Irp->AssociatedIrp.SystemBuffer;
  67. buf->AllocationSize.QuadPart = 0;
  68. buf->EndOfFile = buf->AllocationSize;
  69. buf->NumberOfLinks = 0;
  70. buf->DeletePending = FALSE;
  71. buf->Directory = FALSE;
  72. Irp->IoStatus.Information = sizeof(FILE_STANDARD_INFORMATION);
  73. } else if (irpSp->Parameters.QueryFile.FileInformationClass ==
  74. FilePositionInformation) {
  75. ((PFILE_POSITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer)->
  76. CurrentByteOffset.QuadPart = 0;
  77. Irp->IoStatus.Information = sizeof(FILE_POSITION_INFORMATION);
  78. } else {
  79. status = STATUS_INVALID_PARAMETER;
  80. }
  81. Irp->IoStatus.Status = status;
  82. MoxaCompleteRequest((PMOXA_DEVICE_EXTENSION)DeviceObject->
  83. DeviceExtension, Irp, 0);
  84. return status;
  85. }
  86. NTSTATUS
  87. MoxaSetInformationFile(
  88. IN PDEVICE_OBJECT DeviceObject,
  89. IN PIRP Irp
  90. )
  91. /*++
  92. Routine Description:
  93. This routine is used to set the end of file information on
  94. the opened parallel port. Any other file information request
  95. is retured with an invalid parameter.
  96. This routine always ignores the actual end of file since
  97. the query information code always returns an end of file of 0.
  98. Arguments:
  99. DeviceObject - Pointer to the device object for this device
  100. Irp - Pointer to the IRP for the current request
  101. Return Value:
  102. The function value is the final status of the call
  103. --*/
  104. {
  105. //
  106. // The status that gets returned to the caller and
  107. // set in the Irp.
  108. //
  109. NTSTATUS status;
  110. PMOXA_DEVICE_EXTENSION Extension = DeviceObject->DeviceExtension;
  111. if (Extension->ControlDevice) { // Control Device
  112. status = STATUS_CANCELLED;
  113. Irp->IoStatus.Information = 0L;
  114. Irp->IoStatus.Status = status;
  115. IoCompleteRequest(
  116. Irp,
  117. 0
  118. );
  119. return status;
  120. }
  121. if ((status = MoxaIRPPrologue(Irp,
  122. (PMOXA_DEVICE_EXTENSION)DeviceObject->
  123. DeviceExtension)) != STATUS_SUCCESS) {
  124. MoxaCompleteRequest((PMOXA_DEVICE_EXTENSION)DeviceObject->
  125. DeviceExtension, Irp, IO_NO_INCREMENT);
  126. return status;
  127. }
  128. if (MoxaCompleteIfError(
  129. DeviceObject,
  130. Irp
  131. ) != STATUS_SUCCESS) {
  132. return STATUS_CANCELLED;
  133. }
  134. Irp->IoStatus.Information = 0L;
  135. if ((IoGetCurrentIrpStackLocation(Irp)->
  136. Parameters.SetFile.FileInformationClass ==
  137. FileEndOfFileInformation) ||
  138. (IoGetCurrentIrpStackLocation(Irp)->
  139. Parameters.SetFile.FileInformationClass ==
  140. FileAllocationInformation)) {
  141. status = STATUS_SUCCESS;
  142. } else {
  143. status = STATUS_INVALID_PARAMETER;
  144. }
  145. Irp->IoStatus.Status = status;
  146. MoxaCompleteRequest((PMOXA_DEVICE_EXTENSION)DeviceObject->
  147. DeviceExtension, Irp, 0);
  148. return status;
  149. }
  150.