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.

130 lines
3.7 KiB

  1. // Copyright (c) 1998-1999 Microsoft Corporation. All Rights Reserved.
  2. #ifndef _INC_CBITMASK
  3. #include <cwudload.h>
  4. #include <diamond.h>
  5. //used with Read method to determine what type of bitmask to retrieve.
  6. #define BITMASK_CDM_TYPE 1 //read a device driver cdm bitmask file
  7. #define BITMASK_ACTIVESETUP_TYPE 2 //read an active setup bitmask file
  8. class CBitmask
  9. {
  10. public:
  11. //create a new memory bitmask with the specified number of
  12. //masks and number of bits in each bitmask record
  13. CBitmask(
  14. int iMaxMasks, //iMaxMasks maximum number of bit masks to allocate space for
  15. int iMaxMaskBits, //iMaxMaskBits size of each individual mask in bits
  16. int iTotalOEMs, //iTotalOEMs total oem bitmask records
  17. int iTotalLangs, //iTotalLangs total locale bitmask records
  18. int iTotalPlatforms //Total number of platforms defined.
  19. );
  20. //create an empty uninitialized bitmask
  21. CBitmask();
  22. ~CBitmask();
  23. //read bitmask into memory bitmask
  24. void Read(
  25. IN CWUDownload* pDownload, //pointer to internet server download class.
  26. IN CDiamond* pDiamond, //pointer to diamond de-compression class.
  27. IN PUID puidCatalog, //PUID id of catalog where bitmask file is stored.
  28. IN int iType, //BITMASK_CDM_TYPE or BITMASK_ACTIVESETUP_TYPE
  29. IN LPCTSTR pszBaseName
  30. );
  31. //parse an in memory array that contains a bitmask into a bitmask class
  32. void Parse(
  33. IN PBYTE pBuffer, //memory buffer that contains the bitmask file
  34. IN int iMaskFileSize //file size of memory buffer file
  35. );
  36. //returns the number of bits in an individual bitmask
  37. int GetBitSize()
  38. {
  39. return m_pMask->iRecordSize;
  40. }
  41. //returns a pointer to the beginning of the bitmask id array
  42. PBITMASKID GetIDPtr()
  43. {
  44. return m_pMask->bmID;
  45. }
  46. //returns a pointer to the beginning of the bitmask array
  47. PBYTE GetBitPtr()
  48. {
  49. return m_pMask->GetBitsPtr();
  50. }
  51. //returns the beginning of a given bitmask based on its physical index.
  52. //Note: this method and the GetBitmaskPtr are the only ways to get the
  53. //global bitmask by since the global bitmask does not have a corrisponding
  54. //id
  55. PBYTE GetBitMaskPtr(
  56. IN int index //index of bitmask to retrieve
  57. )
  58. {
  59. return (m_pMask->GetBitsPtr() + ((m_pMask->iRecordSize+7)/8) * index);
  60. }
  61. //returns the state of a selected bit in a bitmask
  62. BYTE GetBit(
  63. IN int index, //index of bitmask to get bit from
  64. IN int bit //bitmask bit position to retrieve
  65. )
  66. {
  67. return GETBIT(GetBitMaskPtr(index), bit);
  68. }
  69. //This is a hack to alloc the mkinv app to write out the bitmask file this is not
  70. //needed by the client application.
  71. PBITMASK GetBITMASKPtr()
  72. {
  73. return m_pMask;
  74. }
  75. //returns a pointer to a bitmask customized for the client computer that we are running on.
  76. //Note: This bitmask only has one record. This record is the correctly anded bitmask for
  77. //OEM and LOCALE.
  78. PBYTE GetClientBits(
  79. DWORD dwOemId, // PnP ID for current machine
  80. DWORD langid //pointer to variable that receives the OS locale id
  81. );
  82. //Returns a pointer to a bitmask customized for the detected platform list.
  83. PBYTE CBitmask::GetClientBits(
  84. PDWORD pdwPlatformIdList, //Array of Platform ids.
  85. int iTotalPlatforms //Total Platform ids in previous array.
  86. );
  87. int GetMaskFileSize()
  88. {
  89. return m_iMaskFileSize;
  90. }
  91. private:
  92. PBITMASK m_pMask; //pointer to bitmask structure array
  93. int m_iTotalBitMasks; //total number of bitmasks in bitmask class
  94. int m_iMaskFileSize; //total size of bitmask file
  95. //This method performs a logical AND operation between an array of bits and a bitmask bit array.
  96. void AndBitmasks(
  97. PBYTE pBitsResult, //result array for the AND operation
  98. PBYTE pBitMask, //bitmask array to AND into the result array
  99. int iMaskByteSize //size of bitmask
  100. );
  101. };
  102. #define _INC_CBITMASK
  103. #endif