zoukankan      html  css  js  c++  java
  • Rva2Offset

          /// <summary>
          /// The PE format frequently uses the term RVA (Relative Virtual Address). An RVA is the address of an item
          /// <i>once loaded into memory</i>, with the base address of the image file subtracted from it (i.e., the offset from the
          /// base address where the file is loaded). The RVA of an item will almost always differ from its position within
          /// the file on disk. To compute the file position of an item with RVA <i>r</i>, search all the sections in the PE file to find
          /// the section with RVA s, length <i>l</i> and file position <i>p </i>in which the RVA lies, ie <i>s ≤ r < s+l</i>. The file position of
          /// the item is then given by <i>p+(r-s)</i>.
          /// <see cref="c042927_ISO_IEC_23271_2006(E).pdf"/>page 299 of 556.
          /// </summary>
          /// <param name="rva"></param>
          /// <returns></returns>
    -     public uint Rva2Offset(uint rva) {
            if (rva == 0)
              return 0;
    -       else {
    -         for (int i = 0; i < this.pe.SectionHeaders.Length; i++) {
                SectionHeader sh = this.pe.SectionHeaders[i];
                if ((sh.VirtualAddress <= rva) && (sh.VirtualAddress + sh.SizeOfRawData > rva))
                  return (sh.PointerToRawData + (rva - sh.VirtualAddress));
              }
            }
            throw new Exception("Invalid RVA address.");
          }
  • 相关阅读:
    《Vue.js 2.x实践指南》 已出版
    《H5+移动应用实战开发》已出版
    关于《ASP.NET MVC企业级实战》
    ASP.NET MVC企业级实战目录
    ASP.NET MVC4入门到精通系列目录汇总
    网站服务架构
    ASP.NET MVC搭建项目后台UI框架—1、后台主框架
    webpack介绍—上
    通过一个vue+elementUI的小实例来讲解一下它们是如何使用的
    不要为自己学历低找借口
  • 原文地址:https://www.cnblogs.com/peanut/p/1083597.html
Copyright © 2011-2022 走看看