ReactOS 0.4.17-dev-1190-g4c812f4
ntfslib.c File Reference
#include "ntfslib.h"
#include <debug.h>
Include dependency graph for ntfslib.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define CEIL_DIV(a, b)   (((a) + (b) - 1) / (b))
 

Functions

VOID NtfsGetSystemTimeAsFileTime (OUT PFILETIME lpFileTime)
 
BYTE GetSectorsPerCluster (VOID)
 
static CHAR EncodeRecordSize (IN ULONG RecordBytes, IN ULONG ClusterBytes)
 
NTSTATUS ComputeLayout (IN ULONG ClusterSize)
 
static NTSTATUS InvalidateStaleBootSectors (VOID)
 
BOOLEAN NTAPI NtfsFormat (IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN QuickFormat, IN BOOLEAN BackwardCompatible, IN MEDIA_TYPE MediaType, IN PUNICODE_STRING Label, IN ULONG ClusterSize)
 
BOOLEAN NTAPI NtfsChkdsk (IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID pUnknown1, IN PVOID pUnknown2, IN PVOID pUnknown3, IN PVOID pUnknown4, IN PULONG ExitStatus)
 

Variables

NTFS_FORMAT_DATA NtfsFormatData
 

Macro Definition Documentation

◆ CEIL_DIV

#define CEIL_DIV (   a,
  b 
)    (((a) + (b) - 1) / (b))

Definition at line 96 of file ntfslib.c.

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file ntfslib.c.

Function Documentation

◆ ComputeLayout()

NTSTATUS ComputeLayout ( IN ULONG  ClusterSize)

Definition at line 99 of file ntfslib.c.

100{
102 ULONGLONG VolumeBytes;
103 ULONGLONG VolumeSectors;
104 ULONG Spc;
105 ULONG C;
106 ULONGLONG Lcn;
107
108 if (Bps == 0)
110
111 VolumeBytes = DISK_LEN->Length.QuadPart;
112 VolumeSectors = VolumeBytes / Bps;
113
114 // Need at least the backup boot sector plus something to format.
115 if (VolumeSectors < 2)
117
118 // Sectors per cluster
119 if (ClusterSize != 0)
120 {
121 Spc = ClusterSize / Bps;
122 if (Spc == 0)
123 Spc = 1;
124 }
125 else
126 {
127 Spc = GetSectorsPerCluster();
128 }
129
130 LAYOUT.SectorsPerCluster = Spc;
131 LAYOUT.BytesPerCluster = Spc * Bps;
132 C = LAYOUT.BytesPerCluster;
133
134 // The last sector holds the backup boot sector and is not addressable.
135 LAYOUT.TotalSectors = VolumeSectors - 1;
136 LAYOUT.ClusterCount = LAYOUT.TotalSectors / Spc;
137 if (LAYOUT.ClusterCount == 0)
139
140 LAYOUT.ClustersPerMftRecord = EncodeRecordSize(MFT_RECORD_SIZE, C);
141 LAYOUT.ClustersPerIndexRecord = EncodeRecordSize(INDEX_RECORD_SIZE, C);
142
143 //
144 // Metadata sizes (in clusters)
145 //
146
147 // $Boot is exactly the first 8192 bytes of the volume.
148 LAYOUT.BootClusters = (ULONG)CEIL_DIV(8192ULL, (ULONGLONG)C);
149
150 // $MFT: reserve a large MFT.
151 ULONGLONG MftBytes = VolumeBytes / 128;
152
153 if (MftBytes < (4ULL * 1024 * 1024))
154 MftBytes = 4ULL * 1024 * 1024; // 4 MB min (~4096 records)
155 if (MftBytes > (32ULL * 1024 * 1024))
156 MftBytes = 32ULL * 1024 * 1024; // 32 MB cap (~32768 records)
157
158 LAYOUT.MftAllocRecords = (ULONG)(MftBytes / MFT_RECORD_SIZE);
159 LAYOUT.MftClusters = (ULONG)CEIL_DIV((ULONGLONG)LAYOUT.MftAllocRecords * MFT_RECORD_SIZE, (ULONGLONG)C);
160
161 // $MFTMirr: the first four system records.
163
164 // $LogFile: ~0.78% of the volume, clamped to [256 KB, 64 MB].
165 {
166 ULONGLONG LogBytes = VolumeBytes / 128;
167
168 if (LogBytes < (256ULL * 1024))
169 LogBytes = 256ULL * 1024;
170 if (LogBytes > (64ULL * 1024 * 1024))
171 LogBytes = 64ULL * 1024 * 1024;
172
173 LAYOUT.LogFileClusters = (ULONG)CEIL_DIV(LogBytes, (ULONGLONG)C);
174 }
175
176 // $Bitmap: one bit per cluster. The stream length must be a multiple of
177 // 8 bytes (NTFS tracks the bitmap in 64-bit groups). If it isn't, the OS
178 // rounds it up on first write and zero-fills the gap, leaving phantom
179 // trailing clusters marked free. Round up here; WriteMetafiles matches.
180 {
181 ULONGLONG BitmapBytes = CEIL_DIV(LAYOUT.ClusterCount, 8ULL);
182 BitmapBytes = (BitmapBytes + 7) & ~7ULL;
183 LAYOUT.BitmapClusters = (ULONG)CEIL_DIV(BitmapBytes, (ULONGLONG)C);
184 }
185
186 // $UpCase: 128 KB (65536 UTF-16 entries).
187 LAYOUT.UpCaseClusters = (ULONG)CEIL_DIV(128ULL * 1024, (ULONGLONG)C);
188
189 // $AttrDef: reserve 4 KB (the attribute-definition table is ~2.5 KB).
190 LAYOUT.AttrDefClusters = (ULONG)CEIL_DIV(4096ULL, (ULONGLONG)C);
191
192 // $MFT's own allocation bitmap: one bit per reserved MFT record.
193 {
194 ULONGLONG MftBmpBytes = CEIL_DIV((ULONGLONG)LAYOUT.MftAllocRecords, 8ULL);
195 LAYOUT.MftBitmapClusters = (ULONG)CEIL_DIV(MftBmpBytes, (ULONGLONG)C);
196 }
197
198 // Root directory $I30 index: one INDX block.
200
201 // $Secure:$SDS: the 8 default descriptors plus their mirror 256 KiB later.
203
204 // $Secure:$SDH: one INDX block (large view index).
206
207 // $Extend / TxF payload streams (contents zero-initialized on a fresh volume;
208 // chkdsk validates the metadata, not the CLFS log data).
209 LAYOUT.TopsTClusters = (ULONG)CEIL_DIV(1024ULL * 1024, (ULONGLONG)C); // 1 MiB
210 LAYOUT.BlfClusters = (ULONG)CEIL_DIV(64ULL * 1024, (ULONGLONG)C); // 64 KiB
211 LAYOUT.Cont1Clusters = (ULONG)CEIL_DIV(2ULL * 1024 * 1024, (ULONGLONG)C); // 2 MiB
212 LAYOUT.Cont2Clusters = (ULONG)CEIL_DIV(2ULL * 1024 * 1024, (ULONGLONG)C); // 2 MiB
213 LAYOUT.DeletedIdxClusters = (ULONG)CEIL_DIV(64ULL * 1024, (ULONGLONG)C); // 64 KiB
214
215 //
216 // Placement: everything contiguous from the start of the volume.
217 //
218 Lcn = 0;
219 LAYOUT.BootLcn = Lcn; Lcn += LAYOUT.BootClusters;
220 LAYOUT.MftLcn = Lcn; Lcn += LAYOUT.MftClusters;
221 LAYOUT.MftMirrLcn = Lcn; Lcn += LAYOUT.MftMirrClusters;
222 LAYOUT.LogFileLcn = Lcn; Lcn += LAYOUT.LogFileClusters;
223 LAYOUT.BitmapLcn = Lcn; Lcn += LAYOUT.BitmapClusters;
224 LAYOUT.UpCaseLcn = Lcn; Lcn += LAYOUT.UpCaseClusters;
225 LAYOUT.AttrDefLcn = Lcn; Lcn += LAYOUT.AttrDefClusters;
226 LAYOUT.MftBitmapLcn = Lcn; Lcn += LAYOUT.MftBitmapClusters;
227 LAYOUT.RootIdxLcn = Lcn; Lcn += LAYOUT.RootIdxClusters;
228 LAYOUT.SdsLcn = Lcn; Lcn += LAYOUT.SdsClusters;
229 LAYOUT.SdhIdxLcn = Lcn; Lcn += LAYOUT.SdhIdxClusters;
230 LAYOUT.TopsTLcn = Lcn; Lcn += LAYOUT.TopsTClusters;
231 LAYOUT.BlfLcn = Lcn; Lcn += LAYOUT.BlfClusters;
232 LAYOUT.Cont1Lcn = Lcn; Lcn += LAYOUT.Cont1Clusters;
233 LAYOUT.Cont2Lcn = Lcn; Lcn += LAYOUT.Cont2Clusters;
234 LAYOUT.DeletedIdxLcn = Lcn; Lcn += LAYOUT.DeletedIdxClusters;
235 LAYOUT.FirstFreeLcn = Lcn;
236
237 // The volume must be large enough to hold the metadata (plus slack).
238 if (LAYOUT.FirstFreeLcn + 16 >= LAYOUT.ClusterCount)
239 {
240 DPRINT1("Volume too small for NTFS: need %I64u clusters, have %I64u\n",
241 LAYOUT.FirstFreeLcn + 16, LAYOUT.ClusterCount);
242 return STATUS_DISK_FULL;
243 }
244
245 // Volume serial number
246 {
248 ULONG Hi = RtlRandom(&Seed);
249 ULONG Lo = RtlRandom(&Seed);
250 LAYOUT.SerialNumber = ((ULONGLONG)Hi << 32) | (ULONGLONG)Lo;
251 }
252
253 return STATUS_SUCCESS;
254}
#define DPRINT1
Definition: precomp.h:8
#define BYTES_PER_SECTOR
Definition: volume.c:37
DWORD ClusterSize
Definition: format.c:66
#define C(c)
Definition: builtin.c:4556
Definition: terminate.cpp:24
#define DISK_LEN
Definition: ntfslib.h:63
#define MFT_MIRR_COUNT
Definition: ntfslib.h:101
#define NTFS_SDS_MIRROR
Definition: ntfslib.h:245
#define MFT_RECORD_SIZE
Definition: ntfslib.h:93
#define INDEX_RECORD_SIZE
Definition: ntfslib.h:94
NTSYSAPI ULONG NTAPI RtlRandom(_Inout_ PULONG Seed)
#define CEIL_DIV(a, b)
Definition: ntfslib.c:96
BYTE GetSectorsPerCluster(VOID)
Definition: ntfslib.c:42
static CHAR EncodeRecordSize(IN ULONG RecordBytes, IN ULONG ClusterBytes)
Definition: ntfslib.c:74
#define NtGetTickCount
Definition: rtlp.h:163
BYTE Seed[SYMCRYPT_HASH_MAX_RESULT_SIZE]
Definition: sc_lib.h:4529
#define STATUS_SUCCESS
Definition: shellext.h:65
uint64_t ULONGLONG
Definition: typedefs.h:67
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_DISK_FULL
Definition: udferr_usr.h:155

Referenced by NtfsFormat().

◆ EncodeRecordSize()

static CHAR EncodeRecordSize ( IN ULONG  RecordBytes,
IN ULONG  ClusterBytes 
)
static

Definition at line 74 of file ntfslib.c.

76{
77 if (RecordBytes >= ClusterBytes)
78 {
79 return (CHAR)(RecordBytes / ClusterBytes);
80 }
81 else
82 {
83 CHAR Log = 0;
84 ULONG Value = RecordBytes;
85
86 while (Value > 1)
87 {
88 Value >>= 1;
89 Log++;
90 }
91
92 return (CHAR)(-Log);
93 }
94}
char CHAR
Definition: pedump.c:57
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by ComputeLayout().

◆ GetSectorsPerCluster()

BYTE GetSectorsPerCluster ( VOID  )

Definition at line 42 of file ntfslib.c.

43{
44 // Default NTFS cluster size selection based on the volume size,
45 // mirroring the classic Windows defaults (for 512-byte sectors):
46 // <= 512 MB : 512 B, <= 1 GB : 1 KB, <= 2 GB : 2 KB, else 4 KB.
47 ULONGLONG Size = DISK_LEN->Length.QuadPart;
49 ULONG ClusterBytes;
50
51 if (Size <= (512ULL * 1024 * 1024))
52 ClusterBytes = 512;
53 else if (Size <= (1024ULL * 1024 * 1024))
54 ClusterBytes = 1024;
55 else if (Size <= (2048ULL * 1024 * 1024))
56 ClusterBytes = 2048;
57 else
58 ClusterBytes = 4096;
59
60 if (ClusterBytes < Bps)
61 ClusterBytes = Bps;
62
63 return (BYTE)(ClusterBytes / Bps);
64}
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ComputeLayout().

◆ InvalidateStaleBootSectors()

static NTSTATUS InvalidateStaleBootSectors ( VOID  )
static

Definition at line 265 of file ntfslib.c.

266{
270 PBYTE Sector;
272
273 Sector = RtlAllocateHeap(RtlGetProcessHeap(), 0, Bps);
274 if (!Sector)
276
277 RtlZeroMemory(Sector, Bps);
278
279 // Primary boot sector
280 Offset.QuadPart = 0LL;
282 NULL,
283 NULL,
284 NULL,
286 Sector,
287 Bps,
288 &Offset,
289 NULL);
290
291 // Backup boot sector
292 if (NT_SUCCESS(Status))
293 {
294 Offset.QuadPart = (LONGLONG)TOTAL_SECTORS * Bps;
296 NULL,
297 NULL,
298 NULL,
300 Sector,
301 Bps,
302 &Offset,
303 NULL);
304 }
305
306 FREE(Sector);
307
308 return Status;
309}
#define FREE(ptr, size)
Definition: auth_des.c:64
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
_In_ PIO_STATUS_BLOCK IoStatusBlock
Definition: dispmprt.h:608
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:24
#define TOTAL_SECTORS
Definition: ntfslib.h:74
#define DISK_HANDLE
Definition: ntfslib.h:61
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
BYTE * PBYTE
Definition: pedump.c:66
#define LL
Definition: tui.h:167
int64_t LONGLONG
Definition: typedefs.h:68
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by NtfsFormat().

◆ NtfsChkdsk()

BOOLEAN NTAPI NtfsChkdsk ( IN PUNICODE_STRING  DriveRoot,
IN PFMIFSCALLBACK  Callback,
IN BOOLEAN  FixErrors,
IN BOOLEAN  Verbose,
IN BOOLEAN  CheckOnlyIfDirty,
IN BOOLEAN  ScanDrive,
IN PVOID  pUnknown1,
IN PVOID  pUnknown2,
IN PVOID  pUnknown3,
IN PVOID  pUnknown4,
IN PULONG  ExitStatus 
)

Definition at line 495 of file ntfslib.c.

507{
508 // STUB
509
510 if (Callback)
511 {
513
514 TextOut.Lines = 1;
515 TextOut.Output = "stub, not implemented";
516
517 Callback(OUTPUT, 0, &TextOut);
518 }
519
521 return TRUE;
522}
_In_ ULONG _In_ ULONG _In_opt_ DXGKCB_MIRACAST_SEND_MESSAGE_CALLBACK Callback
Definition: dispmprt.h:620
#define TRUE
Definition: types.h:120
#define OUTPUT(ch)
_In_ NTSTATUS ExitStatus
Definition: psfuncs.h:913
#define TextOut
Definition: wingdi.h:4929

◆ NtfsFormat()

BOOLEAN NTAPI NtfsFormat ( IN PUNICODE_STRING  DriveRoot,
IN PFMIFSCALLBACK  Callback,
IN BOOLEAN  QuickFormat,
IN BOOLEAN  BackwardCompatible,
IN MEDIA_TYPE  MediaType,
IN PUNICODE_STRING  Label,
IN ULONG  ClusterSize 
)

Definition at line 313 of file ntfslib.c.

321{
322 HANDLE DiskHandle;
325 GET_LENGTH_INFORMATION LengthInformation;
326 DISK_GEOMETRY DiskGeometry;
329
330 DPRINT1("NtfsFormat(DriveRoot '%wZ')\n", DriveRoot);
331
332 // We always perform a quick format (metadata only); the volume body is
333 // not zeroed.
335 UNREFERENCED_PARAMETER(BackwardCompatible);
336 UNREFERENCED_PARAMETER(MediaType);
337
339
340 // Open volume
341 Status = NtOpenFile(&DiskHandle,
343 &Attributes,
344 &Iosb,
347 if (!NT_SUCCESS(Status))
348 {
349 DPRINT1("NtOpenFile() failed with status 0x%.08x\n", Status);
350 return FALSE;
351 }
352
353 // Get length info
354 Status = NtDeviceIoControlFile(DiskHandle,
355 NULL,
356 NULL,
357 NULL,
358 &Iosb,
360 NULL,
361 0,
362 &LengthInformation,
363 sizeof(GET_LENGTH_INFORMATION));
364 if (!NT_SUCCESS(Status))
365 {
366 DPRINT1("IOCTL_DISK_GET_LENGTH_INFO failed with status 0x%.08x\n", Status);
367 NtClose(DiskHandle);
368 return FALSE;
369 }
370
371 // Get disk geometry
372 Status = NtDeviceIoControlFile(DiskHandle,
373 NULL,
374 NULL,
375 NULL,
376 &Iosb,
378 NULL,
379 0,
380 &DiskGeometry,
381 sizeof(DiskGeometry));
382 if (!NT_SUCCESS(Status))
383 {
384 DPRINT1("IOCTL_DISK_GET_DRIVE_GEOMETRY failed with status 0x%.08x\n", Status);
385 NtClose(DiskHandle);
386 return FALSE;
387 }
388
389 // Initialize progress bar
390 if (Callback)
391 {
392 ULONG pc = 0;
393 Callback(PROGRESS, 0, (PVOID)&pc);
394 }
395
396 // Setup global data
397 DISK_HANDLE = DiskHandle;
398 DISK_GEO = &DiskGeometry;
399 DISK_LEN = &LengthInformation;
400 LABEL = Label;
401
402
405 NTSTATUS PartStatus =
406 NtDeviceIoControlFile(DiskHandle, NULL, NULL, NULL, &Iosb,
408 NULL, 0,
409 &PartitionInfo, sizeof(PartitionInfo));
410 if (NT_SUCCESS(PartStatus) && DiskGeometry.BytesPerSector != 0)
411 {
413 (ULONG)(PartitionInfo.StartingOffset.QuadPart / DiskGeometry.BytesPerSector);
414 }
415 else
416 {
417 DPRINT1("IOCTL_DISK_GET_PARTITION_INFO_EX failed (0x%.08x); HiddenSectors=0\n", PartStatus);
418 }
419
420 // Capture a single timestamp used for every record, so a file's timestamps
421 // match the copies stored in its parent directory's index entries.
422 {
423 LARGE_INTEGER SystemTime;
424 KeQuerySystemTime(&SystemTime);
426 }
427
428 // Compute the on-disk layout (cluster size, metadata placement, serial)
430 if (!NT_SUCCESS(Status))
431 {
432 DPRINT1("ComputeLayout() failed with status 0x%.08x\n", Status);
433 goto end;
434 }
435
436 NtFsControlFile(DiskHandle, NULL, NULL, NULL, &Iosb, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0);
438
439 // Kill any stale boot sectors FIRST: the volume reads as RAW from here on,
440 // so no partially-formatted state is ever recognizable as a filesystem.
442 if (!NT_SUCCESS(Status))
443 {
444 DPRINT1("InvalidateStaleBootSectors() failed with status 0x%.08x\n", Status);
445 goto end;
446 }
447
448 // Create metafiles
450 if (!NT_SUCCESS(Status))
451 {
452 DPRINT1("WriteMetafiles() failed with status 0x%.08x\n", Status);
453 goto end;
454 }
455
456 // Write the boot sector LAST - only now, with all metadata complete behind
457 // it, does the volume become recognizable as NTFS.
459 if (!NT_SUCCESS(Status))
460 {
461 DPRINT1("WriteBootSector() failed with status 0x%.08x\n", Status);
462 goto end;
463 }
464
465 Result = TRUE;
466 DPRINT1("NtfsFormat() completed successfully\n");
467
468end:
469
470 // Dismount and unlock volume
472 NtFsControlFile(DiskHandle, NULL, NULL, NULL, &Iosb, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0);
473
474 // Close the volume handle
475 NtClose(DiskHandle);
476
477 // Clear global data structure
479 DISK_GEO = NULL;
480 DISK_LEN = NULL;
481 LABEL = NULL;
482
483 // Update progress bar
484 if (Callback)
485 {
487 Callback(DONE, 0, (PVOID)&success);
488 }
489
490 return Result;
491}
unsigned char BOOLEAN
Definition: actypes.h:127
BOOL QuickFormat
Definition: format.c:65
PWCHAR Label
Definition: format.c:69
NTSTATUS WriteBootSector(VOID)
Definition: bootsect.c:112
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
_In_ ULONG Attributes
Definition: dispmprt.h:1077
#define FALSE
Definition: types.h:117
#define FILE_SHARE_READ
Definition: compat.h:136
return Iosb
Definition: create.c:4403
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define IOCTL_DISK_GET_PARTITION_INFO_EX
Definition: ntddk_ex.h:206
unsigned int BOOL
Definition: ntddk_ex.h:94
@ PROGRESS
Definition: fmifs.h:83
#define FILE_SYNCHRONOUS_IO_ALERT
Definition: from_kernel.h:30
GLuint GLuint end
Definition: gl.h:1545
#define LABEL
Definition: ntfslib.h:64
#define IOCTL_DISK_GET_LENGTH_INFO
Definition: imports.h:192
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FSCTL_LOCK_VOLUME
Definition: nt_native.h:832
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define FSCTL_UNLOCK_VOLUME
Definition: nt_native.h:833
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3434
#define FSCTL_DISMOUNT_VOLUME
Definition: nt_native.h:834
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define FILE_GENERIC_READ
Definition: nt_native.h:653
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
static NTSTATUS InvalidateStaleBootSectors(VOID)
Definition: ntfslib.c:265
NTSTATUS ComputeLayout(IN ULONG ClusterSize)
Definition: ntfslib.c:99
NTFS_FORMAT_DATA NtfsFormatData
Definition: ntfslib.c:20
#define DONE
Definition: rnr20lib.h:14
NTSTATUS WriteMetafiles(VOID)
Definition: files.c:872
ULONG BytesPerSector
Definition: ntdddisk.h:404
ULONG HiddenSectors
Definition: ntfslib.h:256
ULONGLONG FormatTime
Definition: ntfslib.h:255
LONGLONG QuadPart
Definition: typedefs.h:114
#define success(from, fromstr, to, tostr)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
Definition: iofuncs.h:2105

◆ NtfsGetSystemTimeAsFileTime()

VOID NtfsGetSystemTimeAsFileTime ( OUT PFILETIME  lpFileTime)

Definition at line 26 of file ntfslib.c.

27{
28 LARGE_INTEGER SystemTime;
29
30 do
31 {
32 SystemTime.HighPart = SharedUserData->SystemTime.High1Time;
33 SystemTime.LowPart = SharedUserData->SystemTime.LowPart;
34 }
35 while (SystemTime.HighPart != SharedUserData->SystemTime.High2Time);
36
37 lpFileTime->dwLowDateTime = SystemTime.LowPart;
38 lpFileTime->dwHighDateTime = SystemTime.HighPart;
39}
#define SharedUserData
ULONG LowPart
Definition: typedefs.h:106

Variable Documentation

◆ NtfsFormatData

NTFS_FORMAT_DATA NtfsFormatData

Definition at line 20 of file ntfslib.c.

Referenced by NtfsFormat().