本文整理汇总了C#中Module.__GetDataDirectoryEntry方法的典型用法代码示例。如果您正苦于以下问题:C# Module.__GetDataDirectoryEntry方法的具体用法?C# Module.__GetDataDirectoryEntry怎么用?C# Module.__GetDataDirectoryEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module.__GetDataDirectoryEntry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}