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);
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);
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);
private static extern IntPtr CreateFile( string lpFileName, EFileAccess dwDesiredAccess, EFileShare dwShareMode, IntPtr lpSecurityAttributes, ECreationDisposition dwCreationDisposition, EFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile);
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);
private static extern IntPtr CreateFile( string fileName, EFileAccess fileAccess, EFileShare fileShare, IntPtr securityAttributes, ECreationDisposition creationDisposition, EFileAttributes flags, IntPtr template);
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);
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);
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 );
// // 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); }
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); }
public static extern IntPtr CreateFile(string filename, int desiredAccess, int shareMode, IntPtr securityAttributes, ECreationDisposition creationDisposition, int flags, IntPtr template);
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);
private static extern SafeFileHandle CreateFile(string fileName, EAccessMode accessMode, EShareMode shareMode, IntPtr lpSecurityAttributes, ECreationDisposition creationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
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);
public static extern IntPtr BoxedAppSDK_CreateVirtualFileBasedOnIStream(string lpFileName, EFileAccess dwDesiredAccess, EFileShare dwShareMode, IntPtr lpSecurityAttributes, ECreationDisposition dwCreationDisposition, EFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile, IStream Stream);
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; }
internal static extern SafeFileHandle CreateFileW( string lpFileName, EFileAccess dwDesiredAccess, EFileShare dwShareMode, SECURITY_ATTRIBUTES lpSecurityAttributes, ECreationDisposition dwCreationDisposition, EFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile);