Beispiel #1
0
        private static Int32 ResolveReparsePoints(
            IntPtr FileSystemPtr,
            String FileName,
            UInt32 ReparsePointIndex,
            Boolean ResolveLastPathComponent,
            out IoStatusBlock PIoStatus,
            IntPtr Buffer,
            IntPtr PSize)
        {
            FileSystemBase FileSystem = (FileSystemBase)Api.GetUserContext(FileSystemPtr);

            try
            {
                return(FileSystem.ResolveReparsePoints(
                           FileName,
                           ReparsePointIndex,
                           ResolveLastPathComponent,
                           out PIoStatus,
                           Buffer,
                           PSize));
            }
            catch (Exception ex)
            {
                PIoStatus = default(IoStatusBlock);
                return(ExceptionHandler(FileSystem, ex));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Resolves reparse points.
        /// </summary>
        public virtual Int32 ResolveReparsePoints(
            String FileName,
            UInt32 ReparsePointIndex,
            Boolean ResolveLastPathComponent,
            out IoStatusBlock IoStatus,
            IntPtr Buffer,
            IntPtr PSize)
        {
            GCHandle Handle = GCHandle.Alloc(this, GCHandleType.Normal);

            try
            {
                return(Api.FspFileSystemResolveReparsePoints(
                           IntPtr.Zero,
                           GetReparsePointByName,
                           (IntPtr)Handle,
                           FileName,
                           ReparsePointIndex,
                           ResolveLastPathComponent,
                           out IoStatus,
                           Buffer,
                           PSize));
            }
            finally
            {
                Handle.Free();
            }
        }
 public static extern int NtOpenFile(
     out IntPtr FileHandle,
     FileAccessRights DesiredAccess,
     ObjectAttributes ObjAttr,
     [In][Out] IoStatusBlock IoStatusBlock,
     ShareMode ShareAccess,
     FileOpenOptions OpenOptions);
 public static extern int NtDeviceIoControlFile(
     SafeFileHandle FileHandle,
     IntPtr Event,
     IntPtr ApcRoutine,
     IntPtr ApcContext,
     [In][Out] IoStatusBlock IoStatusBlock,
     uint IoControlCode,
     SafeHGlobalBuffer InputBuffer,
     int InputBufferLength,
     SafeHGlobalBuffer OutputBuffer,
     int OutputBufferLength
     );
Beispiel #5
0
        public bool Remove(out IoStatusBlock isb, out IntPtr keyContext, out IntPtr apcContext, long timeout, bool relative)
        {
            NtStatus status;
            long     realTimeout = relative ? -timeout : timeout;

            if ((status = Win32.NtRemoveIoCompletion(
                     this, out keyContext, out apcContext, out isb, ref realTimeout)) >= NtStatus.Error)
            {
                Win32.Throw(status);
            }

            return(status != NtStatus.Timeout);
        }
            static T DeviceIoControl <T>(SafeFileHandle FileHandle, uint IoControlCode, object input_buffer)
            {
                using (SafeStructureOutBuffer <T> output = new SafeStructureOutBuffer <T>())
                {
                    using (SafeStructureBuffer input = new SafeStructureBuffer(input_buffer))
                    {
                        IoStatusBlock status = new IoStatusBlock();
                        StatusToNtException(NtDeviceIoControlFile(FileHandle, IntPtr.Zero, IntPtr.Zero,
                                                                  IntPtr.Zero, status, IoControlCode, input, input.Length,
                                                                  output, output.Length));

                        return(output.Result);
                    }
                }
            }
            public static SafeFileHandle OpenFile(string name, FileAccessRights DesiredAccess, ShareMode ShareAccess, FileOpenOptions OpenOptions, bool inherit)
            {
                AttributeFlags flags = AttributeFlags.CaseInsensitive;

                if (inherit)
                {
                    flags |= AttributeFlags.Inherit;
                }
                using (ObjectAttributes obja = new ObjectAttributes(name, flags))
                {
                    IntPtr        handle;
                    IoStatusBlock iostatus = new IoStatusBlock();
                    StatusToNtException(NtOpenFile(out handle, DesiredAccess, obja, iostatus, ShareAccess, OpenOptions));
                    return(new SafeFileHandle(handle, true));
                }
            }
Beispiel #8
0
 public static extern NtStatus NtFsControlFile([In] IntPtr fileHandle, [In, Optional] IntPtr Event, [In, Optional] IntPtr apcRoutine, [In, Optional] IntPtr apcContext, [Out] out IoStatusBlock ioStatusBlock, [In] uint fsControlCode, [In, Optional] IntPtr inputBuffer, [In] uint inputBufferLength, [Out, Optional] IntPtr outputBuffer, [In] uint outputBufferLength);
Beispiel #9
0
        public bool Remove(out IoStatusBlock isb, out IntPtr keyContext, out IntPtr apcContext, long timeout, bool relative)
        {
            long realTimeout = relative ? -timeout : timeout;

            return(Win32.NtRemoveIoCompletion(this, out keyContext, out apcContext, out isb, ref realTimeout) != NtStatus.Timeout);
        }
Beispiel #10
0
 public bool Remove(out IoStatusBlock isb, out IntPtr keyContext, out IntPtr apcContext, long timeout)
 {
     return(this.Remove(out isb, out keyContext, out apcContext, timeout, true));
 }
Beispiel #11
0
 private static extern int NtQueryInformationFile(IntPtr fileHandle, ref IoStatusBlock ioStatusBlock, IntPtr fileInformation, int length, int fileInformationClass);
Beispiel #12
0
 private static extern int NtCreateFile(ref IntPtr fileHandle, int desiredAccess, ref ObjectAttributes objectAttributes, ref IoStatusBlock ioStatusBlock, int allocationSize, int fileAttribs, int sharedAccess, int creationDisposition, int createOptions, int eaBuffer,
                                        int eaLength);