PiDmObjectProcessPropertyChange

VOID __stdcall PiDmObjectProcessPropertyChange(
        _PNP_OBJECT_TYPE ObjectType,
        WCHAR *ObjectName,
        _PI_DM_OBJECT *Object,
        WCHAR *PropertyLocaleName,
        _DEVPROPKEY *PropertyKey,
        UINT8 *ValueNotChanged){
  UINT8 *v6; 
  int ObjectProperty; 
  VOID **PoolWithTag; 
  INT64 v11; 
  _PI_DM_CACHED_PROPERTY_KEY *v12; 
  unsigned int v13; 
  __int64 v14; 
  unsigned int v15; 
  __int64 v16; 
  _ETHREAD *CurrentThread; 
  _EX_PUSH_LOCK *v18; 
  PI_DM_CACHED_PROPERTY_DATA *v19; 
  NTSTATUS v20; 
  unsigned int v21; 
  bool v22; 
  unsigned int v23; 
  __int64 *v24; 
  _QWORD *v25; 
  __int64 v26; 
  __int64 *v27; 
  _ETHREAD *v28; 
  __int64 v29; 
  _EX_PUSH_LOCK *v30; 
  int v31; 
  int v32; 
  char PropertyType[12]; 
  _SIZE_T CachedKeyCount[3]; 
  VOID *buf2; 
  ULONG_PTR v36[2]; 
  _PI_DM_CACHED_PROPERTY_KEY *CachedKeys; 
  _EX_PUSH_LOCK *PushLock; 
  char v40; 

  PushLock = (_EX_PUSH_LOCK *)Object;
  v6 = ValueNotChanged;
  CachedKeys = 0i64;
  CachedKeyCount[1] = 0;
  *(_DWORD *)&PropertyType[8] = 0;
  ObjectProperty = 0;
  *ValueNotChanged = 0;
  PoolWithTag = 0i64;
  CachedKeyCount[0] = 0;
  v40 = 0;
  buf2 = 0i64;
  *(_DWORD *)&PropertyType[4] = 0;
  *(_DWORD *)PropertyType = 0;
  *(_QWORD *)v36 = 0i64;
  if( PropertyLocaleName )
    return;
  PiDmGetCacheKeys(ObjectType, (const _PI_DM_CACHED_PROPERTY_KEY **)&CachedKeys, (UINT64 *)&CachedKeyCount[1]);
  if( !CachedKeyCount[1] )
    return;
  v12 = CachedKeys;
  PiDmGetCachedKeyIndex(CachedKeys, CachedKeyCount[1], PropertyKey, v11);
  v14 = v13;
  if( v13 >= v15 )
    return;
  if( !Object )
  {
    ObjectProperty = PiDmGetObject(ObjectType, ObjectName, (PI_DM_OBJECT **)&PushLock);
    if( ObjectProperty < 0 )
      return;
    v40 = 1;
  }
  v16 = 3 * v14;
  if( v12[6 * v14 + 4] == 1 )
  {
    ObjectProperty = PnpGetObjectProperty(
                       0x5A706E50u,
                       0x10ui64,
                       (INT64)ObjectName,
                       ObjectType,
                       0i64,
                       0i64,
                       (INT64)PropertyKey,
                       (INT64)PropertyType,
                       (__int64)&buf2,
                       (__int64)CachedKeyCount);
    if( ObjectProperty == -1073741275 )
    {
      ObjectProperty = 0;
      *(_DWORD *)PropertyType = 0;
      CachedKeyCount[0] = 0;
    }
  }
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  --CurrentThread->Tcb.KernelApcDisable;
  v18 = PushLock;
  ExAcquirePushLockExclusiveEx(PushLock, 0i64);
  v19 = (PI_DM_CACHED_PROPERTY_DATA *)&v18[v16 + 14];
  if( !*v19 )
  {
    if( !v12[2 * v16 + 4] )
      goto LABEL_24;
    goto LABEL_35;
  }
  if( *v19 == 1 || ObjectProperty < 0 || !v12[2 * v16 + 4] )
    goto LABEL_35;
  v20 = PiDmCacheDataDecode(v19, (UINT64 *)&PropertyType[4], 0i64, 0i64, (UINT64 *)&PropertyType[8]);
  ObjectProperty = v20;
  if( v20 == -1073741275 )
  {
    *(_DWORD *)&PropertyType[4] = 0;
    ObjectProperty = 0;
    v22 = *(_DWORD *)PropertyType == 0;
  }
  else
  {
    if( (int)(v20 + 0x80000000) >= 0 && v20 != -1073741789 )
      goto LABEL_35;
    v21 = *(_DWORD *)&PropertyType[8];
    if( *(_DWORD *)&PropertyType[8] )
    {
      PoolWithTag = ExAllocatePoolWithTag(1ui64, *(unsigned int *)&PropertyType[8], 1517317712i64);
      if( !PoolWithTag )
      {
        ObjectProperty = -1073741670;
        goto LABEL_35;
      }
    }
    ObjectProperty = PiDmCacheDataDecode(
                       v19,
                       (UINT64 *)&PropertyType[4],
                       (UINT8 *)PoolWithTag,
                       v21,
                       (UINT64 *)&PropertyType[8]);
    if( ObjectProperty < 0
      || *(_DWORD *)&PropertyType[4] != *(_DWORD *)PropertyType
      || *(_DWORD *)&PropertyType[8] != CachedKeyCount[0] )
    {
      goto LABEL_35;
    }
    if( !*(_DWORD *)&PropertyType[8] )
    {
LABEL_23:
      *v6 = 1;
      goto LABEL_24;
    }
    v22 = memcmp(PoolWithTag, buf2, *(unsigned int *)&PropertyType[8]) == 0;
  }
  if( v22 )
    goto LABEL_23;
LABEL_35:
  PiDmCacheDataFree(v19);
  if( ObjectProperty >= 0 && v12[2 * v16 + 4] == 1 && !v12[2 * v16 + 3] )
    ObjectProperty = PiDmCacheDataEncode(
                       *(unsigned int *)PropertyType,
                       (UINT8 *)buf2,
                       (unsigned int)CachedKeyCount[0],
                       (unsigned int)v12[2 * v16 + 2],
                       0,
                       v19);
LABEL_24:
  ExReleasePushLockEx((ULONG_PTR)PushLock, 0);
  KeLeaveCriticalRegionThread(KeGetCurrentThread());
  if( !v12[2 * v16 + 4] || *v6 )
    goto LABEL_26;
  v23 = 0;
  v24 = PiDmAggregatedBooleanDefs;
  while( 1 )
  {
    v25 = (_QWORD *)v24[1];
    if( *((_DWORD *)v25 + 4) == PropertyKey->pid )
    {
      v26 = *v25 - *(_QWORD *)&PropertyKey->fmtid.Data1;
      if( *v25 == *(_QWORD *)&PropertyKey->fmtid.Data1 )
        v26 = v25[1] - *(_QWORD *)PropertyKey->fmtid.Data4;
      if( !v26 && ObjectType == *(_DWORD *)v24 )
        break;
    }
    ++v23;
    v24 += 7;
    if( v23 >= 3 )
      goto LABEL_26;
  }
  v27 = &PiDmAggregatedBooleanDefs[7 * v23];
  if( !v27
    || PiDmGetReferencedObjectFromProperty(
         ObjectType,
         ObjectName,
         PushLock,
         v25,
         (const _DEVPROPKEY *)v27[2],
         *((_DWORD *)v27 + 6),
         (PI_DM_OBJECT **)v36) < 0 )
  {
    goto LABEL_26;
  }
  v28 = (_ETHREAD *)KeGetCurrentThread();
  v29 = v27[6];
  v30 = *(_EX_PUSH_LOCK **)v36;
  --v28->Tcb.KernelApcDisable;
  ExAcquirePushLockExclusiveEx(*(_EX_PUSH_LOCK **)v36, 0i64);
  if( ObjectProperty < 0 || (v31 = *(_DWORD *)((char *)&v30->_bf_0 + v29), v31 == 0x80000000) )
  {
    *(_DWORD *)((char *)&v30->_bf_0 + v29) = 0x80000000;
    goto LABEL_60;
  }
  if( *(_DWORD *)&PropertyType[4] != 17 )
    goto LABEL_57;
  if( *(_BYTE *)PoolWithTag == 0xFF && (*(_DWORD *)PropertyType != 17 || !*(_BYTE *)buf2) )
  {
    v32 = v31 - 1;
LABEL_59:
    *(_DWORD *)((char *)&v30->_bf_0 + v29) = v32;
    goto LABEL_60;
  }
  if( !*(_BYTE *)PoolWithTag )
  {
LABEL_57:
    if( *(_DWORD *)PropertyType != 17 || *(_BYTE *)buf2 != 0xFF )
      goto LABEL_60;
    v32 = v31 + 1;
    goto LABEL_59;
  }
LABEL_60:
  ExReleasePushLockEx(v36[0], 0);
  KeLeaveCriticalRegionThread(KeGetCurrentThread());
LABEL_26:
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0x5A706E50u);
  if( buf2 )
    ExFreePoolWithTag(buf2, 0x5A706E50u);
  if( *(_QWORD *)v36 )
    PiDmObjectRelease(*(_PI_DM_OBJECT **)v36);
  if( v40 )
    PiDmObjectRelease((_PI_DM_OBJECT *)PushLock);
}

Referenced by:

PiPnpRtlObjectEventWorker