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.

166 lines
4.3 KiB

  1. #include "pch.h"
  2. NTSTATUS
  3. PptPdoQueryInformation(
  4. IN PDEVICE_OBJECT DeviceObject,
  5. IN PIRP Irp
  6. )
  7. /*++
  8. Routine Description:
  9. This routine is used to query the end of file information on
  10. the opened parallel port. Any other file information request
  11. is retured with an invalid parameter.
  12. This routine always returns an end of file of 0.
  13. Arguments:
  14. DeviceObject - Supplies the device object.
  15. Irp - Supplies the I/O request packet.
  16. Return Value:
  17. STATUS_SUCCESS - Success.
  18. STATUS_INVALID_PARAMETER - Invalid file information request.
  19. STATUS_BUFFER_TOO_SMALL - Buffer too small.
  20. --*/
  21. {
  22. NTSTATUS Status;
  23. PIO_STACK_LOCATION IrpSp;
  24. PFILE_STANDARD_INFORMATION StdInfo;
  25. PFILE_POSITION_INFORMATION PosInfo;
  26. PPDO_EXTENSION Extension = DeviceObject->DeviceExtension;
  27. UNREFERENCED_PARAMETER(DeviceObject);
  28. //
  29. // bail out if device has been removed
  30. //
  31. if(Extension->DeviceStateFlags & (PPT_DEVICE_REMOVED|PPT_DEVICE_SURPRISE_REMOVED) ) {
  32. P4CompleteRequest( Irp, STATUS_DEVICE_REMOVED, Irp->IoStatus.Information );
  33. return STATUS_DEVICE_REMOVED;
  34. }
  35. Irp->IoStatus.Information = 0;
  36. IrpSp = IoGetCurrentIrpStackLocation(Irp);
  37. switch (IrpSp->Parameters.QueryFile.FileInformationClass) {
  38. case FileStandardInformation:
  39. if (IrpSp->Parameters.QueryFile.Length < sizeof(FILE_STANDARD_INFORMATION)) {
  40. Status = STATUS_BUFFER_TOO_SMALL;
  41. } else {
  42. StdInfo = Irp->AssociatedIrp.SystemBuffer;
  43. StdInfo->AllocationSize.QuadPart = 0;
  44. StdInfo->EndOfFile = StdInfo->AllocationSize;
  45. StdInfo->NumberOfLinks = 0;
  46. StdInfo->DeletePending = FALSE;
  47. StdInfo->Directory = FALSE;
  48. Irp->IoStatus.Information = sizeof(FILE_STANDARD_INFORMATION);
  49. Status = STATUS_SUCCESS;
  50. }
  51. break;
  52. case FilePositionInformation:
  53. if (IrpSp->Parameters.SetFile.Length < sizeof(FILE_POSITION_INFORMATION)) {
  54. Status = STATUS_BUFFER_TOO_SMALL;
  55. } else {
  56. PosInfo = Irp->AssociatedIrp.SystemBuffer;
  57. PosInfo->CurrentByteOffset.QuadPart = 0;
  58. Irp->IoStatus.Information = sizeof(FILE_POSITION_INFORMATION);
  59. Status = STATUS_SUCCESS;
  60. }
  61. break;
  62. default:
  63. Status = STATUS_INVALID_PARAMETER;
  64. break;
  65. }
  66. P4CompleteRequest( Irp, Status, Irp->IoStatus.Information );
  67. return Status;
  68. }
  69. NTSTATUS
  70. PptPdoSetInformation(
  71. IN PDEVICE_OBJECT DeviceObject,
  72. IN PIRP Irp
  73. )
  74. /*++
  75. Routine Description:
  76. This routine is used to set the end of file information on
  77. the opened parallel port. Any other file information request
  78. is retured with an invalid parameter.
  79. This routine always ignores the actual end of file since
  80. the query information code always returns an end of file of 0.
  81. Arguments:
  82. DeviceObject - Supplies the device object.
  83. Irp - Supplies the I/O request packet.
  84. Return Value:
  85. STATUS_SUCCESS - Success.
  86. STATUS_INVALID_PARAMETER - Invalid file information request.
  87. --*/
  88. {
  89. NTSTATUS Status;
  90. FILE_INFORMATION_CLASS fileInfoClass;
  91. PPDO_EXTENSION Extension = DeviceObject->DeviceExtension;
  92. UNREFERENCED_PARAMETER(DeviceObject);
  93. //
  94. // bail out if device has been removed
  95. //
  96. if(Extension->DeviceStateFlags & (PPT_DEVICE_REMOVED|PPT_DEVICE_SURPRISE_REMOVED) ) {
  97. return P4CompleteRequest( Irp, STATUS_DEVICE_REMOVED, Irp->IoStatus.Information );
  98. }
  99. Irp->IoStatus.Information = 0;
  100. fileInfoClass = IoGetCurrentIrpStackLocation(Irp)->Parameters.SetFile.FileInformationClass;
  101. if (fileInfoClass == FileEndOfFileInformation) {
  102. Status = STATUS_SUCCESS;
  103. } else {
  104. Status = STATUS_INVALID_PARAMETER;
  105. }
  106. return P4CompleteRequest( Irp, Status, Irp->IoStatus.Information );
  107. }