IopMountVolume
NTSTATUS __stdcall IopMountVolume(
_DEVICE_OBJECT *DeviceObject,
UINT8 AllowRawMount,
UINT8 DeviceLockAlreadyHeld,
UINT8 Alertable,
_VPB **Vpb){
_GUID *v5;
_ETHREAD *CurrentThread;
char v10;
char v11;
_ETHREAD *v12;
signed int v13;
char v14;
char VpbFlagsSafe;
_DEVICE_OBJECT *AttachedDevice;
_DEVICE_OBJECT *v17;
unsigned int DeviceType;
char *v19;
__int64 *v20;
int v21;
UINT8 v22;
__int64 v23;
bool v24;
_ETHREAD *v25;
_KEVENT *v26;
_ADAPTER_OBJECT *v28;
char v29;
_ADAPTER_OBJECT *ScatterBufferListHead;
_DEVICE_OBJECT *v31;
_IRP *IrpWithExtension;
UINT64 v33;
_IO_STACK_LOCATION *CurrentStackLocation;
int v35;
_DEVICE_OBJECT *v36;
NTSTATUS v37;
_VPB *v38;
char v39;
char v40;
char v41;
char v43;
char v44;
UINT8 MountedAsRaw;
unsigned int RawMountOnly;
int RawMountOnly_4;
_ETHREAD *Thread;
_GUID *ActivityId;
_UNICODE_STRING DosName;
INT64 Status[2];
__int128 v54;
_DEVICE_OBJECT *DeviceObjecta;
_VPB **v56;
char *v57;
__int128 Object;
__int64 v59;
_GUID Guid;
VOID *retaddr;
v56 = Vpb;
v5 = 0i64;
v59 = 0i64;
v44 = 0;
v41 = 0;
Object = 0i64;
ActivityId = 0i64;
*(_OWORD *)Status = 0i64;
v54 = 0i64;
Guid = 0i64;
DosName = 0i64;
MmIsThisAnNtAsSystem((CHAR)DeviceObject, AllowRawMount);
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
Thread = CurrentThread;
v11 = v10;
v43 = v10;
if( !ExAcquireRundownProtection((_EX_RUNDOWN_REF *)&stru_140C452E0 + 173) )
return -1073741431;
if( v11 )
{
ActivityId = IoGetActivityIdThread();
v5 = ActivityId;
IoVolumeDeviceToGuid(DeviceObject, &Guid);
IoVolumeDeviceToDosName(DeviceObject, &DosName);
}
if( DeviceLockAlreadyHeld )
{
v14 = 0;
}
else
{
v12 = (_ETHREAD *)KeGetCurrentThread();
--v12->Tcb.KernelApcDisable;
v13 = IopWaitForLockAlertable(DeviceObject->gap118, CurrentThread->Tcb.PreviousMode, Alertable);
if( v13 < 0 )
{
KeLeaveCriticalRegion();
if( DosName.Buffer )
ExFreePoolWithTag(DosName.Buffer, 0);
goto LABEL_33;
}
v11 = v43;
v14 = 1;
v41 = 1;
}
--CurrentThread->Tcb.KernelApcDisable;
ExAcquireResourceSharedLite((UINT64)&stru_140C452E0 + 1280, 1);
VpbFlagsSafe = IopQueryVpbFlagsSafe(DeviceObject);
if( (VpbFlagsSafe & 9) != 0 )
{
v13 = (VpbFlagsSafe & 8) != 0 ? 0xC00000C0 : 0;
goto LABEL_23;
}
if( v11 )
{
IopLogEventIoMgrMountBegin(v5, &Guid, &DosName);
v44 = 1;
}
KeInitializeEvent((INT64)&Object, 0, 0);
DeviceObject->Flags &= ~2u;
v13 = -1073741823;
AttachedDevice = DeviceObject->AttachedDevice;
v17 = DeviceObject;
while( AttachedDevice )
{
v17 = AttachedDevice;
AttachedDevice = AttachedDevice->AttachedDevice;
}
ObfReferenceObject(v17);
DeviceType = DeviceObject->DeviceType;
if( DeviceType == 7 || DeviceType == 36 )
{
v19 = (char *)&stru_140C452E0 + 1552;
}
else
{
v19 = (char *)&stru_140C452E0 + 1568;
if( DeviceType != 2 )
v19 = (char *)&stru_140C452E0 + 1520;
}
v20 = *(__int64 **)v19;
v21 = DeviceObject->Vpb->Flags & 0x10;
RawMountOnly = v21;
if( *(char **)v19 == v19 )
{
LABEL_56:
HalPutDmaAdapter((PADAPTER_OBJECT)v17);
goto LABEL_23;
}
v22 = AllowRawMount;
while( 1 )
{
if( v13 >= 0 )
{
v14 = v41;
goto LABEL_23;
}
v23 = *v20;
v24 = *v20 == (_QWORD)v19;
v57 = (char *)*v20;
MountedAsRaw = v24;
if( !v22 && (char *)v23 == v19 && v20 != *(__int64 **)v19 )
goto LABEL_22;
if( !v21 || (char *)v23 == v19 )
break;
LABEL_21:
v20 = (__int64 *)*v20;
if( v20 == (__int64 *)v19 )
goto LABEL_22;
}
v28 = (_ADAPTER_OBJECT *)(v20 - 10);
v29 = 1;
ScatterBufferListHead = (_ADAPTER_OBJECT *)*(v20 - 7);
DeviceObjecta = (_DEVICE_OBJECT *)(v20 - 10);
while( ScatterBufferListHead )
{
v28 = ScatterBufferListHead;
++v29;
ScatterBufferListHead = (_ADAPTER_OBJECT *)ScatterBufferListHead->AdapterObject.ScatterBufferListHead;
}
KeResetEvent((_KEVENT *)&Object);
IrpWithExtension = IopAllocateIrpWithExtension(v31, v29 + v17->StackSize, 0, retaddr);
v33 = (UINT64)IrpWithExtension;
if( !IrpWithExtension )
{
v13 = -1073741670;
goto LABEL_90;
}
CurrentStackLocation = IrpWithExtension->Tail.CurrentStackLocation;
IrpWithExtension->Flags = 66;
IrpWithExtension->RequestorMode = 0;
IrpWithExtension->UserEvent = (_KEVENT *)&Object;
IrpWithExtension->UserIosb = (_IO_STATUS_BLOCK *)Status;
IrpWithExtension->Tail.Thread = Thread;
CurrentStackLocation[-1].Flags = AllowRawMount;
*(_WORD *)&CurrentStackLocation[-1].MajorFunction = 269;
CurrentStackLocation[-1].Parameters.SecurityContext = (_IO_SECURITY_CONTEXT *)DeviceObject->Vpb;
v35 = *(&stru_140C452E0 + 282);
*(_QWORD *)&CurrentStackLocation[-1].Parameters.Options = v17;
RawMountOnly_4 = v35;
ObfReferenceObject(v28);
v36 = DeviceObjecta;
IopIncrementDeviceObjectRefCount(DeviceObjecta, 1u);
_InterlockedIncrement((_DWORD *)&WheapErrorSourceTable + 220);
ExReleaseResourceLite((PERESOURCE)((char *)&stru_140C452E0 + 1280));
v37 = IofCallDriver((UINT64)v28, v33);
if( v37 == 259 )
{
KeWaitForSingleObject((UINT64)&Object, 0, 0, 0, 0i64);
}
else
{
Status[1] = 0i64;
LODWORD(Status[0]) = v37;
}
ExAcquireResourceSharedLite((UINT64)&stru_140C452E0 + 1280, 1);
_InterlockedAdd((_DWORD *)&WheapErrorSourceTable + 220, 0xFFFFFFFF);
if( *(&stru_140CF2E80 + 1629) )
KeSetEvent((PRKEVENT)((char *)&stru_140C452E0 + 2496), 0, 0);
HalPutDmaAdapter(v28);
IopDecrementDeviceObjectRef(v36, 0, 0);
v13 = Status[0];
if( SLODWORD(Status[0]) >= 0 )
{
v38 = IopMountInitializeVpb(DeviceObject, v17, RawMountOnly, MountedAsRaw);
*v56 = v38;
LABEL_51:
v22 = AllowRawMount;
v21 = RawMountOnly;
goto LABEL_21;
}
if( ((unsigned int)(LODWORD(Status[0]) + 1073741662) <= 1
|| (unsigned int)(LODWORD(Status[0]) + 1073741806) <= 2
|| LODWORD(Status[0]) == -2147483626
|| LODWORD(Status[0]) == -1073741643)
&& Status[1] == 1 )
{
goto LABEL_22;
}
if( RawMountOnly_4 != *(&stru_140C452E0 + 282) )
{
v20 = (__int64 *)&v54;
*(_QWORD *)&v54 = *(_QWORD *)v19;
v13 = -1073741489;
}
if( v13 != -1073741412 )
{
LABEL_50:
if( v13 != -1073741489 )
{
FsRtlIsTotalDeviceFailure((unsigned int)v13);
if( v39 )
{
if( !AllowRawMount || v57 == v19 )
goto LABEL_22;
v20 = *(__int64 **)(*((_QWORD *)v19 + 1) + 8i64);
}
}
goto LABEL_51;
}
IopIncrementDeviceObjectRefCount(v36, 1u);
ExReleaseResourceLite((PERESOURCE)((char *)&stru_140C452E0 + 1280));
v26 = (_KEVENT *)DeviceObject->gap118;
if( !DeviceLockAlreadyHeld )
{
KeSetEvent((PRKEVENT)DeviceObject->gap118, 0, 0);
v41 = 0;
}
v25 = Thread;
KeLeaveCriticalRegionThread(&Thread->Tcb);
IopLoadFileSystemDriver(v36);
if( !DeviceLockAlreadyHeld )
{
v13 = IopWaitForLockAlertable(DeviceObject->gap118, Thread->Tcb.PreviousMode, Alertable);
if( v13 < 0 )
{
HalPutDmaAdapter((PADAPTER_OBJECT)v17);
KeLeaveCriticalRegion();
v14 = v41;
goto LABEL_24;
}
v41 = 1;
}
--Thread->Tcb.KernelApcDisable;
ExAcquireResourceSharedLite((UINT64)&stru_140C452E0 + 1280, 1);
v40 = IopQueryVpbFlagsSafe(DeviceObject);
if( (v40 & 8) != 0 )
{
v13 = -1073741632;
LABEL_90:
v14 = v41;
goto LABEL_56;
}
if( (v40 & 1) == 0 )
{
v20 = (__int64 *)&v54;
*(_QWORD *)&v54 = *(_QWORD *)v19;
v13 = -1073741489;
goto LABEL_50;
}
HalPutDmaAdapter((PADAPTER_OBJECT)v17);
v13 = 0;
LABEL_22:
v14 = v41;
if( v13 < 0 )
goto LABEL_56;
LABEL_23:
ExReleaseResourceLite((PERESOURCE)((char *)&stru_140C452E0 + 1280));
v25 = Thread;
v26 = (_KEVENT *)DeviceObject->gap118;
LABEL_24:
if( v14 )
{
KeSetEvent(v26, 0, 0);
KeLeaveCriticalRegion();
}
KeLeaveCriticalRegionThread(&v25->Tcb);
if( v43 )
{
if( v44 )
{
if( v13 < 0 )
IopLogEventIoMgrMountFailed(ActivityId, &Guid, &DosName, (unsigned int)v13);
else
IopLogEventIoMgrMountSucceeded(ActivityId, &Guid, &DosName);
}
if( DosName.Buffer )
ExFreePoolWithTag(DosName.Buffer, 0);
}
if( v13 < 0 && (DeviceObject->Flags & 0x100) != 0 && (unsigned int)InitializationPhase < 2 )
KeBugCheckEx(0xEDu, DeviceObject, (PVOID)v13, 0i64, 0i64);
LABEL_33:
ExReleaseRundownProtection((_EX_RUNDOWN_REF *)&stru_140C452E0 + 173);
return v13;
}Referenced by:
IoVerifyVolume
IopCheckVpbMounted