worawit / blutter

Flutter Mobile Application Reverse Engineering Tool
MIT License
752 stars 128 forks source link

undefined CSREG_DART_HEAP #69

Open Vonggg opened 1 month ago

Vonggg commented 1 month ago

─$ python3 blutter.py /home/von/桌面/lib/arm64-v8a output --rebuild Dart version: 2.19.6, Snapshot: adb4292f3ec25074ca70abcd2d5c7251, Target: android arm64 flags: product no-code_comments no-dwarf_stack_traces_mode no-lazy_dispatchers dedup_instructions no-asserts arm android no-compressed-pointers null-safety -- Configuring done (0.1s) -- Generating done (0.0s) -- Build files have been written to: /home/von/桌面/blutter/build/blutter_dartvm2.19.6_android_arm64_no-compressed-ptrs [2/6] Building CXX object CMakeFile...rs.dir/src/CodeAnalyzer_arm64.cpp.o FAILED: CMakeFiles/blutter_dartvm2.19.6_android_arm64_no-compressed-ptrs.dir/src/CodeAnalyzer_arm64.cpp.o /usr/bin/c++ -DDART_PRECOMPILED_RUNTIME -DDART_TARGET_OS_ANDROID -DDART_TARGET_OS_WINDOWS_UWP -DEXCLUDE_CFE_AND_KERNEL_PLATFORM -DFRIDA_TEMPLATE_DIR=\"/home/von/桌面/blutter/scripts\" -DHAS_TYPE_REF -DNDEBUG -DPRODUCT -DTARGET_ARCH_ARM64 -DU_USING_ICU_NAMESPACE=0 -D_HAS_EXCEPTIONS=0 -I/usr/include/capstone -isystem /home/von/桌面/blutter/packages/include/dartvm2.19.6 -O3 -DNDEBUG -std=c++20 -O3 -fno-rtti -fvisibility=hidden -fvisibility-inlines-hidden -fno-omit-frame-pointer -Winvalid-pch -include /home/von/桌面/blutter/build/blutter_dartvm2.19.6_android_arm64_no-compressed-ptrs/CMakeFiles/blutter_dartvm2.19.6_android_arm64_no-compressed-ptrs.dir/cmake_pch.hxx -MD -MT CMakeFiles/blutter_dartvm2.19.6_android_arm64_no-compressed-ptrs.dir/src/CodeAnalyzer_arm64.cpp.o -MF CMakeFiles/blutter_dartvm2.19.6_android_arm64_no-compressed-ptrs.dir/src/CodeAnalyzer_arm64.cpp.o.d -o CMakeFiles/blutter_dartvm2.19.6_android_arm64_no-compressed-ptrs.dir/src/CodeAnalyzer_arm64.cpp.o -c '/home/von/桌面/blutter/blutter/src/CodeAnalyzer_arm64.cpp' /home/von/桌面/blutter/blutter/src/CodeAnalyzer_arm64.cpp: In function ‘void handleDecompressPointer(AsmIterator&, arm64_reg)’: /home/von/桌面/blutter/blutter/src/CodeAnalyzer_arm64.cpp:183:40: error: ‘CSREG_DART_HEAP’ was not declared in this scope; did you mean ‘CSREG_DART_TMP’? 183 | INSN_ASSERT(insn.ops(2).reg == CSREG_DART_HEAP && insn.ops(2).shift.value == 32); | ^~~~~~~ /home/von/桌面/blutter/blutter/src/CodeAnalyzer_arm64.cpp:48:15: note: in definition of macro ‘INSN_ASSERT’ 48 | if (!(cond)) throw InsnException(#cond, insn); \ | ^~~~ /home/von/桌面/blutter/blutter/src/CodeAnalyzer_arm64.cpp: In member function ‘std::unique_ptr FunctionAnalyzer::processDecompressPointerInstr(AsmIterator&)’: /home/von/桌面/blutter/blutter/src/CodeAnalyzer_arm64.cpp:2072:62: error: ‘CSREG_DART_HEAP’ was not declared in this scope; did you mean ‘CSREG_DART_TMP’? 2072 | if (insn.id() == ARM64_INS_ADD && insn.ops(2).reg == CSREG_DART_HEAP && insn.ops(2).shift.value == 32) { | ^~~~~~~ | CSREG_DART_TMP /home/von/桌面/blutter/blutter/src/CodeAnalyzer_arm64.cpp: In member function ‘std::unique_ptr FunctionAnalyzer::processWriteBarrierInstr(AsmIterator&)’: /home/von/桌面/blutter/blutter/src/CodeAnalyzer_arm64.cpp:2830:40: error: ‘CSREG_DART_HEAP’ was not declared in this scope; did you mean ‘CSREG_DART_TMP’? 2830 | INSN_ASSERT(insn.ops(1).reg == CSREG_DART_HEAP); | ^~~~~~~ /home/von/桌面/blutter/blutter/src/CodeAnalyzer_arm64.cpp:48:15: note: in definition of macro ‘INSN_ASSERT’ 48 | if (!(cond)) throw InsnException(#cond, insn); \ | ^~~~ [4/6] Building CXX object CMakeFile...no-compressed-ptrs.dir/src/il.cpp.o ninja: build stopped: subcommand failed. Traceback (most recent call last): File "/home/von/桌面/blutter/blutter.py", line 168, in main(args.indir, args.outdir, args.rebuild, args.vs_sln, args.no_analysis) File "/home/von/桌面/blutter/blutter.py", line 149, in main cmake_blutter(blutter_name, dartlib_name, name_suffix, macros) File "/home/von/桌面/blutter/blutter.py", line 92, in cmake_blutter subprocess.run([NINJA_CMD], cwd=builddir, check=True) File "/usr/lib/python3.11/subprocess.py", line 571, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['ninja']' returned non-zero exit status 1.

Vonggg commented 1 month ago

Sorry, I was in a hurry when asking the question as I had a class coming up. Let me restate the issue I encountered. When I use python3 blutter.py /home/von/桌面/lib/arm64-v8a output (the issue persists regardless of whether --rebuild is used), I encountered an undefined CSREG_DART_HEAP problem. I apologize that after looking at blutter/src/CodeAnalyzer_arm64.cpp, I couldn't understand what CSREG_DART_HEAP means, and therefore, I have no idea what it should be defined as. I apologize for my ignorance, and I would be extremely grateful if someone could help me solve this problem.

AbhiTheModder commented 4 weeks ago

I couldn't understand what CSREG_DART_HEAP means

CSREG_DART_HEAP is Heap start Address where Darts Code Stack Registers gets loaded initially at runtime, Similarly there's Pool Heap offset for Dart's Object Pool and others.

Though your issue seems to be related to the library you're working on, can you share them if possible

Vonggg commented 4 weeks ago

@AbhiTheModder Are you referring to the library file 'arm64-v8a' in the path /home/von/Desktop/lib/arm64-v8a in the command I'm supposed to execute? I can provide this library.Thank you very
arm64-v8a.zip

AbhiTheModder commented 4 weeks ago

Are you referring to the library file 'arm64-v8a' in the path /home/von/Desktop/lib/arm64-v8a in the command I'm supposed to execute?

Yes,

The file link you provided gives "not found" error.

Vonggg commented 4 weeks ago

Are you referring to the library file 'arm64-v8a' in the path /home/von/Desktop/lib/arm64-v8a in the command I'm supposed to execute?

Yes,

The file link you provided gives "not found" error.

I'm sorry, this is my first time using file upload. The zip file link I uploaded seems to show 'NOT FOUND' for some reason. Here is the link to my latest upload, could you please try to open it? arm64-v8a.zip

AbhiTheModder commented 4 weeks ago

@Vonggg thanks worked now

AbhiTheModder commented 4 weeks ago

@Vonggg It is indeed an issue with the library you're working on.

The libflutter.so is 64-bit however libapp.so is of 32-bit and blutter doesn't support 32-bit.

IMG_20240605_192044

Also if you want to know the solution to fix that CSREG_DART_HEAP error you can comment out it's defining condition in Disassembler_arm64.h but again due to libapp.so of being 32-bit you'll face below problem so it's better to fix your target binary

Screenshot_2024-06-05-19-23-37-945_com termux-edit

Vonggg commented 3 weeks ago

@Vonggg It is indeed an issue with the library you're working on.

The is 64-bit however is of 32-bit and blutter doesn't support 32-bit.libflutter.so``libapp.so

IMG_20240605_192044

Also if you want to know the solution to fix that error you can comment out it's defining condition in but again due to of being 32-bit you'll face below problem so it's better to fix your target binaryCSREG_DART_HEAP``Disassembler_arm64.h``libapp.so

Screenshot_2024-06-05-19-23-37-945_com termux-edit

Thank you very much for your help.