CmSetDeviceInterfaceMappedPropertyFromRegValue

__int64 __fastcall CmSetDeviceInterfaceMappedPropertyFromRegValue(
        __int64 a1,
        const WCHAR *a2,
        void *a3,
        __int64 a4,
        int a5,
        __int64 a6,
        ULONG a7){
  unsigned int v7; 
  int v8; 
  __int64 v13; 
  DEVPROPKEY **v14; 
  DEVPROPKEY *v15; 
  DEVPROPKEY **v16; 
  __int64 v17; 
  int v18; 
  int v19; 
  __int64 v20; 
  int v21; 
  __int64 v23; 
  HANDLE v24; 
  __int64 v25; 
  __int64 v26; 
  HANDLE KeyHandle; 
  HANDLE v28; 
  HANDLE Handle; 
  v7 = *(_DWORD *)(a4 + 16);
  v8 = 0;
  v28 = 0i64;
  KeyHandle = 0i64;
  Handle = 0i64;
  if( v7 < 2 )
    return(unsigned int)-1073741264;
  v13 = 0i64;
  v14 = &off_140983A68;
  do
  {
    v15 = *v14;
    v16 = v14;
    if( v7 == (*v14)->pid )
    {
      v17 = *(_QWORD *)a4 - *(_QWORD *)&v15->fmtid.Data1;
      if( *(_QWORD *)a4 == *(_QWORD *)&v15->fmtid.Data1 )
        v17 = *(_QWORD *)(a4 + 8) - *(_QWORD *)v15->fmtid.Data4;
      if( !v17 )
        break;
    }
    v16 = 0i64;
    v13 = (unsigned int)(v13 + 1);
    v14 += 2;
  }
  while( (unsigned int)v13 < 3 );
  if( !v16 )
    return(unsigned int)-1073741264;
  v18 = *((_DWORD *)v16 + 2);
  if( a5 != v18 )
  {
    if( a5 == 25 )
    {
      if( v18 == 18 )
        goto LABEL_11;
    }
    else if( (unsigned int)a5 < 2 )
    {
      goto LABEL_11;
    }
    return(unsigned int)-1073741811;
  }
LABEL_11:
  if( !a3 )
  {
    v8 = CmOpenDeviceInterfaceRegKey(a1, a2, 0x30u, v13, 1, 0, (__int64)&v28, 0i64);
    if( v8 < 0 )
      goto LABEL_21;
  }
  v19 = *(_DWORD *)(a4 + 16);
  if( v19 == 2 )
  {
    v23 = *(_QWORD *)a4 - *(_QWORD *)&DEVPKEY_DeviceInterface_FriendlyName.fmtid.Data1;
    if( *(_QWORD *)a4 == *(_QWORD *)&DEVPKEY_DeviceInterface_FriendlyName.fmtid.Data1 )
      v23 = *(_QWORD *)(a4 + 8) - *(_QWORD *)DEVPKEY_DeviceInterface_FriendlyName.fmtid.Data4;
    if( !v23 )
    {
      v24 = v28;
      if( a3 )
        v24 = a3;
      v21 = PnpCtxRegCreateKey(a1, (__int64)v24, L"Device Parameters", 0, 2u, 0i64, &KeyHandle, 0i64);
      if( v21 == -1073741444 )
        goto LABEL_45;
      if( v21 < 0 )
        goto LABEL_36;
      v21 = RegRtlSetValue(KeyHandle, L"FriendlyName", 1u, (void *)a6, a7);
LABEL_19:
      if( v21 != -1073741444 )
      {
        if( v21 >= 0 )
          goto LABEL_21;
LABEL_36:
        v8 = v21;
        goto LABEL_21;
      }
LABEL_45:
      v8 = -1073741772;
      goto LABEL_21;
    }
LABEL_55:
    v8 = -1073741264;
    goto LABEL_21;
  }
  if( v19 != 256 )
  {
    if( v19 == 3 )
    {
      v25 = *(_QWORD *)a4 - *(_QWORD *)&DEVPKEY_DeviceInterface_Enabled.fmtid.Data1;
      if( *(_QWORD *)a4 == *(_QWORD *)&DEVPKEY_DeviceInterface_Enabled.fmtid.Data1 )
        v25 = *(_QWORD *)(a4 + 8) - *(_QWORD *)DEVPKEY_DeviceInterface_Enabled.fmtid.Data4;
      if( !v25 )
        goto LABEL_54;
    }
    if( v19 == 4 )
    {
      v26 = *(_QWORD *)a4 - *(_QWORD *)&DEVPKEY_DeviceInterface_ClassGuid.fmtid.Data1;
      if( *(_QWORD *)a4 == *(_QWORD *)&DEVPKEY_DeviceInterface_ClassGuid.fmtid.Data1 )
        v26 = *(_QWORD *)(a4 + 8) - *(_QWORD *)DEVPKEY_DeviceInterface_ClassGuid.fmtid.Data4;
      if( !v26 )
      {
LABEL_54:
        v8 = -1073741790;
        goto LABEL_21;
      }
    }
    goto LABEL_55;
  }
  v20 = *(_QWORD *)a4 - *(_QWORD *)&DEVPKEY_Device_InstanceId.fmtid.Data1;
  if( *(_QWORD *)a4 == *(_QWORD *)&DEVPKEY_Device_InstanceId.fmtid.Data1 )
    v20 = *(_QWORD *)(a4 + 8) - *(_QWORD *)DEVPKEY_Device_InstanceId.fmtid.Data4;
  if( v20 )
    goto LABEL_55;
  v8 = CmOpenDeviceInterfaceRegKey(a1, a2, 0x31u, v13, 2, 0, (__int64)&Handle, 0i64);
  if( v8 >= 0 )
  {
    v21 = RegRtlSetValue(Handle, L"DeviceInstance", 1u, (void *)a6, a7);
    goto LABEL_19;
  }
LABEL_21:
  if( Handle )
    ZwClose(Handle);
  if( KeyHandle )
    ZwClose(KeyHandle);
  if( v28 )
    ZwClose(v28);
  return(unsigned int)v8;
}

Referenced by:

CmSetDeviceInterfaceMappedProperty