您好,欢迎光临本网站![请登录][注册会员]  
文件名称: PETools源码
  所属分类: C++
  开发工具:
  文件大小: 94kb
  下载次数: 0
  上传时间: 2012-05-09
  提 供 者: chayan******
 详细说明: PETools 源码 // ImportTable.cpp : implementation file // #include "stdafx.h" #include "PEinfo by saga.h" #include "ImportTable.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CImportTable dialog CImportTable::CImportTable(CWnd* pParent /*=NULL*/) : CDialog(CImportTable::IDD, pParent) { //{{AFX_DATA_INIT(CImportTable) //}}AFX_DATA_INIT } void CImportTable::DoData Exchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CImportTable) DDX_Control(pDX, IDC_LIST2, m_ListCtrl2); DDX_Control(pDX, IDC_LIST1, m_ListCtrl1); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CImportTable, CDialog) //{{AFX_MSG_MAP(CImportTable) ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CImportTable message handlers BOOL CImportTable::OnInitDialog() { // TODO: Add extra initialization here CDialog::OnInitDialog(); CFile PEfile,PEfile2; WORD NumofSection; DWORD n,j,ImpRVA,ImpRaw,NameRaw; char cBuff[1024]; IMAGE_IMPORT_DESCRIPTOR ImpDescriptor; if (!PEfile.Open(CPEinfo::FilePathName.GetBuffer(CPEinfo::\ FilePathName.GetLength()),CFile::shareDenyNone)) { MessageBox("无法打开文件!"); return TRUE; } else{ PEfile.Seek(CPEinfo::DosHeader.e_lfanew,CFile::begin); PEfile.Seek(sizeof(CPEinfo::NtHeader),CFile::current); } if (!PEfile2.Open(CPEinfo::FilePathName.GetBuffer(CPEinfo::\ FilePathName.GetLength()),CFile::shareDenyNone)) { MessageBox("无法打开文件!"); return TRUE; } this->m_ListCtrl1.InsertColumn(0,"DLL Name",LVCFMT_LEFT,80); this->m_ListCtrl1.InsertColumn(1,"OriginalFirstThunk",LVCFMT_LEFT,98); this->m_ListCtrl1.InsertColumn(2,"TimeDateStamp",LVCFMT_LEFT,94); this->m_ListCtrl1.InsertColumn(3,"ForwarderChain",LVCFMT_LEFT,94); this->m_ListCtrl1.InsertColumn(4,"Name",LVCFMT_LEFT,90); this->m_ListCtrl1.InsertColumn(5,"FirstThunk",LVCFMT_LEFT,94); this->m_ListCtrl1.SetExtendedStyle(LVS_EX_FULLROWSELECT); this->m_ListCtrl2.InsertColumn(0,"ThunkRVA",LVCFMT_LEFT,90); this->m_ListCtrl2.InsertColumn(1,"ThunkValue",LVCFMT_LEFT,90); this->m_ListCtrl2.InsertColumn(2,"Hint",LVCFMT_LEFT,50); this->m_ListCtrl2.InsertColumn(3,"Function Name",LVCFMT_LEFT,300); this->m_ListCtrl2.SetExtendedStyle(LVS_EX_FULLROWSELECT); NumofSection=CPEinfo::NtHeader.FileHeader.NumberOfSections; ImpRVA=CPEinfo::NtHeader.OptionalHeader.DataDirectory[1].VirtualAddress; for(n=NumofSection;n>0;n--){ PEfile.Read(&CPEinfo;::SecHeader,sizeof(CPEinfo::SecHeader)); if (ImpRVA<(CPEinfo::SecHeader.VirtualAddress+\ CPEinfo::SecHeader.Misc.VirtualSize)) { ImpRaw=ImpRVA-CPEinfo::SecHeader.VirtualAddress\ +CPEinfo::SecHeader.PointerToRawData; break; } } PEfile.Seek(ImpRaw,CFile::begin); n=0; while (TRUE) { PEfile.Read(&ImpDescriptor;,20); if (ImpDescriptor.Name==NULL) { break; } else { NameRaw=ImpDescriptor.Name-ImpRVA+ImpRaw; PEfile2.Seek(NameRaw,CFile::begin); for(j=0;j<1024;j++){ PEfile2.Read(&cBuff;[j],1); if (cBuff[j]==NULL) { break; } } this->m_ListCtrl1.InsertItem(n,cBuff); wsprintf(cBuff,"lX",ImpDescriptor.OriginalFirstThunk); this->m_ListCtrl1.SetItemText(n,1,cBuff); wsprintf(cBuff,"lX",ImpDescriptor.TimeDateStamp); this->m_ListCtrl1.SetItemText(n,2,cBuff); wsprintf(cBuff,"lX",ImpDescriptor.ForwarderChain); this->m_ListCtrl1.SetItemText(n,3,cBuff); wsprintf(cBuff,"lX",ImpDescriptor.Name); this->m_ListCtrl1.SetItemText(n,4,cBuff); wsprintf(cBuff,"lX",ImpDescriptor.FirstThunk); this->m_ListCtrl1.SetItemText(n,5,cBuff); n++; } } PEfile.Close(); PEfile2.Close(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CImportTable::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here POSITION SelectItemNum; char cBuff[1024]; CFile PEfile,PEfile2; DWORD n,j,ImpRVA,ImpRaw,IATRaw,NameRaw; WORD NumofSection,Hint; IMAGE_IMPORT_DESCRIPTOR ImpDescriptor; IMAGE_THUNK_DATA ThunkData; if (!PEfile.Open(CPEinfo::FilePathName.GetBuffer(CPEinfo::\ FilePathName.GetLength()),CFile::shareDenyNone)) { MessageBox("无法打开文件!"); return; } else{ PEfile.Seek(CPEinfo::DosHeader.e_lfanew,CFile::begin); PEfile.Seek(sizeof(CPEinfo::NtHeader),CFile::current); } if (!PEfile2.Open(CPEinfo::FilePathName.GetBuffer(CPEinfo::\ FilePathName.GetLength()),CFile::shareDenyNone)) { MessageBox("无法打开文件!"); return; } NumofSection=CPEinfo::NtHeader.FileHeader.NumberOfSections; ImpRVA=CPEinfo::NtHeader.OptionalHeader.DataDirectory[1].VirtualAddress; for(n=NumofSection;n>0;n--){ PEfile.Read(&CPEinfo;::SecHeader,sizeof(CPEinfo::SecHeader)); if (ImpRVA<(CPEinfo::SecHeader.VirtualAddress+CPEinfo::SecHeader.Misc.VirtualSize)) { ImpRaw=ImpRVA-CPEinfo::SecHeader.VirtualAddress +CPEinfo::SecHeader.PointerToRawData; break; } } PEfile.Seek(ImpRaw,CFile::begin); if ((SelectItemNum=this->m_ListCtrl1.GetFirstSelectedItemPosition())==NULL) { return; } this->m_ListCtrl2.DeleteAllItems(); j=DWORD(SelectItemNum); for(n=0;nm_ListCtrl2.InsertItem(n,cBuff); wsprintf(cBuff,"lX",ThunkData); this->m_ListCtrl2.SetItemText(n,1,cBuff); if (((DWORD)ThunkData.u1.AddressOfData&0x80000000;)==0x80000000) { this->m_ListCtrl2.SetItemText(n,2,"--"); this->m_ListCtrl2.SetItemText(n,3,"--"); } else{ NameRaw=(DWORD)ThunkData.u1.AddressOfData-ImpRVA+ImpRaw; PEfile2.Seek(NameRaw,CFile::begin); PEfile2.Read(&Hint;,2); wsprintf(cBuff,"lX",Hint); this->m_ListCtrl2.SetItemText(n,2,cBuff); for(j=0;j<1024;j++){ PEfile2.Read(&cBuff;[j],1); if (cBuff[j]==NULL) { break; } } this->m_ListCtrl2.SetItemText(n,3,cBuff); } ImpDescriptor.FirstThunk+=4; n++; } PEfile.Close(); PEfile2.Close(); *pResult = 0; } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: PETools 源码
 输入关键字,在本站1000多万海量源码库中尽情搜索: