ExpFindDiskSignature
NTSTATUS __stdcall ExpFindDiskSignature(
_DISK_SIGNATURE_NEW *pSignature,
UINT64 *pPartitionNumber,
UINT64 *pDiskNumber,
UINT64 *pPartitionStart,
UINT64 *pPartitionSize,
UINT8 GPTpartition){
_DRIVE_LAYOUT_INFORMATION_EX *v6;
unsigned __int8 *v7;
char v8;
NTSTATUS result;
int v10;
VOID **PoolWithTag;
unsigned int v12;
NTSTATUS PartitionTableInfo;
ULONG PartitionCount;
ULONG v15;
unsigned __int8 *Data4;
UINT64 *v17;
__int64 v18;
UINT64 *v19;
UINT64 *v20;
_DRIVE_LAYOUT_INFORMATION_EX *ppDriveLayout;
_DISK_SIGNATURE_NEW *v22;
UINT64 *v23;
UINT64 *v24;
UINT64 *v25;
__int128 v26;
__int64 v27;
v6 = 0i64;
v25 = pPartitionSize;
v24 = pPartitionStart;
v23 = pDiskNumber;
v20 = pPartitionNumber;
v22 = pSignature;
ppDriveLayout = 0i64;
v7 = 0i64;
v27 = 0i64;
v26 = 0i64;
v8 = 0;
ZwQuerySystemInformation();
v10 = result;
if( result < 0 )
return result;
PoolWithTag = ExAllocatePoolWithTag(0x200ui64, 0x4Cui64, 1920364101i64);
if( !PoolWithTag )
return -1073741670;
v12 = 0;
if( !(_DWORD)v26 )
goto LABEL_23;
do
{
swprintf_s((WCHAR *)PoolWithTag, 0x26ui64, (WCHAR *)L"\\Device\\Harddisk%lu\\Partition0", v12, v20);
PartitionTableInfo = ExpGetPartitionTableInfo((PWCHAR)PoolWithTag, &ppDriveLayout);
v6 = ppDriveLayout;
v10 = PartitionTableInfo;
if( PartitionTableInfo < 0 )
goto LABEL_22;
if( ppDriveLayout->PartitionStyle != (GPTpartition == 1)
|| GPTpartition != 1 && ppDriveLayout->Mbr.Signature != v22->Signature )
{
goto LABEL_21;
}
PartitionCount = ppDriveLayout->PartitionCount;
v15 = 0;
if( !PartitionCount )
goto LABEL_20;
Data4 = ppDriveLayout->PartitionEntry[0].Gpt.PartitionId[0].Data4;
while( 1 )
{
v7 = Data4 - 48;
if( GPTpartition == 1 )
break;
v17 = v20;
if( *((_DWORD *)Data4 - 6) == *(_DWORD *)v20 )
{
v8 = 1;
goto LABEL_24;
}
LABEL_17:
++v15;
Data4 += 144;
if( v15 >= PartitionCount )
goto LABEL_20;
}
v18 = *(_QWORD *)Data4 - *(_QWORD *)&v22->Signature;
if( *(_QWORD *)Data4 == *(_QWORD *)&v22->Signature )
v18 = *((_QWORD *)Data4 + 1) - *(_QWORD *)&v22[2].Signature;
if( v18 )
goto LABEL_17;
v8 = 1;
LABEL_20:
if( v8 == 1 )
break;
LABEL_21:
ExFreePoolWithTag(ppDriveLayout, 0);
LABEL_22:
++v12;
}
while( v12 < (unsigned int)v26 );
LABEL_23:
v17 = v20;
LABEL_24:
if( v10 >= 0 && !v8 )
v10 = -1073741766;
if( v8 == 1 )
{
v19 = v24;
*(_DWORD *)v17 = *((_DWORD *)v7 + 6);
*(_DWORD *)v23 = v12;
if( v19 )
*v19 = *((_QWORD *)v7 + 1);
if( v25 )
*v25 = *((_QWORD *)v7 + 2);
ExFreePoolWithTag(v6, 0);
}
ExFreePoolWithTag(PoolWithTag, 0);
return v10;
}Referenced by:
ExpConvertSignatureName
ExpCreateOutputEFI
ExpTranslateEfiPath