CmGetInstallerClassMappedPropertyFromRegValue

NTSTATUS __stdcall CmGetInstallerClassMappedPropertyFromRegValue(
        HPNPCTX *hPnpCtx,
        const WCHAR *ClassGuid,
        VOID *ObjectBaseKey,
        const _DEVPROPKEY *PropertyKey,
        UINT64 *PropertyType,
        UINT8 *PropertyBuffer,
        UINT64 BufferSize,
        UINT64 *PropertySize){
  _BYTE *v10; 
  const UINT8 *v11; 
  unsigned int pid; 
  int v14; 
  unsigned int v15; 
  _QWORD *v16; 
  const UINT8 *v17; 
  int v18; 
  unsigned int v19; 
  VOID *v20; 
  WCHAR *v21; 
  NTSTATUS v22; 
  __int64 v24; 
  VOID *v25; 
  const wchar_t *v26; 
  int Value; 
  int v28; 
  __int64 v29; 
  __int64 v30; 
  __int64 v31; 
  __int64 v32; 
  int v33; 
  __int64 v34; 
  int v35; 
  WCHAR *v36; 
  VOID *v37; 
  NTSTATUS v38; 
  __int64 v39; 
  VOID *v40; 
  const wchar_t *v41; 
  int v42; 
  VOID **ClassKey; 
  UINT64 *Disposition; 
  UINT8 Indirected[4]; 
  UINT64 DataSize; 
  VOID *Handle; 
  int v48; 
  INT64 v49; 
  UINT64 *v50; 
  VOID *KeyHandle; 
  wchar_t Str2[12]; 

  v10 = PropertyBuffer;
  v11 = &Create;
  v49 = (INT64)hPnpCtx;
  pid = PropertyKey->pid;
  LODWORD(hPnpCtx) = 0;
  v50 = PropertySize;
  v14 = 0;
  Handle = 0i64;
  v15 = 0;
  KeyHandle = 0i64;
  DataSize = 0i64;
  Indirected[0] = 0;
  v48 = 0;
  while( 1 )
  {
    v16 = *(_QWORD **)v11;
    v17 = v11;
    if( pid == *(_DWORD *)(*(_QWORD *)v11 + 16i64) )
      break;
LABEL_3:
    ++v15;
    v11 += 32;
    v17 = 0i64;
    if( v15 >= 0xD )
      goto LABEL_8;
  }
  hPnpCtx = (HPNPCTX *)(*(_QWORD *)&PropertyKey->fmtid.Data1 - *v16);
  if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *v16 )
    hPnpCtx = (HPNPCTX *)(*(_QWORD *)PropertyKey->fmtid.Data4 - v16[1]);
  if( hPnpCtx )
  {
    LODWORD(hPnpCtx) = 0;
    goto LABEL_3;
  }
LABEL_8:
  if( !v17 )
    return -1073741802;
  *(_DWORD *)PropertyType = (_DWORD)hPnpCtx;
  *(_DWORD *)PropertySize = (_DWORD)hPnpCtx;
  if( PropertyBuffer )
  {
    v18 = BufferSize;
    v10 = (_BYTE *)(-(__int64)((_DWORD)BufferSize != 0) & (unsigned __int64)PropertyBuffer);
    LOBYTE(hPnpCtx) = 0;
  }
  else
  {
    v18 = (int)hPnpCtx;
  }
  if( !ObjectBaseKey )
  {
    LOBYTE(Disposition) = (_BYTE)hPnpCtx;
    LODWORD(ClassKey) = 1;
    v14 = CmOpenInstallerClassRegKey((HPNPCTX *)v49, (WCHAR *)ClassGuid, (UINT64)v16, v15, ClassKey, Disposition);
    if( v14 < 0 )
      goto LABEL_22;
  }
  v19 = PropertyKey->pid;
  if( v19 == 7 )
  {
    v29 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_NoInstallClass.fmtid.Data1;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_NoInstallClass.fmtid.Data1 )
      v29 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_NoInstallClass.fmtid.Data4;
    if( !v29 )
      goto LABEL_33;
  }
  if( v19 == 8 )
  {
    v30 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_NoDisplayClass.fmtid.Data1;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_NoDisplayClass.fmtid.Data1 )
      v30 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_NoDisplayClass.fmtid.Data4;
    if( !v30 )
      goto LABEL_33;
  }
  if( v19 == 9 )
  {
    v31 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_SilentInstall.fmtid.Data1;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_SilentInstall.fmtid.Data1 )
      v31 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_SilentInstall.fmtid.Data4;
    if( !v31 )
      goto LABEL_33;
  }
  if( v19 == 10 )
  {
    v24 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_NoUseClass.fmtid.Data1;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_NoUseClass.fmtid.Data1 )
      v24 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_NoUseClass.fmtid.Data4;
    if( !v24 )
      goto LABEL_33;
  }
  if( v19 == 15 )
  {
    v32 = *(_QWORD *)&PropertyKey->fmtid.Data1 - DEVPKEY_DeviceClass_FSFilterClass;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == DEVPKEY_DeviceClass_FSFilterClass )
      v32 = *(_QWORD *)PropertyKey->fmtid.Data4 - 0x6633D7A7C96808AFi64;
    if( !v32 )
    {
LABEL_33:
      v25 = Handle;
      v26 = (const wchar_t *)*((_QWORD *)v17 + 2);
      LODWORD(DataSize) = 22;
      if( ObjectBaseKey )
        v25 = ObjectBaseKey;
      Value = RegRtlQueryValue(v25, v26, (_DWORD *)&DataSize + 1, Str2, (__int64)&DataSize);
      if( Value != -1073741772 && Value != -1073741444 )
      {
        if( Value >= 0 )
        {
          *(_DWORD *)v50 = 1;
          *(_DWORD *)PropertyType = *((_DWORD *)v17 + 2);
          if( v18 )
          {
            Str2[10] = 0;
            v33 = wcsicmp(L"0", Str2);
LABEL_68:
            *v10 = -(v33 != 0);
            goto LABEL_22;
          }
          goto LABEL_67;
        }
        goto LABEL_66;
      }
      goto LABEL_21;
    }
  }
  if( v19 != 2 )
  {
LABEL_18:
    v20 = Handle;
    v21 = (WCHAR *)*((_QWORD *)v17 + 2);
    if( ObjectBaseKey )
      v20 = ObjectBaseKey;
    LODWORD(DataSize) = v18;
    v22 = PnpCtxRegQueryValueIndirect(
            (HPNPCTX *)v49,
            v20,
            v21,
            (UINT64 *)((char *)&DataSize + 4),
            v10,
            &DataSize,
            Indirected);
    if( v22 == -1073741772 || v22 == -1073741444 )
      goto LABEL_21;
    if( v22 && v22 != -1073741789 )
    {
      v14 = v22;
      goto LABEL_22;
    }
    goto LABEL_39;
  }
  v34 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_Name.fmtid.Data1;
  if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_Name.fmtid.Data1 )
    v34 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_Name.fmtid.Data4;
  if( v34 )
  {
    v39 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_DHPRebalanceOptOut.fmtid.Data1;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_DHPRebalanceOptOut.fmtid.Data1 )
      v39 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_DHPRebalanceOptOut.fmtid.Data4;
    if( !v39 )
    {
      v40 = Handle;
      v41 = (const wchar_t *)*((_QWORD *)v17 + 2);
      if( ObjectBaseKey )
        v40 = ObjectBaseKey;
      LODWORD(DataSize) = 4;
      v42 = PnpOpenPropertiesKey(v49, v40, 0i64, 1u, 0, (int)Disposition, (INT64)&KeyHandle);
      v14 = v42;
      if( v42 != -1073741772 )
      {
        if( v42 < 0 )
          goto LABEL_22;
        Value = RegRtlQueryValue(KeyHandle, v41, (_DWORD *)&DataSize + 1, &v48, (__int64)&DataSize);
        if( Value != -1073741772 && Value != -1073741444 )
        {
          if( Value >= 0 )
          {
            *(_DWORD *)v50 = 1;
            *(_DWORD *)PropertyType = *((_DWORD *)v17 + 2);
            if( v18 )
            {
              v33 = v48;
              goto LABEL_68;
            }
LABEL_67:
            v14 = -1073741789;
            goto LABEL_22;
          }
LABEL_66:
          v14 = Value;
          goto LABEL_22;
        }
      }
LABEL_21:
      v14 = -1073741275;
      goto LABEL_22;
    }
    goto LABEL_18;
  }
  v35 = 0;
  v14 = -1073741275;
  while( 1 )
  {
    if( v35 )
    {
      v36 = (WCHAR *)&dword_1407CF120;
    }
    else
    {
      v36 = (WCHAR *)*((_QWORD *)v17 + 2);
      if( !v36 )
        goto LABEL_22;
    }
    v37 = Handle;
    LODWORD(DataSize) = v18;
    if( ObjectBaseKey )
      v37 = ObjectBaseKey;
    v38 = PnpCtxRegQueryValueIndirect(
            (HPNPCTX *)v49,
            v37,
            v36,
            (UINT64 *)((char *)&DataSize + 4),
            v10,
            &DataSize,
            Indirected);
    v22 = v38;
    if( v38 != -1073741772 && v38 != -1073741444 )
      break;
    if( ++v35 >= 2 )
      goto LABEL_22;
  }
  if( !v38 || (v14 = v38, v38 == -1073741789) )
    v14 = 0;
  if( v14 >= 0 )
  {
LABEL_39:
    *(_DWORD *)v50 = DataSize;
    v28 = *((_DWORD *)v17 + 2);
    *(_DWORD *)PropertyType = v28;
    if( v22 || !v18 )
      v14 = -1073741789;
    if( Indirected[0] && v28 == 18 )
      *(_DWORD *)PropertyType = 25;
  }
LABEL_22:
  if( KeyHandle )
    ZwClose((_HANDLE)KeyHandle);
  if( Handle )
    ZwClose((_HANDLE)Handle);
  return v14;
}

Referenced by:

CmGetInstallerClassMappedProperty
CmGetInstallerClassMappedPropertyKeys