[PORTCLS]

* Fix some memory leaks.
* Add some comments.
* Fix broken PcNewResourceSublist which ignored the MaximumEntries parameter.
* Add more checks.

svn path=/trunk/; revision=55002
This commit is contained in:
Amine Khaldi 2012-01-17 23:42:13 +00:00
parent 3209e691d6
commit 0102072a69

View file

@ -34,11 +34,9 @@ public:
} }
IMP_IResourceList; IMP_IResourceList;
#ifdef BUILD_WDK
ULONG NTAPI NumberOfEntries(); CResourceList(IUnknown * OuterUnknown) : m_OuterUnknown(OuterUnknown), m_PoolType(NonPagedPool), m_TranslatedResourceList(0), m_UntranslatedResourceList(0), m_NumberOfEntries(0), m_MaxEntries(0), m_Ref(0) {}
#endif virtual ~CResourceList();
CResourceList(IUnknown * OuterUnknown) : m_OuterUnknown(OuterUnknown), m_PoolType(NonPagedPool), m_TranslatedResourceList(0), m_UntranslatedResourceList(0), m_NumberOfEntries(0) {}
virtual ~CResourceList() {}
public: public:
PUNKNOWN m_OuterUnknown; PUNKNOWN m_OuterUnknown;
@ -46,10 +44,24 @@ public:
PCM_RESOURCE_LIST m_TranslatedResourceList; PCM_RESOURCE_LIST m_TranslatedResourceList;
PCM_RESOURCE_LIST m_UntranslatedResourceList; PCM_RESOURCE_LIST m_UntranslatedResourceList;
ULONG m_NumberOfEntries; ULONG m_NumberOfEntries;
ULONG m_MaxEntries;
LONG m_Ref; LONG m_Ref;
}; };
CResourceList::~CResourceList()
{
if (m_TranslatedResourceList)
{
/* Free resource list */
FreeItem(m_TranslatedResourceList, TAG_PORTCLASS);
}
if (m_UntranslatedResourceList)
{
/* Free resource list */
FreeItem(m_UntranslatedResourceList, TAG_PORTCLASS);
}
}
NTSTATUS NTSTATUS
NTAPI NTAPI
@ -75,7 +87,7 @@ CResourceList::QueryInterface(
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
#if 1
ULONG ULONG
NTAPI NTAPI
CResourceList::NumberOfEntries() CResourceList::NumberOfEntries()
@ -84,7 +96,6 @@ CResourceList::NumberOfEntries()
return m_NumberOfEntries; return m_NumberOfEntries;
} }
#endif
ULONG ULONG
NTAPI NTAPI
@ -92,39 +103,27 @@ CResourceList::NumberOfEntriesOfType(
IN CM_RESOURCE_TYPE Type) IN CM_RESOURCE_TYPE Type)
{ {
ULONG Index, Count = 0; ULONG Index, Count = 0;
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor, UnPartialDescriptor; PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL); PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
if (!m_TranslatedResourceList) /* Is there a resource list? */
if (!m_UntranslatedResourceList)
{ {
// no resource list /* No resource list provided */
return 0; return 0;
} }
PC_ASSERT(m_TranslatedResourceList->List[0].PartialResourceList.Count == m_UntranslatedResourceList->List[0].PartialResourceList.Count);
// I guess the translated and untranslated lists will be same length? for (Index = 0; Index < m_NumberOfEntries; Index ++ )
for (Index = 0; Index < m_TranslatedResourceList->List[0].PartialResourceList.Count; Index ++ )
{ {
PartialDescriptor = &m_TranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[Index];
UnPartialDescriptor = &m_UntranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[Index]; /* Get descriptor */
DPRINT("Descriptor Type %u\n", PartialDescriptor->Type); PartialDescriptor = &m_UntranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[Index];
if (PartialDescriptor->Type == Type) if (PartialDescriptor->Type == Type)
{ {
// Yay! Finally found one that matches! /* Yay! Finally found one that matches! */
Count++; Count++;
} }
if (PartialDescriptor->Type == CmResourceTypeInterrupt)
{
DPRINT("Index %u TRANS Interrupt Number Affinity %x Level %u Vector %u Flags %x Share %x\n", Index, PartialDescriptor->u.Interrupt.Affinity, PartialDescriptor->u.Interrupt.Level, PartialDescriptor->u.Interrupt.Vector, PartialDescriptor->Flags, PartialDescriptor->ShareDisposition);
DPRINT("Index %u UNTRANS Interrupt Number Affinity %x Level %u Vector %u Flags %x Share %x\\n", Index, UnPartialDescriptor->u.Interrupt.Affinity, UnPartialDescriptor->u.Interrupt.Level, UnPartialDescriptor->u.Interrupt.Vector, UnPartialDescriptor->Flags, UnPartialDescriptor->ShareDisposition);
}
else if (PartialDescriptor->Type == CmResourceTypePort)
{
DPRINT("Index %u TRANS Port Length %u Start %u %u Flags %x Share %x\n", Index, PartialDescriptor->u.Port.Length, PartialDescriptor->u.Port.Start.HighPart, PartialDescriptor->u.Port.Start.LowPart, PartialDescriptor->Flags, PartialDescriptor->ShareDisposition);
DPRINT("Index %u UNTRANS Port Length %u Start %u %u Flags %x Share %x\n", Index, UnPartialDescriptor->u.Port.Length, UnPartialDescriptor->u.Port.Start.HighPart, UnPartialDescriptor->u.Port.Start.LowPart, UnPartialDescriptor->Flags, UnPartialDescriptor->ShareDisposition);
}
} }
DPRINT("Found %d type %d\n", Count, Type); DPRINT("Found %d type %d\n", Count, Type);
@ -142,27 +141,33 @@ CResourceList::FindTranslatedEntry(
PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL); PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
/* Is there a resource list? */
if (!m_TranslatedResourceList) if (!m_TranslatedResourceList)
{ {
// no resource list /* No resource list */
return NULL; return NULL;
} }
for (DescIndex = 0; DescIndex < m_TranslatedResourceList->List[0].PartialResourceList.Count; DescIndex ++ ) for (DescIndex = 0; DescIndex < m_NumberOfEntries; DescIndex ++ )
{ {
/* Get descriptor */
PartialDescriptor = &m_TranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[DescIndex]; PartialDescriptor = &m_TranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[DescIndex];
if (PartialDescriptor->Type == Type) if (PartialDescriptor->Type == Type)
{ {
// Yay! Finally found one that matches! /* Found type, is it the requested index? */
if (Index == Count) if (Index == Count)
{ {
/* Found */
return PartialDescriptor; return PartialDescriptor;
} }
/* Need to continue search */
Count++; Count++;
} }
} }
/* No such descriptor */
return NULL; return NULL;
} }
@ -177,26 +182,34 @@ CResourceList::FindUntranslatedEntry(
PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL); PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
/* Is there a resource list? */
if (!m_UntranslatedResourceList) if (!m_UntranslatedResourceList)
{ {
// no resource list /* Empty resource list */
return NULL; return NULL;
} }
for (DescIndex = 0; DescIndex < m_UntranslatedResourceList->List[0].PartialResourceList.Count; DescIndex ++ ) /* Search descriptors */
for (DescIndex = 0; DescIndex < m_NumberOfEntries; DescIndex ++ )
{ {
/* Get descriptor */
PartialDescriptor = &m_UntranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[DescIndex]; PartialDescriptor = &m_UntranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[DescIndex];
if (PartialDescriptor->Type == Type) if (PartialDescriptor->Type == Type)
{ {
// Yay! Finally found one that matches! /* Found type, is it the requested index? */
if (Index == Count) if (Index == Count)
{ {
/* Found */
return PartialDescriptor; return PartialDescriptor;
} }
/* Need to continue search */
Count++; Count++;
} }
} }
/* No such descriptor */
return NULL; return NULL;
} }
@ -206,68 +219,37 @@ CResourceList::AddEntry(
IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Translated, IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Translated,
IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Untranslated) IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Untranslated)
{ {
PCM_RESOURCE_LIST NewUntranslatedResources, NewTranslatedResources; PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
ULONG NewTranslatedSize, NewUntranslatedSize, TranslatedSize, UntranslatedSize, ResourceCount;
/* Sanity check */
PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL); PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
// calculate translated resource list size
ResourceCount = m_TranslatedResourceList->List[0].PartialResourceList.Count;
#ifdef _MSC_VER
NewTranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount+1]);
TranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]);
#else
NewTranslatedSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount+1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
TranslatedSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
#endif
NewTranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(m_PoolType, NewTranslatedSize, TAG_PORTCLASS);
if (!NewTranslatedResources)
return STATUS_INSUFFICIENT_RESOURCES;
/* Is there still room for another entry */
// calculate untranslated resouce list size if (m_NumberOfEntries >= m_MaxEntries)
ResourceCount = m_UntranslatedResourceList->List[0].PartialResourceList.Count;
#ifdef _MSC_VER
NewUntranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount+1]);
UntranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]);
#else
NewUntranslatedSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount+1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
UntranslatedSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
#endif
// allocate untranslated resource list size
NewUntranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(m_PoolType, NewUntranslatedSize, TAG_PORTCLASS);
if (!NewUntranslatedResources)
{ {
FreeItem(NewTranslatedResources, TAG_PORTCLASS); /* No more space */
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
// now copy translated resource list /* Get free descriptor */
RtlMoveMemory(NewTranslatedResources, m_TranslatedResourceList, TranslatedSize); PartialDescriptor = &m_UntranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[m_NumberOfEntries];
RtlMoveMemory((PUCHAR)NewTranslatedResources + TranslatedSize, Translated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
// now copy untranslated resource list /* Copy descriptor */
RtlMoveMemory(NewUntranslatedResources, m_UntranslatedResourceList, UntranslatedSize); RtlCopyMemory(PartialDescriptor, Untranslated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
RtlMoveMemory((PUCHAR)NewUntranslatedResources + UntranslatedSize, Untranslated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
// free old lists /* Get free descriptor */
FreeItem(m_TranslatedResourceList, TAG_PORTCLASS); PartialDescriptor = &m_TranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[m_NumberOfEntries];
FreeItem(m_UntranslatedResourceList, TAG_PORTCLASS);
// store new lists /* Copy descriptor */
m_UntranslatedResourceList = NewUntranslatedResources; RtlCopyMemory(PartialDescriptor, Translated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
m_TranslatedResourceList = NewTranslatedResources;
// increment descriptor count /* Add entry count */
NewUntranslatedResources->List[0].PartialResourceList.Count++;
NewTranslatedResources->List[0].PartialResourceList.Count++;
// add entry count
m_NumberOfEntries++; m_NumberOfEntries++;
m_UntranslatedResourceList->List[0].PartialResourceList.Count++;
m_TranslatedResourceList->List[0].PartialResourceList.Count++;
/* Done */
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -282,16 +264,18 @@ CResourceList::AddEntryFromParent(
PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL); PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
/* Get entries from parent */
Translated = Parent->FindTranslatedEntry(Type, Index); Translated = Parent->FindTranslatedEntry(Type, Index);
Untranslated = Parent->FindUntranslatedEntry(Type, Index); Untranslated = Parent->FindUntranslatedEntry(Type, Index);
/* Are both found? */
if (Translated && Untranslated) if (Translated && Untranslated)
{ {
// add entry from parent /* Add entry from parent */
return AddEntry(Translated, Untranslated); return AddEntry(Translated, Untranslated);
} }
// entry not found /* Entry not found */
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
@ -325,99 +309,92 @@ PcNewResourceList(
IN PCM_RESOURCE_LIST UntranslatedResourceList) IN PCM_RESOURCE_LIST UntranslatedResourceList)
{ {
PCM_RESOURCE_LIST NewUntranslatedResources, NewTranslatedResources; PCM_RESOURCE_LIST NewUntranslatedResources, NewTranslatedResources;
ULONG NewTranslatedSize, NewUntranslatedSize, ResourceCount; ULONG ResourceSize, ResourceCount;
CResourceList* NewList; CResourceList* NewList;
NTSTATUS Status; NTSTATUS Status;
if (!TranslatedResourceList) if (!TranslatedResourceList)
{ {
// /* If the untranslated resource list is also not provided, it becomes an empty resource list */
// if the untranslated resource list is also not provided, it becomes an empty resource list
//
if (UntranslatedResourceList) if (UntranslatedResourceList)
{ {
// invalid parameter mix /* Invalid parameter mix */
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
} }
else else
{ {
// /* If the translated resource list is also not provided, it becomes an empty resource list */
// if the translated resource list is also not provided, it becomes an empty resource list
//
if (!UntranslatedResourceList) if (!UntranslatedResourceList)
{ {
// invalid parameter mix /* Invalid parameter mix */
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
} }
/* Allocate resource list */
NewList = new(PoolType, TAG_PORTCLASS)CResourceList(OuterUnknown); NewList = new(PoolType, TAG_PORTCLASS)CResourceList(OuterUnknown);
if (!NewList) if (!NewList)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
/* Query resource list */
Status = NewList->QueryInterface(IID_IResourceList, (PVOID*)OutResourceList); Status = NewList->QueryInterface(IID_IResourceList, (PVOID*)OutResourceList);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
// /* Ouch, FIX ME */
// Ouch, FIX ME
//
delete NewList; delete NewList;
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
/* Is there a resource list */
if (!TranslatedResourceList) if (!TranslatedResourceList)
{ {
// /* Empty resource list */
// empty resource list
//
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
// calculate translated resource list size /* Sanity check */
ResourceCount = TranslatedResourceList->List[0].PartialResourceList.Count; ASSERT(UntranslatedResourceList->List[0].PartialResourceList.Count == TranslatedResourceList->List[0].PartialResourceList.Count);
#ifdef _MSC_VER
NewTranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]);
#else
NewTranslatedSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
#endif
// store resource count /* Get resource count */
NewList->m_NumberOfEntries = ResourceCount;
// calculate untranslated resouce list size
ResourceCount = UntranslatedResourceList->List[0].PartialResourceList.Count; ResourceCount = UntranslatedResourceList->List[0].PartialResourceList.Count;
#ifdef _MSC_VER #ifdef _MSC_VER
NewUntranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]); ResourceSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]);
#else #else
NewUntranslatedSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); ResourceSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
#endif #endif
// allocate translated resource list /* Allocate translated resource list */
NewTranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(PoolType, NewTranslatedSize, TAG_PORTCLASS); NewTranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(PoolType, ResourceSize, TAG_PORTCLASS);
if (!NewTranslatedResources) if (!NewTranslatedResources)
{ {
/* No memory */
delete NewList; delete NewList;
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
// allocate untranslated resource list /* Allocate untranslated resource list */
NewUntranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(PoolType, NewUntranslatedSize, TAG_PORTCLASS); NewUntranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(PoolType, ResourceSize, TAG_PORTCLASS);
if (!NewUntranslatedResources) if (!NewUntranslatedResources)
{ {
/* No memory */
delete NewList; delete NewList;
FreeItem(NewTranslatedResources, TAG_PORTCLASS);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
// copy resource lists /* Copy resource lists */
RtlCopyMemory(NewTranslatedResources, TranslatedResourceList, NewTranslatedSize); RtlCopyMemory(NewTranslatedResources, TranslatedResourceList, ResourceSize);
RtlCopyMemory(NewUntranslatedResources, UntranslatedResourceList, NewUntranslatedSize); RtlCopyMemory(NewUntranslatedResources, UntranslatedResourceList, ResourceSize);
// store resource lists /* Init resource list */
NewList->m_TranslatedResourceList= NewTranslatedResources; NewList->m_TranslatedResourceList= NewTranslatedResources;
NewList->m_UntranslatedResourceList = NewUntranslatedResources; NewList->m_UntranslatedResourceList = NewUntranslatedResources;
NewList->m_NumberOfEntries = ResourceCount;
NewList->m_MaxEntries = ResourceCount;
NewList->m_PoolType = PoolType;
/* Done */
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -431,53 +408,60 @@ PcNewResourceSublist(
IN PRESOURCELIST ParentList, IN PRESOURCELIST ParentList,
IN ULONG MaximumEntries) IN ULONG MaximumEntries)
{ {
CResourceList* NewList, *Parent; CResourceList* NewList;
ULONG ResourceSize;
if (!OutResourceList || !ParentList || !MaximumEntries) if (!OutResourceList || !ParentList || !MaximumEntries)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
Parent = (CResourceList*)ParentList; /* Allocate new list */
if (!Parent->m_TranslatedResourceList->List[0].PartialResourceList.Count ||
!Parent->m_UntranslatedResourceList->List[0].PartialResourceList.Count)
{
// parent list can't be empty
return STATUS_INVALID_PARAMETER;
}
NewList = new(PoolType, TAG_PORTCLASS) CResourceList(OuterUnknown); NewList = new(PoolType, TAG_PORTCLASS) CResourceList(OuterUnknown);
if (!NewList) if (!NewList)
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
/* Get resource size */
#ifdef _MSC_VER
ResourceSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[MaximumEntries]);
#else
ResourceSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (MaximumEntries) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
#endif
/* Allocate resource list */
NewList->m_TranslatedResourceList = (PCM_RESOURCE_LIST)AllocateItem(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS); NewList->m_TranslatedResourceList = (PCM_RESOURCE_LIST)AllocateItem(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS);
if (!NewList->m_TranslatedResourceList) if (!NewList->m_TranslatedResourceList)
{ {
/* No memory */
delete NewList; delete NewList;
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
/* Allocate resource list */
NewList->m_UntranslatedResourceList = (PCM_RESOURCE_LIST)AllocateItem(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS); NewList->m_UntranslatedResourceList = (PCM_RESOURCE_LIST)AllocateItem(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS);
if (!NewList->m_UntranslatedResourceList) if (!NewList->m_UntranslatedResourceList)
{ {
/* No memory */
delete NewList; delete NewList;
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
RtlCopyMemory(NewList->m_TranslatedResourceList, Parent->m_TranslatedResourceList, sizeof(CM_RESOURCE_LIST)); /* Copy resource lists */
RtlCopyMemory(NewList->m_UntranslatedResourceList, Parent->m_UntranslatedResourceList, sizeof(CM_RESOURCE_LIST)); RtlCopyMemory(NewList->m_TranslatedResourceList, ParentList->TranslatedList(), sizeof(CM_RESOURCE_LIST));
RtlCopyMemory(NewList->m_UntranslatedResourceList, ParentList->UntranslatedList(), sizeof(CM_RESOURCE_LIST));
// mark list as empty /* Resource list is empty */
NewList->m_TranslatedResourceList->List[0].PartialResourceList.Count = 0;
NewList->m_UntranslatedResourceList->List[0].PartialResourceList.Count = 0; NewList->m_UntranslatedResourceList->List[0].PartialResourceList.Count = 0;
// store members NewList->m_TranslatedResourceList->List[0].PartialResourceList.Count = 0;
/* Store members */
NewList->m_OuterUnknown = OuterUnknown; NewList->m_OuterUnknown = OuterUnknown;
NewList->m_PoolType = PoolType; NewList->m_PoolType = PoolType;
NewList->m_Ref = 1; NewList->m_Ref = 1;
NewList->m_NumberOfEntries = 0; NewList->m_NumberOfEntries = 0;
NewList->m_MaxEntries = MaximumEntries;
/* Store result */
*OutResourceList = (IResourceList*)NewList; *OutResourceList = (IResourceList*)NewList;
DPRINT("PcNewResourceSublist OutResourceList %p OuterUnknown %p ParentList %p\n", *OutResourceList, OuterUnknown, ParentList); /* Done */
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }