ExpTranslateEfiPath
NTSTATUS __stdcall ExpTranslateEfiPath(
_FILE_PATH *InputPath,
UINT64 OutputType,
_FILE_PATH *OutputPath,
UINT64 *OutputPathLength){
int v4;
NTSTATUS result;
UINT64 v6;
unsigned int v7;
unsigned int BytesPerSector;
_DISK_SIGNATURE_NEW *v9;
int DiskSignature;
UINT64 v11;
VOID **PoolWithTag;
WCHAR *v13;
UINT64 v14;
UINT64 v15;
UINT64 v16;
NTSTATUS v17;
unsigned int v18;
VOID **v19;
NTSTATUS v20;
PVOID pPathName;
NTSTATUS v22;
NTSTATUS DriveGeometry;
UINT64 *pPartitionSize;
UINT8 GPTpartition;
char v26;
PVOID P;
UINT64 pPartitionNumber;
UINT64 pDiskNumber;
UINT64 v30;
UINT64 pPartitionStart;
UINT64 *OutputPathLengtha;
_FILE_PATH *OutputPatha;
_UNICODE_STRING GuidString;
_UNICODE_STRING DestinationString;
_DISK_GEOMETRY DiskGeometry;
pPartitionNumber = 0i64;
P = 0i64;
v4 = OutputType;
pPartitionStart = 0i64;
v30 = 0i64;
OutputPathLengtha = OutputPathLength;
OutputPatha = OutputPath;
GPTpartition = 0;
GuidString = 0i64;
DestinationString = 0i64;
memset(&DiskGeometry, 0, sizeof(DiskGeometry));
result = ExpParseEfiPath(InputPath->FilePath, &pPartitionNumber, &P, (char *)&GPTpartition);
if( result >= 0 )
{
RtlInitUnicodeString(&DestinationString, 0i64);
v6 = pPartitionNumber;
v7 = 0;
LODWORD(pDiskNumber) = 0;
v26 = 0;
BytesPerSector = 1;
if( GPTpartition == 1 && v4 != 2 )
{
v9 = (_DISK_SIGNATURE_NEW *)(pPartitionNumber + 24);
DiskSignature = RtlStringFromGUIDEx((_GUID *)(pPartitionNumber + 24), &GuidString, 1u);
if( DiskSignature < 0 )
goto LABEL_12;
v11 = (unsigned int)GuidString.Length + 22;
PoolWithTag = ExAllocatePoolWithTag(0x200ui64, v11, 1920364101i64);
v13 = (WCHAR *)PoolWithTag;
if( !PoolWithTag )
{
ExFreePoolWithTag(GuidString.Buffer, 0);
LABEL_7:
if( P )
ExFreePoolWithTag(P, 0);
DiskSignature = -1073741670;
LABEL_42:
ExFreePoolWithTag((PVOID)v6, 0);
return DiskSignature;
}
v14 = v11 >> 1;
wcscpy_s((PWCHAR)PoolWithTag, v14, (PWCHAR)L"\\??\\Volume");
wcsncat_s(v13, v14, GuidString.Buffer, GuidString.Length);
ExFreePoolWithTag(GuidString.Buffer, 0);
LODWORD(v14) = ExpTranslateSymbolicLink(v13, &DestinationString);
ExFreePoolWithTag(v13, 0);
if( (v14 & 0x80000000) == 0i64 )
{
LABEL_27:
pPathName = P;
if( v4 == 3 )
{
v22 = ExpCreateOutputNT(OutputPatha, OutputPathLengtha, &DestinationString, (WCHAR *)P);
}
else if( v4 == 2 )
{
if( v26 == 1 )
{
DriveGeometry = ExpGetDriveGeometry(v7, &DiskGeometry);
if( DriveGeometry < 0 )
{
LABEL_36:
ExFreePoolWithTag(DestinationString.Buffer, 0);
if( pPathName )
ExFreePoolWithTag(pPathName, 0);
DiskSignature = DriveGeometry;
goto LABEL_42;
}
BytesPerSector = DiskGeometry.BytesPerSector;
}
LODWORD(pPartitionNumber) = *(_DWORD *)(v6 + 4);
pPartitionStart = BytesPerSector * *(_QWORD *)(v6 + 8);
v30 = BytesPerSector * *(_QWORD *)(v6 + 16);
v22 = ExpCreateOutputSIGNATURE(
OutputPatha,
OutputPathLengtha,
v9,
&pPartitionNumber,
&pPartitionStart,
&v30,
(PWCHAR)pPathName,
GPTpartition);
}
else
{
v22 = ExpCreateOutputARC(OutputPatha, OutputPathLengtha, &DestinationString, (WCHAR *)P);
}
DriveGeometry = v22;
goto LABEL_36;
}
}
v9 = (_DISK_SIGNATURE_NEW *)(v6 + 24);
LODWORD(pPartitionNumber) = *(_DWORD *)(v6 + 4);
DiskSignature = ExpFindDiskSignature(
(_DISK_SIGNATURE_NEW *)(v6 + 24),
&pPartitionNumber,
&pDiskNumber,
&pPartitionStart,
&v30,
GPTpartition);
if( DiskSignature < 0 )
{
LABEL_12:
if( P )
ExFreePoolWithTag(P, 0);
goto LABEL_42;
}
if( *(_DWORD *)(v6 + 4) == (_DWORD)pPartitionNumber )
{
v15 = pPartitionStart;
v7 = pDiskNumber;
v16 = v30;
if( *(_QWORD *)(v6 + 8) == pPartitionStart && *(_QWORD *)(v6 + 16) == v30 )
goto LABEL_22;
v17 = ExpGetDriveGeometry((unsigned int)pDiskNumber, &DiskGeometry);
v18 = DiskGeometry.BytesPerSector;
if( v17 < 0 )
v18 = 1;
DiskGeometry.BytesPerSector = v18;
if( *(_QWORD *)(v6 + 8) == v15 / v18 && *(_QWORD *)(v6 + 16) == v16 / v18 )
{
v26 = 1;
LABEL_22:
v19 = ExAllocatePoolWithTag(0x200ui64, 0x5Eui64, 1920364101i64);
if( !v19 )
goto LABEL_7;
LODWORD(pPartitionSize) = pPartitionNumber;
swprintf_s((WCHAR *)v19, 0x2Fui64, (WCHAR *)L"\\Device\\Harddisk%lu\\Partition%lu", v7, pPartitionSize);
v20 = ExpTranslateSymbolicLink((PWCHAR)v19, &DestinationString);
ExFreePoolWithTag(v19, 0);
if( v20 < 0 )
{
if( P )
ExFreePoolWithTag(P, 0);
DiskSignature = v20;
goto LABEL_42;
}
goto LABEL_27;
}
}
if( P )
ExFreePoolWithTag(P, 0);
DiskSignature = -1073741811;
goto LABEL_42;
}
return result;
}Referenced by:
NtTranslateFilePath