ReactOS 0.4.16-dev-112-g52265ae
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 14 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 295 of file resource.cpp.

301{
302 PCM_RESOURCE_LIST NewUntranslatedResources, NewTranslatedResources;
303 ULONG ResourceSize, ResourceCount;
304 CResourceList* NewList;
306
307 if (!TranslatedResourceList)
308 {
309 /* If the untranslated resource list is also not provided, it becomes an empty resource list */
310 if (UntranslatedResourceList)
311 {
312 /* Invalid parameter mix */
314 }
315 }
316 else
317 {
318 /* If the translated resource list is also not provided, it becomes an empty resource list */
319 if (!UntranslatedResourceList)
320 {
321 /* Invalid parameter mix */
323 }
324 }
325
326 /* Allocate resource list */
327 NewList = new(PoolType, TAG_PORTCLASS)CResourceList(OuterUnknown);
328 if (!NewList)
330
331 /* Query resource list */
332 Status = NewList->QueryInterface(IID_IResourceList, (PVOID*)OutResourceList);
333 if (!NT_SUCCESS(Status))
334 {
335 /* Ouch, FIX ME */
336 delete NewList;
338 }
339
340 /* Is there a resource list */
341 if (!TranslatedResourceList)
342 {
343 /* Empty resource list */
344 return STATUS_SUCCESS;
345 }
346
347 /* Sanity check */
348 ASSERT(UntranslatedResourceList->List[0].PartialResourceList.Count == TranslatedResourceList->List[0].PartialResourceList.Count);
349
350 /* Get resource count */
351 ResourceCount = UntranslatedResourceList->List[0].PartialResourceList.Count;
352#ifdef _MSC_VER
353 ResourceSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors[ResourceCount]);
354#else
356#endif
357
358 /* Allocate translated resource list */
359 NewTranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(PoolType, ResourceSize, TAG_PORTCLASS);
360 if (!NewTranslatedResources)
361 {
362 /* No memory */
363 delete NewList;
365 }
366
367 /* Allocate untranslated resource list */
368 NewUntranslatedResources = (PCM_RESOURCE_LIST)AllocateItem(PoolType, ResourceSize, TAG_PORTCLASS);
369 if (!NewUntranslatedResources)
370 {
371 /* No memory */
372 delete NewList;
373 FreeItem(NewTranslatedResources, TAG_PORTCLASS);
375 }
376
377 /* Copy resource lists */
378 RtlCopyMemory(NewTranslatedResources, TranslatedResourceList, ResourceSize);
379 RtlCopyMemory(NewUntranslatedResources, UntranslatedResourceList, ResourceSize);
380
381 /* Init resource list */
382 NewList->m_TranslatedResourceList= NewTranslatedResources;
383 NewList->m_UntranslatedResourceList = NewUntranslatedResources;
385 NewList->m_MaxEntries = ResourceCount;
386 NewList->m_PoolType = PoolType;
387
388 /* Done */
389 return STATUS_SUCCESS;
390}
LONG NTSTATUS
Definition: precomp.h:26
POOL_TYPE m_PoolType
Definition: resource.cpp:37
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: resource.cpp:61
ULONG m_MaxEntries
Definition: resource.cpp:41
PCM_RESOURCE_LIST m_TranslatedResourceList
Definition: resource.cpp:38
ULONG m_NumberOfEntries
Definition: resource.cpp:40
PCM_RESOURCE_LIST m_UntranslatedResourceList
Definition: resource.cpp:39
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
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:29
VOID FreeItem(IN PVOID Item)
Definition: misc.c:37
#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 395 of file resource.cpp.

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

Referenced by AssignResources(), and ProcessResources().