Dex文件DexClassData 结构求助
《Android 软件安全与逆向分析》这本书在讲解DexClassData时很简略,只说了u4是LEB128编码的东西。 DexClassData中的几个指针成员指什么地方也没提。typedef struct DexClassData {DexClassDataHeader header;
DexField* staticFields;
DexField* instanceFields;
DexMethod* directMethods;
DexMethod* virtualMethods;
} DexClassData;
网上查的资料显示:
encoded_field..... 我就依葫芦画瓢下了下面代码:
DexClassData *cdata;
cdata=(DexClassData *)&f.pBuffer.classDataOff];
u=f.GetClassMethodSize(cdata);
for (int y = 0; y < u; y++)
{
DexMethod *df;
u4 uid;
df=f.GetClassMethod(cdata);
uid=readU4Leb128(&df.methodIdx);
u2 classId;
u2 protoId;
u4 nameIdx;
DexTypeList *list;
classId=f.Method_ids.classIdx;
protoId=f.Method_ids.protoIdx;
nameIdx=f.Method_ids.nameIdx;
.....................................................................
寻址代码:
DexField *CDexFile::GetClassStaticField(DexClassData *classdef)
{
char *pbuf;
pbuf=(char *)classdef;
return (DexField *)&pbuf;//越过DexClassDataHeader
}
DexField *CDexFile::GetClassField(DexClassData *classdef)
{
char *pbuf;
pbuf=(char *)GetClassStaticField(classdef);
return (DexField *)&pbuf;
}
DexMethod *CDexFile::GetClassMethod(DexClassData *classdef)
{
char *pbuf;
pbuf=(char *)GetClassField(classdef);
return (DexMethod * )&pbuf;
}
DexMethod *CDexFile::GetClassVirtualMethod(DexClassData *classdef)
{
char *pbuf;
pbuf=(char *)GetClassMethod(classdef);
return (DexMethod *)&pbuf;
}
页:
[1]