Beispiel #1
0
 public static extern IntPtr CreateFile(
     string fileName,
     FileAccessRightFlags desiredAccess,
     FileShareModeFlags shareMode,
     IntPtr securityAttributes,
     FileCreationDisposition creationDisposition,
     FileFlagsAndAttributes flagsAndAttributes,
     IntPtr templateFile);
 public static extern IntPtr CreateFile(
     string fileName,
     FileAccessRightFlags desiredAccess,
     FileShareModeFlags shareMode,
     IntPtr securityAttributes,
     FileCreationDisposition creationDisposition,
     FileFlagsAndAttributes flagsAndAttributes,
     IntPtr templateFile);
 /// <summary>
 /// Handles intercepted file access.
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="desiredAccess"></param>
 /// <param name="shareMode"></param>
 /// <param name="securityAttributes"></param>
 /// <param name="creationDisposition"></param>
 /// <param name="flagsAndAttributes"></param>
 /// <param name="templateFile"></param>
 /// <returns></returns>
 public IntPtr CreateFile(string fileName, FileAccessRightFlags desiredAccess, FileShareModeFlags shareMode,
                            IntPtr securityAttributes, FileCreationDisposition creationDisposition,
                            FileFlagsAndAttributes flagsAndAttributes, IntPtr templateFile)
 {
   var request = new FileRequest
   {
     CreationDisposition = creationDisposition,
     Path = fileName,
     ResourceType = ResourceType.File
   };
   using (EngineCore.Engine.GetEngineProcessingSpace())
   {
     var virtualPath = _fileSystem.GetVirtualPath(request);
     return HostFileSystem.NativeMethods.CreateFile(
       virtualPath, desiredAccess, shareMode, securityAttributes,
       creationDisposition, flagsAndAttributes, templateFile);
   }
 }
Beispiel #4
0
        /// <summary>
        /// Handles intercepted file access.
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="desiredAccess"></param>
        /// <param name="shareMode"></param>
        /// <param name="securityAttributes"></param>
        /// <param name="creationDisposition"></param>
        /// <param name="flagsAndAttributes"></param>
        /// <param name="templateFile"></param>
        /// <returns></returns>
        public IntPtr CreateFile(string fileName, FileAccessRightFlags desiredAccess, FileShareModeFlags shareMode,
                                 IntPtr securityAttributes, FileCreationDisposition creationDisposition,
                                 FileFlagsAndAttributes flagsAndAttributes, IntPtr templateFile)
        {
            var request = new FileRequest
            {
                CreationDisposition = creationDisposition,
                Path         = fileName,
                ResourceType = ResourceType.File
            };

            using (EngineCore.Engine.GetEngineProcessingSpace())
            {
                var virtualPath = _fileSystem.GetVirtualPath(request);
                return(HostFileSystem.NativeMethods.CreateFile(
                           virtualPath, desiredAccess, shareMode, securityAttributes,
                           creationDisposition, flagsAndAttributes, templateFile));
            }
        }