ReactOS  0.4.14-dev-98-gb0d4763
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 310 of file resource.cpp.

316 {
317  PCM_RESOURCE_LIST NewUntranslatedResources, NewTranslatedResources;
318  ULONG ResourceSize, ResourceCount;
319  CResourceList* NewList;
321 
322  if (!TranslatedResourceList)
323  {
324  /* If the untranslated resource list is also not provided, it becomes an empty resource list */
325  if (UntranslatedResourceList)
326  {
327  /* Invalid parameter mix */
329  }
330  }
331  else
332  {
333  /* If the translated resource list is also not provided, it becomes an empty resource list */
334  if (!UntranslatedResourceList)
335  {
336  /* Invalid parameter mix */
338  }
339  }
340 
341  /* Allocate resource list */
342  NewList = new(PoolType, TAG_PORTCLASS)CResourceList(OuterUnknown);
343  if (!NewList)
345 
346  /* Query resource list */
347  Status = NewList->QueryInterface(IID_IResourceList, (PVOID*)OutResourceList);
348  if (!NT_SUCCESS(Status))
349  {
350  /* Ouch, FIX ME */
351  delete NewList;
353  }
354 
355  /* Is there a resource list */
356  if (!TranslatedResourceList)
357  {
358  /* Empty resource list */
359  return STATUS_SUCCESS;
360  }
361 
362  /* Sanity check */
363  ASSERT(UntranslatedResourceList->List[0].PartialResourceList.Count == TranslatedResourceList->List[0].PartialResourceList.Count);
364 
365  /* Get resource count */
366  ResourceCount = UntranslatedResourceList->List[0].PartialResourceList.Count;
367 #ifdef _MSC_VER
368  ResourceSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]);
369 #else
371 #endif
372 
373  /* Allocate translated resource list */
374  NewTranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(PoolType, ResourceSize, TAG_PORTCLASS);
375  if (!NewTranslatedResources)
376  {
377  /* No memory */
378  delete NewList;
380  }
381 
382  /* Allocate untranslated resource list */
383  NewUntranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(PoolType, ResourceSize, TAG_PORTCLASS);
384  if (!NewUntranslatedResources)
385  {
386  /* No memory */
387  delete NewList;
388  FreeItem(NewTranslatedResources, TAG_PORTCLASS);
390  }
391 
392  /* Copy resource lists */
393  RtlCopyMemory(NewTranslatedResources, TranslatedResourceList, ResourceSize);
394  RtlCopyMemory(NewUntranslatedResources, UntranslatedResourceList, ResourceSize);
395 
396  /* Init resource list */
397  NewList->m_TranslatedResourceList= NewTranslatedResources;
398  NewList->m_UntranslatedResourceList = NewUntranslatedResources;
399  NewList->m_NumberOfEntries = ResourceCount;
400  NewList->m_MaxEntries = ResourceCount;
401  NewList->m_PoolType = PoolType;
402 
403  /* Done */
404  return STATUS_SUCCESS;
405 }
struct _CM_RESOURCE_LIST * PCM_RESOURCE_LIST
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TAG_PORTCLASS
Definition: private.hpp:24
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
ULONG m_NumberOfEntries
Definition: resource.cpp:52
LONG NTSTATUS
Definition: precomp.h:26
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
PCM_RESOURCE_LIST m_UntranslatedResourceList
Definition: resource.cpp:51
LIST_ENTRY List
Definition: psmgr.c:57
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static ULONG ResourceCount
Definition: inbv.c:95
ULONG m_MaxEntries
Definition: resource.cpp:53
struct _CM_RESOURCE_LIST CM_RESOURCE_LIST
Status
Definition: gdiplustypes.h:24
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: resource.cpp:74
POOL_TYPE m_PoolType
Definition: resource.cpp:49
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
PCM_RESOURCE_LIST m_TranslatedResourceList
Definition: resource.cpp:50
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444

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

416 {
417  CResourceList* NewList;
418  ULONG ResourceSize;
419 
420  if (!OutResourceList || !ParentList || !MaximumEntries)
422 
423  /* Allocate new list */
424  NewList = new(PoolType, TAG_PORTCLASS) CResourceList(OuterUnknown);
425  if (!NewList)
427 
428  /* Get resource size */
429 #ifdef _MSC_VER
430  ResourceSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[MaximumEntries]);
431 #else
432  ResourceSize = sizeof(CM_RESOURCE_LIST) - sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + (MaximumEntries) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
433 #endif
434 
435  /* Allocate resource list */
437  if (!NewList->m_TranslatedResourceList)
438  {
439  /* No memory */
440  delete NewList;
442  }
443 
444  /* Allocate resource list */
446  if (!NewList->m_UntranslatedResourceList)
447  {
448  /* No memory */
449  delete NewList;
451  }
452 
453  /* Copy resource lists */
454  RtlCopyMemory(NewList->m_TranslatedResourceList, ParentList->TranslatedList(), sizeof(CM_RESOURCE_LIST));
455  RtlCopyMemory(NewList->m_UntranslatedResourceList, ParentList->UntranslatedList(), sizeof(CM_RESOURCE_LIST));
456 
457  /* Resource list is empty */
460 
461  /* Store members */
462  NewList->m_OuterUnknown = OuterUnknown;
463  NewList->m_PoolType = PoolType;
464  NewList->m_Ref = 1;
465  NewList->m_NumberOfEntries = 0;
466  NewList->m_MaxEntries = MaximumEntries;
467 
468  /* Store result */
469  *OutResourceList = (IResourceList*)NewList;
470 
471  /* Done */
472  return STATUS_SUCCESS;
473 }
struct _CM_RESOURCE_LIST * PCM_RESOURCE_LIST
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
CM_FULL_RESOURCE_DESCRIPTOR List[1]
Definition: hwresource.cpp:165
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TAG_PORTCLASS
Definition: private.hpp:24
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
ULONG m_NumberOfEntries
Definition: resource.cpp:52
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
PCM_RESOURCE_LIST m_UntranslatedResourceList
Definition: resource.cpp:51
LIST_ENTRY List
Definition: psmgr.c:57
PUNKNOWN m_OuterUnknown
Definition: resource.cpp:48
ULONG m_MaxEntries
Definition: resource.cpp:53
struct _CM_RESOURCE_LIST CM_RESOURCE_LIST
POOL_TYPE m_PoolType
Definition: resource.cpp:49
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
PCM_RESOURCE_LIST m_TranslatedResourceList
Definition: resource.cpp:50
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444

Referenced by AssignResources(), and ProcessResources().