PiDevCfgConfigureDeviceLocation
NTSTATUS __stdcall PiDevCfgConfigureDeviceLocation(
_DEVICE_NODE *DeviceNode,
PI_DEVCFG_DEVICE_CONTEXT *DeviceContext,
UINT64 *ConfigFlags,
UINT64 *ConfigStatus){
unsigned int v4;
wchar_t *Buffer;
int CachedContextBaseKey;
INT64 v11;
NTSTATUS v12;
WCHAR v13;
__int64 v14;
NTSTATUS MatchingSubKey;
__int64 v16;
PI_DEVCFG_DEVICE_CONTEXT *v17;
WCHAR v18;
int v19;
NTSTATUS v20;
NTSTATUS v21;
NTSTATUS v22;
UINT64 *ResultLength;
UINT64 *ResultLengtha;
UINT64 *ConfigStatusa;
UINT64 *ConfigStatusb;
INT64 v27;
INT64 v28[2];
_UNICODE_STRING UnicodeString;
INT64 v30;
VOID *KeyHandle;
UINT64 v32;
VOID *ConfigurationKeyHandle;
_OBJECT_ATTRIBUTES ObjectAttributes;
INT64 v35;
_DEVICE_NODE *DeviceNodea;
__int128 KeyInformation[2];
__int64 v38;
v4 = 0;
DeviceNodea = DeviceNode;
v35 = 0i64;
KeyHandle = 0i64;
v30 = 0i64;
v27 = 0i64;
ConfigurationKeyHandle = 0i64;
v38 = 0i64;
*(_QWORD *)&UnicodeString.Length = 0i64;
Buffer = 0i64;
UnicodeString.Buffer = 0i64;
LODWORD(v32) = 0;
*(_OWORD *)v28 = 0i64;
memset(KeyInformation, 0, sizeof(KeyInformation));
if( ConfigFlags )
*(_DWORD *)ConfigFlags = 0;
if( ConfigStatus )
*(_DWORD *)ConfigStatus = 0;
if( !*((_QWORD *)DeviceContext + 8) )
goto LABEL_6;
CachedContextBaseKey = PnpCtxGetCachedContextBaseKey(
*(&stru_140CF2E80 + 607),
PNPCTX_BASE_KEY_TYPE_CONTROLSET,
(VOID **)&v35);
if( CachedContextBaseKey < 0 )
goto LABEL_7;
LODWORD(v28[0]) = 3145774;
v28[1] = (INT64)L"Control\\DeviceLocations";
ObjectAttributes.RootDirectory = (void *)v35;
*(_QWORD *)&ObjectAttributes.Length = 48i64;
ObjectAttributes.ObjectName = (_UNICODE_STRING *)v28;
*(_QWORD *)&ObjectAttributes.Attributes = 576i64;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
v12 = ZwOpenKey(
&KeyHandle,
0x20019ui64,
&ObjectAttributes,
v11,
(INT64)ResultLength,
(INT64)ConfigStatusa,
v27,
v28[0]);
CachedContextBaseKey = v12;
if( v12 == -1073741772 )
goto LABEL_6;
if( v12 < 0 )
goto LABEL_7;
CachedContextBaseKey = NtQueryKey(KeyHandle, KeyCachedInformation, KeyInformation, 0x28ui64, &v32);
if( CachedContextBaseKey < 0 )
goto LABEL_7;
if( !HIDWORD(KeyInformation[0]) )
goto LABEL_6;
MatchingSubKey = PnpOpenFirstMatchingSubKey(*((WCHAR **)DeviceContext + 8), (INT64)KeyHandle, v13, v14, (VOID **)&v30);
CachedContextBaseKey = MatchingSubKey;
if( MatchingSubKey == -1073741772 )
goto LABEL_6;
if( MatchingSubKey < 0 )
goto LABEL_7;
v17 = DeviceContext + 8;
while( 1 )
{
if( !*(_QWORD *)v17 )
goto LABEL_34;
if( Buffer )
RtlFreeAnsiString(&UnicodeString);
if( !PnpDuplicateUnicodeString((__int64)&UnicodeString, (__int64)&DeviceContext[4 * v4 + 6]) )
break;
IopReplaceSeperatorWithPound(&UnicodeString, &UnicodeString);
Buffer = UnicodeString.Buffer;
if( v19 >= 0 )
{
v20 = PnpOpenFirstMatchingSubKey(UnicodeString.Buffer, v30, v18, v16, (VOID **)&v27);
CachedContextBaseKey = v20;
if( v20 == -1073741772 )
{
CachedContextBaseKey = 0;
}
else if( v20 < 0 )
{
goto LABEL_7;
}
if( v27 )
goto LABEL_37;
}
else
{
CachedContextBaseKey = 0;
}
LABEL_34:
++v4;
v17 += 4;
if( v4 >= 2 )
goto LABEL_37;
}
CachedContextBaseKey = -1073741670;
LABEL_37:
if( CachedContextBaseKey >= 0 )
{
if( v27 )
goto LABEL_41;
LODWORD(v28[0]) = 262146;
v28[1] = (INT64)L"*";
ObjectAttributes.RootDirectory = (void *)v30;
*(_QWORD *)&ObjectAttributes.Length = 48i64;
ObjectAttributes.ObjectName = (_UNICODE_STRING *)v28;
*(_QWORD *)&ObjectAttributes.Attributes = 576i64;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
v21 = ZwOpenKey(
(VOID **)&v27,
0x20019ui64,
&ObjectAttributes,
v16,
(INT64)ResultLengtha,
(INT64)ConfigStatusb,
0i64,
v28[0]);
CachedContextBaseKey = v21;
if( v21 != -1073741772 )
{
if( v21 < 0 )
goto LABEL_7;
LABEL_41:
LODWORD(v28[0]) = 1835034;
v28[1] = (INT64)L"Configuration";
ObjectAttributes.RootDirectory = (void *)v27;
*(_QWORD *)&ObjectAttributes.Length = 48i64;
ObjectAttributes.ObjectName = (_UNICODE_STRING *)v28;
*(_QWORD *)&ObjectAttributes.Attributes = 576i64;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
v22 = ZwOpenKey(
&ConfigurationKeyHandle,
0x20019ui64,
&ObjectAttributes,
v16,
(INT64)ResultLengtha,
(INT64)ConfigStatusb,
v27,
v28[0]);
CachedContextBaseKey = v22;
if( v22 != -1073741772 )
{
if( v22 >= 0 )
CachedContextBaseKey = PiDevCfgConfigureDeviceKeys(
DeviceNodea,
DeviceContext,
ConfigurationKeyHandle,
0xFFFFFFFFui64,
ConfigFlags,
ConfigStatus);
goto LABEL_7;
}
}
LABEL_6:
CachedContextBaseKey = 0;
}
LABEL_7:
RtlFreeAnsiString(&UnicodeString);
if( ConfigurationKeyHandle )
ZwClose((_HANDLE)ConfigurationKeyHandle);
if( v27 )
ZwClose(v27);
if( v30 )
ZwClose(v30);
if( KeyHandle )
ZwClose((_HANDLE)KeyHandle);
return CachedContextBaseKey;
}Referenced by:
PiDevCfgConfigureDevice