VhdiMountVhdFile
NTSTATUS __stdcall VhdiMountVhdFile(WCHAR *VhdFileName){
int DeviceInterfaces;
WCHAR *v3;
__int64 v4;
__int64 v5;
size_t v6;
unsigned int v7;
VOID **PoolWithTag;
VOID **v9;
size_t v10;
VOID **v11;
_IRP *v12;
char *v13;
__int128 v14;
WCHAR *v15;
_DEVICE_OBJECT *v16;
UINT64 v17;
_IRP *v18;
UINT64 OutputBufferLength;
UINT64 OutputBufferLengtha;
UINT64 OutputBufferLengthb;
UINT64 InternalDeviceIoControl;
_KEVENT *Event;
_IO_STATUS_BLOCK *IoStatusBlock;
UINT64 EaLength;
__int128 Object_8;
__int64 v28;
WCHAR *SymbolicLinkList;
PDEVICE_OBJECT DeviceObject;
PFILE_OBJECT FileObject;
_IO_STATUS_BLOCK v32;
_UNICODE_STRING DestinationString;
_UNICODE_STRING v34;
_OBJECT_ATTRIBUTES ObjectAttributes;
__int128 v36[6];
__int128 InputBuffer[3];
__int64 v38;
int EaBuffer[2];
__int64 v40;
GUID v41;
__int128 v42;
__int128 v43;
__int128 v44;
__int128 v45;
int v46;
int v47;
VOID *ReturnAddress;
DeviceObject = 0i64;
SymbolicLinkList = 0i64;
v28 = 0i64;
v38 = 0i64;
FileObject = 0i64;
DestinationString = 0i64;
Object_8 = 0i64;
v34 = 0i64;
v32 = 0i64;
memset(&ObjectAttributes, 0, sizeof(ObjectAttributes));
memset(InputBuffer, 0, sizeof(InputBuffer));
if( !VhdFileName )
{
DeviceInterfaces = -1073741811;
goto LABEL_3;
}
memset(v36, 0i64, 0x54u);
DeviceInterfaces = IoGetDeviceInterfaces(&GUID_DEVINTERFACE_SURFACE_VIRTUAL_DRIVE, 0i64, 0i64, &SymbolicLinkList);
if( DeviceInterfaces < 0 )
goto LABEL_3;
v3 = SymbolicLinkList;
if( !*SymbolicLinkList )
{
DeviceInterfaces = -1073741275;
goto LABEL_3;
}
RtlInitUnicodeString(&DestinationString, SymbolicLinkList);
DeviceInterfaces = IoGetDeviceObjectPointer(&DestinationString, 0x10000000ui64, &FileObject, &DeviceObject);
if( DeviceInterfaces < 0 )
goto LABEL_3;
v4 = -1i64;
v5 = -1i64;
do
++v5;
while( VhdFileName[v5] );
v6 = 2 * v5 + 2;
v7 = 2 * v5 + 34;
PoolWithTag = ExAllocatePoolWithTag(0x200ui64, v7, 1113876566i64);
v9 = PoolWithTag;
if( !PoolWithTag )
goto LABEL_11;
*((_DWORD *)PoolWithTag + 1) = 0;
*(GUID *)(PoolWithTag + 1) = VIRTUAL_STORAGE_TYPE_VENDOR_UNKNOWN;
*(_DWORD *)PoolWithTag = 1;
*((_DWORD *)PoolWithTag + 6) = 32;
*((_DWORD *)PoolWithTag + 7) = v6;
memmove(PoolWithTag + 4, VhdFileName, v6);
v10 = v6 + 540;
v11 = ExAllocatePoolWithTag(0x200ui64, v10, 1113876566i64);
if( !v11 )
{
LABEL_11:
DeviceInterfaces = -1073741801;
goto LABEL_3;
}
v28 = (__int64)&Object_8 + 8;
DWORD1(Object_8) = 0;
*((_QWORD *)&Object_8 + 1) = (char *)&Object_8 + 8;
LODWORD(OutputBufferLength) = v10;
LOWORD(Object_8) = 1;
BYTE2(Object_8) = 6;
v12 = IopBuildDeviceIoControlRequest(
0x2D592Cui64,
DeviceObject,
v9,
v7,
v11,
OutputBufferLength,
0,
(_KEVENT *)&Object_8,
&v32,
ReturnAddress);
if( !v12 )
goto LABEL_14;
DeviceInterfaces = IofCallDriver((UINT64)DeviceObject, (UINT64)v12);
if( DeviceInterfaces == 259 )
{
KeWaitForSingleObject((UINT64)&Object_8, 0, 0, 0, 0i64);
DeviceInterfaces = v32.Status;
}
if( DeviceInterfaces < 0 )
goto LABEL_3;
v13 = (char *)v11 + *((unsigned int *)v11 + 5);
if( *(_WORD *)v13 == 92 && *((_WORD *)v13 + 1) == 92 && *((_WORD *)v13 + 2) == 46 && *((_WORD *)v13 + 3) == 92 )
*(_DWORD *)(v13 + 2) = 4128831;
do
++v4;
while( VhdFileName[v4] );
wcscat_s((WCHAR *)v13, (unsigned int)(v4 + 257), VhdFileName);
RtlInitUnicodeString(&v34, (PCWSTR)v13);
LODWORD(EaLength) = 103;
ObjectAttributes.ObjectName = &v34;
ObjectAttributes.Length = 48;
v47 = 0;
ObjectAttributes.RootDirectory = 0i64;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
ObjectAttributes.Attributes = 512;
*(_QWORD *)((char *)&v36[2] + 4) = 0x400000054i64;
v40 = 0x4B534454524956i64;
EaBuffer[0] = 0;
EaBuffer[1] = 5506944;
v14 = *(_OWORD *)v11;
LODWORD(v36[2]) = *((_DWORD *)v11 + 4);
v42 = v14;
DWORD1(v36[3]) = 2;
v46 = v36[5];
LODWORD(IoStatusBlock) = 0;
LODWORD(Event) = 2;
v41 = GUID_DEVINTERFACE_SURFACE_VIRTUAL_DRIVE;
LODWORD(InternalDeviceIoControl) = 1;
v43 = v36[2];
LODWORD(OutputBufferLengtha) = 128;
v44 = v36[3];
v45 = v36[4];
DeviceInterfaces = ZwCreateFile(
(VOID **)&Handle,
0x80000000ui64,
&ObjectAttributes,
&v32,
0i64,
OutputBufferLengtha,
InternalDeviceIoControl,
(UINT64)Event,
(UINT64)IoStatusBlock,
EaBuffer,
EaLength);
if( DeviceInterfaces < 0 )
goto LABEL_3;
SymbolicLinkList = 0i64;
DeviceInterfaces = ObReferenceObjectByHandle(
*(VOID **)&Handle,
0xC0100000ui64,
0i64,
0,
(VOID **)&SymbolicLinkList,
0i64);
if( DeviceInterfaces < 0 )
goto LABEL_3;
v15 = SymbolicLinkList;
LODWORD(v16) = IoGetRelatedDeviceObject((INT64)SymbolicLinkList);
v17 = (UINT64)v16;
LODWORD(InputBuffer[0]) = 1;
LOWORD(Object_8) = 1;
v28 = (__int64)&Object_8 + 8;
BYTE2(Object_8) = 6;
*((_QWORD *)&Object_8 + 1) = (char *)&Object_8 + 8;
DWORD1(Object_8) = 0;
LODWORD(OutputBufferLengthb) = 0;
v18 = IopBuildDeviceIoControlRequest(
0x2D191Cui64,
v16,
InputBuffer,
0x38ui64,
0i64,
OutputBufferLengthb,
0,
(_KEVENT *)&Object_8,
&v32,
ReturnAddress);
if( !v18 )
{
LABEL_14:
DeviceInterfaces = -1073741670;
goto LABEL_3;
}
v18->Tail.CurrentStackLocation[-1].FileObject = (_FILE_OBJECT *)v15;
DeviceInterfaces = IofCallDriver(v17, (UINT64)v18);
if( DeviceInterfaces == 259 )
{
KeWaitForSingleObject((UINT64)&Object_8, 0, 0, 0, 0i64);
DeviceInterfaces = v32.Status;
}
if( DeviceInterfaces < 0 )
LABEL_3:
KeBugCheckEx(0x12Fu, (PVOID)5, (PVOID)DeviceInterfaces, 0i64, 0i64);
ExFreeHeapPool(v9);
ExFreeHeapPool(v11);
if( v15 )
ObfDereferenceObjectWithTag(v15, 0x746C6644ui64);
if( FileObject )
ObfDereferenceObjectWithTag(FileObject, 0x746C6644ui64);
ExFreeHeapPool(v3);
return DeviceInterfaces;
}Referenced by:
VhdInitialize