DrvDbSetDeviceIdDriverInfMatches
NTSTATUS __stdcall DrvDbSetDeviceIdDriverInfMatches(VOID *ObjectBaseKey, WCHAR *DriverInfMatches){
__int64 v2;
WCHAR *v3;
int inited;
size_t v6;
WORD *v7;
WORD *v8;
__int64 v9;
size_t v10;
__int64 v11;
VOID **PoolWithTag;
ULONG v13;
NTSTATUS v14;
const WCHAR *v15;
__int64 v16;
__int64 v17;
WCHAR v18;
__int64 v20;
unsigned int v21;
_DRVDB_DRIVER_INF_MATCH_DATA *p_DriverInfMatchData;
int v23;
_OBJECT_TYPE *v24;
unsigned int v25;
ULONG v26;
_OBJECT_TYPE *v27;
int v28;
UINT64 v29;
_DRVDB_DRIVER_INF_MATCH_DATA DriverInfMatchData;
int v31;
size_t v32;
int v33;
_UNICODE_STRING DestinationString;
size_t MaxCount;
int v36;
VOID *KeyHandle;
WCHAR *v38;
unsigned int v39;
v38 = (WCHAR *)v2;
KeyHandle = DriverInfMatches;
v36 = HIDWORD(ObjectBaseKey);
v3 = (WCHAR *)v2;
v39 = 0;
MaxCount = 0;
v31 = 0;
DriverInfMatchData = 0;
v33 = PnpCtxRegQueryInfoKey((__int64)ObjectBaseKey, DriverInfMatches, 0i64, 0i64, &v39, &MaxCount, 0i64);
inited = v33;
if( v33 >= 0 )
{
v6 = MaxCount + 1;
v32 = MaxCount + 1;
if( v3 )
{
v7 = v3;
if( *v3 )
{
do
{
v8 = wcschr(v7, 92);
if( v8 )
{
v9 = v8 - v7;
}
else
{
v9 = -1i64;
do
++v9;
while( v7[v9] );
}
v10 = v9 + 1;
if( v10 > v6 )
v6 = v10;
v11 = -1i64;
do
++v11;
while( v7[v11] );
v7 += v11 + 1;
}
while( *v7 );
inited = v33;
v32 = v6;
}
PoolWithTag = ExAllocatePoolWithTag(1ui64, 2i64 * v6, 1111770192i64);
if( PoolWithTag )
{
v13 = 0;
if( v39 )
{
while( 1 )
{
MaxCount = v6;
v14 = PnpCtxRegEnumValue(0i64, (_HANDLE)KeyHandle, v13, PoolWithTag, (INT64)&MaxCount, &v31, 0i64);
inited = v14;
if( v14 < 0 )
break;
if( v31 == 3 || !v31 )
{
v15 = v3;
if( *v3 )
{
v16 = MaxCount;
do
{
if( !wcsncmp(v15, (const WCHAR *)PoolWithTag, v16) )
{
v18 = v15[v16];
if( v18 == 92 || !v18 )
break;
}
v17 = -1i64;
do
++v17;
while( v15[v17] );
v15 += v17 + 1;
}
while( *v15 );
v3 = v38;
v6 = v32;
}
if( !*v15 )
{
DestinationString = 0i64;
inited = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)PoolWithTag);
if( inited >= 0 )
inited = ZwDeleteValueKey(KeyHandle, &DestinationString, v24);
if( inited == -1073741772 )
{
inited = 0;
}
else if( inited < 0 )
{
goto LABEL_28;
}
}
}
if( ++v13 >= v39 )
goto LABEL_27;
}
if( v14 == -2147483622 )
inited = 0;
}
LABEL_27:
if( inited >= 0 )
{
while( *v3 )
{
inited = DrvDbSplitDeviceIdDriverInfMatch(v3, (WCHAR *)PoolWithTag, v6, &DriverInfMatchData);
if( inited < 0 )
break;
if( DriverInfMatchData.Type )
{
v21 = 3;
p_DriverInfMatchData = &DriverInfMatchData;
v23 = 4;
}
else
{
v21 = 0;
p_DriverInfMatchData = 0i64;
v23 = 0;
}
LODWORD(v29) = v23;
inited = RegRtlSetValue(KeyHandle, (const wchar_t *)PoolWithTag, v21, p_DriverInfMatchData, v29);
if( inited < 0 )
break;
v20 = -1i64;
do
++v20;
while( v3[v20] );
v3 += v20 + 1;
}
}
LABEL_28:
ExFreePoolWithTag(PoolWithTag, 0);
return inited;
}
}
else
{
v25 = v39;
if( !v39 )
return 0;
PoolWithTag = ExAllocatePoolWithTag(1ui64, 2i64 * v6, 1111770192i64);
if( PoolWithTag )
{
v26 = 0;
if( v25 )
{
while( 1 )
{
MaxCount = v6;
inited = PnpCtxRegEnumValue(0i64, (_HANDLE)DriverInfMatches, v26, PoolWithTag, (INT64)&MaxCount, 0i64, 0i64);
if( inited < 0 )
break;
DestinationString = 0i64;
inited = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)PoolWithTag);
if( inited >= 0 )
inited = ZwDeleteValueKey(DriverInfMatches, &DestinationString, v27);
if( (int)(inited + 0x80000000) < 0 || inited == -1073741772 )
{
v28 = 0;
if( inited != -1073741772 )
v28 = inited;
++v26;
inited = v28;
if( v26 < v25 )
continue;
}
goto LABEL_28;
}
if( inited == -2147483622 )
inited = 0;
}
goto LABEL_28;
}
}
return -1073741801;
}
return inited;
}Referenced by:
DrvDbSetDeviceIdMappedProperty