当前位置: 首页>>代码示例>>C#>>正文


C# Module.__ReadDataFromRVA方法代码示例

本文整理汇总了C#中Module.__ReadDataFromRVA方法的典型用法代码示例。如果您正苦于以下问题:C# Module.__ReadDataFromRVA方法的具体用法?C# Module.__ReadDataFromRVA怎么用?C# Module.__ReadDataFromRVA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Module的用法示例。


在下文中一共展示了Module.__ReadDataFromRVA方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetExportedMethods

        static Dictionary<int, List<ExportedMethod>> GetExportedMethods(Module module)
        {
            int rva;
            int length;
            module.__GetDataDirectoryEntry(0, out rva, out length);

            if (rva == 0 || length < 40)
            {
                return new Dictionary<int, List<ExportedMethod>>();
            }

            ExportDirectoryTable edt = new ExportDirectoryTable();
            byte[] buf = new byte[512];
            module.__ReadDataFromRVA(rva, buf, 0, 40);
            edt.Read(new BinaryReader(new MemoryStream(buf)));

            var methods = new Dictionary<int, List<ExportedMethod>>();
            for (int i = 0; i < edt.NumberOfNamePointers; i++)
            {
                module.__ReadDataFromRVA((int)edt.OrdinalTableRVA + i * 2, buf, 0, 2);
                int ordinal = BitConverter.ToInt16(buf, 0) + (int)edt.OrdinalBase;
                string name = null;
                if (edt.NamePointerRVA != 0)
                {
                    module.__ReadDataFromRVA((int)edt.NamePointerRVA + i * 4, buf, 0, 4);
                    module.__ReadDataFromRVA(BitConverter.ToInt32(buf, 0), buf, 0, buf.Length);
                    int len = 0;
                    while (buf[len] != 0) len++;
                    name = Encoding.ASCII.GetString(buf, 0, len);
                }
                int token = GetTokenFromExportOrdinal(module, edt, ordinal);
                if (token == -1)
                {
                    continue;
                }
                List<ExportedMethod> list;
                if (!methods.TryGetValue(token, out list))
                {
                    list = new List<ExportedMethod>();
                    methods.Add(token, list);
                }
                ExportedMethod method;
                method.name = name;
                method.ordinal = ordinal;
                list.Add(method);
            }
            return methods;
        }
开发者ID:jfrijters,项目名称:ikdasm,代码行数:48,代码来源:ExportedMethods.cs

示例2: GetTokenFromExportOrdinal

 static int GetTokenFromExportOrdinal(Module module, ExportDirectoryTable edt, int ordinal)
 {
     PortableExecutableKinds peKind;
     ImageFileMachine machine;
     module.GetPEKind(out peKind, out machine);
     byte[] buf = new byte[16];
     module.__ReadDataFromRVA((int)edt.ExportAddressTableRVA + (int)(ordinal - edt.OrdinalBase) * 4, buf, 0, 4);
     int exportRVA = BitConverter.ToInt32(buf, 0);
     if (machine == ImageFileMachine.ARM)
     {
         // mask out the instruction set selection flag
         exportRVA &= ~1;
     }
     module.__ReadDataFromRVA(exportRVA, buf, 0, 16);
     int offset;
     if (machine == ImageFileMachine.I386 && buf[0] == 0xFF && buf[1] == 0x25)
     {
         // for x86 the code here is:
         //   FF 25 00 40 40 00               jmp         dword ptr ds:[00404000h]
         offset = 2;
     }
     else if (machine == ImageFileMachine.AMD64 && buf[0] == 0x48 && buf[1] == 0xA1)
     {
         // for x64 the code here is:
         //   48 A1 00 40 40 00 00 00 00 00   mov         rax,qword ptr [0000000000404000h]
         //   FF E0                           jmp         rax
         offset = 2;
     }
     else if (machine == ImageFileMachine.ARM && buf[0] == 0xDF && buf[1] == 0xF8 && buf[2] == 0x08 && buf[3] == 0xC0)
     {
         // for arm the code here is:
         // F8DF C008 ldr         r12,0040145C
         // F8DC C000 ldr         r12,[r12]
         // 4760      bx          r12
         // DEFE      __debugbreak
         // here is the RVA
         offset = 12;
     }
     else
     {
         return -1;
     }
     int vtableRVA = BitConverter.ToInt32(buf, offset) - (int)module.__ImageBase;
     module.__ReadDataFromRVA(vtableRVA, buf, 0, 4);
     return BitConverter.ToInt32(buf, 0);
 }
开发者ID:jfrijters,项目名称:ikdasm,代码行数:46,代码来源:ExportedMethods.cs


注:本文中的Module.__ReadDataFromRVA方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。