25#define IOCTL_VOLUME_IS_DYNAMIC CTL_CODE(IOCTL_VOLUME_BASE, 18, METHOD_BUFFERED, FILE_ANY_ACCESS)
26#define IOCTL_VOLUME_POST_ONLINE CTL_CODE(IOCTL_VOLUME_BASE, 25, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
66 if (vde->
pdo->AttachedDevice)
101 Irp->IoStatus.Information = 0;
170 ERR(
"IoAllocateIrp failed\n");
185 ERR(
"out of memory\n");
195 Irp2->MdlAddress =
Irp->MdlAddress;
203 Irp2->UserIosb = &
context.iosb;
216 Irp->IoStatus.Information =
context.iosb.Information;
257 ERR(
"IoAllocateIrp failed\n");
276 Irp2->MdlAddress =
Irp->MdlAddress;
284 Irp2->UserIosb = &
context.iosb;
297 Irp->IoStatus.Information =
context.iosb.Information;
318 name =
Irp->AssociatedIrp.SystemBuffer;
343 mduid =
Irp->AssociatedIrp.SystemBuffer;
374 Irp->IoStatus.Information = 1;
409 ULONG num_extents = 0,
i, max_extents = 1;
425 ERR(
"IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS returned %08lx\n",
Status);
429 num_extents +=
ext2.NumberOfDiskExtents;
431 if (
ext2.NumberOfDiskExtents > max_extents)
432 max_extents =
ext2.NumberOfDiskExtents;
437 ext =
Irp->AssociatedIrp.SystemBuffer;
441 ext->NumberOfDiskExtents = num_extents;
448 ERR(
"out of memory\n");
454 ext->NumberOfDiskExtents = 0;
463 ERR(
"IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS returned %08lx\n",
Status);
468 if (
i +
ext3->NumberOfDiskExtents > num_extents) {
470 ext->NumberOfDiskExtents =
i +
ext3->NumberOfDiskExtents;
477 i +=
ext3->NumberOfDiskExtents;
486 ext->NumberOfDiskExtents =
i;
499 bool writable =
false;
688 ERR(
"IoAllocateIrp failed\n");
706 Irp2->MdlAddress =
Irp->MdlAddress;
707 Irp2->UserBuffer =
Irp->UserBuffer;
708 Irp2->Flags =
Irp->Flags;
741 mdsg =
Irp->AssociatedIrp.SystemBuffer;
761 Irp->IoStatus.Information = 0;
774 TRACE(
"unhandled control code IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME\n");
781 TRACE(
"unhandled control code IOCTL_MOUNTDEV_LINK_CREATED\n");
791 Irp->IoStatus.Information = 0;
795 Irp->IoStatus.Information = 0;
822 WARN(
"passing through ioctl %lx (returning %08lx)\n",
code,
Status);
842 ERR(
"out of memory\n");
853 ERR(
"IOCTL_MOUNTMGR_NEXT_DRIVE_LETTER returned %08lx\n",
Status);
868 TRACE(
"GUID_TARGET_DEVICE_QUERY_REMOVE\n");
890 ERR(
"out of memory\n");
897 path.Buffer[
i] =
'\\';
900 for (
j = 0;
j < 16;
j++) {
906 if (
j == 3 ||
j == 5 ||
j == 7 ||
j == 9) {
907 path.Buffer[
i] =
'-';
917 ERR(
"out of memory\n");
926 ERR(
"ZwOpenKey returned %08lx\n",
Status);
930 adus.
Buffer =
L"AllowDegraded";
975 ERR(
"out of memory\n");
992 ERR(
"out of memory\n");
1020 while (le != &dlrlist) {
1026 WARN(
"remove_drive_letter returned %08lx\n", dlr->
Status);
1068 ERR(
"IoGetDeviceObjectPointer returned %08lx\n",
Status);
1084 bool inserted =
false, new_pdo =
false;
1087 bool process_drive_letters =
false;
1089 if (devpath->
Length == 0)
1108 ERR(
"IoGetDeviceObjectPointer returned %08lx\n",
Status);
1118 ERR(
"IoReportDetectedDevice returned %08lx\n",
Status);
1126 ERR(
"out of memory\n");
1134 ERR(
"IoCreateDevice returned %08lx\n",
Status);
1155 pdo->
Flags &= ~DO_DEVICE_INITIALIZING;
1182 ERR(
"out of memory\n");
1199 WARN(
"IoRegisterPlugPlayNotification returned %08lx\n",
Status);
1204 devpath2 = *devpath;
1209 devpath->
Buffer[2] ==
'?' && devpath->
Buffer[3] ==
'\\') {
1221 ERR(
"out of memory\n");
1257 le =
Vcb->devices.Flink;
1258 while (le != &
Vcb->devices) {
1263 dev->disk_num = disk_num;
1264 dev->part_num = part_num;
1283 if ((!new_pdo || !
no_pnp) && pdode->
vde) {
1286 WARN(
"IoSetDeviceInterfaceState returned %08lx\n",
Status);
1289 process_drive_letters =
true;
1299 if (process_drive_letters)
1300 drive_letter_callback(pdode);
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define InterlockedIncrement
#define InterlockedDecrement
NTSTATUS(__stdcall * tIoUnregisterPlugPlayNotificationEx)(PVOID NotificationEntry)
void void void NTSTATUS void NTSTATUS NTSTATUS remove_drive_letter(PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath)
NTSTATUS pnp_query_remove_device(PDEVICE_OBJECT DeviceObject, PIRP Irp)
#define FILE_DEVICE_SECURE_OPEN
#define IOCTL_DISK_CHECK_VERIFY
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
#define IOCTL_DISK_IS_WRITABLE
#define NT_SUCCESS(StatCode)
static const WCHAR *const ext[]
void boot_add_device(DEVICE_OBJECT *pdo)
uint32_t mount_allow_degraded
void init_device(_In_ device_extension *Vcb, _Inout_ device *dev, _In_ bool get_nums)
NTSTATUS dev_ioctl(_In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG ControlCode, _In_reads_bytes_opt_(InputBufferSize) PVOID InputBuffer, _In_ ULONG InputBufferSize, _Out_writes_bytes_opt_(OutputBufferSize) PVOID OutputBuffer, _In_ ULONG OutputBufferSize, _In_ bool Override, _Out_opt_ IO_STATUS_BLOCK *iosb)
#define BTRFS_SUPERBLOCK_FLAGS_SEEDING
static void drive_letter_callback2(pdo_device_extension *pdode, PDEVICE_OBJECT mountmgr)
static NTSTATUS vol_query_unique_id(volume_device_extension *vde, PIRP Irp)
static NTSTATUS vol_query_stable_guid(volume_device_extension *vde, PIRP Irp)
static bool allow_degraded_mount(BTRFS_UUID *uuid)
static NTSTATUS vol_check_verify(volume_device_extension *vde)
NTSTATUS mountmgr_add_drive_letter(PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath)
UNICODE_STRING registry_path
static NTSTATUS vol_get_disk_extents(volume_device_extension *vde, PIRP Irp)
NTSTATUS vol_read(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define IOCTL_VOLUME_IS_DYNAMIC
NTSTATUS vol_close(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
static NTSTATUS vol_get_length(volume_device_extension *vde, PIRP Irp)
static NTSTATUS vol_ioctl_passthrough(volume_device_extension *vde, PIRP Irp)
void free_vol(volume_device_extension *vde)
static NTSTATUS vol_get_gpt_attributes(PIRP Irp)
PDEVICE_OBJECT master_devobj
#define IOCTL_VOLUME_POST_ONLINE
NTSTATUS vol_device_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
static NTSTATUS vol_get_drive_geometry(PDEVICE_OBJECT DeviceObject, PIRP Irp)
tIoUnregisterPlugPlayNotificationEx fIoUnregisterPlugPlayNotificationEx
static NTSTATUS vol_is_writable(volume_device_extension *vde)
NTSTATUS vol_write(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
static NTSTATUS vol_query_device_name(volume_device_extension *vde, PIRP Irp)
static NTSTATUS vol_get_device_number(volume_device_extension *vde, PIRP Irp)
NTSTATUS vol_create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
static NTSTATUS vol_is_dynamic(PIRP Irp)
void add_volume_device(superblock *sb, PUNICODE_STRING devpath, uint64_t length, ULONG disk_num, ULONG part_num)
_In_ PIO_STACK_LOCATION IrpSp
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define IsListEmpty(ListHead)
NTSTATUS ExInitializeResourceLite(PULONG res)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define RtlCompareMemory(s1, s2, l)
#define KeInitializeEvent(pEvt, foo, foo2)
#define ExConvertExclusiveToSharedLite(res)
#define KeSetEvent(pEvt, foo, foo2)
#define ExAcquireResourceExclusiveLite(res, wait)
#define ExDeleteResourceLite(res)
#define RemoveHeadList(ListHead)
#define InitializeListHead(ListHead)
#define ExAcquireResourceSharedLite(res, wait)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
#define OBJ_KERNEL_HANDLE
#define OBJ_CASE_INSENSITIVE
#define UInt32x32To64(a, b)
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
struct _MOUNTDEV_NAME MOUNTDEV_NAME
struct _MOUNTDEV_UNIQUE_ID MOUNTDEV_UNIQUE_ID
#define IOCTL_MOUNTDEV_LINK_CREATED
#define IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
struct _GET_LENGTH_INFORMATION GET_LENGTH_INFORMATION
#define IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME
#define IOCTL_MOUNTDEV_QUERY_STABLE_GUID
#define IOCTL_DISK_GET_LENGTH_INFO
#define IOCTL_MOUNTDEV_QUERY_UNIQUE_ID
#define MOUNTMGR_DEVICE_NAME
struct _MOUNTDEV_STABLE_GUID MOUNTDEV_STABLE_GUID
#define InitializeObjectAttributes(p, n, a, r, s)
#define IOCTL_MOUNTMGR_NEXT_DRIVE_LETTER
#define _Function_class_(x)
#define FILE_AUTOGENERATED_DEVICE_NAME
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyValueFullInformation
#define FILE_READ_ATTRIBUTES
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define FILE_REMOVABLE_MEDIA
struct _DISK_GEOMETRY DISK_GEOMETRY
struct _STORAGE_DEVICE_NUMBER STORAGE_DEVICE_NUMBER
#define IOCTL_STORAGE_GET_DEVICE_NUMBER
#define IOCTL_STORAGE_CHECK_VERIFY
#define IOCTL_VOLUME_GET_GPT_ATTRIBUTES
struct _DISK_EXTENT DISK_EXTENT
#define IOCTL_VOLUME_ONLINE
#define IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
#define IoCompleteRequest
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
VOID NTAPI IoFreeIrp(IN PIRP Irp)
DRIVER_ADD_DEVICE AddDevice
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
NTSTATUS NTAPI IoRegisterPlugPlayNotification(_In_ IO_NOTIFICATION_EVENT_CATEGORY EventCategory, _In_ ULONG EventCategoryFlags, _In_opt_ PVOID EventCategoryData, _In_ PDRIVER_OBJECT DriverObject, _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, _Inout_opt_ PVOID Context, _Out_ PVOID *NotificationEntry)
NTSTATUS NTAPI IoUnregisterPlugPlayNotification(_In_ PVOID NotificationEntry)
NTSTATUS NTAPI IoReportDetectedDevice(_In_ PDRIVER_OBJECT DriverObject, _In_ INTERFACE_TYPE LegacyBusType, _In_ ULONG BusNumber, _In_ ULONG SlotNumber, _In_opt_ PCM_RESOURCE_LIST ResourceList, _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements, _In_ BOOLEAN ResourceAssigned, _Inout_ PDEVICE_OBJECT *DeviceObject)
#define offsetof(TYPE, MEMBER)
#define STATUS_DEVICE_NOT_READY
#define STATUS_MORE_PROCESSING_REQUIRED
#define STATUS_BUFFER_TOO_SMALL
#define STATUS_BUFFER_OVERFLOW
struct _IO_STACK_LOCATION::@3974::@3979 Write
struct _IO_STACK_LOCATION::@3974::@3978 Read
struct _IO_STACK_LOCATION::@1575::@1576 DeviceIoControl
union _IO_STACK_LOCATION::@1575 Parameters
union _IRP::@1577 AssociatedIrp
struct _LIST_ENTRY * Blink
struct _LIST_ENTRY * Flink
struct pdo_device_extension * pdode
PDEVICE_OBJECT mounted_device
volume_device_extension * vde
void * notification_entry
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_MEDIA_WRITE_PROTECTED
#define STATUS_ACCESS_DENIED
#define STATUS_INVALID_PARAMETER
#define STATUS_INSUFFICIENT_RESOURCES
#define STATUS_OBJECT_NAME_NOT_FOUND
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
_In_ PVOID NotificationStructure
#define IRP_DEALLOCATE_BUFFER
#define IRP_INPUT_OPERATION
#define DO_BUS_ENUMERATED_DEVICE
@ EventCategoryTargetDeviceChange
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
#define ObDereferenceObject