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

📄 lion-petut-c01.htm

📁 在DOS下编程因为实模式的限制
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!-- saved from url=(0043)http://203.157.250.93/win32asm/pe-tut1.html -->
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>PE教程1: PE文件格式一览</title>
</head>

<body bgcolor="#000066" text="#FFFFFF" link="#FFFFCC"
vlink="#FFCCCC" alink="#CCFFCC">

<h1 align="center"><font color="#FFFFCC"
face="Arial, Helvetica, sans-serif">PE</font><font
color="#FFFFCC">教程1</font><font color="#FFFFCC"
face="Arial, Helvetica, sans-serif">: PE</font><font
color="#FFFFCC">文件格式一览</font></h1>

<p><font size="2">考虑到早期写的</font><font size="2"
face="MS Sans Serif">PE</font><font size="2">教程</font><font
size="2" face="MS Sans Serif">1</font><font size="2">是自己所有教程中最糟糕的一篇,此番决心彻底重写一篇以飨读者。</font></p>

<p><font size="2" face="MS Sans Serif">PE </font><font size="2">的意思就是
</font><font size="2" face="MS Sans Serif">Portable Executable</font><font
size="2">(可移植的执行体)。它是 </font><font
size="2" face="MS Sans Serif">Win32</font><font size="2">环境自身所带的执行体文件格式。它的一些特性继承自
</font><font size="2" face="MS Sans Serif">Unix</font><font
size="2">的 </font><font size="2" face="MS Sans Serif">Coff
(common object file format)</font><font size="2">文件格式。</font><font
size="2" face="MS Sans Serif">&quot;portable executable&quot;</font><font
size="2">(可移植的执行体)意味着此文件格式是跨</font><font
size="2" face="MS Sans Serif">win32</font><font size="2">平台的
</font><font size="2" face="MS Sans Serif">: </font><font
size="2">即使</font><font size="2" face="MS Sans Serif">Windows</font><font
size="2">运行在非</font><font size="2" face="MS Sans Serif">Intel</font><font
size="2">的</font><font size="2" face="MS Sans Serif">CPU</font><font
size="2">上,任何</font><font size="2" face="MS Sans Serif">win32</font><font
size="2">平台的</font><font size="2" face="MS Sans Serif">PE</font><font
size="2">装载器都能识别和使用该文件格式。当然,移植到不同的</font><font
size="2" face="MS Sans Serif">CPU</font><font size="2">上</font><font
size="2" face="MS Sans Serif">PE</font><font size="2">执行体必然得有一些改变。所有
</font><font size="2" face="MS Sans Serif">win32</font><font
size="2">执行体 </font><font size="2" face="MS Sans Serif">(</font><font
size="2">除了</font><font size="2" face="MS Sans Serif">VxD</font><font
size="2">和</font><font size="2" face="MS Sans Serif">16</font><font
size="2">位的</font><font size="2" face="MS Sans Serif">Dll)</font><font
size="2">都使用</font><font size="2" face="MS Sans Serif">PE</font><font
size="2">文件格式,包括</font><font size="2"
face="MS Sans Serif">NT</font><font size="2">的内核模式驱动程序(</font><font
size="2" face="MS Sans Serif">kernel mode drivers</font><font
size="2">)。因而研究</font><font size="2"
face="MS Sans Serif">PE</font><font size="2">文件格式给了我们洞悉</font><font
size="2" face="MS Sans Serif">Windows</font><font size="2">结构的良机。</font></p>

<p><font size="2">本教程就让我们浏览一下 </font><font
size="2" face="MS Sans Serif">PE</font><font size="2">文件格式的概要。</font></p>

<table border="1" cellpadding="2">
<TBODY>    <tr>
        <td align="center" bgcolor="#0033CC"><font size="2"
        face="MS Sans Serif"><b>DOS MZ header</b></font></td>
    </tr>
    <tr>
        <td align="center" bgcolor="#990000" height="28"><font
        size="2" face="MS Sans Serif"><b>DOS stub</b></font></td>
    </tr>
    <tr>
        <td align="center" bgcolor="#006600" height="36"><font
        size="2" face="MS Sans Serif"><b>PE header</b></font></td>
    </tr>
    <tr>
        <td align="center" bgcolor="#333399"><font size="2"
        face="MS Sans Serif"><b>Section table</b></font></td>
    </tr>
    <tr>
        <td align="center" bgcolor="#660066" height="52"><font
        size="2" face="MS Sans Serif"><b>Section 1</b></font></td>
    </tr>
    <tr>
        <td align="center" bgcolor="#660066" height="55"><font
        size="2" face="MS Sans Serif"><b>Section 2</b></font></td>
    </tr>
    <tr>
        <td align="center" bgcolor="#660066" height="53"><font
        size="2" face="MS Sans Serif"><b>Section ...</b></font></td>
    </tr>
    <tr>
        <td align="center" bgcolor="#660066" height="50"><font
        size="2" face="MS Sans Serif"><b>Section n</b></font></td>
    </tr>
</TBODY></table>

<p><font size="2">上图是 </font><font size="2"
face="MS Sans Serif">PE</font><font size="2">文件结构的总体层次分布。
所有 </font><font size="2" face="MS Sans Serif">PE</font><font
size="2">文件</font><font size="2" face="MS Sans Serif">(</font><font
size="2">甚至</font><font size="2" face="MS Sans Serif">32</font><font
size="2">位的 </font><font size="2" face="MS Sans Serif">DLLs) </font><font
size="2">必须以一个简单的 </font><font size="2"
face="MS Sans Serif">DOS MZ header </font><font size="2">开始。
我们通常对此结构没有太大兴趣。有了它,一旦程序在</font><font
size="2" face="MS Sans Serif">DOS</font><font size="2">下执行,</font><font
size="2" face="MS Sans Serif">DOS</font><font size="2">就能识别出这是有效的执行体,然后运行紧随
</font><font size="2" face="MS Sans Serif">MZ header </font><font
size="2">之后的 </font><font size="2" face="MS Sans Serif">DOS
stub</font><font size="2">。</font><font size="2"
face="MS Sans Serif">DOS stub</font><font size="2">实际上是个有效的
</font><font size="2" face="MS Sans Serif">EXE</font><font
size="2">,在不支持 </font><font size="2"
face="MS Sans Serif">PE</font><font size="2">文件格式的操作系统中,它将简单显示一个错误提示,类似于字符串
</font><font size="2" face="MS Sans Serif">&quot;This program
requires Windows&quot; </font><font size="2">或者程序员可根据自己的意图实现完整的
</font><font size="2" face="MS Sans Serif">DOS</font><font
size="2">代码。通常我们也不对 </font><font size="2"
face="MS Sans Serif">DOS stub </font><font size="2">太感兴趣</font><font
size="2" face="MS Sans Serif">: </font><font size="2">因为大多数情况下它是由汇编器</font><font
size="2" face="MS Sans Serif">/</font><font size="2">编译器自动生成。通常,它简单调用中断</font><font
size="2" face="MS Sans Serif">21h</font><font size="2">服务</font><font
size="2" face="MS Sans Serif">9</font><font size="2">来显示字符串</font><font

⌨️ 快捷键说明

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