CmSetInstallerClassMappedPropertyFromRegValue

NTSTATUS __stdcall CmSetInstallerClassMappedPropertyFromRegValue(
        HPNPCTX *hPnpCtx,
        const WCHAR *ClassGuid,
        VOID *ObjectBaseKey,
        const _DEVPROPKEY *PropertyKey,
        UINT64 PropertyType,
        UINT8 *PropertyBuffer,
        UINT64 PropertySize){
  unsigned int pid; 
  NTSTATUS v8; 
  const UINT8 *v10; 
  unsigned int i; 
  _QWORD *v15; 
  const UINT8 *v16; 
  __int64 v17; 
  int v18; 
  unsigned int v19; 
  const wchar_t *v20; 
  unsigned int v21; 
  VOID *v22; 
  NTSTATUS v23; 
  __int64 v25; 
  __int64 v26; 
  __int64 v27; 
  __int64 v28; 
  __int64 v29; 
  wchar_t *v30; 
  VOID *v31; 
  NTSTATUS v32; 
  __int64 v33; 
  int v34; 
  VOID *v35; 
  __int64 v36; 
  VOID **ClassKey; 
  UINT64 *Disposition; 
  int v39; 
  UINT64 v40; 
  VOID *Handle; 

  pid = PropertyKey->pid;
  v8 = 0;
  v39 = 0;
  v40 = 0i64;
  v10 = &Create;
  Handle = 0i64;
  for( i = 0; i < 0xD; ++i )
  {
    v15 = *(_QWORD **)v10;
    v16 = v10;
    if( pid == *(_DWORD *)(*(_QWORD *)v10 + 16i64) )
    {
      v17 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *v15;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *v15 )
        v17 = *(_QWORD *)PropertyKey->fmtid.Data4 - v15[1];
      if( !v17 )
        break;
    }
    v16 = 0i64;
    v10 += 32;
  }
  if( !v16 )
    return -1073741802;
  v18 = *((_DWORD *)v16 + 2);
  if( (_DWORD)PropertyType != v18 )
  {
    if( (_DWORD)PropertyType == 25 )
    {
      if( v18 == 18 )
        goto LABEL_10;
    }
    else if( (unsigned int)PropertyType < 2 )
    {
      goto LABEL_10;
    }
    return -1073741811;
  }
LABEL_10:
  if( !ObjectBaseKey )
  {
    LOBYTE(Disposition) = 0;
    LODWORD(ClassKey) = 3;
    v8 = CmOpenInstallerClassRegKey(hPnpCtx, (WCHAR *)ClassGuid, 0i64, (UINT8)v10, ClassKey, Disposition);
    if( v8 < 0 )
      goto LABEL_22;
  }
  v19 = PropertyKey->pid;
  v20 = (const wchar_t *)*((_QWORD *)v16 + 2);
  v21 = *((_DWORD *)v16 + 6);
  if( v19 != 7 )
    goto LABEL_49;
  v25 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_NoInstallClass.fmtid.Data1;
  if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_NoInstallClass.fmtid.Data1 )
    v25 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_NoInstallClass.fmtid.Data4;
  if( v25 )
  {
LABEL_49:
    if( v19 != 8 )
      goto LABEL_85;
    v26 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_NoDisplayClass.fmtid.Data1;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_NoDisplayClass.fmtid.Data1 )
      v26 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_NoDisplayClass.fmtid.Data4;
    if( v26 )
    {
LABEL_85:
      if( v19 != 9 )
        goto LABEL_86;
      v27 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_SilentInstall.fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_SilentInstall.fmtid.Data1 )
        v27 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_SilentInstall.fmtid.Data4;
      if( v27 )
      {
LABEL_86:
        if( v19 != 10 )
          goto LABEL_15;
        v28 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_NoUseClass.fmtid.Data1;
        if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_NoUseClass.fmtid.Data1 )
          v28 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_NoUseClass.fmtid.Data4;
        if( v28 )
        {
LABEL_15:
          if( v19 != 15 )
          {
            if( v19 != 2 )
            {
              if( v19 != 3 )
                goto LABEL_18;
              v36 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_ClassName.fmtid.Data1;
              if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_ClassName.fmtid.Data1 )
                v36 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_ClassName.fmtid.Data4;
              if( v36 || (unsigned int)PropertySize <= 0x40 )
              {
LABEL_18:
                v22 = (VOID *)v40;
                LODWORD(ClassKey) = PropertySize;
                if( ObjectBaseKey )
                  v22 = ObjectBaseKey;
                v23 = RegRtlSetValue(v22, v20, v21, PropertyBuffer, (UINT64)ClassKey);
                if( v23 < 0 )
                  v8 = v23;
                goto LABEL_22;
              }
              goto LABEL_57;
            }
            v33 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceClass_DHPRebalanceOptOut.fmtid.Data1;
            if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceClass_DHPRebalanceOptOut.fmtid.Data1 )
              v33 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceClass_DHPRebalanceOptOut.fmtid.Data4;
            if( v33 )
              goto LABEL_18;
            if( !(_DWORD)PropertySize )
              goto LABEL_57;
            if( *PropertyBuffer == 0xFF )
            {
              v34 = 1;
LABEL_74:
              v35 = (VOID *)v40;
              v39 = v34;
              if( ObjectBaseKey )
                v35 = ObjectBaseKey;
              v8 = PnpOpenPropertiesKey((__int64)hPnpCtx, v35, 0i64, 2u, 1, (int)Disposition, (INT64)&Handle);
              if( v8 < 0 )
                goto LABEL_22;
              v31 = Handle;
              v30 = (wchar_t *)&v39;
              goto LABEL_62;
            }
            if( !*PropertyBuffer )
            {
              v34 = 0;
              goto LABEL_74;
            }
            goto LABEL_57;
          }
          v29 = *(_QWORD *)&PropertyKey->fmtid.Data1 - DEVPKEY_DeviceClass_FSFilterClass;
          if( *(_QWORD *)&PropertyKey->fmtid.Data1 == DEVPKEY_DeviceClass_FSFilterClass )
            v29 = *(_QWORD *)PropertyKey->fmtid.Data4 - 0x6633D7A7C96808AFi64;
          if( v29 )
            goto LABEL_18;
        }
      }
    }
  }
  if( (_DWORD)PropertySize )
  {
    if( *PropertyBuffer == 0xFF )
    {
      v30 = L"1";
    }
    else
    {
      if( *PropertyBuffer )
        goto LABEL_57;
      v30 = (wchar_t *)L"0";
    }
    v31 = (VOID *)v40;
    if( ObjectBaseKey )
      v31 = ObjectBaseKey;
LABEL_62:
    LODWORD(ClassKey) = 4;
    v32 = RegRtlSetValue(v31, v20, v21, v30, (UINT64)ClassKey);
    if( v32 == -1073741444 )
    {
      v8 = -1073741772;
    }
    else if( v32 < 0 )
    {
      v8 = v32;
    }
    goto LABEL_22;
  }
LABEL_57:
  v8 = -1073741811;
LABEL_22:
  if( Handle )
    ZwClose((_HANDLE)Handle);
  if( v40 )
    ZwClose(v40);
  return v8;
}

Referenced by:

CmSetInstallerClassMappedProperty