CmGetInterfaceClassMappedPropertyFromRegValue

NTSTATUS __stdcall CmGetInterfaceClassMappedPropertyFromRegValue(
        HPNPCTX *hPnpCtx,
        WCHAR *ClassGuid,
        VOID *ObjectBaseKey,
        _DEVPROPKEY *PropertyKey,
        UINT64 *PropertyType,
        UINT8 *PropertyBuffer,
        UINT64 BufferSize,
        UINT64 *PropertySize){
  UINT64 *v8; 
  int v9; 
  UINT64 *v10; 
  VOID *v13; 
  int v14; 
  UINT64 pid; 
  int v16; 
  DEVPROPKEY **v17; 
  DEVPROPKEY *v18; 
  DEVPROPKEY **v19; 
  __int64 v20; 
  __int64 v21; 
  int v22; 
  int v24; 
  VOID **ClassKey; 
  UINT64 *Disposition; 
  VOID *KeyHandle; 
  VOID *Handle; 
  int v30; 

  v8 = PropertyType;
  v9 = 0;
  v10 = PropertySize;
  v30 = 0;
  Handle = 0i64;
  *(_DWORD *)PropertyType = 0;
  *(_DWORD *)v10 = 0;
  KeyHandle = 0i64;
  v13 = PropertyBuffer;
  if( PropertyBuffer )
  {
    v14 = BufferSize;
    v13 = (VOID *)(-(__int64)((_DWORD)BufferSize != 0) & (unsigned __int64)PropertyBuffer);
  }
  else
  {
    v14 = 0;
  }
  pid = PropertyKey->pid;
  if( (unsigned int)pid < 2 )
    return -1073741264;
  v16 = 0;
  v17 = &off_140983758;
  do
  {
    v18 = *v17;
    v19 = v17;
    if( (_DWORD)pid == (*v17)->pid )
    {
      v20 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&v18->fmtid.Data1;
      if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&v18->fmtid.Data1 )
        v20 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)v18->fmtid.Data4;
      if( !v20 )
        break;
    }
    v19 = 0i64;
    ++v16;
    v17 += 2;
  }
  while( !v16 );
  if( !v19 )
    return -1073741264;
  if( (_DWORD)pid == 2 )
  {
    v21 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceInterfaceClass_DefaultInterface.fmtid.Data1;
    if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceInterfaceClass_DefaultInterface.fmtid.Data1 )
      v21 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceInterfaceClass_DefaultInterface.fmtid.Data4;
    if( !v21 )
    {
      if( !ObjectBaseKey )
      {
        LOBYTE(Disposition) = 0;
        LODWORD(ClassKey) = 1;
        v9 = CmOpenInterfaceClassRegKey(hPnpCtx, ClassGuid, pid, (UINT8)PropertyKey, ClassKey, Disposition);
        if( v9 < 0 )
          goto LABEL_17;
        ObjectBaseKey = Handle;
      }
      v22 = PnpOpenPropertiesKey((__int64)hPnpCtx, ObjectBaseKey, 0i64, 1u, 0, (int)Disposition, (INT64)&KeyHandle);
      v9 = v22;
      if( v22 == -1073741772 )
      {
LABEL_16:
        v9 = -1073741275;
        goto LABEL_17;
      }
      if( v22 >= 0 )
      {
        LODWORD(PropertyType) = v14;
        v24 = RegRtlQueryValue(KeyHandle, L"Default", &v30, v13, (__int64)&PropertyType);
        ZwClose((_HANDLE)KeyHandle);
        if( v24 != -1073741772 && v24 != -1073741444 )
        {
          if( !v24 || v24 == -1073741789 )
          {
            *(_DWORD *)PropertySize = (_DWORD)PropertyType;
            *(_DWORD *)v8 = 18;
            if( v24 || !v14 )
              v9 = -1073741789;
          }
          else
          {
            v9 = v24;
          }
          goto LABEL_17;
        }
        goto LABEL_16;
      }
LABEL_17:
      if( Handle )
        ZwClose((_HANDLE)Handle);
    }
  }
  return v9;
}

Referenced by:

CmGetInterfaceClassMappedProperty
CmGetInterfaceClassMappedPropertyKeys