source: branches/eraser6/CodeReview/Eraser.Util/NativeMethods/NtDll.cs @ 1710

Revision 1710, 6.9 KB checked in by lowjoel, 5 years ago (diff)

Remove the obsolete managed call to NtQuerySystemInformation?

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1/*
2 * $Id$
3 * Copyright 2008-2010 The Eraser Project
4 * Original Author: Joel Low <lowjoel@users.sourceforge.net>
5 * Modified By:
6 *
7 * This file is part of Eraser.
8 *
9 * Eraser is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * Eraser is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 *
18 * A copy of the GNU General Public License can be found at
19 * <http://www.gnu.org/licenses/>.
20 */
21
22using System;
23using System.Collections.Generic;
24using System.Text;
25using System.Runtime.InteropServices;
26using Microsoft.Win32.SafeHandles;
27
28namespace Eraser.Util
29{
30    internal static partial class NativeMethods
31    {
32        /// <summary>
33        /// The ZwQueryInformationFile routine returns various kinds of information
34        /// about a file object.
35        /// </summary>
36        /// <param name="FileHandle">Handle to a file object. The handle is created
37        /// by a successful call to ZwCreateFile or ZwOpenFile.</param>
38        /// <param name="IoStatusBlock">Pointer to an IO_STATUS_BLOCK structure
39        /// that receives the final completion status and information about
40        /// the operation. The Information member receives the number of bytes
41        /// that this routine actually writes to the FileInformation buffer.</param>
42        /// <param name="FileInformation">Pointer to a caller-allocated buffer
43        /// into which the routine writes the requested information about the
44        /// file object. The FileInformationClass parameter specifies the type
45        /// of information that the caller requests.</param>
46        /// <param name="Length">The size, in bytes, of the buffer pointed to
47        /// by FileInformation.</param>
48        /// <param name="FileInformationClass">Specifies the type of information
49        /// to be returned about the file, in the buffer that FileInformation
50        /// points to. Device and intermediate drivers can specify any of the
51        /// following FILE_INFORMATION_CLASS enumeration values, which are defined
52        /// in header file Wdm.h.</param>
53        /// <returns>ZwQueryInformationFile returns STATUS_SUCCESS or an appropriate
54        /// NTSTATUS error code.</returns>
55        [DllImport("NtDll.dll")]
56        public static extern uint NtQueryInformationFile(SafeFileHandle FileHandle,
57            ref IO_STATUS_BLOCK IoStatusBlock, IntPtr FileInformation, uint Length,
58            FILE_INFORMATION_CLASS FileInformationClass);
59
60        public struct IO_STATUS_BLOCK
61        {
62            public IntPtr PointerStatus;
63            public UIntPtr Information;
64        }
65
66        public struct FILE_STREAM_INFORMATION
67        {
68            /// <summary>
69            /// The offset of the next FILE_STREAM_INFORMATION entry. This
70            /// member is zero if no other entries follow this one.
71            /// </summary>
72            public uint NextEntryOffset;
73
74            /// <summary>
75            /// Length, in bytes, of the StreamName string.
76            /// </summary>
77            public uint StreamNameLength;
78
79            /// <summary>
80            /// Size, in bytes, of the stream.
81            /// </summary>
82            public long StreamSize;
83
84            /// <summary>
85            /// File stream allocation size, in bytes. Usually this value
86            /// is a multiple of the sector or cluster size of the underlying
87            /// physical device.
88            /// </summary>
89            public long StreamAllocationSize;
90
91            /// <summary>
92            /// Unicode string that contains the name of the stream.
93            /// </summary>
94            public string StreamName;
95        }
96
97        public enum FILE_INFORMATION_CLASS
98        {
99            FileDirectoryInformation = 1,
100            FileFullDirectoryInformation,
101            FileBothDirectoryInformation,
102            FileBasicInformation,
103            FileStandardInformation,
104            FileInternalInformation,
105            FileEaInformation,
106            FileAccessInformation,
107            FileNameInformation,
108            FileRenameInformation,
109            FileLinkInformation,
110            FileNamesInformation,
111            FileDispositionInformation,
112            FilePositionInformation,
113            FileFullEaInformation,
114            FileModeInformation,
115            FileAlignmentInformation,
116            FileAllInformation,
117            FileAllocationInformation,
118            FileEndOfFileInformation,
119            FileAlternateNameInformation,
120            FileStreamInformation,
121            FilePipeInformation,
122            FilePipeLocalInformation,
123            FilePipeRemoteInformation,
124            FileMailslotQueryInformation,
125            FileMailslotSetInformation,
126            FileCompressionInformation,
127            FileCopyOnWriteInformation,
128            FileCompletionInformation,
129            FileMoveClusterInformation,
130            FileQuotaInformation,
131            FileReparsePointInformation,
132            FileNetworkOpenInformation,
133            FileObjectIdInformation,
134            FileTrackingInformation,
135            FileOleDirectoryInformation,
136            FileContentIndexInformation,
137            FileInheritContentIndexInformation,
138            FileOleInformation,
139            FileMaximumInformation
140        }
141
142        /// <summary>
143        /// Represents volume data. This structure is passed to the
144        /// FSCTL_GET_NTFS_VOLUME_DATA control code.
145        /// </summary>
146        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
147        public struct NTFS_VOLUME_DATA_BUFFER
148        {
149            /// <summary>
150            /// The serial number of the volume. This is a unique number assigned
151            /// to the volume media by the operating system.
152            /// </summary>
153            public long VolumeSerialNumber;
154
155            /// <summary>
156            /// The number of sectors in the specified volume.
157            /// </summary>
158            public long NumberSectors;
159
160            /// <summary>
161            /// The number of used and free clusters in the specified volume.
162            /// </summary>
163            public long TotalClusters;
164
165            /// <summary>
166            /// The number of free clusters in the specified volume.
167            /// </summary>
168            public long FreeClusters;
169
170            /// <summary>
171            /// The number of reserved clusters in the specified volume.
172            /// </summary>
173            public long TotalReserved;
174
175            /// <summary>
176            /// The number of bytes in a sector on the specified volume.
177            /// </summary>
178            public uint BytesPerSector;
179
180            /// <summary>
181            /// The number of bytes in a cluster on the specified volume. This
182            /// value is also known as the cluster factor.
183            /// </summary>
184            public uint BytesPerCluster;
185
186            /// <summary>
187            /// The number of bytes in a file record segment.
188            /// </summary>
189            public uint BytesPerFileRecordSegment;
190
191            /// <summary>
192            /// The number of clusters in a file record segment.
193            /// </summary>
194            public uint ClustersPerFileRecordSegment;
195
196            /// <summary>
197            /// The length of the master file table, in bytes.
198            /// </summary>
199            public long MftValidDataLength;
200
201            /// <summary>
202            /// The starting logical cluster number of the master file table.
203            /// </summary>
204            public long MftStartLcn;
205
206            /// <summary>
207            /// The starting logical cluster number of the master file table mirror.
208            /// </summary>
209            public long Mft2StartLcn;
210
211            /// <summary>
212            /// The starting logical cluster number of the master file table zone.
213            /// </summary>
214            public long MftZoneStart;
215
216            /// <summary>
217            /// The ending logical cluster number of the master file table zone.
218            /// </summary>
219            public long MftZoneEnd;
220
221            public uint ByteCount;
222            public ushort MajorVersion;
223            public ushort MinorVersion;
224        }
225    }
226}
Note: See TracBrowser for help on using the repository browser.