• Home
  • Raw
  • Download

Lines Matching refs:state

92 static inline u4 fileOffset(const CheckState* state, const void* ptr) {  in fileOffset()  argument
93 return ((const u1*) ptr) - state->fileStart; in fileOffset()
99 static inline void* filePointer(const CheckState* state, u4 offset) { in filePointer() argument
100 return (void*) (state->fileStart + offset); in filePointer()
111 static inline bool checkPtrRange(const CheckState* state, in checkPtrRange() argument
113 const void* fileStart = state->fileStart; in checkPtrRange()
114 const void* fileEnd = state->fileEnd; in checkPtrRange()
118 fileOffset(state, start), fileOffset(state, end)); in checkPtrRange()
134 const u1* _startPtr = (const u1*) filePointer(state, (_start)); \
135 const u1* _endPtr = (const u1*) filePointer(state, (_end)); \
136 if (!checkPtrRange(state, _startPtr, _endPtr, \
153 if (!checkPtrRange(state, (_start), (_end), #_start ".." #_end)) { \
168 !checkPtrRange(state, _start, _end, #_ptr)) { \
233 static bool verifyFieldDefiner(const CheckState* state, u4 definingClass, in verifyFieldDefiner() argument
235 const DexFieldId* field = dexGetFieldId(state->pDexFile, fieldIdx); in verifyFieldDefiner()
240 static bool verifyMethodDefiner(const CheckState* state, u4 definingClass, in verifyMethodDefiner() argument
242 const DexMethodId* meth = dexGetMethodId(state->pDexFile, methodIdx); in verifyMethodDefiner()
250 static size_t calcDefinedClassBitsSize(const CheckState* state) in calcDefinedClassBitsSize() argument
253 return (state->pHeader->typeIdsSize + 0x1f) >> 5; in calcDefinedClassBitsSize()
259 static bool setDefinedClassBit(const CheckState* state, u4 typeIdx) { in setDefinedClassBit() argument
262 u4* element = &state->pDefinedClassBits[arrayIdx]; in setDefinedClassBit()
273 static bool swapDexHeader(const CheckState* state, DexHeader* pHeader) in swapDexHeader() argument
323 static bool checkHeaderSection(const CheckState* state, u4 sectionOffset, in checkHeaderSection() argument
335 const DexHeader* pHeader = (const DexHeader*) filePointer(state, 0); in checkHeaderSection()
395 static bool swapMap(CheckState* state, DexMapList* pMap) in swapMap() argument
400 u4 dataItemsLeft = state->pHeader->dataSize; // See use below. in swapMap()
424 if (item->offset >= state->pHeader->fileSize) { in swapMap()
426 item->offset, state->pHeader->fileSize); in swapMap()
475 && ((state->pHeader->stringIdsOff != 0) in swapMap()
476 || (state->pHeader->stringIdsSize != 0))) { in swapMap()
482 && ((state->pHeader->typeIdsOff != 0) in swapMap()
483 || (state->pHeader->typeIdsSize != 0))) { in swapMap()
489 && ((state->pHeader->protoIdsOff != 0) in swapMap()
490 || (state->pHeader->protoIdsSize != 0))) { in swapMap()
496 && ((state->pHeader->fieldIdsOff != 0) in swapMap()
497 || (state->pHeader->fieldIdsSize != 0))) { in swapMap()
503 && ((state->pHeader->methodIdsOff != 0) in swapMap()
504 || (state->pHeader->methodIdsSize != 0))) { in swapMap()
510 && ((state->pHeader->classDefsOff != 0) in swapMap()
511 || (state->pHeader->classDefsSize != 0))) { in swapMap()
516 state->pDataMap = dexDataMapAlloc(dataItemCount); in swapMap()
517 if (state->pDataMap == NULL) { in swapMap()
526 static bool checkMapSection(const CheckState* state, u4 sectionOffset, in checkMapSection() argument
533 if (sectionOffset != state->pHeader->mapOff) { in checkMapSection()
535 sectionOffset, state->pHeader->mapOff); in checkMapSection()
539 const DexMapList* pMap = (const DexMapList*) filePointer(state, sectionOffset); in checkMapSection()
547 static void* swapStringIdItem(const CheckState* state, void* ptr) { in swapStringIdItem() argument
557 static void* crossVerifyStringIdItem(const CheckState* state, void* ptr) { in crossVerifyStringIdItem() argument
560 if (!dexDataMapVerify(state->pDataMap, in crossVerifyStringIdItem()
565 const DexStringId* item0 = (const DexStringId*) state->previousItem; in crossVerifyStringIdItem()
568 const char* s0 = dexGetStringData(state->pDexFile, item0); in crossVerifyStringIdItem()
569 const char* s1 = dexGetStringData(state->pDexFile, item); in crossVerifyStringIdItem()
580 static void* swapTypeIdItem(const CheckState* state, void* ptr) { in swapTypeIdItem() argument
584 SWAP_INDEX4(item->descriptorIdx, state->pHeader->stringIdsSize); in swapTypeIdItem()
590 static void* crossVerifyTypeIdItem(const CheckState* state, void* ptr) { in crossVerifyTypeIdItem() argument
593 dexStringById(state->pDexFile, item->descriptorIdx); in crossVerifyTypeIdItem()
600 const DexTypeId* item0 = (const DexTypeId*) state->previousItem; in crossVerifyTypeIdItem()
614 static void* swapProtoIdItem(const CheckState* state, void* ptr) { in swapProtoIdItem() argument
618 SWAP_INDEX4(item->shortyIdx, state->pHeader->stringIdsSize); in swapProtoIdItem()
619 SWAP_INDEX4(item->returnTypeIdx, state->pHeader->typeIdsSize); in swapProtoIdItem()
671 static void* crossVerifyProtoIdItem(const CheckState* state, void* ptr) { in crossVerifyProtoIdItem() argument
674 dexStringById(state->pDexFile, item->shortyIdx); in crossVerifyProtoIdItem()
676 if (!dexDataMapVerify0Ok(state->pDataMap, in crossVerifyProtoIdItem()
682 dexStringByTypeIdx(state->pDexFile, item->returnTypeIdx), in crossVerifyProtoIdItem()
687 u4 protoIdx = item - state->pDexFile->pProtoIds; in crossVerifyProtoIdItem()
688 DexProto proto = { state->pDexFile, protoIdx }; in crossVerifyProtoIdItem()
718 const DexProtoId* item0 = (const DexProtoId*) state->previousItem; in crossVerifyProtoIdItem()
726 DexProto proto0 = { state->pDexFile, protoIdx - 1 }; in crossVerifyProtoIdItem()
764 static void* swapFieldIdItem(const CheckState* state, void* ptr) { in swapFieldIdItem() argument
768 SWAP_INDEX2(item->classIdx, state->pHeader->typeIdsSize); in swapFieldIdItem()
769 SWAP_INDEX2(item->typeIdx, state->pHeader->typeIdsSize); in swapFieldIdItem()
770 SWAP_INDEX4(item->nameIdx, state->pHeader->stringIdsSize); in swapFieldIdItem()
776 static void* crossVerifyFieldIdItem(const CheckState* state, void* ptr) { in crossVerifyFieldIdItem() argument
780 s = dexStringByTypeIdx(state->pDexFile, item->classIdx); in crossVerifyFieldIdItem()
786 s = dexStringByTypeIdx(state->pDexFile, item->typeIdx); in crossVerifyFieldIdItem()
792 s = dexStringById(state->pDexFile, item->nameIdx); in crossVerifyFieldIdItem()
798 const DexFieldId* item0 = (const DexFieldId*) state->previousItem; in crossVerifyFieldIdItem()
836 static void* swapMethodIdItem(const CheckState* state, void* ptr) { in swapMethodIdItem() argument
840 SWAP_INDEX2(item->classIdx, state->pHeader->typeIdsSize); in swapMethodIdItem()
841 SWAP_INDEX2(item->protoIdx, state->pHeader->protoIdsSize); in swapMethodIdItem()
842 SWAP_INDEX4(item->nameIdx, state->pHeader->stringIdsSize); in swapMethodIdItem()
848 static void* crossVerifyMethodIdItem(const CheckState* state, void* ptr) { in crossVerifyMethodIdItem() argument
852 s = dexStringByTypeIdx(state->pDexFile, item->classIdx); in crossVerifyMethodIdItem()
858 s = dexStringById(state->pDexFile, item->nameIdx); in crossVerifyMethodIdItem()
864 const DexMethodId* item0 = (const DexMethodId*) state->previousItem; in crossVerifyMethodIdItem()
902 static void* swapClassDefItem(const CheckState* state, void* ptr) { in swapClassDefItem() argument
906 SWAP_INDEX4(item->classIdx, state->pHeader->typeIdsSize); in swapClassDefItem()
908 SWAP_INDEX4_OR_NOINDEX(item->superclassIdx, state->pHeader->typeIdsSize); in swapClassDefItem()
910 SWAP_INDEX4_OR_NOINDEX(item->sourceFileIdx, state->pHeader->stringIdsSize); in swapClassDefItem()
918 static u4 findFirstClassDataDefiner(const CheckState* state,
920 static u4 findFirstAnnotationsDirectoryDefiner(const CheckState* state,
925 static bool verifyClassDataIsForDef(const CheckState* state, u4 offset, in verifyClassDataIsForDef() argument
931 const u1* data = (const u1*) filePointer(state, offset); in verifyClassDataIsForDef()
944 u4 dataDefiner = findFirstClassDataDefiner(state, classData); in verifyClassDataIsForDef()
954 static bool verifyAnnotationsDirectoryIsForDef(const CheckState* state, in verifyAnnotationsDirectoryIsForDef() argument
961 (const DexAnnotationsDirectoryItem*) filePointer(state, offset); in verifyAnnotationsDirectoryIsForDef()
962 u4 annoDefiner = findFirstAnnotationsDirectoryDefiner(state, dir); in verifyAnnotationsDirectoryIsForDef()
968 static void* crossVerifyClassDefItem(const CheckState* state, void* ptr) { in crossVerifyClassDefItem() argument
971 const char* descriptor = dexStringByTypeIdx(state->pDexFile, classIdx); in crossVerifyClassDefItem()
978 if (setDefinedClassBit(state, classIdx)) { in crossVerifyClassDefItem()
984 dexDataMapVerify0Ok(state->pDataMap, in crossVerifyClassDefItem()
986 && dexDataMapVerify0Ok(state->pDataMap, in crossVerifyClassDefItem()
988 && dexDataMapVerify0Ok(state->pDataMap, in crossVerifyClassDefItem()
990 && dexDataMapVerify0Ok(state->pDataMap, in crossVerifyClassDefItem()
998 descriptor = dexStringByTypeIdx(state->pDexFile, item->superclassIdx); in crossVerifyClassDefItem()
1006 dexGetInterfacesList(state->pDexFile, item); in crossVerifyClassDefItem()
1016 descriptor = dexStringByTypeIdx(state->pDexFile, in crossVerifyClassDefItem()
1038 dexStringByTypeIdx(state->pDexFile, idx1)); in crossVerifyClassDefItem()
1045 if (!verifyClassDataIsForDef(state, item->classDataOff, item->classIdx)) { in crossVerifyClassDefItem()
1050 if (!verifyAnnotationsDirectoryIsForDef(state, item->annotationsOff, in crossVerifyClassDefItem()
1062 static u1* swapFieldAnnotations(const CheckState* state, u4 count, u1* addr) { in swapFieldAnnotations() argument
1070 SWAP_INDEX4(item->fieldIdx, state->pHeader->fieldIdsSize); in swapFieldAnnotations()
1091 static u1* swapMethodAnnotations(const CheckState* state, u4 count, u1* addr) { in swapMethodAnnotations() argument
1099 SWAP_INDEX4(item->methodIdx, state->pHeader->methodIdsSize); in swapMethodAnnotations()
1120 static u1* swapParameterAnnotations(const CheckState* state, u4 count, in swapParameterAnnotations() argument
1129 SWAP_INDEX4(item->methodIdx, state->pHeader->methodIdsSize); in swapParameterAnnotations()
1149 static void* swapAnnotationsDirectoryItem(const CheckState* state, void* ptr) { in swapAnnotationsDirectoryItem() argument
1161 addr = swapFieldAnnotations(state, item->fieldsSize, addr); in swapAnnotationsDirectoryItem()
1168 addr = swapMethodAnnotations(state, item->methodsSize, addr); in swapAnnotationsDirectoryItem()
1175 addr = swapParameterAnnotations(state, item->parametersSize, addr); in swapAnnotationsDirectoryItem()
1186 static const u1* crossVerifyFieldAnnotations(const CheckState* state, u4 count, in crossVerifyFieldAnnotations() argument
1191 if (!verifyFieldDefiner(state, definingClass, item->fieldIdx)) { in crossVerifyFieldAnnotations()
1194 if (!dexDataMapVerify(state->pDataMap, item->annotationsOff, in crossVerifyFieldAnnotations()
1206 static const u1* crossVerifyMethodAnnotations(const CheckState* state, in crossVerifyMethodAnnotations() argument
1211 if (!verifyMethodDefiner(state, definingClass, item->methodIdx)) { in crossVerifyMethodAnnotations()
1214 if (!dexDataMapVerify(state->pDataMap, item->annotationsOff, in crossVerifyMethodAnnotations()
1226 static const u1* crossVerifyParameterAnnotations(const CheckState* state, in crossVerifyParameterAnnotations() argument
1232 if (!verifyMethodDefiner(state, definingClass, item->methodIdx)) { in crossVerifyParameterAnnotations()
1235 if (!dexDataMapVerify(state->pDataMap, item->annotationsOff, in crossVerifyParameterAnnotations()
1248 static u4 findFirstAnnotationsDirectoryDefiner(const CheckState* state, in findFirstAnnotationsDirectoryDefiner() argument
1252 dexGetFieldAnnotations(state->pDexFile, dir); in findFirstAnnotationsDirectoryDefiner()
1254 dexGetFieldId(state->pDexFile, fields[0].fieldIdx); in findFirstAnnotationsDirectoryDefiner()
1260 dexGetMethodAnnotations(state->pDexFile, dir); in findFirstAnnotationsDirectoryDefiner()
1262 dexGetMethodId(state->pDexFile, methods[0].methodIdx); in findFirstAnnotationsDirectoryDefiner()
1268 dexGetParameterAnnotations(state->pDexFile, dir); in findFirstAnnotationsDirectoryDefiner()
1270 dexGetMethodId(state->pDexFile, parameters[0].methodIdx); in findFirstAnnotationsDirectoryDefiner()
1278 static void* crossVerifyAnnotationsDirectoryItem(const CheckState* state, in crossVerifyAnnotationsDirectoryItem() argument
1281 u4 definingClass = findFirstAnnotationsDirectoryDefiner(state, item); in crossVerifyAnnotationsDirectoryItem()
1283 if (!dexDataMapVerify0Ok(state->pDataMap, in crossVerifyAnnotationsDirectoryItem()
1291 addr = crossVerifyFieldAnnotations(state, item->fieldsSize, addr, in crossVerifyAnnotationsDirectoryItem()
1299 addr = crossVerifyMethodAnnotations(state, item->methodsSize, addr, in crossVerifyAnnotationsDirectoryItem()
1307 addr = crossVerifyParameterAnnotations(state, item->parametersSize, in crossVerifyAnnotationsDirectoryItem()
1318 static void* swapTypeList(const CheckState* state, void* ptr) in swapTypeList() argument
1331 SWAP_INDEX2(pType->typeIdx, state->pHeader->typeIdsSize); in swapTypeList()
1340 static void* swapAnnotationSetRefList(const CheckState* state, void* ptr) { in swapAnnotationSetRefList() argument
1360 static void* crossVerifyAnnotationSetRefList(const CheckState* state, in crossVerifyAnnotationSetRefList() argument
1367 if (!dexDataMapVerify0Ok(state->pDataMap, in crossVerifyAnnotationSetRefList()
1379 static void* swapAnnotationSetItem(const CheckState* state, void* ptr) { in swapAnnotationSetItem() argument
1406 static void* crossVerifyAnnotationSetItem(const CheckState* state, void* ptr) { in crossVerifyAnnotationSetItem() argument
1414 if (!dexDataMapVerify0Ok(state->pDataMap, in crossVerifyAnnotationSetItem()
1420 dexGetAnnotationItem(state->pDexFile, set, i); in crossVerifyAnnotationSetItem()
1438 static bool verifyFields(const CheckState* state, u4 size, in verifyFields() argument
1447 CHECK_INDEX(field->fieldIdx, state->pHeader->fieldIdsSize); in verifyFields()
1464 static bool verifyMethods(const CheckState* state, u4 size, in verifyMethods() argument
1471 CHECK_INDEX(method->methodIdx, state->pHeader->methodIdsSize); in verifyMethods()
1508 static bool verifyClassDataItem0(const CheckState* state, in verifyClassDataItem0() argument
1512 okay = verifyFields(state, classData->header.staticFieldsSize, in verifyClassDataItem0()
1520 verifyFields(state, classData->header.instanceFieldsSize, in verifyClassDataItem0()
1528 okay = verifyMethods(state, classData->header.directMethodsSize, in verifyClassDataItem0()
1536 okay = verifyMethods(state, classData->header.virtualMethodsSize, in verifyClassDataItem0()
1548 static void* intraVerifyClassDataItem(const CheckState* state, void* ptr) { in intraVerifyClassDataItem() argument
1550 DexClassData* classData = dexReadAndVerifyClassData(&data, state->fileEnd); in intraVerifyClassDataItem()
1557 bool okay = verifyClassDataItem0(state, classData); in intraVerifyClassDataItem()
1571 static u4 findFirstClassDataDefiner(const CheckState* state, in findFirstClassDataDefiner() argument
1575 const DexFieldId* field = dexGetFieldId(state->pDexFile, fieldIdx); in findFirstClassDataDefiner()
1581 const DexFieldId* field = dexGetFieldId(state->pDexFile, fieldIdx); in findFirstClassDataDefiner()
1587 const DexMethodId* meth = dexGetMethodId(state->pDexFile, methodIdx); in findFirstClassDataDefiner()
1593 const DexMethodId* meth = dexGetMethodId(state->pDexFile, methodIdx); in findFirstClassDataDefiner()
1601 static void* crossVerifyClassDataItem(const CheckState* state, void* ptr) { in crossVerifyClassDataItem() argument
1603 DexClassData* classData = dexReadAndVerifyClassData(&data, state->fileEnd); in crossVerifyClassDataItem()
1604 u4 definingClass = findFirstClassDataDefiner(state, classData); in crossVerifyClassDataItem()
1611 okay = verifyFieldDefiner(state, definingClass, field->fieldIdx); in crossVerifyClassDataItem()
1617 okay = verifyFieldDefiner(state, definingClass, field->fieldIdx); in crossVerifyClassDataItem()
1623 okay = dexDataMapVerify0Ok(state->pDataMap, meth->codeOff, in crossVerifyClassDataItem()
1625 && verifyMethodDefiner(state, definingClass, meth->methodIdx); in crossVerifyClassDataItem()
1631 okay = dexDataMapVerify0Ok(state->pDataMap, meth->codeOff, in crossVerifyClassDataItem()
1633 && verifyMethodDefiner(state, definingClass, meth->methodIdx); in crossVerifyClassDataItem()
1648 static u4 setHandlerOffsAndVerify(const CheckState* state, in setHandlerOffsAndVerify() argument
1650 const u1* fileEnd = state->fileEnd; in setHandlerOffsAndVerify()
1689 CHECK_INDEX(typeIdx, state->pHeader->typeIdsSize); in setHandlerOffsAndVerify()
1726 static void* swapTriesAndCatches(const CheckState* state, DexCode* code) { in swapTriesAndCatches() argument
1731 readAndVerifyUnsignedLeb128(&encodedPtr, state->fileEnd, &okay); in swapTriesAndCatches()
1744 u4 endOffset = setHandlerOffsAndVerify(state, code, in swapTriesAndCatches()
1801 static void* swapCodeItem(const CheckState* state, void* ptr) { in swapCodeItem() argument
1853 ptr = swapTriesAndCatches(state, item); in swapCodeItem()
1860 static void* intraVerifyStringDataItem(const CheckState* state, void* ptr) { in intraVerifyStringDataItem() argument
1861 const u1* fileEnd = state->fileEnd; in intraVerifyStringDataItem()
1961 static void* intraVerifyDebugInfoItem(const CheckState* state, void* ptr) { in intraVerifyDebugInfoItem() argument
1962 const u1* fileEnd = state->fileEnd; in intraVerifyDebugInfoItem()
1998 CHECK_INDEX(parameterName, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2031 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2037 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2063 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2069 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2075 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2084 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2103 static const u1* verifyEncodedValue(const CheckState* state, const u1* data,
2105 static const u1* verifyEncodedAnnotation(const CheckState* state,
2110 static u4 readUnsignedLittleEndian(const CheckState* state, const u1** pData, in readUnsignedLittleEndian() argument
2128 static const u1* verifyEncodedArray(const CheckState* state, in verifyEncodedArray() argument
2131 u4 size = readAndVerifyUnsignedLeb128(&data, state->fileEnd, &okay); in verifyEncodedArray()
2139 data = verifyEncodedValue(state, data, crossVerify); in verifyEncodedArray()
2151 static const u1* verifyEncodedValue(const CheckState* state, in verifyEncodedValue() argument
2196 u4 idx = readUnsignedLittleEndian(state, &data, valueArg + 1); in verifyEncodedValue()
2197 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in verifyEncodedValue()
2205 u4 idx = readUnsignedLittleEndian(state, &data, valueArg + 1); in verifyEncodedValue()
2206 CHECK_INDEX(idx, state->pHeader->typeIdsSize); in verifyEncodedValue()
2215 u4 idx = readUnsignedLittleEndian(state, &data, valueArg + 1); in verifyEncodedValue()
2216 CHECK_INDEX(idx, state->pHeader->fieldIdsSize); in verifyEncodedValue()
2224 u4 idx = readUnsignedLittleEndian(state, &data, valueArg + 1); in verifyEncodedValue()
2225 CHECK_INDEX(idx, state->pHeader->methodIdsSize); in verifyEncodedValue()
2233 data = verifyEncodedArray(state, data, crossVerify); in verifyEncodedValue()
2241 data = verifyEncodedAnnotation(state, data, crossVerify); in verifyEncodedValue()
2271 static const u1* verifyEncodedAnnotation(const CheckState* state, in verifyEncodedAnnotation() argument
2273 const u1* fileEnd = state->fileEnd; in verifyEncodedAnnotation()
2282 CHECK_INDEX(idx, state->pHeader->typeIdsSize); in verifyEncodedAnnotation()
2285 const char* descriptor = dexStringByTypeIdx(state->pDexFile, idx); in verifyEncodedAnnotation()
2309 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in verifyEncodedAnnotation()
2312 const char* name = dexStringById(state->pDexFile, idx); in verifyEncodedAnnotation()
2327 data = verifyEncodedValue(state, data, crossVerify); in verifyEncodedAnnotation()
2339 static void* intraVerifyEncodedArrayItem(const CheckState* state, void* ptr) { in intraVerifyEncodedArrayItem() argument
2340 return (void*) verifyEncodedArray(state, (const u1*) ptr, false); in intraVerifyEncodedArrayItem()
2344 static void* intraVerifyAnnotationItem(const CheckState* state, void* ptr) { in intraVerifyAnnotationItem() argument
2361 return (void*) verifyEncodedAnnotation(state, data, false); in intraVerifyAnnotationItem()
2365 static void* crossVerifyAnnotationItem(const CheckState* state, void* ptr) { in crossVerifyAnnotationItem() argument
2371 return (void*) verifyEncodedAnnotation(state, data, true); in crossVerifyAnnotationItem()
2380 typedef void* ItemVisitorFunction(const CheckState* state, void* ptr);
2387 static bool iterateSectionWithOptionalUpdate(CheckState* state, in iterateSectionWithOptionalUpdate() argument
2393 state->previousItem = NULL; in iterateSectionWithOptionalUpdate()
2397 u1* ptr = (u1*) filePointer(state, newOffset); in iterateSectionWithOptionalUpdate()
2400 ptr = (u1*) filePointer(state, offset); in iterateSectionWithOptionalUpdate()
2414 u1* newPtr = (u1*) func(state, ptr); in iterateSectionWithOptionalUpdate()
2415 newOffset = fileOffset(state, newPtr); in iterateSectionWithOptionalUpdate()
2422 if (newOffset > state->fileLen) { in iterateSectionWithOptionalUpdate()
2428 dexDataMapAdd(state->pDataMap, offset, mapType); in iterateSectionWithOptionalUpdate()
2431 state->previousItem = ptr; in iterateSectionWithOptionalUpdate()
2447 static bool iterateSection(CheckState* state, u4 offset, u4 count, in iterateSection() argument
2449 return iterateSectionWithOptionalUpdate(state, offset, count, func, in iterateSection()
2457 static bool checkBoundsAndIterateSection(CheckState* state, in checkBoundsAndIterateSection() argument
2472 return iterateSection(state, offset, count, func, alignment, nextOffset); in checkBoundsAndIterateSection()
2479 static bool iterateDataSection(CheckState* state, u4 offset, u4 count, in iterateDataSection() argument
2481 u4 dataStart = state->pHeader->dataOff; in iterateDataSection()
2482 u4 dataEnd = dataStart + state->pHeader->dataSize; in iterateDataSection()
2491 if (!iterateSectionWithOptionalUpdate(state, offset, count, func, in iterateDataSection()
2513 static bool swapEverythingButHeaderAndMap(CheckState* state, in swapEverythingButHeaderAndMap() argument
2527 const u1* ptr = (const u1*) filePointer(state, lastOffset); in swapEverythingButHeaderAndMap()
2554 okay = checkHeaderSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2559 okay = checkBoundsAndIterateSection(state, sectionOffset, in swapEverythingButHeaderAndMap()
2560 sectionCount, state->pHeader->stringIdsOff, in swapEverythingButHeaderAndMap()
2561 state->pHeader->stringIdsSize, swapStringIdItem, in swapEverythingButHeaderAndMap()
2566 okay = checkBoundsAndIterateSection(state, sectionOffset, in swapEverythingButHeaderAndMap()
2567 sectionCount, state->pHeader->typeIdsOff, in swapEverythingButHeaderAndMap()
2568 state->pHeader->typeIdsSize, swapTypeIdItem, in swapEverythingButHeaderAndMap()
2573 okay = checkBoundsAndIterateSection(state, sectionOffset, in swapEverythingButHeaderAndMap()
2574 sectionCount, state->pHeader->protoIdsOff, in swapEverythingButHeaderAndMap()
2575 state->pHeader->protoIdsSize, swapProtoIdItem, in swapEverythingButHeaderAndMap()
2580 okay = checkBoundsAndIterateSection(state, sectionOffset, in swapEverythingButHeaderAndMap()
2581 sectionCount, state->pHeader->fieldIdsOff, in swapEverythingButHeaderAndMap()
2582 state->pHeader->fieldIdsSize, swapFieldIdItem, in swapEverythingButHeaderAndMap()
2587 okay = checkBoundsAndIterateSection(state, sectionOffset, in swapEverythingButHeaderAndMap()
2588 sectionCount, state->pHeader->methodIdsOff, in swapEverythingButHeaderAndMap()
2589 state->pHeader->methodIdsSize, swapMethodIdItem, in swapEverythingButHeaderAndMap()
2594 okay = checkBoundsAndIterateSection(state, sectionOffset, in swapEverythingButHeaderAndMap()
2595 sectionCount, state->pHeader->classDefsOff, in swapEverythingButHeaderAndMap()
2596 state->pHeader->classDefsSize, swapClassDefItem, in swapEverythingButHeaderAndMap()
2605 okay = checkMapSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2610 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2615 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2621 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2626 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2632 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2637 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2643 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2649 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2655 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2661 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2687 static bool crossVerifyEverything(CheckState* state, DexMapList* pMap) in crossVerifyEverything() argument
2710 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2715 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2720 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2725 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2730 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2736 size_t arraySize = calcDefinedClassBitsSize(state); in crossVerifyEverything()
2739 state->pDefinedClassBits = definedClassBits; in crossVerifyEverything()
2741 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2744 state->pDefinedClassBits = NULL; in crossVerifyEverything()
2748 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2753 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2758 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2763 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2820 CheckState state; in dexSwapAndVerify() local
2823 memset(&state, 0, sizeof(state)); in dexSwapAndVerify()
2874 state.fileStart = addr; in dexSwapAndVerify()
2875 state.fileEnd = addr + len; in dexSwapAndVerify()
2876 state.fileLen = len; in dexSwapAndVerify()
2877 state.pDexFile = NULL; in dexSwapAndVerify()
2878 state.pDataMap = NULL; in dexSwapAndVerify()
2879 state.pDefinedClassBits = NULL; in dexSwapAndVerify()
2880 state.previousItem = NULL; in dexSwapAndVerify()
2885 okay = swapDexHeader(&state, pHeader); in dexSwapAndVerify()
2889 state.pHeader = pHeader; in dexSwapAndVerify()
2911 okay = okay && swapMap(&state, pDexMap); in dexSwapAndVerify()
2912 okay = okay && swapEverythingButHeaderAndMap(&state, pDexMap); in dexSwapAndVerify()
2915 state.pDexFile = &dexFile; in dexSwapAndVerify()
2917 okay = okay && crossVerifyEverything(&state, pDexMap); in dexSwapAndVerify()
2928 if (state.pDataMap != NULL) { in dexSwapAndVerify()
2929 dexDataMapFree(state.pDataMap); in dexSwapAndVerify()