Browse Source

Added TreeID parameter to OpenFileObject

Tal Aloni 8 years ago
parent
commit
2c1b59973b

+ 3 - 1
SMBLibrary/Server/ConnectionState/OpenFileObject.cs

@@ -13,11 +13,13 @@ namespace SMBLibrary.Server
 {
     internal class OpenFileObject
     {
+        public uint TreeID;
         public string Path;
         public object Handle;
 
-        public OpenFileObject(string path, object handle)
+        public OpenFileObject(uint treeID, string path, object handle)
         {
+            TreeID = treeID;
             Path = path;
             Handle = handle;
         }

+ 4 - 4
SMBLibrary/Server/ConnectionState/SMB1Session.cs

@@ -69,17 +69,17 @@ namespace SMBLibrary.Server
 
         /// <param name="relativePath">Should include the path relative to the share</param>
         /// <returns>FileID</returns>
-        public ushort? AddOpenFile(string relativePath)
+        public ushort? AddOpenFile(ushort treeID, string relativePath)
         {
-            return AddOpenFile(relativePath, null);
+            return AddOpenFile(treeID, relativePath, null);
         }
 
-        public ushort? AddOpenFile(string relativePath, object handle)
+        public ushort? AddOpenFile(ushort treeID, string relativePath, object handle)
         {
             ushort? fileID = m_connection.AllocateFileID();
             if (fileID.HasValue)
             {
-                m_openFiles.Add(fileID.Value, new OpenFileObject(relativePath, handle));
+                m_openFiles.Add(fileID.Value, new OpenFileObject(treeID, relativePath, handle));
             }
             return fileID;
         }

+ 2 - 2
SMBLibrary/Server/ConnectionState/SMB2Session.cs

@@ -95,12 +95,12 @@ namespace SMBLibrary.Server
         }
 
         /// <returns>The persistent portion of the FileID</returns>
-        public ulong? AddOpenFile(string relativePath, object handle)
+        public ulong? AddOpenFile(uint treeID, string relativePath, object handle)
         {
             ulong? persistentID = m_connection.AllocatePersistentFileID();
             if (persistentID.HasValue)
             {
-                m_openFiles.Add(persistentID.Value, new OpenFileObject(relativePath, handle));
+                m_openFiles.Add(persistentID.Value, new OpenFileObject(treeID, relativePath, handle));
             }
             return persistentID;
         }

+ 1 - 1
SMBLibrary/Server/SMB1/NTCreateHelper.cs

@@ -40,7 +40,7 @@ namespace SMBLibrary.Server.SMB1
                 return new ErrorResponse(request.CommandName);
             }
 
-            ushort? fileID = session.AddOpenFile(path, handle);
+            ushort? fileID = session.AddOpenFile(header.TID, path, handle);
             if (!fileID.HasValue)
             {
                 share.FileStore.CloseFile(handle);

+ 1 - 1
SMBLibrary/Server/SMB1/OpenAndXHelper.cs

@@ -56,7 +56,7 @@ namespace SMBLibrary.Server.SMB1
                 return new ErrorResponse(request.CommandName);
             }
 
-            ushort? fileID = session.AddOpenFile(path, handle);
+            ushort? fileID = session.AddOpenFile(header.TID, path, handle);
             if (!fileID.HasValue)
             {
                 share.FileStore.CloseFile(handle);

+ 1 - 1
SMBLibrary/Server/SMB2/CreateHelper.cs

@@ -40,7 +40,7 @@ namespace SMBLibrary.Server.SMB2
                 return new ErrorResponse(request.CommandName, createStatus);
             }
 
-            ulong? persistentFileID = session.AddOpenFile(path, handle);
+            ulong? persistentFileID = session.AddOpenFile(request.Header.TreeID, path, handle);
             if (!persistentFileID.HasValue)
             {
                 share.FileStore.CloseFile(handle);