ExpTranslateEfiPath
INT64 __fastcall ExpTranslateEfiPath(INT64 a1, INT64 a2, _DWORD *a3, UINT64 *a4){
int v4;
INT64 result;
WCHAR v6;
unsigned int *v7;
unsigned int v8;
DWORD BytesPerSector;
unsigned int *v10;
int DiskSignature;
UINT64 v12;
WCHAR *PoolWithTag;
WCHAR *v14;
UINT64 v15;
unsigned __int64 v16;
unsigned __int64 v17;
int v18;
DWORD v19;
WCHAR *v20;
NTSTATUS v21;
PVOID v22;
int OutputNT;
int DriveGeometry;
char v25;
char v26;
PVOID v27;
PVOID v28;
UINT64 DiskNumber;
__int64 v30;
__int64 v31;
UINT64 *a2a;
INT64 v33;
PVOID P[2];
struct _UNICODE_STRING DestinationString;
_DISK_GEOMETRY DiskGeometry;
v28 = 0i64;
v27 = 0i64;
v4 = a2;
v31 = 0i64;
v30 = 0i64;
a2a = a4;
v33 = (INT64)a3;
v25 = 0;
*(_OWORD *)P = 0i64;
DestinationString = 0i64;
memset(&DiskGeometry, 0, sizeof(DiskGeometry));
result = ExpParseEfiPath((void *)(a1 + 12), &v28, &v27, &v25);
if( (int)result >= 0 )
{
RtlInitUnicodeString(&DestinationString, 0i64, v6);
v7 = (unsigned int *)v28;
v8 = 0;
LODWORD(DiskNumber) = 0;
v26 = 0;
BytesPerSector = 1;
if( v25 == 1 && v4 != 2 )
{
v10 = (unsigned int *)((char *)v28 + 24);
DiskSignature = RtlStringFromGUIDEx((const _GUID *const)((char *)v28 + 24), (_UNICODE_STRING *)P, 1u);
if( DiskSignature < 0 )
goto LABEL_12;
v12 = (unsigned int)LOWORD(P[0]) + 22;
PoolWithTag = (WCHAR *)ExAllocatePoolWithTag(NonPagedPoolNx, v12, 0x72766E45ui64);
v14 = PoolWithTag;
if( !PoolWithTag )
{
ExFreePoolWithTag(P[1], 0);
LABEL_7:
if( v27 )
ExFreePoolWithTag(v27, 0);
DiskSignature = -1073741670;
LABEL_42:
ExFreePoolWithTag(v7, 0);
return(unsigned int)DiskSignature;
}
v15 = v12 >> 1;
wcscpy_s(PoolWithTag, v15, (PWCHAR)L"\\??\\Volume");
wcsncat_s(v14, v15, (WCHAR *)P[1], LOWORD(P[0]));
ExFreePoolWithTag(P[1], 0);
LODWORD(v15) = ExpTranslateSymbolicLink(v14, &DestinationString);
ExFreePoolWithTag(v14, 0);
if( (v15 & 0x80000000) == 0i64 )
{
LABEL_27:
v22 = v27;
if( v4 == 3 )
{
OutputNT = ExpCreateOutputNT(v33, a2a, (const WCHAR **)&DestinationString, (const WCHAR *)v27);
}
else if( v4 == 2 )
{
if( v26 == 1 )
{
DriveGeometry = ExpGetDriveGeometry(v8, &DiskGeometry);
if( DriveGeometry < 0 )
{
LABEL_36:
ExFreePoolWithTag(DestinationString.Buffer, 0);
if( v22 )
ExFreePoolWithTag(v22, 0);
DiskSignature = DriveGeometry;
goto LABEL_42;
}
BytesPerSector = DiskGeometry.BytesPerSector;
}
LODWORD(v28) = v7[1];
v31 = BytesPerSector * *((_QWORD *)v7 + 1);
v30 = BytesPerSector * *((_QWORD *)v7 + 2);
OutputNT = ExpCreateOutputSIGNATURE(
v33,
(unsigned int *)a2a,
v10,
(unsigned int *)&v28,
(__int64)&v31,
(__int64)&v30,
(wchar_t *)v22,
v25);
}
else
{
OutputNT = ExpCreateOutputARC((_DWORD *)v33, a2a, &DestinationString, (WCHAR *)v27);
}
DriveGeometry = OutputNT;
goto LABEL_36;
}
}
v10 = v7 + 6;
LODWORD(v28) = v7[1];
DiskSignature = ExpFindDiskSignature((__int64)(v7 + 6), &v28, (unsigned int *)&DiskNumber, (__int64)&v31, &v30, v25);
if( DiskSignature < 0 )
{
LABEL_12:
if( v27 )
ExFreePoolWithTag(v27, 0);
goto LABEL_42;
}
if( v7[1] == (_DWORD)v28 )
{
v16 = v31;
v8 = DiskNumber;
v17 = v30;
if( *((_QWORD *)v7 + 1) == v31 && *((_QWORD *)v7 + 2) == v30 )
goto LABEL_22;
v18 = ExpGetDriveGeometry((unsigned int)DiskNumber, &DiskGeometry);
v19 = DiskGeometry.BytesPerSector;
if( v18 < 0 )
v19 = 1;
DiskGeometry.BytesPerSector = v19;
if( *((_QWORD *)v7 + 1) == v16 / v19 && *((_QWORD *)v7 + 2) == v17 / v19 )
{
v26 = 1;
LABEL_22:
v20 = (WCHAR *)ExAllocatePoolWithTag(NonPagedPoolNx, 0x5Eui64, 0x72766E45ui64);
if( !v20 )
goto LABEL_7;
swprintf_s(v20, 0x2Fui64, (WCHAR *)L"\\Device\\Harddisk%lu\\Partition%lu");
v21 = ExpTranslateSymbolicLink(v20, &DestinationString);
ExFreePoolWithTag(v20, 0);
if( v21 < 0 )
{
if( v27 )
ExFreePoolWithTag(v27, 0);
DiskSignature = v21;
goto LABEL_42;
}
goto LABEL_27;
}
}
if( v27 )
ExFreePoolWithTag(v27, 0);
DiskSignature = -1073741811;
goto LABEL_42;
}
return result;
}Referenced by:
NtTranslateFilePath