internal static extern System.IntPtr CreateFile(string lpFileName,
                                                 [MarshalAs(UnmanagedType.U4)] EFileAccess dwDesiredAccess,
                                                 [MarshalAs(UnmanagedType.U4)] EFileShare dwShareMode,
                                                 System.IntPtr lpSecurityAttributes,
                                                 [MarshalAs(UnmanagedType.U4)] ECreationDisposition dwCreationDisposition,
                                                 [MarshalAs(UnmanagedType.U4)] uint dwFlagsAndAttributes,
                                                 System.IntPtr hTemplateFile);
Exemple #2
0
 internal static extern SafeFileHandle CreateFile(string lpFileName,
                                                  EFileAccess dwDesiredAccess,
                                                  EFileShare dwShareMode,
                                                  IntPtr lpSecurityAttributes,
                                                  ECreationDisposition dwCreationDisposition,
                                                  EFileAttributes dwFlagsAndAttributes,
                                                  IntPtr hTemplateFile);
 private static extern IntPtr CreateFile(
     [MarshalAs(UnmanagedType.LPTStr)] string lpFileName,
     [MarshalAs(UnmanagedType.U4)] EFileAccess dwDesiredAccess,
     [MarshalAs(UnmanagedType.U4)] EFileShare dwShareMode,
     [MarshalAs(UnmanagedType.SysInt)] IntPtr lpSecurityAttributes,
     [MarshalAs(UnmanagedType.U4)] ECreationDisposition dwCreationDisposition,
     [MarshalAs(UnmanagedType.U4)] EFileAttributes dwFlagsAndAttributes,
     [MarshalAs(UnmanagedType.U4)] uint hTemplateFile);
Exemple #4
0
 public static extern SafeFileHandle CreateFile(
     [In][MarshalAs(UnmanagedType.LPWStr)] string filename,
     [In][MarshalAs(UnmanagedType.U4)] EFileAccess dwDesiredAccess,
     [In][MarshalAs(UnmanagedType.U4)] EFileShare dwShareMode,
     [In, Optional] IntPtr lpSecurityAttributes,
     [In][MarshalAs(UnmanagedType.U4)] ECreationDisposition dwCreationDisposition,
     [In][MarshalAs(UnmanagedType.U4)] EFileAttributes dwFlagsAndAttributes,
     [In, Optional] IntPtr hTemplateFile);
Exemple #5
0
		private static extern IntPtr CreateFile(
			string lpFileName,
			EFileAccess dwDesiredAccess,
			EFileShare dwShareMode,
			IntPtr lpSecurityAttributes,
			ECreationDisposition dwCreationDisposition,
			EFileAttributes dwFlagsAndAttributes,
			IntPtr hTemplateFile);
Exemple #6
0
 public static extern IntPtr CreateFile(
     [MarshalAs(UnmanagedType.LPTStr)] string filename,
     [MarshalAs(UnmanagedType.U4)] EFileAccess access,
     [MarshalAs(UnmanagedType.U4)] EFileShare share,
     IntPtr securityAttributes,
     [MarshalAs(UnmanagedType.U4)] ECreationDisposition creationDisposition,
     [MarshalAs(UnmanagedType.U4)] EFileAttributes flagsAndAttributes,
     IntPtr templateFile);
 public static extern IntPtr CreateFile(
     [MarshalAs(UnmanagedType.LPTStr)] string filename,
     [MarshalAs(UnmanagedType.U4)] EFileAccess access,
     [MarshalAs(UnmanagedType.U4)] EFileShare share,
     IntPtr securityAttributes, // optional SECURITY_ATTRIBUTES struct or IntPtr.Zero
     [MarshalAs(UnmanagedType.U4)] ECreationDisposition creationDisposition,
     [MarshalAs(UnmanagedType.U4)] EFileAttributes flagsAndAttributes,
     IntPtr templateFile);
Exemple #8
0
 private static extern IntPtr CreateFile(
     string fileName,
     EFileAccess fileAccess,
     EFileShare fileShare,
     IntPtr securityAttributes,
     ECreationDisposition creationDisposition,
     EFileAttributes flags,
     IntPtr template);
Exemple #9
0
 private static extern IntPtr CreateFile(
     String lpFileName,
     EFileAccess dwDesiredAccess,
     EFileShare dwShareMode,
     IntPtr lpSecurityAttributes,
     ECreationDisposition dwCreationDisposition,
     EFileAttributes dwFlagsAndAttributes,
     IntPtr hTemplateFile);
 internal static extern SafeFileHandle CreateFile(
     string fileName,
     [MarshalAs(UnmanagedType.U4)] EFileAccess fileAccess,
     [MarshalAs(UnmanagedType.U4)] EFileShare shareMode,
     IntPtr securityAttributes,
     [MarshalAs(UnmanagedType.U4)] ECreationDisposition creationDisposition,
     EFileAttributes flagsAndAttributes,
     SafeFileHandle templateFile);
Exemple #11
0
 public static extern SafeFileHandle CreateFile(
     [MarshalAs(UnmanagedType.LPTStr)] string lpFileName,
     [MarshalAs(UnmanagedType.U4)] EFileAccess dwDesiredAccess,
     [MarshalAs(UnmanagedType.U4)] EFileShare dwShareMode,
     IntPtr lpSecurityAttributes, // optional SECURITY_ATTRIBUTES struct or IntPtr.Zero
     [MarshalAs(UnmanagedType.U4)] ECreationDisposition dwCreationDisposition,
     [MarshalAs(UnmanagedType.U4)] EFileAttributes dwFlagsAndAttributes,
     IntPtr hTemplateFile);
Exemple #12
0
 public IntPtr OpenWrite(ECreationDisposition method)
 {
     Handle          =
         writeHandle =
             CreateFileW(Path, EFileAccess.GenericWrite, EFileShare.Read | EFileShare.Write,
                         IntPtr.Zero, method, EFileAttributes.Normal, IntPtr.Zero);
     SetHandleInformation(Handle, HANDLE_FLAGS.INHERIT, HANDLE_FLAGS.INHERIT);
     return(Handle);
 }
 public static extern SafeFileHandle CreateFile(
       string lpFileName,
       EFileAccess dwDesiredAccess,
       EFileShare dwShareMode,
       IntPtr SecurityAttributes,
       ECreationDisposition dwCreationDisposition,
       EFileAttributes dwFlagsAndAttributes,
       IntPtr hTemplateFile
       );
Exemple #14
0
        //
        // These are wrappers that translate error codes
        // into exceptions to make error handling easier
        //
        private static IntPtr CreateFileNet(
            string lpFileName,
            EFileAccess dwDesiredAccess,
            EFileShare dwShareMode,
            IntPtr lpSecurityAttributes,
            ECreationDisposition dwCreationDisposition,
            EFileAttributes dwFlagsAndAttributes,
            IntPtr hTemplateFile)
        {
            IntPtr ret = CreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);

            //If == INVALID_HANDLE_VALUE
            if (ret.ToInt32() == -1)
            {
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }
            return(ret);
        }
Exemple #15
0
        public static IntPtr _CreateFile(
            string lpFileName,
            EFileAccess dwDesiredAccess,
            EFileShare dwShareMode,
            ECreationDisposition dwCreationDisposition,
            EFileAttributes dwFlagsAndAttributes,
            IntPtr hTemplateFile
            )
        {
            SECURITY_DESCRIPTOR sd = new SECURITY_DESCRIPTOR();

            InitializeSecurityDescriptor(ref sd, SECURITY_DESCRIPTOR_REVISION);
            SetSecurityDescriptorDacl(ref sd, true, IntPtr.Zero, false);
            GCHandle sdHandle = GCHandle.Alloc(sd, GCHandleType.Pinned);

            SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES();

            sa.nLength = Marshal.SizeOf(sa);
            sa.lpSecurityDescriptor = sdHandle.AddrOfPinnedObject();
            sa.bInheritHandle       = 0;
            GCHandle saHandle = GCHandle.Alloc(sa, GCHandleType.Pinned);

            System.IntPtr hFile = IntPtr.Zero;
            hFile = CreateFile(
                lpFileName,
                dwDesiredAccess,
                dwShareMode,
                saHandle.AddrOfPinnedObject(),
                dwCreationDisposition,
                dwFlagsAndAttributes,
                hTemplateFile
                );

            saHandle.Free();
            sdHandle.Free();
            if (hFile == (System.IntPtr)(int) - 1)
            {
                return(IntPtr.Zero);
            }
            return(hFile);
        }
Exemple #16
0
 private static extern IntPtr CreateFile(
    string fileName,
    EFileAccess fileAccess,
    EFileShare fileShare,
    IntPtr securityAttributes,
    ECreationDisposition creationDisposition,
    EFileAttributes flags,
    IntPtr template);
 public static extern IntPtr CreateFile(string filename, int desiredAccess, int shareMode, IntPtr securityAttributes, ECreationDisposition creationDisposition, int flags, IntPtr template);
Exemple #18
0
        static SafeFileHandle open(string filePath, string streamName, EFileAccess access, ECreationDisposition mode)
        {
            var sfh = CreateFile($"{filePath}:{streamName}", access, EFileShare.Read, IntPtr.Zero,
                                 mode, EFileAttributes.Normal, IntPtr.Zero);

            if (sfh.IsInvalid)
            {
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }
            return(sfh);
        }
 private static extern IntPtr CreateFile(string fileName, EFileAccess desiredAccess, EFileShare shareMode, IntPtr securityAttributes, ECreationDisposition creationDisposition, EFileAttributes flagsAndAttributes, IntPtr templateFile);
 public extern static IntPtr CreateFile(string filename, int desiredAccess, int shareMode, IntPtr securityAttributes, ECreationDisposition creationDisposition, int flags, IntPtr template);
Exemple #21
0
 private static extern SafeFileHandle CreateFile(string fileName, EAccessMode accessMode,
                                                 EShareMode shareMode, IntPtr lpSecurityAttributes, ECreationDisposition creationDisposition,
                                                 uint dwFlagsAndAttributes, IntPtr hTemplateFile);
Exemple #22
0
 private static extern IntPtr CreateFile(string fileName, EFileAccess desiredAccess, EFileShare shareMode, IntPtr securityAttributes, ECreationDisposition creationDisposition, EFileAttributes flagsAndAttributes, IntPtr templateFile);
 private void *CreateFileHook(string FileName, EFileAccess Access, EFileShare Share, void *SecurityAttributes, ECreationDisposition CreationDisposition, EFileAttributes FlagsAndAttributes, void *TemplateFile)
 {
     FileName = OnCreateFile?.Invoke(FileName);
     return(Bypass(FileName, Access, Share, SecurityAttributes, CreationDisposition, FlagsAndAttributes, TemplateFile));
 }
 public static extern IntPtr CreateFile(string filename, EFileAccess desiredAccess, EFileShare shareMode, IntPtr securityAttributes,
     ECreationDisposition creationDisposition, EFileAttributes attributes, IntPtr template);
Exemple #25
0
 public static extern IntPtr BoxedAppSDK_CreateVirtualFileBasedOnIStream(string lpFileName, EFileAccess dwDesiredAccess, EFileShare dwShareMode, IntPtr lpSecurityAttributes, ECreationDisposition dwCreationDisposition, EFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile, IStream Stream);
Exemple #26
0
 public static extern IntPtr CreateFile(string filename, EFileAccess desiredAccess,
                                        EFileShare shareMode, IntPtr securityAttributes,
                                        ECreationDisposition creationDisposition, EFileAttributes attributes, IntPtr template);
Exemple #27
0
        public static IntPtr _CreateFile(
           string lpFileName,
           EFileAccess dwDesiredAccess,
           EFileShare dwShareMode,
           ECreationDisposition dwCreationDisposition,
           EFileAttributes dwFlagsAndAttributes,
           IntPtr hTemplateFile
            )
        {
            SECURITY_DESCRIPTOR sd = new SECURITY_DESCRIPTOR();
            InitializeSecurityDescriptor(ref sd, SECURITY_DESCRIPTOR_REVISION);
            SetSecurityDescriptorDacl(ref sd, true, IntPtr.Zero, false);
            GCHandle sdHandle = GCHandle.Alloc(sd, GCHandleType.Pinned); 

            SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES();
            sa.nLength = Marshal.SizeOf(sa);
            sa.lpSecurityDescriptor = sdHandle.AddrOfPinnedObject(); 
            sa.bInheritHandle = 0;
            GCHandle saHandle = GCHandle.Alloc(sa, GCHandleType.Pinned); 

            System.IntPtr hFile = IntPtr.Zero;
            hFile = CreateFile(
                lpFileName,
                dwDesiredAccess,
                dwShareMode,
                saHandle.AddrOfPinnedObject(),
                dwCreationDisposition,
                dwFlagsAndAttributes,
                hTemplateFile
            );

            saHandle.Free();
            sdHandle.Free();
            if (hFile == (System.IntPtr)(int)-1)
            {
                return IntPtr.Zero;
            }
            return hFile;
        }
Exemple #28
0
 internal static extern SafeFileHandle CreateFileW(
     string lpFileName,
     EFileAccess dwDesiredAccess,
     EFileShare dwShareMode,
     SECURITY_ATTRIBUTES lpSecurityAttributes,
     ECreationDisposition dwCreationDisposition,
     EFileAttributes dwFlagsAndAttributes,
     IntPtr hTemplateFile);