IopMountVolume
NTSTATUS __stdcall IopMountVolume(
DEVICE_OBJECT *DeviceObject,
UINT8 AllowRawMount,
UINT8 DeviceLockAlreadyHeld,
UINT8 Alertable,
VPB **Vpb){
GUID *v5;
_ETHREAD *CurrentThread;
char v10;
char v11;
BOOL v12;
_ETHREAD *v13;
signed int v14;
char v15;
char VpbFlagsSafe;
__int64 v17;
DEVICE_OBJECT *v18;
UINT64 v19;
UINT8 v20;
UINT8 v21;
int v22;
_LIST_ENTRY *v23;
__int64 *Flink;
int v25;
__int64 v26;
bool v27;
__int64 v28;
struct _KEVENT *v29;
_DEVICE_OBJECT *v31;
char v32;
__int64 v33;
_DEVICE_OBJECT *v34;
_IRP *IrpWithExtension;
IRP *v36;
__int64 v37;
int v38;
DEVICE_OBJECT *v39;
NTSTATUS v40;
BOOL v41;
_VPB *v42;
BOOL v43;
char v44;
IRP *BugCheckParameter4;
char v46;
char v48;
char v49;
UINT8 MountedAsRaw;
unsigned int RawMountOnly;
int RawMountOnly_4;
__int64 v55;
GUID *ActivityId;
struct _UNICODE_STRING DosName;
NTSTATUS Status[4];
__int128 v59;
ULONG_PTR BugCheckParameter2;
VPB **v61;
_LIST_ENTRY *v62;
struct _KEVENT Event;
GUID Guid;
PVOID retaddr;
v61 = Vpb;
v5 = 0i64;
v49 = 0;
v46 = 0;
memset(&Event, 0, sizeof(Event));
ActivityId = 0i64;
*(_OWORD *)Status = 0i64;
v59 = 0i64;
Guid = 0i64;
DosName = 0i64;
MmIsThisAnNtAsSystem((CHAR)DeviceObject, AllowRawMount);
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
v55 = (__int64)CurrentThread;
v11 = v10;
v48 = v10;
if( !ExAcquireRundownProtection((PEX_RUNDOWN_REF)&IopFilesystemDatabaseShutdownRundown) )
return -1073741431;
if( v11 )
{
ActivityId = (GUID *)IoGetActivityIdThread();
v5 = ActivityId;
IoVolumeDeviceToGuid(DeviceObject, &Guid);
IoVolumeDeviceToDosName(DeviceObject, &DosName);
}
if( DeviceLockAlreadyHeld )
{
v15 = 0;
}
else
{
v13 = (_ETHREAD *)KeGetCurrentThread();
--*((_WORD *)v13 + 242);
v14 = IopWaitForLockAlertable((char *)DeviceObject + 280, *((_BYTE *)CurrentThread + 562), Alertable);
if( v14 < 0 )
{
KeLeaveCriticalRegion();
if( DosName.Buffer )
ExFreePoolWithTag(DosName.Buffer, 0);
goto LABEL_33;
}
v11 = v48;
v15 = 1;
v46 = 1;
}
--*((_WORD *)CurrentThread + 242);
LOBYTE(v12) = 1;
ExAcquireResourceSharedLite(&IopDatabaseResource, v12);
VpbFlagsSafe = IopQueryVpbFlagsSafe(DeviceObject);
if( (VpbFlagsSafe & 9) != 0 )
{
v14 = (VpbFlagsSafe & 8) != 0 ? 0xC00000C0 : 0;
goto LABEL_23;
}
if( v11 )
{
IopLogEventIoMgrMountBegin(v5, &Guid, &DosName);
v49 = 1;
}
KeInitializeEvent(&Event, NotificationEvent, 0);
*((_DWORD *)DeviceObject + 12) &= ~2u;
v14 = -1073741823;
v17 = *((_QWORD *)DeviceObject + 3);
v18 = DeviceObject;
while( v17 )
{
v18 = (DEVICE_OBJECT *)v17;
v17 = *(_QWORD *)(v17 + 24);
}
ObfReferenceObject(v18);
v22 = *((_DWORD *)DeviceObject + 18);
if( v22 == 7 || v22 == 36 )
{
v23 = &IopDiskFileSystemQueueHead;
}
else
{
v23 = (_LIST_ENTRY *)IopCdRomFileSystemQueueHead;
if( v22 != 2 )
v23 = &IopTapeFileSystemQueueHead;
}
Flink = (__int64 *)v23->Flink;
v25 = *(_WORD *)(*((_QWORD *)DeviceObject + 7) + 4i64) & 0x10;
RawMountOnly = v25;
if( v23->Flink == v23 )
{
LABEL_56:
HalPutDmaAdapter((PADAPTER_OBJECT)v18);
goto LABEL_23;
}
LOBYTE(v19) = AllowRawMount;
while( 1 )
{
if( v14 >= 0 )
{
v15 = v46;
goto LABEL_23;
}
v26 = *Flink;
v27 = *Flink == (_QWORD)v23;
v62 = (_LIST_ENTRY *)*Flink;
MountedAsRaw = v27;
if( !(_BYTE)v19 && (_LIST_ENTRY *)v26 == v23 && Flink != (__int64 *)v23->Flink )
goto LABEL_22;
if( !v25 || (_LIST_ENTRY *)v26 == v23 )
break;
LABEL_21:
Flink = (__int64 *)*Flink;
if( Flink == (__int64 *)v23 )
goto LABEL_22;
}
v31 = (_DEVICE_OBJECT *)(Flink - 10);
v32 = 1;
v33 = *(Flink - 7);
BugCheckParameter2 = (ULONG_PTR)(Flink - 10);
while( v33 )
{
v31 = (_DEVICE_OBJECT *)v33;
++v32;
v33 = *(_QWORD *)(v33 + 24);
}
KeResetEvent(&Event, v19, v20, v21, BugCheckParameter4);
IrpWithExtension = IopAllocateIrpWithExtension(v34, v32 + *((_BYTE *)v18 + 76), 0, retaddr);
v36 = IrpWithExtension;
if( !IrpWithExtension )
{
v14 = -1073741670;
goto LABEL_90;
}
v37 = *((_QWORD *)IrpWithExtension + 23);
*((_DWORD *)IrpWithExtension + 4) = 66;
*((_BYTE *)IrpWithExtension + 64) = 0;
*((_QWORD *)IrpWithExtension + 10) = &Event;
*((_QWORD *)IrpWithExtension + 9) = Status;
*((_QWORD *)IrpWithExtension + 19) = v55;
*(_BYTE *)(v37 - 70) = AllowRawMount;
*(_WORD *)(v37 - 72) = 269;
*(_QWORD *)(v37 - 64) = *((_QWORD *)DeviceObject + 7);
v38 = IopFsRegistrationOps;
*(_QWORD *)(v37 - 56) = v18;
RawMountOnly_4 = v38;
ObfReferenceObject(v31);
v39 = (DEVICE_OBJECT *)BugCheckParameter2;
IopIncrementDeviceObjectRefCount((_DEVICE_OBJECT *)BugCheckParameter2, 1u);
_InterlockedIncrement(&IopMountsInProgress);
ExReleaseResourceLite(&IopDatabaseResource);
v40 = IofCallDriver(v31, v36);
if( v40 == 259 )
{
KeWaitForSingleObject(&Event, Executive, 0, 0, 0i64);
}
else
{
*(_QWORD *)&Status[2] = 0i64;
Status[0] = v40;
}
LOBYTE(v41) = 1;
ExAcquireResourceSharedLite(&IopDatabaseResource, v41);
_InterlockedAdd(&IopMountsInProgress, 0xFFFFFFFF);
if( IopMountCompletionWaiters )
KeSetEvent(&IopMountCompletionEvent, 0);
HalPutDmaAdapter((PADAPTER_OBJECT)v31);
IopDecrementDeviceObjectRef(v39, 0, 0);
v14 = Status[0];
if( Status[0] >= 0 )
{
v42 = IopMountInitializeVpb(DeviceObject, v18, RawMountOnly, MountedAsRaw);
*v61 = v42;
LABEL_51:
LOBYTE(v19) = AllowRawMount;
v25 = RawMountOnly;
goto LABEL_21;
}
if( ((unsigned int)(Status[0] + 1073741662) <= 1
|| (unsigned int)(Status[0] + 1073741806) <= 2
|| Status[0] == -2147483626
|| Status[0] == -1073741643)
&& *(_QWORD *)&Status[2] == 1i64 )
{
goto LABEL_22;
}
if( RawMountOnly_4 != IopFsRegistrationOps )
{
Flink = (__int64 *)&v59;
*(_QWORD *)&v59 = v23->Flink;
v14 = -1073741489;
}
if( v14 != -1073741412 )
{
LABEL_50:
if( v14 != -1073741489 && FsRtlIsTotalDeviceFailure(v14) )
{
if( !AllowRawMount || v62 == v23 )
goto LABEL_22;
Flink = (__int64 *)v23->Blink->Blink;
}
goto LABEL_51;
}
IopIncrementDeviceObjectRefCount(v39, 1u);
ExReleaseResourceLite(&IopDatabaseResource);
v29 = (struct _KEVENT *)((char *)DeviceObject + 280);
if( !DeviceLockAlreadyHeld )
{
KeSetEvent((PRKEVENT)((char *)DeviceObject + 280), 0);
v46 = 0;
}
v28 = v55;
KeLeaveCriticalRegionThread(v55);
IopLoadFileSystemDriver(v39);
if( !DeviceLockAlreadyHeld )
{
v14 = IopWaitForLockAlertable((char *)DeviceObject + 280, *(_BYTE *)(v55 + 562), Alertable);
if( v14 < 0 )
{
HalPutDmaAdapter((PADAPTER_OBJECT)v18);
KeLeaveCriticalRegion();
v15 = v46;
goto LABEL_24;
}
v46 = 1;
}
--*(_WORD *)(v55 + 484);
LOBYTE(v43) = 1;
ExAcquireResourceSharedLite(&IopDatabaseResource, v43);
v44 = IopQueryVpbFlagsSafe(DeviceObject);
if( (v44 & 8) != 0 )
{
v14 = -1073741632;
LABEL_90:
v15 = v46;
goto LABEL_56;
}
if( (v44 & 1) == 0 )
{
Flink = (__int64 *)&v59;
*(_QWORD *)&v59 = v23->Flink;
v14 = -1073741489;
goto LABEL_50;
}
HalPutDmaAdapter((PADAPTER_OBJECT)v18);
v14 = 0;
LABEL_22:
v15 = v46;
if( v14 < 0 )
goto LABEL_56;
LABEL_23:
ExReleaseResourceLite(&IopDatabaseResource);
v28 = v55;
v29 = (struct _KEVENT *)((char *)DeviceObject + 280);
LABEL_24:
if( v15 )
{
KeSetEvent(v29, 0);
KeLeaveCriticalRegion();
}
KeLeaveCriticalRegionThread(v28);
if( v48 )
{
if( v49 )
{
if( v14 < 0 )
IopLogEventIoMgrMountFailed(ActivityId, &Guid, &DosName, (unsigned int)v14);
else
IopLogEventIoMgrMountSucceeded(ActivityId, &Guid, &DosName);
}
if( DosName.Buffer )
ExFreePoolWithTag(DosName.Buffer, 0);
}
if( v14 < 0 && (*((_DWORD *)DeviceObject + 12) & 0x100) != 0 && *(_DWORD *)InitializationPhase < 2u )
KeBugCheckEx(0xEDu, (ULONG_PTR)DeviceObject, v14, 0i64, 0i64);
LABEL_33:
ExReleaseRundownProtection((PEX_RUNDOWN_REF)&IopFilesystemDatabaseShutdownRundown);
return v14;
}Referenced by:
IoVerifyVolume
IopCheckVpbMounted