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

📄 chap8-1-6.htm.primary

📁 加密与解密,软件加密保护技术与解决方案,看雪文档!
💻 PRIMARY
📖 第 1 页 / 共 5 页
字号:
  <li><font size="2" color="#000000">从 </font><font size="2" face="MS Sans Serif" color="#000000">optional 
    header </font><font size="2" color="#000000">读取 </font><font size="2" face="MS Sans Serif" color="#000000">data 
    directory </font><font size="2" color="#000000">的地址。</font></li>
  <li><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_DATA_DIRECTORY 
    </b></font><font size="2" color="#000000">结构尺寸乘上找寻结构的索引号</font><font size="2" face="MS Sans Serif" color="#000000">: 
    </font><font size="2" color="#000000">比如您要找寻</font><font size="2" face="MS Sans Serif" color="#000000">import 
    symbols</font><font size="2" color="#000000">的位置信息,必须用</font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_DATA_DIRECTORY</b> 
    </font><font size="2" color="#000000">结构尺寸</font><font size="2" face="MS Sans Serif" color="#000000">(8 
    bytes)</font><font size="2" color="#000000">乘上</font><font size="2" face="MS Sans Serif" color="#000000">1</font><font size="2" color="#000000">(</font><font size="2" face="MS Sans Serif" color="#000000">import 
    symbols</font><font size="2" color="#000000">在</font><font size="2" face="MS Sans Serif" color="#000000">data 
    directory</font><font size="2" color="#000000">中的索引号)。</font></li>
  <li><font size="2" color="#000000">将上面的结果加上</font><font size="2" face="MS Sans Serif" color="#000000">data 
    directory</font><font size="2" color="#000000">地址,我们就得到包含所查询数据结构信息的 </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_DATA_DIRECTORY</b> 
    </font><font size="2" color="#000000">结构项。</font></li>
</ol>
<p><font size="2" color="#000000">现在我们开始真正讨论引入表了。</font><font size="2" face="MS Sans Serif" color="#000000">data 
  directory</font><font size="2" color="#000000">数组第二项的</font><font color="#000000" size="2" face="MS Sans Serif"><b>VirtualAddress</b></font><font size="2" color="#000000">包含引入表地址。引入表实际上是一个 
  </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_IMPORT_DESCRIPTOR</b> 
  </font><font size="2" color="#000000">结构数组。每个结构包含</font><font size="2" face="MS Sans Serif" color="#000000">PE</font><font size="2" color="#000000">文件引入函数的一个相关</font><font size="2" face="MS Sans Serif" color="#000000">DLL</font><font size="2" color="#000000">的信息。比如,如果该</font><font size="2" face="MS Sans Serif" color="#000000">PE</font><font size="2" color="#000000">文件从</font><font size="2" face="MS Sans Serif" color="#000000">10</font><font size="2" color="#000000">个不同的</font><font size="2" face="MS Sans Serif" color="#000000">DLL</font><font size="2" color="#000000">中引入函数,那么这个数组就有</font><font size="2" face="MS Sans Serif" color="#000000">10</font><font size="2" color="#000000">个成员。该数组以一个全</font><font size="2" face="MS Sans Serif" color="#000000">0</font><font size="2" color="#000000">的成员结尾。下面详细研究结构组成</font><font size="2" face="MS Sans Serif" color="#000000">:</font></p>
<p><font face="Fixedsys" color="#000000">IMAGE_IMPORT_DESCRIPTOR STRUCT <br>
  &nbsp;&nbsp;union <br>
  &nbsp;&nbsp;&nbsp; Characteristics dd ? <br>
  &nbsp;&nbsp;&nbsp; OriginalFirstThunk dd ? <br>
  &nbsp; ends <br>
  &nbsp; TimeDateStamp dd ? <br>
  &nbsp; ForwarderChain dd ? <br>
  &nbsp; Name1 dd ? <br>
  &nbsp; FirstThunk dd ? <br>
  IMAGE_IMPORT_DESCRIPTOR ENDS </font></p>
<p><font size="2" color="#000000">结构第一项是一个</font><font size="2" face="MS Sans Serif" color="#000000">union</font><font size="2" color="#000000">子结构。 
  事实上,这个</font><font size="2" face="MS Sans Serif" color="#000000">union</font><font size="2" color="#000000">子结构只是给 
  </font><font color="#000000" size="2" face="MS Sans Serif"><b>OriginalFirstThunk</b> 
  </font><font size="2" color="#000000">增添了个别名,您也可以称其为</font><font size="2" face="MS Sans Serif" color="#000000">&quot;Characteristics&quot;</font><font size="2" color="#000000">。 
  该成员项含有指向一个 </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_THUNK_DATA</b> 
  </font><font size="2" color="#000000">结构数组的</font><font size="2" face="MS Sans Serif" color="#000000">RVA</font><font size="2" color="#000000">。<br>
  什么是 </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_THUNK_DATA</b>? 
  </font><font size="2" color="#000000">这是一个</font><font size="2" face="MS Sans Serif" color="#000000">dword</font><font size="2" color="#000000">类型的集合。通常我们将其解释为指向一个 
  </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_IMPORT_BY_NAME</b> 
  </font><font size="2" color="#000000">结构的指针。注意 </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_THUNK_DATA</b> 
  </font><font size="2" color="#000000">包含了指向一个 </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_IMPORT_BY_NAME</b> 
  </font><font size="2" color="#000000">结构的指针</font><font size="2" face="MS Sans Serif" color="#000000">: 
  </font><font size="2" color="#000000">而不是结构本身。<br>
  请看这里</font><font size="2" face="MS Sans Serif" color="#000000">: </font><font size="2" color="#000000">现有几个 
  </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_IMPORT_BY_NAME</b> 
  </font><font size="2" color="#000000">结构,我们收集起这些结构的</font><font size="2" face="MS Sans Serif" color="#000000">RVA 
  (<b>IMAGE_THUNK_DATAs</b>)</font><font size="2" color="#000000">组成一个数组,并以</font><font size="2" face="MS Sans Serif" color="#000000">0</font><font size="2" color="#000000">结尾,然后再将数组的</font><font size="2" face="MS Sans Serif" color="#000000">RVA</font><font size="2" color="#000000">放入 
  </font><font color="#000000" size="2" face="MS Sans Serif"><b>OriginalFirstThunk</b></font><font size="2" color="#000000">。<br>
  此 </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_IMPORT_BY_NAME</b> 
  </font><font size="2" color="#000000">结构存有一个引入函数的相关信息。再来研究 </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_IMPORT_BY_NAME</b> 
  </font><font size="2" color="#000000">结构到底是什么样子的呢</font><font size="2" face="MS Sans Serif" color="#000000">:</font></p>
<p><font face="Fixedsys" color="#000000">IMAGE_IMPORT_BY_NAME STRUCT <br>
  &nbsp; Hint dw ? <br>
  &nbsp; Name1 db ? <br>
  IMAGE_IMPORT_BY_NAME ENDS </font></p>
<p><font color="#000000" size="2" face="MS Sans Serif"><b>Hint </b></font><font size="2" color="#000000">指示本函数在其所驻留</font><font size="2" face="MS Sans Serif" color="#000000">DLL</font><font size="2" color="#000000">的引出表中的索引号。该域被</font><font size="2" face="MS Sans Serif" color="#000000">PE</font><font size="2" color="#000000">装载器用来在</font><font size="2" face="MS Sans Serif" color="#000000">DLL</font><font size="2" color="#000000">的引出表里快速查询函数。该值不是必须的,一些连接器将此值设为</font><font size="2" face="MS Sans Serif" color="#000000">0</font><font size="2" color="#000000">。<br>
  </font><font color="#000000" size="2" face="MS Sans Serif"><b>Name1</b> </font><font size="2" color="#000000">含有引入函数的函数名。函数名是一个</font><font size="2" face="MS Sans Serif" color="#000000">ASCIIZ</font><font size="2" color="#000000">字符串。注意这里虽然将</font><font size="2" face="MS Sans Serif" color="#000000">Name1</font><font size="2" color="#000000">的大小定义成字节,其实它是可变尺寸域,只不过我们没有更好方法来表示结构中的可变尺寸域。</font><font size="2" face="MS Sans Serif" color="#000000">The 
  structure is provided so that you can refer to the data structure with descriptive 
  names.<br>
  </font></p>
<p><font color="#000000" size="2" face="MS Sans Serif"><b>TimeDateStamp</b> </font><font size="2" color="#000000">和 
  </font><font color="#000000" size="2" face="MS Sans Serif"><b>ForwarderChain</b> 
  </font><font size="2" color="#000000">可是高级东东</font><font size="2" face="MS Sans Serif" color="#000000">: 
  </font><font size="2" color="#000000">让我们精通其他成员后再来讨论它们吧。</font></p>
<p><font color="#000000" size="2" face="MS Sans Serif"><b>Name1</b> </font><font size="2" color="#000000">含有指向</font><font size="2" face="MS Sans Serif" color="#000000">DLL</font><font size="2" color="#000000">名字的</font><font size="2" face="MS Sans Serif" color="#000000">RVA</font><font size="2" color="#000000">,即指向</font><font size="2" face="MS Sans Serif" color="#000000">DLL</font><font size="2" color="#000000">名字的指针,也是一个</font><font size="2" face="MS Sans Serif" color="#000000">ASCIIZ</font><font size="2" color="#000000">字符串。</font></p>
<p><font color="#000000" size="2" face="MS Sans Serif"><b>FirstThunk</b> </font><font size="2" color="#000000">与 
  </font><font color="#000000" size="2" face="MS Sans Serif"><b>OriginalFirstThunk</b> 
  </font><font size="2" color="#000000">非常相似,它也包含指向一个 </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_THUNK_DATA</b> 
  </font><font size="2" color="#000000">结构数组的</font><font size="2" face="MS Sans Serif" color="#000000">RVA(</font><font size="2" color="#000000">当然这是另外一个</font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_THUNK_DATA</b> 
  </font><font size="2" color="#000000">结构数组</font><font size="2" face="MS Sans Serif" color="#000000">)</font><font size="2" color="#000000">。 
  <br>
  好了,如果您还在犯糊涂,就朝这边看过来</font><font size="2" face="MS Sans Serif" color="#000000">: 
  </font><font size="2" color="#000000">现在有几个 </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_IMPORT_BY_NAME 
  </b></font><font size="2" color="#000000">结构,同时您又创建了两个结构数组,并同样寸入指向那些 </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_IMPORT_BY_NAME</b> 
  </font><font size="2" color="#000000">结构的</font><font size="2" face="MS Sans Serif" color="#000000">RVAs</font><font size="2" color="#000000">,这样两个数组就包含相同数值了</font><font size="2" face="MS Sans Serif" color="#000000">(</font><font size="2" color="#000000">可谓相当精确的复制啊</font><font size="2" face="MS Sans Serif" color="#000000">)</font><font size="2" color="#000000">。 
  最后您决定将第一个数组的</font><font size="2" face="MS Sans Serif" color="#000000">RVA</font><font size="2" color="#000000">赋给 
  </font><font color="#000000" size="2" face="MS Sans Serif"><b>OriginalFirstThunk</b></font><font color="#000000" size="2"><b>,</b>第二个数组的</font><font size="2" face="MS Sans Serif" color="#000000">RVA</font><font size="2" color="#000000">赋给 
  </font><font color="#000000" size="2" face="MS Sans Serif"><b>FirstThunk</b></font><font size="2" color="#000000">,这样一切都很清楚了。</font></p>
<table border="0" cellspacing="1">
  <tr> 
    <th width="152" bgcolor="#006666"><font size="2" face="MS Sans Serif" color="#FFFFFF">OriginalFirstThunk</font></th>
    <th width="58"><font color="#FFFFFF"> </font></th>
    <th width="183" bgcolor="#006666"><font size="2" face="MS Sans Serif" color="#FFFFFF">IMAGE_IMPORT_BY_NAME</font></th>
    <th width="27"><font color="#FFFFFF"> </font></th>
    <th width="152" bgcolor="#006666"><font size="2" face="MS Sans Serif" color="#FFFFFF">FirstThunk</font></th>
  </tr>
  <tr> 
    <td align="center" width="152"> 
      <p align="center">| </p>
    </td>
    <td align="center" width="58"> </td>
    <td align="center" width="183"> </td>
    <td align="center" width="27"> </td>
    <td align="center" width="152"><font size="2"
        face="MS Sans Serif">|</font> </td>
  </tr>
  <tr> 
    <td align="center" width="152"> 
      <table border="1"
        cellpadding="2">
        <tr> 
          <td align="center" bgcolor="#666600"><font size="2" face="MS Sans Serif" color="#FFFFFF">IMAGE_THUNK_DATA</font> 
          </td>
        </tr>
        <tr> 
          <td align="center" bgcolor="#666600"><font size="2" face="MS Sans Serif" color="#FFFFFF">IMAGE_THUNK_DATA</font> 
          </td>
        </tr>
        <tr> 
          <td align="center" bgcolor="#666600"><font size="2" face="MS Sans Serif" color="#FFFFFF">IMAGE_THUNK_DATA</font> 
          </td>
        </tr>
        <tr> 
          <td align="center" bgcolor="#666600"><font size="2" face="MS Sans Serif" color="#FFFFFF">IMAGE_THUNK_DATA</font> 
          </td>
        </tr>
        <tr> 
          <td align="center" bgcolor="#666600"><font size="2" face="MS Sans Serif" color="#FFFFFF">...</font> 
          </td>
        </tr>
        <tr> 
          <td align="center" bgcolor="#666600"><font size="2" face="MS Sans Serif" color="#FFFFFF">IMAGE_THUNK_DATA</font> 
          </td>
        </tr>
      </table>
    </td>
    <td align="center" width="58"> 
      <table border="0"
        cellpadding="2">
        <tr> 
          <td align="center" nowrap><font size="2"
                face="MS Sans Serif">---&gt;</font></td>
        </tr>
        <tr> 
          <td align="center" nowrap><font size="2"
                face="MS Sans Serif">---&gt;</font></td>
        </tr>
        <tr> 
          <td align="center" nowrap><font size="2"
                face="MS Sans Serif">---&gt;</font></td>
        </tr>
        <tr> 
          <td align="center" nowrap><font size="2"
                face="MS Sans Serif">---&gt;</font></td>
        </tr>
        <tr> 
          <td align="center" nowrap><font size="2"
                face="MS Sans Serif">---&gt;</font></td>
        </tr>
        <tr> 
          <td align="center" nowrap><font size="2"
                face="MS Sans Serif">---&gt;</font></td>
        </tr>
      </table>
    </td>
    <td align="center" width="183"> 
      <table border="1"
        cellpadding="2">
        <tr> 
          <td align="center" bgcolor="#660066"><font size="2" face="MS Sans Serif" color="#FFFFFF">Function 
            1</font> </td>
        </tr>
        <tr> 
          <td align="center" bgcolor="#660066"><font size="2" face="MS Sans Serif" color="#FFFFFF">Function 
            2</font> </td>
        </tr>
        <tr> 
          <td align="center" bgcolor="#660066"><font size="2" face="MS Sans Serif" color="#FFFFFF">Function 
            3</font> </td>
        </tr>
        <tr> 
          <td align="center" bgcolor="#660066"><font size="2" face="MS Sans Serif" color="#FFFFFF">Function 
            4 </font></td>
        </tr>
        <tr> 
          <td align="center" bgcolor="#660066"><font size="2" face="MS Sans Serif" color="#FFFFFF">...</font> 
          </td>
        </tr>
        <tr> 
          <td align="center" bgcolor="#660066"><font size="2" face="MS Sans Serif" color="#FFFFFF">Function 
            n</font> </td>
        </tr>
      </table>
    </td>
    <td align="center" width="27"> 
      <table border="0"
        cellpadding="2">
        <tr> 
          <td align="center" nowrap><font size="2"
                face="MS Sans Serif">&lt;---</font></td>
        </tr>
        <tr> 
          <td align="center" nowrap><font size="2"
                face="MS Sans Serif">&lt;---</font></td>
        </tr>

⌨️ 快捷键说明

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