ReactOS 0.4.15-dev-5893-g1bb4167
resource.cpp File Reference
#include "private.hpp"
#include <debug.h>
Include dependency graph for resource.cpp:

Go to the source code of this file.

Classes

class  CResourceList
 

Macros

#define NDEBUG
 

Functions

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)
 
PORTCLASSAPI NTSTATUS NTAPI PcNewResourceSublist (OUT PRESOURCELIST *OutResourceList, IN PUNKNOWN OuterUnknown OPTIONAL, IN POOL_TYPE PoolType, IN PRESOURCELIST ParentList, IN ULONG MaximumEntries)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file resource.cpp.

Function Documentation

◆ PcNewResourceList()

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 300 of file resource.cpp.

306{
307 PCM_RESOURCE_LIST NewUntranslatedResources, NewTranslatedResources;
308 ULONG ResourceSize, ResourceCount;
309 CResourceList* NewList;
311
312 if (!TranslatedResourceList)
313 {
314 /* If the untranslated resource list is also not provided, it becomes an empty resource list */
315 if (UntranslatedResourceList)
316 {
317 /* Invalid parameter mix */
319 }
320 }
321 else
322 {
323 /* If the translated resource list is also not provided, it becomes an empty resource list */
324 if (!UntranslatedResourceList)
325 {
326 /* Invalid parameter mix */
328 }
329 }
330
331 /* Allocate resource list */
332 NewList = new(PoolType, TAG_PORTCLASS)CResourceList(OuterUnknown);
333 if (!NewList)
335
336 /* Query resource list */
337 Status = NewList->QueryInterface(IID_IResourceList, (PVOID*)OutResourceList);
338 if (!NT_SUCCESS(Status))
339 {
340 /* Ouch, FIX ME */
341 delete NewList;
343 }
344
345 /* Is there a resource list */
346 if (!TranslatedResourceList)
347 {
348 /* Empty resource list */
349 return STATUS_SUCCESS;
350 }
351
352 /* Sanity check */
353 ASSERT(UntranslatedResourceList->List[0].PartialResourceList.Count == TranslatedResourceList->List[0].PartialResourceList.Count);
354
355 /* Get resource count */
356 ResourceCount = UntranslatedResourceList->List[0].PartialResourceList.Count;
357#ifdef _MSC_VER
358 ResourceSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]);
359#else
361#endif
362
363 /* Allocate translated resource list */
364 NewTranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(PoolType, ResourceSize, TAG_PORTCLASS);
365 if (!NewTranslatedResources)
366 {
367 /* No memory */
368 delete NewList;
370 }
371
372 /* Allocate untranslated resource list */
373 NewUntranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(PoolType, ResourceSize, TAG_PORTCLASS);
374 if (!NewUntranslatedResources)
375 {
376 /* No memory */
377 delete NewList;
378 FreeItem(NewTranslatedResources, TAG_PORTCLASS);
380 }
381
382 /* Copy resource lists */
383 RtlCopyMemory(NewTranslatedResources, TranslatedResourceList, ResourceSize);
384 RtlCopyMemory(NewUntranslatedResources, UntranslatedResourceList, ResourceSize);
385
386 /* Init resource list */
387 NewList->m_TranslatedResourceList= NewTranslatedResources;
388 NewList->m_UntranslatedResourceList = NewUntranslatedResources;
390 NewList->m_MaxEntries = ResourceCount;
391 NewList->m_PoolType = PoolType;
392
393 /* Done */
394 return STATUS_SUCCESS;
395}
LONG NTSTATUS
Definition: precomp.h:26
POOL_TYPE m_PoolType
Definition: resource.cpp:40
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: resource.cpp:64
ULONG m_MaxEntries
Definition: resource.cpp:44
PCM_RESOURCE_LIST m_TranslatedResourceList
Definition: resource.cpp:41
ULONG m_NumberOfEntries
Definition: resource.cpp:43
PCM_RESOURCE_LIST m_UntranslatedResourceList
Definition: resource.cpp:42
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
struct _CM_RESOURCE_LIST CM_RESOURCE_LIST
struct _CM_RESOURCE_LIST * PCM_RESOURCE_LIST
static ULONG ResourceCount
Definition: inbv.c:50
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
#define ASSERT(a)
Definition: mode.c:44
#define TAG_PORTCLASS
Definition: private.hpp:24
#define STATUS_SUCCESS
Definition: shellext.h:65
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by PortClsPnp().

◆ PcNewResourceSublist()

PORTCLASSAPI NTSTATUS NTAPI PcNewResourceSublist ( OUT PRESOURCELIST OutResourceList,
IN PUNKNOWN OuterUnknown  OPTIONAL,
IN POOL_TYPE  PoolType,
IN PRESOURCELIST  ParentList,
IN ULONG  MaximumEntries 
)

Definition at line 400 of file resource.cpp.

406{
407 CResourceList* NewList;
408 ULONG ResourceSize;
409
410 if (!OutResourceList || !ParentList || !MaximumEntries)
412
413 /* Allocate new list */
414 NewList = new(PoolType, TAG_PORTCLASS) CResourceList(OuterUnknown);
415 if (!NewList)
417
418 /* Get resource size */
419#ifdef _MSC_VER
420 ResourceSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[MaximumEntries]);
421#else
422 ResourceSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (MaximumEntries) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
423#endif
424
425 /* Allocate resource list */
427 if (!NewList->m_TranslatedResourceList)
428 {
429 /* No memory */
430 delete NewList;
432 }
433
434 /* Allocate resource list */
436 if (!NewList->m_UntranslatedResourceList)
437 {
438 /* No memory */
439 delete NewList;
441 }
442
443 /* Copy resource lists */
444 RtlCopyMemory(NewList->m_TranslatedResourceList, ParentList->TranslatedList(), sizeof(CM_RESOURCE_LIST));
445 RtlCopyMemory(NewList->m_UntranslatedResourceList, ParentList->UntranslatedList(), sizeof(CM_RESOURCE_LIST));
446
447 /* Resource list is empty */
450
451 /* Store members */
452 NewList->m_OuterUnknown = OuterUnknown;
453 NewList->m_PoolType = PoolType;
454 NewList->AddRef();
455 NewList->m_NumberOfEntries = 0;
456 NewList->m_MaxEntries = MaximumEntries;
457
458 /* Store result */
459 *OutResourceList = (IResourceList*)NewList;
460
461 /* Done */
462 return STATUS_SUCCESS;
463}
PUNKNOWN m_OuterUnknown
Definition: resource.cpp:39
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
CM_FULL_RESOURCE_DESCRIPTOR List[1]
Definition: hwresource.cpp:165

Referenced by AssignResources(), and ProcessResources().