DlgSections.cpp
资源名称:Skinload.rar [点击查看]
上传用户:tjjuxin
上传日期:2021-06-01
资源大小:3552k
文件大小:3k
源码类别:
Shell编程
开发平台:
Visual C++
- // DlgSections.cpp : implementation file
- //
- #include "stdafx.h"
- #include "SkiиArt.h"
- #include "DlgSections.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDlgSections dialog
- CDlgSections::CDlgSections(CWnd* pParent /*=NULL*/, char *pImage)
- : CDialog(CDlgSections::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDlgSections)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_pImage = pImage;
- }
- void CDlgSections::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDlgSections)
- DDX_Control(pDX, IDC_LIST1, m_list);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDlgSections, CDialog)
- //{{AFX_MSG_MAP(CDlgSections)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDlgSections message handlers
- BOOL CDlgSections::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- m_list.InsertColumn(0, "名称", LVCFMT_LEFT, 80);
- m_list.InsertColumn(1, "VOffset", LVCFMT_LEFT, 80);
- m_list.InsertColumn(2, "VSize", LVCFMT_LEFT, 80);
- m_list.InsertColumn(3, "Roffset", LVCFMT_LEFT, 80);
- m_list.InsertColumn(4, "RSize", LVCFMT_LEFT, 80);
- m_list.InsertColumn(5, "属性标志", LVCFMT_LEFT, 80);
- m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT);
- GetSections(m_pImage);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CDlgSections::GetSections(char *pImage)
- {
- PIMAGE_DOS_HEADER pDos = PIMAGE_DOS_HEADER (pImage);
- PIMAGE_NT_HEADERS pNtHeaders = (PIMAGE_NT_HEADERS )(pImage + pDos->e_lfanew);
- UINT uSectionCount = pNtHeaders->FileHeader.NumberOfSections;
- PIMAGE_SECTION_HEADER pFirstSection = (PIMAGE_SECTION_HEADER )(pNtHeaders->FileHeader.SizeOfOptionalHeader + (DWORD)pNtHeaders + sizeof(IMAGE_FILE_HEADER) + sizeof(pNtHeaders->Signature));
- char szTemp[100] = {0};
- unsigned char *pTemp = NULL;
- for (UINT i=0; i<uSectionCount; i++)
- {
- //set section name
- memcpy(szTemp, pFirstSection->Name, 8);
- if (strlen(szTemp) == 0)
- {
- memcpy(szTemp, "No Name ", 8);
- }
- int iListCount = m_list.GetItemCount();
- m_list.InsertItem(iListCount, szTemp);
- //set address
- sprintf(szTemp, "0x%.8X", pFirstSection->VirtualAddress);
- m_list.SetItemText(iListCount, 1, szTemp);
- sprintf(szTemp, "0x%.8X", pFirstSection->Misc.VirtualSize);
- m_list.SetItemText(iListCount, 2, szTemp);
- sprintf(szTemp, "0x%.8X", pFirstSection->PointerToRawData);
- m_list.SetItemText(iListCount, 3, szTemp);
- sprintf(szTemp, "0x%.8X", pFirstSection->SizeOfRawData);
- m_list.SetItemText(iListCount, 4, szTemp);
- sprintf(szTemp, "0x%.8X", pFirstSection->Characteristics);
- m_list.SetItemText(iListCount, 5, szTemp);
- pFirstSection++;
- }
- }