ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

PORTCLASSAPI NTSTATUS NTAPI PcNewResourceList ( OUT PRESOURCELIST OutResourceList,
IN PUNKNOWN OuterUnknown  OPTIONAL,
IN POOL_TYPE  PoolType,
IN PCM_RESOURCE_LIST  TranslatedResourceList,
IN PCM_RESOURCE_LIST  UntranslatedResourceList 
)

Definition at line 304 of file resource.cpp.

Referenced by PortClsPnp().

{
    PCM_RESOURCE_LIST NewUntranslatedResources, NewTranslatedResources;
    ULONG ResourceSize, ResourceCount;
    CResourceList* NewList;
    NTSTATUS Status;

    if (!TranslatedResourceList)
    {
        /* If the untranslated resource list is also not provided, it becomes an empty resource list */
        if (UntranslatedResourceList)
        {
            /* Invalid parameter mix */
            return STATUS_INVALID_PARAMETER;
        }
    }
    else
    {
        /* If the translated resource list is also not provided, it becomes an empty resource list */
        if (!UntranslatedResourceList)
        {
            /* Invalid parameter mix */
            return STATUS_INVALID_PARAMETER;
        }
    }

    /* Allocate resource list */
    NewList = new(PoolType, TAG_PORTCLASS)CResourceList(OuterUnknown);
    if (!NewList)
        return STATUS_INSUFFICIENT_RESOURCES;

    /* Query resource list */
    Status = NewList->QueryInterface(IID_IResourceList, (PVOID*)OutResourceList);
    if (!NT_SUCCESS(Status))
    {
        /* Ouch, FIX ME */
        delete NewList;
        return STATUS_INVALID_PARAMETER;
    }

    /* Is there a resource list */
    if (!TranslatedResourceList)
    {
        /* Empty resource list */
        return STATUS_SUCCESS;
    }

    /* Sanity check */
    ASSERT(UntranslatedResourceList->List[0].PartialResourceList.Count == TranslatedResourceList->List[0].PartialResourceList.Count);

    /* Get resource count */
    ResourceCount = UntranslatedResourceList->List[0].PartialResourceList.Count;
#ifdef _MSC_VER
    ResourceSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]);
#else
    ResourceSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
#endif

    /* Allocate translated resource list */
    NewTranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(PoolType, ResourceSize, TAG_PORTCLASS);
    if (!NewTranslatedResources)
    {
        /* No memory */
        delete NewList;
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    /* Allocate untranslated resource list */
    NewUntranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(PoolType, ResourceSize, TAG_PORTCLASS);
    if (!NewUntranslatedResources)
    {
        /* No memory */
        delete NewList;
        FreeItem(NewTranslatedResources, TAG_PORTCLASS);
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    /* Copy resource lists */
    RtlCopyMemory(NewTranslatedResources, TranslatedResourceList, ResourceSize);
    RtlCopyMemory(NewUntranslatedResources, UntranslatedResourceList, ResourceSize);

    /* Init resource list */
    NewList->m_TranslatedResourceList= NewTranslatedResources;
    NewList->m_UntranslatedResourceList = NewUntranslatedResources;
    NewList->m_NumberOfEntries = ResourceCount;
    NewList->m_MaxEntries = ResourceCount;    
    NewList->m_PoolType = PoolType;
 
    /* Done */
    return STATUS_SUCCESS;
}

Generated on Sat May 26 2012 05:26:00 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.