IopChangeInterfaceType

UINT8 __stdcall IopChangeInterfaceType(
        _IO_RESOURCE_REQUIREMENTS_LIST *IoResources,
        _CM_RESOURCE_LIST **AllocatedResources){
  UINT8 v2; 
  UINT8 result; 
  unsigned int AlternativeLists; 
  _IO_RESOURCE_LIST *List; 
  _IO_RESOURCE_DESCRIPTOR *Descriptors; 
  _CM_RESOURCE_LIST *v8; 
  size_t v9; 
  VOID **PoolWithTag; 
  _CM_RESOURCE_LIST *v11; 
  unsigned int v12; 
  _CM_FULL_RESOURCE_DESCRIPTOR *i; 
  unsigned int Count; 
  _CM_PARTIAL_RESOURCE_DESCRIPTOR *PartialDescriptors; 
  __int64 v16; 
  __int64 LowPart; 

  v2 = 0;
  result = (unsigned __int8)IoResources;
  if( IoResources )
  {
    if( IoResources->InterfaceType == Internal )
    {
      IoResources->InterfaceType = Isa;
      v2 = 1;
    }
    AlternativeLists = IoResources->AlternativeLists;
    List = IoResources->List;
    while( (--AlternativeLists & 0x80000000) == 0 )
    {
      Descriptors = List->Descriptors;
      List = (_IO_RESOURCE_LIST *)((char *)List + 32 * List->Count + 8);
      while( Descriptors < (_IO_RESOURCE_DESCRIPTOR *)List )
      {
        if( Descriptors->Type == 0xF0 && !Descriptors->u.Port.Length )
        {
          Descriptors->u.Port.Length = 1;
          v2 = 1;
        }
        ++Descriptors;
      }
    }
    if( v2 )
    {
      v8 = *AllocatedResources;
      if( *AllocatedResources )
      {
        v9 = PnpDetermineResourceListSize(*AllocatedResources);
        PoolWithTag = ExAllocatePoolWithTag(1ui64, v9, 538996816i64);
        v11 = (_CM_RESOURCE_LIST *)PoolWithTag;
        if( PoolWithTag )
        {
          memmove(PoolWithTag, v8, v9);
          v12 = 0;
          for( i = v11->List; v12 < v8->Count; i = (_CM_FULL_RESOURCE_DESCRIPTOR *)PartialDescriptors )
          {
            if( i->InterfaceType == Internal )
              i->InterfaceType = Isa;
            Count = i->PartialResourceList.Count;
            PartialDescriptors = i->PartialResourceList.PartialDescriptors;
            if( Count )
            {
              v16 = Count;
              do
              {
                LowPart = 0i64;
                if( PartialDescriptors->Type == 5 )
                  LowPart = PartialDescriptors->u.Start.anonymous_0.LowPart;
                PartialDescriptors = (_CM_PARTIAL_RESOURCE_DESCRIPTOR *)((char *)PartialDescriptors + LowPart + 20);
                --v16;
              }
              while( v16 );
            }
            ++v12;
          }
          *AllocatedResources = v11;
        }
        else
        {
          return 0;
        }
      }
    }
    return v2;
  }
  return result;
}

Referenced by:

IoReportResourceUsageInternal