예제 #1
0
        public static FILE_FS_VOLUME_INFORMATION GetFileVolumeInfo(IntPtr file_handle)
        {
            IO_STATUS_BLOCK status     = new IO_STATUS_BLOCK();
            IntPtr          ret_buffer = IntPtr.Zero;

            try
            {
                int ret_buffer_len = VOLUME_INFO_BUFFER_LEN;
                ret_buffer = Marshal.AllocHGlobal(ret_buffer_len);
                uint res = ntApiFS.NtQueryVolumeInformationFile
                               (file_handle,
                               ref status,
                               ret_buffer,
                               ret_buffer_len,
                               FS_INFORMATION_CLASS.FileFsVolumeInformation);
                NTSTATUS_helper.ThrowOnError(res, status, NTSTATUS_severity.Warning);
                FILE_FS_VOLUME_INFORMATION ret = FILE_FS_VOLUME_INFORMATION.FromBuffer(ret_buffer);
                return(ret);
            }
            finally
            {
                if (ret_buffer != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(ret_buffer);
                }
            }
        }
예제 #2
0
        public static FILE_FS_VOLUME_INFORMATION FromBuffer(IntPtr buffer)
        {
            FILE_FS_VOLUME_INFORMATION ret = new FILE_FS_VOLUME_INFORMATION();

            ret.VolumeCreationTime = Marshal.ReadInt64(buffer, 0);
            ret.VolumeSerialNumber = IOhelper.PtrToUint(buffer, 8);
            ret.VolumeLabelLength  = Marshal.ReadInt32(buffer, 12);
            ret.SupportsObjects    = Marshal.ReadByte(buffer, 13);

            //pack=4
            ret.VolumeLabel = IOhelper.PtrToStringUni(buffer, 18, ret.VolumeLabelLength / 2);

            return(ret);
        }