当前位置: 首页>>代码示例>>C++>>正文


C++ Section::getIdentifier方法代码示例

本文整理汇总了C++中Section::getIdentifier方法的典型用法代码示例。如果您正苦于以下问题:C++ Section::getIdentifier方法的具体用法?C++ Section::getIdentifier怎么用?C++ Section::getIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Section的用法示例。


在下文中一共展示了Section::getIdentifier方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: prepareImageHeader

void EncoreBootImage::prepareImageHeader(boot_image_header_t & header)
{
	// get identifier for the first bootable section
	Section * firstBootSection = findFirstBootableSection();
	section_id_t firstBootSectionID = 0;
	if (firstBootSection)
	{
		firstBootSectionID = firstBootSection->getIdentifier();
	}
	
	// fill in header fields
	header.m_signature[0] = 'S';
	header.m_signature[1] = 'T';
	header.m_signature[2] = 'M';
	header.m_signature[3] = 'P';
	header.m_majorVersion = ROM_BOOT_IMAGE_MAJOR_VERSION;
	header.m_minorVersion = ROM_BOOT_IMAGE_MINOR_VERSION;
	header.m_flags = ENDIAN_HOST_TO_LITTLE_U16(m_headerFlags);
	header.m_imageBlocks = ENDIAN_HOST_TO_LITTLE_U32(getImageSize());
	header.m_firstBootableSectionID = ENDIAN_HOST_TO_LITTLE_U32(firstBootSectionID);
	header.m_keyCount = ENDIAN_HOST_TO_LITTLE_U16((uint16_t)m_keys.size());
	header.m_headerBlocks = ENDIAN_HOST_TO_LITTLE_U16((uint16_t)numberOfCipherBlocks(sizeof(header)));
	header.m_sectionCount = ENDIAN_HOST_TO_LITTLE_U16((uint16_t)m_sections.size());
	header.m_sectionHeaderSize = ENDIAN_HOST_TO_LITTLE_U16((uint16_t)numberOfCipherBlocks(sizeof(section_header_t)));
	header.m_signature2[0] = 's';
	header.m_signature2[1] = 'g';
	header.m_signature2[2] = 't';
	header.m_signature2[3] = 'l';
	header.m_timestamp = ENDIAN_HOST_TO_LITTLE_U64(getTimestamp());
	header.m_driveTag = m_driveTag;

	// Prepare version fields by converting them to the correct byte order.
	header.m_productVersion = m_productVersion;
	header.m_componentVersion = m_componentVersion;
	header.m_productVersion.fixByteOrder();
	header.m_componentVersion.fixByteOrder();

	// the fields are dependant on others
	header.m_keyDictionaryBlock = ENDIAN_HOST_TO_LITTLE_U16(header.m_headerBlocks + header.m_sectionCount * header.m_sectionHeaderSize);
	header.m_firstBootTagBlock = ENDIAN_HOST_TO_LITTLE_U32(header.m_keyDictionaryBlock + header.m_keyCount * 2);
	
	// generate random pad bytes
	RandomNumberGenerator rng;
	rng.generateBlock(header.m_padding0, sizeof(header.m_padding0));
	rng.generateBlock(header.m_padding1, sizeof(header.m_padding1));
	
	// compute SHA-1 digest over the image header
	uint8_t * message = reinterpret_cast<uint8_t *>(&header.m_signature);
	uint32_t length = static_cast<uint32_t>(sizeof(header) - sizeof(header.m_digest)); // include padding
	
	CSHA1 hash;
	hash.Reset();
	hash.Update(message, length);
	hash.Final();
	hash.GetHash(header.m_digest);
}
开发者ID:IIJ-NetBSD,项目名称:netbsd-src,代码行数:56,代码来源:EncoreBootImage.cpp

示例2:

//! The identifier, length, and flags fields are taken from \a section.
//!
//! \todo How does length get set correctly if the length is supposed to include
//!		this command?
EncoreBootImage::TagCommand::TagCommand(const Section & section)
{
	m_sectionIdentifier = section.getIdentifier();
	m_sectionLength = section.getBlockCount();
	m_sectionFlags = section.getFlags();
}
开发者ID:IIJ-NetBSD,项目名称:netbsd-src,代码行数:10,代码来源:EncoreBootImage.cpp


注:本文中的Section::getIdentifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。