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.

115 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. write.c
  5. Abstract:
  6. This module contains the code that is very specific to initialization
  7. and unload operations in the irenum driver
  8. Author:
  9. Brian Lieuallen, 7-13-2000
  10. Environment:
  11. Kernel mode
  12. Revision History :
  13. --*/
  14. #include "internal.h"
  15. #include "ircomm.h"
  16. VOID
  17. ProcesWriteData(
  18. PFDO_DEVICE_EXTENSION DeviceExtension
  19. );
  20. NTSTATUS
  21. IrCommWrite(
  22. PDEVICE_OBJECT DeviceObject,
  23. PIRP Irp
  24. )
  25. {
  26. PFDO_DEVICE_EXTENSION DeviceExtension=(PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
  27. NTSTATUS Status=STATUS_SUCCESS;
  28. D_TRACE(DbgPrint("IRCOMM: IrCommWrite\n");)
  29. if (DeviceExtension->Removing) {
  30. //
  31. // the device has been removed, no more irps
  32. //
  33. Irp->IoStatus.Status=STATUS_DEVICE_REMOVED;
  34. IoCompleteRequest(Irp,IO_NO_INCREMENT);
  35. return STATUS_DEVICE_REMOVED;
  36. }
  37. IoMarkIrpPending(Irp);
  38. QueuePacket(&DeviceExtension->Write.Queue,Irp,FALSE);
  39. return STATUS_PENDING;
  40. }
  41. VOID
  42. SendComplete(
  43. PVOID Context,
  44. PIRP Irp
  45. )
  46. {
  47. PFDO_DEVICE_EXTENSION DeviceExtension=(PFDO_DEVICE_EXTENSION)Context;
  48. PIO_STACK_LOCATION IrpSp=IoGetCurrentIrpStackLocation(Irp);
  49. if (IrpSp->MajorFunction == IRP_MJ_WRITE) {
  50. InterlockedExchangeAdd(
  51. &DeviceExtension->Write.BytesWritten,
  52. (LONG)Irp->IoStatus.Information
  53. );
  54. }
  55. IoCompleteRequest(Irp,IO_NO_INCREMENT);
  56. StartNextPacket(&DeviceExtension->Write.Queue);
  57. return;
  58. }
  59. VOID
  60. WriteStartRoutine(
  61. PVOID Context,
  62. PIRP Irp
  63. )
  64. {
  65. PFDO_DEVICE_EXTENSION DeviceExtension=(PFDO_DEVICE_EXTENSION)Context;
  66. PIO_STACK_LOCATION IrpSp=IoGetCurrentIrpStackLocation(Irp);
  67. SendOnConnection(
  68. DeviceExtension->ConnectionHandle,
  69. Irp,
  70. SendComplete,
  71. DeviceExtension,
  72. DeviceExtension->TimeOuts.WriteTotalTimeoutConstant + (DeviceExtension->TimeOuts.WriteTotalTimeoutMultiplier * IrpSp->Parameters.Write.Length)
  73. );
  74. return;
  75. }