PiDevCfgConfigureDeviceLocation
__int64 __fastcall PiDevCfgConfigureDeviceLocation(__int64 a1, __int64 a2, _DWORD *a3, _DWORD *a4){
unsigned int v4;
wchar_t *Buffer;
int CachedContextBaseKey;
NTSTATUS v11;
PVOID *v12;
int MatchingSubKey;
_QWORD *v14;
NTSTATUS v15;
PVOID *v16;
int v17;
NTSTATUS v18;
NTSTATUS v19;
HANDLE v20;
__int128 v21;
struct _UNICODE_STRING UnicodeString;
HANDLE RootHandle;
void *KeyHandle;
UINT64 ResultLength;
HANDLE Handle;
struct _OBJECT_ATTRIBUTES ObjectAttributes;
void *v28;
__int64 v29;
__int128 KeyInformation[2];
__int64 v31;
v4 = 0;
v29 = a1;
v28 = 0i64;
KeyHandle = 0i64;
RootHandle = 0i64;
v20 = 0i64;
Handle = 0i64;
v31 = 0i64;
*(_QWORD *)&UnicodeString.Length = 0i64;
Buffer = 0i64;
UnicodeString.Buffer = 0i64;
LODWORD(ResultLength) = 0;
v21 = 0i64;
memset(KeyInformation, 0, sizeof(KeyInformation));
if( a3 )
*a3 = 0;
if( a4 )
*a4 = 0;
if( !*(_QWORD *)(a2 + 64) )
goto LABEL_6;
CachedContextBaseKey = PnpCtxGetCachedContextBaseKey(PiPnpRtlCtx, 4, (__int64 *)&v28);
if( CachedContextBaseKey < 0 )
goto LABEL_7;
LODWORD(v21) = 3145774;
*((_QWORD *)&v21 + 1) = L"Control\\DeviceLocations";
ObjectAttributes.RootDirectory = v28;
*(_QWORD *)&ObjectAttributes.Length = 48i64;
ObjectAttributes.ObjectName = (_UNICODE_STRING *)&v21;
*(_QWORD *)&ObjectAttributes.Attributes = 576i64;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
v11 = ZwOpenKey(&KeyHandle, 0x20019u, &ObjectAttributes);
CachedContextBaseKey = v11;
if( v11 == -1073741772 )
goto LABEL_6;
if( v11 < 0 )
goto LABEL_7;
CachedContextBaseKey = NtQueryKey(KeyHandle, KeyCachedInformation, KeyInformation, 0x28ui64, &ResultLength);
if( CachedContextBaseKey < 0 )
goto LABEL_7;
if( !HIDWORD(KeyInformation[0]) )
goto LABEL_6;
MatchingSubKey = PnpOpenFirstMatchingSubKey(*(WCHAR **)(a2 + 64), KeyHandle, v12);
CachedContextBaseKey = MatchingSubKey;
if( MatchingSubKey == -1073741772 )
goto LABEL_6;
if( MatchingSubKey < 0 )
goto LABEL_7;
v14 = (_QWORD *)(a2 + 32);
while( 1 )
{
if( !*v14 )
goto LABEL_34;
if( Buffer )
RtlFreeAnsiString(&UnicodeString);
if( !PnpDuplicateUnicodeString(&UnicodeString, (UNICODE_STRING *)(16i64 * v4 + a2 + 24)) )
break;
v15 = IopReplaceSeperatorWithPound(&UnicodeString, &UnicodeString);
Buffer = UnicodeString.Buffer;
if( v15 >= 0 )
{
v17 = PnpOpenFirstMatchingSubKey(UnicodeString.Buffer, RootHandle, v16);
CachedContextBaseKey = v17;
if( v17 == -1073741772 )
{
CachedContextBaseKey = 0;
}
else if( v17 < 0 )
{
goto LABEL_7;
}
if( v20 )
goto LABEL_37;
}
else
{
CachedContextBaseKey = 0;
}
LABEL_34:
++v4;
v14 += 2;
if( v4 >= 2 )
goto LABEL_37;
}
CachedContextBaseKey = -1073741670;
LABEL_37:
if( CachedContextBaseKey >= 0 )
{
if( v20 )
goto LABEL_41;
LODWORD(v21) = 262146;
*((_QWORD *)&v21 + 1) = L"*";
ObjectAttributes.RootDirectory = RootHandle;
*(_QWORD *)&ObjectAttributes.Length = 48i64;
ObjectAttributes.ObjectName = (_UNICODE_STRING *)&v21;
*(_QWORD *)&ObjectAttributes.Attributes = 576i64;
v20 = 0i64;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
v18 = ZwOpenKey(&v20, 0x20019u, &ObjectAttributes);
CachedContextBaseKey = v18;
if( v18 != -1073741772 )
{
if( v18 < 0 )
goto LABEL_7;
LABEL_41:
LODWORD(v21) = 1835034;
*((_QWORD *)&v21 + 1) = L"Configuration";
ObjectAttributes.RootDirectory = v20;
*(_QWORD *)&ObjectAttributes.Length = 48i64;
ObjectAttributes.ObjectName = (_UNICODE_STRING *)&v21;
*(_QWORD *)&ObjectAttributes.Attributes = 576i64;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
v19 = ZwOpenKey(&Handle, 0x20019u, &ObjectAttributes);
CachedContextBaseKey = v19;
if( v19 != -1073741772 )
{
if( v19 >= 0 )
CachedContextBaseKey = PiDevCfgConfigureDeviceKeys(v29, a2, Handle, -1, a3, a4);
goto LABEL_7;
}
}
LABEL_6:
CachedContextBaseKey = 0;
}
LABEL_7:
RtlFreeAnsiString(&UnicodeString);
if( Handle )
ZwClose(Handle);
if( v20 )
ZwClose(v20);
if( RootHandle )
ZwClose(RootHandle);
if( KeyHandle )
ZwClose(KeyHandle);
return(unsigned int)CachedContextBaseKey;
}Referenced by:
PiDevCfgConfigureDevice