Explorar o código

Merge branch 'master' into Mod-1

HOME %!s(int64=5) %!d(string=hai) anos
pai
achega
119d84c0c9

+ 38 - 2
SMBLibrary/Client/SMB1FileStore.cs

@@ -289,7 +289,43 @@ namespace SMBLibrary.Client
 
         public NTStatus SetFileInformation(object handle, FileInformation information)
         {
-            throw new NotImplementedException();
+            if (m_client.InfoLevelPassthrough)
+            {
+	            if (information is FileRenameInformationType2)
+	            {
+	                FileRenameInformationType1 informationType1 = new FileRenameInformationType1();
+	                informationType1.FileName = ((FileRenameInformationType2)information).FileName;
+	                informationType1.ReplaceIfExists = ((FileRenameInformationType2)information).ReplaceIfExists;
+	                informationType1.RootDirectory = (uint)((FileRenameInformationType2)information).RootDirectory;
+	                information = informationType1;
+	            }
+	
+	            int maxOutputLength = 4096;
+	            Transaction2SetFileInformationRequest subcommand = new Transaction2SetFileInformationRequest();
+	            subcommand.FID = (ushort)handle;
+	            subcommand.SetInformation(information);
+	
+	            Transaction2Request request = new Transaction2Request();
+	            request.Setup = subcommand.GetSetup();
+	            request.TransParameters = subcommand.GetParameters(m_client.Unicode);
+	            request.TransData = subcommand.GetData(m_client.Unicode);
+	            request.TotalDataCount = (ushort)request.TransData.Length;
+	            request.TotalParameterCount = (ushort)request.TransParameters.Length;
+	            request.MaxParameterCount = Transaction2SetFileInformationResponse.ParametersLength;
+	            request.MaxDataCount = (ushort)maxOutputLength;
+	
+	            TrySendMessage(request);
+	            SMB1Message reply = m_client.WaitForMessage(CommandName.SMB_COM_TRANSACTION2);
+	            if (reply != null)
+	            {
+	                return reply.Header.Status;
+	            }
+	            return NTStatus.STATUS_INVALID_SMB;
+            }
+			else
+			{
+				throw new NotSupportedException("Server does not support InfoLevelPassthrough");
+			}
         }
 
         public NTStatus SetFileInformation(object handle, SetInformation information)
@@ -351,7 +387,7 @@ namespace SMBLibrary.Client
             }
             else
             {
-                throw new NotImplementedException();
+                throw new NotSupportedException("Server does not support InfoLevelPassthrough");
             }
         }
 

+ 2 - 2
SMBLibrary/NTFileStore/Structures/FileInformation/Set/FileLinkInformationType1.cs

@@ -16,8 +16,8 @@ namespace SMBLibrary
     /// </summary>
     /// <remarks>
     /// [MS-FSA] 2.1.5.14.6
-    /// FILE_LINK_INFORMATION_TYPE_1: Used for 32-bit local clients.
-    /// FILE_LINK_INFORMATION_TYPE_2: Used for remote clients or 64-bit local clients.
+    /// FILE_LINK_INFORMATION_TYPE_1: Used for 32-bit local clients and the SMB1 protocol.
+    /// FILE_LINK_INFORMATION_TYPE_2: Used for 64-bit local clients and the SMB2 protocol.
     /// </remarks>
     public class FileLinkInformationType1 : FileInformation
     {

+ 2 - 2
SMBLibrary/NTFileStore/Structures/FileInformation/Set/FileLinkInformationType2.cs

@@ -16,8 +16,8 @@ namespace SMBLibrary
     /// </summary>
     /// <remarks>
     /// [MS-FSA] 2.1.5.14.6
-    /// FILE_LINK_INFORMATION_TYPE_1: Used for 32-bit local clients.
-    /// FILE_LINK_INFORMATION_TYPE_2: Used for remote clients or 64-bit local clients.
+    /// FILE_LINK_INFORMATION_TYPE_1: Used for 32-bit local clients and the SMB1 protocol.
+    /// FILE_LINK_INFORMATION_TYPE_2: Used for 64-bit local clients and the SMB2 protocol.
     /// </remarks>
     public class FileLinkInformationType2 : FileInformation
     {

+ 2 - 2
SMBLibrary/NTFileStore/Structures/FileInformation/Set/FileRenameInformationType1.cs

@@ -16,8 +16,8 @@ namespace SMBLibrary
     /// </summary>
     /// <remarks>
     /// [MS-FSA] 2.1.5.14.11
-    /// FILE_RENAME_INFORMATION_TYPE_1: Used for 32-bit local clients.
-    /// FILE_RENAME_INFORMATION_TYPE_2: Used for remote clients or 64-bit local clients.
+    /// FILE_RENAME_INFORMATION_TYPE_1: Used for 32-bit local clients and the SMB1 protocol.
+    /// FILE_RENAME_INFORMATION_TYPE_2: Used for 64-bit local clients and the SMB2 protocol.
     /// </remarks>
     public class FileRenameInformationType1 : FileInformation
     {

+ 2 - 2
SMBLibrary/NTFileStore/Structures/FileInformation/Set/FileRenameInformationType2.cs

@@ -16,8 +16,8 @@ namespace SMBLibrary
     /// </summary>
     /// <remarks>
     /// [MS-FSA] 2.1.5.14.11
-    /// FILE_RENAME_INFORMATION_TYPE_1: Used for 32-bit local clients.
-    /// FILE_RENAME_INFORMATION_TYPE_2: Used for remote clients or 64-bit local clients.
+    /// FILE_RENAME_INFORMATION_TYPE_1: Used for 32-bit local clients and the SMB1 protocol.
+    /// FILE_RENAME_INFORMATION_TYPE_2: Used for 64-bit local clients and the SMB2 protocol.
     /// </remarks>
     public class FileRenameInformationType2 : FileInformation
     {