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.

151 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. smb64.c
  5. Abstract:
  6. This module implements thunking needed for the SMB MiniRDR
  7. Author:
  8. David Kruse [DKruse] 30-November 2000
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. PBYTE
  14. Smb64ThunkFileRenameInfo(
  15. IN PFILE_RENAME_INFORMATION pRenameInfo,
  16. IN OUT PULONG pBufferSize,
  17. OUT NTSTATUS* pStatus
  18. );
  19. PBYTE
  20. Smb64ThunkRemoteLinkTrackingInfo(
  21. IN PBYTE pData,
  22. IN OUT PULONG BufferSize,
  23. OUT NTSTATUS* pStatus
  24. );
  25. #ifdef ALLOC_PRAGMA
  26. #pragma alloc_text(PAGE, Smb64ThunkFileRenameInfo)
  27. #pragma alloc_text(PAGE, Smb64ThunkRemoteLinkTrackingInfo)
  28. #endif
  29. PBYTE
  30. Smb64ThunkFileRenameInfo(
  31. IN PFILE_RENAME_INFORMATION pRenameInfo,
  32. IN OUT PULONG pBufferSize,
  33. OUT NTSTATUS* pStatus
  34. )
  35. /*++
  36. Routine Description:
  37. This routine thunks the FILE_RENAME_INFORMATION structure IN PLACE. This means that the
  38. original buffer will no longer be intact after this call! (However, it requires no memory
  39. allocation either)
  40. Arguments:
  41. RxContext - the RDBSS context
  42. Return Value:
  43. RXSTATUS - The return status for the operation
  44. Notes:
  45. Remoting of FSCTL's is permitted only to NT servers.
  46. --*/
  47. {
  48. PFILE_RENAME_INFORMATION32 pRenameInfo32;
  49. if (*pBufferSize < pRenameInfo->FileNameLength + sizeof(FILE_RENAME_INFORMATION32)) {
  50. *pStatus = STATUS_BUFFER_OVERFLOW;
  51. return NULL;
  52. }
  53. // Allocate the new buffer
  54. pRenameInfo32 = RxAllocatePoolWithTag( NonPagedPool, *pBufferSize, MRXSMB_MISC_POOLTAG );
  55. if( !pRenameInfo32 )
  56. {
  57. *pStatus = STATUS_INSUFFICIENT_RESOURCES;
  58. return NULL;
  59. }
  60. // Copy the data into the new buffer
  61. pRenameInfo32->ReplaceIfExists = pRenameInfo->ReplaceIfExists;
  62. pRenameInfo32->RootDirectory = *((PULONG)&pRenameInfo->RootDirectory);
  63. pRenameInfo32->FileNameLength = pRenameInfo->FileNameLength;
  64. RtlCopyMemory( &pRenameInfo32->FileName, &pRenameInfo->FileName, pRenameInfo->FileNameLength );
  65. // Succeeded. Return
  66. *pStatus = STATUS_SUCCESS;
  67. return (PBYTE)pRenameInfo32;
  68. }
  69. PBYTE
  70. Smb64ThunkRemoteLinkTrackingInfo(
  71. IN PBYTE pData,
  72. IN OUT PULONG BufferSize,
  73. OUT NTSTATUS* pStatus
  74. )
  75. /*++
  76. Routine Description:
  77. This routine handles all the FSCTL's
  78. Arguments:
  79. RxContext - the RDBSS context
  80. Return Value:
  81. RXSTATUS - The return status for the operation
  82. Notes:
  83. Remoting of FSCTL's is permitted only to NT servers.
  84. --*/
  85. {
  86. PREMOTE_LINK_TRACKING_INFORMATION pRemoteLink = (PREMOTE_LINK_TRACKING_INFORMATION)pData;
  87. PREMOTE_LINK_TRACKING_INFORMATION32 pRemoteLink32;
  88. if (*BufferSize < pRemoteLink->TargetLinkTrackingInformationLength +
  89. FIELD_OFFSET(REMOTE_LINK_TRACKING_INFORMATION32, TargetLinkTrackingInformationBuffer)) {
  90. *pStatus = STATUS_BUFFER_OVERFLOW;
  91. return NULL;
  92. }
  93. // Allocate the new buffer
  94. pRemoteLink32 = RxAllocatePoolWithTag( NonPagedPool, *BufferSize, MRXSMB_MISC_POOLTAG );
  95. if( !pRemoteLink32 )
  96. {
  97. *pStatus = STATUS_INSUFFICIENT_RESOURCES;
  98. return NULL;
  99. }
  100. // Copy the data into the new buffer
  101. pRemoteLink32->TargetFileObject = *((PULONG)&pRemoteLink->TargetFileObject);
  102. pRemoteLink32->TargetLinkTrackingInformationLength = pRemoteLink->TargetLinkTrackingInformationLength;
  103. RtlCopyMemory( &pRemoteLink32->TargetLinkTrackingInformationBuffer,
  104. &pRemoteLink->TargetLinkTrackingInformationBuffer,
  105. pRemoteLink->TargetLinkTrackingInformationLength );
  106. // Succeeded. Return
  107. *pStatus = STATUS_SUCCESS;
  108. return (PBYTE)pRemoteLink32;
  109. }