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.

161 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. nb32.c
  5. Abstract:
  6. This module contains routines to support thunking 32-bit NetBIOS IOCTLs
  7. on Win64.
  8. Author:
  9. Samer Arafeh (SamerA) 11-June-2000
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. --*/
  14. #if defined(_WIN64)
  15. #include "nb.h"
  16. NTSTATUS
  17. NbThunkNcb(
  18. IN PNCB32 Ncb32,
  19. OUT PDNCB Dncb)
  20. /*++
  21. Routine Description:
  22. This routine converts the input NCB structure received from the
  23. 32-bit app, into a 64-bit compatible structure
  24. Arguments:
  25. Ncb32 - Pointer to the NCB received from the 32-bit app.
  26. Dncb - Pointer to the structure to receive the 64-bit NCB after
  27. thunking the 32-bit one.
  28. Return Value:
  29. The function returns the status of the operation.
  30. --*/
  31. {
  32. Dncb->ncb_command = Ncb32->ncb_command;
  33. Dncb->ncb_retcode = Ncb32->ncb_retcode;
  34. Dncb->ncb_lsn = Ncb32->ncb_lsn;
  35. Dncb->ncb_num = Ncb32->ncb_num;
  36. Dncb->ncb_buffer = (PUCHAR)Ncb32->ncb_buffer;
  37. Dncb->ncb_length = Ncb32->ncb_length;
  38. RtlCopyMemory(Dncb->ncb_callname,
  39. Ncb32->ncb_callname,
  40. sizeof(Dncb->ncb_callname)) ;
  41. RtlCopyMemory(Dncb->ncb_name,
  42. Ncb32->ncb_name,
  43. sizeof(Dncb->ncb_name));
  44. Dncb->ncb_rto = Ncb32->ncb_rto;
  45. Dncb->ncb_sto = Ncb32->ncb_sto;
  46. Dncb->ncb_post = (void (*)(struct _NCB *))
  47. Ncb32->ncb_post;
  48. Dncb->ncb_lana_num = Ncb32->ncb_lana_num;
  49. Dncb->ncb_cmd_cplt = Ncb32->ncb_cmd_cplt;
  50. return STATUS_SUCCESS;
  51. }
  52. NTSTATUS
  53. NbCompleteIrp32(
  54. IN OUT PIRP Irp
  55. )
  56. /*++
  57. Routine Description:
  58. This routine completes an NCB Irp if it has been received
  59. from a 32-bit appliation. The caller should verify that the Irp
  60. is coming from a 32-bit context.
  61. Arguments:
  62. Irp - Pointer to the request packet representing the I/O request.
  63. Return Value:
  64. The function returns the status of the operation.
  65. --*/
  66. {
  67. PDNCB Dncb;
  68. PNCB32 Ncb32;
  69. ULONG Count;
  70. //
  71. // Conver the 64-bit NCB to a 32-bit compatible NCB
  72. // before the IO MGR copies it back to the supplied
  73. // user-mode buffer
  74. //
  75. if ((Irp->Flags & (IRP_BUFFERED_IO | IRP_INPUT_OPERATION)) ==
  76. (IRP_BUFFERED_IO | IRP_INPUT_OPERATION))
  77. {
  78. Dncb = (PDNCB) Irp->AssociatedIrp.SystemBuffer;
  79. Ncb32 = (PNCB32) Dncb;
  80. if ((Irp->IoStatus.Information > 0) &&
  81. (!NT_ERROR(Irp->IoStatus.Status)) &&
  82. (InterlockedCompareExchange(&Dncb->Wow64Flags, TRUE, FALSE) == FALSE))
  83. {
  84. Ncb32->ncb_command = Dncb->ncb_command;
  85. Ncb32->ncb_retcode = Dncb->ncb_retcode;
  86. Ncb32->ncb_lsn = Dncb->ncb_lsn;
  87. Ncb32->ncb_num = Dncb->ncb_num;
  88. Ncb32->ncb_buffer = (UCHAR * POINTER_32)PtrToUlong(Dncb->ncb_buffer);
  89. Ncb32->ncb_length = Dncb->ncb_length;
  90. for (Count=0 ; Count<sizeof(Ncb32->ncb_callname) ; Count++)
  91. {
  92. Ncb32->ncb_callname[Count] = Dncb->ncb_callname[Count];
  93. }
  94. for (Count=0 ; Count<sizeof(Ncb32->ncb_name) ; Count++)
  95. {
  96. Ncb32->ncb_name[Count] = Dncb->ncb_name[Count];
  97. }
  98. Ncb32->ncb_rto = Dncb->ncb_rto;
  99. Ncb32->ncb_sto = Dncb->ncb_sto;
  100. Ncb32->ncb_post = (void (* POINTER_32)(struct _NCB *))
  101. PtrToUlong(Dncb->ncb_post);
  102. Ncb32->ncb_lana_num = Dncb->ncb_lana_num;
  103. Ncb32->ncb_cmd_cplt = Dncb->ncb_cmd_cplt;
  104. Irp->IoStatus.Information = FIELD_OFFSET(NCB32, ncb_cmd_cplt);
  105. }
  106. }
  107. return STATUS_SUCCESS;
  108. }
  109. #endif // (_WIN64)