• Home
  • Raw
  • Download

Lines Matching refs:state

66 static inline u4 fileOffset(const CheckState* state, const void* ptr) {  in fileOffset()  argument
67 return ((const u1*) ptr) - state->fileStart; in fileOffset()
73 static inline void* filePointer(const CheckState* state, u4 offset) { in filePointer() argument
74 return (void*) (state->fileStart + offset); in filePointer()
85 static inline bool checkPtrRange(const CheckState* state, in checkPtrRange() argument
87 const void* fileStart = state->fileStart; in checkPtrRange()
88 const void* fileEnd = state->fileEnd; in checkPtrRange()
92 fileOffset(state, start), fileOffset(state, end)); in checkPtrRange()
108 const u1* _startPtr = (const u1*) filePointer(state, (_start)); \
109 const u1* _endPtr = (const u1*) filePointer(state, (_end)); \
110 if (!checkPtrRange(state, _startPtr, _endPtr, \
127 if (!checkPtrRange(state, (_start), (_end), #_start ".." #_end)) { \
142 !checkPtrRange(state, _start, _end, #_ptr)) { \
207 static bool verifyFieldDefiner(const CheckState* state, u4 definingClass, in verifyFieldDefiner() argument
209 const DexFieldId* field = dexGetFieldId(state->pDexFile, fieldIdx); in verifyFieldDefiner()
214 static bool verifyMethodDefiner(const CheckState* state, u4 definingClass, in verifyMethodDefiner() argument
216 const DexMethodId* meth = dexGetMethodId(state->pDexFile, methodIdx); in verifyMethodDefiner()
224 static size_t calcDefinedClassBitsSize(const CheckState* state) in calcDefinedClassBitsSize() argument
227 return (state->pHeader->typeIdsSize + 0x1f) >> 5; in calcDefinedClassBitsSize()
233 static bool setDefinedClassBit(const CheckState* state, u4 typeIdx) { in setDefinedClassBit() argument
236 u4* element = &state->pDefinedClassBits[arrayIdx]; in setDefinedClassBit()
247 static bool swapDexHeader(const CheckState* state, DexHeader* pHeader) in swapDexHeader() argument
297 static bool checkHeaderSection(const CheckState* state, u4 sectionOffset, in checkHeaderSection() argument
309 const DexHeader* pHeader = (const DexHeader*) filePointer(state, 0); in checkHeaderSection()
369 static bool swapMap(CheckState* state, DexMapList* pMap) in swapMap() argument
374 u4 dataItemsLeft = state->pHeader->dataSize; // See use below. in swapMap()
398 if (item->offset >= state->pHeader->fileSize) { in swapMap()
400 item->offset, state->pHeader->fileSize); in swapMap()
449 && ((state->pHeader->stringIdsOff != 0) in swapMap()
450 || (state->pHeader->stringIdsSize != 0))) { in swapMap()
456 && ((state->pHeader->typeIdsOff != 0) in swapMap()
457 || (state->pHeader->typeIdsSize != 0))) { in swapMap()
463 && ((state->pHeader->protoIdsOff != 0) in swapMap()
464 || (state->pHeader->protoIdsSize != 0))) { in swapMap()
470 && ((state->pHeader->fieldIdsOff != 0) in swapMap()
471 || (state->pHeader->fieldIdsSize != 0))) { in swapMap()
477 && ((state->pHeader->methodIdsOff != 0) in swapMap()
478 || (state->pHeader->methodIdsSize != 0))) { in swapMap()
484 && ((state->pHeader->classDefsOff != 0) in swapMap()
485 || (state->pHeader->classDefsSize != 0))) { in swapMap()
490 state->pDataMap = dexDataMapAlloc(dataItemCount); in swapMap()
491 if (state->pDataMap == NULL) { in swapMap()
500 static bool checkMapSection(const CheckState* state, u4 sectionOffset, in checkMapSection() argument
507 if (sectionOffset != state->pHeader->mapOff) { in checkMapSection()
509 sectionOffset, state->pHeader->mapOff); in checkMapSection()
513 const DexMapList* pMap = (const DexMapList*) filePointer(state, sectionOffset); in checkMapSection()
521 static void* swapStringIdItem(const CheckState* state, void* ptr) { in swapStringIdItem() argument
531 static void* crossVerifyStringIdItem(const CheckState* state, void* ptr) { in crossVerifyStringIdItem() argument
534 if (!dexDataMapVerify(state->pDataMap, in crossVerifyStringIdItem()
539 const DexStringId* item0 = (const DexStringId*) state->previousItem; in crossVerifyStringIdItem()
542 const char* s0 = dexGetStringData(state->pDexFile, item0); in crossVerifyStringIdItem()
543 const char* s1 = dexGetStringData(state->pDexFile, item); in crossVerifyStringIdItem()
554 static void* swapTypeIdItem(const CheckState* state, void* ptr) { in swapTypeIdItem() argument
558 SWAP_INDEX4(item->descriptorIdx, state->pHeader->stringIdsSize); in swapTypeIdItem()
564 static void* crossVerifyTypeIdItem(const CheckState* state, void* ptr) { in crossVerifyTypeIdItem() argument
567 dexStringById(state->pDexFile, item->descriptorIdx); in crossVerifyTypeIdItem()
574 const DexTypeId* item0 = (const DexTypeId*) state->previousItem; in crossVerifyTypeIdItem()
588 static void* swapProtoIdItem(const CheckState* state, void* ptr) { in swapProtoIdItem() argument
592 SWAP_INDEX4(item->shortyIdx, state->pHeader->stringIdsSize); in swapProtoIdItem()
593 SWAP_INDEX4(item->returnTypeIdx, state->pHeader->typeIdsSize); in swapProtoIdItem()
645 static void* crossVerifyProtoIdItem(const CheckState* state, void* ptr) { in crossVerifyProtoIdItem() argument
648 dexStringById(state->pDexFile, item->shortyIdx); in crossVerifyProtoIdItem()
650 if (!dexDataMapVerify0Ok(state->pDataMap, in crossVerifyProtoIdItem()
656 dexStringByTypeIdx(state->pDexFile, item->returnTypeIdx), in crossVerifyProtoIdItem()
661 u4 protoIdx = item - state->pDexFile->pProtoIds; in crossVerifyProtoIdItem()
662 DexProto proto = { state->pDexFile, protoIdx }; in crossVerifyProtoIdItem()
692 const DexProtoId* item0 = (const DexProtoId*) state->previousItem; in crossVerifyProtoIdItem()
700 DexProto proto0 = { state->pDexFile, protoIdx - 1 }; in crossVerifyProtoIdItem()
738 static void* swapFieldIdItem(const CheckState* state, void* ptr) { in swapFieldIdItem() argument
742 SWAP_INDEX2(item->classIdx, state->pHeader->typeIdsSize); in swapFieldIdItem()
743 SWAP_INDEX2(item->typeIdx, state->pHeader->typeIdsSize); in swapFieldIdItem()
744 SWAP_INDEX4(item->nameIdx, state->pHeader->stringIdsSize); in swapFieldIdItem()
750 static void* crossVerifyFieldIdItem(const CheckState* state, void* ptr) { in crossVerifyFieldIdItem() argument
754 s = dexStringByTypeIdx(state->pDexFile, item->classIdx); in crossVerifyFieldIdItem()
760 s = dexStringByTypeIdx(state->pDexFile, item->typeIdx); in crossVerifyFieldIdItem()
766 s = dexStringById(state->pDexFile, item->nameIdx); in crossVerifyFieldIdItem()
772 const DexFieldId* item0 = (const DexFieldId*) state->previousItem; in crossVerifyFieldIdItem()
810 static void* swapMethodIdItem(const CheckState* state, void* ptr) { in swapMethodIdItem() argument
814 SWAP_INDEX2(item->classIdx, state->pHeader->typeIdsSize); in swapMethodIdItem()
815 SWAP_INDEX2(item->protoIdx, state->pHeader->protoIdsSize); in swapMethodIdItem()
816 SWAP_INDEX4(item->nameIdx, state->pHeader->stringIdsSize); in swapMethodIdItem()
822 static void* crossVerifyMethodIdItem(const CheckState* state, void* ptr) { in crossVerifyMethodIdItem() argument
826 s = dexStringByTypeIdx(state->pDexFile, item->classIdx); in crossVerifyMethodIdItem()
832 s = dexStringById(state->pDexFile, item->nameIdx); in crossVerifyMethodIdItem()
838 const DexMethodId* item0 = (const DexMethodId*) state->previousItem; in crossVerifyMethodIdItem()
876 static void* swapClassDefItem(const CheckState* state, void* ptr) { in swapClassDefItem() argument
880 SWAP_INDEX4(item->classIdx, state->pHeader->typeIdsSize); in swapClassDefItem()
882 SWAP_INDEX4_OR_NOINDEX(item->superclassIdx, state->pHeader->typeIdsSize); in swapClassDefItem()
884 SWAP_INDEX4_OR_NOINDEX(item->sourceFileIdx, state->pHeader->stringIdsSize); in swapClassDefItem()
898 static u4 findFirstClassDataDefiner(const CheckState* state,
900 static u4 findFirstAnnotationsDirectoryDefiner(const CheckState* state,
905 static bool verifyClassDataIsForDef(const CheckState* state, u4 offset, in verifyClassDataIsForDef() argument
911 const u1* data = (const u1*) filePointer(state, offset); in verifyClassDataIsForDef()
924 u4 dataDefiner = findFirstClassDataDefiner(state, classData); in verifyClassDataIsForDef()
934 static bool verifyAnnotationsDirectoryIsForDef(const CheckState* state, in verifyAnnotationsDirectoryIsForDef() argument
941 (const DexAnnotationsDirectoryItem*) filePointer(state, offset); in verifyAnnotationsDirectoryIsForDef()
942 u4 annoDefiner = findFirstAnnotationsDirectoryDefiner(state, dir); in verifyAnnotationsDirectoryIsForDef()
948 static void* crossVerifyClassDefItem(const CheckState* state, void* ptr) { in crossVerifyClassDefItem() argument
951 const char* descriptor = dexStringByTypeIdx(state->pDexFile, classIdx); in crossVerifyClassDefItem()
958 if (setDefinedClassBit(state, classIdx)) { in crossVerifyClassDefItem()
964 dexDataMapVerify0Ok(state->pDataMap, in crossVerifyClassDefItem()
966 && dexDataMapVerify0Ok(state->pDataMap, in crossVerifyClassDefItem()
968 && dexDataMapVerify0Ok(state->pDataMap, in crossVerifyClassDefItem()
970 && dexDataMapVerify0Ok(state->pDataMap, in crossVerifyClassDefItem()
978 descriptor = dexStringByTypeIdx(state->pDexFile, item->superclassIdx); in crossVerifyClassDefItem()
986 dexGetInterfacesList(state->pDexFile, item); in crossVerifyClassDefItem()
996 descriptor = dexStringByTypeIdx(state->pDexFile, in crossVerifyClassDefItem()
1018 dexStringByTypeIdx(state->pDexFile, idx1)); in crossVerifyClassDefItem()
1025 if (!verifyClassDataIsForDef(state, item->classDataOff, item->classIdx)) { in crossVerifyClassDefItem()
1030 if (!verifyAnnotationsDirectoryIsForDef(state, item->annotationsOff, in crossVerifyClassDefItem()
1042 static u1* swapFieldAnnotations(const CheckState* state, u4 count, u1* addr) { in swapFieldAnnotations() argument
1050 SWAP_INDEX4(item->fieldIdx, state->pHeader->fieldIdsSize); in swapFieldAnnotations()
1071 static u1* swapMethodAnnotations(const CheckState* state, u4 count, u1* addr) { in swapMethodAnnotations() argument
1079 SWAP_INDEX4(item->methodIdx, state->pHeader->methodIdsSize); in swapMethodAnnotations()
1100 static u1* swapParameterAnnotations(const CheckState* state, u4 count, in swapParameterAnnotations() argument
1109 SWAP_INDEX4(item->methodIdx, state->pHeader->methodIdsSize); in swapParameterAnnotations()
1129 static void* swapAnnotationsDirectoryItem(const CheckState* state, void* ptr) { in swapAnnotationsDirectoryItem() argument
1141 addr = swapFieldAnnotations(state, item->fieldsSize, addr); in swapAnnotationsDirectoryItem()
1148 addr = swapMethodAnnotations(state, item->methodsSize, addr); in swapAnnotationsDirectoryItem()
1155 addr = swapParameterAnnotations(state, item->parametersSize, addr); in swapAnnotationsDirectoryItem()
1166 static const u1* crossVerifyFieldAnnotations(const CheckState* state, u4 count, in crossVerifyFieldAnnotations() argument
1171 if (!verifyFieldDefiner(state, definingClass, item->fieldIdx)) { in crossVerifyFieldAnnotations()
1174 if (!dexDataMapVerify(state->pDataMap, item->annotationsOff, in crossVerifyFieldAnnotations()
1186 static const u1* crossVerifyMethodAnnotations(const CheckState* state, in crossVerifyMethodAnnotations() argument
1191 if (!verifyMethodDefiner(state, definingClass, item->methodIdx)) { in crossVerifyMethodAnnotations()
1194 if (!dexDataMapVerify(state->pDataMap, item->annotationsOff, in crossVerifyMethodAnnotations()
1206 static const u1* crossVerifyParameterAnnotations(const CheckState* state, in crossVerifyParameterAnnotations() argument
1212 if (!verifyMethodDefiner(state, definingClass, item->methodIdx)) { in crossVerifyParameterAnnotations()
1215 if (!dexDataMapVerify(state->pDataMap, item->annotationsOff, in crossVerifyParameterAnnotations()
1228 static u4 findFirstAnnotationsDirectoryDefiner(const CheckState* state, in findFirstAnnotationsDirectoryDefiner() argument
1232 dexGetFieldAnnotations(state->pDexFile, dir); in findFirstAnnotationsDirectoryDefiner()
1234 dexGetFieldId(state->pDexFile, fields[0].fieldIdx); in findFirstAnnotationsDirectoryDefiner()
1240 dexGetMethodAnnotations(state->pDexFile, dir); in findFirstAnnotationsDirectoryDefiner()
1242 dexGetMethodId(state->pDexFile, methods[0].methodIdx); in findFirstAnnotationsDirectoryDefiner()
1248 dexGetParameterAnnotations(state->pDexFile, dir); in findFirstAnnotationsDirectoryDefiner()
1250 dexGetMethodId(state->pDexFile, parameters[0].methodIdx); in findFirstAnnotationsDirectoryDefiner()
1258 static void* crossVerifyAnnotationsDirectoryItem(const CheckState* state, in crossVerifyAnnotationsDirectoryItem() argument
1261 u4 definingClass = findFirstAnnotationsDirectoryDefiner(state, item); in crossVerifyAnnotationsDirectoryItem()
1263 if (!dexDataMapVerify0Ok(state->pDataMap, in crossVerifyAnnotationsDirectoryItem()
1271 addr = crossVerifyFieldAnnotations(state, item->fieldsSize, addr, in crossVerifyAnnotationsDirectoryItem()
1279 addr = crossVerifyMethodAnnotations(state, item->methodsSize, addr, in crossVerifyAnnotationsDirectoryItem()
1287 addr = crossVerifyParameterAnnotations(state, item->parametersSize, in crossVerifyAnnotationsDirectoryItem()
1298 static void* swapTypeList(const CheckState* state, void* ptr) in swapTypeList() argument
1311 SWAP_INDEX2(pType->typeIdx, state->pHeader->typeIdsSize); in swapTypeList()
1320 static void* swapAnnotationSetRefList(const CheckState* state, void* ptr) { in swapAnnotationSetRefList() argument
1340 static void* crossVerifyAnnotationSetRefList(const CheckState* state, in crossVerifyAnnotationSetRefList() argument
1347 if (!dexDataMapVerify0Ok(state->pDataMap, in crossVerifyAnnotationSetRefList()
1359 static void* swapAnnotationSetItem(const CheckState* state, void* ptr) { in swapAnnotationSetItem() argument
1386 static void* crossVerifyAnnotationSetItem(const CheckState* state, void* ptr) { in crossVerifyAnnotationSetItem() argument
1394 if (!dexDataMapVerify0Ok(state->pDataMap, in crossVerifyAnnotationSetItem()
1400 dexGetAnnotationItem(state->pDexFile, set, i); in crossVerifyAnnotationSetItem()
1418 static bool verifyFields(const CheckState* state, u4 size, in verifyFields() argument
1427 CHECK_INDEX(field->fieldIdx, state->pHeader->fieldIdsSize); in verifyFields()
1445 static bool verifyMethods(const CheckState* state, u4 size, in verifyMethods() argument
1452 CHECK_INDEX(method->methodIdx, state->pHeader->methodIdsSize); in verifyMethods()
1494 static bool verifyClassDataItem0(const CheckState* state, in verifyClassDataItem0() argument
1498 okay = verifyFields(state, classData->header.staticFieldsSize, in verifyClassDataItem0()
1506 verifyFields(state, classData->header.instanceFieldsSize, in verifyClassDataItem0()
1514 okay = verifyMethods(state, classData->header.directMethodsSize, in verifyClassDataItem0()
1522 okay = verifyMethods(state, classData->header.virtualMethodsSize, in verifyClassDataItem0()
1534 static void* intraVerifyClassDataItem(const CheckState* state, void* ptr) { in intraVerifyClassDataItem() argument
1536 DexClassData* classData = dexReadAndVerifyClassData(&data, state->fileEnd); in intraVerifyClassDataItem()
1543 bool okay = verifyClassDataItem0(state, classData); in intraVerifyClassDataItem()
1557 static u4 findFirstClassDataDefiner(const CheckState* state, in findFirstClassDataDefiner() argument
1561 const DexFieldId* field = dexGetFieldId(state->pDexFile, fieldIdx); in findFirstClassDataDefiner()
1567 const DexFieldId* field = dexGetFieldId(state->pDexFile, fieldIdx); in findFirstClassDataDefiner()
1573 const DexMethodId* meth = dexGetMethodId(state->pDexFile, methodIdx); in findFirstClassDataDefiner()
1579 const DexMethodId* meth = dexGetMethodId(state->pDexFile, methodIdx); in findFirstClassDataDefiner()
1587 static void* crossVerifyClassDataItem(const CheckState* state, void* ptr) { in crossVerifyClassDataItem() argument
1589 DexClassData* classData = dexReadAndVerifyClassData(&data, state->fileEnd); in crossVerifyClassDataItem()
1590 u4 definingClass = findFirstClassDataDefiner(state, classData); in crossVerifyClassDataItem()
1597 okay = verifyFieldDefiner(state, definingClass, field->fieldIdx); in crossVerifyClassDataItem()
1603 okay = verifyFieldDefiner(state, definingClass, field->fieldIdx); in crossVerifyClassDataItem()
1609 okay = dexDataMapVerify0Ok(state->pDataMap, meth->codeOff, in crossVerifyClassDataItem()
1611 && verifyMethodDefiner(state, definingClass, meth->methodIdx); in crossVerifyClassDataItem()
1617 okay = dexDataMapVerify0Ok(state->pDataMap, meth->codeOff, in crossVerifyClassDataItem()
1619 && verifyMethodDefiner(state, definingClass, meth->methodIdx); in crossVerifyClassDataItem()
1634 static u4 setHandlerOffsAndVerify(const CheckState* state, in setHandlerOffsAndVerify() argument
1636 const u1* fileEnd = state->fileEnd; in setHandlerOffsAndVerify()
1675 CHECK_INDEX(typeIdx, state->pHeader->typeIdsSize); in setHandlerOffsAndVerify()
1712 static void* swapTriesAndCatches(const CheckState* state, DexCode* code) { in swapTriesAndCatches() argument
1717 readAndVerifyUnsignedLeb128(&encodedPtr, state->fileEnd, &okay); in swapTriesAndCatches()
1730 u4 endOffset = setHandlerOffsAndVerify(state, code, in swapTriesAndCatches()
1787 static void* swapCodeItem(const CheckState* state, void* ptr) { in swapCodeItem() argument
1839 ptr = swapTriesAndCatches(state, item); in swapCodeItem()
1846 static void* intraVerifyStringDataItem(const CheckState* state, void* ptr) { in intraVerifyStringDataItem() argument
1847 const u1* fileEnd = state->fileEnd; in intraVerifyStringDataItem()
1947 static void* intraVerifyDebugInfoItem(const CheckState* state, void* ptr) { in intraVerifyDebugInfoItem() argument
1948 const u1* fileEnd = state->fileEnd; in intraVerifyDebugInfoItem()
1984 CHECK_INDEX(parameterName, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2017 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2023 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2049 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2055 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2061 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2070 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in intraVerifyDebugInfoItem()
2089 static const u1* verifyEncodedValue(const CheckState* state, const u1* data,
2091 static const u1* verifyEncodedAnnotation(const CheckState* state,
2096 static u4 readUnsignedLittleEndian(const CheckState* state, const u1** pData, in readUnsignedLittleEndian() argument
2114 static const u1* verifyEncodedArray(const CheckState* state, in verifyEncodedArray() argument
2117 u4 size = readAndVerifyUnsignedLeb128(&data, state->fileEnd, &okay); in verifyEncodedArray()
2125 data = verifyEncodedValue(state, data, crossVerify); in verifyEncodedArray()
2137 static const u1* verifyEncodedValue(const CheckState* state, in verifyEncodedValue() argument
2182 u4 idx = readUnsignedLittleEndian(state, &data, valueArg + 1); in verifyEncodedValue()
2183 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in verifyEncodedValue()
2191 u4 idx = readUnsignedLittleEndian(state, &data, valueArg + 1); in verifyEncodedValue()
2192 CHECK_INDEX(idx, state->pHeader->typeIdsSize); in verifyEncodedValue()
2201 u4 idx = readUnsignedLittleEndian(state, &data, valueArg + 1); in verifyEncodedValue()
2202 CHECK_INDEX(idx, state->pHeader->fieldIdsSize); in verifyEncodedValue()
2210 u4 idx = readUnsignedLittleEndian(state, &data, valueArg + 1); in verifyEncodedValue()
2211 CHECK_INDEX(idx, state->pHeader->methodIdsSize); in verifyEncodedValue()
2219 data = verifyEncodedArray(state, data, crossVerify); in verifyEncodedValue()
2227 data = verifyEncodedAnnotation(state, data, crossVerify); in verifyEncodedValue()
2257 static const u1* verifyEncodedAnnotation(const CheckState* state, in verifyEncodedAnnotation() argument
2259 const u1* fileEnd = state->fileEnd; in verifyEncodedAnnotation()
2268 CHECK_INDEX(idx, state->pHeader->typeIdsSize); in verifyEncodedAnnotation()
2271 const char* descriptor = dexStringByTypeIdx(state->pDexFile, idx); in verifyEncodedAnnotation()
2295 CHECK_INDEX(idx, state->pHeader->stringIdsSize); in verifyEncodedAnnotation()
2298 const char* name = dexStringById(state->pDexFile, idx); in verifyEncodedAnnotation()
2313 data = verifyEncodedValue(state, data, crossVerify); in verifyEncodedAnnotation()
2325 static void* intraVerifyEncodedArrayItem(const CheckState* state, void* ptr) { in intraVerifyEncodedArrayItem() argument
2326 return (void*) verifyEncodedArray(state, (const u1*) ptr, false); in intraVerifyEncodedArrayItem()
2330 static void* intraVerifyAnnotationItem(const CheckState* state, void* ptr) { in intraVerifyAnnotationItem() argument
2347 return (void*) verifyEncodedAnnotation(state, data, false); in intraVerifyAnnotationItem()
2351 static void* crossVerifyAnnotationItem(const CheckState* state, void* ptr) { in crossVerifyAnnotationItem() argument
2357 return (void*) verifyEncodedAnnotation(state, data, true); in crossVerifyAnnotationItem()
2366 typedef void* ItemVisitorFunction(const CheckState* state, void* ptr);
2373 static bool iterateSectionWithOptionalUpdate(CheckState* state, in iterateSectionWithOptionalUpdate() argument
2379 state->previousItem = NULL; in iterateSectionWithOptionalUpdate()
2383 u1* ptr = (u1*) filePointer(state, newOffset); in iterateSectionWithOptionalUpdate()
2386 ptr = (u1*) filePointer(state, offset); in iterateSectionWithOptionalUpdate()
2400 u1* newPtr = (u1*) func(state, ptr); in iterateSectionWithOptionalUpdate()
2401 newOffset = fileOffset(state, newPtr); in iterateSectionWithOptionalUpdate()
2408 if (newOffset > state->fileLen) { in iterateSectionWithOptionalUpdate()
2414 dexDataMapAdd(state->pDataMap, offset, mapType); in iterateSectionWithOptionalUpdate()
2417 state->previousItem = ptr; in iterateSectionWithOptionalUpdate()
2433 static bool iterateSection(CheckState* state, u4 offset, u4 count, in iterateSection() argument
2435 return iterateSectionWithOptionalUpdate(state, offset, count, func, in iterateSection()
2443 static bool checkBoundsAndIterateSection(CheckState* state, in checkBoundsAndIterateSection() argument
2458 return iterateSection(state, offset, count, func, alignment, nextOffset); in checkBoundsAndIterateSection()
2465 static bool iterateDataSection(CheckState* state, u4 offset, u4 count, in iterateDataSection() argument
2467 u4 dataStart = state->pHeader->dataOff; in iterateDataSection()
2468 u4 dataEnd = dataStart + state->pHeader->dataSize; in iterateDataSection()
2477 if (!iterateSectionWithOptionalUpdate(state, offset, count, func, in iterateDataSection()
2499 static bool swapEverythingButHeaderAndMap(CheckState* state, in swapEverythingButHeaderAndMap() argument
2513 const u1* ptr = (const u1*) filePointer(state, lastOffset); in swapEverythingButHeaderAndMap()
2540 okay = checkHeaderSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2545 okay = checkBoundsAndIterateSection(state, sectionOffset, in swapEverythingButHeaderAndMap()
2546 sectionCount, state->pHeader->stringIdsOff, in swapEverythingButHeaderAndMap()
2547 state->pHeader->stringIdsSize, swapStringIdItem, in swapEverythingButHeaderAndMap()
2552 okay = checkBoundsAndIterateSection(state, sectionOffset, in swapEverythingButHeaderAndMap()
2553 sectionCount, state->pHeader->typeIdsOff, in swapEverythingButHeaderAndMap()
2554 state->pHeader->typeIdsSize, swapTypeIdItem, in swapEverythingButHeaderAndMap()
2559 okay = checkBoundsAndIterateSection(state, sectionOffset, in swapEverythingButHeaderAndMap()
2560 sectionCount, state->pHeader->protoIdsOff, in swapEverythingButHeaderAndMap()
2561 state->pHeader->protoIdsSize, swapProtoIdItem, in swapEverythingButHeaderAndMap()
2566 okay = checkBoundsAndIterateSection(state, sectionOffset, in swapEverythingButHeaderAndMap()
2567 sectionCount, state->pHeader->fieldIdsOff, in swapEverythingButHeaderAndMap()
2568 state->pHeader->fieldIdsSize, swapFieldIdItem, in swapEverythingButHeaderAndMap()
2573 okay = checkBoundsAndIterateSection(state, sectionOffset, in swapEverythingButHeaderAndMap()
2574 sectionCount, state->pHeader->methodIdsOff, in swapEverythingButHeaderAndMap()
2575 state->pHeader->methodIdsSize, swapMethodIdItem, in swapEverythingButHeaderAndMap()
2580 okay = checkBoundsAndIterateSection(state, sectionOffset, in swapEverythingButHeaderAndMap()
2581 sectionCount, state->pHeader->classDefsOff, in swapEverythingButHeaderAndMap()
2582 state->pHeader->classDefsSize, swapClassDefItem, in swapEverythingButHeaderAndMap()
2591 okay = checkMapSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2596 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2601 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2607 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2612 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2618 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2623 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2629 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2635 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2641 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2647 okay = iterateDataSection(state, sectionOffset, sectionCount, in swapEverythingButHeaderAndMap()
2673 static bool crossVerifyEverything(CheckState* state, DexMapList* pMap) in crossVerifyEverything() argument
2696 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2701 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2706 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2711 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2716 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2722 size_t arraySize = calcDefinedClassBitsSize(state); in crossVerifyEverything()
2725 state->pDefinedClassBits = definedClassBits; in crossVerifyEverything()
2727 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2730 state->pDefinedClassBits = NULL; in crossVerifyEverything()
2734 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2739 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2744 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2749 okay = iterateSection(state, sectionOffset, sectionCount, in crossVerifyEverything()
2806 CheckState state; in dexSwapAndVerify() local
2809 memset(&state, 0, sizeof(state)); in dexSwapAndVerify()
2860 state.fileStart = addr; in dexSwapAndVerify()
2861 state.fileEnd = addr + len; in dexSwapAndVerify()
2862 state.fileLen = len; in dexSwapAndVerify()
2863 state.pDexFile = NULL; in dexSwapAndVerify()
2864 state.pDataMap = NULL; in dexSwapAndVerify()
2865 state.pDefinedClassBits = NULL; in dexSwapAndVerify()
2866 state.previousItem = NULL; in dexSwapAndVerify()
2871 okay = swapDexHeader(&state, pHeader); in dexSwapAndVerify()
2875 state.pHeader = pHeader; in dexSwapAndVerify()
2897 okay = okay && swapMap(&state, pDexMap); in dexSwapAndVerify()
2898 okay = okay && swapEverythingButHeaderAndMap(&state, pDexMap); in dexSwapAndVerify()
2901 state.pDexFile = &dexFile; in dexSwapAndVerify()
2903 okay = okay && crossVerifyEverything(&state, pDexMap); in dexSwapAndVerify()
2914 if (state.pDataMap != NULL) { in dexSwapAndVerify()
2915 dexDataMapFree(state.pDataMap); in dexSwapAndVerify()