Browse Source

Renamed ShareAccess enum members

Tal Aloni 7 years ago
parent
commit
23db301a21

+ 1 - 1
SMBLibrary/Client/Helpers/ServerServiceHelper.cs

@@ -18,7 +18,7 @@ namespace SMBLibrary.Client
         {
             object pipeHandle;
             FileStatus fileStatus;
-            status = namedPipeShare.CreateFile(out pipeHandle, out fileStatus, ServerService.ServicePipeName, (AccessMask)(FileAccessMask.FILE_READ_DATA | FileAccessMask.FILE_WRITE_DATA), 0, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.FILE_OPEN, 0, null);
+            status = namedPipeShare.CreateFile(out pipeHandle, out fileStatus, ServerService.ServicePipeName, (AccessMask)(FileAccessMask.FILE_READ_DATA | FileAccessMask.FILE_WRITE_DATA), 0, ShareAccess.Read | ShareAccess.Write, CreateDisposition.FILE_OPEN, 0, null);
             if (status != NTStatus.STATUS_SUCCESS)
             {
                 return null;

+ 1 - 1
SMBLibrary/Client/SMB2FileStore.cs

@@ -185,7 +185,7 @@ namespace SMBLibrary.Client
             result = null;
             object fileHandle;
             FileStatus fileStatus;
-            NTStatus status = CreateFile(out fileHandle, out fileStatus, String.Empty, (AccessMask)DirectoryAccessMask.FILE_LIST_DIRECTORY | (AccessMask)DirectoryAccessMask.FILE_READ_ATTRIBUTES | AccessMask.SYNCHRONIZE, 0, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE | ShareAccess.FILE_SHARE_DELETE, CreateDisposition.FILE_OPEN, CreateOptions.FILE_SYNCHRONOUS_IO_NONALERT | CreateOptions.FILE_DIRECTORY_FILE, null);
+            NTStatus status = CreateFile(out fileHandle, out fileStatus, String.Empty, (AccessMask)DirectoryAccessMask.FILE_LIST_DIRECTORY | (AccessMask)DirectoryAccessMask.FILE_READ_ATTRIBUTES | AccessMask.SYNCHRONIZE, 0, ShareAccess.Read | ShareAccess.Write | ShareAccess.Delete, CreateDisposition.FILE_OPEN, CreateOptions.FILE_SYNCHRONOUS_IO_NONALERT | CreateOptions.FILE_DIRECTORY_FILE, null);
             if (status != NTStatus.STATUS_SUCCESS)
             {
                 return status;

+ 3 - 3
SMBLibrary/NTFileStore/Enums/NtCreateFile/ShareAccess.cs

@@ -8,8 +8,8 @@ namespace SMBLibrary
     [Flags]
     public enum ShareAccess : uint
     {
-        FILE_SHARE_READ = 0x0001,
-        FILE_SHARE_WRITE = 0x0002,
-        FILE_SHARE_DELETE = 0x0004,
+        Read = 0x0001,   // FILE_SHARE_READ
+        Write = 0x0002,  // FILE_SHARE_WRITE
+        Delete = 0x0004, // FILE_SHARE_DELETE
     }
 }

+ 4 - 4
SMBLibrary/NTFileStore/NTFileStoreHelper.cs

@@ -99,17 +99,17 @@ namespace SMBLibrary
         public static FileShare ToFileShare(ShareAccess shareAccess)
         {
             FileShare result = FileShare.None;
-            if ((shareAccess & ShareAccess.FILE_SHARE_READ) > 0)
+            if ((shareAccess & ShareAccess.Read) > 0)
             {
                 result |= FileShare.Read;
             }
 
-            if ((shareAccess & ShareAccess.FILE_SHARE_WRITE) > 0)
+            if ((shareAccess & ShareAccess.Write) > 0)
             {
                 result |= FileShare.Write;
             }
 
-            if ((shareAccess & ShareAccess.FILE_SHARE_DELETE) > 0)
+            if ((shareAccess & ShareAccess.Delete) > 0)
             {
                 result |= FileShare.Delete;
             }
@@ -121,7 +121,7 @@ namespace SMBLibrary
         {
             object handle;
             FileStatus fileStatus;
-            NTStatus openStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)FileAccessMask.FILE_READ_ATTRIBUTES, 0, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.FILE_OPEN, 0, securityContext);
+            NTStatus openStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)FileAccessMask.FILE_READ_ATTRIBUTES, 0, ShareAccess.Read | ShareAccess.Write, CreateDisposition.FILE_OPEN, 0, securityContext);
             if (openStatus != NTStatus.STATUS_SUCCESS)
             {
                 return null;

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

@@ -144,7 +144,7 @@ namespace SMBLibrary.Server.SMB1
         {
             if (sharingMode == SharingMode.Compatibility)
             {
-                return ShareAccess.FILE_SHARE_READ;
+                return ShareAccess.Read;
             }
             else if (sharingMode == SharingMode.DenyReadWriteExecute)
             {
@@ -152,15 +152,15 @@ namespace SMBLibrary.Server.SMB1
             }
             else if (sharingMode == SharingMode.DenyWrite)
             {
-                return ShareAccess.FILE_SHARE_READ;
+                return ShareAccess.Read;
             }
             else if (sharingMode == SharingMode.DenyReadExecute)
             {
-                return ShareAccess.FILE_SHARE_WRITE;
+                return ShareAccess.Write;
             }
             else if (sharingMode == SharingMode.DenyNothing)
             {
-                return ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE;
+                return ShareAccess.Read | ShareAccess.Write;
             }
             else if (sharingMode == (SharingMode)0xFF)
             {

+ 2 - 2
SMBLibrary/Server/SMB1/SMB1FileStoreHelper.Query.cs

@@ -18,7 +18,7 @@ namespace SMBLibrary.Server.SMB1
         {
             object handle;
             FileStatus fileStatus;
-            NTStatus openStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)FileAccessMask.FILE_READ_ATTRIBUTES, 0, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.FILE_OPEN, 0, securityContext);
+            NTStatus openStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)FileAccessMask.FILE_READ_ATTRIBUTES, 0, ShareAccess.Read | ShareAccess.Write, CreateDisposition.FILE_OPEN, 0, securityContext);
             if (openStatus != NTStatus.STATUS_SUCCESS)
             {
                 result = null;
@@ -33,7 +33,7 @@ namespace SMBLibrary.Server.SMB1
         {
             object handle;
             FileStatus fileStatus;
-            NTStatus openStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)FileAccessMask.FILE_READ_ATTRIBUTES, 0, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.FILE_OPEN, 0, securityContext);
+            NTStatus openStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)FileAccessMask.FILE_READ_ATTRIBUTES, 0, ShareAccess.Read | ShareAccess.Write, CreateDisposition.FILE_OPEN, 0, securityContext);
             if (openStatus != NTStatus.STATUS_SUCCESS)
             {
                 result = null;

+ 1 - 1
SMBLibrary/Server/SMB1/SMB1FileStoreHelper.QueryDirectory.cs

@@ -33,7 +33,7 @@ namespace SMBLibrary.Server.SMB1
                 FileStatus fileStatus;
                 DirectoryAccessMask accessMask = DirectoryAccessMask.FILE_LIST_DIRECTORY | DirectoryAccessMask.FILE_TRAVERSE | DirectoryAccessMask.SYNCHRONIZE;
                 CreateOptions createOptions = CreateOptions.FILE_DIRECTORY_FILE | CreateOptions.FILE_SYNCHRONOUS_IO_NONALERT;
-                NTStatus status = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)accessMask, 0, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.FILE_OPEN, createOptions, securityContext);
+                NTStatus status = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)accessMask, 0, ShareAccess.Read | ShareAccess.Write, CreateDisposition.FILE_OPEN, createOptions, securityContext);
                 if (status != NTStatus.STATUS_SUCCESS)
                 {
                     result = null;

+ 6 - 6
SMBLibrary/Server/SMB1/SMB1FileStoreHelper.cs

@@ -18,7 +18,7 @@ namespace SMBLibrary.Server.SMB1
         {
             object handle;
             FileStatus fileStatus;
-            NTStatus createStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)DirectoryAccessMask.FILE_ADD_SUBDIRECTORY, 0, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.FILE_CREATE, CreateOptions.FILE_DIRECTORY_FILE, securityContext);
+            NTStatus createStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)DirectoryAccessMask.FILE_ADD_SUBDIRECTORY, 0, ShareAccess.Read | ShareAccess.Write, CreateDisposition.FILE_CREATE, CreateOptions.FILE_DIRECTORY_FILE, securityContext);
             if (createStatus != NTStatus.STATUS_SUCCESS)
             {
                 return createStatus;
@@ -41,7 +41,7 @@ namespace SMBLibrary.Server.SMB1
         {
             object handle;
             FileStatus fileStatus;
-            ShareAccess shareAccess = ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE | ShareAccess.FILE_SHARE_DELETE;
+            ShareAccess shareAccess = ShareAccess.Read | ShareAccess.Write | ShareAccess.Delete;
             NTStatus status = fileStore.CreateFile(out handle, out fileStatus, path, AccessMask.DELETE, 0, shareAccess, CreateDisposition.FILE_OPEN, createOptions, securityContext);
             if (status != NTStatus.STATUS_SUCCESS)
             {
@@ -65,7 +65,7 @@ namespace SMBLibrary.Server.SMB1
             {
                 createOptions = CreateOptions.FILE_NON_DIRECTORY_FILE;
             }
-            ShareAccess shareAccess = ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE | ShareAccess.FILE_SHARE_DELETE;
+            ShareAccess shareAccess = ShareAccess.Read | ShareAccess.Write | ShareAccess.Delete;
             NTStatus status = fileStore.CreateFile(out handle, out fileStatus, oldName, AccessMask.DELETE, 0, shareAccess, CreateDisposition.FILE_OPEN, createOptions, securityContext);
             if (status != NTStatus.STATUS_SUCCESS)
             {
@@ -83,7 +83,7 @@ namespace SMBLibrary.Server.SMB1
         {
             object handle;
             FileStatus fileStatus;
-            NTStatus openStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)0, 0, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.FILE_OPEN, CreateOptions.FILE_DIRECTORY_FILE, securityContext);
+            NTStatus openStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)0, 0, ShareAccess.Read | ShareAccess.Write, CreateDisposition.FILE_OPEN, CreateOptions.FILE_DIRECTORY_FILE, securityContext);
             if (openStatus != NTStatus.STATUS_SUCCESS)
             {
                 return openStatus;
@@ -97,7 +97,7 @@ namespace SMBLibrary.Server.SMB1
         {
             object handle;
             FileStatus fileStatus;
-            NTStatus openStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)FileAccessMask.FILE_READ_ATTRIBUTES, 0, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.FILE_OPEN, 0, securityContext);
+            NTStatus openStatus = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)FileAccessMask.FILE_READ_ATTRIBUTES, 0, ShareAccess.Read | ShareAccess.Write, CreateDisposition.FILE_OPEN, 0, securityContext);
             if (openStatus != NTStatus.STATUS_SUCCESS)
             {
                 fileInfo = null;
@@ -113,7 +113,7 @@ namespace SMBLibrary.Server.SMB1
         {
             object handle;
             FileStatus fileStatus;
-            NTStatus status = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)FileAccessMask.FILE_WRITE_ATTRIBUTES, (FileAttributes)0, ShareAccess.FILE_SHARE_READ | ShareAccess.FILE_SHARE_WRITE, CreateDisposition.FILE_OPEN, 0, securityContext);
+            NTStatus status = fileStore.CreateFile(out handle, out fileStatus, path, (AccessMask)FileAccessMask.FILE_WRITE_ATTRIBUTES, (FileAttributes)0, ShareAccess.Read | ShareAccess.Write, CreateDisposition.FILE_OPEN, 0, securityContext);
             if (status != NTStatus.STATUS_SUCCESS)
             {
                 return status;

+ 1 - 1
SMBLibrary/Win32/NTFileStore/NTDirectoryFileSystem.cs

@@ -354,7 +354,7 @@ namespace SMBLibrary.Win32
             IntPtr volumeHandle;
             FileStatus fileStatus;
             string nativePath = @"\??\" + m_directory.FullName.Substring(0, 3);
-            NTStatus status = CreateFile(out volumeHandle, out fileStatus, nativePath, AccessMask.GENERIC_READ, 0, (FileAttributes)0, ShareAccess.FILE_SHARE_READ, CreateDisposition.FILE_OPEN, (CreateOptions)0);
+            NTStatus status = CreateFile(out volumeHandle, out fileStatus, nativePath, AccessMask.GENERIC_READ, 0, (FileAttributes)0, ShareAccess.Read, CreateDisposition.FILE_OPEN, (CreateOptions)0);
             result = null;
             if (status != NTStatus.STATUS_SUCCESS)
             {