没有合适的资源?快使用搜索试试~ 我知道了~
首页如何在内存中加载DLL
资源详情
资源评论
资源推荐
Loading a DLL from memory
This tutorial describes a technique how a dynamic link library (DLL) can be loaded from memory without storing it on
the hard-disk first.
Overview
The default windows API functions to load external libraries into a program (LoadLibrary, LoadLibraryEx) only work
with files on the filesystem. It’s therefore impossible to load a DLL from memory. But sometimes, you need exactly this
functionality (e.g. you don’t want to distribute a lot of files or want to make disassembling harder). Common
workarounds for this problems are to write the DLL into a temporary file first and import it from there. When the
program terminates, the temporary file gets deleted.
In this tutorial, I will describe first, how DLL files are structured and will present some code that can be used to load a
DLL completely from memory – without storing on the disk first.
Windows executables – the PE format
Most windows binaries that can contain executable code (.exe, .dll, .sys) share a common file format that consists of
the following parts:
enter keyword...
Go
Categories
Development
spreed
Uncategorized
Links
Bugtracker
fancy.code
github
spreed.com
Wishlist
amazon.com
amazon.de
~magog/public
random::entropy
Home About me Projects Tutorials Disclaimer
Subscribe to RSS Feed
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
DOS header
DOS stub
PE header
Section header
Section 1
Section 2
. . .
Section n
All structures given below can be found in the header file winnt.h.
DOS header / stub
The DOS header is only used for backwards compatibility. It precedes the DOS stub that normally just displays an
error message about the program not being able to be run from DOS mode.
Microsoft defines the DOS header as follows:
typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header
WORD e_magic; // Magic number
WORD e_cblp; // Bytes on last page of file
WORD e_cp; // Pages in file
WORD e_crlc; // Relocations
WORD e_cparhdr; // Size of header in paragraphs
WORD e_minalloc; // Minimum extra paragraphs needed
WORD e_maxalloc; // Maximum extra paragraphs needed
WORD e_ss; // Initial (relative) SS value
Paypal
Archives
April 2012
March 2011
January 2011
November 2010
October 2010
August 2010
May 2010
April 2010
Meta
Log in
Entries RSS
Comments RSS
WordPress.org
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
WORD e_sp; // Initial SP value
WORD e_csum; // Checksum
WORD e_ip; // Initial IP value
WORD e_cs; // Initial (relative) CS value
WORD e_lfarlc; // File address of relocation table
WORD e_ovno; // Overlay number
WORD e_res[4]; // Reserved words
WORD e_oemid; // OEM identifier (for e_oeminfo)
WORD e_oeminfo; // OEM information; e_oemid specific
WORD e_res2[10]; // Reserved words
LONG e_lfanew; // File address of new exe header
} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
PE header
The PE header contains informations about the different sections inside the executable that are used to store code
and data or to define imports from other libraries or exports this libraries provides.
It’s defined as follows:
typedef struct _IMAGE_NT_HEADERS {
DWORD Signature;
IMAGE_FILE_HEADER FileHeader;
IMAGE_OPTIONAL_HEADER32 OptionalHeader;
} IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;
The FileHeader describes the physical format of the file, i.e. contents, informations about symbols, etc:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
typedef struct _IMAGE_FILE_HEADER {
WORD Machine;
WORD NumberOfSections;
DWORD TimeDateStamp;
DWORD PointerToSymbolTable;
DWORD NumberOfSymbols;
WORD SizeOfOptionalHeader;
WORD Characteristics;
} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
The OptionalHeader contains informations about the logical format of the library, including required OS version,
memory requirements and entry points:
typedef struct _IMAGE_OPTIONAL_HEADER {
//
// Standard fields.
//
WORD Magic;
BYTE MajorLinkerVersion;
BYTE MinorLinkerVersion;
DWORD SizeOfCode;
DWORD SizeOfInitializedData;
DWORD SizeOfUninitializedData;
DWORD AddressOfEntryPoint;
DWORD BaseOfCode;
DWORD BaseOfData;
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
剩余16页未读,继续阅读
etsi
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- zigbee-cluster-library-specification
- JSBSim Reference Manual
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0