mirror of
https://github.com/revanced/smali.git
synced 2025-05-05 09:04:25 +02:00
change the field lookup to a field dump, and the inline method lookup to an inline method dump
git-svn-id: https://smali.googlecode.com/svn/trunk@444 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
6fa95185b7
commit
e6e9569227
@ -285,7 +285,7 @@ int loadAllClasses(DvmDex* pDvmDex)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Field *lookupField(char *classType, int offset)
|
int dumpFields(char *classType, FILE *clientOut)
|
||||||
{
|
{
|
||||||
ClassObject *clazz;
|
ClassObject *clazz;
|
||||||
if (classType[0] == '[')
|
if (classType[0] == '[')
|
||||||
@ -294,44 +294,54 @@ Field *lookupField(char *classType, int offset)
|
|||||||
clazz = dvmFindSystemClassNoInit(classType);
|
clazz = dvmFindSystemClassNoInit(classType);
|
||||||
|
|
||||||
if (clazz == NULL)
|
if (clazz == NULL)
|
||||||
return NULL;
|
return 0;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
InstField *pField = clazz->ifields;
|
InstField *pField = clazz->ifields;
|
||||||
for (i=0; i<clazz->ifieldCount; i++, pField++)
|
for (i=0; i<clazz->ifieldCount; i++, pField++)
|
||||||
{
|
fprintf(clientOut, "field: %d %s:%s\n", pField->byteOffset, pField->field.name, pField->field.signature);
|
||||||
if (pField->byteOffset == offset)
|
|
||||||
return &pField->field;
|
|
||||||
}
|
|
||||||
|
|
||||||
clazz = clazz->super;
|
clazz = clazz->super;
|
||||||
} while (clazz != NULL);
|
} while (clazz != NULL);
|
||||||
|
|
||||||
return NULL;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Method *lookupInlineMethod(int index)
|
int dumpInlineMethods(FILE *clientOut)
|
||||||
{
|
{
|
||||||
const InlineOperation *inlineTable = dvmGetInlineOpsTable();
|
const InlineOperation *inlineTable = dvmGetInlineOpsTable();
|
||||||
int count = dvmGetInlineOpsTableLength();
|
int count = dvmGetInlineOpsTableLength();
|
||||||
|
|
||||||
if (index >= count)
|
int i;
|
||||||
return NULL;
|
for (i=0; i<count; i++) {
|
||||||
|
const InlineOperation *inlineOp = &inlineTable[i];
|
||||||
|
|
||||||
const InlineOperation *inlineOp = &inlineTable[index];
|
ClassObject *clazz = dvmFindSystemClassNoInit(inlineOp->classDescriptor);
|
||||||
|
if (clazz == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
ClassObject *clazz = dvmFindSystemClassNoInit(inlineOp->classDescriptor);
|
char *methodType;
|
||||||
if (clazz == NULL)
|
Method *method = dvmFindDirectMethodByDescriptor(clazz, inlineOp->methodName, inlineOp->methodSignature);
|
||||||
return NULL;
|
if (method == NULL)
|
||||||
|
{
|
||||||
|
method = dvmFindVirtualMethodByDescriptor(clazz, inlineOp->methodName, inlineOp->methodSignature);
|
||||||
|
methodType = "virtual";
|
||||||
|
} else {
|
||||||
|
if (dvmIsStaticMethod(method))
|
||||||
|
methodType = "static";
|
||||||
|
else
|
||||||
|
methodType = "direct";
|
||||||
|
}
|
||||||
|
|
||||||
Method *method = dvmFindDirectMethodByDescriptor(clazz, inlineOp->methodName, inlineOp->methodSignature);
|
if (method == NULL)
|
||||||
if (method != NULL)
|
return 0;
|
||||||
return method;
|
|
||||||
|
|
||||||
method = dvmFindVirtualMethodByDescriptor(clazz, inlineOp->methodName, inlineOp->methodSignature);
|
fprintf(clientOut, "inline: %s %s->%s%s\n", methodType, method->clazz->descriptor, method->name, dexProtoGetMethodDescriptor(&method->prototype, &stringCache));
|
||||||
return method;
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dumpVirtualMethods(char *classType, FILE *clientOut)
|
int dumpVirtualMethods(char *classType, FILE *clientOut)
|
||||||
@ -371,27 +381,6 @@ int dumpVirtualMethods(char *classType, FILE *clientOut)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Method *lookupSuperMethod(char *classType, int index, ClassObject **clazz)
|
|
||||||
{
|
|
||||||
if (classType[0] == '[')
|
|
||||||
*clazz = dvmFindArrayClass(classType, NULL);
|
|
||||||
else
|
|
||||||
*clazz = dvmFindSystemClassNoInit(classType);
|
|
||||||
|
|
||||||
if (*clazz == NULL)
|
|
||||||
return NULL;
|
|
||||||
*clazz = (*clazz)->super;
|
|
||||||
if (*clazz == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (index >= (*clazz)->vtableCount)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
Method *method = (*clazz)->vtable[index];
|
|
||||||
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClassObject *lookupSuperclass(char *classType)
|
ClassObject *lookupSuperclass(char *classType)
|
||||||
{
|
{
|
||||||
ClassObject *clazz = dvmFindSystemClassNoInit(classType);
|
ClassObject *clazz = dvmFindSystemClassNoInit(classType);
|
||||||
@ -563,71 +552,27 @@ int main(int argc, char* const argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *offsetStr = strtok(NULL, " ");
|
if (!dumpFields(classType, clientOut))
|
||||||
if (offsetStr == NULL)
|
|
||||||
{
|
{
|
||||||
fprintf(clientOut, "err: no offset for field lookup\n");
|
fprintf(clientOut, "err: error while dumping fields\n");
|
||||||
fflush(clientOut);
|
fflush(clientOut);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *end;
|
fprintf(clientOut, "done\n");
|
||||||
int offset = strtol(offsetStr, &end, 10);
|
|
||||||
if (*end != '\0')
|
|
||||||
{
|
|
||||||
fprintf(clientOut, "err: offset not a valid number for field lookup\n");
|
|
||||||
fflush(clientOut);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Field *field = lookupField(classType, offset);
|
|
||||||
if (field == NULL)
|
|
||||||
{
|
|
||||||
fprintf(clientOut, "err: field not found\n");
|
|
||||||
fflush(clientOut);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(clientOut, "field: %s->%s:%s\n", classType, field->name, field->signature);
|
|
||||||
fflush(clientOut);
|
fflush(clientOut);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'I':
|
case 'I':
|
||||||
{
|
{
|
||||||
char *indexStr = strtok(NULL, " ");
|
if (!dumpInlineMethods(clientOut))
|
||||||
if (indexStr == NULL)
|
|
||||||
{
|
|
||||||
fprintf(clientOut, "err: no index for inline method lookup\n");
|
|
||||||
fflush(clientOut);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *end;
|
|
||||||
int index = strtol(indexStr, &end, 10);
|
|
||||||
if (*end != '\0')
|
|
||||||
{
|
|
||||||
fprintf(clientOut, "err: index not a valid number for inline method lookup\n");
|
|
||||||
fflush(clientOut);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Method *method = lookupInlineMethod(index);
|
|
||||||
if (method == NULL)
|
|
||||||
{
|
{
|
||||||
fprintf(clientOut, "err: inline method not found\n");
|
fprintf(clientOut, "err: inline method not found\n");
|
||||||
fflush(clientOut);
|
fflush(clientOut);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *methodType;
|
fprintf(clientOut, "done\n");
|
||||||
if (dvmIsStaticMethod(method))
|
|
||||||
methodType = "static";
|
|
||||||
else if (dvmIsDirectMethod(method))
|
|
||||||
methodType = "direct";
|
|
||||||
else
|
|
||||||
methodType = "virtual";
|
|
||||||
|
|
||||||
fprintf(clientOut, "%s method: %s->%s%s\n", methodType, method->clazz->descriptor, method->name, dexProtoGetMethodDescriptor(&method->prototype, &stringCache));
|
|
||||||
fflush(clientOut);
|
fflush(clientOut);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -651,46 +596,6 @@ int main(int argc, char* const argv[])
|
|||||||
fflush(clientOut);
|
fflush(clientOut);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'S':
|
|
||||||
{
|
|
||||||
char *classType = strtok(NULL, " ");
|
|
||||||
if (classType == NULL)
|
|
||||||
{
|
|
||||||
fprintf(clientOut, "err: no classType for super method lookup\n");
|
|
||||||
fflush(clientOut);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *indexStr = strtok(NULL, " ");
|
|
||||||
if (indexStr == NULL)
|
|
||||||
{
|
|
||||||
fprintf(clientOut, "err: no vtable index for super method lookup\n");
|
|
||||||
fflush(clientOut);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *end;
|
|
||||||
int index = strtol(indexStr, &end, 10);
|
|
||||||
if (*end != '\0')
|
|
||||||
{
|
|
||||||
fprintf(clientOut, "err: vtable index not a valid number for super method lookup\n");
|
|
||||||
fflush(clientOut);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClassObject *clazz;
|
|
||||||
Method *method = lookupSuperMethod(classType, index, &clazz);
|
|
||||||
if (method == NULL)
|
|
||||||
{
|
|
||||||
fprintf(clientOut, "err: method not found\n");
|
|
||||||
fflush(clientOut);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(clientOut, "method: %s->%s%s\n", clazz->descriptor, method->name, dexProtoGetMethodDescriptor(&method->prototype, &stringCache));
|
|
||||||
fflush(clientOut);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'P':
|
case 'P':
|
||||||
{
|
{
|
||||||
char *classType = strtok(NULL, " ");
|
char *classType = strtok(NULL, " ");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user