37#define DOE_START_PENDING 0x10
55 bool second_time =
false;
57 static const WCHAR system_root[] =
L"\\SystemRoot";
58 static const WCHAR boot_device[] =
L"\\Device\\BootDevice";
59 static const WCHAR arc_btrfs_prefix[] =
L"\\ArcName\\btrfs(";
61 us.Buffer = (
WCHAR*)system_root;
62 us.Length =
us.MaximumLength =
sizeof(system_root) -
sizeof(
WCHAR);
69 ERR(
"ZwOpenSymbolicLinkObject returned %08lx\n",
Status);
77 ERR(
"ZwQuerySymbolicLinkObject returned %08lx\n",
Status);
89 ERR(
"out of memory\n");
98 ERR(
"ZwQuerySymbolicLinkObject returned %08lx\n",
Status);
112 if (!second_time &&
target.Length >=
sizeof(boot_device) -
sizeof(
WCHAR) &&
116 us.Buffer = (
WCHAR*)boot_device;
117 us.Length =
us.MaximumLength =
sizeof(boot_device) -
sizeof(
WCHAR);
124 if (
target.Length >=
sizeof(arc_btrfs_prefix) -
sizeof(
WCHAR) &&
128 for (
unsigned int i = 0;
i < 16;
i++) {
129 if (*
s >=
'0' && *
s <=
'9')
131 else if (*
s >=
'a' && *
s <=
'f')
133 else if (*
s >=
'A' && *
s <=
'F')
142 if (*
s >=
'0' && *
s <=
'9')
144 else if (*
s >=
'a' && *
s <=
'f')
146 else if (*
s >=
'A' && *
s <=
'F')
155 if (
i == 3 ||
i == 5 ||
i == 7 ||
i == 9) {
192 ERR(
"IoGetDeviceObjectPointer returned %08lx\n",
Status);
200 ERR(
"out of memory\n");
210 for (
unsigned int i = 0;
i < 16;
i++) {
214 if (
i == 3 ||
i == 5 ||
i == 7 ||
i == 9) {
224 ERR(
"IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION returned %08lx\n",
Status);
236 static const WCHAR pathw[] =
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control";
237 static const WCHAR namew[] =
L"SystemStartOptions";
238 static const WCHAR subvol[] =
L"SUBVOL=";
250 path.Length =
path.MaximumLength =
sizeof(pathw) -
sizeof(
WCHAR);
256 ERR(
"ZwOpenKey returned %08lx\n",
Status);
264 ERR(
"out of memory\n");
270 name.Length =
name.MaximumLength =
sizeof(namew) -
sizeof(
WCHAR);
275 ERR(
"ZwQueryValueKey returned %08lx\n",
Status);
290 s += (
sizeof(subvol) /
sizeof(
WCHAR)) - 1;
295 if (*
s >=
'0' && *
s <=
'9') {
298 }
else if (*
s >=
'a' && *
s <=
'f') {
301 }
else if (*
s >=
'A' && *
s <=
'F') {
326 if (pdo->DeviceObjectExtension) {
327 ((
DEVOBJ_EXTENSION2*)pdo->DeviceObjectExtension)->ExtensionFlags &= ~DOE_START_PENDING;
357 pdo_to_add = pdode->
pdo;
366 ERR(
"IoSetDeviceInterfaceState returned %08lx\n",
Status);
370 ERR(
"IoSetDeviceInterfaceState returned %08lx\n",
Status);
#define BTRFS_VOLUME_PREFIX
#define NT_SUCCESS(StatCode)
static bool get_system_root()
void boot_add_device(DEVICE_OBJECT *pdo)
static void mountmgr_notification(BTRFS_UUID *uuid)
static void check_boot_options()
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 ExAllocatePoolWithTag(hernya, size, tag)
#define RtlCompareMemory(s1, s2, l)
#define ExAcquireResourceExclusiveLite(res, wait)
#define DO_SYSTEM_BOOT_PARTITION
#define ExAcquireResourceSharedLite(res, wait)
GLubyte GLubyte GLubyte GLubyte w
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
#define EXCEPTION_EXECUTE_HANDLER
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define OBJ_KERNEL_HANDLE
#define OBJ_CASE_INSENSITIVE
#define MOUNTMGR_DEVICE_NAME
#define IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION
#define InitializeObjectAttributes(p, n, a, r, s)
NTSYSAPI NTSTATUS NTAPI ZwOpenSymbolicLinkObject(_Out_ PHANDLE SymbolicLinkHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
struct _KEY_VALUE_FULL_INFORMATION KEY_VALUE_FULL_INFORMATION
@ KeyValueFullInformation
#define FILE_READ_ATTRIBUTES
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
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)
DRIVER_ADD_DEVICE AddDevice
#define _SEH2_EXCEPT(...)
#define offsetof(TYPE, MEMBER)
#define STATUS_BUFFER_TOO_SMALL
PDEVICE_OBJECT DeviceObject
struct _LIST_ENTRY * Flink
volume_device_extension * vde
#define RtlCopyMemory(Destination, Source, Length)
#define CONTAINING_RECORD(address, type, field)
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName