示例#1
0
 internal static extern NTSTATUS NtQueryDirectoryFile(
     SafeFileHandle fileHandle,
     IntPtr eventHandle,
     IntPtr apcRoutime,
     IntPtr appContext,
     ref IO_STATUS_BLOCK ioStatusBlock,
     IntPtr FileInformation,
     UInt32 length,
     FILE_INFORMATION_CLASS fileInformationClass,
     [MarshalAs(UnmanagedType.Bool)] bool returnSingleEntry,
     IntPtr fileName,
     [MarshalAs(UnmanagedType.Bool)] bool restartScan);
 public static unsafe extern int NtQueryDirectoryFile(
     IntPtr FileHandle,
     IntPtr Event,
     IntPtr ApcRoutine,
     IntPtr ApcContext,
     IO_STATUS_BLOCK *IoStatusBlock,
     IntPtr FileInformation,
     uint Length,
     FILE_INFORMATION_CLASS FileInformationClass,
     BOOLEAN ReturnSingleEntry,
     UNICODE_STRING *FileName,
     BOOLEAN RestartScan);
示例#3
0
        unsafe private static void GetFileInformation(SafeFileHandle fileHandle, FILE_INFORMATION_CLASS fileInformationClass, void *value, uint size)
        {
            IO_STATUS_BLOCK ioStatus;

            NTSTATUS status = Direct.NtQueryInformationFile(
                FileHandle: fileHandle,
                IoStatusBlock: out ioStatus,
                FileInformation: value,
                Length: size,
                FileInformationClass: fileInformationClass);

            if (status != NTSTATUS.STATUS_SUCCESS)
            {
                throw ErrorHelper.GetIoExceptionForNTStatus(status);
            }
        }
示例#4
0
        private static string GetFileInformationString(SafeFileHandle fileHandle, FILE_INFORMATION_CLASS fileInformationClass)
        {
            return(BufferHelper.CachedInvoke((StringBuffer buffer) =>
            {
                NTSTATUS status = NTSTATUS.STATUS_BUFFER_OVERFLOW;
                uint nameLength = 260 * sizeof(char);

                IO_STATUS_BLOCK ioStatus;
                var reader = new CheckedReader(buffer);

                while (status == NTSTATUS.STATUS_BUFFER_OVERFLOW)
                {
                    // Add space for the FileNameLength
                    buffer.EnsureByteCapacity(nameLength + sizeof(uint));

                    unsafe
                    {
                        status = Direct.NtQueryInformationFile(
                            FileHandle: fileHandle,
                            IoStatusBlock: out ioStatus,
                            FileInformation: buffer.VoidPointer,
                            Length: checked ((uint)buffer.ByteCapacity),
                            FileInformationClass: fileInformationClass);
                    }

                    if (status == NTSTATUS.STATUS_SUCCESS || status == NTSTATUS.STATUS_BUFFER_OVERFLOW)
                    {
                        reader.ByteOffset = 0;
                        nameLength = reader.ReadUint();
                    }
                }

                if (status != NTSTATUS.STATUS_SUCCESS)
                {
                    throw ErrorHelper.GetIoExceptionForNTStatus(status);
                }

                // The string isn't null terminated so we have to explicitly pass the size
                return reader.ReadString(checked ((int)nameLength) / sizeof(char));
            }));
        }
示例#5
0
 private static extern NTSTATUS NtQueryInformationFile(IntPtr FileHandle,
     ref IO_STATUS_BLOCK IoStatusBlock, IntPtr FileInformation, int FileInformationLength, 
     FILE_INFORMATION_CLASS FileInformationClass);
示例#6
0
 public static extern int NtSetInformationFile(
     SafeFileHandle FileHandle,
     ref IO_STATUS_BLOCK ioStatus,
     IntPtr FileInformation,
     Int32 Length,
     FILE_INFORMATION_CLASS fileClass);
示例#7
0
 public static extern IntPtr NtQueryInformationFile(IntPtr fileHandle, ref IO_STATUS_BLOCK IoStatusBlock, IntPtr pInfoBlock, uint length, FILE_INFORMATION_CLASS fileInformation);
示例#8
0
 private static extern NTSTATUS NtQueryInformationFile(IntPtr FileHandle,
                                                       ref IO_STATUS_BLOCK IoStatusBlock, IntPtr FileInformation, int FileInformationLength,
                                                       FILE_INFORMATION_CLASS FileInformationClass);
 public static extern NTSTATUS NtSetInformationFile(
     IntPtr FileHandle,
     ref IO_STATUS_BLOCK IoStatusBlock,
     ref FILE_CASE_SENSITIVE_INFORMATION FileInformation,
     int Length,
     FILE_INFORMATION_CLASS FileInformationClass);
示例#10
0
 unsafe public static extern NTSTATUS NtQueryInformationFile(
     SafeFileHandle FileHandle,
     out IO_STATUS_BLOCK IoStatusBlock,
     void *FileInformation,
     uint Length,
     FILE_INFORMATION_CLASS FileInformationClass);
示例#11
0
      public static extern uint NtQueryInformationFile(SafeFileHandle FileHandle,
 ref IO_STATUS_BLOCK IoStatusBlock, IntPtr FileInformation, uint Length,
 FILE_INFORMATION_CLASS FileInformationClass);
 static extern Int32 NtQueryInformationFile(SafeHandle handle, out IO_STATUS_BLOCK ioStatusBlock,
                                            out FILE_STANDARD_INFORMATION info, Int32 length, FILE_INFORMATION_CLASS fileInformationClass);
示例#13
0
 static extern uint NtSetInformationFile(IntPtr FileHandle,
                                         IO_STATUS_BLOCK IoStatusBlock,
                                         IntPtr FileInformation,
                                         uint Length,
                                         FILE_INFORMATION_CLASS FileInformationClass);
示例#14
0
 public static extern IntPtr NtQueryInformationFile(IntPtr fileHandle, ref IO_STATUS_BLOCK IoStatusBlock, IntPtr pInfoBlock, uint length, FILE_INFORMATION_CLASS fileInformation);
示例#15
0
 internal static extern uint NtQueryInformationFile(SafeFileHandle fileHandle, ref IO_STATUS_BLOCK IoStatusBlock,
                                                    IntPtr pInfoBlock, uint length, FILE_INFORMATION_CLASS fileInformation);