public static unsafe NativeFileObject Open(string fileName, FileObjectAccessRights accessRights, FileShareMode shareMode, FileDisposition disposition, FileAttributes attributes) { SafeFileObjectHandle handle = CreateFileW(fileName, (uint)accessRights, (uint)shareMode, null, (uint)disposition, (uint)attributes, SafeFileObjectHandle.InvalidHandle); if (handle.IsInvalid) { throw new Win32Exception(); } return(new NativeFileObject(handle)); }
internal static unsafe extern SafeFileMappingHandle CreateFileMappingA(SafeFileObjectHandle fileHandle, [Optional] SecurityAttributes *securityAttributes, UInt32 flProtect, UInt32 dwMaximumSizeHigh, UInt32 dwMaximumSizeLow, [MarshalAs(UnmanagedType.LPStr)] string name);
internal static extern bool UnlockFileNative(SafeFileObjectHandle handle, UInt32 offsetLow, UInt32 offsetHigh, UInt32 sizeLow, UInt32 sizeHigh);
internal static extern FileObjectType GetFileType(SafeFileObjectHandle handle);
internal static extern unsafe SafeFileObjectHandle CreateFileW([MarshalAs(UnmanagedType.LPWStr)] string fileName, UInt32 desiredAccess, UInt32 shareMode, SecurityAttributes *securityAttributes, UInt32 creationDisposition, UInt32 flagsAndAttributes, SafeFileObjectHandle template);
internal static extern unsafe bool DeviceIoControl(SafeFileObjectHandle handle, DeviceIoControlCode controlCode, void *inBuffer, uint inBufferLength, void *outBuffer, uint outBufferLength, out uint returnSize, void *lpOverlapped);
public NativeFileObject(FileStream stream) { this.handle = new SafeFileObjectHandle(stream.SafeFileHandle); }
internal NativeFileObject(SafeFileObjectHandle handle) { this.handle = handle; }