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

📄 sectiondlg.cpp

📁 此为本书的配套光盘.本书不但由浅入深地讲解了软件保护技术
💻 CPP
字号:
/********************************************************************

	Copyright (c) Beijing Feitian Technologies
	http://www.FTSafe.com

	File :		SectionDlg.cpp	

	Created:	2003/11/04

	Author:		yihai
	
	Purpose:	?

	Revision:	?

*********************************************************************/

// SectionDlg.cpp : implementation file
//

#include "stdafx.h"
#include "PEViewer.h"
#include "SectionDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSectionDlg dialog


CSectionDlg::CSectionDlg(CPEImageFile& peFile,CWnd* pParent /*=NULL*/)
	: CDialog(CSectionDlg::IDD, pParent),m_peFile(peFile),m_iSecIndex(0)
{
	//{{AFX_DATA_INIT(CSectionDlg)
	m_strName = _T("");
	m_strPhysicalAddressOrVirtualSize = _T("");
	m_strVirtualAddress = _T("");
	m_strSizeOfRawData = _T("");
	m_strPointerToRawData = _T("");
	m_strPointerToRelocations = _T("");
	m_strPointerToLinenumbers = _T("");
	m_strNumberOfRelocations = _T("");
	m_strNumberOfLinenumbers = _T("");
	m_strCharacteristics = _T("");
	m_strCurSection = _T("");
	m_strTotalSections = _T("");
	//}}AFX_DATA_INIT
}


void CSectionDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSectionDlg)
	DDX_Text(pDX, IDC_SEC_NAME, m_strName);
	DDX_Text(pDX, IDC_PHYADDR_VIRSIZE, m_strPhysicalAddressOrVirtualSize);
	DDX_Text(pDX, IDC_SEC_VIRADDR, m_strVirtualAddress);
	DDX_Text(pDX, IDC_SEC_SIZEOFRAWDATA, m_strSizeOfRawData);
	DDX_Text(pDX, IDC_SEC_PRAWDATA, m_strPointerToRawData);
	DDX_Text(pDX, IDC_SEC_PRELOC, m_strPointerToRelocations);
	DDX_Text(pDX, IDC_SEC_PLINENUM, m_strPointerToLinenumbers);
	DDX_Text(pDX, IDC_SEC_NUM_RELOC, m_strNumberOfRelocations);
	DDX_Text(pDX, IDC_SEC_NUM_LINENUM, m_strNumberOfLinenumbers);
	DDX_Text(pDX, IDC_SEC_CHARACTER, m_strCharacteristics);
	DDX_Text(pDX, IDC_STC_CUR_SEC, m_strCurSection);
	DDX_Text(pDX, IDC_STC_TOTAL_SECS, m_strTotalSections);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSectionDlg, CDialog)
	//{{AFX_MSG_MAP(CSectionDlg)
	ON_BN_CLICKED(IDC_SEC_PREV, OnSecPrev)
	ON_BN_CLICKED(IDC_SEC_NEXT, OnSecNext)
	ON_BN_CLICKED(IDC_SEC_UPDATE, OnSecUpdate)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSectionDlg message handlers

BOOL CSectionDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_pImgSection = m_peFile.m_pFirstSection;

	m_iSecIndex = 0;
	UpdateUI();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSectionDlg::UpdateCTX()
{
	if(IsWindow(GetSafeHwnd()))
		UpdateData();

	if(m_pImgSection)
	{
		lstrcpyn((char *)m_pImgSection[m_iSecIndex].Name,m_strName,8);
		m_pImgSection[m_iSecIndex].Misc.VirtualSize       = StrToHex(m_strPhysicalAddressOrVirtualSize );
		m_pImgSection[m_iSecIndex].VirtualAddress         = StrToHex(m_strVirtualAddress               );
		m_pImgSection[m_iSecIndex].SizeOfRawData          = StrToHex(m_strSizeOfRawData                );
		m_pImgSection[m_iSecIndex].PointerToRawData       = StrToHex(m_strPointerToRawData             );
		m_pImgSection[m_iSecIndex].PointerToRelocations   = StrToHex(m_strPointerToRelocations         );
		m_pImgSection[m_iSecIndex].PointerToLinenumbers   = StrToHex(m_strPointerToLinenumbers         );
		m_pImgSection[m_iSecIndex].NumberOfRelocations    = StrToHex(m_strNumberOfRelocations          );
		m_pImgSection[m_iSecIndex].NumberOfLinenumbers    = StrToHex(m_strNumberOfLinenumbers          );
		m_pImgSection[m_iSecIndex].Characteristics        = StrToHex(m_strCharacteristics              );
	}
}

void CSectionDlg::OnSecPrev() 
{
	if(m_iSecIndex != 0)
		m_iSecIndex --;
	UpdateUI();
}

void CSectionDlg::OnSecNext() 
{
	if(m_iSecIndex != m_peFile.GetSectionCount() -1)
		m_iSecIndex ++;	
	UpdateUI();
}

void CSectionDlg::OnSecUpdate() 
{
	UpdateCTX();	
}

void CSectionDlg::UpdateUI()
{
	if(m_pImgSection)
	{
		m_strTotalSections.Format("%d",m_peFile.GetSectionCount());
		m_strCurSection.Format("%d",m_iSecIndex+1);
		m_strName.Format("%.8s",m_pImgSection[m_iSecIndex].Name);
		m_strPhysicalAddressOrVirtualSize  .Format("%X",  m_pImgSection[m_iSecIndex].Misc.VirtualSize		      );
		m_strVirtualAddress                .Format("%X",  m_pImgSection[m_iSecIndex].VirtualAddress               );
		m_strSizeOfRawData                 .Format("%X",  m_pImgSection[m_iSecIndex].SizeOfRawData                );
		m_strPointerToRawData              .Format("%X",  m_pImgSection[m_iSecIndex].PointerToRawData             );
		m_strPointerToRelocations          .Format("%X",  m_pImgSection[m_iSecIndex].PointerToRelocations         );
		m_strPointerToLinenumbers          .Format("%X",  m_pImgSection[m_iSecIndex].PointerToLinenumbers         );
		m_strNumberOfRelocations           .Format("%X",  m_pImgSection[m_iSecIndex].NumberOfRelocations          );
		m_strNumberOfLinenumbers           .Format("%X",  m_pImgSection[m_iSecIndex].NumberOfLinenumbers          );
		m_strCharacteristics               .Format("%X",  m_pImgSection[m_iSecIndex].Characteristics              );
		UpdateData(FALSE);
	}	
}

⌨️ 快捷键说明

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