MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / CheckClassDataItemMethod

Method CheckClassDataItemMethod

Bcore/src/main/cpp/dex/dex_file_verifier.cc:672–737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

670}
671
672bool DexFileVerifier::CheckClassDataItemMethod(uint32_t idx,
673 uint32_t access_flags,
674 uint32_t class_access_flags,
675 dex::TypeIndex class_type_index,
676 uint32_t code_offset,
677 std::unordered_set<uint32_t>* direct_method_indexes,
678 bool expect_direct) {
679 DCHECK(direct_method_indexes != nullptr);
680 // Check for overflow.
681 if (!CheckIndex(idx, header_->method_ids_size_, "class_data_item method_idx")) {
682 return false;
683 }
684
685 // Check that it's the right class.
686 dex::TypeIndex my_class_index =
687 (reinterpret_cast<const DexFile::MethodId*>(begin_ + header_->method_ids_off_) + idx)->
688 class_idx_;
689 if (class_type_index != my_class_index) {
690 ErrorStringPrintf("Method's class index unexpected, %" PRIu16 " vs %" PRIu16,
691 my_class_index.index_,
692 class_type_index.index_);
693 return false;
694 }
695
696 // Check that it's not defined as both direct and virtual.
697 if (expect_direct) {
698 direct_method_indexes->insert(idx);
699 } else if (direct_method_indexes->find(idx) != direct_method_indexes->end()) {
700 ErrorStringPrintf("Found virtual method with same index as direct method: %d", idx);
701 return false;
702 }
703
704 std::string error_msg;
705 const char* method_name;
706 if (!FindMethodName(idx, begin_, header_, &method_name, &error_msg)) {
707 ErrorStringPrintf("%s", error_msg.c_str());
708 return false;
709 }
710
711 uint32_t constructor_flags_by_name = 0;
712 if (!GetConstructorFlagsForMethodName(method_name, &constructor_flags_by_name)) {
713 ErrorStringPrintf("Bad method name: %s", method_name);
714 return false;
715 }
716
717 bool has_code = (code_offset != 0);
718 if (!CheckMethodAccessFlags(idx,
719 access_flags,
720 class_access_flags,
721 constructor_flags_by_name,
722 has_code,
723 expect_direct,
724 &error_msg)) {
725 ErrorStringPrintf("%s", error_msg.c_str());
726 return false;
727 }
728
729 if (constructor_flags_by_name != 0) {

Callers

nothing calls this directly

Calls 6

FindMethodNameFunction · 0.85
c_strMethod · 0.80
insertMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected