BiIssueGetDriveLayoutIoctl
NTSTATUS __stdcall BiIssueGetDriveLayoutIoctl(PVOID DeviceHandle, _DRIVE_LAYOUT_INFORMATION_EX **DriveLayout){
LARGE_INTEGER *v4;
ULONG OutputBufferLength;
_DRIVE_LAYOUT_INFORMATION_EX *OutputBuffer;
_DRIVE_LAYOUT_INFORMATION_EX *v7;
NTSTATUS v8;
NTSTATUS v9;
ULONG v11;
UINT64 i;
LARGE_INTEGER *PoolWithTag;
NTSTATUS v14;
_DRIVE_LAYOUT_INFORMATION_EX *v15;
LARGE_INTEGER *v16;
PARTITION_INFORMATION_EX *PartitionEntry;
unsigned int v18;
LARGE_INTEGER v19;
struct _IO_STATUS_BLOCK IoStatusBlock;
v4 = 0i64;
OutputBufferLength = 18480;
IoStatusBlock = 0i64;
OutputBuffer = (_DRIVE_LAYOUT_INFORMATION_EX *)ExAllocatePoolWithTag(PagedPool, 0x4830ui64, 0x4B444342ui64);
v7 = OutputBuffer;
if( !OutputBuffer )
return -1073741670;
while( 1 )
{
v8 = ZwDeviceIoControlFile(
DeviceHandle,
0i64,
0i64,
0i64,
&IoStatusBlock,
0x70050u,
0i64,
0,
OutputBuffer,
OutputBufferLength);
v9 = v8;
if( v8 != -1073741789 )
break;
ExFreePoolWithTag(v7, 0x4B444342u);
OutputBufferLength += 9216;
OutputBuffer = (_DRIVE_LAYOUT_INFORMATION_EX *)ExAllocatePoolWithTag(PagedPool, OutputBufferLength, 0x4B444342ui64);
v7 = OutputBuffer;
if( !OutputBuffer )
goto LABEL_11;
}
if( v8 >= 0 )
{
LABEL_4:
*DriveLayout = v7;
goto LABEL_5;
}
v11 = 2056;
for( i = 2056i64; ; i = v11 )
{
PoolWithTag = (LARGE_INTEGER *)ExAllocatePoolWithTag(PagedPool, i, 0x4B444342ui64);
v4 = PoolWithTag;
if( !PoolWithTag )
{
v9 = -1073741670;
goto LABEL_14;
}
v14 = ZwDeviceIoControlFile(DeviceHandle, 0i64, 0i64, 0i64, &IoStatusBlock, 0x7400Cu, 0i64, 0, PoolWithTag, v11);
v9 = v14;
if( v14 != -1073741789 )
break;
ExFreePoolWithTag(v4, 0x4B444342u);
v11 += 2048;
}
if( v14 >= 0 )
{
ExFreePoolWithTag(v7, 0x4B444342u);
v15 = (_DRIVE_LAYOUT_INFORMATION_EX *)ExAllocatePoolWithTag(PagedPool, 144 * v4->LowPart + 48, 0x4B444342ui64);
v7 = v15;
if( v15 )
{
memset((INT64)v15, 0i64);
v7->PartitionStyle = 0;
v16 = v4 + 1;
PartitionEntry = v7->PartitionEntry;
v7->PartitionCount = v4->LowPart;
v18 = 0;
for( v7->Mbr.Signature = v4->HighPart; v18 < v4->LowPart; PartitionEntry[-1].Mbr.HiddenSectors = v16[-2].LowPart )
{
PartitionEntry->PartitionStyle = PARTITION_STYLE_MBR;
++v18;
v19 = *v16;
v16 += 4;
PartitionEntry->StartingOffset = v19;
++PartitionEntry;
PartitionEntry[-1].PartitionLength = v16[-3];
PartitionEntry[-1].PartitionNumber = v16[-2].HighPart;
PartitionEntry[-1].RewritePartition = BYTE3(v16[-1].QuadPart);
PartitionEntry[-1].Mbr.PartitionType = v16[-1].LowPart;
PartitionEntry[-1].Mbr.BootIndicator = BYTE1(v16[-1].LowPart);
PartitionEntry[-1].Mbr.RecognizedPartition = BYTE2(v16[-1].u.LowPart);
}
goto LABEL_4;
}
LABEL_11:
v9 = -1073741670;
}
LABEL_5:
if( v4 )
ExFreePoolWithTag(v4, 0x4B444342u);
if( v9 < 0 )
{
LABEL_14:
if( v7 )
ExFreePoolWithTag(v7, 0x4B444342u);
}
return v9;
}Referenced by:
BiGetDriveLayoutInformation