Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. regresls.cxx
  5. Abstract:
  6. This module contains the definitions of the member functions
  7. of RESOURCE_LIST class.
  8. Author:
  9. Jaime Sasson (jaimes) 02-Dec-1993
  10. Environment:
  11. ULIB, User Mode
  12. --*/
  13. #include "regresls.hxx"
  14. #include "iterator.hxx"
  15. #include "regdesc.hxx"
  16. #include "regfdesc.hxx"
  17. DEFINE_CONSTRUCTOR ( RESOURCE_LIST, OBJECT );
  18. RESOURCE_LIST::~RESOURCE_LIST (
  19. )
  20. /*++
  21. Routine Description:
  22. Destroy a RESOURCE_LIST.
  23. Arguments:
  24. None.
  25. Return Value:
  26. None.
  27. --*/
  28. {
  29. Destroy();
  30. }
  31. VOID
  32. RESOURCE_LIST::Construct (
  33. )
  34. /*++
  35. Routine Description:
  36. Construct a RESOURCE_LIST object.
  37. Arguments:
  38. None.
  39. Return Value:
  40. None.
  41. --*/
  42. {
  43. _FullResourceDescriptors = NULL;
  44. }
  45. VOID
  46. RESOURCE_LIST::Destroy (
  47. )
  48. /*++
  49. Routine Description:
  50. Worker method for object destruction.
  51. Arguments:
  52. None.
  53. Return Value:
  54. None.
  55. --*/
  56. {
  57. if( _FullResourceDescriptors != NULL ) {
  58. _FullResourceDescriptors->DeleteAllMembers();
  59. DELETE( _FullResourceDescriptors );
  60. }
  61. _FullResourceDescriptors = NULL;
  62. }
  63. BOOLEAN
  64. RESOURCE_LIST::Initialize(
  65. IN PCBYTE Data,
  66. IN ULONG Size
  67. )
  68. /*++
  69. Routine Description:
  70. Initialize an object of type RESOURCE_LIST.
  71. Arguments:
  72. Data - Pointer to a buffer that contains a CM_RESOURCE_LIST.
  73. Size - Buffer size.
  74. Return Value:
  75. BOOLEAN - Returns TRUE if the initialization succeeds.
  76. --*/
  77. {
  78. PCM_FULL_RESOURCE_DESCRIPTOR FullResource;
  79. ULONG Count;
  80. ULONG i;
  81. PARRAY TmpList;
  82. ULONG BufferSize;
  83. ULONG FullDescriptorSize;
  84. if( Data == NULL ) {
  85. return( FALSE );
  86. }
  87. Count = ( ( PCM_RESOURCE_LIST )Data )->Count;
  88. FullResource = ( ( PCM_RESOURCE_LIST )Data )->List;
  89. TmpList = ( PARRAY )NEW( ARRAY );
  90. DebugPtrAssert( TmpList );
  91. if( ( TmpList == NULL ) ||
  92. ( !TmpList->Initialize() ) ) {
  93. DebugPrintTrace(("REGEDT32: Out of memory" ));
  94. DELETE( TmpList );
  95. return( FALSE );
  96. }
  97. //
  98. // For each CM_FULL_RESOURCE DESCRIPTOR in the current value...
  99. //
  100. BufferSize = Size - // Data size
  101. sizeof( ULONG ); // Count
  102. for( i = 0; i < Count; i++ ) {
  103. PFULL_DESCRIPTOR FullResourceDescriptor;
  104. FullResourceDescriptor = ( PFULL_DESCRIPTOR )NEW( FULL_DESCRIPTOR );
  105. if( ( FullResourceDescriptor == NULL ) ||
  106. !FullResourceDescriptor->Initialize( ( PCBYTE )FullResource,
  107. BufferSize,
  108. &FullDescriptorSize )
  109. ) {
  110. DebugPrint( "REGEDT32: Unable to create or initialize FullResourcedescriptor \n" );
  111. DELETE( FullResourceDescriptor );
  112. TmpList->DeleteAllMembers();
  113. DELETE( TmpList );
  114. return( FALSE );
  115. }
  116. TmpList->Put( FullResourceDescriptor );
  117. FullResource = ( PCM_FULL_RESOURCE_DESCRIPTOR )( ( ULONG_PTR )FullResource + FullDescriptorSize );
  118. BufferSize -= FullDescriptorSize;
  119. }
  120. _FullResourceDescriptors = TmpList;
  121. return( TRUE );
  122. }