⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tt.cpp

📁 WinCE5.0部分核心源码
💻 CPP
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// This source code is licensed under Microsoft Shared Source License
// Version 1.0 for Windows CE.
// For a copy of the license visit http://go.microsoft.com/fwlink/?LinkId=3223.
//
// translation table
// tt.cpp
#include "diffbin.h"


CTranslationTable::CTranslationTable(): m_cEntries(0), m_pte(NULL)
/*---------------------------------------------------------------------------*\
 * Create the translation table
\*---------------------------------------------------------------------------*/
{

} /* CTranslationTable::CTranslationTable()
   */

CTranslationTable::~CTranslationTable()
/*---------------------------------------------------------------------------*\
 *
\*---------------------------------------------------------------------------*/
{
    LocalFree(m_pte);

} /* CTranslationTable::~CTranslationTable()
   */

HRESULT
CTranslationTable::Insert(UINT32 iPacked, ADDRESS iUnpacked)
/*---------------------------------------------------------------------------*\
 *   Insert a new translation from offset "iPacked" in the
 *   image to address "iUnpacked" in the destination memory
\*---------------------------------------------------------------------------*/
{
    HRESULT         hr       = NOERROR;

    if (m_cEntries % TT_ENTRIES == 0) {
        CHR(SafeRealloc((LPVOID*)&m_pte, (m_cEntries + TT_ENTRIES) * sizeof(TranslationEntry)));
    }
	m_pte[m_cEntries].iPacked = iPacked;
	m_pte[m_cEntries].iUnpacked = iUnpacked;
	m_cEntries++;

Error:
    return hr;

} /* CTranslationTable::Insert()
   */

ADDRESS 
CTranslationTable::Lookup(UINT32 iPacked)
/*---------------------------------------------------------------------------*\
 *   Get the address in the destination memory that
 *   corresponds to offset "iPacked" in the image file
\*---------------------------------------------------------------------------*/
{
	UINT32 iEntry = 0;
	while (iEntry < m_cEntries)
	{
		if (iPacked < m_pte[iEntry].iPacked)
			return AddAddress(m_pte[iEntry - 1].iUnpacked, iPacked - m_pte[iEntry - 1].iPacked);
		++iEntry;
	}
	return AddAddress(m_pte[m_cEntries - 1].iUnpacked, iPacked - m_pte[m_cEntries - 1].iPacked);

} /* CTranslationTable::Lookup()
   */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -