VC遍历dll导出函数
来源:互联网 发布:ui设计需要编程吗 编辑:程序博客网 时间:2024/05/22 12:47
参考文章:http://www.ccrun.com/article.asp?i=653&d=b2m5o1
代码:
// ViewDllFunc.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include<windows.h>#include<stdio.h>#include<Imagehlp.h>#pragma comment(lib,"Imagehlp.lib")bool GetDLLFileExports(char *szFileName, UINT *nNoOfExports, char **&pszFunctions);int main(int argc, char* argv[]){UINT unNoOfExports=0; char **lppBuffer; GetDLLFileExports("dllA.dll", &unNoOfExports, lppBuffer);char func[256];memset(func,0,sizeof(func)); for(UINT i=0; i<unNoOfExports; i++){ // Memo1->Lines->Add(lppBuffer[i]);sprintf(func,"%d %s",i,lppBuffer[i]);printf("%s \n",func);} for(i=0; i<unNoOfExports; i++) delete []lppBuffer[i]; delete []lppBuffer;printf("Hello World!\n");getchar();return 0;}bool GetDLLFileExports(char *szFileName, UINT *nNoOfExports, char **&pszFunctions){ HANDLE hFile; HANDLE hFileMapping; LPVOID lpFileBase; PIMAGE_DOS_HEADER pImg_DOS_Header; PIMAGE_NT_HEADERS pImg_NT_Header; PIMAGE_EXPORT_DIRECTORY pImg_Export_Dir; hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ,NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if(hFile == INVALID_HANDLE_VALUE) return false; hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); if(hFileMapping == 0) { CloseHandle(hFile); return false; } lpFileBase = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0); if(lpFileBase == 0) { CloseHandle(hFileMapping); CloseHandle(hFile); return false; } pImg_DOS_Header = (PIMAGE_DOS_HEADER)lpFileBase; pImg_NT_Header = (PIMAGE_NT_HEADERS)( (LONG)pImg_DOS_Header + (LONG)pImg_DOS_Header->e_lfanew); if(IsBadReadPtr(pImg_NT_Header, sizeof(IMAGE_NT_HEADERS)) || pImg_NT_Header->Signature != IMAGE_NT_SIGNATURE) { UnmapViewOfFile(lpFileBase); CloseHandle(hFileMapping); CloseHandle(hFile); return false; } pImg_Export_Dir = (PIMAGE_EXPORT_DIRECTORY)pImg_NT_Header->OptionalHeader .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; if(!pImg_Export_Dir) {UnmapViewOfFile(lpFileBase);CloseHandle(hFileMapping);CloseHandle(hFile);return false; } // 63 63 72 75 6E 2E 63 6F 6D pImg_Export_Dir= (PIMAGE_EXPORT_DIRECTORY)ImageRvaToVa(pImg_NT_Header, pImg_DOS_Header, (DWORD)pImg_Export_Dir, 0); DWORD **ppdwNames = (DWORD **)pImg_Export_Dir->AddressOfNames; ppdwNames = (PDWORD*)ImageRvaToVa(pImg_NT_Header, pImg_DOS_Header, (DWORD)ppdwNames, 0); if(!ppdwNames) { UnmapViewOfFile(lpFileBase); CloseHandle(hFileMapping); CloseHandle(hFile); return false; } *nNoOfExports = pImg_Export_Dir->NumberOfNames; pszFunctions = new char*[*nNoOfExports]; for(UINT i=0; i < *nNoOfExports; i++) { char *szFunc=(PSTR)ImageRvaToVa(pImg_NT_Header, pImg_DOS_Header, (DWORD)*ppdwNames, 0); pszFunctions[i] = new char[strlen(szFunc)+1]; strcpy(pszFunctions[i],szFunc); ppdwNames++; } UnmapViewOfFile(lpFileBase); CloseHandle(hFileMapping); CloseHandle(hFile); return true;}
---------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------
您的十分满意是我追求的宗旨。
您的一点建议是我后续的动力。
0 0
- VC遍历dll导出函数
- VC遍历dll导出函数
- VC DLL导出函数
- VC++ DLL 导出函数
- VC++ DLL 导出函数
- VC++编写DLL导出函数通用方法
- VC中DLL导出函数时注意事项
- VC中创建DLL,导出全局变量,函数和类
- VC生成的dll中导出函数名三种方法
- VC.NET写的DLL导出函数的奇怪现象
- VC中创建DLL,导出全局变量,函数和类
- 更方便地动态调用DLL导出函数(VC++)
- 解决vc dll导出函数名字发生改变问题
- VC++编写DLL导出函数及其调用方法
- VB调用VC写的DLL导出函数出现“Bad DLL call convention”的解决
- VC++ dll 导出名详解
- vs2008 dll 导出函数
- dll导出函数
- 详细介绍ORACLE sqlplus命令(转)
- STM8L101时钟管理
- 开题报告
- <C++黑客编程揭秘与防范>笔记心得与更正
- 书非买不能读也---与爱书的同仁共勉(有空了再写哈, 各位亲)
- VC遍历dll导出函数
- poj2151
- 关于nginx根据url进行负载分配即location部分的相关设置
- OpenGL混合的基本知识
- java添加类和包
- Linux系统下的DDOS攻击防范
- 自定义调试查看器分析 StdStringVisualizer(二)
- CentOs下安装svn服务器
- 简单的CSS下拉菜单