#include "precomp.h"
#include "volutil.h"
#include "fsrec.h"
#include "devutils.h"
#include <debug.h>
Go to the source code of this file.
◆ NDEBUG
◆ DismountVolume()
Attempts to dismount the designated volume.
- Parameters
-
[in,out] | Volume | The volume to dismount. |
[in] | Force | Whether the volume is forcibly dismounted, even if there are open handles to files on this volume. |
- Returns
- An NTSTATUS code indicating success or failure.
Definition at line 152 of file volutil.c.
155{
159
160
163
164
169 {
170 DPRINT1(
"ERROR: Cannot open volume %S for dismounting! (Status 0x%lx)\n",
173 }
174
175
183 DPRINT1(
"WARNING: Failed to lock volume (Status 0x%lx)\n", LockStatus);
184
185
188 {
196 DPRINT1(
"Failed to unmount volume (Status 0x%lx)\n",
Status);
197 }
198
199
201 {
209 DPRINT1(
"Failed to unlock volume (Status 0x%lx)\n", LockStatus);
210 }
211
212
214
215
217 {
221 }
222
224}
_Inout_ PVCB _In_ BOOLEAN Force
NTSTATUS pOpenDeviceEx(_In_ PCWSTR DevicePath, _Out_ PHANDLE DeviceHandle, _In_ ACCESS_MASK DesiredAccess, _In_ ULONG ShareAccess)
Open an existing device given by its NT-style path, which is assumed to be for a disk device or a par...
#define NT_SUCCESS(StatCode)
_Must_inspect_result_ _Out_ PHANDLE VolumeHandle
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define FSCTL_LOCK_VOLUME
#define FSCTL_UNLOCK_VOLUME
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
#define FSCTL_DISMOUNT_VOLUME
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 STATUS_ACCESS_DENIED
Referenced by clean_main(), DeletePartition(), DismountPartition(), and MountVolume().
◆ MountVolume()
Definition at line 23 of file volutil.c.
26{
29
30
33
34
38 {
40
41
45
47 }
49
50
53 sizeof(
Volume->FileSystem));
55 DPRINT1(
"InferFileSystem() failed, Status 0x%08lx\n",
Status);
56
58 {
59
60
61
62
64 {
65
66
67
68
69
70
71
72
73
74
75
76
77
84 {
85
86 }
87 else
88 {
89
92
93
94
95
98 }
99 }
100
101 }
102
103
104
106 {
108 struct
109 {
112 } LabelInfo;
113
116 &LabelInfo,
117 sizeof(LabelInfo),
120 {
121
123 LabelInfo.VolumeLabel, LabelInfo.VolumeLabelLength);
124 }
125 else
126 {
127 DPRINT1(
"NtQueryVolumeInformationFile() failed, Status 0x%08lx\n",
Status);
128 }
129 }
130
131
134
136}
#define PARTITION_FAT32_XINT13
NTSTATUS pOpenDevice(_In_ PCWSTR DevicePath, _Out_ PHANDLE DeviceHandle)
Open an existing device given by its NT-style path, which is assumed to be for a disk device or a par...
@ FileFsVolumeInformation
NTSTATUS InferFileSystem(IN PCWSTR PartitionPath OPTIONAL, IN HANDLE PartitionHandle OPTIONAL, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
NTSTRSAFEAPI RtlStringCbCopyNW(_Out_writes_bytes_(cbDest) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cbToCopy)
struct _FILE_FS_VOLUME_INFORMATION FILE_FS_VOLUME_INFORMATION
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
NTSTATUS DismountVolume(_Inout_ PVOLINFO Volume, _In_ BOOLEAN Force)
Attempts to dismount the designated volume.
#define IsUnformatted(VolInfo)
Referenced by AddPartitionToDisk().