Pārlūkot izejas kodu

Bugfixes and improvements to the WriteBytes methods of several SMB1 structures

Tal Aloni 7 gadi atpakaļ
vecāks
revīzija
84a771641e

+ 3 - 3
SMBLibrary/SMB1/EnumStructures/OpenResults.cs

@@ -26,14 +26,14 @@ namespace SMBLibrary.SMB1
 
         public void WriteBytes(byte[] buffer, int offset)
         {
-            buffer[0] = (byte)OpenResult;
+            buffer[offset + 0] = (byte)OpenResult;
             if (OpLockGranted)
             {
-                buffer[1] = 0x80;
+                buffer[offset + 1] = 0x80;
             }
             else
             {
-                buffer[1] = 0x00;
+                buffer[offset + 1] = 0x00;
             }
         }
 

+ 6 - 0
SMBLibrary/SMB1/Transaction2Subcommands/EnumStructures/AccessModeOptions.cs

@@ -82,6 +82,12 @@ namespace SMBLibrary.SMB1
             buffer[offset + 1] |= (byte)(((byte)WriteThroughMode << 6) & 0x40);
         }
 
+        public void WriteBytes(byte[] buffer, ref int offset)
+        {
+            WriteBytes(buffer, offset);
+            offset += Length;
+        }
+
         public static AccessModeOptions Read(byte[] buffer, ref int offset)
         {
             offset += Length;

+ 8 - 2
SMBLibrary/SMB1/Transaction2Subcommands/EnumStructures/OpenMode.cs

@@ -38,8 +38,14 @@ namespace SMBLibrary.SMB1
 
         public void WriteBytes(byte[] buffer, int offset)
         {
-            buffer[0] = (byte)FileExistsOpts;
-            buffer[0] |= (byte)((byte)CreateFile << 4);
+            buffer[offset + 0] = (byte)FileExistsOpts;
+            buffer[offset + 0] |= (byte)((byte)CreateFile << 4);
+        }
+
+        public void WriteBytes(byte[] buffer, ref int offset)
+        {
+            WriteBytes(buffer, offset);
+            offset += Length;
         }
 
         public static OpenMode Read(byte[] buffer, ref int offset)