PiDrvDbResolveSystemFilePath
INT64 __fastcall PiDrvDbResolveSystemFilePath(
__m128i *a1,
CHAR a2,
UNICODE_STRING *a3,
UNICODE_STRING *a4,
UNICODE_STRING *String1,
UNICODE_STRING *Destination){
UNICODE_STRING *v6;
bool v7;
NTSTATUS appended;
UNICODE_STRING *v10;
CHAR *v12;
CHAR *SystemFilePathToken;
CHAR *v14;
CHAR *v15;
unsigned __int64 Length;
__int16 v17;
unsigned __int16 v18;
wchar_t *v19;
unsigned __int16 v20;
unsigned __int16 v21;
wchar_t v22;
unsigned int v23;
ULONG v24;
UINT8 *StringRoutine;
wchar_t *Buffer;
char v28;
unsigned int v29;
bool v30;
char v31;
int v32;
UNICODE_STRING Source;
UNICODE_STRING v34;
int v36;
PUNICODE_STRING Destinationa;
v6 = a4;
v7 = 0;
v28 = 0;
v31 = 0;
v30 = 0;
v29 = 0;
v32 = a2 & 2;
appended = 0;
v34 = 0i64;
v10 = 0i64;
if( (a2 & 2) != 0 && a3 )
{
v7 = RtlEqualUnicodeString(a3, (UNICODE_STRING *)&PiDrvDbSystemRootNt, 1u) != 0;
v31 = v7;
}
v36 = a2 & 1;
if( (a2 & 1) != 0 && String1 && v6 )
v30 = RtlEqualUnicodeString(String1, v6, 1u) != 0;
Destination->Length = 0;
Source = (UNICODE_STRING)*a1;
Destinationa = (PUNICODE_STRING)_mm_srli_si128((__m128i)Source, 8).m128i_u64[0];
if( !Destinationa->Length )
return(unsigned int)-1073741275;
while( 1 )
{
v12 = 0i64;
if( v32 )
{
if( a3 && !v7 )
{
SystemFilePathToken = PiDrvDbFindSystemFilePathToken((__m128i *)&Source, &PiDrvDbSystemRootNt.Length);
if( SystemFilePathToken )
{
v10 = a3;
v12 = SystemFilePathToken;
v29 = 22;
}
else
{
v31 = 1;
}
}
if( v6 && !v28 )
{
v14 = PiDrvDbFindSystemFilePathToken((__m128i *)&Source, &PiDrvDbSystemRootWin32.Length);
if( v14 )
{
if( !v12 || v14 < v12 )
{
v12 = v14;
v29 = 24;
v10 = v6;
}
}
else
{
v28 = 1;
}
}
}
if( v36 && v6 && !v30 && String1 && String1->Length > 2u )
{
v15 = PiDrvDbFindSystemFilePathToken((__m128i *)&Source, &String1->Length);
if( !v15 )
{
v30 = 1;
LABEL_29:
Length = v29;
goto LABEL_30;
}
if( v12 && v15 >= v12 )
goto LABEL_29;
v12 = v15;
v10 = v6;
Length = String1->Length;
v29 = String1->Length;
}
else
{
Length = v29;
}
LABEL_30:
if( !v12 )
goto LABEL_54;
v17 = a1->m128i_i16[0];
v18 = 2 * ((v12 - (CHAR *)Destinationa) >> 1);
Source.Length = v18;
v19 = (wchar_t *)&v12[2 * (Length >> 1)];
v34.Buffer = v19;
v20 = v17 - 2 * ((__int64)((unsigned int)v12 + 2 * (unsigned int)(Length >> 1) - a1->m128i_i32[2]) >> 1);
v21 = v20;
v34.Length = v20;
v34.MaximumLength = v20 + 2;
v22 = *v19;
if( !*v19 || v22 == 92 )
break;
LABEL_47:
Source = v34;
if( !*v19 )
goto LABEL_54;
v6 = a4;
v7 = v31;
Destinationa = (PUNICODE_STRING)Source.Buffer;
}
if( v22 == 92 && v10->Buffer[((unsigned __int64)v10->Length >> 1) - 1] == 92 )
{
++v19;
v34.MaximumLength = v20;
v21 = v20 - 2;
v34.Buffer = v19;
v34.Length = v20 - 2;
}
v23 = v21 + Destination->Length + v18 + v10->Length + 2;
if( v23 > 0xFFFE )
return(unsigned int)-2147483643;
if( v23 <= Destination->MaximumLength )
goto LABEL_44;
StringRoutine = (UINT8 *)ExpAllocateStringRoutine(v23);
if( StringRoutine )
{
Buffer = Destination->Buffer;
if( Buffer )
{
if( Destination->Length )
{
memmove(StringRoutine, (UINT8 *)Destination->Buffer, Destination->Length);
Buffer = Destination->Buffer;
}
ExFreePoolWithTag(Buffer, v24);
}
Destination->Buffer = (wchar_t *)StringRoutine;
Destination->MaximumLength = v23;
LABEL_44:
if( v18 )
{
appended = RtlAppendUnicodeStringToString(Destination, &Source);
if( appended < 0 )
return(unsigned int)appended;
}
appended = RtlAppendUnicodeStringToString(Destination, v10);
if( appended < 0 )
return(unsigned int)appended;
goto LABEL_47;
}
appended = -1073741670;
LABEL_54:
if( appended < 0 )
return(unsigned int)appended;
if( !Destination->Length )
return(unsigned int)-1073741275;
if( Source.Length )
return(unsigned int)RtlAppendUnicodeStringToString(Destination, &Source);
return(unsigned int)appended;
}Referenced by:
PiDrvDbResolveFilePathKeyValues