├── .github └── workflows │ ├── cmake-android-platform.yml │ ├── cmake-macos-platform.yml │ └── cmake-ubuntu-platform.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE ├── NOTICE ├── README.md ├── VERSION ├── android ├── android.cpp ├── android.h ├── art │ ├── base │ │ ├── bit_memory_region.cpp │ │ ├── bit_memory_region.h │ │ ├── bit_table.cpp │ │ ├── bit_table.h │ │ ├── bit_utils.h │ │ ├── bit_vector.h │ │ ├── enums.h │ │ ├── globals.h │ │ ├── leb128.h │ │ ├── length_prefixed_array.cpp │ │ ├── length_prefixed_array.h │ │ ├── mem_map.cpp │ │ ├── mem_map.h │ │ ├── memory_region.cpp │ │ └── memory_region.h │ ├── dex │ │ ├── compact_dex_file.cpp │ │ ├── compact_dex_file.h │ │ ├── descriptors_names.cpp │ │ ├── descriptors_names.h │ │ ├── dex_file.cpp │ │ ├── dex_file.h │ │ ├── dex_file_structs.cpp │ │ ├── dex_file_structs.h │ │ ├── dex_file_types.h │ │ ├── modifiers.cpp │ │ ├── modifiers.h │ │ ├── primitive.cpp │ │ ├── primitive.h │ │ ├── standard_dex_file.cpp │ │ ├── standard_dex_file.h │ │ ├── utf.cpp │ │ └── utf.h │ ├── dexdump │ │ ├── dexdump.cpp │ │ └── dexdump.h │ └── runtime │ │ ├── arch │ │ ├── arm │ │ │ ├── callee_save_frame_arm.h │ │ │ ├── quick_method_frame_info_arm.cpp │ │ │ ├── quick_method_frame_info_arm.h │ │ │ ├── registers_arm.cpp │ │ │ └── registers_arm.h │ │ ├── arm64 │ │ │ ├── callee_save_frame_arm64.h │ │ │ ├── quick_method_frame_info_arm64.cpp │ │ │ ├── quick_method_frame_info_arm64.h │ │ │ ├── registers_arm64.cpp │ │ │ └── registers_arm64.h │ │ ├── riscv64 │ │ │ ├── callee_save_frame_riscv64.h │ │ │ ├── quick_method_frame_info_riscv64.cpp │ │ │ ├── quick_method_frame_info_riscv64.h │ │ │ ├── registers_riscv64.cpp │ │ │ └── registers_riscv64.h │ │ ├── x86 │ │ │ ├── callee_save_frame_x86.h │ │ │ ├── quick_method_frame_info_x86.cpp │ │ │ ├── quick_method_frame_info_x86.h │ │ │ ├── registers_x86.cpp │ │ │ └── registers_x86.h │ │ └── x86_64 │ │ │ ├── callee_save_frame_x86_64.h │ │ │ ├── quick_method_frame_info_x86_64.cpp │ │ │ ├── quick_method_frame_info_x86_64.h │ │ │ ├── registers_x86_64.cpp │ │ │ └── registers_x86_64.h │ │ ├── art_field.cpp │ │ ├── art_field.h │ │ ├── art_method.cpp │ │ ├── art_method.h │ │ ├── base │ │ ├── callee_save_type.h │ │ ├── locks.cpp │ │ ├── locks.h │ │ ├── mutex.cpp │ │ └── mutex.h │ │ ├── cache_helpers.cpp │ │ ├── cache_helpers.h │ │ ├── class_linker.cpp │ │ ├── class_linker.h │ │ ├── class_status.h │ │ ├── entrypoints │ │ ├── quick │ │ │ ├── callee_save_frame.cpp │ │ │ └── callee_save_frame.h │ │ └── runtime_asm_entrypoints.h │ │ ├── gc │ │ ├── accounting │ │ │ ├── space_bitmap.cpp │ │ │ └── space_bitmap.h │ │ ├── heap.cpp │ │ ├── heap.h │ │ └── space │ │ │ ├── bump_pointer_space.cpp │ │ │ ├── bump_pointer_space.h │ │ │ ├── dlmalloc_space.cpp │ │ │ ├── dlmalloc_space.h │ │ │ ├── fake_space.cpp │ │ │ ├── fake_space.h │ │ │ ├── image_space.cpp │ │ │ ├── image_space.h │ │ │ ├── large_object_space.cpp │ │ │ ├── large_object_space.h │ │ │ ├── malloc_space.cpp │ │ │ ├── malloc_space.h │ │ │ ├── region_space.cpp │ │ │ ├── region_space.h │ │ │ ├── rosalloc_space.cpp │ │ │ ├── rosalloc_space.h │ │ │ ├── space.cpp │ │ │ ├── space.h │ │ │ ├── zygote_space.cpp │ │ │ └── zygote_space.h │ │ ├── handle_scope.cpp │ │ ├── handle_scope.h │ │ ├── hprof │ │ ├── hprof.cpp │ │ └── hprof.h │ │ ├── image.cpp │ │ ├── image.h │ │ ├── indirect_reference_table.cpp │ │ ├── indirect_reference_table.h │ │ ├── interpreter │ │ ├── quick_frame.cpp │ │ ├── quick_frame.h │ │ ├── shadow_frame.cpp │ │ └── shadow_frame.h │ │ ├── java_frame.cpp │ │ ├── java_frame.h │ │ ├── jit │ │ ├── jit.cpp │ │ ├── jit.h │ │ ├── jit_code_cache.cpp │ │ ├── jit_code_cache.h │ │ ├── jit_memory_region.cpp │ │ └── jit_memory_region.h │ │ ├── jni │ │ ├── java_vm_ext.cpp │ │ ├── java_vm_ext.h │ │ ├── jni_env_ext.cpp │ │ ├── jni_env_ext.h │ │ ├── local_reference_table.cpp │ │ └── local_reference_table.h │ │ ├── lock_word.cpp │ │ ├── lock_word.h │ │ ├── managed_stack.cpp │ │ ├── managed_stack.h │ │ ├── mirror │ │ ├── array.cpp │ │ ├── array.h │ │ ├── class.cpp │ │ ├── class.h │ │ ├── class_flags.h │ │ ├── dex_cache.cpp │ │ ├── dex_cache.h │ │ ├── iftable.h │ │ ├── object.cpp │ │ ├── object.h │ │ ├── object_array.h │ │ ├── string.cpp │ │ └── string.h │ │ ├── monitor.cpp │ │ ├── monitor.h │ │ ├── monitor_pool.cpp │ │ ├── monitor_pool.h │ │ ├── nterp_helpers.cpp │ │ ├── nterp_helpers.h │ │ ├── oat.cpp │ │ ├── oat.h │ │ ├── oat │ │ ├── oat_file.cpp │ │ ├── oat_file.h │ │ ├── stack_map.cpp │ │ └── stack_map.h │ │ ├── oat_quick_method_header.cpp │ │ ├── oat_quick_method_header.h │ │ ├── quick │ │ ├── quick_method_frame_info.cpp │ │ └── quick_method_frame_info.h │ │ ├── runtime.cpp │ │ ├── runtime.h │ │ ├── runtime_globals.h │ │ ├── stack.cpp │ │ ├── stack.h │ │ ├── thread.cpp │ │ ├── thread.h │ │ ├── thread_list.cpp │ │ ├── thread_list.h │ │ ├── thread_state.h │ │ ├── vdex_file.cpp │ │ └── vdex_file.h ├── basic.cpp ├── dalvik_vm_bytecode.h ├── fdtrack │ ├── fdtrack.cpp │ └── fdtrack.h ├── jdk │ ├── java │ │ └── lang │ │ │ ├── Array.cpp │ │ │ ├── Array.h │ │ │ ├── Class.cpp │ │ │ ├── Class.h │ │ │ ├── Integer.h │ │ │ ├── Object.cpp │ │ │ ├── Object.h │ │ │ ├── ObjectArray.h │ │ │ ├── StackTraceElement.cpp │ │ │ ├── StackTraceElement.h │ │ │ ├── String.cpp │ │ │ ├── String.h │ │ │ ├── Thread.h │ │ │ ├── ThreadGroup.h │ │ │ ├── Throwable.cpp │ │ │ └── Throwable.h │ ├── libcore │ │ └── util │ │ │ └── NativeAllocationRegistry.h │ └── sun │ │ └── misc │ │ └── Cleaner.h ├── logcat │ ├── LogBuffer.cpp │ ├── LogBuffer.h │ ├── LogStatistics.cpp │ ├── LogStatistics.h │ ├── SerializedData.cpp │ ├── SerializedData.h │ ├── SerializedLogBuffer.cpp │ ├── SerializedLogBuffer.h │ ├── event_logtags.cpp │ ├── event_logtags.h │ ├── log.cpp │ └── log.h ├── properties │ ├── prop_area.cpp │ ├── prop_area.h │ ├── prop_info.cpp │ ├── prop_info.h │ ├── property.cpp │ └── property.h ├── sdk │ ├── android │ │ ├── app │ │ │ ├── ActivityThread.h │ │ │ ├── ContextImpl.cpp │ │ │ └── ContextImpl.h │ │ ├── os │ │ │ └── BinderProxy.h │ │ └── util │ │ │ ├── ArrayMap.cpp │ │ │ ├── ArrayMap.h │ │ │ ├── BaseArrayMap.h │ │ │ └── Singleton.h │ └── native │ │ ├── android_BpBinder.cpp │ │ ├── android_BpBinder.h │ │ ├── android_os_BinderProxy.cpp │ │ └── android_os_BinderProxy.h ├── services │ └── com │ │ └── android │ │ └── server │ │ └── am │ │ ├── ActivityManagerService.cpp │ │ └── ActivityManagerService.h └── unwindstack │ ├── Unwinder.cpp │ └── Unwinder.h ├── core ├── api │ ├── bridge.cpp │ ├── bridge.h │ ├── core.cpp │ ├── core.h │ ├── elf.cpp │ ├── elf.h │ ├── memory_ref.h │ ├── thread.h │ ├── unwind.cpp │ └── unwind.h ├── arm │ ├── core.cpp │ ├── core.h │ ├── inst │ │ └── constant.h │ ├── thread_info.cpp │ ├── thread_info.h │ ├── unwind.cpp │ └── unwind.h ├── arm64 │ ├── core.cpp │ ├── core.h │ ├── inst │ │ └── constant.h │ ├── thread_info.cpp │ ├── thread_info.h │ ├── unwind.cpp │ └── unwind.h ├── common │ ├── auxv.cpp │ ├── auxv.h │ ├── bit.h │ ├── block.h │ ├── disassemble │ │ ├── capstone.cpp │ │ └── capstone.h │ ├── elf.cpp │ ├── elf.h │ ├── exception.h │ ├── file.h │ ├── link_map.cpp │ ├── link_map.h │ ├── load_block.cpp │ ├── load_block.h │ ├── native_frame.cpp │ ├── native_frame.h │ ├── note_block.cpp │ ├── note_block.h │ ├── prstatus.h │ ├── syment.h │ ├── ucontext.h │ └── xz │ │ ├── codec.cpp │ │ ├── codec.h │ │ ├── lzma.cpp │ │ └── lzma.h ├── lp32 │ ├── core.cpp │ └── core.h ├── lp64 │ ├── core.cpp │ └── core.h ├── riscv64 │ ├── core.cpp │ ├── core.h │ ├── thread_info.cpp │ ├── thread_info.h │ ├── unwind.cpp │ └── unwind.h ├── x86 │ ├── core.cpp │ ├── core.h │ ├── thread_info.cpp │ ├── thread_info.h │ ├── unwind.cpp │ └── unwind.h └── x86_64 │ ├── core.cpp │ ├── core.h │ ├── thread_info.cpp │ ├── thread_info.h │ ├── unwind.cpp │ └── unwind.h ├── doc └── OpenCoreAnalyzer.jpg ├── llvm ├── cxx │ ├── deque.cpp │ ├── deque.h │ ├── list.cpp │ ├── list.h │ ├── map.cpp │ ├── map.h │ ├── mutex.cpp │ ├── mutex.h │ ├── set.cpp │ ├── set.h │ ├── split_buffer.cpp │ ├── split_buffer.h │ ├── string.cpp │ ├── string.h │ ├── unordered_map.cpp │ ├── unordered_map.h │ ├── unordered_set.cpp │ ├── unordered_set.h │ ├── vector.cpp │ └── vector.h ├── llvm.cpp ├── llvm.h └── scudo │ └── standalone │ └── chunk.h ├── macos └── linux │ └── elf.h ├── parser ├── command │ ├── android │ │ ├── cmd_class.cpp │ │ ├── cmd_class.h │ │ ├── cmd_dex.cpp │ │ ├── cmd_dex.h │ │ ├── cmd_dumpsys.cpp │ │ ├── cmd_dumpsys.h │ │ ├── cmd_fdtrack.cpp │ │ ├── cmd_fdtrack.h │ │ ├── cmd_format_dump.h │ │ ├── cmd_getprop.cpp │ │ ├── cmd_getprop.h │ │ ├── cmd_hprof.cpp │ │ ├── cmd_hprof.h │ │ ├── cmd_logcat.cpp │ │ ├── cmd_logcat.h │ │ ├── cmd_method.cpp │ │ ├── cmd_method.h │ │ ├── cmd_print.cpp │ │ ├── cmd_print.h │ │ ├── cmd_reference.cpp │ │ ├── cmd_reference.h │ │ ├── cmd_search.cpp │ │ ├── cmd_search.h │ │ ├── cmd_space.cpp │ │ ├── cmd_space.h │ │ ├── cmd_top.cpp │ │ └── cmd_top.h │ ├── cmd_env.cpp │ ├── cmd_env.h │ ├── cmd_plugin.cpp │ ├── cmd_plugin.h │ ├── cmd_shell.cpp │ ├── cmd_shell.h │ ├── cmd_time.cpp │ ├── cmd_time.h │ ├── command.cpp │ ├── command.h │ ├── command_manager.cpp │ ├── command_manager.h │ ├── core │ │ ├── backtrace │ │ │ ├── cmd_backtrace.cpp │ │ │ ├── cmd_backtrace.h │ │ │ ├── cmd_frame.cpp │ │ │ └── cmd_frame.h │ │ ├── cmd_auxv.cpp │ │ ├── cmd_auxv.h │ │ ├── cmd_core.cpp │ │ ├── cmd_core.h │ │ ├── cmd_disassemble.cpp │ │ ├── cmd_disassemble.h │ │ ├── cmd_exec.cpp │ │ ├── cmd_exec.h │ │ ├── cmd_file.cpp │ │ ├── cmd_file.h │ │ ├── cmd_linkmap.cpp │ │ ├── cmd_linkmap.h │ │ ├── cmd_mmap.cpp │ │ ├── cmd_mmap.h │ │ ├── cmd_read.cpp │ │ ├── cmd_read.h │ │ ├── cmd_register.cpp │ │ ├── cmd_register.h │ │ ├── cmd_search.cpp │ │ ├── cmd_search.h │ │ ├── cmd_sysroot.cpp │ │ ├── cmd_sysroot.h │ │ ├── cmd_thread.cpp │ │ ├── cmd_thread.h │ │ ├── cmd_vtor.cpp │ │ ├── cmd_vtor.h │ │ ├── cmd_write.cpp │ │ └── cmd_write.h │ ├── env.cpp │ ├── env.h │ ├── fake │ │ ├── cmd_fake.cpp │ │ ├── cmd_fake.h │ │ ├── core │ │ │ ├── arm │ │ │ │ ├── fake_core.cpp │ │ │ │ ├── fake_core.h │ │ │ │ ├── tombstone_parser.cpp │ │ │ │ └── tombstone_parser.h │ │ │ ├── arm64 │ │ │ │ ├── fake_core.cpp │ │ │ │ ├── fake_core.h │ │ │ │ ├── tombstone_parser.cpp │ │ │ │ └── tombstone_parser.h │ │ │ ├── fake_core.cpp │ │ │ ├── fake_core.h │ │ │ ├── lp32 │ │ │ │ ├── fake_core.cpp │ │ │ │ └── fake_core.h │ │ │ ├── lp64 │ │ │ │ ├── fake_core.cpp │ │ │ │ └── fake_core.h │ │ │ ├── riscv64 │ │ │ │ ├── fake_core.cpp │ │ │ │ └── fake_core.h │ │ │ ├── tombstone.cpp │ │ │ ├── tombstone.h │ │ │ ├── tombstone_parser.h │ │ │ ├── x86 │ │ │ │ ├── fake_core.cpp │ │ │ │ ├── fake_core.h │ │ │ │ ├── tombstone_parser.cpp │ │ │ │ └── tombstone_parser.h │ │ │ └── x86_64 │ │ │ │ ├── fake_core.cpp │ │ │ │ ├── fake_core.h │ │ │ │ ├── tombstone_parser.cpp │ │ │ │ └── tombstone_parser.h │ │ ├── exec │ │ │ ├── fake_executable.cpp │ │ │ ├── fake_executable.h │ │ │ ├── fake_executable_32.cpp │ │ │ └── fake_executable_64.cpp │ │ ├── load │ │ │ ├── fake_load_block.cpp │ │ │ └── fake_load_block.h │ │ ├── map │ │ │ ├── fake_map.cpp │ │ │ ├── fake_map.h │ │ │ ├── fake_map_32.cpp │ │ │ └── fake_map_64.cpp │ │ └── stack │ │ │ ├── fake_java_stack.cpp │ │ │ └── fake_java_stack.h │ ├── help.cpp │ ├── help.h │ ├── llvm │ │ ├── cmd_cxx.cpp │ │ ├── cmd_cxx.h │ │ ├── cmd_scudo.cpp │ │ └── cmd_scudo.h │ └── remote │ │ ├── cmd_remote.cpp │ │ ├── cmd_remote.h │ │ ├── fakecore │ │ ├── arm │ │ │ ├── process_parser.cpp │ │ │ └── process_parser.h │ │ ├── arm64 │ │ │ ├── process_parser.cpp │ │ │ └── process_parser.h │ │ ├── process.cpp │ │ ├── process.h │ │ ├── process_parser.h │ │ ├── riscv64 │ │ │ ├── process_parser.cpp │ │ │ └── process_parser.h │ │ ├── x86 │ │ │ ├── process_parser.cpp │ │ │ └── process_parser.h │ │ └── x86_64 │ │ │ ├── process_parser.cpp │ │ │ └── process_parser.h │ │ ├── hook │ │ ├── arm │ │ │ ├── hook.cpp │ │ │ └── hook.h │ │ ├── arm64 │ │ │ ├── hook.cpp │ │ │ └── hook.h │ │ ├── hook.cpp │ │ ├── hook.h │ │ ├── lp32 │ │ │ └── hook.h │ │ ├── lp64 │ │ │ └── hook.h │ │ ├── riscv64 │ │ │ ├── hook.cpp │ │ │ └── hook.h │ │ ├── x86 │ │ │ ├── hook.cpp │ │ │ └── hook.h │ │ └── x86_64 │ │ │ ├── hook.cpp │ │ │ └── hook.h │ │ ├── opencore │ │ ├── arm │ │ │ ├── opencore.cpp │ │ │ └── opencore.h │ │ ├── arm64 │ │ │ ├── opencore.cpp │ │ │ └── opencore.h │ │ ├── lp32 │ │ │ ├── opencore.cpp │ │ │ └── opencore.h │ │ ├── lp64 │ │ │ ├── opencore.cpp │ │ │ └── opencore.h │ │ ├── opencore.cpp │ │ ├── opencore.h │ │ ├── riscv64 │ │ │ ├── opencore.cpp │ │ │ └── opencore.h │ │ ├── x86 │ │ │ ├── opencore.cpp │ │ │ └── opencore.h │ │ └── x86_64 │ │ │ ├── opencore.cpp │ │ │ └── opencore.h │ │ └── setprop │ │ ├── prop_area.cpp │ │ ├── prop_area.h │ │ ├── prop_info.h │ │ ├── property.cpp │ │ └── property.h ├── core_parser.cpp ├── ui │ ├── mini_shell.cpp │ ├── mini_shell.h │ ├── ui_thread.cpp │ └── ui_thread.h └── work │ ├── work_thread.cpp │ └── work_thread.h ├── plugin └── simple │ └── simple.cpp ├── script ├── build.sh ├── build_android.sh └── build_macos.sh ├── tests ├── test.cpp └── time.cpp └── utils ├── backtrace ├── callstack.cpp └── callstack.h ├── base ├── macros.h ├── memory_map.cpp ├── memory_map.h ├── utils.cpp └── utils.h ├── logger ├── log.cpp └── log.h └── zip ├── zip_entry.cpp ├── zip_entry.h ├── zip_file.cpp └── zip_file.h /.github/workflows/cmake-android-platform.yml: -------------------------------------------------------------------------------- 1 | # This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. 2 | # See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml 3 | name: cmake on android platforms 4 | 5 | on: 6 | push: 7 | branches: [ "main" ] 8 | pull_request: 9 | branches: [ "main" ] 10 | 11 | env: 12 | BUILD_TYPE: Debug 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-22.04 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - name: Setup Android NDK 22 | id: setup-ndk 23 | uses: nttld/setup-ndk@v1 24 | with: 25 | ndk-version: r25c 26 | local-cache: true 27 | 28 | - name: Build 29 | run: | 30 | bash ./script/build_android.sh 31 | tar -czvf core-parser_1.0.8.tar.gz output/aosp/debug/android/arm64-v8a/bin/core-parser \ 32 | output/aosp/debug/android/x86_64/bin/core-parser \ 33 | output/aosp/debug/android/armeabi-v7a/bin/core-parser \ 34 | output/aosp/debug/android/x86/bin/core-parser 35 | 36 | - name: Upload a Build Artifact 37 | uses: actions/upload-artifact@v4 38 | with: 39 | name: core-parser_1.0.8_for_android.tar.gz 40 | path: core-parser_1.0.8.tar.gz 41 | -------------------------------------------------------------------------------- /.github/workflows/cmake-macos-platform.yml: -------------------------------------------------------------------------------- 1 | # This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. 2 | # See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml 3 | name: cmake on macos platforms 4 | 5 | on: 6 | push: 7 | branches: [ "main" ] 8 | pull_request: 9 | branches: [ "main" ] 10 | 11 | env: 12 | BUILD_TYPE: Debug 13 | 14 | jobs: 15 | build: 16 | runs-on: macos-latest 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - name: Build 22 | run: | 23 | bash ./script/build_macos.sh 24 | tar -czvf core-parser_1.0.8.tar.gz output/aosp/debug/macos/bin/core-parser 25 | 26 | - name: Upload a Build Artifact 27 | uses: actions/upload-artifact@v4 28 | with: 29 | name: core-parser_1.0.8_for_macos.tar.gz 30 | path: core-parser_1.0.8.tar.gz 31 | -------------------------------------------------------------------------------- /.github/workflows/cmake-ubuntu-platform.yml: -------------------------------------------------------------------------------- 1 | # This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. 2 | # See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml 3 | name: cmake on ubuntu platforms 4 | 5 | on: 6 | push: 7 | branches: [ "main" ] 8 | pull_request: 9 | branches: [ "main" ] 10 | 11 | env: 12 | BUILD_TYPE: Debug 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-22.04 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - name: Build 22 | run: | 23 | bash ./script/build.sh 24 | tar -czvf core-parser_1.0.8.tar.gz output/aosp/debug/linux/bin/core-parser 25 | 26 | - name: Upload a Build Artifact 27 | uses: actions/upload-artifact@v4 28 | with: 29 | name: core-parser_1.0.8_for_ubuntu.tar.gz 30 | path: core-parser_1.0.8.tar.gz 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /output 2 | mybuild.sh 3 | push.sh 4 | install.sh 5 | clocline.sh 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "3rd-party/capstone"] 2 | path = 3rd-party/capstone 3 | url = https://github.com/Penguin38/capstone.git 4 | [submodule "3rd-party/xz-utils"] 5 | path = 3rd-party/xz-utils 6 | url = https://github.com/Penguin38/xz.git 7 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Third Party Licenses: 2 | 3 | The following software may be included in this product: 4 | 5 | - Capstone (https://github.com/capstone-engine/capstone) 6 | Copyright (c) 2013-2024 Nguyen Anh Quynh 7 | Distributed under the BSD 3-Clause License. 8 | See https://github.com/capstone-engine/capstone/blob/next/LICENSES/LICENSE.TXT for full license text. 9 | 10 | - XZ (https://github.com/tukaani-project/xz) 11 | Copyright (C) The XZ Utils authors and contributors 12 | See https://github.com/tukaani-project/xz/blob/master/COPYING for full license text. 13 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | MAJOR=1 2 | MINOR=0 3 | PATCH=8 4 | -------------------------------------------------------------------------------- /android/art/base/enums.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ART_LIBARTBASE_BASE_ENUMS_H_ 18 | #define ART_LIBARTBASE_BASE_ENUMS_H_ 19 | 20 | #include 21 | 22 | namespace art { 23 | 24 | enum class PointerSize : uint32_t { 25 | k32 = 4, 26 | k64 = 8 27 | }; 28 | 29 | } // namespace art 30 | 31 | #endif // ART_LIBARTBASE_BASE_ENUMS_H_ 32 | -------------------------------------------------------------------------------- /android/art/base/globals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_BASE_GLOBALS_H_ 18 | #define ANDROID_ART_BASE_GLOBALS_H_ 19 | 20 | #include 21 | #include 22 | 23 | namespace art { 24 | 25 | static constexpr uint32_t KB = 1024; 26 | static constexpr uint32_t MB = KB * KB; 27 | static constexpr uint32_t GB = KB * KB * KB; 28 | 29 | // Runtime sizes. 30 | static constexpr uint32_t kBitsPerByte = 8; 31 | static constexpr uint32_t kBitsPerByteLog2 = 3; 32 | 33 | // Required stack alignment 34 | static constexpr uint32_t kStackAlignment = 16; 35 | 36 | static constexpr uint32_t kPageSize = 0x1000; 37 | 38 | } // namespace art 39 | 40 | #endif // ANDROID_ART_BASE_GLOBALS_H_ 41 | -------------------------------------------------------------------------------- /android/art/base/length_prefixed_array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "base/length_prefixed_array.h" 18 | 19 | struct LengthPrefixedArray_OffsetTable __LengthPrefixedArray_offset__; 20 | struct LengthPrefixedArray_SizeTable __LengthPrefixedArray_size__; 21 | 22 | namespace art { 23 | 24 | void LengthPrefixedArray::Init() { 25 | __LengthPrefixedArray_offset__ = { 26 | .size_ = 0, 27 | .data_ = 4, 28 | }; 29 | 30 | __LengthPrefixedArray_size__ = { 31 | .THIS = 4, 32 | }; 33 | } 34 | 35 | } // namespace art 36 | -------------------------------------------------------------------------------- /android/art/base/mem_map.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "base/mem_map.h" 18 | #include "api/core.h" 19 | 20 | struct MemMap_OffsetTable __MemMap_offset__; 21 | struct MemMap_SizeTable __MemMap_size__; 22 | 23 | namespace art { 24 | 25 | void MemMap::Init() { 26 | if (CoreApi::Bits() == 64) { 27 | __MemMap_offset__ = { 28 | .name_ = 0, 29 | .begin_ = 24, 30 | .size_ = 32, 31 | }; 32 | 33 | __MemMap_size__ = { 34 | .THIS = 72, 35 | }; 36 | } else { 37 | __MemMap_offset__ = { 38 | .name_ = 0, 39 | .begin_ = 12, 40 | .size_ = 16, 41 | }; 42 | 43 | __MemMap_size__ = { 44 | .THIS = 40, 45 | }; 46 | } 47 | } 48 | 49 | const char* MemMap::GetName() { 50 | if (!name_cache.Ptr()) { 51 | name_cache = name(); 52 | } 53 | return name_cache.c_str(); 54 | } 55 | 56 | } // namespace art 57 | -------------------------------------------------------------------------------- /android/art/base/memory_region.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "base/memory_region.h" 18 | #include 19 | 20 | namespace art { 21 | 22 | uint32_t MemoryRegion::LoadUnaligned32(uint64_t offset) { 23 | typedef typename std::make_unsigned::type U; 24 | U equivalent_unsigned_integer_value = 0; 25 | api::MemoryRef ref = begin(); 26 | for (size_t i = 0; i < sizeof(U); ++i) { 27 | equivalent_unsigned_integer_value += ref.value8Of(offset + i) << (i * kBitsPerByte); 28 | } 29 | return reinterpret_cast(equivalent_unsigned_integer_value); 30 | } 31 | 32 | } // namespace art 33 | -------------------------------------------------------------------------------- /android/art/dex/descriptors_names.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_DEX_DESCRIPTORS_NAMES_H_ 18 | #define ANDROID_ART_DEX_DESCRIPTORS_NAMES_H_ 19 | 20 | #include 21 | 22 | namespace art { 23 | 24 | // Used to implement PrettyClass, PrettyField, PrettyMethod, and PrettyTypeOf, 25 | // one of which is probably more useful to you. 26 | // Returns a human-readable equivalent of 'descriptor'. So "I" would be "int", 27 | // "[[I" would be "int[][]", "[Ljava/lang/String;" would be 28 | // "java.lang.String[]", and so forth. 29 | void AppendPrettyDescriptor(const char* descriptor, std::string* result); 30 | void AppendPrettyDescriptor(const char* descriptor, std::string* result, const char* def); 31 | 32 | // Turn "java.lang.String" into "Ljava/lang/String;". 33 | std::string DotToDescriptor(const char* class_name); 34 | 35 | } // namespace art 36 | 37 | #endif // ANDROID_ART_DEX_DESCRIPTORS_NAMES_H_ 38 | -------------------------------------------------------------------------------- /android/art/dex/primitive.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "dex/primitive.h" 18 | 19 | namespace art { 20 | 21 | static const char* kTypeNames[] = { 22 | "PrimNot", 23 | "PrimBoolean", 24 | "PrimByte", 25 | "PrimChar", 26 | "PrimShort", 27 | "PrimInt", 28 | "PrimLong", 29 | "PrimFloat", 30 | "PrimDouble", 31 | "PrimVoid", 32 | }; 33 | 34 | static const char* kBoxedDescriptors[] = { 35 | "Ljava/lang/Object;", 36 | "Ljava/lang/Boolean;", 37 | "Ljava/lang/Byte;", 38 | "Ljava/lang/Character;", 39 | "Ljava/lang/Short;", 40 | "Ljava/lang/Integer;", 41 | "Ljava/lang/Long;", 42 | "Ljava/lang/Float;", 43 | "Ljava/lang/Double;", 44 | "Ljava/lang/Void;", 45 | }; 46 | 47 | const char* Primitive::PrettyDescriptor(Primitive::Type type) { 48 | return kTypeNames[type]; 49 | } 50 | 51 | const char* Primitive::BoxedDescriptor(Primitive::Type type) { 52 | return kBoxedDescriptors[type]; 53 | } 54 | 55 | } // namespace art 56 | -------------------------------------------------------------------------------- /android/art/dex/utf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_DEX_UTF_H_ 18 | #define ANDROID_ART_DEX_UTF_H_ 19 | 20 | #include 21 | #include 22 | 23 | namespace art { 24 | 25 | /* 26 | * Returns the number of modified UTF-8 bytes needed to represent the given 27 | * UTF-16 string. 28 | */ 29 | size_t CountUtf8Bytes(const uint16_t* chars, size_t char_count); 30 | 31 | /* 32 | * Convert from UTF-16 to Modified UTF-8. Note that the output is _not_ 33 | * NUL-terminated. You probably need to call CountUtf8Bytes before calling 34 | * this anyway, so if you want a NUL-terminated string, you know where to 35 | * put the NUL byte. 36 | */ 37 | void ConvertUtf16ToModifiedUtf8(char* utf8_out, size_t byte_count, 38 | const uint16_t* utf16_in, size_t char_count); 39 | 40 | } // namespace art 41 | 42 | #endif // ANDROID_ART_DEX_UTF_H_ 43 | -------------------------------------------------------------------------------- /android/art/runtime/arch/arm/quick_method_frame_info_arm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_ARCH_ARM_QUICK_METHOD_FRAME_INFO_ARM_H_ 18 | #define ANDROID_ART_RUNTIME_ARCH_ARM_QUICK_METHOD_FRAME_INFO_ARM_H_ 19 | 20 | #include 21 | #include 22 | 23 | namespace art { 24 | namespace arm { 25 | 26 | class ArmQuickMethodFrameInfo { 27 | public: 28 | static std::string PrettySpillMask(uint32_t mask); 29 | static void DumpCoreSpill(const char* prefix, uint64_t sp, uint32_t core_mask, uint32_t frame_size); 30 | }; 31 | 32 | } // namespace arm 33 | } // namespace art 34 | 35 | #endif // ANDROID_ART_RUNTIME_ARCH_ARM_QUICK_METHOD_FRAME_INFO_ARM_H_ 36 | -------------------------------------------------------------------------------- /android/art/runtime/arch/arm64/quick_method_frame_info_arm64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_ARCH_ARM64_QUICK_METHOD_FRAME_INFO_ARM64_H_ 18 | #define ANDROID_ART_RUNTIME_ARCH_ARM64_QUICK_METHOD_FRAME_INFO_ARM64_H_ 19 | 20 | #include 21 | #include 22 | 23 | namespace art { 24 | namespace arm64 { 25 | 26 | class Arm64QuickMethodFrameInfo { 27 | public: 28 | static std::string PrettySpillMask(uint32_t mask); 29 | static void DumpCoreSpill(const char* prefix, uint64_t sp, uint32_t core_mask, uint32_t frame_size); 30 | }; 31 | 32 | } // namespace arm64 33 | } // namespace art 34 | 35 | #endif // ANDROID_ART_RUNTIME_ARCH_ARM64_QUICK_METHOD_FRAME_INFO_ARM64_H_ 36 | -------------------------------------------------------------------------------- /android/art/runtime/arch/riscv64/quick_method_frame_info_riscv64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_ARCH_RISCV64_QUICK_METHOD_FRAME_INFO_RISCV64_H_ 18 | #define ANDROID_ART_RUNTIME_ARCH_RISCV64_QUICK_METHOD_FRAME_INFO_RISCV64_H_ 19 | 20 | #include 21 | #include 22 | 23 | namespace art { 24 | namespace riscv64 { 25 | 26 | class Riscv64QuickMethodFrameInfo { 27 | public: 28 | static std::string PrettySpillMask(uint32_t mask); 29 | static void DumpCoreSpill(const char* prefix, uint64_t sp, uint32_t core_mask, uint32_t frame_size); 30 | }; 31 | 32 | } // namespace riscv64 33 | } // namespace art 34 | 35 | #endif // ANDROID_ART_RUNTIME_ARCH_RISCV64_QUICK_METHOD_FRAME_INFO_RISCV64_H_ 36 | -------------------------------------------------------------------------------- /android/art/runtime/arch/x86/quick_method_frame_info_x86.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_ARCH_X86_QUICK_METHOD_FRAME_INFO_X86_H_ 18 | #define ANDROID_ART_RUNTIME_ARCH_X86_QUICK_METHOD_FRAME_INFO_X86_H_ 19 | 20 | #include 21 | #include 22 | 23 | namespace art { 24 | namespace x86 { 25 | 26 | class X86QuickMethodFrameInfo { 27 | public: 28 | static std::string PrettySpillMask(uint32_t mask); 29 | static void DumpCoreSpill(const char* prefix, uint64_t sp, uint32_t core_mask, uint32_t frame_size); 30 | }; 31 | 32 | } // namespace x86 33 | } // namespace art 34 | 35 | #endif // ANDROID_ART_RUNTIME_ARCH_X86_QUICK_METHOD_FRAME_INFO_X86_H_ 36 | -------------------------------------------------------------------------------- /android/art/runtime/arch/x86/registers_x86.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "runtime/arch/x86/registers_x86.h" 18 | 19 | #include 20 | 21 | namespace art HIDDEN { 22 | namespace x86 { 23 | 24 | static const char* kRegisterNames[] = { 25 | "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", 26 | }; 27 | 28 | const char* RegisterName(const Register& rhs) { 29 | if (rhs >= EAX && rhs <= EIP) { 30 | return kRegisterNames[rhs]; 31 | } 32 | return ""; 33 | } 34 | 35 | std::ostream& operator<<(std::ostream& os, const Register& rhs) { 36 | if (rhs >= EAX && rhs <= EDI) { 37 | os << kRegisterNames[rhs]; 38 | } else { 39 | os << "Register[" << static_cast(rhs) << "]"; 40 | } 41 | return os; 42 | } 43 | 44 | } // namespace x86 45 | } // namespace art 46 | -------------------------------------------------------------------------------- /android/art/runtime/arch/x86_64/quick_method_frame_info_x86_64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_ARCH_X86_64_QUICK_METHOD_FRAME_INFO_X86_64_H_ 18 | #define ANDROID_ART_RUNTIME_ARCH_X86_64_QUICK_METHOD_FRAME_INFO_X86_64_H_ 19 | 20 | #include 21 | #include 22 | 23 | namespace art { 24 | namespace x86_64 { 25 | 26 | class X86_64QuickMethodFrameInfo { 27 | public: 28 | static std::string PrettySpillMask(uint32_t mask); 29 | static void DumpCoreSpill(const char* prefix, uint64_t sp, uint32_t core_mask, uint32_t frame_size); 30 | }; 31 | 32 | } // namespace x86_64 33 | } // namespace art 34 | 35 | #endif // ANDROID_ART_RUNTIME_ARCH_X86_64_QUICK_METHOD_FRAME_INFO_X86_64_H_ 36 | -------------------------------------------------------------------------------- /android/art/runtime/base/locks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_BASE_LOCKS_H_ 18 | #define ANDROID_ART_RUNTIME_BASE_LOCKS_H_ 19 | 20 | #include 21 | 22 | namespace art { 23 | 24 | class LockLevel { 25 | public: 26 | static uint8_t kMonitorLock; 27 | static uint8_t kLockLevelCount; 28 | static void Init(); 29 | static void Init23(); 30 | static void Init24(); 31 | static void Init26(); 32 | static void Init28(); 33 | static void Init29(); 34 | static void Init30(); 35 | }; 36 | 37 | } // namespace art 38 | 39 | #endif // ANDROID_ART_RUNTIME_BASE_LOCKS_H_ 40 | -------------------------------------------------------------------------------- /android/art/runtime/entrypoints/quick/callee_save_frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_ENTRYPOINTS_QUICK_CALLEE_SAVE_FRAME_H_ 18 | #define ANDROID_ART_RUNTIME_ENTRYPOINTS_QUICK_CALLEE_SAVE_FRAME_H_ 19 | 20 | #include "runtime/base/callee_save_type.h" 21 | #include "runtime/quick/quick_method_frame_info.h" 22 | 23 | namespace art { 24 | 25 | class RuntimeCalleeSaveFrame { 26 | public: 27 | static QuickMethodFrameInfo GetMethodFrameInfo(CalleeSaveType type); 28 | static uint32_t GetFpSpills(CalleeSaveType type); 29 | static uint32_t GetCoreSpills(CalleeSaveType type); 30 | }; 31 | 32 | } // namespace art 33 | 34 | #endif // ANDROID_ART_RUNTIME_ENTRYPOINTS_QUICK_CALLEE_SAVE_FRAME_H_ 35 | -------------------------------------------------------------------------------- /android/art/runtime/gc/space/dlmalloc_space.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "runtime/gc/space/dlmalloc_space.h" 19 | #include "runtime/runtime_globals.h" 20 | #include "common/bit.h" 21 | 22 | namespace art { 23 | namespace gc { 24 | namespace space { 25 | 26 | void DlMallocSpace::Init() { 27 | // do nothing 28 | } 29 | 30 | void DlMallocSpace::Walk(std::function visitor, bool check) { 31 | // do nothing 32 | } 33 | 34 | uint64_t DlMallocSpace::GetNextObject(mirror::Object& object) { 35 | const uint64_t position = object.Ptr() + object.SizeOf(); 36 | return RoundUp(position, kObjectAlignment * 2); 37 | } 38 | 39 | } // namespace space 40 | } // namespace gc 41 | } // namespace art 42 | -------------------------------------------------------------------------------- /android/art/runtime/gc/space/malloc_space.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "runtime/gc/space/malloc_space.h" 19 | 20 | namespace art { 21 | namespace gc { 22 | namespace space { 23 | 24 | void MallocSpace::Init() { 25 | // do nothing 26 | } 27 | 28 | } // namespace space 29 | } // namespace gc 30 | } // namespace art 31 | -------------------------------------------------------------------------------- /android/art/runtime/gc/space/rosalloc_space.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "runtime/gc/space/rosalloc_space.h" 19 | #include "runtime/runtime_globals.h" 20 | #include "common/bit.h" 21 | 22 | namespace art { 23 | namespace gc { 24 | namespace space { 25 | 26 | void RosAllocSpace::Init() { 27 | // do nothing 28 | } 29 | 30 | void RosAllocSpace::Walk(std::function visitor, bool check) { 31 | // do nothing 32 | } 33 | 34 | uint64_t RosAllocSpace::GetNextObject(mirror::Object& object) { 35 | const uint64_t position = object.Ptr() + object.SizeOf(); 36 | return RoundUp(position, kObjectAlignment * 2); 37 | } 38 | 39 | } // namespace space 40 | } // namespace gc 41 | } // namespace art 42 | -------------------------------------------------------------------------------- /android/art/runtime/handle_scope.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_HANDLE_SCOPE_H_ 18 | #define ANDROID_ART_RUNTIME_HANDLE_SCOPE_H_ 19 | 20 | #include "api/memory_ref.h" 21 | 22 | struct HandleScope_SizeTable { 23 | uint32_t THIS; 24 | }; 25 | 26 | extern struct HandleScope_SizeTable __HandleScope_size__; 27 | 28 | namespace art { 29 | 30 | class HandleScope : public api::MemoryRef { 31 | public: 32 | HandleScope(uint64_t v) : api::MemoryRef(v) {} 33 | HandleScope(const api::MemoryRef& ref) : api::MemoryRef(ref) {} 34 | HandleScope(uint64_t v, api::MemoryRef& ref) : api::MemoryRef(v, ref) {} 35 | HandleScope(uint64_t v, api::MemoryRef* ref) : api::MemoryRef(v, ref) {} 36 | 37 | static void Init(); 38 | static void Init23(); 39 | static void Init34(); 40 | static uint32_t SizeOf(uint32_t num_references); 41 | }; 42 | 43 | } //namespace art 44 | 45 | #endif // ANDROID_ART_RUNTIME_HANDLE_SCOPE_H_ 46 | -------------------------------------------------------------------------------- /android/art/runtime/hprof/hprof.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_HPROF_HPROF_H_ 18 | #define ANDROID_ART_RUNTIME_HPROF_HPROF_H_ 19 | 20 | #include "logger/log.h" 21 | 22 | namespace art { 23 | namespace hprof { 24 | 25 | void DumpHeap(const char* output, bool visible, bool quick); 26 | 27 | } // namespace hprof 28 | } // namespace art 29 | 30 | #endif // ANDROID_ART_RUNTIME_HPROF_HPROF_H_ 31 | -------------------------------------------------------------------------------- /android/art/runtime/java_frame.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "runtime/java_frame.h" 18 | 19 | namespace art { 20 | 21 | uint64_t JavaFrame::GetDexPcPtr() { 22 | if (shadow_frame.Ptr()) { 23 | return shadow_frame.GetDexPcPtr(); 24 | } else if (quick_frame.Ptr()) { 25 | return quick_frame.GetDexPcPtr(); 26 | } 27 | return 0x0; 28 | } 29 | 30 | } // namespace art 31 | -------------------------------------------------------------------------------- /android/art/runtime/jit/jit_memory_region.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "api/core.h" 18 | #include "android.h" 19 | #include "runtime/jit/jit_memory_region.h" 20 | 21 | struct JitMemoryRegion_OffsetTable __JitMemoryRegion_offset__; 22 | 23 | namespace art { 24 | namespace jit { 25 | 26 | void JitMemoryRegion::Init() { 27 | Android::RegisterSdkListener(Android::R, art::jit::JitMemoryRegion::Init30); 28 | } 29 | 30 | void JitMemoryRegion::Init30() { 31 | if (CoreApi::Bits() == 64) { 32 | __JitMemoryRegion_offset__ = { 33 | .exec_pages_ = 200, 34 | }; 35 | } else { 36 | __JitMemoryRegion_offset__ = { 37 | .exec_pages_ = 108, 38 | }; 39 | } 40 | } 41 | 42 | MemMap& JitMemoryRegion::GetExecPages() { 43 | if (!exec_pages_cache.Ptr()) { 44 | exec_pages_cache = exec_pages(); 45 | exec_pages_cache.copyRef(this); 46 | } 47 | return exec_pages_cache; 48 | } 49 | 50 | } // namespace jit 51 | } // namespace art 52 | -------------------------------------------------------------------------------- /android/art/runtime/mirror/object_array.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_MIRROR_OBJECT_ARRAY_H_ 18 | #define ANDROID_ART_RUNTIME_MIRROR_OBJECT_ARRAY_H_ 19 | 20 | #include "runtime/mirror/array.h" 21 | 22 | namespace art { 23 | namespace mirror { 24 | 25 | class ObjectArray : public Array { 26 | public: 27 | ObjectArray(uint32_t v) : Array(v) {} 28 | ObjectArray(const Array& ref) : Array(ref) {} 29 | ObjectArray(uint32_t v, Array* ref) : Array(v, ref) {} 30 | }; 31 | 32 | } // namespace mirror 33 | } // namespace art 34 | 35 | #endif // ANDROID_ART_RUNTIME_MIRROR_OBJECT_ARRAY_H_ 36 | -------------------------------------------------------------------------------- /android/art/runtime/nterp_helpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_NTERP_HELPERS_H_ 18 | #define ANDROID_ART_RUNTIME_NTERP_HELPERS_H_ 19 | 20 | #include "runtime/interpreter/quick_frame.h" 21 | #include "runtime/quick/quick_method_frame_info.h" 22 | 23 | namespace art { 24 | 25 | QuickMethodFrameInfo NterpFrameInfo(ArtMethod& method); 26 | inline QuickMethodFrameInfo NterpFrameInfo(QuickFrame& frame) { 27 | return NterpFrameInfo(frame.GetMethod()); 28 | } 29 | uint64_t NterpGetFrameDexPcPtr(QuickFrame& frame); 30 | void NterpGetFrameVRegs(QuickFrame& frame); 31 | 32 | } // namespace art 33 | 34 | #endif // ANDROID_ART_RUNTIME_NTERP_HELPERS_H_ 35 | -------------------------------------------------------------------------------- /android/art/runtime/oat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_OAT_H_ 18 | #define ANDROID_ART_RUNTIME_OAT_H_ 19 | 20 | namespace art { 21 | 22 | class OatHeader { 23 | public: 24 | OatHeader() : kOatVersion(0) {} 25 | static int OatVersion(); 26 | static int AnalysiOatVersion(); 27 | 28 | int kOatVersion; 29 | }; 30 | 31 | } // namespace art 32 | 33 | #endif // ANDROID_ART_RUNTIME_OAT_H_ 34 | -------------------------------------------------------------------------------- /android/art/runtime/runtime_globals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_ART_RUNTIME_RUNTIME_GLOBALS_H_ 18 | #define ANDROID_ART_RUNTIME_RUNTIME_GLOBALS_H_ 19 | 20 | #include "base/globals.h" 21 | 22 | namespace art { 23 | 24 | // Size of Dex virtual registers. 25 | static constexpr size_t kVRegSize = 4; 26 | 27 | // Required object alignment 28 | static constexpr size_t kObjectAlignmentShift = 3; 29 | static constexpr size_t kObjectAlignment = 1u << kObjectAlignmentShift; 30 | static constexpr size_t kLargeObjectAlignment = kPageSize; 31 | 32 | } // namespace art 33 | 34 | #endif // ANDROID_ART_RUNTIME_RUNTIME_GLOBALS_H_ 35 | -------------------------------------------------------------------------------- /android/art/runtime/vdex_file.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "runtime/vdex_file.h" 18 | #include "android.h" 19 | 20 | struct VdexFile_OffsetTable __VdexFile_offset__; 21 | 22 | namespace art { 23 | 24 | void VdexFile::Init() { 25 | __VdexFile_offset__ = { 26 | .mmap_ = 0, 27 | }; 28 | } 29 | 30 | MemMap& VdexFile::GetMap() { 31 | if (!mmap_cache.Ptr()) { 32 | if (Android::Sdk() >= Android::Q) { 33 | mmap_cache = mmap(); 34 | } else { 35 | mmap_cache = mmap_lv29(); 36 | } 37 | mmap_cache.Prepare(false); 38 | } 39 | return mmap_cache; 40 | } 41 | 42 | const char* VdexFile::GetName() { 43 | return GetMap().GetName(); 44 | } 45 | 46 | uint64_t VdexFile::Begin() { 47 | return GetMap().begin(); 48 | } 49 | 50 | } //namespace art 51 | -------------------------------------------------------------------------------- /android/jdk/java/lang/Array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "java/lang/Array.h" 18 | #include "runtime/mirror/array.h" 19 | 20 | namespace java { 21 | namespace lang { 22 | 23 | int Array::length() { 24 | if (length_cache < 0) { 25 | art::mirror::Array array = thiz(); 26 | length_cache = array.GetLength(); 27 | } 28 | return length_cache; 29 | } 30 | 31 | } // namespace lang 32 | } // namespace java 33 | -------------------------------------------------------------------------------- /android/jdk/java/lang/Array.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_JDK_JAVA_LANG_ARRAY_H_ 18 | #define ANDROID_JDK_JAVA_LANG_ARRAY_H_ 19 | 20 | #include "java/lang/Object.h" 21 | 22 | namespace java { 23 | namespace lang { 24 | 25 | class Array : public Object { 26 | public: 27 | Array(uint32_t obj) : Object(obj) {} 28 | Array(Object& obj) : Object(obj) {} 29 | Array(art::mirror::Object& obj) : Object(obj) {} 30 | 31 | int length(); 32 | private: 33 | int length_cache = -1; 34 | }; 35 | 36 | } // namespace lang 37 | } // namespace java 38 | 39 | #endif // ANDROID_JDK_JAVA_LANG_ARRAY_H_ 40 | -------------------------------------------------------------------------------- /android/jdk/java/lang/Class.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_JDK_JAVA_LANG_CLASS_H_ 18 | #define ANDROID_JDK_JAVA_LANG_CLASS_H_ 19 | 20 | #include "java/lang/Object.h" 21 | #include 22 | #include 23 | 24 | namespace java { 25 | namespace lang { 26 | 27 | class Class : public Object { 28 | public: 29 | Class(uint32_t obj) : Object(obj) {} 30 | Class(Object& obj) : Object(obj) {} 31 | Class(art::mirror::Object& obj) : Object(obj) {} 32 | 33 | std::string getSimpleName(); 34 | static Class forName(const char* className); 35 | private: 36 | static std::vector kClassesCache; 37 | }; 38 | 39 | } // namespace lang 40 | } // namespace java 41 | 42 | #endif // ANDROID_JDK_JAVA_LANG_CLASS_H_ 43 | -------------------------------------------------------------------------------- /android/jdk/java/lang/Integer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_JDK_JAVA_LANG_INTEGER_H_ 18 | #define ANDROID_JDK_JAVA_LANG_INTEGER_H_ 19 | 20 | #include "java/lang/Object.h" 21 | #include "base/utils.h" 22 | 23 | namespace java { 24 | namespace lang { 25 | 26 | class Integer : public Object { 27 | public: 28 | Integer(uint32_t obj) : Object(obj) {} 29 | Integer(Object& obj) : Object(obj) {} 30 | Integer(art::mirror::Object& obj) : Object(obj) {} 31 | 32 | inline static std::string toHexString(uint32_t value) { 33 | return Utils::ToHex(value); 34 | } 35 | }; 36 | 37 | } // namespace lang 38 | } // namespace java 39 | 40 | #endif // ANDROID_JDK_JAVA_LANG_INTEGER_H_ 41 | -------------------------------------------------------------------------------- /android/jdk/java/lang/ObjectArray.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_JDK_JAVA_LANG_OBJECT_ARRAY_H_ 18 | #define ANDROID_JDK_JAVA_LANG_OBJECT_ARRAY_H_ 19 | 20 | #include "java/lang/Array.h" 21 | 22 | namespace java { 23 | namespace lang { 24 | 25 | template 26 | class ObjectArray : public Array { 27 | public: 28 | ObjectArray(uint32_t array) : Array(array) {} 29 | ObjectArray(Object& array) : Array(array) {} 30 | ObjectArray(Array& array) : Array(array) {} 31 | ObjectArray(art::mirror::Object& obj) : Array(obj) {} 32 | 33 | T operator[](int idx) { 34 | art::mirror::Array array = thiz(); 35 | api::MemoryRef ref(array.GetRawData(sizeof(uint32_t), idx), array); 36 | art::mirror::Object object(*reinterpret_cast(ref.Real()), array); 37 | return object; 38 | } 39 | }; 40 | 41 | } // namespace lang 42 | } // namespace java 43 | 44 | #endif // ANDROID_JDK_JAVA_LANG_OBJECT_ARRAY_H_ 45 | -------------------------------------------------------------------------------- /android/jdk/java/lang/String.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "java/lang/String.h" 19 | #include "runtime/mirror/string.h" 20 | 21 | namespace java { 22 | namespace lang { 23 | 24 | std::string String::toString() { 25 | art::mirror::String mirror = thiz(); 26 | if (mirror.Ptr()) { 27 | return mirror.ToModifiedUtf8(); 28 | } else { 29 | return "null"; 30 | } 31 | } 32 | 33 | void String::FormatDump(const char* prefix, art::mirror::Object& obj) { 34 | String value = obj; 35 | LOGI("%s%s\n", prefix, value.toString().c_str()); 36 | } 37 | 38 | } // namespace lang 39 | } // namespace java 40 | -------------------------------------------------------------------------------- /android/jdk/java/lang/String.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_JDK_JAVA_LANG_STRING_H_ 18 | #define ANDROID_JDK_JAVA_LANG_STRING_H_ 19 | 20 | #include "java/lang/Object.h" 21 | 22 | namespace java { 23 | namespace lang { 24 | 25 | class String : public Object { 26 | public: 27 | String(uint32_t obj) : Object(obj) {} 28 | String(Object& obj) : Object(obj) {} 29 | String(art::mirror::Object& obj) : Object(obj) {} 30 | 31 | std::string toString(); 32 | static void FormatDump(const char* prefix, art::mirror::Object& obj); 33 | }; 34 | 35 | } // namespace lang 36 | } // namespace java 37 | 38 | #endif // ANDROID_JDK_JAVA_LANG_STRING_H_ 39 | -------------------------------------------------------------------------------- /android/jdk/java/lang/ThreadGroup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_JDK_JAVA_LANG_THREADGROUP_H_ 18 | #define ANDROID_JDK_JAVA_LANG_THREADGROUP_H_ 19 | 20 | #include "java/lang/Object.h" 21 | #include "java/lang/String.h" 22 | 23 | namespace java { 24 | namespace lang { 25 | 26 | class ThreadGroup : public Object { 27 | public: 28 | ThreadGroup(uint32_t obj) : Object(obj) {} 29 | ThreadGroup(Object& obj) : Object(obj) {} 30 | ThreadGroup(art::mirror::Object& obj) : Object(obj) {} 31 | 32 | inline String& getName() { return name(); } 33 | inline std::string Name() { return getName().toString(); } 34 | private: 35 | DEFINE_OBJECT_FIELD_CACHE(String, name); 36 | }; 37 | 38 | } // namespace lang 39 | } // namespace java 40 | 41 | #endif // ANDROID_JDK_JAVA_LANG_THREADGROUP_H_ 42 | -------------------------------------------------------------------------------- /android/jdk/sun/misc/Cleaner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_JDK_SUN_MISC_CLEANER_H_ 18 | #define ANDROID_JDK_SUN_MISC_CLEANER_H_ 19 | 20 | #include "java/lang/Object.h" 21 | 22 | namespace sun { 23 | namespace misc { 24 | 25 | class Cleaner : public java::lang::Object { 26 | public: 27 | Cleaner(uint32_t obj) : java::lang::Object(obj) {} 28 | Cleaner(java::lang::Object& obj) : java::lang::Object(obj) {} 29 | Cleaner(art::mirror::Object& obj) : java::lang::Object(obj) {} 30 | 31 | inline java::lang::Object& getReferent() { return referent(); } 32 | inline java::lang::Object& getThunk() { return thunk(); } 33 | 34 | private: 35 | DEFINE_OBJECT_FIELD_CACHE(java::lang::Object, referent); 36 | DEFINE_OBJECT_FIELD_CACHE(java::lang::Object, thunk); 37 | }; 38 | 39 | } // namespace misc 40 | } // namespace sun 41 | 42 | #endif // ANDROID_JDK_SUN_MISC_CLEANER_H_ 43 | -------------------------------------------------------------------------------- /android/logcat/LogBuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logcat/LogBuffer.h" 18 | 19 | struct LogBuffer_OffsetTable __LogBuffer_offset__; 20 | 21 | namespace android { 22 | 23 | void LogBuffer::Init() { 24 | 25 | } 26 | 27 | } // namespace android 28 | -------------------------------------------------------------------------------- /android/logcat/LogBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_LOGCAT_LOGBUFFER_H_ 18 | #define ANDROID_LOGCAT_LOGBUFFER_H_ 19 | 20 | #include "api/memory_ref.h" 21 | 22 | struct LogBuffer_OffsetTable { 23 | }; 24 | 25 | extern struct LogBuffer_OffsetTable __LogBuffer_offset__; 26 | 27 | namespace android { 28 | 29 | class LogBuffer : public api::MemoryRef { 30 | public: 31 | LogBuffer(uint64_t v) : api::MemoryRef(v) {} 32 | LogBuffer(uint64_t v, LoadBlock* b) : api::MemoryRef(v, b) {} 33 | LogBuffer(const api::MemoryRef& ref) : api::MemoryRef(ref) {} 34 | LogBuffer(uint64_t v, api::MemoryRef& ref) : api::MemoryRef(v, ref) {} 35 | LogBuffer(uint64_t v, api::MemoryRef* ref) : api::MemoryRef(v, ref) {} 36 | 37 | static void Init(); 38 | }; 39 | 40 | } // namespace android 41 | 42 | #endif // ANDROID_LOGCAT_LOGBUFFER_H_ 43 | -------------------------------------------------------------------------------- /android/logcat/LogStatistics.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "api/core.h" 18 | #include "logcat/LogStatistics.h" 19 | 20 | struct LogStatistics_OffsetTable __LogStatistics_offset__; 21 | 22 | namespace android { 23 | 24 | void LogStatistics::Init() { 25 | if (CoreApi::Bits() == 64) { 26 | __LogStatistics_offset__ = { 27 | .mElements = 64, 28 | }; 29 | } else { 30 | // do nothing 31 | } 32 | } 33 | 34 | } // namespace android 35 | -------------------------------------------------------------------------------- /android/logcat/LogStatistics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_LOGCAT_LOG_STATISTICS_H_ 18 | #define ANDROID_LOGCAT_LOG_STATISTICS_H_ 19 | 20 | #include "api/memory_ref.h" 21 | 22 | struct LogStatistics_OffsetTable { 23 | uint32_t mElements; 24 | }; 25 | 26 | extern struct LogStatistics_OffsetTable __LogStatistics_offset__; 27 | 28 | namespace android { 29 | 30 | class LogStatistics : public api::MemoryRef { 31 | public: 32 | LogStatistics(uint64_t v) : api::MemoryRef(v) {} 33 | LogStatistics(uint64_t v, LoadBlock* b) : api::MemoryRef(v, b) {} 34 | LogStatistics(const api::MemoryRef& ref) : api::MemoryRef(ref) {} 35 | LogStatistics(uint64_t v, api::MemoryRef& ref) : api::MemoryRef(v, ref) {} 36 | LogStatistics(uint64_t v, api::MemoryRef* ref) : api::MemoryRef(v, ref) {} 37 | 38 | static void Init(); 39 | inline uint64_t mElements() { return Ptr() + OFFSET(LogStatistics, mElements); } 40 | }; 41 | 42 | } // namespace android 43 | 44 | #endif // ANDROID_LOGCAT_LOG_STATISTICS_H_ 45 | -------------------------------------------------------------------------------- /android/logcat/SerializedLogBuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logcat/SerializedLogBuffer.h" 18 | 19 | struct SerializedLogBuffer_OffsetTable __SerializedLogBuffer_offset__; 20 | struct SerializedLogBuffer_SizeTable __SerializedLogBuffer_size__; 21 | 22 | namespace android { 23 | 24 | void SerializedLogBuffer::Init31() { 25 | __SerializedLogBuffer_offset__ = { 26 | .vtbl = 0, 27 | .reader_list_ = 8, 28 | .tags_ = 16, 29 | .stats_ = 24, 30 | .max_size_ = 32, 31 | .logs_ = 96, 32 | }; 33 | 34 | __SerializedLogBuffer_size__ = { 35 | .THIS = 288, 36 | .vtbl = 10, 37 | }; 38 | } 39 | 40 | } // namespace android 41 | -------------------------------------------------------------------------------- /android/properties/prop_info.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "properties/prop_info.h" 18 | 19 | struct PropInfo_OffsetTable __PropInfo_offset__; 20 | struct PropInfo_SizeTable __PropInfo_size__; 21 | 22 | void android::PropInfo::Init() { 23 | __PropInfo_offset__ = { 24 | .serial = 0, 25 | .value = 4, 26 | .name = 96, 27 | }; 28 | 29 | __PropInfo_size__ = { 30 | .THIS = 96, 31 | .serial = 4, 32 | .value = 92, 33 | .name = 0, 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /android/properties/property.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_PROPERTIES_PROPERTY_H_ 18 | #define ANDROID_PROPERTIES_PROPERTY_H_ 19 | 20 | #include "properties/prop_info.h" 21 | #include 22 | 23 | namespace android { 24 | class Property { 25 | public: 26 | static void Init(); 27 | static const char* Get(const char *name); 28 | static const char* Get(const char *name, const char* def); 29 | static int64_t GetInt64(const char *name); 30 | static int64_t GetInt64(const char *name, int64_t def); 31 | static int32_t GetInt32(const char *name); 32 | static int32_t GetInt32(const char *name, int32_t def); 33 | static void Foreach(std::function callback); 34 | }; 35 | } // android 36 | 37 | #endif // ANDROID_PROPERTIES_PROPERTY_H_ 38 | -------------------------------------------------------------------------------- /android/sdk/android/app/ContextImpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SDK_ANDROID_APP_CONTEXTIMPL_H_ 18 | #define ANDROID_SDK_ANDROID_APP_CONTEXTIMPL_H_ 19 | 20 | #include "java/lang/Object.h" 21 | 22 | namespace android { 23 | namespace app { 24 | 25 | class ContextImpl : public java::lang::Object { 26 | public: 27 | ContextImpl(uint32_t obj) : java::lang::Object(obj) {} 28 | ContextImpl(java::lang::Object& obj) : java::lang::Object(obj) {} 29 | ContextImpl(art::mirror::Object& obj) : java::lang::Object(obj) {} 30 | 31 | inline java::lang::Object& getServiceCache() { return mServiceCache(); } 32 | java::lang::Object getSystemService(const char* serviceName); 33 | private: 34 | DEFINE_OBJECT_FIELD_CACHE(java::lang::Object, mServiceCache); 35 | }; 36 | 37 | } // namespace app 38 | } // namespace android 39 | 40 | #endif // ANDROID_SDK_ANDROID_APP_CONTEXTIMPL_H_ 41 | -------------------------------------------------------------------------------- /android/sdk/android/os/BinderProxy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by oslicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SDK_ANDROID_OS_BINDERPROXY_H_ 18 | #define ANDROID_SDK_ANDROID_OS_BINDERPROXY_H_ 19 | 20 | #include "java/lang/Object.h" 21 | 22 | namespace android { 23 | namespace os { 24 | 25 | class BinderProxy : public java::lang::Object { 26 | public: 27 | BinderProxy(uint32_t obj) : java::lang::Object(obj) {} 28 | BinderProxy(java::lang::Object& obj) : java::lang::Object(obj) {} 29 | BinderProxy(art::mirror::Object& obj) : java::lang::Object(obj) {} 30 | 31 | inline uint64_t getNativeData() { return GetLongField("mNativeData"); } 32 | }; 33 | 34 | } // namespace os 35 | } // namespace android 36 | 37 | #endif // ANDROID_SDK_ANDROID_OS_BINDERPROXY_H_ 38 | -------------------------------------------------------------------------------- /android/sdk/android/util/BaseArrayMap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SDK_ANDROID_UTIL_BASE_ARRAYMAP_H_ 18 | #define ANDROID_SDK_ANDROID_UTIL_BASE_ARRAYMAP_H_ 19 | 20 | #include "java/lang/Object.h" 21 | #include "java/lang/ObjectArray.h" 22 | 23 | namespace android { 24 | namespace util { 25 | 26 | class BaseArrayMap : public java::lang::Object { 27 | public: 28 | BaseArrayMap(uint32_t obj) : java::lang::Object(obj) {} 29 | BaseArrayMap(java::lang::Object& obj) : java::lang::Object(obj) {} 30 | BaseArrayMap(art::mirror::Object& obj) : java::lang::Object(obj) {} 31 | 32 | inline int size() { return GetIntField("mSize"); } 33 | inline java::lang::ObjectArray& getArray() { return mArray(); } 34 | private: 35 | DEFINE_OBJECT_FIELD_CACHE(java::lang::ObjectArray, mArray); 36 | }; 37 | 38 | } // namespace util 39 | } // namespace android 40 | 41 | #endif // ANDROID_SDK_ANDROID_UTIL_BASE_ARRAYMAP_H_ 42 | -------------------------------------------------------------------------------- /android/sdk/android/util/Singleton.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SDK_ANDROID_UTIL_SINGLETON_H_ 18 | #define ANDROID_SDK_ANDROID_UTIL_SINGLETON_H_ 19 | 20 | #include "java/lang/Object.h" 21 | 22 | namespace android { 23 | namespace util { 24 | 25 | class Singleton : public java::lang::Object { 26 | public: 27 | Singleton(uint32_t obj) : java::lang::Object(obj) {} 28 | Singleton(java::lang::Object& obj) : java::lang::Object(obj) {} 29 | Singleton(art::mirror::Object& obj) : java::lang::Object(obj) {} 30 | 31 | inline java::lang::Object& get() { return mInstance(); } 32 | private: 33 | DEFINE_OBJECT_FIELD_CACHE(java::lang::Object, mInstance); 34 | }; 35 | 36 | } // namespace util 37 | } // namespace android 38 | 39 | #endif // ANDROID_SDK_ANDROID_UTIL_SINGLETON_H_ 40 | -------------------------------------------------------------------------------- /android/services/com/android/server/am/ActivityManagerService.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SERVICES_COM_ANDROID_SERVER_AM_ACTIVITYMANAGERSERVICE_H_ 18 | #define SERVICES_COM_ANDROID_SERVER_AM_ACTIVITYMANAGERSERVICE_H_ 19 | 20 | #include "java/lang/Object.h" 21 | 22 | namespace com { 23 | namespace android { 24 | namespace server { 25 | namespace am { 26 | 27 | class ActivityManagerService : public java::lang::Object { 28 | public: 29 | ActivityManagerService(uint32_t obj) : java::lang::Object(obj) {} 30 | ActivityManagerService(java::lang::Object& obj) : java::lang::Object(obj) {} 31 | ActivityManagerService(art::mirror::Object& obj) : java::lang::Object(obj) {} 32 | 33 | int dump(int argc, char* const argv[]); 34 | static int Main(int argc, char* const argv[]); 35 | }; 36 | 37 | } // namespace am 38 | } // namespace server 39 | } // namespace android 40 | } // namespace com 41 | 42 | #endif // SERVICES_COM_ANDROID_SERVER_AM_ACTIVITYMANAGERSERVICE_H_ 43 | -------------------------------------------------------------------------------- /core/api/bridge.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "api/bridge.h" 18 | #include "api/core.h" 19 | 20 | namespace api { 21 | LoadBlock* Bridge::FindLoadBlock(uint64_t vaddr, bool check) { 22 | return CoreApi::FindLoadBlock(vaddr, check, true); 23 | } 24 | } // namespace api 25 | -------------------------------------------------------------------------------- /core/api/bridge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_API_BRIDGE_H_ 18 | #define CORE_API_BRIDGE_H_ 19 | 20 | #include "common/load_block.h" 21 | 22 | namespace api { 23 | class Bridge { 24 | public: 25 | static LoadBlock* FindLoadBlock(uint64_t vaddr, bool check); 26 | }; 27 | } // namespace api 28 | 29 | #endif // CORE_API_BRIDGE_H_ 30 | -------------------------------------------------------------------------------- /core/arm/core.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "arm/core.h" 18 | #include "arm/thread_info.h" 19 | #include "common/prstatus.h" 20 | #include "common/bit.h" 21 | #include 22 | #include 23 | 24 | namespace arm { 25 | 26 | bool Core::load() { 27 | pointer_mask = GENMASK_UL(bits() - 1, 0); 28 | vabits_mask = pointer_mask; 29 | 30 | auto callback = [](uint64_t type, uint64_t pos) -> void * { 31 | switch(type) { 32 | case NT_PRSTATUS: 33 | Elf32_prstatus* prs = reinterpret_cast(pos); 34 | ThreadInfo* thread = new ThreadInfo(prs->pr_pid, pos); 35 | memcpy(&thread->reg, &prs->pr_reg, sizeof(Register)); 36 | return thread; 37 | } 38 | return nullptr; 39 | }; 40 | return load32(this, callback); 41 | } 42 | 43 | void Core::unload() { 44 | } 45 | 46 | Core::~Core() { 47 | unload(); 48 | } 49 | 50 | } // namespace arm 51 | -------------------------------------------------------------------------------- /core/arm/core.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_ARM_CORE_H_ 18 | #define CORE_ARM_CORE_H_ 19 | 20 | #include "api/core.h" 21 | #include "lp32/core.h" 22 | #include "common/elf.h" 23 | 24 | namespace arm { 25 | 26 | class Core : public CoreApi, lp32::Core { 27 | public: 28 | Core(std::unique_ptr& map) 29 | : CoreApi(map) {} 30 | ~Core(); 31 | private: 32 | bool load(); 33 | void unload(); 34 | const char* getMachineName() { return "arm"; } 35 | int getMachine() { return EM_ARM; } 36 | int bits() { return 32; } 37 | int getPointSize() { return 4; } 38 | uint64_t getVabitsMask() { return 0xFFFFFFFFULL; } 39 | void loadLinkMap() { loadLinkMap32(this); } 40 | bool exec(uint64_t phdr, const char* file) { return exec32(this, phdr, file); } 41 | bool sysroot(LinkMap* handle, const char* file, const char* subfile) { return dlopen32(this, handle, file, subfile); } 42 | api::MemoryRef& r_debug_ptr() { return GetDebug(); } 43 | }; 44 | 45 | } // namespace arm 46 | 47 | #endif // CORE_ARM_CORE_H_ 48 | -------------------------------------------------------------------------------- /core/arm/inst/constant.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_ARM_INST_CONSTANT_H_ 18 | #define CORE_ARM_INST_CONSTANT_H_ 19 | 20 | namespace thumb { 21 | 22 | static constexpr uint32_t mov_expr = 0b00100; 23 | static constexpr uint32_t mov_rm = 0b0001110; 24 | 25 | } // namespace thumb 26 | 27 | namespace arm { 28 | 29 | 30 | } //namespace arm 31 | #endif // CORE_ARM_INST_CONSTANT_H_ 32 | -------------------------------------------------------------------------------- /core/arm/unwind.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_ARM_UNWIND_H_ 18 | #define CORE_ARM_UNWIND_H_ 19 | 20 | #include "api/unwind.h" 21 | #include "arm/thread_info.h" 22 | 23 | namespace arm { 24 | 25 | class UnwindStack : public api::UnwindStack { 26 | public: 27 | UnwindStack(ThreadApi* thread) : api::UnwindStack(thread) {} 28 | void WalkStack(); 29 | void Backtrace(Register& regs); 30 | uint32_t GetUContext(); 31 | void DumpContextRegister(const char* prefix); 32 | }; 33 | 34 | } // namespace arm 35 | 36 | #endif // CORE_ARM_UNWIND_H_ 37 | -------------------------------------------------------------------------------- /core/arm64/unwind.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_ARM64_UNWIND_H_ 18 | #define CORE_ARM64_UNWIND_H_ 19 | 20 | #include "api/unwind.h" 21 | #include "arm64/thread_info.h" 22 | 23 | namespace arm64 { 24 | 25 | class UnwindStack : public api::UnwindStack { 26 | public: 27 | UnwindStack(ThreadApi* thread) : api::UnwindStack(thread) {} 28 | void WalkStack(); 29 | void FpBacktrace(Register& regs); 30 | void OnlyFpBackStack(uint64_t fp); 31 | uint64_t GetUContext(); 32 | void DumpContextRegister(const char* prefix); 33 | }; 34 | 35 | } // namespace arm64 36 | 37 | #endif // CORE_ARM64_UNWIND_H_ 38 | -------------------------------------------------------------------------------- /core/common/auxv.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "api/core.h" 18 | #include "common/auxv.h" 19 | #include "common/note_block.h" 20 | 21 | void Auxv::bind(NoteBlock* block, uint64_t addr) { 22 | mBlock = block; 23 | mAuxv = addr; 24 | } 25 | 26 | void Auxv::setValue(uint64_t value) { 27 | if (mBlock) { 28 | mBlock->setOverlay(mAuxv + CoreApi::GetPointSize(), (void *)&value, CoreApi::GetPointSize()); 29 | mValue = value; 30 | } 31 | } 32 | 33 | void Auxv::setType(uint64_t type) { 34 | if (mBlock) { 35 | mBlock->setOverlay(mAuxv, (void *)&type, CoreApi::GetPointSize()); 36 | mType = type; 37 | } 38 | } 39 | 40 | void Auxv::setTypeAndValue(uint64_t type, uint64_t value) { 41 | if (mBlock) { 42 | mBlock->setOverlay(mAuxv, (void *)&type, CoreApi::GetPointSize()); 43 | mBlock->setOverlay(mAuxv + CoreApi::GetPointSize(), (void *)&value, CoreApi::GetPointSize()); 44 | mType = type; 45 | mValue = value; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/common/bit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_COMMON_BIT_H_ 18 | #define CORE_COMMON_BIT_H_ 19 | 20 | #include 21 | 22 | #define GENMASK_UL(h, l) (((~0ULL) << (l)) & (~0ULL >> (64 - 1 - (h)))) 23 | 24 | template 25 | constexpr T RoundDown(T x, std::remove_reference_t n) { 26 | return (x & -n); 27 | } 28 | 29 | template 30 | constexpr T RoundUp(T x, std::remove_reference_t n) { 31 | return RoundDown(x + n - 1, n); 32 | } 33 | 34 | #endif // CORE_COMMON_BIT_H_ 35 | -------------------------------------------------------------------------------- /core/common/elf.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "common/elf.h" 18 | #include "api/core.h" 19 | #include 20 | 21 | bool ElfHeader::CheckLibrary(const char* file) { 22 | if (memcmp(ident, ELFMAG, 4)) { 23 | LOGE("Invalid ELF file (%s)\n", file); 24 | return false; 25 | } 26 | 27 | if (type != ET_DYN) { 28 | LOGE("Invalid shared object file (%s)\n", file); 29 | return false; 30 | } 31 | 32 | if (machine != CoreApi::GetMachine()) { 33 | LOGE("Invalid match machine(%d) (%s)\n", machine, file); 34 | return false; 35 | } 36 | 37 | return true; 38 | } 39 | 40 | std::string ElfHeader::ToMachineName(uint16_t machine) { 41 | switch(machine) { 42 | case EM_AARCH64: return "arm64"; 43 | case EM_RISCV: return "riscv64"; 44 | case EM_X86_64: return "x86_64"; 45 | case EM_ARM: return "arm"; 46 | case EM_386: return "x86"; 47 | } 48 | return std::to_string(machine); 49 | } 50 | -------------------------------------------------------------------------------- /core/common/elf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_COMMON_ELF_H_ 18 | #define CORE_COMMON_ELF_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #define EM_NONE 0 25 | #define EM_386 3 26 | #define EM_ARM 40 27 | #define EM_X86_64 62 28 | #define EM_AARCH64 183 29 | #define EM_RISCV 243 30 | 31 | #define DEF_VA_BITS 39 32 | #ifndef NT_ARM_PAC_MASK 33 | #define NT_ARM_PAC_MASK 0x406 34 | #endif 35 | #ifndef NT_ARM_TAGGED_ADDR_CTRL 36 | #define NT_ARM_TAGGED_ADDR_CTRL 0x409 37 | #endif 38 | #ifndef NT_ARM_PAC_ENABLED_KEYS 39 | #define NT_ARM_PAC_ENABLED_KEYS 0x40A 40 | #endif 41 | 42 | #define ELF_PAGE_SIZE 0x1000 43 | 44 | class ElfHeader { 45 | public: 46 | uint8_t ident[16]; 47 | uint16_t type; 48 | uint16_t machine; 49 | uint32_t version; 50 | bool CheckLibrary(const char* file); 51 | static std::string ToMachineName(uint16_t machine); 52 | }; 53 | 54 | #endif // CORE_COMMON_ELF_H_ 55 | -------------------------------------------------------------------------------- /core/common/exception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_COMMON_EXCEPTION_H_ 18 | #define CORE_COMMON_EXCEPTION_H_ 19 | 20 | #include "logger/log.h" 21 | #include "backtrace/callstack.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | class InvalidAddressException : public std::exception { 29 | private: 30 | uint64_t addr; 31 | std::string error; 32 | public: 33 | InvalidAddressException(uint64_t p) : addr(p) { 34 | if (Logger::GetDebugLevel() >= Logger::LEVEL_DEBUG_2) { 35 | CallStack stack; 36 | stack.update(2); 37 | stack.dump(1); 38 | } 39 | 40 | std::ostringstream ss; 41 | ss << "Invalid address 0x" << std::hex << addr; 42 | error.append(ss.str()); 43 | } 44 | 45 | const char * what() const throw() { 46 | return error.c_str(); 47 | } 48 | }; 49 | 50 | #endif // CORE_COMMON_EXCEPTION_H_ 51 | -------------------------------------------------------------------------------- /core/common/native_frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_COMMON_NATIVE_FRAME_H_ 18 | #define CORE_COMMON_NATIVE_FRAME_H_ 19 | 20 | #include "common/link_map.h" 21 | 22 | class NativeFrame { 23 | public: 24 | NativeFrame(uint64_t fp, uint64_t sp, uint64_t pc); 25 | void Decode(); 26 | uint64_t GetFrameFp() { return frame_fp; } 27 | void SetFramePc(uint64_t pc); 28 | uint64_t GetFramePc() { return frame_pc; } 29 | std::string& GetMethodName() { return frame_symbol.GetMethod(); } 30 | std::string& GetMethodSymbol() { return frame_symbol.GetSymbol(); } 31 | LinkMap* GetLinkMap() { return map; } 32 | uint64_t GetMethodOffset(); 33 | uint64_t GetMethodSize(); 34 | std::string GetLibrary(); 35 | bool IsThumbMode(); 36 | void SetThumbMode() { thumb = true; } 37 | private: 38 | uint64_t frame_fp; 39 | uint64_t frame_sp; 40 | uint64_t frame_pc; 41 | LinkMap* map; 42 | LinkMap::NiceSymbol frame_symbol; 43 | bool thumb; 44 | }; 45 | 46 | #endif // CORE_COMMON_NATIVE_FRAME_H_ 47 | -------------------------------------------------------------------------------- /core/common/xz/codec.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "common/xz/codec.h" 18 | #include "common/xz/lzma.h" 19 | #include 20 | 21 | namespace xz { 22 | 23 | bool Codec::HasLZMASupport() { 24 | #if defined(__LZMA__) 25 | return true; 26 | #else 27 | return false; 28 | #endif // __LZMA__ 29 | } 30 | 31 | bool Codec::IsLZMA(uint8_t *data) { 32 | return !memcmp(data, LZMA::kMagic, 6); 33 | } 34 | 35 | std::unique_ptr Codec::Create(uint8_t *data, uint64_t size) { 36 | std::unique_ptr impl; 37 | #if defined(__LZMA__) 38 | if (Codec::IsLZMA(data)) 39 | impl = std::make_unique(data, size); 40 | #endif // __LZMA__ 41 | return std::move(impl); 42 | } 43 | 44 | } // xz 45 | -------------------------------------------------------------------------------- /core/common/xz/codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_COMMON_XZ_CODEC_H_ 18 | #define CORE_COMMON_XZ_CODEC_H_ 19 | 20 | #include "base/memory_map.h" 21 | #include 22 | #include 23 | #include 24 | 25 | namespace xz { 26 | 27 | class Codec { 28 | public: 29 | static bool HasLZMASupport(); 30 | inline uint8_t* data() { return mData; } 31 | inline uint64_t size() { return mSize; } 32 | 33 | Codec(uint8_t *data, uint64_t size) 34 | : mData(data), mSize(size) {} 35 | 36 | virtual ~Codec() {} 37 | virtual MemoryMap* Decode2Map() = 0; 38 | 39 | static bool IsLZMA(uint8_t* data); 40 | static std::unique_ptr Create(uint8_t *data, uint64_t size); 41 | private: 42 | uint8_t *mData; 43 | uint64_t mSize; 44 | }; 45 | 46 | } // xz 47 | 48 | #endif // CORE_COMMON_XZ_CODEC_H_ 49 | -------------------------------------------------------------------------------- /core/common/xz/lzma.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_COMMON_XZ_LZMA_H_ 18 | #define CORE_COMMON_XZ_LZMA_H_ 19 | 20 | #include "common/xz/codec.h" 21 | 22 | namespace xz { 23 | 24 | class LZMA : public Codec { 25 | public: 26 | static constexpr uint8_t kMagic[] = { 0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00 }; 27 | LZMA(uint8_t *data, uint64_t size) : Codec(data, size) {} 28 | ~LZMA() {} 29 | 30 | uint64_t TotalSize(); 31 | MemoryMap* Decode2Map(); 32 | }; 33 | 34 | } // xz 35 | 36 | #endif // CORE_COMMON_XZ_LZMA_H_ 37 | -------------------------------------------------------------------------------- /core/riscv64/core.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "riscv64/core.h" 18 | #include "riscv64/thread_info.h" 19 | #include "common/prstatus.h" 20 | #include "common/bit.h" 21 | #include 22 | #include 23 | 24 | namespace riscv64 { 25 | 26 | bool Core::load() { 27 | pointer_mask = GENMASK_UL(bits() - 1, 0); 28 | vabits_mask = pointer_mask; 29 | 30 | auto callback = [](uint64_t type, uint64_t pos) -> void * { 31 | switch(type) { 32 | case NT_PRSTATUS: 33 | Elf64_prstatus* prs = reinterpret_cast(pos); 34 | ThreadInfo* thread = new ThreadInfo(prs->pr_pid, pos); 35 | memcpy(&thread->reg, &prs->pr_reg, sizeof(Register)); 36 | return thread; 37 | } 38 | return nullptr; 39 | }; 40 | return load64(this, callback); 41 | } 42 | 43 | void Core::unload() { 44 | } 45 | 46 | Core::~Core() { 47 | unload(); 48 | } 49 | 50 | } // namespace riscv64 51 | -------------------------------------------------------------------------------- /core/riscv64/unwind.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "api/core.h" 19 | #include "riscv64/unwind.h" 20 | #include "common/ucontext.h" 21 | #include "common/exception.h" 22 | #include 23 | 24 | namespace riscv64 { 25 | 26 | uint64_t UnwindStack::GetUContext() { 27 | return cur_uc_; 28 | } 29 | 30 | void UnwindStack::WalkStack() { 31 | ThreadInfo* thread = reinterpret_cast(GetThread()); 32 | Register& regs = thread->GetRegs(); 33 | cur_frame_pc_ = regs.pc; 34 | VisitFrame(); 35 | } 36 | 37 | void UnwindStack::DumpContextRegister(const char* prefix) { 38 | api::MemoryRef uc = GetUContext(); 39 | if (uc.Ptr()) { 40 | struct ucontext* context = (struct ucontext*)uc.Real(); 41 | Register uc_regs; 42 | memcpy(&uc_regs, &context->uc_mcontext.sc_regs, sizeof(Register)); 43 | uc_regs.Dump(prefix); 44 | } 45 | } 46 | 47 | } // namespace riscv64 48 | -------------------------------------------------------------------------------- /core/riscv64/unwind.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_RISCV64_UNWIND_H_ 18 | #define CORE_RISCV64_UNWIND_H_ 19 | 20 | #include "api/unwind.h" 21 | #include "riscv64/thread_info.h" 22 | 23 | namespace riscv64 { 24 | 25 | class UnwindStack : public api::UnwindStack { 26 | public: 27 | UnwindStack(ThreadApi* thread) : api::UnwindStack(thread) {} 28 | void WalkStack(); 29 | uint64_t GetUContext(); 30 | void DumpContextRegister(const char* prefix); 31 | }; 32 | 33 | } // namespace riscv64 34 | 35 | #endif // CORE_RISCV64_UNWIND_H_ 36 | -------------------------------------------------------------------------------- /core/x86/core.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "x86/core.h" 18 | #include "x86/thread_info.h" 19 | #include "common/prstatus.h" 20 | #include "common/bit.h" 21 | #include 22 | #include 23 | 24 | namespace x86 { 25 | 26 | bool Core::load() { 27 | pointer_mask = GENMASK_UL(bits() - 1, 0); 28 | vabits_mask = pointer_mask; 29 | 30 | auto callback = [](uint64_t type, uint64_t pos) -> void * { 31 | switch(type) { 32 | case NT_PRSTATUS: 33 | Elf32_prstatus* prs = reinterpret_cast(pos); 34 | ThreadInfo* thread = new ThreadInfo(prs->pr_pid, pos); 35 | memcpy(&thread->reg, &prs->pr_reg, sizeof(Register)); 36 | return thread; 37 | } 38 | return nullptr; 39 | }; 40 | return load32(this, callback); 41 | } 42 | 43 | void Core::unload() { 44 | } 45 | 46 | Core::~Core() { 47 | unload(); 48 | } 49 | 50 | } // namespace x86 51 | -------------------------------------------------------------------------------- /core/x86/unwind.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_X86_UNWIND_H_ 18 | #define CORE_X86_UNWIND_H_ 19 | 20 | #include "api/unwind.h" 21 | #include "x86/thread_info.h" 22 | 23 | namespace x86 { 24 | 25 | class UnwindStack : public api::UnwindStack { 26 | public: 27 | UnwindStack(ThreadApi* thread) : api::UnwindStack(thread) {} 28 | void WalkStack(); 29 | void Backtrace(Register& regs); 30 | uint32_t GetUContext(); 31 | void DumpContextRegister(const char* prefix); 32 | }; 33 | 34 | } // namespace x86 35 | 36 | #endif // CORE_X86_UNWIND_H_ 37 | -------------------------------------------------------------------------------- /core/x86_64/core.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "x86_64/core.h" 18 | #include "x86_64/thread_info.h" 19 | #include "common/prstatus.h" 20 | #include "common/bit.h" 21 | #include 22 | #include 23 | 24 | namespace x86_64 { 25 | 26 | bool Core::load() { 27 | pointer_mask = GENMASK_UL(bits() - 1, 0); 28 | vabits_mask = pointer_mask; 29 | 30 | auto callback = [](uint64_t type, uint64_t pos) -> void * { 31 | switch(type) { 32 | case NT_PRSTATUS: 33 | Elf64_prstatus* prs = reinterpret_cast(pos); 34 | ThreadInfo* thread = new ThreadInfo(prs->pr_pid, pos); 35 | memcpy(&thread->reg, &prs->pr_reg, sizeof(Register)); 36 | return thread; 37 | } 38 | return nullptr; 39 | }; 40 | return load64(this, callback); 41 | } 42 | 43 | void Core::unload() { 44 | } 45 | 46 | Core::~Core() { 47 | unload(); 48 | } 49 | 50 | } // namespace x86_64 51 | -------------------------------------------------------------------------------- /core/x86_64/unwind.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CORE_X86_64_UNWIND_H_ 18 | #define CORE_X86_64_UNWIND_H_ 19 | 20 | #include "api/unwind.h" 21 | #include "x86_64/thread_info.h" 22 | 23 | namespace x86_64 { 24 | 25 | class UnwindStack : public api::UnwindStack { 26 | public: 27 | UnwindStack(ThreadApi* thread) : api::UnwindStack(thread) {} 28 | void WalkStack(); 29 | void Backtrace(Register& regs); 30 | uint64_t GetUContext(); 31 | void DumpContextRegister(const char* prefix); 32 | }; 33 | 34 | } // namespace x86_64 35 | 36 | #endif // CORE_X86_64_UNWIND_H_ 37 | -------------------------------------------------------------------------------- /doc/OpenCoreAnalyzer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Penguin38/OpenCoreAnalysisKit/76b72018d497ad9690f161232ef89b82c24b9a42/doc/OpenCoreAnalyzer.jpg -------------------------------------------------------------------------------- /llvm/cxx/mutex.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "api/core.h" 18 | #include "cxx/mutex.h" 19 | 20 | struct cxx_mutex_OffsetTable __cxx_mutex_offset__; 21 | struct cxx_mutex_SizeTable __cxx_mutex_size__; 22 | 23 | namespace cxx { 24 | 25 | void mutex::Init() { 26 | __cxx_mutex_offset__ = { 27 | .__m_ = 0, 28 | }; 29 | 30 | if (CoreApi::Bits() == 64) { 31 | __cxx_mutex_size__ = { 32 | .THIS = 40, 33 | }; 34 | } else { 35 | __cxx_mutex_size__ = { 36 | .THIS = 16, 37 | }; 38 | } 39 | } 40 | 41 | } // namespace cxx 42 | -------------------------------------------------------------------------------- /llvm/cxx/split_buffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "api/core.h" 18 | #include "cxx/split_buffer.h" 19 | 20 | struct cxx_split_buffer_OffsetTable __cxx_split_buffer_offset__; 21 | struct cxx_split_buffer_SizeTable __cxx_split_buffer_size__; 22 | 23 | namespace cxx { 24 | 25 | void split_buffer::Init() { 26 | uint32_t cap = 64 / CoreApi::Bits(); 27 | __cxx_split_buffer_offset__ = { 28 | .__first_ = 0, 29 | .__begin_ = 8 / cap, 30 | .__end_ = 16 / cap, 31 | .__end_cap_ = 24 / cap, 32 | }; 33 | 34 | __cxx_split_buffer_size__ = { 35 | .THIS = 32 / cap, 36 | }; 37 | } 38 | 39 | } // namespace cxx 40 | -------------------------------------------------------------------------------- /llvm/cxx/string.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "api/core.h" 18 | #include "cxx/string.h" 19 | 20 | struct cxx_string_OffsetTable __cxx_string_offset__; 21 | struct cxx_string_SizeTable __cxx_string_size__; 22 | 23 | namespace cxx { 24 | 25 | void string::Init() { 26 | uint32_t cap = 64 / CoreApi::Bits(); 27 | __cxx_string_offset__ = { 28 | .__l__cap_ = 0, 29 | .__l__size_ = 8 / cap, 30 | .__l__data_ = 16 / cap, 31 | .__s__size_ = 0, 32 | .__s__data_ = 1, 33 | }; 34 | 35 | __cxx_string_size__ = { 36 | .THIS = 24 / cap, 37 | }; 38 | } 39 | 40 | const char* string::c_str() { 41 | if (!(__s__size() & __short_mask)) { 42 | return reinterpret_cast(__s__data()); 43 | } else { 44 | api::MemoryRef ref(__l__data(), this); 45 | return reinterpret_cast(ref.Real()); 46 | } 47 | } 48 | 49 | std::string string::str() { 50 | std::string sb = c_str(); 51 | return sb; 52 | } 53 | 54 | } // namespace cxx 55 | 56 | -------------------------------------------------------------------------------- /llvm/llvm.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "llvm.h" 18 | #include "cxx/string.h" 19 | #include "cxx/vector.h" 20 | #include "cxx/map.h" 21 | #include "cxx/set.h" 22 | #include "cxx/list.h" 23 | #include "cxx/unordered_map.h" 24 | #include "cxx/unordered_set.h" 25 | #include "cxx/deque.h" 26 | #include "cxx/split_buffer.h" 27 | #include "cxx/mutex.h" 28 | 29 | void LLVM::Init() { 30 | cxx::string::Init(); 31 | cxx::vector::Init(); 32 | cxx::map::Init(); 33 | cxx::map::pair::Init(); 34 | cxx::set::Init(); 35 | cxx::set::pair::Init(); 36 | cxx::list::Init(); 37 | cxx::unordered_map::Init(); 38 | cxx::unordered_set::Init(); 39 | cxx::deque::Init(); 40 | cxx::split_buffer::Init(); 41 | cxx::mutex::Init(); 42 | } 43 | -------------------------------------------------------------------------------- /llvm/llvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LLVM_LLVM_H_ 18 | #define LLVM_LLVM_H_ 19 | 20 | class LLVM { 21 | public: 22 | static void Init(); 23 | }; 24 | 25 | #endif // LLVM_LLVM_H_ 26 | -------------------------------------------------------------------------------- /parser/command/android/cmd_dumpsys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_ANDROID_CMD_DUMPSYS_H_ 18 | #define PARSER_COMMAND_ANDROID_CMD_DUMPSYS_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class DumpsysCommand : public Command { 23 | public: 24 | DumpsysCommand() : Command("dumpsys") {} 25 | ~DumpsysCommand() {} 26 | int main(int argc, char* const argv[]); 27 | int prepare(int argc, char* const argv[]); 28 | void usage(); 29 | }; 30 | 31 | #endif // PARSER_COMMAND_ANDROID_CMD_DUMPSYS_H_ 32 | -------------------------------------------------------------------------------- /parser/command/android/cmd_getprop.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_ANDROID_CMD_GET_PROP_H_ 18 | #define PARSER_COMMAND_ANDROID_CMD_GET_PROP_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class GetPropCommand : public Command { 23 | public: 24 | GetPropCommand() : Command("getprop") {} 25 | ~GetPropCommand() {} 26 | int main(int argc, char* const argv[]); 27 | void usage(); 28 | void printProperties(); 29 | }; 30 | 31 | #endif // PARSER_COMMAND_ANDROID_CMD_GET_PROP_H_ 32 | -------------------------------------------------------------------------------- /parser/command/android/cmd_hprof.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_ANDROID_CMD_HPROF_H_ 18 | #define PARSER_COMMAND_ANDROID_CMD_HPROF_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class HprofCommand : public Command { 23 | public: 24 | HprofCommand() : Command("hprof") {} 25 | ~HprofCommand() {} 26 | 27 | struct Options : Command::Options { 28 | bool visible; 29 | bool quick; 30 | }; 31 | 32 | int main(int argc, char* const argv[]); 33 | int prepare(int argc, char* const argv[]); 34 | void usage(); 35 | private: 36 | Options options; 37 | }; 38 | 39 | #endif // PARSER_COMMAND_ANDROID_CMD_HPROF_H_ 40 | -------------------------------------------------------------------------------- /parser/command/android/cmd_logcat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_ANDROID_CMD_LOGCAT_H_ 18 | #define PARSER_COMMAND_ANDROID_CMD_LOGCAT_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class LogcatCommand : public Command { 23 | public: 24 | static constexpr int DUMP_MAIN = 1 << 0; 25 | static constexpr int DUMP_RADIO = 1 << 1; 26 | static constexpr int DUMP_EVENTS = 1 << 2; 27 | static constexpr int DUMP_SYSTEM = 1 << 3; 28 | static constexpr int DUMP_CRASH = 1 << 4; 29 | static constexpr int DUMP_KERNEL = 1 << 5; 30 | 31 | LogcatCommand() : Command("logcat") {} 32 | ~LogcatCommand() {} 33 | 34 | struct Options : Command::Options { 35 | int dump_flag; 36 | int filter; 37 | int id; 38 | }; 39 | 40 | int main(int argc, char* const argv[]); 41 | int prepare(int argc, char* const argv[]); 42 | void usage(); 43 | private: 44 | Options options; 45 | }; 46 | 47 | #endif // PARSER_COMMAND_ANDROID_CMD_LOGCAT_H_ 48 | -------------------------------------------------------------------------------- /parser/command/android/cmd_reference.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_ANDROID_CMD_REFERENCE_H_ 18 | #define PARSER_COMMAND_ANDROID_CMD_REFERENCE_H_ 19 | 20 | #include "command/command.h" 21 | #include "runtime/mirror/object.h" 22 | 23 | class ReferenceCommand : public Command { 24 | public: 25 | ReferenceCommand() : Command("reference", "ref") {} 26 | ~ReferenceCommand() {} 27 | 28 | struct Options : Command::Options { 29 | int flags; 30 | int tid; 31 | bool format_hex; 32 | bool dump_refs; 33 | }; 34 | 35 | int main(int argc, char* const argv[]); 36 | int prepare(int argc, char* const argv[]); 37 | void usage(); 38 | private: 39 | Options options; 40 | }; 41 | 42 | #endif // PARSER_COMMAND_ANDROID_CMD_REFERENCE_H_ 43 | -------------------------------------------------------------------------------- /parser/command/android/cmd_space.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_ANDROID_CMD_SPACE_H_ 18 | #define PARSER_COMMAND_ANDROID_CMD_SPACE_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class SpaceCommand : public Command { 23 | public: 24 | SpaceCommand() : Command("space") {} 25 | ~SpaceCommand() {} 26 | 27 | struct Options : Command::Options { 28 | int flag; 29 | bool check; 30 | }; 31 | 32 | int main(int argc, char* const argv[]); 33 | int prepare(int argc, char* const argv[]); 34 | void usage(); 35 | private: 36 | Options options; 37 | }; 38 | 39 | #endif // PARSER_COMMAND_ANDROID_CMD_SPACE_H_ 40 | -------------------------------------------------------------------------------- /parser/command/cmd_env.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CMD_ENV_H_ 18 | #define PARSER_COMMAND_CMD_ENV_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class EnvCommand : public Command { 23 | public: 24 | EnvCommand() : Command("env") {} 25 | ~EnvCommand() {} 26 | int main(int argc, char* const argv[]); 27 | int dumpEnv(); 28 | void usage(); 29 | static int onConfigChanged(int argc, char* const argv[]); 30 | static int onLoggerChanged(int argc, char* const argv[]); 31 | static int onOffsetChanged(int argc, char* const argv[]); 32 | static int onSizeChanged(int argc, char* const argv[]); 33 | static int showArtEnv(int argc, char* const argv[]); 34 | static int showCoreEnv(int argc, char* const argv[]); 35 | static int showLoadEnv(bool quick); 36 | static int showNoteEnv(); 37 | static int clocLoadCRC32(int num); 38 | }; 39 | 40 | #endif // PARSER_COMMAND_CMD_ENV_H_ 41 | -------------------------------------------------------------------------------- /parser/command/cmd_shell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CMD_SHELL_H_ 18 | #define PARSER_COMMAND_CMD_SHELL_H_ 19 | 20 | #include "command/command.h" 21 | #include 22 | 23 | class ShellCommand : public Command { 24 | public: 25 | ShellCommand() : Command("shell", "sh") {} 26 | ~ShellCommand() {} 27 | int main(int argc, char* const argv[]); 28 | int main(int argc, char* const argv[], std::function callback); 29 | void usage(); 30 | }; 31 | 32 | #endif // PARSER_COMMAND_CMD_SHELL_H_ 33 | -------------------------------------------------------------------------------- /parser/command/cmd_time.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "command/cmd_time.h" 19 | #include "command/command_manager.h" 20 | #include 21 | #include 22 | 23 | using namespace std::chrono; 24 | 25 | int TimeCommand::main(int argc, char* const argv[]) { 26 | if (!(argc > 1)) return 0; 27 | auto starttime = system_clock::now(); 28 | CommandManager::Execute(argv[1], argc - 1, &argv[1]); 29 | duration diff = system_clock::now()- starttime; 30 | LOGI("\nTotal time: %lf (seconds)\n", diff.count()); 31 | return 0; 32 | } 33 | 34 | void TimeCommand::usage() { 35 | LOGI("Usage: time [options..]\n"); 36 | } 37 | -------------------------------------------------------------------------------- /parser/command/cmd_time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CMD_TIME_H_ 18 | #define PARSER_COMMAND_CMD_TIME_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class TimeCommand : public Command { 23 | public: 24 | TimeCommand() : Command("time") {} 25 | ~TimeCommand() {} 26 | int main(int argc, char* const argv[]); 27 | void usage(); 28 | }; 29 | 30 | #endif // PARSER_COMMAND_CMD_TIME_H_ 31 | -------------------------------------------------------------------------------- /parser/command/core/cmd_auxv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_AUXV_H_ 18 | #define PARSER_COMMAND_CORE_CMD_AUXV_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class AuxvCommand : public Command { 23 | public: 24 | AuxvCommand() : Command("auxv") {} 25 | ~AuxvCommand() {} 26 | int main(int argc, char* const argv[]); 27 | void usage() {} 28 | }; 29 | 30 | #endif // PARSER_COMMAND_CORE_CMD_AUXV_H_ 31 | -------------------------------------------------------------------------------- /parser/command/core/cmd_core.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "command/env.h" 19 | #include "command/core/cmd_core.h" 20 | #include "api/core.h" 21 | 22 | int CoreCommand::Load(const char* path) { 23 | return Load(path, false); 24 | } 25 | 26 | int CoreCommand::Load(const char* path, bool remote) { 27 | return CoreApi::Load(path, remote, Env::Init); 28 | } 29 | 30 | int CoreCommand::main(int argc, char* const argv[]) { 31 | return Load(argv[1]); 32 | } 33 | 34 | void CoreCommand::usage() { 35 | LOGI("Usage: core /tmp/default.core\n"); 36 | } 37 | -------------------------------------------------------------------------------- /parser/command/core/cmd_core.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_CORE_H_ 18 | #define PARSER_COMMAND_CORE_CMD_CORE_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class CoreCommand : public Command { 23 | public: 24 | CoreCommand() : Command("core") {} 25 | ~CoreCommand() {} 26 | int main(int argc, char* const argv[]); 27 | void usage(); 28 | static int Load(const char* path); 29 | static int Load(const char* path, bool remote); 30 | }; 31 | 32 | #endif // PARSER_COMMAND_CORE_CMD_CORE_H_ 33 | -------------------------------------------------------------------------------- /parser/command/core/cmd_disassemble.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_DISASSEMBLE_H_ 18 | #define PARSER_COMMAND_CORE_CMD_DISASSEMBLE_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class DisassembleCommand : public Command { 23 | public: 24 | DisassembleCommand() : Command("disassemble", "disas") {} 25 | ~DisassembleCommand() {} 26 | 27 | struct Options : Command::Options { 28 | int read_opt; 29 | }; 30 | 31 | int main(int argc, char* const argv[]); 32 | int prepare(int argc, char* const argv[]); 33 | void usage(); 34 | private: 35 | Options options; 36 | }; 37 | 38 | #endif // PARSER_COMMAND_CORE_CMD_DISASSEMBLE_H_ 39 | -------------------------------------------------------------------------------- /parser/command/core/cmd_exec.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "command/core/cmd_exec.h" 19 | #include "api/core.h" 20 | 21 | int ExecCommand::main(int argc, char* const argv[]) { 22 | if (CoreApi::IsReady() && argc > 1) { 23 | CoreApi::ExecFile(argv[1]); 24 | } 25 | return 0; 26 | } 27 | 28 | void ExecCommand::usage() { 29 | LOGI("Usage: exec \n"); 30 | ENTER(); 31 | LOGI("core-parser> exec /system/bin/app_process64\n"); 32 | LOGI("Mmap segment [60969cb26000, 60969cb28000) /system/bin/app_process64 [0]\n"); 33 | LOGI("Mmap segment [60969cb28000, 60969cb2a000) /system/bin/app_process64 [1000]\n"); 34 | } 35 | -------------------------------------------------------------------------------- /parser/command/core/cmd_exec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_EXEC_H_ 18 | #define PARSER_COMMAND_CORE_CMD_EXEC_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class ExecCommand : public Command { 23 | public: 24 | ExecCommand() : Command("exec") {} 25 | ~ExecCommand() {} 26 | int main(int argc, char* const argv[]); 27 | void usage(); 28 | }; 29 | 30 | #endif // PARSER_COMMAND_CORE_CMD_EXEC_H_ 31 | -------------------------------------------------------------------------------- /parser/command/core/cmd_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_FILE_H_ 18 | #define PARSER_COMMAND_CORE_CMD_FILE_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class FileCommand : public Command { 23 | public: 24 | FileCommand() : Command("file") {} 25 | ~FileCommand() {} 26 | int main(int argc, char* const argv[]); 27 | void usage(); 28 | }; 29 | 30 | #endif // PARSER_COMMAND_CORE_CMD_FILE_H_ 31 | -------------------------------------------------------------------------------- /parser/command/core/cmd_linkmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_LINKMAP_H_ 18 | #define PARSER_COMMAND_CORE_CMD_LINKMAP_H_ 19 | 20 | #include "command/command.h" 21 | #include "common/link_map.h" 22 | 23 | class LinkMapCommand : public Command { 24 | public: 25 | LinkMapCommand() : Command("map") {} 26 | ~LinkMapCommand() {} 27 | 28 | struct Options : Command::Options { 29 | bool dump_ori; 30 | bool dump_all; 31 | int num; 32 | }; 33 | 34 | int main(int argc, char* const argv[]); 35 | int prepare(int argc, char* const argv[]); 36 | void ShowLinkMap(int pos, LinkMap* map); 37 | void ShowLinkMapSymbols(LinkMap* map); 38 | void usage(); 39 | private: 40 | Options options; 41 | }; 42 | 43 | #endif // PARSER_COMMAND_CORE_CMD_LINKMAP_H_ 44 | -------------------------------------------------------------------------------- /parser/command/core/cmd_mmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_MMAP_H_ 18 | #define PARSER_COMMAND_CORE_CMD_MMAP_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class MmapCommand : public Command { 23 | public: 24 | static constexpr int REMOVE_MMAP = 1 << 0; 25 | static constexpr int REMOVE_OVERLAY = 1 << 1; 26 | 27 | MmapCommand() : Command("mmap") {} 28 | ~MmapCommand() {} 29 | int main(int argc, char* const argv[]); 30 | void usage(); 31 | }; 32 | 33 | #endif // PARSER_COMMAND_CORE_CMD_MMAP_H_ 34 | -------------------------------------------------------------------------------- /parser/command/core/cmd_read.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_READ_H_ 18 | #define PARSER_COMMAND_CORE_CMD_READ_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class ReadCommand : public Command { 23 | public: 24 | ReadCommand() : Command("read", "rd") {} 25 | ~ReadCommand() {} 26 | int main(int argc, char* const argv[]); 27 | void usage(); 28 | void saveBinary(char* path, uint64_t* real, uint64_t size); 29 | static void ShowBuffer(uint64_t ptr, int size); 30 | }; 31 | 32 | #endif // PARSER_COMMAND_CORE_CMD_READ_H_ 33 | -------------------------------------------------------------------------------- /parser/command/core/cmd_register.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_REGISTER_H_ 18 | #define PARSER_COMMAND_CORE_CMD_REGISTER_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class RegisterCommand : public Command { 23 | public: 24 | static constexpr int REGS_DUMP = 0; 25 | static constexpr int REGS_SET = 1; 26 | static constexpr int REGS_GET = 2; 27 | 28 | RegisterCommand() : Command("register", "regs") {} 29 | ~RegisterCommand() {} 30 | int main(int argc, char* const argv[]); 31 | void usage(); 32 | }; 33 | 34 | #endif // PARSER_COMMAND_CORE_CMD_REGISTER_H_ 35 | -------------------------------------------------------------------------------- /parser/command/core/cmd_search.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_CS_H_ 18 | #define PARSER_COMMAND_CORE_CMD_CS_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class CoreSearchCommand : public Command { 23 | public: 24 | CoreSearchCommand() : Command("cs") {} 25 | ~CoreSearchCommand() {} 26 | 27 | struct Options : Command::Options { 28 | int flags; 29 | bool in_stack; 30 | }; 31 | 32 | int main(int argc, char* const argv[]); 33 | int prepare(int argc, char* const argv[]); 34 | void usage(); 35 | static void WalkStack(const char* value); 36 | static void WalkLoadBlock(const char* value, int flags); 37 | private: 38 | Options options; 39 | }; 40 | 41 | #endif // PARSER_COMMAND_CORE_CMD_CS_H_ 42 | -------------------------------------------------------------------------------- /parser/command/core/cmd_sysroot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_SYSROOT_H_ 18 | #define PARSER_COMMAND_CORE_CMD_SYSROOT_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class SysRootCommand : public Command { 23 | public: 24 | static constexpr int MAP_ROOT = 1 << 0; 25 | static constexpr int DEX_ROOT = 1 << 1; 26 | 27 | SysRootCommand() : Command("sysroot") {} 28 | ~SysRootCommand() {} 29 | int main(int argc, char* const argv[]); 30 | void usage(); 31 | }; 32 | 33 | #endif // PARSER_COMMAND_CORE_CMD_SYSROOT_H_ 34 | -------------------------------------------------------------------------------- /parser/command/core/cmd_thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_THREAD_H_ 18 | #define PARSER_COMMAND_CORE_CMD_THREAD_H_ 19 | 20 | #include "command/command.h" 21 | #include "android.h" 22 | 23 | class ThreadCommand : public Command { 24 | public: 25 | ThreadCommand() : Command("thread", "t") {} 26 | ~ThreadCommand() {} 27 | 28 | struct Options : Command::Options { 29 | bool native; 30 | bool java; 31 | bool dump_all; 32 | }; 33 | 34 | int main(int argc, char* const argv[]); 35 | int prepare(int argc, char* const argv[]); 36 | void usage(); 37 | private: 38 | Options options; 39 | }; 40 | 41 | #endif // PARSER_COMMAND_CORE_CMD_THREAD_H_ 42 | -------------------------------------------------------------------------------- /parser/command/core/cmd_vtor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_VTOR_H_ 18 | #define PARSER_COMMAND_CORE_CMD_VTOR_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class VtorCommand : public Command { 23 | public: 24 | VtorCommand() : Command("vtor") {} 25 | ~VtorCommand() {} 26 | int main(int argc, char* const argv[]); 27 | void usage(); 28 | }; 29 | 30 | #endif // PARSER_COMMAND_CORE_CMD_VTOR_H_ 31 | -------------------------------------------------------------------------------- /parser/command/core/cmd_write.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_CORE_CMD_WRITE_H_ 18 | #define PARSER_COMMAND_CORE_CMD_WRITE_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class WriteCommand : public Command { 23 | public: 24 | WriteCommand() : Command("write", "wd") {} 25 | ~WriteCommand() {} 26 | int main(int argc, char* const argv[]); 27 | void usage(); 28 | }; 29 | 30 | #endif // PARSER_COMMAND_CORE_CMD_WRITE_H_ 31 | -------------------------------------------------------------------------------- /parser/command/env.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_ENV_H_ 18 | #define PARSER_COMMAND_ENV_H_ 19 | 20 | #include 21 | 22 | #if defined(__ANDROID__) 23 | #define CURRENT_DIR_DEF "/data/local/tmp" 24 | #else 25 | #define CURRENT_DIR_DEF "." 26 | #endif 27 | 28 | class Env { 29 | public: 30 | Env() : pid(0), remote_pid(0) {} 31 | void init(); 32 | bool setCurrentPid(int p); 33 | inline int current() { return pid; } 34 | inline int remote() { return remote_pid; } 35 | 36 | static void Init(); 37 | static void Dump(); 38 | static bool SetCurrentPid(int p) { return INSTANCE->setCurrentPid(p); } 39 | static int CurrentPid() { return INSTANCE->current(); } 40 | static int CurrentRemotePid() { return INSTANCE->remote(); } 41 | static const char* CurrentDir() { return CURRENT_DIR_DEF; } 42 | private: 43 | static std::unique_ptr INSTANCE; 44 | int pid; 45 | int remote_pid; 46 | }; 47 | 48 | #endif // PARSER_COMMAND_ENV_H_ 49 | -------------------------------------------------------------------------------- /parser/command/fake/cmd_fake.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_FAKE_CMD_FAKE_H_ 18 | #define PARSER_COMMAND_FAKE_CMD_FAKE_H_ 19 | 20 | #include "command/command.h" 21 | #include 22 | 23 | class FakeCommand : public Command { 24 | public: 25 | FakeCommand() : Command("fake") {} 26 | ~FakeCommand() {} 27 | int main(int argc, char* const argv[]); 28 | int prepare(int argc, char* const argv[]); 29 | void usage(); 30 | }; 31 | 32 | #endif // PARSER_COMMAND_FAKE_CMD_FAKE_H_ 33 | -------------------------------------------------------------------------------- /parser/command/fake/core/arm/fake_core.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_FAKE_CORE_ARM_FAKECORE_IMPL_H_ 18 | #define PARSER_COMMAND_FAKE_CORE_ARM_FAKECORE_IMPL_H_ 19 | 20 | #include "command/fake/core/lp32/fake_core.h" 21 | #include "common/prstatus.h" 22 | 23 | namespace arm { 24 | 25 | class FakeCore : public lp32::FakeCore { 26 | public: 27 | FakeCore() : lp32::FakeCore(), 28 | prnum(0), prstatus(nullptr) {} 29 | FakeCore(std::unique_ptr& in) { 30 | FakeCore(); 31 | InitStream(in); 32 | } 33 | int execute(const char* output); 34 | int getMachine() { return EM_ARM; } 35 | void CreateCorePrStatus(); 36 | uint32_t WriteCorePrStatus(std::unique_ptr& map, uint32_t off); 37 | 38 | ~FakeCore(); 39 | private: 40 | int prnum; 41 | Elf32_prstatus *prstatus; 42 | }; 43 | 44 | } // namespace arm 45 | 46 | #endif // PARSER_COMMAND_FAKE_CORE_ARM_FAKECORE_IMPL_H_ 47 | -------------------------------------------------------------------------------- /parser/command/fake/core/arm/tombstone_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_FAKE_CORE_ARM_TOMBSTONE_PARSER_H_ 18 | #define PARSER_COMMAND_FAKE_CORE_ARM_TOMBSTONE_PARSER_H_ 19 | 20 | #include "command/fake/core/tombstone_parser.h" 21 | #include "common/prstatus.h" 22 | #include 23 | #include 24 | 25 | namespace arm { 26 | 27 | class TombstoneParser : public android::TombstoneParser { 28 | public: 29 | TombstoneParser(const char* path) : android::TombstoneParser(path) {} 30 | bool parse(); 31 | bool parseCmdline(); 32 | bool parseTid(); 33 | bool parseRegister(); 34 | bool parseBacktrace(); 35 | bool parseMemory(); 36 | bool parseMaps(); 37 | 38 | void * Regs() { return (void *)®s; } 39 | private: 40 | struct pt_regs regs; 41 | }; 42 | 43 | } // namespace arm 44 | 45 | #endif // PARSER_COMMAND_FAKE_CORE_ARM_TOMBSTONE_PARSER_H_ 46 | -------------------------------------------------------------------------------- /parser/command/fake/core/riscv64/fake_core.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_FAKE_CORE_RISCV64_FAKECORE_IMPL_H_ 18 | #define PARSER_COMMAND_FAKE_CORE_RISCV64_FAKECORE_IMPL_H_ 19 | 20 | #include "command/fake/core/lp64/fake_core.h" 21 | #include "common/prstatus.h" 22 | 23 | namespace riscv64 { 24 | 25 | class FakeCore : public lp64::FakeCore { 26 | public: 27 | FakeCore() : lp64::FakeCore(), 28 | prnum(0), prstatus(nullptr) {} 29 | FakeCore(std::unique_ptr& in) { 30 | FakeCore(); 31 | InitStream(in); 32 | } 33 | int execute(const char* output); 34 | int getMachine() { return EM_RISCV; } 35 | void CreateCorePrStatus(); 36 | uint64_t WriteCorePrStatus(std::unique_ptr& map, uint64_t off); 37 | 38 | ~FakeCore(); 39 | private: 40 | int prnum; 41 | Elf64_prstatus *prstatus; 42 | }; 43 | 44 | } // namespace riscv64 45 | 46 | #endif // PARSER_COMMAND_FAKE_CORE_RISCV64_FAKECORE_IMPL_H_ 47 | -------------------------------------------------------------------------------- /parser/command/fake/core/x86/fake_core.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_FAKE_CORE_X86_FAKECORE_IMPL_H_ 18 | #define PARSER_COMMAND_FAKE_CORE_X86_FAKECORE_IMPL_H_ 19 | 20 | #include "command/fake/core/lp32/fake_core.h" 21 | #include "common/prstatus.h" 22 | 23 | namespace x86 { 24 | 25 | class FakeCore : public lp32::FakeCore { 26 | public: 27 | FakeCore() : lp32::FakeCore(), 28 | prnum(0), prstatus(nullptr) {} 29 | FakeCore(std::unique_ptr& in) { 30 | FakeCore(); 31 | InitStream(in); 32 | } 33 | int execute(const char* output); 34 | int getMachine() { return EM_386; } 35 | void CreateCorePrStatus(); 36 | uint32_t WriteCorePrStatus(std::unique_ptr& map, uint32_t off); 37 | 38 | ~FakeCore(); 39 | private: 40 | int prnum; 41 | Elf32_prstatus *prstatus; 42 | }; 43 | 44 | } // namespace x86 45 | 46 | #endif // PARSER_COMMAND_FAKE_CORE_X86_FAKECORE_IMPL_H_ 47 | -------------------------------------------------------------------------------- /parser/command/fake/core/x86/tombstone_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_FAKE_CORE_X86_TOMBSTONE_PARSER_H_ 18 | #define PARSER_COMMAND_FAKE_CORE_X86_TOMBSTONE_PARSER_H_ 19 | 20 | #include "command/fake/core/tombstone_parser.h" 21 | #include "common/prstatus.h" 22 | #include 23 | #include 24 | 25 | namespace x86 { 26 | 27 | class TombstoneParser : public android::TombstoneParser { 28 | public: 29 | TombstoneParser(const char* path) : android::TombstoneParser(path) {} 30 | bool parse(); 31 | bool parseCmdline(); 32 | bool parseTid(); 33 | bool parseRegister(); 34 | bool parseBacktrace(); 35 | bool parseMemory(); 36 | bool parseMaps(); 37 | 38 | void * Regs() { return (void *)®s; } 39 | private: 40 | struct pt_regs regs; 41 | }; 42 | 43 | } // namespace x86 44 | 45 | #endif // PARSER_COMMAND_FAKE_CORE_X86_TOMBSTONE_PARSER_H_ 46 | -------------------------------------------------------------------------------- /parser/command/fake/core/x86_64/fake_core.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_FAKE_CORE_X86_64_FAKECORE_IMPL_H_ 18 | #define PARSER_COMMAND_FAKE_CORE_X86_64_FAKECORE_IMPL_H_ 19 | 20 | #include "command/fake/core/lp64/fake_core.h" 21 | #include "common/prstatus.h" 22 | 23 | namespace x86_64 { 24 | 25 | class FakeCore : public lp64::FakeCore { 26 | public: 27 | FakeCore() : lp64::FakeCore(), 28 | prnum(0), prstatus(nullptr) {} 29 | FakeCore(std::unique_ptr& in) { 30 | FakeCore(); 31 | InitStream(in); 32 | } 33 | int execute(const char* output); 34 | int getMachine() { return EM_X86_64; } 35 | void CreateCorePrStatus(); 36 | uint64_t WriteCorePrStatus(std::unique_ptr& map, uint64_t off); 37 | 38 | ~FakeCore(); 39 | private: 40 | int prnum; 41 | Elf64_prstatus *prstatus; 42 | }; 43 | 44 | } // namespace x86_64 45 | 46 | #endif // PARSER_COMMAND_FAKE_CORE_X86_64_FAKECORE_IMPL_H_ 47 | -------------------------------------------------------------------------------- /parser/command/fake/core/x86_64/tombstone_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_FAKE_CORE_X86_64_TOMBSTONE_PARSER_H_ 18 | #define PARSER_COMMAND_FAKE_CORE_X86_64_TOMBSTONE_PARSER_H_ 19 | 20 | #include "command/fake/core/tombstone_parser.h" 21 | #include "common/prstatus.h" 22 | #include 23 | #include 24 | 25 | namespace x86_64 { 26 | 27 | class TombstoneParser : public android::TombstoneParser { 28 | public: 29 | TombstoneParser(const char* path) : android::TombstoneParser(path) {} 30 | bool parse(); 31 | bool parseCmdline(); 32 | bool parseTid(); 33 | bool parseRegister(); 34 | bool parseBacktrace(); 35 | bool parseMemory(); 36 | bool parseMaps(); 37 | 38 | void * Regs() { return (void *)®s; } 39 | private: 40 | struct pt_regs regs; 41 | }; 42 | 43 | } // namespace x86_64 44 | 45 | #endif // PARSER_COMMAND_FAKE_CORE_X86_64_TOMBSTONE_PARSER_H_ 46 | -------------------------------------------------------------------------------- /parser/command/fake/exec/fake_executable.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "api/core.h" 19 | #include "command/fake/exec/fake_executable.h" 20 | 21 | int FakeExecutable::OptionExec(int argc, char* const argv[]) { 22 | if (!CoreApi::IsReady() 23 | || (argc < 2)) { 24 | return 0; 25 | } 26 | 27 | LinkMap* executable = CoreApi::FindLinkMap(argv[1]); 28 | RebuildExecDynamic(executable); 29 | return 0; 30 | } 31 | 32 | bool FakeExecutable::RebuildExecDynamic(LinkMap* executable) { 33 | LOGI("Rebuild FAKE PHDR\n"); 34 | if (CoreApi::Bits() == 64) 35 | return FakeExecutable::RebuildExecDynamic64(executable); 36 | else 37 | return FakeExecutable::RebuildExecDynamic32(executable); 38 | } 39 | 40 | void FakeExecutable::Usage() { 41 | LOGI("Usage: fake exec \n"); 42 | LOGI("core-parser> fake exec /system/bin/app_process64\n"); 43 | } 44 | -------------------------------------------------------------------------------- /parser/command/fake/exec/fake_executable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_FAKE_EXEC_FAKE_EXECUTABLE_H_ 18 | #define PARSER_COMMAND_FAKE_EXEC_FAKE_EXECUTABLE_H_ 19 | 20 | #include "common/link_map.h" 21 | 22 | class FakeExecutable { 23 | public: 24 | static int OptionExec(int argc, char* const argv[]); 25 | static bool RebuildExecDynamic(LinkMap* executable); 26 | static bool RebuildExecDynamic64(LinkMap* executable); 27 | static bool RebuildExecDynamic32(LinkMap* executable); 28 | static void Usage(); 29 | }; 30 | 31 | #endif // PARSER_COMMAND_FAKE_EXEC_FAKE_EXECUTABLE_H_ 32 | -------------------------------------------------------------------------------- /parser/command/fake/load/fake_load_block.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_FAKE_LOAD_FAKE_LOAD_BLOCK_H_ 18 | #define PARSER_COMMAND_FAKE_LOAD_FAKE_LOAD_BLOCK_H_ 19 | 20 | class FakeLoadBlock { 21 | public: 22 | static int OptionLoad(int argc, char* const argv[]); 23 | static void Usage(); 24 | }; 25 | 26 | #endif // PARSER_COMMAND_FAKE_LOAD_FAKE_LOAD_BLOCK_H_ 27 | -------------------------------------------------------------------------------- /parser/command/fake/stack/fake_java_stack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_FAKE_STACK_FAKEJAVASTACK_H_ 18 | #define PARSER_COMMAND_FAKE_STACK_FAKEJAVASTACK_H_ 19 | 20 | class FakeJavaStack { 21 | public: 22 | static int OptionJavaStack(int argc, char* const argv[]); 23 | static void Usage(); 24 | }; 25 | 26 | #endif // PARSER_COMMAND_FAKE_STACK_FAKEJAVASTACK_H_ 27 | -------------------------------------------------------------------------------- /parser/command/help.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "command/help.h" 19 | #include "command/command_manager.h" 20 | 21 | void Help::printCommandUsage(const char* cmd) { 22 | Command* command = CommandManager::FindCommand(cmd); 23 | if (command) { 24 | return command->usage(); 25 | } else { 26 | LOGI("Not found command (%s).\n", cmd); 27 | } 28 | } 29 | 30 | void Help::printCommands() { 31 | int index = 0; 32 | auto callback = [&](Command* command) -> bool { 33 | LOGI("%12s ", command->get().c_str()); 34 | ++index; 35 | if (!(index % ROW_NUM)) 36 | ENTER(); 37 | return false; 38 | }; 39 | CommandManager::ForeachCommand(callback); 40 | if (index % ROW_NUM) 41 | ENTER(); 42 | } 43 | 44 | int Help::main(int argc, char* const argv[]) { 45 | if (!(argc > 1)) { 46 | printCommands(); 47 | } else { 48 | printCommandUsage(argv[1]); 49 | } 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /parser/command/help.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_HELP_H_ 18 | #define PARSER_COMMAND_HELP_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class Help : public Command { 23 | public: 24 | static constexpr int ROW_NUM = 5; 25 | 26 | Help() : Command("help") {} 27 | ~Help() {} 28 | int main(int argc, char* const argv[]); 29 | void usage() {} 30 | void printCommands(); 31 | void printCommandUsage(const char* cmd); 32 | }; 33 | 34 | #endif // PARSER_COMMAND_HELP_H_ 35 | -------------------------------------------------------------------------------- /parser/command/llvm/cmd_cxx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_LLVM_CMD_CXX_H_ 18 | #define PARSER_COMMAND_LLVM_CMD_CXX_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class CxxCommand : public Command { 23 | public: 24 | CxxCommand() : Command("cxx") {} 25 | ~CxxCommand() {} 26 | int main(int argc, char* const argv[]); 27 | int prepare(int argc, char* const argv[]); 28 | void usage(); 29 | 30 | static int DumpCxxString(int argc, char* const argv[]); 31 | static int DumpCxxVector(int argc, char* const argv[]); 32 | static int DumpCxxMap(int argc, char* const argv[]); 33 | static int DumpCxxSet(int argc, char* const argv[]); 34 | static int DumpCxxUnOrderedMap(int argc, char* const argv[]); 35 | static int DumpCxxUnOrderedSet(int argc, char* const argv[]); 36 | static int DumpCxxList(int argc, char* const argv[]); 37 | static int DumpCxxDeque(int argc, char* const argv[]); 38 | }; 39 | 40 | #endif // PARSER_COMMAND_LLVM_CMD_CXX_H_ 41 | -------------------------------------------------------------------------------- /parser/command/llvm/cmd_scudo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_LLVM_CMD_SCUDO_H_ 18 | #define PARSER_COMMAND_LLVM_CMD_SCUDO_H_ 19 | 20 | #include "command/command.h" 21 | 22 | class ScudoCommand : public Command { 23 | public: 24 | ScudoCommand() : Command("scudo") {} 25 | ~ScudoCommand() {} 26 | int main(int argc, char* const argv[]); 27 | void usage(); 28 | }; 29 | 30 | #endif // PARSER_COMMAND_LLVM_CMD_SCUDO_H_ 31 | -------------------------------------------------------------------------------- /parser/command/remote/cmd_remote.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_CMD_REMOTE_H_ 18 | #define PARSER_COMMAND_REMOTE_CMD_REMOTE_H_ 19 | 20 | #include "command/command.h" 21 | #include 22 | 23 | class RemoteCommand : public Command { 24 | public: 25 | RemoteCommand() : Command("remote") {} 26 | ~RemoteCommand() {} 27 | int main(int argc, char* const argv[]); 28 | int prepare(int argc, char* const argv[]); 29 | void usage(); 30 | static int OptionRead(int argc, char* const argv[]); 31 | static int OptionWrite(int argc, char* const argv[]); 32 | static int OptionPause(int argc, char* const argv[]); 33 | static int OptionMaps(int argc, char* const argv[]); 34 | static void Write(int pid, uint64_t vaddr, uint64_t value) { 35 | Write(pid, vaddr, &value, 8); 36 | } 37 | static void Write(int pid, uint64_t vaddr, void *buf, uint64_t size); 38 | static bool Read(int pid, uint64_t vaddr, uint64_t size, uint8_t* buf); 39 | }; 40 | 41 | #endif // PARSER_COMMAND_REMOTE_CMD_REMOTE_H_ 42 | -------------------------------------------------------------------------------- /parser/command/remote/fakecore/arm/process_parser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "command/remote/fakecore/arm/process_parser.h" 19 | #include 20 | #include 21 | 22 | namespace arm { 23 | 24 | bool ProcessParser::parse() { 25 | memset(®s, 0x0, sizeof(regs)); 26 | 27 | bool ret = parseRegister() && 28 | parseMaps(); 29 | 30 | LOGI("Tid: %d\n", mProcessTid); 31 | return ret; 32 | } 33 | 34 | bool ProcessParser::parseRegister() { 35 | return true; 36 | } 37 | 38 | bool ProcessParser::parseMaps() { 39 | Opencore::ParseMaps(mProcessTid, mMaps); 40 | return true; 41 | } 42 | 43 | } // namespace arm 44 | -------------------------------------------------------------------------------- /parser/command/remote/fakecore/arm/process_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_FAKE_CORE_ARM_PROCESS_PARSER_H_ 18 | #define PARSER_COMMAND_REMOTE_FAKE_CORE_ARM_PROCESS_PARSER_H_ 19 | 20 | #include "command/remote/fakecore/process_parser.h" 21 | #include "common/prstatus.h" 22 | #include 23 | #include 24 | 25 | namespace arm { 26 | 27 | class ProcessParser : public fakecore::ProcessParser { 28 | public: 29 | ProcessParser(int pid) : fakecore::ProcessParser(pid) {} 30 | bool parse(); 31 | bool parseRegister(); 32 | bool parseMaps(); 33 | 34 | void * Regs() { return (void *)®s; } 35 | private: 36 | struct pt_regs regs; 37 | }; 38 | 39 | } // namespace arm 40 | 41 | #endif // PARSER_COMMAND_REMOTE_FAKE_CORE_ARM_PROCESS_PARSER_H_ 42 | -------------------------------------------------------------------------------- /parser/command/remote/fakecore/arm64/process_parser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "command/remote/fakecore/arm64/process_parser.h" 19 | #include 20 | #include 21 | 22 | namespace arm64 { 23 | 24 | bool ProcessParser::parse() { 25 | tagged_addr_ctrl = -1; 26 | pac_enabled_keys = -1; 27 | memset(®s, 0x0, sizeof(regs)); 28 | 29 | bool ret = parsePauth() && 30 | parseRegister() && 31 | parseMaps(); 32 | 33 | LOGI("Tid: %d\n", mProcessTid); 34 | return ret; 35 | } 36 | 37 | bool ProcessParser::parsePauth() { 38 | return true; 39 | } 40 | 41 | bool ProcessParser::parseRegister() { 42 | return true; 43 | } 44 | 45 | bool ProcessParser::parseMaps() { 46 | Opencore::ParseMaps(mProcessTid, mMaps); 47 | return true; 48 | } 49 | 50 | } // namespace arm64 51 | -------------------------------------------------------------------------------- /parser/command/remote/fakecore/arm64/process_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_FAKE_CORE_ARM64_PROCESS_PARSER_H_ 18 | #define PARSER_COMMAND_REMOTE_FAKE_CORE_ARM64_PROCESS_PARSER_H_ 19 | 20 | #include "command/remote/fakecore/process_parser.h" 21 | #include "common/prstatus.h" 22 | #include 23 | #include 24 | 25 | namespace arm64 { 26 | 27 | class ProcessParser : public fakecore::ProcessParser { 28 | public: 29 | ProcessParser(int pid) : fakecore::ProcessParser(pid) {} 30 | bool parse(); 31 | bool parseRegister(); 32 | bool parseMaps(); 33 | bool parsePauth(); 34 | 35 | uint64_t TaggedAddr() { return tagged_addr_ctrl; } 36 | uint64_t PacEnabledKeys() { return pac_enabled_keys; } 37 | void * Regs() { return (void *)®s; } 38 | private: 39 | uint64_t tagged_addr_ctrl; 40 | uint64_t pac_enabled_keys; 41 | struct pt_regs regs; 42 | }; 43 | 44 | } // namespace arm64 45 | 46 | #endif // PARSER_COMMAND_REMOTE_FAKE_CORE_ARM64_PROCESS_PARSER_H_ 47 | -------------------------------------------------------------------------------- /parser/command/remote/fakecore/riscv64/process_parser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "command/remote/fakecore/riscv64/process_parser.h" 19 | #include 20 | #include 21 | 22 | namespace riscv64 { 23 | 24 | bool ProcessParser::parse() { 25 | memset(®s, 0x0, sizeof(regs)); 26 | 27 | bool ret = parseRegister() && 28 | parseMaps(); 29 | 30 | LOGI("Tid: %d\n", mProcessTid); 31 | return ret; 32 | } 33 | 34 | bool ProcessParser::parseRegister() { 35 | return true; 36 | } 37 | 38 | bool ProcessParser::parseMaps() { 39 | Opencore::ParseMaps(mProcessTid, mMaps); 40 | return true; 41 | } 42 | 43 | } // namespace riscv64 44 | -------------------------------------------------------------------------------- /parser/command/remote/fakecore/riscv64/process_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_FAKE_CORE_RISCV64_PROCESS_PARSER_H_ 18 | #define PARSER_COMMAND_REMOTE_FAKE_CORE_RISCV64_PROCESS_PARSER_H_ 19 | 20 | #include "command/remote/fakecore/process_parser.h" 21 | #include "common/prstatus.h" 22 | #include 23 | #include 24 | 25 | namespace riscv64 { 26 | 27 | class ProcessParser : public fakecore::ProcessParser { 28 | public: 29 | ProcessParser(int pid) : fakecore::ProcessParser(pid) {} 30 | bool parse(); 31 | bool parseRegister(); 32 | bool parseMaps(); 33 | 34 | void * Regs() { return (void *)®s; } 35 | private: 36 | struct pt_regs regs; 37 | }; 38 | 39 | } // namespace riscv64 40 | 41 | #endif // PARSER_COMMAND_REMOTE_FAKE_CORE_RISCV64_PROCESS_PARSER_H_ 42 | -------------------------------------------------------------------------------- /parser/command/remote/fakecore/x86/process_parser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "command/remote/fakecore/x86/process_parser.h" 19 | #include 20 | #include 21 | 22 | namespace x86 { 23 | 24 | bool ProcessParser::parse() { 25 | memset(®s, 0x0, sizeof(regs)); 26 | 27 | bool ret = parseRegister() && 28 | parseMaps(); 29 | 30 | LOGI("Tid: %d\n", mProcessTid); 31 | return ret; 32 | } 33 | 34 | bool ProcessParser::parseRegister() { 35 | return true; 36 | } 37 | 38 | bool ProcessParser::parseMaps() { 39 | Opencore::ParseMaps(mProcessTid, mMaps); 40 | return true; 41 | } 42 | 43 | } // namespace x86 44 | -------------------------------------------------------------------------------- /parser/command/remote/fakecore/x86/process_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_FAKE_CORE_X86_PROCESS_PARSER_H_ 18 | #define PARSER_COMMAND_REMOTE_FAKE_CORE_X86_PROCESS_PARSER_H_ 19 | 20 | #include "command/remote/fakecore/process_parser.h" 21 | #include "common/prstatus.h" 22 | #include 23 | #include 24 | 25 | namespace x86 { 26 | 27 | class ProcessParser : public fakecore::ProcessParser { 28 | public: 29 | ProcessParser(int pid) : fakecore::ProcessParser(pid) {} 30 | bool parse(); 31 | bool parseRegister(); 32 | bool parseMaps(); 33 | 34 | void * Regs() { return (void *)®s; } 35 | private: 36 | struct pt_regs regs; 37 | }; 38 | 39 | } // namespace x86 40 | 41 | #endif // PARSER_COMMAND_REMOTE_FAKE_CORE_X86_PROCESS_PARSER_H_ 42 | -------------------------------------------------------------------------------- /parser/command/remote/fakecore/x86_64/process_parser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "command/remote/fakecore/x86_64/process_parser.h" 19 | #include 20 | #include 21 | 22 | namespace x86_64 { 23 | 24 | bool ProcessParser::parse() { 25 | memset(®s, 0x0, sizeof(regs)); 26 | 27 | bool ret = parseRegister() && 28 | parseMaps(); 29 | 30 | LOGI("Tid: %d\n", mProcessTid); 31 | return ret; 32 | } 33 | 34 | bool ProcessParser::parseRegister() { 35 | return true; 36 | } 37 | 38 | bool ProcessParser::parseMaps() { 39 | Opencore::ParseMaps(mProcessTid, mMaps); 40 | return true; 41 | } 42 | 43 | } // namespace x86_64 44 | -------------------------------------------------------------------------------- /parser/command/remote/fakecore/x86_64/process_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_FAKE_CORE_X86_64_PROCESS_PARSER_H_ 18 | #define PARSER_COMMAND_REMOTE_FAKE_CORE_X86_64_PROCESS_PARSER_H_ 19 | 20 | #include "command/remote/fakecore/process_parser.h" 21 | #include "common/prstatus.h" 22 | #include 23 | #include 24 | 25 | namespace x86_64 { 26 | 27 | class ProcessParser : public fakecore::ProcessParser { 28 | public: 29 | ProcessParser(int pid) : fakecore::ProcessParser(pid) {} 30 | bool parse(); 31 | bool parseRegister(); 32 | bool parseMaps(); 33 | 34 | void * Regs() { return (void *)®s; } 35 | private: 36 | struct pt_regs regs; 37 | }; 38 | 39 | } // namespace x86_64 40 | 41 | #endif // PARSER_COMMAND_REMOTE_FAKE_CORE_X86_64_PROCESS_PARSER_H_ 42 | -------------------------------------------------------------------------------- /parser/command/remote/hook/arm/hook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_HOOK_ARM_HOOK_IMPL_H_ 18 | #define PARSER_COMMAND_REMOTE_HOOK_ARM_HOOK_IMPL_H_ 19 | 20 | #include "common/prstatus.h" 21 | #include "command/remote/hook/lp32/hook.h" 22 | 23 | namespace arm { 24 | 25 | class Hook : public lp32::HookImpl { 26 | public: 27 | Hook(int pid) : lp32::HookImpl(pid) {} 28 | bool InjectLibrary(const char* library); 29 | uint64_t RegsSize() { return sizeof(pt_regs); } 30 | private: 31 | pt_regs ori_regs; 32 | }; 33 | 34 | } // namespace arm 35 | 36 | #endif // PARSER_COMMAND_REMOTE_HOOK_ARM_HOOK_IMPL_H_ 37 | -------------------------------------------------------------------------------- /parser/command/remote/hook/arm64/hook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_HOOK_ARM64_HOOK_IMPL_H_ 18 | #define PARSER_COMMAND_REMOTE_HOOK_ARM64_HOOK_IMPL_H_ 19 | 20 | #include "common/prstatus.h" 21 | #include "command/remote/hook/lp64/hook.h" 22 | 23 | namespace arm64 { 24 | 25 | class Hook : public lp64::HookImpl { 26 | public: 27 | Hook(int pid) : lp64::HookImpl(pid) {} 28 | uint64_t RegsSize() { return sizeof(pt_regs); } 29 | bool InjectLibrary(const char* library); 30 | bool CallMethod(const char* method, int argc, char* const argv[]); 31 | bool MethodContext(const char* method, pt_regs* call_regs, 32 | int argc, char* const argv[]); 33 | private: 34 | pt_regs ori_regs; 35 | }; 36 | 37 | } // namespace arm64 38 | 39 | #endif // PARSER_COMMAND_REMOTE_HOOK_ARM64_HOOK_IMPL_H_ 40 | -------------------------------------------------------------------------------- /parser/command/remote/hook/hook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_HOOK_HOOK_H_ 18 | #define PARSER_COMMAND_REMOTE_HOOK_HOOK_H_ 19 | 20 | #include 21 | 22 | class Hook { 23 | public: 24 | Hook(int p) : pid(p) {} 25 | virtual ~Hook() {} 26 | virtual uint64_t RegsSize() { return 0x0; } 27 | virtual bool InjectLibrary(const char* library) { return false; } 28 | virtual bool CallMethod(const char* method, int argc, char* const argv[]) { return false; } 29 | 30 | inline int Pid() { return pid; } 31 | bool Continue(); 32 | bool LoadContext(void *regs); 33 | bool StoreContext(void *regs); 34 | 35 | struct MethodTable { 36 | const char* method; 37 | const char* sign; 38 | int min; 39 | }; 40 | 41 | static int Main(int argc, char* const argv[]); 42 | static void Usage(); 43 | static std::unique_ptr MakeArch(int pid); 44 | private: 45 | int pid; 46 | }; 47 | 48 | #endif // PARSER_COMMAND_REMOTE_HOOK_HOOK_H_ 49 | -------------------------------------------------------------------------------- /parser/command/remote/hook/lp32/hook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_HOOK_LP32_HOOK_IMPL_H_ 18 | #define PARSER_COMMAND_REMOTE_HOOK_LP32_HOOK_IMPL_H_ 19 | 20 | #include "command/remote/hook/hook.h" 21 | 22 | namespace lp32 { 23 | 24 | class HookImpl : public Hook { 25 | public: 26 | HookImpl(int p) : Hook(p) {} 27 | }; 28 | 29 | } // namespace lp32 30 | 31 | #endif // PARSER_COMMAND_REMOTE_HOOK_LP32_HOOK_IMPL_H_ 32 | -------------------------------------------------------------------------------- /parser/command/remote/hook/lp64/hook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_HOOK_LP64_HOOK_IMPL_H_ 18 | #define PARSER_COMMAND_REMOTE_HOOK_LP64_HOOK_IMPL_H_ 19 | 20 | #include "command/remote/hook/hook.h" 21 | 22 | namespace lp64 { 23 | 24 | class HookImpl : public Hook { 25 | public: 26 | HookImpl(int p) : Hook(p) {} 27 | }; 28 | 29 | } // namespace lp64 30 | 31 | #endif // PARSER_COMMAND_REMOTE_HOOK_LP64_HOOK_IMPL_H_ 32 | -------------------------------------------------------------------------------- /parser/command/remote/hook/riscv64/hook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_HOOK_RISCV64_HOOK_IMPL_H_ 18 | #define PARSER_COMMAND_REMOTE_HOOK_RISCV64_HOOK_IMPL_H_ 19 | 20 | #include "common/prstatus.h" 21 | #include "command/remote/hook/lp64/hook.h" 22 | 23 | namespace riscv64 { 24 | 25 | class Hook : public lp64::HookImpl { 26 | public: 27 | Hook(int pid) : lp64::HookImpl(pid) {} 28 | bool InjectLibrary(const char* library); 29 | uint64_t RegsSize() { return sizeof(pt_regs); } 30 | private: 31 | pt_regs ori_regs; 32 | }; 33 | 34 | } // namespace riscv64 35 | 36 | #endif // PARSER_COMMAND_REMOTE_HOOK_RISCV64_HOOK_IMPL_H_ 37 | -------------------------------------------------------------------------------- /parser/command/remote/hook/x86/hook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_HOOK_X86_HOOK_IMPL_H_ 18 | #define PARSER_COMMAND_REMOTE_HOOK_X86_HOOK_IMPL_H_ 19 | 20 | #include "common/prstatus.h" 21 | #include "command/remote/hook/lp32/hook.h" 22 | 23 | namespace x86 { 24 | 25 | class Hook : public lp32::HookImpl { 26 | public: 27 | Hook(int pid) : lp32::HookImpl(pid) {} 28 | bool InjectLibrary(const char* library); 29 | uint64_t RegsSize() { return sizeof(pt_regs); } 30 | private: 31 | pt_regs ori_regs; 32 | }; 33 | 34 | } // namespace x86 35 | 36 | #endif // PARSER_COMMAND_REMOTE_HOOK_X86_HOOK_IMPL_H_ 37 | -------------------------------------------------------------------------------- /parser/command/remote/hook/x86_64/hook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_HOOK_X86_64_HOOK_IMPL_H_ 18 | #define PARSER_COMMAND_REMOTE_HOOK_X86_64_HOOK_IMPL_H_ 19 | 20 | #include "common/prstatus.h" 21 | #include "command/remote/hook/lp64/hook.h" 22 | 23 | namespace x86_64 { 24 | 25 | class Hook : public lp64::HookImpl { 26 | public: 27 | Hook(int pid) : lp64::HookImpl(pid) {} 28 | bool InjectLibrary(const char* library); 29 | uint64_t RegsSize() { return sizeof(pt_regs); } 30 | private: 31 | pt_regs ori_regs; 32 | }; 33 | 34 | } // namespace x86_64 35 | 36 | #endif // PARSER_COMMAND_REMOTE_HOOK_X86_64_HOOK_IMPL_H_ 37 | -------------------------------------------------------------------------------- /parser/command/remote/opencore/arm/opencore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_OPENCORE_ARM_OPENCORE_IMPL_H_ 18 | #define PARSER_COMMAND_REMOTE_OPENCORE_ARM_OPENCORE_IMPL_H_ 19 | 20 | #include "common/elf.h" 21 | #include "common/prstatus.h" 22 | #include "command/remote/opencore/lp32/opencore.h" 23 | 24 | namespace arm { 25 | 26 | class Opencore : public lp32::OpencoreImpl { 27 | public: 28 | Opencore() : lp32::OpencoreImpl(), 29 | prnum(0), prstatus(nullptr) {} 30 | ~Opencore(); 31 | void CreateCorePrStatus(int pid); 32 | void WriteCorePrStatus(FILE* fp); 33 | int IsSpecialFilterSegment(Opencore::VirtualMemoryArea& vma); 34 | int getMachine() { return EM_ARM; } 35 | private: 36 | int prnum; 37 | Elf32_prstatus *prstatus; 38 | }; 39 | 40 | } // namespace arm 41 | 42 | #endif // PARSER_COMMAND_REMOTE_OPENCORE_ARM_OPENCORE_IMPL_H_ 43 | -------------------------------------------------------------------------------- /parser/command/remote/opencore/arm64/opencore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_OPENCORE_ARM64_OPENCORE_IMPL_H_ 18 | #define PARSER_COMMAND_REMOTE_OPENCORE_ARM64_OPENCORE_IMPL_H_ 19 | 20 | #include "common/elf.h" 21 | #include "common/prstatus.h" 22 | #include "command/remote/opencore/lp64/opencore.h" 23 | 24 | namespace arm64 { 25 | 26 | class Opencore : public lp64::OpencoreImpl { 27 | public: 28 | Opencore() : lp64::OpencoreImpl(), 29 | prnum(0), prstatus(nullptr) {} 30 | ~Opencore(); 31 | void CreateCorePrStatus(int pid); 32 | void WriteCorePrStatus(FILE* fp); 33 | int IsSpecialFilterSegment(Opencore::VirtualMemoryArea& vma); 34 | void WriteCorePAC(int tid, FILE* fp); 35 | void WriteCoreMTE(int tid, FILE* fp); 36 | int getMachine() { return EM_AARCH64; } 37 | private: 38 | int prnum; 39 | Elf64_prstatus *prstatus; 40 | }; 41 | 42 | } // namespace arm64 43 | 44 | #endif // PARSER_COMMAND_REMOTE_OPENCORE_ARM64_OPENCORE_IMPL_H_ 45 | -------------------------------------------------------------------------------- /parser/command/remote/opencore/riscv64/opencore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_OPENCORE_RISCV64_OPENCORE_IMPL_H_ 18 | #define PARSER_COMMAND_REMOTE_OPENCORE_RISCV64_OPENCORE_IMPL_H_ 19 | 20 | #include "common/elf.h" 21 | #include "common/prstatus.h" 22 | #include "command/remote/opencore/lp64/opencore.h" 23 | 24 | namespace riscv64 { 25 | 26 | class Opencore : public lp64::OpencoreImpl { 27 | public: 28 | Opencore() : lp64::OpencoreImpl(), 29 | prnum(0), prstatus(nullptr) {} 30 | ~Opencore(); 31 | void CreateCorePrStatus(int pid); 32 | void WriteCorePrStatus(FILE* fp); 33 | int IsSpecialFilterSegment(Opencore::VirtualMemoryArea& vma); 34 | int getMachine() { return EM_RISCV; } 35 | private: 36 | int prnum; 37 | Elf64_prstatus *prstatus; 38 | }; 39 | 40 | } // namespace riscv64 41 | 42 | #endif // PARSER_COMMAND_REMOTE_OPENCORE_RISCV64_OPENCORE_IMPL_H_ 43 | -------------------------------------------------------------------------------- /parser/command/remote/opencore/x86/opencore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_OPENCORE_X86_OPENCORE_IMPL_H_ 18 | #define PARSER_COMMAND_REMOTE_OPENCORE_X86_OPENCORE_IMPL_H_ 19 | 20 | #include "common/elf.h" 21 | #include "common/prstatus.h" 22 | #include "command/remote/opencore/lp32/opencore.h" 23 | 24 | namespace x86 { 25 | 26 | class Opencore : public lp32::OpencoreImpl { 27 | public: 28 | Opencore() : lp32::OpencoreImpl(), 29 | prnum(0), prstatus(nullptr) {} 30 | ~Opencore(); 31 | void CreateCorePrStatus(int pid); 32 | void WriteCorePrStatus(FILE* fp); 33 | int IsSpecialFilterSegment(Opencore::VirtualMemoryArea& vma); 34 | int getMachine() { return EM_386; } 35 | private: 36 | int prnum; 37 | Elf32_prstatus *prstatus; 38 | }; 39 | 40 | } // namespace x86 41 | 42 | #endif // PARSER_COMMAND_REMOTE_OPENCORE_X86_OPENCORE_IMPL_H_ 43 | -------------------------------------------------------------------------------- /parser/command/remote/opencore/x86_64/opencore.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_OPENCORE_X86_64_OPENCORE_IMPL_H_ 18 | #define PARSER_COMMAND_REMOTE_OPENCORE_X86_64_OPENCORE_IMPL_H_ 19 | 20 | #include "common/elf.h" 21 | #include "common/prstatus.h" 22 | #include "command/remote/opencore/lp64/opencore.h" 23 | 24 | namespace x86_64 { 25 | 26 | class Opencore : public lp64::OpencoreImpl { 27 | public: 28 | Opencore() : lp64::OpencoreImpl(), 29 | prnum(0), prstatus(nullptr) {} 30 | ~Opencore(); 31 | void CreateCorePrStatus(int pid); 32 | void WriteCorePrStatus(FILE* fp); 33 | int IsSpecialFilterSegment(Opencore::VirtualMemoryArea& vma); 34 | int getMachine() { return EM_X86_64; } 35 | private: 36 | int prnum; 37 | Elf64_prstatus *prstatus; 38 | }; 39 | 40 | } // namespace x86_64 41 | 42 | #endif // PARSER_COMMAND_REMOTE_OPENCORE_X86_64_OPENCORE_IMPL_H_ 43 | -------------------------------------------------------------------------------- /parser/command/remote/setprop/prop_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_SETPROP_PROP_INFO_H_ 18 | #define PARSER_COMMAND_REMOTE_SETPROP_PROP_INFO_H_ 19 | 20 | #include 21 | 22 | #define PROP_VALUE_MAX 92 23 | 24 | class prop_info { 25 | public: 26 | constexpr static uint32_t kLongFlag = 1 << 16; 27 | constexpr static uint32_t kLongLegacyErrorBufferSize = 56; 28 | 29 | uint32_t serial; 30 | union { 31 | char value[PROP_VALUE_MAX]; 32 | struct { 33 | char error_message[kLongLegacyErrorBufferSize]; 34 | uint32_t offset; 35 | } long_property; 36 | }; 37 | char name[0]; 38 | }; 39 | 40 | #endif // PARSER_COMMAND_REMOTE_SETPROP_PROP_INFO_H_ 41 | -------------------------------------------------------------------------------- /parser/command/remote/setprop/property.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_COMMAND_REMOTE_SETPROP_PROPERTY_H_ 18 | #define PARSER_COMMAND_REMOTE_SETPROP_PROPERTY_H_ 19 | 20 | #include 21 | 22 | class AndroidProperty { 23 | public: 24 | static int Main(int argc, char* const argv[]); 25 | static void Usage(); 26 | static int Set(std::string& name, std::string& value); 27 | }; 28 | 29 | #endif // PARSER_COMMAND_REMOTE_SETPROP_PROPERTY_H_ 30 | -------------------------------------------------------------------------------- /plugin/simple/simple.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "logger/log.h" 18 | #include "command/command.h" 19 | #include "command/command_manager.h" 20 | 21 | class SimpleCommand : public Command { 22 | public: 23 | SimpleCommand() : Command("simple") {} 24 | ~SimpleCommand() {} 25 | int main(int argc, char* const argv[]); 26 | int prepare(int argc, char* const argv[]); 27 | void usage(); 28 | }; 29 | 30 | void __attribute__((constructor)) simple_init(void) { 31 | CommandManager::PushExtendCommand(new SimpleCommand()); 32 | } 33 | 34 | void __attribute__((destructor)) simple_fini(void) {} 35 | 36 | int SimpleCommand::prepare(int argc, char* const argv[]) { 37 | return Command::ONCHLD; 38 | } 39 | 40 | int SimpleCommand::main(int argc, char* const argv[]) { 41 | LOGI("command simple!\n"); 42 | return 0; 43 | } 44 | 45 | void SimpleCommand::usage() { 46 | LOGI("Usage: simple\n"); 47 | } 48 | -------------------------------------------------------------------------------- /tests/time.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | using namespace std::chrono; 21 | 22 | int main() { 23 | auto starttime = system_clock::now(); 24 | char *line; 25 | size_t length = 0; 26 | while (getline(&line, &length, stdin) > 0) {} 27 | duration diff = system_clock::now()- starttime; 28 | std::cout << "time: " << diff.count() << " (seconds)" << std::endl; 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /utils/backtrace/callstack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef UTILS_BACKTRACE_CALLSTACK_H_ 18 | #define UTILS_BACKTRACE_CALLSTACK_H_ 19 | 20 | #include 21 | #include 22 | 23 | #define CALLSTACK_MODULE_PATH "/system/lib64/libutilscallstack.so" 24 | #define CALLSTACK_DEFAULT_SYMB "_ZN7android9CallStackC2Ev" 25 | #define CALLSTACK_CONSTRUCTOR_CI_SYMB "_ZN7android9CallStackC1EPKci" 26 | #define CALLSTACK_UPDATE_SYMB "_ZN7android9CallStack6updateEii" 27 | #define CALLSTACK_DUMP_SYMB "_ZNK7android9CallStack4dumpEiiPKc" 28 | 29 | class CallStack { 30 | public: 31 | CallStack(); 32 | CallStack(const char* logtag, int32_t ignoreDepth); 33 | void update(int32_t ignoreDepth = 1, pid_t tid = -1); 34 | void dump(int fd, int indent = 0, const char* prefix = nullptr); 35 | private: 36 | __attribute__ ((__unused__)) uint8_t mFrameLines[40]; 37 | __attribute__ ((__unused__)) uint8_t reserved[216]; 38 | }; 39 | 40 | #endif // UTILS_BACKTRACE_CALLSTACK_H_ 41 | -------------------------------------------------------------------------------- /utils/base/macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef UTILS_BASE_MACROS_H_ 18 | #define UTILS_BASE_MACROS_H_ 19 | 20 | #define LIKELY(X) __builtin_expect(!!(X), 1) 21 | #define UNLIKELY(X) __builtin_expect(!!(X), 0) 22 | #define ALWAYS_INLINE __attribute__ ((always_inline)) 23 | #define NO_INLINE __attribute__ ((noinline)) 24 | #define FLATTEN __attribute__ ((flatten)) 25 | #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) 26 | #define ALIGNED(x) __attribute__ ((__aligned__(x))) 27 | #define PACKED(x) __attribute__ ((__aligned__(x), __packed__)) 28 | #define UNREACHABLE __builtin_unreachable 29 | #define HIDDEN __attribute__((visibility("hidden"))) 30 | #define EXPORT __attribute__((visibility("default"))) 31 | 32 | #endif // UTILS_BASE_MACROS_H_ 33 | -------------------------------------------------------------------------------- /utils/base/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024-present, Guanyou.Chen. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef UTILS_BASE_UTILS_H_ 18 | #define UTILS_BASE_UTILS_H_ 19 | 20 | #include 21 | 22 | class Utils { 23 | public: 24 | static bool SearchFile(const std::string& directory, std::string* result, const char* name); 25 | static bool InnerSearchFile(const std::string& directory, std::string* result, const std::string& name); 26 | static void ListFiles(const std::string& directory, std::string* result, const std::string& name); 27 | static std::string ConvertAscii(uint64_t value, int len); 28 | static uint64_t atol(const char* src); 29 | static int FreopenWrite(const char* path); 30 | static void CloseWriteout(int fd); 31 | static std::string ToHex(uint64_t value); 32 | static uint32_t CRC32(uint8_t* data, uint32_t len); 33 | static uint64_t CRC64(uint8_t* data, uint64_t len); 34 | }; 35 | 36 | #endif // UTILS_BASE_UTILS_H_ 37 | --------------------------------------------------------------------------------