Windows NT 4.0 source code leak
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.

139 lines
3.3 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. mailslot.c
  5. Abstract:
  6. This module implements the support routines needed for mailslots in the NT
  7. Lan Manager redirector
  8. Author:
  9. Larry Osterman (LarryO) 08-Aug-1991
  10. Revision History:
  11. 08-Aug-1991 LarryO
  12. Created
  13. --*/
  14. #define INCLUDE_SMB_TRANSACTION
  15. #include "precomp.h"
  16. #pragma hdrstop
  17. #ifdef ALLOC_PRAGMA
  18. #pragma alloc_text(PAGE, RdrMailslotWrite)
  19. #endif
  20. NTSTATUS
  21. RdrMailslotWrite (
  22. IN BOOLEAN Wait,
  23. IN BOOLEAN InFsd,
  24. IN PICB Icb,
  25. IN PIRP Irp,
  26. OUT PBOOLEAN PostToFsp
  27. )
  28. /*++
  29. Routine Description:
  30. This routine processes the NtWriteFile API for a remote mailslot.
  31. Arguments:
  32. IN BOOLEAN Wait - True iff we can wait for this request.
  33. IN PICB Icb - Supplies the ICB for the write request.
  34. IN PIRP Irp - Supplies a pointer to the IRP to be processed.
  35. OUT PBOOLEAN PostToFsp - True if we are to process this request in the FSP
  36. Return Value:
  37. NTSTATUS - The FSD status for this Irp.
  38. --*/
  39. {
  40. USHORT Setup[3];
  41. USHORT Params[2];
  42. UNICODE_STRING MailslotName = Icb->Fcb->FileName;
  43. UNICODE_STRING ServerName;
  44. PVOID DataBuffer;
  45. NTSTATUS Status;
  46. ULONG Disposition = FILE_OPEN_IF;
  47. PCONNECTLISTENTRY Connection;
  48. CLONG OutParameterCount = 2;
  49. CLONG OutSetupCount = 0;
  50. CLONG OutDataCount = 0;
  51. PSECURITY_ENTRY ConnectedSe = NULL;
  52. PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
  53. PAGED_CODE();
  54. if (!Wait) {
  55. *PostToFsp = TRUE;
  56. return STATUS_PENDING;
  57. }
  58. RdrReferenceDiscardableCode(RdrVCDiscardableSection);
  59. Connection = Icb->Fcb->Connection;
  60. RdrExtractNextComponentName(&ServerName, &Icb->Fcb->FileName);
  61. MailslotName.Length -= (ServerName.Length+sizeof(WCHAR));
  62. MailslotName.MaximumLength -= (ServerName.MaximumLength + sizeof(WCHAR));
  63. MailslotName.Buffer += (ServerName.Length/sizeof(WCHAR)) + 1;
  64. try {
  65. RdrMapUsersBuffer(Irp, &DataBuffer, IrpSp->Parameters.Write.Length);
  66. } except (EXCEPTION_EXECUTE_HANDLER) {
  67. RdrDereferenceDiscardableCode(RdrVCDiscardableSection);
  68. return GetExceptionCode();
  69. }
  70. Setup[0] = TRANS_MAILSLOT_WRITE;// Command
  71. Setup[1] = 0; // Priority of write
  72. Setup[2] = 2; // Unreliable request.
  73. //
  74. // Please note that even though we will never get a response
  75. // to this request, the SMB protocol for mailslot writes specifies
  76. // that there be two receive parameters specified in the SMB. Don't ask.
  77. //
  78. Status = RdrTransact(Irp, Connection, Icb->Se,
  79. Setup, sizeof(Setup), &OutSetupCount, // Setup words
  80. &MailslotName, // Name
  81. Params, 0, &OutParameterCount, // Parameters
  82. DataBuffer, IrpSp->Parameters.Write.Length, // In data
  83. NULL, &OutDataCount, // Out data
  84. NULL, 0xffffffff, SMB_TRANSACTION_NO_RESPONSE, 0,
  85. NULL, NULL);
  86. //
  87. // If we were able to send the data, then it all made it.
  88. //
  89. if (NT_SUCCESS(Status)) {
  90. Irp->IoStatus.Information = IrpSp->Parameters.Write.Length;
  91. }
  92. RdrDereferenceDiscardableCode(RdrVCDiscardableSection);
  93. return Status;
  94. }