- Add back PHYSICAL_ADDRESS workarround for IDmaChannel::PhysicalAddress

- Only define guids for gcc
- Add missing PURE interface function definitions
- Silence debug spam
- Initialize ResourceList members
- Fix calculation when allocating new resources entries
- Fix building of portcls with msvc

svn path=/trunk/; revision=43044
This commit is contained in:
Johannes Anderwald 2009-09-13 22:13:48 +00:00
parent 848f926415
commit 71333f2f32
6 changed files with 144 additions and 55 deletions

View file

@ -196,11 +196,16 @@ CDmaChannelInit::MaximumBufferSize()
PHYSICAL_ADDRESS PHYSICAL_ADDRESS
NTAPI NTAPI
CDmaChannelInit::PhysicalAddress() CDmaChannelInit::PhysicalAddress(
PPHYSICAL_ADDRESS Address)
{ {
DPRINT("CDmaChannelInit_PhysicalAdress: this %p Virtuell %p Physical High %x Low %x%\n", this, m_Buffer, m_Address.HighPart, m_Address.LowPart); DPRINT("CDmaChannelInit_PhysicalAdress: this %p Virtuell %p Physical High %x Low %x%\n", this, m_Buffer, m_Address.HighPart, m_Address.LowPart);
return m_Address; PHYSICAL_ADDRESS Result;
Address->QuadPart = m_Address.QuadPart;
Result.QuadPart = (PtrToUlong(Address));
return Result;
} }
VOID VOID

View file

@ -6,9 +6,12 @@
* PROGRAMMER: Johannes Anderwald * PROGRAMMER: Johannes Anderwald
*/ */
#ifdef _MSC_VER
#define PUT_GUIDS_HERE
#endif
#include "private.hpp" #include "private.hpp"
#ifndef _MSC_VER
const GUID CLSID_PortTopology = {0xb4c90a32L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; const GUID CLSID_PortTopology = {0xb4c90a32L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
const GUID CLSID_PortMidi = {0xb4c90a43L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; const GUID CLSID_PortMidi = {0xb4c90a43L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
const GUID CLSID_PortWaveCyclic = {0xb4c90a2aL, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; const GUID CLSID_PortWaveCyclic = {0xb4c90a2aL, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}};
@ -98,3 +101,4 @@ const GUID IID_IMiniportWaveRTStreamNotification = {0x23759128, 0x96f1, 0x423b,
const GUID IID_IUnregisterSubdevice = {0x16738177, 0xe199, 0x41f9, {0x9a, 0x87, 0xab, 0xb2, 0xa5, 0x43, 0x2f, 0x21}}; const GUID IID_IUnregisterSubdevice = {0x16738177, 0xe199, 0x41f9, {0x9a, 0x87, 0xab, 0xb2, 0xa5, 0x43, 0x2f, 0x21}};
const GUID IID_IUnregisterPhysicalConnection = {0x6c38e231, 0x2a0d, 0x428d, {0x81, 0xf8, 0x07, 0xcc, 0x42, 0x8b, 0xb9, 0xa4}}; const GUID IID_IUnregisterPhysicalConnection = {0x6c38e231, 0x2a0d, 0x428d, {0x81, 0xf8, 0x07, 0xcc, 0x42, 0x8b, 0xb9, 0xa4}};
#endif

View file

@ -304,46 +304,46 @@ DECLARE_INTERFACE_(IIrpQueue, IUnknown)
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN ULONG FrameSize, IN ULONG FrameSize,
IN ULONG Alignment, IN ULONG Alignment,
IN PVOID SilenceBuffer); IN PVOID SilenceBuffer) PURE;
STDMETHOD_(NTSTATUS, AddMapping)(THIS_ STDMETHOD_(NTSTATUS, AddMapping)(THIS_
IN PUCHAR Buffer, IN PUCHAR Buffer,
IN ULONG BufferSize, IN ULONG BufferSize,
IN PIRP Irp); IN PIRP Irp) PURE;
STDMETHOD_(NTSTATUS, GetMapping)(THIS_ STDMETHOD_(NTSTATUS, GetMapping)(THIS_
OUT PUCHAR * Buffer, OUT PUCHAR * Buffer,
OUT PULONG BufferSize); OUT PULONG BufferSize) PURE;
STDMETHOD_(VOID, UpdateMapping)(THIS_ STDMETHOD_(VOID, UpdateMapping)(THIS_
IN ULONG BytesWritten); IN ULONG BytesWritten) PURE;
STDMETHOD_(ULONG, NumMappings)(THIS); STDMETHOD_(ULONG, NumMappings)(THIS) PURE;
STDMETHOD_(ULONG, NumData)(THIS); STDMETHOD_(ULONG, NumData)(THIS) PURE;
STDMETHOD_(BOOL, MinimumDataAvailable)(THIS); STDMETHOD_(BOOL, MinimumDataAvailable)(THIS) PURE;
STDMETHOD_(BOOL, CancelBuffers)(THIS); STDMETHOD_(BOOL, CancelBuffers)(THIS) PURE;
STDMETHOD_(VOID, UpdateFormat)(THIS_ STDMETHOD_(VOID, UpdateFormat)(THIS_
IN PKSDATAFORMAT DataFormat); IN PKSDATAFORMAT DataFormat) PURE;
STDMETHOD_(NTSTATUS, GetMappingWithTag)(THIS_ STDMETHOD_(NTSTATUS, GetMappingWithTag)(THIS_
IN PVOID Tag, IN PVOID Tag,
OUT PPHYSICAL_ADDRESS PhysicalAddress, OUT PPHYSICAL_ADDRESS PhysicalAddress,
OUT PVOID *VirtualAddress, OUT PVOID *VirtualAddress,
OUT PULONG ByteCount, OUT PULONG ByteCount,
OUT PULONG Flags); OUT PULONG Flags) PURE;
STDMETHOD_(NTSTATUS, ReleaseMappingWithTag)(THIS_ STDMETHOD_(NTSTATUS, ReleaseMappingWithTag)(THIS_
IN PVOID Tag); IN PVOID Tag) PURE;
STDMETHOD_(BOOL, HasLastMappingFailed)(THIS); STDMETHOD_(BOOL, HasLastMappingFailed)(THIS) PURE;
STDMETHOD_(VOID, PrintQueueStatus)(THIS); STDMETHOD_(VOID, PrintQueueStatus)(THIS) PURE;
STDMETHOD_(VOID, SetMinimumDataThreshold)(THIS_ STDMETHOD_(VOID, SetMinimumDataThreshold)(THIS_
IN ULONG MinimumDataThreshold); IN ULONG MinimumDataThreshold) PURE;
STDMETHOD_(ULONG, GetMinimumDataThreshold)(THIS); STDMETHOD_(ULONG, GetMinimumDataThreshold)(THIS) PURE;
}; };
@ -633,8 +633,8 @@ DECLARE_INTERFACE_(IPortPinWavePci, IIrpTarget)
IN KSPIN_DESCRIPTOR * PinDescriptor, IN KSPIN_DESCRIPTOR * PinDescriptor,
IN PDEVICE_OBJECT DeviceObject) PURE; IN PDEVICE_OBJECT DeviceObject) PURE;
STDMETHOD_(PVOID, GetIrpStream)(THIS); STDMETHOD_(PVOID, GetIrpStream)(THIS) PURE;
STDMETHOD_(PMINIPORT, GetMiniport)(THIS); STDMETHOD_(PMINIPORT, GetMiniport)(THIS) PURE;
}; };
#define IMP_IPortPinWavePci \ #define IMP_IPortPinWavePci \
@ -646,7 +646,7 @@ DECLARE_INTERFACE_(IPortPinWavePci, IIrpTarget)
IN KSPIN_DESCRIPTOR * PinDescriptor, \ IN KSPIN_DESCRIPTOR * PinDescriptor, \
IN PDEVICE_OBJECT DeviceObject); \ IN PDEVICE_OBJECT DeviceObject); \
\ \
STDMETHODIMP_(PVOID) GetIrpStream(THIS); \ STDMETHODIMP_(PVOID) GetIrpStream(); \
STDMETHODIMP_(PMINIPORT) GetMiniport(THIS) STDMETHODIMP_(PMINIPORT) GetMiniport(THIS)
@ -771,11 +771,11 @@ DECLARE_INTERFACE_(IPortPinWaveCyclic, IIrpTarget)
IN KSPIN_CONNECT * ConnectDetails, IN KSPIN_CONNECT * ConnectDetails,
IN KSPIN_DESCRIPTOR * PinDescriptor) PURE; IN KSPIN_DESCRIPTOR * PinDescriptor) PURE;
STDMETHOD_(ULONG, GetCompletedPosition)(THIS); STDMETHOD_(ULONG, GetCompletedPosition)(THIS) PURE;
STDMETHOD_(ULONG, GetCycleCount)(THIS); STDMETHOD_(ULONG, GetCycleCount)(THIS) PURE;
STDMETHOD_(ULONG, GetDeviceBufferSize)(THIS); STDMETHOD_(ULONG, GetDeviceBufferSize)(THIS) PURE;
STDMETHOD_(PVOID, GetIrpStream)(THIS); STDMETHOD_(PVOID, GetIrpStream)(THIS) PURE;
STDMETHOD_(PMINIPORT, GetMiniport)(THIS); STDMETHOD_(PMINIPORT, GetMiniport)(THIS) PURE;
}; };
#define IMP_IPortPinWaveCyclic \ #define IMP_IPortPinWaveCyclic \
@ -814,7 +814,7 @@ DECLARE_INTERFACE_(IPortFilterDMus, IUnknown)
STDMETHOD_(NTSTATUS, FreePin)(THIS_ STDMETHOD_(NTSTATUS, FreePin)(THIS_
IN struct IPortPinDMus* Pin)PURE; IN struct IPortPinDMus* Pin)PURE;
STDMETHOD_(VOID, NotifyPins)(THIS); STDMETHOD_(VOID, NotifyPins)(THIS) PURE;
}; };
typedef IPortFilterDMus *PPORTFILTERDMUS; typedef IPortFilterDMus *PPORTFILTERDMUS;
@ -848,7 +848,7 @@ DECLARE_INTERFACE_(IPortPinDMus, IIrpTarget)
IN KSPIN_DESCRIPTOR * PinDescriptor, IN KSPIN_DESCRIPTOR * PinDescriptor,
IN PDEVICE_OBJECT DeviceObject) PURE; IN PDEVICE_OBJECT DeviceObject) PURE;
STDMETHOD_(VOID, Notify)(THIS); STDMETHOD_(VOID, Notify)(THIS) PURE;
}; };
#define IMP_IPortPinDMus \ #define IMP_IPortPinDMus \
@ -868,13 +868,89 @@ typedef IPortPinDMus *PPORTPINDMUS;
***************************************************************************** *****************************************************************************
*/ */
#define IMP_IDmaChannelEx \
STDMETHODIMP_(NTSTATUS) AllocateBuffer( \
IN ULONG BufferSize, \
IN PPHYSICAL_ADDRESS PhysicalAddressConstraint OPTIONAL); \
\
STDMETHODIMP_(void) FreeBuffer(void); \
STDMETHODIMP_(ULONG) TransferCount(void); \
STDMETHODIMP_(ULONG) MaximumBufferSize(void); \
STDMETHODIMP_(ULONG) AllocatedBufferSize(void); \
STDMETHODIMP_(ULONG) BufferSize(void); \
\
STDMETHODIMP_(void) SetBufferSize( \
IN ULONG BufferSize); \
\
STDMETHODIMP_(PVOID) SystemAddress(void); \
STDMETHODIMP_(PHYSICAL_ADDRESS) PhysicalAddress( \
IN PPHYSICAL_ADDRESS PhysicalAddressConstraint OPTIONAL); \
STDMETHODIMP_(PADAPTER_OBJECT) GetAdapterObject(void); \
\
STDMETHODIMP_(void) CopyTo( \
IN PVOID Destination, \
IN PVOID Source, \
IN ULONG ByteCount); \
\
STDMETHODIMP_(void) CopyFrom( \
IN PVOID Destination, \
IN PVOID Source, \
IN ULONG ByteCount)
#define IMP_IDmaChannelSlaveEx \
IMP_IDmaChannelEx; \
STDMETHODIMP_(NTSTATUS) Start( \
IN ULONG MapSize, \
IN BOOLEAN WriteToDevice); \
\
STDMETHODIMP_(NTSTATUS) Stop(void); \
STDMETHODIMP_(ULONG) ReadCounter(void); \
\
STDMETHODIMP_(NTSTATUS) WaitForTC( \
ULONG Timeout)
#define IMP_IDmaChannelInit\
IMP_IDmaChannelSlaveEx;\
STDMETHODIMP_(NTSTATUS) Init( \
IN PDEVICE_DESCRIPTION DeviceDescription, \
IN PDEVICE_OBJECT DeviceObject)
#define DEFINE_ABSTRACT_DMACHANNEL_EX() \
STDMETHOD_(NTSTATUS, AllocateBuffer)( THIS_ \
IN ULONG BufferSize, \
IN PPHYSICAL_ADDRESS PhysicalAddressConstraint OPTIONAL) PURE; \
\
STDMETHOD_(void, FreeBuffer)( THIS ) PURE; \
STDMETHOD_(ULONG, TransferCount)( THIS ) PURE; \
STDMETHOD_(ULONG, MaximumBufferSize)( THIS ) PURE; \
STDMETHOD_(ULONG, AllocatedBufferSize)( THIS ) PURE; \
STDMETHOD_(ULONG, BufferSize)( THIS ) PURE; \
\
STDMETHOD_(void, SetBufferSize)( THIS_ \
IN ULONG BufferSize) PURE; \
\
STDMETHOD_(PVOID, SystemAddress)( THIS ) PURE; \
STDMETHOD_(PHYSICAL_ADDRESS, PhysicalAddress)( THIS_ \
IN PPHYSICAL_ADDRESS Address) PURE; \
STDMETHOD_(PADAPTER_OBJECT, GetAdapterObject)( THIS ) PURE; \
\
STDMETHOD_(void, CopyTo)( THIS_ \
IN PVOID Destination, \
IN PVOID Source, \
IN ULONG ByteCount) PURE; \
\
STDMETHOD_(void, CopyFrom)( THIS_ \
IN PVOID Destination, \
IN PVOID Source, \
IN ULONG ByteCount) PURE;
#undef INTERFACE #undef INTERFACE
#define INTERFACE IDmaChannelInit #define INTERFACE IDmaChannelInit
DECLARE_INTERFACE_(IDmaChannelInit, IUnknown) DECLARE_INTERFACE_(IDmaChannelInit, IUnknown)
{ {
DEFINE_ABSTRACT_UNKNOWN() DEFINE_ABSTRACT_UNKNOWN()
DEFINE_ABSTRACT_DMACHANNEL() DEFINE_ABSTRACT_DMACHANNEL_EX()
DEFINE_ABSTRACT_DMACHANNELSLAVE() DEFINE_ABSTRACT_DMACHANNELSLAVE()
STDMETHOD_(NTSTATUS, Init)( THIS_ STDMETHOD_(NTSTATUS, Init)( THIS_
@ -882,15 +958,6 @@ DECLARE_INTERFACE_(IDmaChannelInit, IUnknown)
IN PDEVICE_OBJECT DeviceObject) PURE; IN PDEVICE_OBJECT DeviceObject) PURE;
}; };
#define IMP_IDmaChannelInit\
IMP_IDmaChannelSlave;\
STDMETHODIMP_(NTSTATUS) Init( \
IN PDEVICE_DESCRIPTION DeviceDescription, \
IN PDEVICE_OBJECT DeviceObject)
#undef INTERFACE #undef INTERFACE
/***************************************************************************** /*****************************************************************************
@ -1021,7 +1088,4 @@ DECLARE_INTERFACE_(IPortWaveRTStreamInit, IUnknown)
IN ULONG Index \ IN ULONG Index \
) )
#endif #endif

View file

@ -17,6 +17,10 @@
<compilerflag compiler="cxx">-fno-rtti</compilerflag> <compilerflag compiler="cxx">-fno-rtti</compilerflag>
</group> </group>
<group compilerset="msc">
<compilerflag compiler="cxx">/GR-</compilerflag>
</group>
<file>adapter.cpp</file> <file>adapter.cpp</file>
<file>api.cpp</file> <file>api.cpp</file>
<file>connection.cpp</file> <file>connection.cpp</file>

View file

@ -12,7 +12,7 @@
#include <ntddk.h> #include <ntddk.h>
#include <portcls.h> #include <portcls.h>
#define YDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
#include <dmusicks.h> #include <dmusicks.h>

View file

@ -34,7 +34,7 @@ public:
} }
IMP_IResourceList; IMP_IResourceList;
CResourceList(IUnknown * OuterUnknown) {} CResourceList(IUnknown * OuterUnknown) : m_OuterUnknown(OuterUnknown), m_PoolType(NonPagedPool), m_TranslatedResourceList(0), m_UntranslatedResourceList(0), m_NumberOfEntries(0) {}
virtual ~CResourceList() {} virtual ~CResourceList() {}
public: public:
@ -88,7 +88,7 @@ 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; PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor, UnPartialDescriptor;
PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL); PC_ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
@ -97,17 +97,30 @@ CResourceList::NumberOfEntriesOfType(
// no resource list // no resource list
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? // I guess the translated and untranslated lists will be same length?
for (Index = 0; Index < m_TranslatedResourceList->List[0].PartialResourceList.Count; Index ++ ) for (Index = 0; Index < m_TranslatedResourceList->List[0].PartialResourceList.Count; Index ++ )
{ {
PartialDescriptor = &m_TranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[Index]; PartialDescriptor = &m_TranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[Index];
DPRINT("Descriptor Type %u\n", PartialDescriptor->Type); UnPartialDescriptor = &m_UntranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[Index];
DPRINT1("Descriptor Type %u\n", PartialDescriptor->Type);
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)
{
DPRINT1("Index %u TRANS Interrupt Number Affinity %x Level %u Vector %u\n", Index, PartialDescriptor->u.Interrupt.Affinity, PartialDescriptor->u.Interrupt.Level, PartialDescriptor->u.Interrupt.Vector, PartialDescriptor->u.Port.Start.LowPart, PartialDescriptor->Flags);
DPRINT1("Index %u UNTRANS Interrupt Number Affinity %x Level %u Vector %u\n", Index, UnPartialDescriptor->u.Interrupt.Affinity, UnPartialDescriptor->u.Interrupt.Level, UnPartialDescriptor->u.Interrupt.Vector, PartialDescriptor->u.Port.Start.LowPart, PartialDescriptor->Flags);
}
else if (PartialDescriptor->Type == CmResourceTypePort)
{
DPRINT1("Index %u TRANS Port Length %u Start %u %u Flags %x\n", Index, PartialDescriptor->u.Port.Length, PartialDescriptor->u.Port.Start.HighPart, PartialDescriptor->u.Port.Start.LowPart, PartialDescriptor->Flags);
DPRINT1("Index %u UNTRANS Port Length %u Start %u %u Flags %x\n", Index, UnPartialDescriptor->u.Port.Length, UnPartialDescriptor->u.Port.Start.HighPart, UnPartialDescriptor->u.Port.Start.LowPart, UnPartialDescriptor->Flags);
}
} }
DPRINT("Found %d type %d\n", Count, Type); DPRINT("Found %d type %d\n", Count, Type);
@ -200,9 +213,8 @@ CResourceList::AddEntry(
NewTranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount+1]); NewTranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount+1]);
TranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]); TranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]);
#else #else
NewTranslatedSize = sizeof(CM_RESOURCE_LIST) + (ResourceCount > 0 ? (ResourceCount+1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) : 0); NewTranslatedSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount+1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
TranslatedSize = sizeof(CM_RESOURCE_LIST) + (ResourceCount > 0 ? (ResourceCount) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) : 0); TranslatedSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
#endif #endif
NewTranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(m_PoolType, NewTranslatedSize, TAG_PORTCLASS); NewTranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(m_PoolType, NewTranslatedSize, TAG_PORTCLASS);
if (!NewTranslatedResources) if (!NewTranslatedResources)
@ -216,9 +228,8 @@ CResourceList::AddEntry(
NewUntranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount+1]); NewUntranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount+1]);
UntranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]); UntranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]);
#else #else
NewUntranslatedSize = sizeof(CM_RESOURCE_LIST) + (ResourceCount > 0 ? (ResourceCount+1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) : 0); NewUntranslatedSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount+1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
UntranslatedSize = sizeof(CM_RESOURCE_LIST) + (ResourceCount > 0 ? (ResourceCount) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) : 0); UntranslatedSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
#endif #endif
@ -361,7 +372,7 @@ PcNewResourceList(
#ifdef _MSC_VER #ifdef _MSC_VER
NewTranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]); NewTranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]);
#else #else
NewTranslatedSize = sizeof(CM_RESOURCE_LIST) + (ResourceCount > 0 ? (ResourceCount-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) : 0); NewTranslatedSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (ResourceCount) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
#endif #endif
// store resource count // store resource count
@ -372,7 +383,7 @@ PcNewResourceList(
#ifdef _MSC_VER #ifdef _MSC_VER
NewUntranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]); NewUntranslatedSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]);
#else #else
NewUntranslatedSize = sizeof(CM_RESOURCE_LIST) + (ResourceCount > 0 ? (ResourceCount-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) : 0); NewUntranslatedSize = 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
@ -454,6 +465,7 @@ PcNewResourceSublist(
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;
*OutResourceList = (IResourceList*)NewList; *OutResourceList = (IResourceList*)NewList;