PiDrvDbResolveFilePathKeyValues
NTSTATUS __stdcall PiDrvDbResolveFilePathKeyValues(INT64 rcx0, INT8 dl0, _UNICODE_STRING *r8_0, _UNICODE_STRING *a4){
unsigned int v6;
VOID **v7;
UINT64 v8;
VOID **v9;
_UNICODE_STRING *v10;
NTSTATUS v11;
int appended;
unsigned __int8 v13;
__int64 v14;
__int64 v15;
ULONG v16;
NTSTATUS v17;
unsigned int v18;
unsigned __int64 v19;
const wchar_t *v20;
wchar_t *v21;
_KEY_VALUE_FULL_INFORMATION *v22;
ULONG Type;
ULONG v24;
const wchar_t *v25;
unsigned __int64 v26;
int v27;
int v28;
NTSTATUS v29;
unsigned __int16 Length;
const VOID **p_UnicodeString;
wchar_t *Buffer;
const wchar_t *v33;
ULONG DataLength;
const wchar_t *v35;
NTSTATUS v36;
__int64 v37;
UINT64 v39;
UINT64 v40;
unsigned int v41;
UINT64 NumberOfBytes;
_UNICODE_STRING DestinationString;
int v44;
ULONG v45;
PVOID KeyHandle;
_UNICODE_STRING UnicodeString;
VOID *Handle;
VOID **v49;
VOID **PoolWithTag;
_UNICODE_STRING StringAppend;
_UNICODE_STRING MultiSz;
_KEY_VALUE_FULL_INFORMATION *Information;
Handle = 0i64;
v40 = 0i64;
LODWORD(NumberOfBytes) = 0;
v41 = 0;
PoolWithTag = 0i64;
DestinationString = 0i64;
v6 = 0;
v7 = 0i64;
v49 = 0i64;
LODWORD(v8) = 0;
KeyHandle = 0i64;
v9 = 0i64;
Information = 0i64;
StringAppend = 0i64;
v44 = 0;
v10 = r8_0;
UnicodeString = 0i64;
MultiSz = 0i64;
RtlInitUnicodeString(&DestinationString, 0i64);
RtlInitUnicodeString(&UnicodeString, 0i64);
RtlInitUnicodeString(&MultiSz, 0i64);
v11 = SysCtxRegOpenKey(0i64, (VOID *)rcx0, L"Setup\\ResolveFilePaths", 0, 0x20019u, &Handle);
appended = v11;
if( v11 == -1073741772 )
{
appended = 0;
goto LABEL_88;
}
if( v11 >= 0 )
{
appended = PiDrvDbQuerySystemPathWin32(v10, &DestinationString);
if( appended < 0 )
{
appended = 0;
RtlInitUnicodeString(&DestinationString, 0i64);
}
if( (dl0 & 2) != 0 )
{
if( v10 )
{
v13 = (unsigned __int8)RtlEqualUnicodeString(v10, &PiDrvDbSystemRootNt, 1u);
v10 = 0i64;
if( !v13 )
goto LABEL_17;
}
if( (_UNICODE_STRING *)DestinationString.Buffer != v10
&& !(unsigned __int8)RtlEqualUnicodeString(&DestinationString, &PiDrvDbSystemRootWin32, 1u) )
{
goto LABEL_17;
}
}
else
{
v10 = 0i64;
}
if( (dl0 & 1) == 0
|| !a4
|| (_UNICODE_STRING *)DestinationString.Buffer == v10
|| (unsigned __int8)RtlEqualUnicodeString(a4, &DestinationString, 1u) )
{
appended = (int)v10;
goto LABEL_84;
}
LABEL_17:
if( (int)PnpCtxRegQueryInfoKey(v14, Handle, 0i64, 0i64, v10, &v40, &NumberOfBytes) >= 0 )
{
v8 = (unsigned int)NumberOfBytes;
HIDWORD(v40) = NumberOfBytes;
v6 = 2 * v40 + 2;
v41 = v6;
if( 2 * (_DWORD)v40 != -2 )
{
PoolWithTag = ExAllocatePoolWithTag(1ui64, v6, 1650749520i64);
v7 = PoolWithTag;
if( !PoolWithTag )
{
appended = -1073741670;
goto LABEL_88;
}
}
if( (_DWORD)v8 )
{
v49 = ExAllocatePoolWithTag(1ui64, v8, 1650749520i64);
v9 = v49;
if( !v49 )
{
LABEL_23:
appended = -1073741670;
LABEL_84:
if( v7 )
ExFreePoolWithTag(v7, 0);
LABEL_86:
if( v9 )
ExFreePoolWithTag(v9, 0);
goto LABEL_88;
}
}
}
v16 = (unsigned int)v10;
LABEL_25:
v45 = v16;
LODWORD(NumberOfBytes) = v6 >> 1;
LODWORD(v40) = v8;
v17 = PnpCtxRegEnumValue(v15, (_HANDLE)Handle, v16, v7, (INT64)&NumberOfBytes, &v44, (INT64)v9);
if( v17 == -2147483622 )
goto LABEL_84;
if( v17 == -1073741789 )
{
if( (unsigned int)NumberOfBytes > v6 >> 1 )
{
v18 = 2 * NumberOfBytes;
v41 = 2 * NumberOfBytes;
if( v7 )
ExFreePoolWithTag(v7, 0);
PoolWithTag = ExAllocatePoolWithTag(1ui64, v18, 1650749520i64);
v7 = PoolWithTag;
if( !PoolWithTag )
{
appended = -1073741670;
goto LABEL_86;
}
}
if( (unsigned int)v40 <= (unsigned int)v8 )
goto LABEL_35;
v8 = (unsigned int)v40;
HIDWORD(v40) = v40;
if( v9 )
ExFreePoolWithTag(v9, 0);
v49 = ExAllocatePoolWithTag(1ui64, v8, 1650749520i64);
v9 = v49;
if( v49 )
{
LABEL_35:
--v16;
goto LABEL_80;
}
goto LABEL_23;
}
if( v17 < 0 )
goto LABEL_82;
if( v44 != 7 )
goto LABEL_80;
if( (unsigned int)v40 < 4 )
goto LABEL_80;
v19 = (unsigned __int64)(unsigned int)v40 >> 1;
if( *((_WORD *)v9 + v19 - 1) )
goto LABEL_80;
if( *((_WORD *)v9 + v19 - 2) )
goto LABEL_80;
v17 = SysCtxRegOpenKey(0i64, (VOID *)rcx0, (const WCHAR *)v7, 0, 0x2001Fu, &KeyHandle);
if( v17 == -1073741772 )
goto LABEL_80;
if( v17 < 0 )
{
LABEL_82:
appended = v17;
goto LABEL_84;
}
v20 = (const wchar_t *)v9;
if( !*(_WORD *)v9 )
goto LABEL_79;
while( 1 )
{
v21 = (wchar_t *)&dword_1407CF120;
if( wcsicmp(v20, L" ") )
v21 = (wchar_t *)v20;
NumberOfBytes = (UINT64)v21;
if( IopGetRegistryValue(KeyHandle, v21, 0i64, &Information) >= 0 )
break;
LABEL_75:
v37 = -1i64;
do
++v37;
while( v20[v37] );
v20 += v37 + 1;
if( !*v20 )
{
LABEL_78:
v9 = v49;
v7 = PoolWithTag;
LODWORD(v8) = HIDWORD(v40);
v16 = v45;
LABEL_79:
ZwClose((_HANDLE)KeyHandle);
if( appended < 0 )
goto LABEL_84;
LABEL_80:
v6 = v41;
++v16;
goto LABEL_25;
}
}
v22 = Information;
Type = Information->Type;
if( Type )
{
if( Type <= 2 )
{
DataLength = Information->DataLength;
v35 = (const wchar_t *)((char *)Information + Information->DataOffset);
if( DataLength - 3 > 0xFFFB || v35[((unsigned __int64)DataLength >> 1) - 1] )
goto LABEL_74;
RtlInitUnicodeString(&StringAppend, v35);
UnicodeString.Length = 0;
v36 = PiDrvDbResolveSystemFilePath(
(INT16 *)&StringAppend,
dl0,
(PFN_WDFCX_DEVICE_POST_SELF_MANAGED_IO_INIT *)r8_0,
(PFN_WDFCX_DEVICE_POST_SELF_MANAGED_IO_INIT *)((unsigned __int64)&DestinationString & -(__int64)(DestinationString.Buffer != 0i64)),
(PFN_WDFCX_DEVICE_POST_SELF_MANAGED_IO_INIT *)a4,
&UnicodeString);
appended = v36;
if( v36 == -1073741275 || v36 == -1073741637 )
{
appended = 0;
goto LABEL_74;
}
if( v36 < 0 )
goto LABEL_74;
v33 = v21;
Buffer = UnicodeString.Buffer;
v27 = UnicodeString.Length + 2;
}
else
{
if( Type != 7 )
goto LABEL_74;
v24 = Information->DataLength;
v25 = (const wchar_t *)((char *)Information + Information->DataOffset);
if( v24 - 4 > 0xFFFA )
goto LABEL_74;
v26 = (unsigned __int64)v24 >> 1;
if( v25[v26 - 1] || v25[v26 - 2] )
goto LABEL_74;
LOWORD(v27) = 0;
v28 = 0;
MultiSz.Length = 0;
if( *v25 )
{
while( 1 )
{
RtlInitUnicodeString(&StringAppend, v25);
UnicodeString.Length = 0;
v29 = PiDrvDbResolveSystemFilePath(
(INT16 *)&StringAppend,
dl0,
(PFN_WDFCX_DEVICE_POST_SELF_MANAGED_IO_INIT *)r8_0,
(PFN_WDFCX_DEVICE_POST_SELF_MANAGED_IO_INIT *)((unsigned __int64)&DestinationString & -(__int64)(DestinationString.Buffer != 0i64)),
(PFN_WDFCX_DEVICE_POST_SELF_MANAGED_IO_INIT *)a4,
&UnicodeString);
appended = v29;
if( v29 == -1073741275 || v29 == -1073741637 )
{
Length = 0;
UnicodeString.Length = 0;
}
else
{
if( v29 < 0 )
goto LABEL_74;
Length = UnicodeString.Length;
++v28;
}
p_UnicodeString = (const VOID **)&UnicodeString;
if( !Length )
p_UnicodeString = (const VOID **)&StringAppend;
appended = PiDevCfgAppendMultiSz(&MultiSz, p_UnicodeString, 0i64, 1u);
if( appended < 0 )
goto LABEL_74;
v25 += ((unsigned __int64)StringAppend.Length >> 1) + 1;
if( !*v25 )
{
LOWORD(v27) = MultiSz.Length;
break;
}
}
}
if( !v28 )
goto LABEL_74;
Buffer = MultiSz.Buffer;
v33 = (const wchar_t *)NumberOfBytes;
v27 = (unsigned __int16)v27;
}
LODWORD(v39) = v27;
appended = RegRtlSetValue(KeyHandle, v33, v22->Type, Buffer, v39);
}
LABEL_74:
ExFreePoolWithTag(v22, 0);
if( appended < 0 )
goto LABEL_78;
goto LABEL_75;
}
LABEL_88:
RtlFreeAnsiString(&DestinationString);
RtlFreeAnsiString(&UnicodeString);
RtlFreeAnsiString(&MultiSz);
if( Handle )
ZwClose((_HANDLE)Handle);
return appended;
}Referenced by:
PiDrvDbResolveKeyFilePaths
PiDrvDbResolveNodeFilePaths