PiDmAddCacheReferenceForObject
INT64 __fastcall PiDmAddCacheReferenceForObject(UINT64 a1, WCHAR *a2, CHAR **a3){
unsigned int v5;
ERESOURCE *ObjectManagerForObjectType;
_ETHREAD *CurrentThread;
ERESOURCE *v8;
int v9;
PVOID *v10;
volatile signed __int32 *v11;
UINT64 inserted;
PVOID P;
TABLE_SEARCH_RESULT SearchResult;
PVOID NodeOrParent;
INT64 *Buffer;
INT64 result[14];
v5 = a1;
memset((INT64)result, 0i64);
NodeOrParent = 0i64;
SearchResult = TableEmptyTree;
P = 0i64;
Buffer = result;
ObjectManagerForObjectType = (ERESOURCE *)PiDmGetObjectManagerForObjectType(v5);
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
v8 = ObjectManagerForObjectType;
--*((_WORD *)CurrentThread + 242);
ExAcquireResourceExclusiveLite(ObjectManagerForObjectType, 1u);
v9 = PiDmInitializeComparisonObject(a2, v5, (INT64)result);
if( v9 < 0 )
goto LABEL_14;
LODWORD(v10) = RtlLookupElementGenericTableFullAvl((RTL_AVL_TABLE *)&v8[1], &Buffer, &NodeOrParent, &SearchResult);
if( v10 )
v11 = (volatile signed __int32 *)*v10;
else
v11 = 0i64;
P = (PVOID)v11;
if( v11 )
{
++*((_DWORD *)v11 + 3);
goto LABEL_6;
}
v9 = PiDmObjectCreate(v5, a2, (CHAR **)&P);
if( v9 < 0 )
{
LABEL_14:
v11 = (volatile signed __int32 *)P;
goto LABEL_6;
}
inserted = RtlInsertElementGenericTableFullAvl((RTL_BITMAP *)&v8[1], (UINT64)&P, 8ui64);
v11 = (volatile signed __int32 *)P;
if( inserted )
{
*((_DWORD *)P + 3) = 1;
}
else
{
PiDmObjectRelease((CHAR *)P);
v11 = 0i64;
v9 = -1073741670;
P = 0i64;
}
LABEL_6:
if( a3 )
{
*a3 = (CHAR *)v11;
if( v11 )
_InterlockedIncrement(v11 + 2);
}
ExReleaseResourceLite(v8);
KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
return(unsigned int)v9;
}Referenced by:
IopProcessSetInterfaceState
IopRegisterDeviceInterface
PiDmListInitEnumCallback
PiPnpRtlCmActionCallback
PiPnpRtlEnsureObjectCached
PiPnpRtlGatherInstallerClassChangeInfo