PiDmObjectProcessPropertyChange

VOID __fastcall PiDmObjectProcessPropertyChange(UINT64 a1, WCHAR *rdx0, CHAR *a3, INT64 a4, INT64 a5, BYTE *a6){
  BYTE *v6; 
  unsigned int v8; 
  int Object; 
  _GUID *PoolWithTag; 
  DEVPROPKEY **v11; 
  unsigned int CachedKeyIndex; 
  __int64 v13; 
  unsigned int v14; 
  __int64 v15; 
  _ETHREAD *CurrentThread; 
  ULONG_PTR v17; 
  INT64 *v18; 
  int v19; 
  unsigned int v20; 
  bool v21; 
  unsigned int v22; 
  __int64 *v23; 
  INT64 v24; 
  __int64 v25; 
  __int64 *v26; 
  _ETHREAD *v27; 
  __int64 v28; 
  ULONG_PTR v29; 
  int v30; 
  int v31; 
  INT64 v32; 
  INT64 v33; 
  _DWORD a2[3]; 
  ULONG v35; 
  unsigned int v36; 
  void *Buf2; 
  ULONG_PTR P2; 
  DEVPROPKEY **v39; 
  ULONG_PTR BugCheckParameter2; 
  char v42; 
  BugCheckParameter2 = (ULONG_PTR)a3;
  v6 = a6;
  v39 = 0i64;
  v36 = 0;
  v8 = a1;
  a2[2] = 0;
  Object = 0;
  *a6 = 0;
  PoolWithTag = 0i64;
  v35 = 0;
  v42 = 0;
  Buf2 = 0i64;
  a2[1] = 0;
  a2[0] = 0;
  P2 = 0i64;
  if( a4 )
    return;
  PiDmGetCacheKeys(a1, &v39, &v36);
  if( !v36 )
    return;
  v11 = v39;
  CachedKeyIndex = PiDmGetCachedKeyIndex((__int64)v39, v36, a5);
  v13 = CachedKeyIndex;
  if( CachedKeyIndex >= v14 )
    return;
  if( !a3 )
  {
    Object = PiDmGetObject(v8, rdx0, (INT64 *)&BugCheckParameter2);
    if( Object < 0 )
      return;
    v42 = 1;
  }
  v15 = 3 * v13;
  if( LODWORD(v11[3 * v13 + 2]) == 1 )
  {
    LODWORD(v33) = 0x10000;
    Object = PnpGetObjectProperty(
               1517317712i64,
               16i64,
               (INT64)rdx0,
               v8,
               0i64,
               0i64,
               (INT64 *)a5,
               (UINT64)a2,
               (INT64)&Buf2,
               &v35,
               v33);
    if( Object == -1073741275 )
    {
      Object = 0;
      a2[0] = 0;
      v35 = 0;
    }
  }
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  --*((_WORD *)CurrentThread + 242);
  v17 = BugCheckParameter2;
  ExAcquirePushLockExclusiveEx(BugCheckParameter2, 0i64);
  v18 = (INT64 *)(v17 + 8 * v15 + 112);
  if( !*(_DWORD *)v18 )
  {
    if( !LODWORD(v11[v15 + 2]) )
      goto LABEL_24;
    goto LABEL_35;
  }
  if( *(_DWORD *)v18 == 1 || Object < 0 || !LODWORD(v11[v15 + 2]) )
    goto LABEL_35;
  v19 = PiDmCacheDataDecode(v18, &a2[1], 0i64, 0i64, (UINT64 *)&a2[2]);
  Object = v19;
  if( v19 == -1073741275 )
  {
    a2[1] = 0;
    Object = 0;
    v21 = a2[0] == 0;
  }
  else
  {
    if( (int)(v19 + 0x80000000) >= 0 && v19 != -1073741789 )
      goto LABEL_35;
    v20 = a2[2];
    if( a2[2] )
    {
      PoolWithTag = (_GUID *)ExAllocatePoolWithTag(PagedPool, a2[2], 0x5A706E50ui64);
      if( !PoolWithTag )
      {
        Object = -1073741670;
        goto LABEL_35;
      }
    }
    Object = PiDmCacheDataDecode(v18, &a2[1], PoolWithTag, v20, (UINT64 *)&a2[2]);
    if( Object < 0 || a2[1] != a2[0] || a2[2] != v35 )
      goto LABEL_35;
    if( !a2[2] )
    {
LABEL_23:
      *v6 = 1;
      goto LABEL_24;
    }
    v21 = memcmp(PoolWithTag, Buf2, a2[2]) == 0;
  }
  if( v21 )
    goto LABEL_23;
LABEL_35:
  PiDmCacheDataFree((INT64)v18);
  if( Object >= 0 && LODWORD(v11[v15 + 2]) == 1 && !HIDWORD(v11[v15 + 1]) )
    Object = PiDmCacheDataEncode(a2[0], (int *)Buf2, v35, (int)v11[v15 + 1], 0, (__int64)v18);
LABEL_24:
  ExReleasePushLockEx(BugCheckParameter2, 0i64);
  KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
  if( !LODWORD(v11[v15 + 2]) || *v6 )
    goto LABEL_26;
  v22 = 0;
  v23 = PiDmAggregatedBooleanDefs;
  while( 1 )
  {
    v24 = v23[1];
    if( *(_DWORD *)(v24 + 16) == *(_DWORD *)(a5 + 16) )
    {
      v25 = *(_QWORD *)v24 - *(_QWORD *)a5;
      if( *(_QWORD *)v24 == *(_QWORD *)a5 )
        v25 = *(_QWORD *)(v24 + 8) - *(_QWORD *)(a5 + 8);
      if( !v25 && v8 == *(_DWORD *)v23 )
        break;
    }
    ++v22;
    v23 += 7;
    if( v22 >= 3 )
      goto LABEL_26;
  }
  v26 = &PiDmAggregatedBooleanDefs[7 * v22];
  if( !v26 )
    goto LABEL_26;
  LODWORD(v32) = *((_DWORD *)v26 + 6);
  if( (int)PiDmGetReferencedObjectFromProperty(v8, rdx0, (CHAR *)BugCheckParameter2, v24, v26[2], v32, (INT64 *)&P2) < 0 )
    goto LABEL_26;
  v27 = (_ETHREAD *)KeGetCurrentThread();
  v28 = v26[6];
  v29 = P2;
  --*((_WORD *)v27 + 242);
  ExAcquirePushLockExclusiveEx(P2, 0i64);
  if( Object < 0 || (v30 = *(_DWORD *)(v29 + v28), v30 == 0x80000000) )
  {
    *(_DWORD *)(v29 + v28) = 0x80000000;
    goto LABEL_60;
  }
  if( a2[1] != 17 )
    goto LABEL_57;
  if( LOBYTE(PoolWithTag->Data1) == 0xFF && (a2[0] != 17 || !*(_BYTE *)Buf2) )
  {
    v31 = v30 - 1;
LABEL_59:
    *(_DWORD *)(v29 + v28) = v31;
    goto LABEL_60;
  }
  if( !LOBYTE(PoolWithTag->Data1) )
  {
LABEL_57:
    if( a2[0] != 17 || *(_BYTE *)Buf2 != 0xFF )
      goto LABEL_60;
    v31 = v30 + 1;
    goto LABEL_59;
  }
LABEL_60:
  ExReleasePushLockEx(P2, 0i64);
  KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
LABEL_26:
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0x5A706E50u);
  if( Buf2 )
    ExFreePoolWithTag(Buf2, 0x5A706E50u);
  if( P2 )
    PiDmObjectRelease((CHAR *)P2);
  if( v42 )
    PiDmObjectRelease((CHAR *)BugCheckParameter2);
}

Referenced by:

PiPnpRtlObjectEventWorker