-
-
TaintDroid剖析之DVM变量级污点跟踪(下篇)
-
发表于: 2016-7-18 14:29 6885
-
struct ClassObject : Object { /* leave space for instance data; we could access fields directly if we freeze the definition of java/lang/Class */ #ifdef WITH_TAINT_TRACKING // x2 space for interleaved taint tags u4 instanceData[CLASS_FIELD_SLOTS*2]; #else u4 instanceData[CLASS_FIELD_SLOTS]; #endif /*WITH_TAINT_TRACKING*/
struct StaticField : Field { JValue value; /* initially set from DEX for primitives */ #ifdef WITH_TAINT_TRACKING Taint taint; #endif };
…… if (clazz->super != NULL) fieldOffset = clazz->super->objectSize; else fieldOffset = OFFSETOF_MEMBER(DataObject, instanceData); …… /*Start by moving all reference fields to the front */ for (i = 0; i < clazz->ifieldCount; i++) { InstField* pField = &clazz->ifields[i]; char c = pField->signature[0]; if (c != '[' && c != 'L') { while (j > i) { InstField* refField = &clazz->ifields[j--]; char rc = refField->signature[0]; if (rc == '[' || rc == 'L'] { swapField(pField, refField); c = rc; clazz->ifieldRefCount++; break; } } /* We may or may not have swapped a field.*/ } else { /* This is a reference field.*/ clazz->ifieldRefCount++; } /*If we've hit the end of the reference fields, break.*/ if (c != '[' && c != 'L') break; pField->byteOffset = fieldOffset; #ifdef WITH_TAINT_TRACKING fieldOffset += sizeof(u4) + sizeof(u4); /* interleaved tag */ #else fieldOffset += sizeof(u4); #endif LOGVV(" --- offset1 '%s'=%d", pField->name,pField->byteOffset); } …… /* Alignment is good, shuffle any double-wide fields forward, and finish assigning field offsets to all fields.*/ for ( ; i < clazz->ifieldCount; i++) { InstField* pField = &clazz->ifields[i]; char c = pField->signature[0]; if (c != 'D' && c != 'J') { while (j > i) { InstField* doubleField = &clazz->ifields[j--]; char rc = doubleField->signature[0]; if (rc == 'D' || rc == 'J') { swapField(pField, doubleField); c = rc; break; } } } else { } pField->byteOffset = fieldOffset; #ifdef WITH_TAINT_TRACKING fieldOffset += sizeof(u4) + sizeof(u4); /* room for tag */ if (c == 'J' || c == 'D') fieldOffset += sizeof(u4) + sizeof(u4); /* keep 64-bit aligned */ #else fieldOffset += sizeof(u4); if (c == 'J' || c == 'D') fieldOffset += sizeof(u4); #endif /* ndef WITH_TAINT_TRACKING */ }
struct ArrayObject : Object { /* number of elements; immutable after init */ u4 length; #ifdef WITH_TAINT_TRACKING Taint taint; #endif u8 contents[1]; };
static ArrayObject* allocArray(ClassObject* arrayClass, size_t length, size_t elemWidth, int allocFlags) { …… ArrayObject* newArray = (ArrayObject*)dvmMalloc(totalSize, allocFlags); if (newArray != NULL) { DVM_OBJECT_INIT(newArray, arrayClass); newArray->length = length; #ifdef WITH_TAINT_TRACKING newArray->taint.tag = TAINT_CLEAR; #endif dvmTrackAllocation(arrayClass, totalSize); } }
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)
赞赏记录
参与人
雪币
留言
时间
飘零丶
为你点赞~
2024-5-31 07:21
shinratensei
为你点赞~
2024-5-31 07:15
一笑人间万事
为你点赞~
2023-2-21 00:20
赞赏
他的文章
看原图
赞赏
雪币:
留言: