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

Function fixCodeItem

Bcore/src/main/cpp/DexDump.cpp:173–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173void fixCodeItem(JNIEnv *env, const art_lkchan::DexFile *dex_file_, size_t begin) {
174 for (size_t classdef_ctr = 0; classdef_ctr < dex_file_->NumClassDefs(); ++classdef_ctr) {
175 const art_lkchan::DexFile::ClassDef &cd = dex_file_->GetClassDef(classdef_ctr);
176 const uint8_t *class_data = dex_file_->GetClassData(cd);
177 auto &classTypeId = dex_file_->GetTypeId(cd.class_idx_);
178 std::string class_name = dex_file_->GetTypeDescriptor(classTypeId);
179
180 if (class_data != nullptr) {
181 art_lkchan::ClassDataItemIterator cdit(*dex_file_, class_data);
182 cdit.SkipAllFields();
183 while (cdit.HasNextMethod()) {
184 const art_lkchan::DexFile::MethodId &method_id_item = dex_file_->GetMethodId(
185 cdit.GetMemberIndex());
186 auto method_name = dex_file_->GetMethodName(method_id_item);
187 auto method_signature = dex_file_->GetMethodSignature(
188 method_id_item).ToString().c_str();
189 auto java_method = VmCore::findMethod(env, class_name.c_str(), method_name,
190 method_signature);
191 if (java_method) {
192 auto artMethod = ArtM::GetArtMethod(env, java_method);
193 const art_lkchan::DexFile::CodeItem *orig_code_item = cdit.GetMethodCodeItem();
194 if (cdit.GetMethodCodeItemOffset() && orig_code_item) {
195 auto codeItemSize = dex_file_->GetCodeItemSize(*orig_code_item);
196 auto new_code_item =
197 begin + ArtM::GetArtMethodDexCodeItemOffset(artMethod);
198 memcpy((void *) orig_code_item,
199 (void *) new_code_item,
200 codeItemSize);
201 }
202 } else {
203 env->ExceptionClear();
204 }
205 cdit.Next();
206 }
207 }
208 }
209}
210
211void DexDump::cookieDumpDex(JNIEnv *env, jlong cookie, jstring dir, jboolean fix) {
212 if (beginOffset == -2) {

Callers 1

cookieDumpDexMethod · 0.85

Calls 14

NumClassDefsMethod · 0.80
GetClassDataMethod · 0.80
GetTypeDescriptorMethod · 0.80
SkipAllFieldsMethod · 0.80
HasNextMethodMethod · 0.80
GetMemberIndexMethod · 0.80
GetMethodNameMethod · 0.80
c_strMethod · 0.80
GetMethodSignatureMethod · 0.80
GetMethodCodeItemMethod · 0.80
ToStringMethod · 0.45

Tested by

no test coverage detected