DrvDbGetDriverPackageMappedPropertyKeys

NTSTATUS __stdcall DrvDbGetDriverPackageMappedPropertyKeys(
        _DRVDB_CONTEXT *pDrvDbCtx,
        WCHAR *DriverPackageId,
        VOID *ObjectBaseKey,
        _DEVPROPKEY *PropertyKeys,
        UINT64 BufferLength,
        UINT64 *PropertyCount){
  UINT64 *v6; 
  unsigned int v7; 
  _DEVPROPKEY *v10; 
  unsigned int v11; 
  signed int CompositeMappedPropertyKeys; 
  __int64 v13; 
  __int64 v14; 
  unsigned int v15; 
  _DEVPROPKEY **v16; 
  VOID *v17; 
  NTSTATUS DriverPackageMappedProperty; 
  _DEVPROPKEY *v19; 
  __int64 v20; 
  __int64 v21; 
  unsigned int v22; 
  int v23; 
  unsigned int v24; 
  unsigned int v25; 
  const wchar_t **v26; 
  VOID *v27; 
  signed int Value; 
  const wchar_t *v29; 
  __int64 v30; 
  VOID *v31; 
  const wchar_t *v32; 
  __int64 v33; 
  __int64 v34; 
  unsigned int v35; 
  int v36; 
  unsigned int v37; 
  INT64 v39; 
  UINT64 *v40; 
  UINT64 v41; 
  WCHAR SignerScore[2]; 
  UINT64 PropertyType; 
  __int64 v44[2]; 

  v6 = PropertyCount;
  v7 = BufferLength;
  v40 = PropertyCount;
  v44[0] = 0i64;
  PropertyType = 0i64;
  v10 = PropertyKeys;
  v11 = 0;
  *(_DWORD *)SignerScore = 0;
  *(_DWORD *)PropertyCount = 0;
  LODWORD(v39) = BufferLength;
  CompositeMappedPropertyKeys = DrvDbGetCompositeMappedPropertyKeys(
                                  pDrvDbCtx,
                                  (const _DEVPROPKEY **)&off_140C0F0B0,
                                  0xEui64,
                                  PropertyKeys,
                                  v39,
                                  v40);
  if( CompositeMappedPropertyKeys >= 0 )
  {
    v14 = *(unsigned int *)v6;
    if( (_DWORD)v14 )
    {
      if( v13 )
        v10 = (_DEVPROPKEY *)(v13 + 20 * v14);
      v7 = BufferLength - v14;
    }
    if( ObjectBaseKey
      || (CompositeMappedPropertyKeys = DrvDbOpenDriverPackageRegKey(
                                          (INT64 *)pDrvDbCtx,
                                          (INT64)DriverPackageId,
                                          1i64,
                                          0,
                                          (INT64)v44,
                                          0i64),
          CompositeMappedPropertyKeys >= 0) )
    {
      v15 = 0;
      v16 = (_DEVPROPKEY **)off_1400099D0;
      while( 1 )
      {
        v17 = (VOID *)v44[0];
        if( ObjectBaseKey )
          v17 = ObjectBaseKey;
        LODWORD(v41) = 0;
        DriverPackageMappedProperty = DrvDbGetDriverPackageMappedProperty(
                                        pDrvDbCtx,
                                        DriverPackageId,
                                        v17,
                                        *v16,
                                        (UINT64 *)((char *)&PropertyType + 4),
                                        0i64,
                                        v41,
                                        &PropertyType);
        if( DriverPackageMappedProperty != -1073741275 )
        {
          if( DriverPackageMappedProperty && DriverPackageMappedProperty != -1073741789 )
            goto LABEL_23;
          if( v10 && v11 < v7 )
          {
            v19 = *v16;
            v20 = v11++;
            v21 = v20;
            v10[v21].fmtid = (*v16)->fmtid;
            v10[v21].pid = v19->pid;
          }
          v22 = *(_DWORD *)v6;
          v23 = -1;
          v24 = *(_DWORD *)v6 + 1;
          if( v24 >= *(_DWORD *)v6 )
            v23 = *(_DWORD *)v6 + 1;
          *(_DWORD *)v6 = v23;
          if( v24 < v22 )
            break;
        }
        ++v15;
        ++v16;
        if( v15 >= 2 )
          goto LABEL_23;
      }
      *(_DWORD *)v6 = 0;
LABEL_23:
      v25 = 0;
      v26 = (const wchar_t **)&off_140001760;
      do
      {
        LODWORD(PropertyCount) = 0;
        v27 = (VOID *)v44[0];
        if( ObjectBaseKey )
          v27 = ObjectBaseKey;
        Value = RegRtlQueryValue(v27, v26[2], 0i64, 0i64, (__int64)&PropertyCount);
        CompositeMappedPropertyKeys = Value;
        if( Value == -1073741772 )
        {
          v29 = *v26;
          if( *((_DWORD *)*v26 + 4) != 7 )
            goto LABEL_35;
          v30 = *(_QWORD *)v29 - *(_QWORD *)&DEVPKEY_DriverPackage_SignerName.fmtid.Data1;
          if( *(_QWORD *)v29 == *(_QWORD *)&DEVPKEY_DriverPackage_SignerName.fmtid.Data1 )
            v30 = *((_QWORD *)v29 + 1) - *(_QWORD *)DEVPKEY_DriverPackage_SignerName.fmtid.Data4;
          if( v30 )
            goto LABEL_35;
          v31 = (VOID *)v44[0];
          if( ObjectBaseKey )
            v31 = ObjectBaseKey;
          if( DrvDbGetDriverPackageSignerScore(pDrvDbCtx, DriverPackageId, v31, SignerScore) < 0
            || *(_DWORD *)SignerScore != 218103811 )
          {
LABEL_35:
            CompositeMappedPropertyKeys = 0;
            goto LABEL_44;
          }
        }
        else if( Value && Value != -1073741789 )
        {
          break;
        }
        if( v10 && v11 < v7 )
        {
          v32 = *v26;
          v33 = v11++;
          v34 = v33;
          v10[v34].fmtid = *(_GUID *)*v26;
          v10[v34].pid = *((_DWORD *)v32 + 4);
        }
        v35 = *(_DWORD *)v6;
        v36 = -1;
        v37 = *(_DWORD *)v6 + 1;
        if( v37 >= *(_DWORD *)v6 )
          v36 = *(_DWORD *)v6 + 1;
        CompositeMappedPropertyKeys = v37 < v35 ? 0xC0000095 : 0;
        *(_DWORD *)v6 = v36;
        if( v37 < v35 )
        {
          *(_DWORD *)v6 = 0;
          break;
        }
LABEL_44:
        ++v25;
        v26 += 5;
      }
      while( v25 < 0x20 );
    }
    if( v44[0] )
      ZwClose(v44[0]);
  }
  return CompositeMappedPropertyKeys;
}

Referenced by:

DrvDbDispatchDriverPackage