├── .gitignore
├── .idea
├── .gitignore
├── compiler.xml
├── deploymentTargetDropDown.xml
├── gradle.xml
├── migrations.xml
├── misc.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── libs
│ └── wrap.sh
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── linkerbridge
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── cpp
│ │ ├── CMakeLists.txt
│ │ ├── Dobby
│ │ │ ├── .clang-format
│ │ │ ├── .gitignore
│ │ │ ├── CMakeLists.txt
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── README_zh-cn.md
│ │ │ ├── auto-build.sh
│ │ │ ├── builtin-plugin
│ │ │ │ ├── ApplicationEventMonitor
│ │ │ │ │ ├── MGCopyAnswerMonitor.cc
│ │ │ │ │ ├── dobby_monitor.h
│ │ │ │ │ ├── dynamic_loader_monitor.cc
│ │ │ │ │ ├── file_operation_monitor.cc
│ │ │ │ │ ├── memory_operation_instrument.cc
│ │ │ │ │ ├── posix_file_descriptor_operation_monitor.cc
│ │ │ │ │ └── posix_socket_network_monitor.cc
│ │ │ │ ├── BionicLinkerRestriction
│ │ │ │ │ ├── bionic_linker_restriction.cc
│ │ │ │ │ ├── bionic_linker_restriction.h
│ │ │ │ │ └── linker_restriction_demo.cc
│ │ │ │ ├── Dyld2HideLibrary
│ │ │ │ │ ├── CMakeLists.txt
│ │ │ │ │ ├── dyld2_hide_library.cc
│ │ │ │ │ └── dyld2_hide_library.h
│ │ │ │ ├── GlobalOffsetTableHook
│ │ │ │ │ ├── global_offset_table_hook.cc
│ │ │ │ │ └── global_offset_table_hook.h
│ │ │ │ ├── HideSystemCall
│ │ │ │ │ ├── syscall.darwin.s
│ │ │ │ │ └── syscall.linux.s
│ │ │ │ ├── LinkerImageLoadCallback
│ │ │ │ │ └── linker_load_callback.cc
│ │ │ │ ├── MemoryRemapHook
│ │ │ │ │ └── runtime_sdk.cc
│ │ │ │ ├── ObjcRuntimeHook
│ │ │ │ │ ├── CMakeLists.txt
│ │ │ │ │ ├── objc_runtime_hook.h
│ │ │ │ │ └── objc_runtime_hook.mm
│ │ │ │ ├── SupervisorCallMonitor
│ │ │ │ │ ├── CMakeLists.txt
│ │ │ │ │ ├── XnuInternal
│ │ │ │ │ │ ├── README
│ │ │ │ │ │ ├── mach
│ │ │ │ │ │ │ ├── audit_triggers.defs
│ │ │ │ │ │ │ ├── boolean.h
│ │ │ │ │ │ │ ├── bootstrap.h
│ │ │ │ │ │ │ ├── clock.defs
│ │ │ │ │ │ │ ├── clock.h
│ │ │ │ │ │ │ ├── clock_priv.defs
│ │ │ │ │ │ │ ├── clock_priv.h
│ │ │ │ │ │ │ ├── clock_reply.defs
│ │ │ │ │ │ │ ├── clock_reply.h
│ │ │ │ │ │ │ ├── clock_types.defs
│ │ │ │ │ │ │ ├── clock_types.h
│ │ │ │ │ │ │ ├── dyld_kernel.h
│ │ │ │ │ │ │ ├── error.h
│ │ │ │ │ │ │ ├── exc.defs
│ │ │ │ │ │ │ ├── exc.h
│ │ │ │ │ │ │ ├── exception.h
│ │ │ │ │ │ │ ├── exception_types.h
│ │ │ │ │ │ │ ├── host_info.h
│ │ │ │ │ │ │ ├── host_notify.h
│ │ │ │ │ │ │ ├── host_notify_reply.defs
│ │ │ │ │ │ │ ├── host_priv.defs
│ │ │ │ │ │ │ ├── host_priv.h
│ │ │ │ │ │ │ ├── host_reboot.h
│ │ │ │ │ │ │ ├── host_security.defs
│ │ │ │ │ │ │ ├── host_security.h
│ │ │ │ │ │ │ ├── host_special_ports.h
│ │ │ │ │ │ │ ├── i386
│ │ │ │ │ │ │ │ ├── _structs.h
│ │ │ │ │ │ │ │ ├── asm.h
│ │ │ │ │ │ │ │ ├── boolean.h
│ │ │ │ │ │ │ │ ├── exception.h
│ │ │ │ │ │ │ │ ├── fp_reg.h
│ │ │ │ │ │ │ │ ├── kern_return.h
│ │ │ │ │ │ │ │ ├── ndr_def.h
│ │ │ │ │ │ │ │ ├── processor_info.h
│ │ │ │ │ │ │ │ ├── rpc.h
│ │ │ │ │ │ │ │ ├── sdt_isa.h
│ │ │ │ │ │ │ │ ├── thread_state.h
│ │ │ │ │ │ │ │ ├── thread_status.h
│ │ │ │ │ │ │ │ ├── vm_param.h
│ │ │ │ │ │ │ │ └── vm_types.h
│ │ │ │ │ │ │ ├── kern_return.h
│ │ │ │ │ │ │ ├── kmod.h
│ │ │ │ │ │ │ ├── lock_set.defs
│ │ │ │ │ │ │ ├── lock_set.h
│ │ │ │ │ │ │ ├── mach.h
│ │ │ │ │ │ │ ├── mach_error.h
│ │ │ │ │ │ │ ├── mach_exc.defs
│ │ │ │ │ │ │ ├── mach_host.defs
│ │ │ │ │ │ │ ├── mach_host.h
│ │ │ │ │ │ │ ├── mach_init.h
│ │ │ │ │ │ │ ├── mach_interface.h
│ │ │ │ │ │ │ ├── mach_param.h
│ │ │ │ │ │ │ ├── mach_port.defs
│ │ │ │ │ │ │ ├── mach_port.h
│ │ │ │ │ │ │ ├── mach_right.h
│ │ │ │ │ │ │ ├── mach_syscalls.h
│ │ │ │ │ │ │ ├── mach_time.h
│ │ │ │ │ │ │ ├── mach_traps.h
│ │ │ │ │ │ │ ├── mach_types.defs
│ │ │ │ │ │ │ ├── mach_types.h
│ │ │ │ │ │ │ ├── mach_vm.defs
│ │ │ │ │ │ │ ├── mach_vm.h
│ │ │ │ │ │ │ ├── mach_voucher.defs
│ │ │ │ │ │ │ ├── mach_voucher.h
│ │ │ │ │ │ │ ├── mach_voucher_attr_control.defs
│ │ │ │ │ │ │ ├── mach_voucher_types.h
│ │ │ │ │ │ │ ├── machine.h
│ │ │ │ │ │ │ ├── machine
│ │ │ │ │ │ │ │ ├── _structs.h
│ │ │ │ │ │ │ │ ├── asm.h
│ │ │ │ │ │ │ │ ├── boolean.h
│ │ │ │ │ │ │ │ ├── exception.h
│ │ │ │ │ │ │ │ ├── kern_return.h
│ │ │ │ │ │ │ │ ├── machine_types.defs
│ │ │ │ │ │ │ │ ├── ndr_def.h
│ │ │ │ │ │ │ │ ├── processor_info.h
│ │ │ │ │ │ │ │ ├── rpc.h
│ │ │ │ │ │ │ │ ├── sdt.h
│ │ │ │ │ │ │ │ ├── sdt_isa.h
│ │ │ │ │ │ │ │ ├── thread_state.h
│ │ │ │ │ │ │ │ ├── thread_status.h
│ │ │ │ │ │ │ │ ├── vm_param.h
│ │ │ │ │ │ │ │ └── vm_types.h
│ │ │ │ │ │ │ ├── memory_entry.defs
│ │ │ │ │ │ │ ├── memory_entry.h
│ │ │ │ │ │ │ ├── memory_object_types.h
│ │ │ │ │ │ │ ├── message.h
│ │ │ │ │ │ │ ├── mig.h
│ │ │ │ │ │ │ ├── mig_errors.h
│ │ │ │ │ │ │ ├── mig_strncpy_zerofill_support.h
│ │ │ │ │ │ │ ├── mig_voucher_support.h
│ │ │ │ │ │ │ ├── ndr.h
│ │ │ │ │ │ │ ├── notify.defs
│ │ │ │ │ │ │ ├── notify.h
│ │ │ │ │ │ │ ├── policy.h
│ │ │ │ │ │ │ ├── port.h
│ │ │ │ │ │ │ ├── port_obj.h
│ │ │ │ │ │ │ ├── processor.defs
│ │ │ │ │ │ │ ├── processor.h
│ │ │ │ │ │ │ ├── processor_info.h
│ │ │ │ │ │ │ ├── processor_set.defs
│ │ │ │ │ │ │ ├── processor_set.h
│ │ │ │ │ │ │ ├── rpc.h
│ │ │ │ │ │ │ ├── sdt.h
│ │ │ │ │ │ │ ├── semaphore.h
│ │ │ │ │ │ │ ├── shared_memory_server.h
│ │ │ │ │ │ │ ├── shared_region.h
│ │ │ │ │ │ │ ├── std_types.defs
│ │ │ │ │ │ │ ├── std_types.h
│ │ │ │ │ │ │ ├── sync.h
│ │ │ │ │ │ │ ├── sync_policy.h
│ │ │ │ │ │ │ ├── task.defs
│ │ │ │ │ │ │ ├── task.h
│ │ │ │ │ │ │ ├── task_access.defs
│ │ │ │ │ │ │ ├── task_info.h
│ │ │ │ │ │ │ ├── task_inspect.h
│ │ │ │ │ │ │ ├── task_policy.h
│ │ │ │ │ │ │ ├── task_special_ports.h
│ │ │ │ │ │ │ ├── telemetry_notification.defs
│ │ │ │ │ │ │ ├── thread_act.defs
│ │ │ │ │ │ │ ├── thread_act.h
│ │ │ │ │ │ │ ├── thread_info.h
│ │ │ │ │ │ │ ├── thread_policy.h
│ │ │ │ │ │ │ ├── thread_special_ports.h
│ │ │ │ │ │ │ ├── thread_state.h
│ │ │ │ │ │ │ ├── thread_status.h
│ │ │ │ │ │ │ ├── thread_switch.h
│ │ │ │ │ │ │ ├── time_value.h
│ │ │ │ │ │ │ ├── vm_attributes.h
│ │ │ │ │ │ │ ├── vm_behavior.h
│ │ │ │ │ │ │ ├── vm_inherit.h
│ │ │ │ │ │ │ ├── vm_map.defs
│ │ │ │ │ │ │ ├── vm_map.h
│ │ │ │ │ │ │ ├── vm_page_size.h
│ │ │ │ │ │ │ ├── vm_param.h
│ │ │ │ │ │ │ ├── vm_prot.h
│ │ │ │ │ │ │ ├── vm_purgable.h
│ │ │ │ │ │ │ ├── vm_region.h
│ │ │ │ │ │ │ ├── vm_statistics.h
│ │ │ │ │ │ │ ├── vm_sync.h
│ │ │ │ │ │ │ ├── vm_task.h
│ │ │ │ │ │ │ └── vm_types.h
│ │ │ │ │ │ ├── syscall_sw.c
│ │ │ │ │ │ └── syscalls.c
│ │ │ │ │ ├── deprecated
│ │ │ │ │ │ ├── mach_system_call.cc
│ │ │ │ │ │ └── system_call.cc
│ │ │ │ │ ├── mach_system_call_log_handler.cc
│ │ │ │ │ ├── misc_utility.cc
│ │ │ │ │ ├── misc_utility.h
│ │ │ │ │ ├── sensitive_api_monitor.cc
│ │ │ │ │ ├── supervisor_call_monitor.cc
│ │ │ │ │ ├── supervisor_call_monitor.h
│ │ │ │ │ ├── system_call_log_handler.cc
│ │ │ │ │ └── test_supervisor_call_monitor.cc
│ │ │ │ └── SymbolResolver
│ │ │ │ │ ├── dobby_symbol_resolver.h
│ │ │ │ │ ├── elf
│ │ │ │ │ └── dobby_symbol_resolver.cc
│ │ │ │ │ └── macho
│ │ │ │ │ ├── dobby_symbol_resolver.cc
│ │ │ │ │ ├── dyld_shared_cache_symbol_table_iterator.cc
│ │ │ │ │ ├── shared-cache
│ │ │ │ │ └── dyld_cache_format.h
│ │ │ │ │ └── shared_cache_internal.h
│ │ │ ├── cmake
│ │ │ │ ├── AutoFiles.cmake
│ │ │ │ ├── Globals.cmake
│ │ │ │ ├── Macros.cmake
│ │ │ │ ├── Util.cmake
│ │ │ │ ├── XcodeGenerator.cmake
│ │ │ │ ├── dobby.xcode.source.cmake
│ │ │ │ └── ios.toolchain.cmake
│ │ │ ├── docs
│ │ │ │ ├── .nojekyll
│ │ │ │ ├── CNAME
│ │ │ │ ├── _cover_page.md
│ │ │ │ ├── _nav_bar.md
│ │ │ │ ├── _side_bar.md
│ │ │ │ ├── build-documentation.md
│ │ │ │ ├── get-started-android.md
│ │ │ │ ├── get-started-ios.md
│ │ │ │ ├── get-started.md
│ │ │ │ ├── images
│ │ │ │ │ └── vue-logo.png
│ │ │ │ ├── index.html
│ │ │ │ ├── intro-board.md
│ │ │ │ ├── scripts
│ │ │ │ │ ├── imagesloaded.pkgd.min.js
│ │ │ │ │ ├── palettify.min.js
│ │ │ │ │ └── palettify.styles.min.js
│ │ │ │ └── styles
│ │ │ │ │ ├── grid.min.css
│ │ │ │ │ ├── palettify.min.css
│ │ │ │ │ └── style.css
│ │ │ ├── example
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── android_common_api.cc
│ │ │ │ ├── darwin_common_api.cc
│ │ │ │ └── main.cc
│ │ │ ├── external
│ │ │ │ ├── external_helper
│ │ │ │ │ ├── CMakeLists.txt
│ │ │ │ │ ├── async_logger.cc
│ │ │ │ │ ├── async_logger.h
│ │ │ │ │ ├── variable_cache.c
│ │ │ │ │ └── variable_cache.h
│ │ │ │ ├── logging
│ │ │ │ │ ├── CMakeLists.txt
│ │ │ │ │ ├── cxxlogging.cc
│ │ │ │ │ ├── logging.c
│ │ │ │ │ └── logging
│ │ │ │ │ │ ├── check_logging.h
│ │ │ │ │ │ ├── cxxlogging.h
│ │ │ │ │ │ └── logging.h
│ │ │ │ └── xnucxx
│ │ │ │ │ ├── CMakeLists.txt
│ │ │ │ │ ├── LiteCollection.cc
│ │ │ │ │ ├── LiteIterator.cc
│ │ │ │ │ ├── LiteMemOpt.cc
│ │ │ │ │ ├── LiteMutableArray.cc
│ │ │ │ │ ├── LiteMutableBuffer.cc
│ │ │ │ │ ├── LiteObject.cc
│ │ │ │ │ └── xnucxx
│ │ │ │ │ ├── LiteCollection.h
│ │ │ │ │ ├── LiteIterator.h
│ │ │ │ │ ├── LiteMemOpt.h
│ │ │ │ │ ├── LiteMutableArray.h
│ │ │ │ │ ├── LiteMutableBuffer.h
│ │ │ │ │ └── LiteObject.h
│ │ │ ├── include
│ │ │ │ └── dobby.h
│ │ │ ├── source
│ │ │ │ ├── InstructionRelocation
│ │ │ │ │ ├── arm
│ │ │ │ │ │ ├── ARMInstructionRelocation.cc
│ │ │ │ │ │ └── ARMInstructionRelocation.h
│ │ │ │ │ ├── arm64
│ │ │ │ │ │ ├── ARM64InstructionRelocation.cc
│ │ │ │ │ │ ├── ARM64InstructionRelocation.h
│ │ │ │ │ │ └── ARM64PCLiteralInstructionTable.h
│ │ │ │ │ ├── x64
│ │ │ │ │ │ ├── X64InstructionRelocation.cc
│ │ │ │ │ │ └── X64InstructionRelocation.h
│ │ │ │ │ └── x86
│ │ │ │ │ │ ├── X86InstructionRelocation.cc
│ │ │ │ │ │ ├── X86InstructionRelocation.h
│ │ │ │ │ │ ├── deprecated
│ │ │ │ │ │ ├── Ia32Disassembler.cc
│ │ │ │ │ │ ├── X86OpcodoDecodeTable.cc
│ │ │ │ │ │ └── X86OpcodoDecodeTable.h
│ │ │ │ │ │ └── x86_insn_decode
│ │ │ │ │ │ ├── build_config.h
│ │ │ │ │ │ ├── x86_insn_decode.c
│ │ │ │ │ │ ├── x86_insn_decode.h
│ │ │ │ │ │ ├── x86_insn_reader.c
│ │ │ │ │ │ ├── x86_opcode_modrm_reg_group.c
│ │ │ │ │ │ ├── x86_opcode_one_byte.c
│ │ │ │ │ │ ├── x86_opcode_sse_group.c
│ │ │ │ │ │ └── x86_opcode_two_byte.c
│ │ │ │ ├── InterceptRouting
│ │ │ │ │ ├── ExtraInternalPlugin
│ │ │ │ │ │ ├── IntegrityReadCallback.cc
│ │ │ │ │ │ ├── IntegrityReadCallback.h
│ │ │ │ │ │ ├── NearBranchTrampoline
│ │ │ │ │ │ │ ├── NeaBranchTrampoline.cc
│ │ │ │ │ │ │ └── NearBranchTrampoline.h
│ │ │ │ │ │ ├── RegisterPlugin.cc
│ │ │ │ │ │ └── RegisterPlugin.h
│ │ │ │ │ ├── InterceptRouting.cpp
│ │ │ │ │ ├── InterceptRouting.h
│ │ │ │ │ └── RoutingPlugin
│ │ │ │ │ │ ├── DynamicBinaryInstrument
│ │ │ │ │ │ ├── DynamicBinaryInstrumentExport.cc
│ │ │ │ │ │ ├── dynamic-binary-instrument.cc
│ │ │ │ │ │ ├── dynamic-binary-instrument.h
│ │ │ │ │ │ ├── intercept_routing_handler.cc
│ │ │ │ │ │ └── intercept_routing_handler.h
│ │ │ │ │ │ ├── FunctionInlineReplace
│ │ │ │ │ │ ├── FunctionInlineReplaceExport.cc
│ │ │ │ │ │ ├── function-inline-replace.cc
│ │ │ │ │ │ └── function-inline-replace.h
│ │ │ │ │ │ └── FunctionWrapper
│ │ │ │ │ │ ├── FunctionWrapperExport.cc
│ │ │ │ │ │ ├── function-wrapper.cc
│ │ │ │ │ │ ├── function-wrapper.h
│ │ │ │ │ │ ├── intercept_routing_handler.cc
│ │ │ │ │ │ └── intercept_routing_handler.h
│ │ │ │ ├── Interceptor.cpp
│ │ │ │ ├── Interceptor.h
│ │ │ │ ├── MemoryAllocator
│ │ │ │ │ ├── AssemblyCodeBuilder.cc
│ │ │ │ │ ├── AssemblyCodeBuilder.h
│ │ │ │ │ ├── CodeBuffer
│ │ │ │ │ │ ├── CodeBufferBase.cc
│ │ │ │ │ │ ├── CodeBufferBase.h
│ │ │ │ │ │ ├── code-buffer-arm.cc
│ │ │ │ │ │ ├── code-buffer-arm.h
│ │ │ │ │ │ ├── code-buffer-arm64.cc
│ │ │ │ │ │ ├── code-buffer-arm64.h
│ │ │ │ │ │ ├── code-buffer-x64.cc
│ │ │ │ │ │ ├── code-buffer-x64.h
│ │ │ │ │ │ ├── code-buffer-x86.cc
│ │ │ │ │ │ └── code-buffer-x86.h
│ │ │ │ │ ├── MemoryArena.cc
│ │ │ │ │ ├── MemoryArena.h
│ │ │ │ │ ├── NearMemoryArena.cc
│ │ │ │ │ └── NearMemoryArena.h
│ │ │ │ ├── PlatformUnifiedInterface
│ │ │ │ │ ├── ExecMemory
│ │ │ │ │ │ ├── ClearCacheTool.h
│ │ │ │ │ │ └── CodePatchTool.h
│ │ │ │ │ └── StdMemory.h
│ │ │ │ ├── TrampolineBridge
│ │ │ │ │ ├── ClosureTrampolineBridge
│ │ │ │ │ │ ├── AssemblyClosureTrampoline.h
│ │ │ │ │ │ ├── arm
│ │ │ │ │ │ │ ├── ARMAssemblyClosureTrampoline.cc
│ │ │ │ │ │ │ ├── closure-bridge-arm.cc
│ │ │ │ │ │ │ ├── dummy
│ │ │ │ │ │ │ │ ├── closure-bridge-template-arm.cc
│ │ │ │ │ │ │ │ └── closure-trampoline-template-arm.S
│ │ │ │ │ │ │ └── helper-arm.cc
│ │ │ │ │ │ ├── arm64
│ │ │ │ │ │ │ ├── ARM64AssemblyClosureTrampoline.cc
│ │ │ │ │ │ │ ├── closure-bridge-arm64.cc
│ │ │ │ │ │ │ ├── dummy
│ │ │ │ │ │ │ │ ├── closure-bridge-template-arm64.c
│ │ │ │ │ │ │ │ ├── closure-trampoline-template-arm64.S
│ │ │ │ │ │ │ │ └── dynamic-closure-trampoline-template-arm64.S
│ │ │ │ │ │ │ └── helper-arm64.cc
│ │ │ │ │ │ ├── closure-trampoline-common-handler.cc
│ │ │ │ │ │ ├── closure-trampoline-common-handler.h
│ │ │ │ │ │ ├── x64
│ │ │ │ │ │ │ ├── X64AssemblyClosureTrampoline.cc
│ │ │ │ │ │ │ ├── closure-bridge-x64.cc
│ │ │ │ │ │ │ ├── dummy
│ │ │ │ │ │ │ │ ├── closure-bridge-template-x64.c
│ │ │ │ │ │ │ │ └── closure-trampoline-template-x64.S
│ │ │ │ │ │ │ └── helper-x64.cc
│ │ │ │ │ │ └── x86
│ │ │ │ │ │ │ ├── X86AssemblyClosureTrampoline.cc
│ │ │ │ │ │ │ ├── closure-bridge-x86.cc
│ │ │ │ │ │ │ └── helper-x86.cc
│ │ │ │ │ └── InterceptRoutingTrampoline
│ │ │ │ │ │ ├── arm
│ │ │ │ │ │ └── trampoline-arm.cc
│ │ │ │ │ │ ├── arm64
│ │ │ │ │ │ └── trampoline-arm64.cc
│ │ │ │ │ │ ├── x64
│ │ │ │ │ │ └── trampoline-x64.cc
│ │ │ │ │ │ └── x86
│ │ │ │ │ │ └── trampoline-x86.cc
│ │ │ │ ├── UserMode
│ │ │ │ │ ├── ExecMemory
│ │ │ │ │ │ ├── clear-cache-tool-all.cc
│ │ │ │ │ │ ├── clear-cache-tool
│ │ │ │ │ │ │ ├── clear-cache-tool-arm-dummy.cc
│ │ │ │ │ │ │ └── clear-cache-tool-arm64-dummy.cc
│ │ │ │ │ │ ├── code-patch-tool-darwin.cc
│ │ │ │ │ │ ├── code-patch-tool-posix.cc
│ │ │ │ │ │ ├── code-patch-tool-windows.cc
│ │ │ │ │ │ └── substrated
│ │ │ │ │ │ │ ├── include
│ │ │ │ │ │ │ ├── bootstrap.h
│ │ │ │ │ │ │ └── xpc
│ │ │ │ │ │ │ │ └── base.h
│ │ │ │ │ │ │ └── mach_interface_support
│ │ │ │ │ │ │ ├── substrated.defs
│ │ │ │ │ │ │ ├── substrated_client.c
│ │ │ │ │ │ │ ├── substrated_client.h
│ │ │ │ │ │ │ ├── substrated_server.c
│ │ │ │ │ │ │ └── substrated_server.h
│ │ │ │ │ ├── MultiThreadSupport
│ │ │ │ │ │ ├── ThreadSupport.cpp
│ │ │ │ │ │ └── ThreadSupport.h
│ │ │ │ │ ├── PlatformUtil
│ │ │ │ │ │ ├── Darwin
│ │ │ │ │ │ │ └── ProcesssRuntimeUtility.cc
│ │ │ │ │ │ ├── Linux
│ │ │ │ │ │ │ └── ProcesssRuntimeUtility.cc
│ │ │ │ │ │ ├── ProcessRuntimeUtility.h
│ │ │ │ │ │ └── Windows
│ │ │ │ │ │ │ └── ProcesssRuntimeUtility.cc
│ │ │ │ │ ├── Thread
│ │ │ │ │ │ ├── PlatformThread.cc
│ │ │ │ │ │ ├── PlatformThread.h
│ │ │ │ │ │ ├── platform-thread-posix.cc
│ │ │ │ │ │ └── platform-thread-windows.cc
│ │ │ │ │ └── UnifiedInterface
│ │ │ │ │ │ ├── platform-darwin
│ │ │ │ │ │ └── mach_vm.h
│ │ │ │ │ │ ├── platform-posix.cc
│ │ │ │ │ │ ├── platform-windows.cc
│ │ │ │ │ │ ├── platform.h
│ │ │ │ │ │ ├── semaphore.cc
│ │ │ │ │ │ └── semaphore.h
│ │ │ │ ├── common
│ │ │ │ │ ├── headers
│ │ │ │ │ │ └── common_header.h
│ │ │ │ │ └── macros
│ │ │ │ │ │ ├── constants_macro.h
│ │ │ │ │ │ ├── platform_macro.h
│ │ │ │ │ │ ├── types_macro.h
│ │ │ │ │ │ └── utilities_macro.h
│ │ │ │ ├── core
│ │ │ │ │ ├── arch
│ │ │ │ │ │ ├── Cpu.cc
│ │ │ │ │ │ ├── Cpu.h
│ │ │ │ │ │ ├── CpuFeature.cc
│ │ │ │ │ │ ├── CpuFeature.h
│ │ │ │ │ │ ├── CpuRegister.cc
│ │ │ │ │ │ ├── CpuRegister.h
│ │ │ │ │ │ ├── CpuUtils.h
│ │ │ │ │ │ ├── arm
│ │ │ │ │ │ │ ├── constants-arm.h
│ │ │ │ │ │ │ └── registers-arm.h
│ │ │ │ │ │ ├── arm64
│ │ │ │ │ │ │ ├── constants-arm64.h
│ │ │ │ │ │ │ └── registers-arm64.h
│ │ │ │ │ │ ├── x64
│ │ │ │ │ │ │ ├── constants-x64.h
│ │ │ │ │ │ │ └── registers-x64.h
│ │ │ │ │ │ └── x86
│ │ │ │ │ │ │ ├── constants-x86.h
│ │ │ │ │ │ │ ├── cpu-x86.cc
│ │ │ │ │ │ │ ├── cpu-x86.h
│ │ │ │ │ │ │ └── registers-x86.h
│ │ │ │ │ └── modules
│ │ │ │ │ │ ├── assembler
│ │ │ │ │ │ ├── assembler-arch.h
│ │ │ │ │ │ ├── assembler-arm.cc
│ │ │ │ │ │ ├── assembler-arm.h
│ │ │ │ │ │ ├── assembler-arm64.cc
│ │ │ │ │ │ ├── assembler-arm64.h
│ │ │ │ │ │ ├── assembler-ia32.cc
│ │ │ │ │ │ ├── assembler-ia32.h
│ │ │ │ │ │ ├── assembler-x64.cc
│ │ │ │ │ │ ├── assembler-x64.h
│ │ │ │ │ │ ├── assembler-x86-shared.cc
│ │ │ │ │ │ ├── assembler-x86-shared.h
│ │ │ │ │ │ ├── assembler.cc
│ │ │ │ │ │ └── assembler.h
│ │ │ │ │ │ ├── codegen
│ │ │ │ │ │ ├── codegen-arm.cc
│ │ │ │ │ │ ├── codegen-arm.h
│ │ │ │ │ │ ├── codegen-arm64.cc
│ │ │ │ │ │ ├── codegen-arm64.h
│ │ │ │ │ │ ├── codegen-ia32.cc
│ │ │ │ │ │ ├── codegen-ia32.h
│ │ │ │ │ │ ├── codegen-x64.cc
│ │ │ │ │ │ ├── codegen-x64.h
│ │ │ │ │ │ └── codegen.h
│ │ │ │ │ │ └── emulator
│ │ │ │ │ │ └── dummy.cc
│ │ │ │ ├── dobby.cpp
│ │ │ │ └── dobby_internal.h
│ │ │ └── tests
│ │ │ │ ├── CMakelists.txt
│ │ │ │ ├── InstructionRelocation
│ │ │ │ ├── aarch64
│ │ │ │ │ └── test_aarch64_instruction_relocation.cc
│ │ │ │ └── x64
│ │ │ │ │ └── test_x64_instruction_relocation.cc
│ │ │ │ └── catch.hpp
│ │ ├── FdPath.h
│ │ ├── base.h
│ │ ├── libc
│ │ │ └── platform
│ │ │ │ └── bionic
│ │ │ │ └── page.h
│ │ ├── linker
│ │ │ ├── android-base
│ │ │ │ └── macros.h
│ │ │ ├── fake_mmap.cpp
│ │ │ ├── fake_mmap.h
│ │ │ ├── linked_list.h
│ │ │ ├── linker.cpp
│ │ │ ├── linker.h
│ │ │ ├── linker_block_allocator.cpp
│ │ │ ├── linker_block_allocator.h
│ │ │ ├── linker_common_types.h
│ │ │ ├── linker_config.cpp
│ │ │ ├── linker_config.h
│ │ │ ├── linker_globals.h
│ │ │ ├── linker_gnu_hash.h
│ │ │ ├── linker_gun_hash.cpp
│ │ │ ├── linker_main.cpp
│ │ │ ├── linker_main.h
│ │ │ ├── linker_mapped_file_fragment.cpp
│ │ │ ├── linker_mapped_file_fragment.h
│ │ │ ├── linker_namespaces.cpp
│ │ │ ├── linker_namespaces.h
│ │ │ ├── linker_note_gnu_property.cpp
│ │ │ ├── linker_note_gnu_property.h
│ │ │ ├── linker_phdr.cpp
│ │ │ ├── linker_phdr.h
│ │ │ ├── linker_reloc_iterators.h
│ │ │ ├── linker_relocate.cpp
│ │ │ ├── linker_relocate.h
│ │ │ ├── linker_relocs.h
│ │ │ ├── linker_soinfo.cpp
│ │ │ ├── linker_soinfo.h
│ │ │ ├── linker_tls.cpp
│ │ │ ├── linker_tls.h
│ │ │ ├── linker_transparent_hugepage_support.cpp
│ │ │ ├── linker_utils.cpp
│ │ │ ├── linker_utils.h
│ │ │ ├── log.h
│ │ │ ├── mylinker.h
│ │ │ └── private
│ │ │ │ ├── bionic_elf_tls.cpp
│ │ │ │ └── bionic_elf_tls.h
│ │ ├── native-lib.cpp
│ │ └── utils
│ │ │ ├── FileUtils.cpp
│ │ │ ├── FileUtils.h
│ │ │ ├── ProcessRuntime.cpp
│ │ │ └── ProcessRuntime.h
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── linkerbridge
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable
│ │ ├── ic_launcher_background.xml
│ │ └── ic_launcher_foreground.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ │ └── xml
│ │ ├── backup_rules.xml
│ │ └── data_extraction_rules.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── linkerbridge
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # [Android U3D手游安全中级篇]
3 | # https://github.com/IIIImmmyyy/u3dCourse
4 |
5 | # ImyLinker
6 | this is Android Custom Linker by Android12 LinkerSourcesCode
7 |
8 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | }
4 |
5 | android {
6 | namespace 'com.example.linkerbridge'
7 | compileSdk 34
8 |
9 | defaultConfig {
10 | applicationId "com.example.linkerbridge"
11 | minSdk 25
12 | targetSdk 34
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | ndk {
18 | abiFilters "arm64-v8a","armeabi-v7a"
19 | }
20 | }
21 |
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 | compileOptions {
29 | sourceCompatibility JavaVersion.VERSION_1_8
30 | targetCompatibility JavaVersion.VERSION_1_8
31 | }
32 | externalNativeBuild {
33 | cmake {
34 | path file('src/main/cpp/CMakeLists.txt')
35 | version '3.22.1'
36 | }
37 | }
38 | sourceSets {
39 | main {
40 | jniLibs.srcDirs = ['libs']
41 | }
42 | }
43 | buildFeatures {
44 | viewBinding true
45 | }
46 | }
47 |
48 | dependencies {
49 |
50 | implementation 'androidx.appcompat:appcompat:1.6.1'
51 | implementation 'com.google.android.material:material:1.11.0'
52 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
53 | testImplementation 'junit:junit:4.13.2'
54 | androidTestImplementation 'androidx.test.ext:junit:1.1.5'
55 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
56 | }
--------------------------------------------------------------------------------
/app/libs/wrap.sh:
--------------------------------------------------------------------------------
1 | #!/system/bin/sh
2 | export LD_DEBUG=1
3 | exec "$@"
4 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/linkerbridge/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.linkerbridge;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.example.linkerbridge", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/.clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: LLVM
2 |
3 | IndentWidth: 2
4 | TabWidth: 2
5 | UseTab: Never
6 | ColumnLimit: 120
7 |
8 | # default is false
9 | AlignConsecutiveMacros: true
10 | AlignConsecutiveAssignments: true
11 | AlignConsecutiveDeclarations: true
12 |
13 | # default is true
14 | ReflowComments: false
15 | SortIncludes : false
16 | AllowShortFunctionsOnASingleLine: false
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .idea/
3 | *-build*/
4 | build-output/
5 |
6 | CMakeLists.txt.user
7 | CMakeCache.txt
8 | CMakeFiles
9 | CMakeScripts
10 | Testing
11 | Makefile
12 | cmake_install.cmake
13 | install_manifest.txt
14 | compile_commands.json
15 | CTestTestfile.cmake
16 | _deps
17 |
18 | ## Build generated
19 | build/
20 | DerivedData/
21 |
22 | ## Various settings
23 | *.pbxuser
24 | !default.pbxuser
25 | *.mode1v3
26 | !default.mode1v3
27 | *.mode2v3
28 | !default.mode2v3
29 | *.perspectivev3
30 | !default.perspectivev3
31 | xcuserdata/
32 |
33 | ## Other
34 | *.moved-aside
35 | *.xccheckout
36 | *.xcscmblueprint
37 |
38 | ## Obj-C/Swift specific
39 | *.hmap
40 | *.ipa
41 | *.dSYM.zip
42 | *.dSYM
43 |
44 | # Prerequisites
45 | *.d
46 |
47 | # Compiled Object files
48 | *.slo
49 | *.lo
50 | *.o
51 | *.obj
52 |
53 | # Precompiled Headers
54 | *.gch
55 | *.pch
56 |
57 | # Compiled Dynamic libraries
58 | *.so
59 | *.dylib
60 | *.dll
61 |
62 | # Fortran module files
63 | *.mod
64 | *.smod
65 |
66 | # Compiled Static libraries
67 | *.lai
68 | *.la
69 | *.a
70 | *.lib
71 |
72 | # Executables
73 | *.exe
74 | *.out
75 | *.app
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/README_zh-cn.md:
--------------------------------------------------------------------------------
1 | ## Dobby
2 |
3 | **待更新**
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/ApplicationEventMonitor/MGCopyAnswerMonitor.cc:
--------------------------------------------------------------------------------
1 | #include "./dobby_monitor.h"
2 |
3 | #include
4 | #include
5 |
6 | #define LOG_TAG "MGCopyAnswer"
7 |
8 | static uintptr_t getCallFirstArg(RegisterContext *reg_ctx) {
9 | uintptr_t result;
10 | #if defined(_M_X64) || defined(__x86_64__)
11 | #if defined(_WIN32)
12 | result = reg_ctx->general.regs.rcx;
13 | #else
14 | result = reg_ctx->general.regs.rdi;
15 | #endif
16 | #elif defined(__arm64__) || defined(__aarch64__)
17 | result = reg_ctx->general.regs.x0;
18 | #elif defined(__arm__)
19 | result = reg_ctx->general.regs.r0;
20 | #else
21 | #error "Not Support Architecture."
22 | #endif
23 | return result;
24 | }
25 |
26 | void common_handler(RegisterContext *reg_ctx, const HookEntryInfo *info) {
27 | CFStringRef key_ = 0;
28 | key_ = (CFStringRef)getCallFirstArg(reg_ctx);
29 |
30 | char str_key[256] = {0};
31 | CFStringGetCString(key_, str_key, 256, kCFStringEncodingUTF8);
32 | LOG("[#] MGCopyAnswer:: %s\n", str_key);
33 | }
34 |
35 | #if 0
36 | __attribute__((constructor)) static void ctor() {
37 | void *lib = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_NOW);
38 | void *MGCopyAnswer_addr = DobbySymbolResolver("libMobileGestalt.dylib", "MGCopyAnswer");
39 |
40 | sleep(1);
41 |
42 | dobby_enable_near_branch_trampoline();
43 | DobbyInstrument((void *)MGCopyAnswer_addr, common_handler);
44 | dobby_disable_near_branch_trampoline();
45 | }
46 | #endif
47 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/ApplicationEventMonitor/dobby_monitor.h:
--------------------------------------------------------------------------------
1 | #ifndef DOBBY_MONITOR_H
2 | #define DOBBY_MONITOR_H
3 |
4 | #include /* getenv */
5 | #include
6 | #include
7 |
8 | #include
9 | #include
10 |
11 | #include
12 | #include
13 |
14 | #include "dobby.h"
15 |
16 | #define LOG printf
17 |
18 | #ifdef __cplusplus
19 | extern "C" {
20 | #endif
21 |
22 | int DobbyHook(void *function_address, void *replace_call, void **origin_call);
23 |
24 | #ifdef __cplusplus
25 | }
26 | #endif
27 |
28 | #endif // !1DOBBY_MONITOR
29 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/BionicLinkerRestriction/bionic_linker_restriction.h:
--------------------------------------------------------------------------------
1 | #ifndef LINKER_RESTRICTION_H
2 | #define LINKER_RESTRICTION_H
3 |
4 | #include
5 |
6 | #ifdef __cplusplus
7 | extern "C" {
8 | #endif
9 |
10 | typedef void *soinfo_t;
11 |
12 | soinfo_t linker_dlopen(const char *filename, int flag);
13 |
14 | char *linker_soinfo_get_realpath(soinfo_t soinfo);
15 |
16 | uintptr_t linker_soinfo_to_handle(soinfo_t soinfo);
17 |
18 | void linker_iterate_soinfo(int (*cb)(soinfo_t soinfo));
19 |
20 | void linker_disable_namespace_restriction();
21 |
22 | #ifdef __cplusplus
23 | }
24 | #endif
25 |
26 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/BionicLinkerRestriction/linker_restriction_demo.cc:
--------------------------------------------------------------------------------
1 | #include "dobby.h"
2 |
3 | #include "bionic_linker_restriction.h"
4 |
5 | #include "logging/logging.h"
6 |
7 | #include
8 |
9 | #define LOG_TAG "AndroidLinkerRestriction"
10 |
11 | __attribute__((constructor)) static void ctor() {
12 | const char *lib = NULL;
13 |
14 | #if defined(__LP64__)
15 | lib = "/system/lib64/libandroid_runtime.so";
16 | #else
17 | lib = "/system/lib/libandroid_runtime.so";
18 | #endif
19 |
20 | void *vm = NULL;
21 |
22 | vm = DobbySymbolResolver(lib, "_ZN7android14AndroidRuntime7mJavaVME");
23 | LOG(1, "DobbySymbolResolver::vm %p", vm);
24 |
25 | #if 0
26 | linker_disable_namespace_restriction();
27 | void *handle = NULL;
28 | handle = dlopen(lib, RTLD_LAZY);
29 | vm = dlsym(handle, "_ZN7android14AndroidRuntime7mJavaVME");
30 | #else
31 | void *handle = NULL;
32 | handle = linker_dlopen(lib, RTLD_LAZY);
33 | vm = dlsym(handle, "_ZN7android14AndroidRuntime7mJavaVME");
34 | #endif
35 | LOG(1, "vm %p", vm);
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/Dyld2HideLibrary/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(dyld2_hide_library
2 | dyld2_hide_library.cc
3 | )
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/Dyld2HideLibrary/dyld2_hide_library.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 | int dyld2_hide_library(const char *library_name);
8 |
9 | #ifdef __cplusplus
10 | }
11 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/GlobalOffsetTableHook/global_offset_table_hook.h:
--------------------------------------------------------------------------------
1 | #ifndef DOBBY_GLOBAL_OFFSET_TABLE_HOOK
2 | #define DOBBY_GLOBAL_OFFSET_TABLE_HOOK
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | int DobbyGlobalOffsetTableReplace(char *image_name, char *symbol_name, void *fake_func, void **orig_func);
9 |
10 | #ifdef __cplusplus
11 | }
12 | #endif
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/HideSystemCall/syscall.darwin.s:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/cpp/Dobby/builtin-plugin/HideSystemCall/syscall.darwin.s
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/HideSystemCall/syscall.linux.s:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/cpp/Dobby/builtin-plugin/HideSystemCall/syscall.linux.s
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/MemoryRemapHook/runtime_sdk.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "dobby_internal.h"
6 |
7 | #include "PlatformUtil/ProcessRuntimeUtility.h"
8 |
9 | std::vector remap_addr_array;
10 |
11 | void DumpMemoryRemapPoint() {
12 | LiteCollectionIterator *iter = LiteCollectionIterator::withCollection(Interceptor::entries);
13 | while ((entry = reinterpret_cast(iter->getNextObject())) != NULL) {
14 | remap_addr_array->push_back(entry->target_address == address);
15 | }
16 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/ObjcRuntimeHook/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(objc_runtime_hook
2 | objc_runtime_hook.mm
3 | )
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/ObjcRuntimeHook/objc_runtime_hook.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 |
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 | IMP DobbyObjcReplace(Class _class, SEL _selector, IMP replacement);
13 |
14 | void DobbyObjcReplaceEx(const char *class_name, const char *selector_name, void *fake_impl, void **orig_impl);
15 |
16 | void *DobbyObjcResolveMethodImp(const char *class_name, const char *selector_name);
17 |
18 | #ifdef __cplusplus
19 | }
20 | #endif
21 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(supervisor_call_monitor STATIC
2 | mach_system_call_log_handler.cc
3 | system_call_log_handler.cc
4 | supervisor_call_monitor.cc
5 | sensitive_api_monitor.cc
6 | misc_utility.cc
7 | )
8 | target_link_libraries(supervisor_call_monitor
9 | external_helper
10 | ${dobby_output_name}
11 | )
12 |
13 | add_library(test_supervisor_call_monitor SHARED
14 | test_supervisor_call_monitor.cc
15 | )
16 | target_link_libraries(test_supervisor_call_monitor
17 | supervisor_call_monitor
18 | )
19 |
20 | include_directories(
21 | .
22 | )
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/README:
--------------------------------------------------------------------------------
1 | syscalls.c is automatically generated
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/bootstrap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | /*
29 | * Mach bootstrap interfaces (obsolete: header included only for compatibility)
30 | */
31 | #ifndef _MACH_BOOTSTRAP_H_
32 | #define _MACH_BOOTSTRAP_H_
33 |
34 | #endif /* _MACH_BOOTSTRAP_H_ */
35 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/host_notify.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_HOST_NOTIFY_H_
30 | #define _MACH_HOST_NOTIFY_H_
31 |
32 | #define HOST_NOTIFY_CALENDAR_CHANGE 0
33 | #define HOST_NOTIFY_CALENDAR_SET 1
34 | #define HOST_NOTIFY_TYPE_MAX 1
35 |
36 | #define HOST_CALENDAR_CHANGED_REPLYID 950
37 | #define HOST_CALENDAR_SET_REPLYID 951
38 |
39 | #endif /* _MACH_HOST_NOTIFY_H_ */
40 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/host_notify_reply.defs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | subsystem
30 | #if KERNEL_USER
31 | KernelUser
32 | #endif /* KERN_USER */
33 | host_notify_reply 950;
34 |
35 | #include
36 |
37 | simpleroutine host_calendar_changed(
38 | notify_port : mach_port_move_send_once_t);
39 |
40 | simpleroutine host_calendar_set(
41 | notify_port : mach_port_move_send_once_t);
42 |
43 | /* vim: set ft=c : */
44 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/host_reboot.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | /*
29 | * @OSF_COPYRIGHT@
30 | */
31 |
32 | #ifndef _MACH_HOST_REBOOT_
33 | #define _MACH_HOST_REBOOT_
34 |
35 | #define HOST_REBOOT_HALT 0x0008
36 | #define HOST_REBOOT_UPSDELAY 0x0100
37 | #define HOST_REBOOT_DEBUGGER 0x1000
38 |
39 | #endif /* _MACH_HOST_REBOOT_ */
40 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/i386/processor_info.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | /*
29 | * File: mach/i386/processor_info.h
30 | *
31 | * Data structure definitions for i386 specific processor control
32 | */
33 |
34 | #ifndef _MACH_I386_PROCESSOR_INFO_H_
35 | #define _MACH_I386_PROCESSOR_INFO_H_
36 |
37 | #endif /* _MACH_I386_PROCESSOR_INFO_H_ */
38 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/i386/rpc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2002,2000 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | /*
29 | * @OSF_COPYRIGHT@
30 | */
31 |
32 | #ifndef _MACH_I386_RPC_H_
33 | #define _MACH_I386_RPC_H_
34 |
35 | #endif /* _MACH_I386_RPC_H_ */
36 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/mach_right.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | #ifndef __MACH_RIGHT_H
29 | #define __MACH_RIGHT_H
30 |
31 | #include
32 |
33 | #if __has_include()
34 | #include
35 | #endif
36 |
37 | #endif // __MACH_RIGHT_H
38 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/mach_syscalls.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | /*
29 | * @OSF_COPYRIGHT@
30 | */
31 |
32 | #ifndef _MACH_MACH_SYSCALLS_H_
33 | #define _MACH_MACH_SYSCALLS_H_
34 |
35 | #include
36 |
37 | #endif /* _MACH_MACH_SYSCALLS_H_ */
38 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/_structs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_MACHINE__STRUCTS_H_
30 | #define _MACH_MACHINE__STRUCTS_H_
31 |
32 | #if defined (__i386__) || defined(__x86_64__)
33 | #include "mach/i386/_structs.h"
34 | #else
35 | #error architecture not supported
36 | #endif
37 |
38 | #endif /* _MACH_MACHINE__STRUCTS_H_ */
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/asm.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_MACHINE_ASM_H
30 | #define _MACH_MACHINE_ASM_H
31 |
32 | #if defined (__i386__) || defined(__x86_64__)
33 | #include "mach/i386/asm.h"
34 | #else
35 | #error architecture not supported
36 | #endif
37 |
38 | #endif /* _MACH_MACHINE_ASM_H */
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/boolean.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_MACHINE_BOOLEAN_H_
30 | #define _MACH_MACHINE_BOOLEAN_H_
31 |
32 | #if defined (__i386__) || defined(__x86_64__)
33 | #include "mach/i386/boolean.h"
34 | #else
35 | #error architecture not supported
36 | #endif
37 |
38 | #endif /* _MACH_MACHINE_BOOLEAN_H_ */
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/exception.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_MACHINE_EXCEPTION_H_
30 | #define _MACH_MACHINE_EXCEPTION_H_
31 |
32 | #if defined (__i386__) || defined(__x86_64__)
33 | #include "mach/i386/exception.h"
34 | #else
35 | #error architecture not supported
36 | #endif
37 |
38 | #endif /* _MACH_MACHINE_EXCEPTION_H_ */
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/kern_return.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_MACHINE_KERN_RETURN_H_
30 | #define _MACH_MACHINE_KERN_RETURN_H_
31 |
32 | #if defined (__i386__) || defined(__x86_64__)
33 | #include "mach/i386/kern_return.h"
34 | #else
35 | #error architecture not supported
36 | #endif
37 |
38 | #endif /* _MACH_MACHINE_KERN_RETURN_H_ */
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/ndr_def.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_MACHINE_NDR_DEF_H
30 | #define _MACH_MACHINE_NDR_DEF_H
31 |
32 | #if defined (__i386__) || defined(__x86_64__)
33 | #include "mach/i386/ndr_def.h"
34 | #else
35 | #error architecture not supported
36 | #endif
37 |
38 | #endif /* _MACH_MACHINE_NDR_DEF_H */
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/processor_info.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_MACHINE_PROCESSOR_INFO_H_
30 | #define _MACH_MACHINE_PROCESSOR_INFO_H_
31 |
32 | #if defined (__i386__) || defined(__x86_64__)
33 | #include "mach/i386/processor_info.h"
34 | #else
35 | #error architecture not supported
36 | #endif
37 |
38 | #endif /* _MACH_MACHINE_PROCESSOR_INFO_H_ */
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/rpc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_MACHINE_RPC_H_
30 | #define _MACH_MACHINE_RPC_H_
31 |
32 | #if defined (__i386__) || defined(__x86_64__)
33 | #include "mach/i386/rpc.h"
34 | #else
35 | #error architecture not supported
36 | #endif
37 |
38 | #endif /* _MACH_MACHINE_RPC_H_ */
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/sdt.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2007-2019 Apple Inc. All rights reserved.
3 | */
4 | /*
5 | * CDDL HEADER START
6 | *
7 | * The contents of this file are subject to the terms of the
8 | * Common Development and Distribution License, Version 1.0 only
9 | * (the "License"). You may not use this file except in compliance
10 | * with the License.
11 | *
12 | * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
13 | * or http://www.opensolaris.org/os/licensing.
14 | * See the License for the specific language governing permissions
15 | * and limitations under the License.
16 | *
17 | * When distributing Covered Code, include this CDDL HEADER in each
18 | * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19 | * If applicable, add the following below this CDDL HEADER, with the
20 | * fields enclosed by brackets "[]" replaced with your own identifying
21 | * information: Portions Copyright [yyyy] [name of copyright owner]
22 | *
23 | * CDDL HEADER END
24 | */
25 | /*
26 | * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
27 | * Use is subject to license terms.
28 | */
29 |
30 | #ifndef _MACH_MACHINE_SYS_SDT_H
31 | #define _MACH_MACHINE_SYS_SDT_H
32 |
33 | #include
34 |
35 |
36 | #endif /* _MACH_MACHINE_SYS_SDT_H */
37 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/sdt_isa.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | #ifndef _MACH_MACHINE_SDT_ISA_H_
29 | #define _MACH_MACHINE_SDT_ISA_H_
30 |
31 | #if defined (__i386__) || defined(__x86_64__)
32 | #include
33 | #else
34 | #error architecture not supported
35 | #endif
36 |
37 | #endif /* _BSD_MACHINE_SDT_ISA_H_ */
38 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/thread_state.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_MACHINE_THREAD_STATE_H_
30 | #define _MACH_MACHINE_THREAD_STATE_H_
31 |
32 | #if defined (__i386__) || defined(__x86_64__)
33 | #include "mach/i386/thread_state.h"
34 | #else
35 | #error architecture not supported
36 | #endif
37 |
38 | #endif /* _MACH_MACHINE_THREAD_STATE_H_ */
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/thread_status.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_MACHINE_THREAD_STATUS_H_
30 | #define _MACH_MACHINE_THREAD_STATUS_H_
31 |
32 | #if defined (__i386__) || defined(__x86_64__)
33 | #include "mach/i386/thread_status.h"
34 | #else
35 | #error architecture not supported
36 | #endif
37 |
38 | #endif /* _MACH_MACHINE_THREAD_STATUS_H_ */
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/vm_param.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_MACHINE_VM_PARAM_H_
30 | #define _MACH_MACHINE_VM_PARAM_H_
31 |
32 | #if defined (__i386__) || defined(__x86_64__)
33 | #include "mach/i386/vm_param.h"
34 | #else
35 | #error architecture not supported
36 | #endif
37 |
38 | #endif /* _MACH_MACHINE_VM_PARAM_H_ */
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/machine/vm_types.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 |
29 | #ifndef _MACH_MACHINE_VM_TYPES_H_
30 | #define _MACH_MACHINE_VM_TYPES_H_
31 |
32 | #if defined (__i386__) || defined(__x86_64__)
33 | #include "mach/i386/vm_types.h"
34 | #else
35 | #error architecture not supported
36 | #endif
37 |
38 | #endif /* _MACH_MACHINE_VM_TYPES_H_ */
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/sdt.h:
--------------------------------------------------------------------------------
1 | /*
2 | * CDDL HEADER START
3 | *
4 | * The contents of this file are subject to the terms of the
5 | * Common Development and Distribution License, Version 1.0 only
6 | * (the "License"). You may not use this file except in compliance
7 | * with the License.
8 | *
9 | * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 | * or http://www.opensolaris.org/os/licensing.
11 | * See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | *
14 | * When distributing Covered Code, include this CDDL HEADER in each
15 | * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 | * If applicable, add the following below this CDDL HEADER, with the
17 | * fields enclosed by brackets "[]" replaced with your own identifying
18 | * information: Portions Copyright [yyyy] [name of copyright owner]
19 | *
20 | * CDDL HEADER END
21 | */
22 | /*
23 | * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 | * Use is subject to license terms.
25 | */
26 |
27 | #ifndef _MACH_SDT_H
28 | #define _MACH_SDT_H
29 |
30 | #include
31 |
32 | #endif /* _MACH_SDT_H */
33 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/sync.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | /*
29 | ** This file contains compatibilty wrapper header for things that used
30 | ** to be generated from mach/sync.defs. Now that code is split into two
31 | ** different interface generator files, so include the two resulting
32 | ** headers here.
33 | */
34 | #include
35 | #include
36 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/telemetry_notification.defs:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012, Apple Inc. All rights reserved.
3 | */
4 |
5 | /*
6 | * Interface definition for the telemetry facility.
7 | */
8 |
9 | subsystem
10 | #if KERNEL_USER
11 | KernelUser
12 | #endif /* KERNEL_USER */
13 | telemetry_notification 5100;
14 |
15 | #include
16 | #include
17 |
18 | simpleroutine telemetry_notification(
19 | RequestPort telemetry_port : mach_port_t;
20 | in flags : uint32_t);
21 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/XnuInternal/mach/vm_task.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 | *
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 | *
6 | * This file contains Original Code and/or Modifications of Original Code
7 | * as defined in and that are subject to the Apple Public Source License
8 | * Version 2.0 (the 'License'). You may not use this file except in
9 | * compliance with the License. The rights granted to you under the License
10 | * may not be used to create, or enable the creation or redistribution of,
11 | * unlawful or unlicensed copies of an Apple operating system, or to
12 | * circumvent, violate, or enable the circumvention or violation of, any
13 | * terms of an Apple operating system software license agreement.
14 | *
15 | * Please obtain a copy of the License at
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 | *
18 | * The Original Code and all software distributed under the License are
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 | * Please see the License for the specific language governing rights and
24 | * limitations under the License.
25 | *
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 | */
28 | /*
29 | ** This file contains compatibilty wrapper header for things that are
30 | ** generated from mach/vm_map.defs into mach/vm_map.h.
31 | **
32 | ** This file will go away eventually - please switch.
33 | */
34 | #include
35 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/misc_utility.cc:
--------------------------------------------------------------------------------
1 | #include "misc_utility.h"
2 |
3 | #include
4 |
5 | segment_command_t *macho_kit_get_segment_by_name(mach_header_t *header, const char *segname)
6 | {
7 | segment_command_t *curr_seg_cmd = NULL;
8 |
9 | curr_seg_cmd = (segment_command_t *)((addr_t)header + sizeof(mach_header_t));
10 | for (int i = 0; i < header->ncmds; i++)
11 | {
12 | if (curr_seg_cmd->cmd == LC_SEGMENT_ARCH_DEPENDENT)
13 | {
14 | if (!strncmp(curr_seg_cmd->segname, segname, sizeof(curr_seg_cmd->segname)))
15 | {
16 | break;
17 | }
18 | }
19 | curr_seg_cmd = (segment_command_t *)((addr_t)curr_seg_cmd + curr_seg_cmd->cmdsize);
20 | }
21 |
22 | return curr_seg_cmd;
23 | }
24 |
25 | section_t *macho_kit_get_section_by_name(mach_header_t *header, const char *segname, const char *sectname)
26 | {
27 | section_t *section = NULL;
28 | segment_command_t *segment = NULL;
29 |
30 | int i = 0;
31 |
32 | segment = macho_kit_get_segment_by_name(header, segname);
33 | if (!segment)
34 | goto finish;
35 |
36 | section = (section_t *)((addr_t)segment + sizeof(segment_command_t));
37 | for (i = 0; i < segment->nsects; ++i)
38 | {
39 | if (!strncmp(section->sectname, sectname, sizeof(section->sectname)))
40 | {
41 | break;
42 | }
43 | section += 1;
44 | }
45 | if (i == segment->nsects)
46 | {
47 | section = NULL;
48 | }
49 |
50 | finish:
51 | return section;
52 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/misc_utility.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | typedef uintptr_t addr_t;
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | #if defined(__LP64__)
11 | typedef struct mach_header_64 mach_header_t;
12 | typedef struct segment_command_64 segment_command_t;
13 | typedef struct section_64 section_t;
14 | typedef struct nlist_64 nlist_t;
15 | #define LC_SEGMENT_ARCH_DEPENDENT LC_SEGMENT_64
16 | #else
17 | typedef struct mach_header mach_header_t;
18 | typedef struct segment_command segment_command_t;
19 | typedef struct section section_t;
20 | typedef struct nlist nlist_t;
21 | #define LC_SEGMENT_ARCH_DEPENDENT LC_SEGMENT
22 | #endif
23 |
24 | // get macho segment by segment name
25 | segment_command_t *macho_kit_get_segment_by_name(mach_header_t *mach_header, const char *segname);
26 |
27 | // get macho section by segment name and section name
28 | section_t *macho_kit_get_section_by_name(mach_header_t *mach_header, const char *segname, const char *sectname);
29 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/supervisor_call_monitor.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | typedef uintptr_t addr_t;
5 |
6 | #include "dobby.h"
7 |
8 | void supervisor_call_monitor_init();
9 |
10 | void supervisor_call_monitor_register_handler(DBICallTy handler);
11 |
12 | void supervisor_call_monitor_register_svc(addr_t svc_addr);
13 |
14 | void supervisor_call_monitor_register_image(void *header);
15 |
16 | void supervisor_call_monitor_register_main_app();
17 |
18 | void supervisor_call_monitor_register_system_kernel();
19 |
20 | void supervisor_call_monitor_register_syscall_call_log_handler();
21 |
22 | void supervisor_call_monitor_register_mach_syscall_call_log_handler();
23 |
24 | void supervisor_call_monitor_register_sensitive_api_handler();
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SupervisorCallMonitor/test_supervisor_call_monitor.cc:
--------------------------------------------------------------------------------
1 |
2 | #include "dobby_internal.h"
3 |
4 | #include "SupervisorCallMonitor/supervisor_call_monitor.h"
5 |
6 | #if 1
7 | __attribute__((constructor)) static void ctor() {
8 | log_set_level(2);
9 | log_switch_to_syslog();
10 |
11 | supervisor_call_monitor_init();
12 | supervisor_call_monitor_register_main_app();
13 | supervisor_call_monitor_register_syscall_call_log_handler();
14 | supervisor_call_monitor_register_mach_syscall_call_log_handler();
15 | }
16 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/builtin-plugin/SymbolResolver/dobby_symbol_resolver.h:
--------------------------------------------------------------------------------
1 | #ifndef DOBBY_SYMBOL_RESOLVER_H
2 | #define DOBBY_SYMBOL_RESOLVER_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | void *DobbySymbolResolver(const char *image_name, const char *symbol_name);
9 |
10 | #ifdef __cplusplus
11 | }
12 | #endif
13 |
14 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/cmake/AutoFiles.cmake:
--------------------------------------------------------------------------------
1 | function (AutoFiles _folder _base _pattern)
2 | if (ARGC GREATER 3)
3 | set(_exclude ${ARGN})
4 | else ()
5 | set(_exclude)
6 | endif ()
7 | file (GLOB _files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${_folder}/*)
8 | set (folderFiles)
9 | foreach (_fname ${_files})
10 | if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_fname})
11 | AutoFiles ("${_fname}" "${_base}" "${_pattern}" "${_exclude}")
12 | elseif (_fname MATCHES ${_pattern})
13 | if(_exclude)
14 | if (NOT _fname MATCHES ${_exclude})
15 | set(folderFiles ${folderFiles} ${_fname})
16 | endif ()
17 | else ()
18 | set(folderFiles ${folderFiles} ${_fname})
19 | endif ()
20 | endif ()
21 | endforeach ()
22 |
23 | string(REPLACE "./" "" _folder2 ${_folder})
24 | string(REPLACE "/" "\\" _folder2 ${_folder2})
25 | if (_folder2 STREQUAL ".")
26 | source_group(${_base} FILES ${folderFiles})
27 | else ()
28 | source_group(${_base}\\${_folder2} FILES ${folderFiles})
29 | endif ()
30 |
31 | set(AUTO_FILES_RESULT ${AUTO_FILES_RESULT} ${folderFiles} PARENT_SCOPE)
32 | endfunction ()
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/cmake/Macros.cmake:
--------------------------------------------------------------------------------
1 | macro(SET_OPTION option value)
2 | set(${option} ${value} CACHE INTERNAL "" FORCE)
3 | endmacro()
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/cmake/Util.cmake:
--------------------------------------------------------------------------------
1 | # Check files list exist
2 | function(check_files_exist CHECK_FILES)
3 | foreach(file ${CHECK_FILES})
4 | if(NOT EXISTS "${file}")
5 | message(FATAL_ERROR "${file} NOT EXISTS!")
6 | endif()
7 | endforeach()
8 | endfunction(check_files_exist CHECK_FILES)
9 |
10 | # Search suffix files
11 | function(search_suffix_files suffix INPUT_VARIABLE OUTPUT_VARIABLE)
12 | set(ResultFiles )
13 | foreach(filePath ${${INPUT_VARIABLE}})
14 | # message(STATUS "[*] searching *.${suffix} from ${filePath}")
15 | file(GLOB files ${filePath}/*.${suffix})
16 | set(ResultFiles ${ResultFiles} ${files})
17 | endforeach()
18 | set(${OUTPUT_VARIABLE} ${ResultFiles} PARENT_SCOPE)
19 | endfunction()
20 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/cmake/XcodeGenerator.cmake:
--------------------------------------------------------------------------------
1 | if(CMAKE_GENERATOR STREQUAL Xcode)
2 | message(STATUS "[*] Detect Xcode Project")
3 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/build/Debug)
4 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/build/Release)
5 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/build/Debug)
6 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/build/Release)
7 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/build/Debug)
8 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/build/Release)
9 | endif()
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/docs/.nojekyll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/cpp/Dobby/docs/.nojekyll
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/docs/CNAME:
--------------------------------------------------------------------------------
1 | dobby.libkernel.com
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/docs/_cover_page.md:
--------------------------------------------------------------------------------
1 | # Dobby beta
2 |
3 | > An exploit hook framework
4 |
5 | [GitHub](https://github.com/jmpews/dobby)
6 | [Get Started](#intro)
7 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/docs/_nav_bar.md:
--------------------------------------------------------------------------------
1 | * [Release Note](https://github.com/jmpews/Dobby/commits/master)
2 | * [Download](https://github.com/jmpews/Dobby/releases/tag/latest)
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/docs/_side_bar.md:
--------------------------------------------------------------------------------
1 | - [Home](/)
2 | - [Installation](build-documentation.md)
3 | - [Getting Started](get-started.md)
4 | - [Getting Started Within iOS](get-started-ios.md)
5 | - [Getting Started Within Android](get-started-android.md)
6 | - Setup
7 | - [Installation](build-documentation.md)
8 | - [Getting Started](get-started.md)
9 | - [Getting Started Within iOS](get-started-ios.md)
10 | - [Getting Started Within Android](get-started-android.md)
11 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/docs/get-started-ios.md:
--------------------------------------------------------------------------------
1 | # Getting Started With iOS
2 |
3 | available build option within iOS:
4 |
5 | ## add Dobby.framework to your project
6 |
7 | ```
8 | cmake .. -G Xcode \
9 | -DCMAKE_TOOLCHAIN_FILE=cmake/ios.toolchain.cmake \
10 | -DPLATFORM=OS64 -DARCHS="arm64" -DCMAKE_SYSTEM_PROCESSOR=arm64 \
11 | -DENABLE_BITCODE=0 -DENABLE_ARC=0 -DENABLE_VISIBILITY=1 -DDEPLOYMENT_TARGET=9.3 \
12 | -DDOBBY_GENERATE_SHARED=OFF -DGenerateDarwinFramework=ON
13 |
14 | ```
15 |
16 | **drag the `Dobby.xcodeproj` to your project**
17 |
18 |
19 | ## replace hook function
20 |
21 | ref source `builtin-plugin/ApplicationEventMonitor/dynamic_loader_monitor.cc`
22 |
23 | ref source `builtin-plugin/ApplicationEventMonitor/posix_file_descriptor_operation_monitor.cc`
24 |
25 | ## instrument function
26 |
27 | ref source `builtin-plugin/ApplicationEventMonitor/MGCopyAnswerMonitor.cc`
28 |
29 | ## replace pac function
30 |
31 | ```
32 | void *posix_spawn_ptr = __builtin_ptrauth_strip((void *)posix_spawn, ptrauth_key_asia);
33 | void *fake_posix_spawn_ptr = __builtin_ptrauth_strip((void *)fake_posix_spawn, ptrauth_key_asia);
34 |
35 | DobbyHook((void *)posix_spawn_ptr, (void *)fake_posix_spawn_ptr, (void **)&orig_posix_spawn);
36 |
37 | *(void **)&orig_posix_spawn = (void *)ptrauth_sign_unauthenticated((void *)orig_posix_spawn, ptrauth_key_asia, 0);
38 | ```
39 |
40 |
41 | ## objective-c toolkit
42 |
43 | invoke `DobbyOCReturnConstant("XXClass", "isVip", true);` will hook the objective-c instance/class method, and return the constant 1 automatically.
44 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/docs/images/vue-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/cpp/Dobby/docs/images/vue-logo.png
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/docs/intro-board.md:
--------------------------------------------------------------------------------
1 | # Intro
2 |
3 | a lightweight, multi-platform, multi-architecture exploit hook framework.
4 |
5 | **tips: any question [go to Discord](https://discordapp.com/invite/dAEEywt)**
6 |
7 | - Minimal and modular library
8 | - Multi-platform support(Windows/macOS/iOS/Android/Linux)
9 | - Multiple architecture support(X86-64, ARM, ARM64)
10 | - Clean code without STL(port to kernel easily)
11 | - Plugin support(DobbyDrill ?)
12 | - iOS kernel exploit support(Gollum ?)
13 |
14 | **[CHANGELOG]()**
15 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/docs/scripts/palettify.styles.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * palettify v1.0.3
3 | * (c) 2018 Dobromir Hristov
4 | * Released under the MIT License.
5 | */
6 | !function(o,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(o.palettifyStyles=o.palettifyStyles||{})}(this,function(o){"use strict";const t={opacities:[.2,.2],dynamic:{boxShadow:"0 2px 2px {{rgba.0}}, 0 4px 4px {{rgba.0}}, 0 8px 8px {{rgba.0}}, 0 16px 16px {{rgba.0}}, 0 32px 32px {{rgba.1}}, 0 64px 64px {{rgba.1}}"}},e={static:{border:"10px solid {{rgb.0}}",borderWidth:"10px"},dynamic:{borderWidth:"0px"}},r={opacities:[],static:{color:"{{rgb.0}}"}},i={opacities:[],static:{backgroundColor:"{{rgb.0}}",color:"{{ contrastColors.0 }}"}};o.boxShadow=t,o.border=e,o.diagonalBackground=r,o.zoomOutRight=i,Object.defineProperty(o,"__esModule",{value:!0})});
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/docs/styles/style.css:
--------------------------------------------------------------------------------
1 | .image-list {
2 | list-style: none;
3 | display: flex;
4 | flex-flow: row wrap;
5 | margin: auto -15px !important;
6 | }
7 |
8 | .image-list .hoverTarget {
9 | flex: 0 0 33%;
10 | padding: 15px;
11 | }
12 |
13 | .image-list .imageTarget {
14 | transition: .3s linear 0s;
15 | display: block;
16 | height: auto;
17 | }
18 |
19 | .imageTarget {
20 | transition: .3s;
21 | }
22 |
23 | .attachTo {
24 | transition: .3s;
25 | display: block;
26 | }
27 |
28 | .image-on-background {
29 | height: 200px;
30 | background-size: cover;
31 | }
32 |
33 | .grid-margin-x-bottom > .cell {
34 | margin-bottom: 30px;
35 | }
36 |
37 | /* Docsify styles */
38 | .sidebar-toggle {
39 | top: 0;
40 | bottom: auto;
41 | }
42 |
43 | .sidebar-toggle, body.close .sidebar-toggle span {
44 | background: #42b983;
45 | }
46 |
47 | .sidebar-toggle span {
48 | background: #ffffff;
49 | transition: .3s;
50 | }
51 |
52 | body.close .sidebar-toggle {
53 | transition: none;
54 | }
55 |
56 | body.close .sidebar-toggle span:first-of-type {
57 | transform: translate(0px, 4px) rotateZ(45deg);
58 | }
59 |
60 | body.close .sidebar-toggle span:nth-of-type(2) {
61 | transform: translate(0px, -2px) rotateZ(-45deg);
62 | }
63 |
64 | body.close .sidebar-toggle span:last-of-type {
65 | opacity: 0;
66 | transform: translateY(-8px);
67 | }
68 |
69 | @media screen and (max-width: 768px) {
70 | .hoverTarget {
71 | flex: 1 1 50%;
72 | }
73 | }
74 |
75 | @media screen and (min-width: 769px) {
76 | .sidebar-toggle {
77 | display: none;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/example/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if(SYSTEM.Darwin)
2 | add_executable(darwin_example
3 | main.cc
4 | darwin_common_api.cc
5 | )
6 |
7 | target_link_libraries(darwin_example
8 | ${dobby_output_name}
9 | )
10 | endif()
11 |
12 | if(SYSTEM.Android)
13 | add_executable(android_example
14 | main.cc
15 | android_common_api.cc
16 | )
17 |
18 | target_link_libraries(android_example
19 | aaa
20 | )
21 | endif()
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/example/main.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main(int argc, char const *argv[]) {
5 |
6 | std::cout << "Start..." << std::endl;
7 |
8 | return 0;
9 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/external_helper/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include_directories(.)
2 |
3 | set(SOURCE_FILE_LIST
4 | variable_cache.c
5 | async_logger.cc
6 | )
7 |
8 | set(SOURCE_HEADER_LIST
9 | async_logger.cc
10 | variable_cache.h
11 | )
12 |
13 | add_library(external_helper STATIC
14 | ${SOURCE_FILE_LIST}
15 | ${SOURCE_HEADER_LIST}
16 | )
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/external_helper/async_logger.h:
--------------------------------------------------------------------------------
1 | #ifndef ASYNC_LOGGER_H
2 | #define ASYNC_LOGGER_H
3 |
4 | void async_logger_print(char *str);
5 |
6 | void async_logger_init(char *logger_path);
7 |
8 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/external_helper/variable_cache.h:
--------------------------------------------------------------------------------
1 | #ifndef VARIABLE_CACHE_H
2 | #define VARIABLE_CACHE_H
3 |
4 | #include
5 | #include
6 |
7 | #define cache_set stash
8 | void cache_set(const char *name, uint64_t value);
9 |
10 | #define cache_get(x) cache(x)
11 | #define assert_cache(x) (assert(cache(x)), cache(x))
12 | uint64_t cache_get(const char *name);
13 |
14 | int serialized_to_file(const char *filepath);
15 |
16 | int unserialized_from_file(const char *filepath);
17 |
18 | #endif
19 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/logging/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include_directories(.)
2 |
3 | set(SOURCE_FILE_LIST
4 | ./cxxlogging.cc
5 | ./logging.c
6 | )
7 |
8 | set(SOURCE_HEADER_LIST
9 | logging/logging.h
10 | logging/check_logging.h
11 | logging/cxxlogging.h
12 | )
13 |
14 | add_library(logging STATIC
15 | ${SOURCE_FILE_LIST}
16 | ${SOURCE_HEADER_LIST}
17 | )
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/logging/cxxlogging.cc:
--------------------------------------------------------------------------------
1 | #include "logging/cxxlogging.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | void Logger::setLogLevel(LogLevel level) {
9 | log_level_ = level;
10 | }
11 |
12 | void Logger::log(LogLevel level, const char *tag, const char *fmt, ...) {
13 | if (level > log_level_) {
14 | va_list ap;
15 |
16 | va_start(ap, fmt);
17 | vprintf(fmt, ap);
18 | va_end(ap);
19 | }
20 | }
21 |
22 | void Logger::LogFatal(const char *fmt, ...) {
23 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/logging/logging/cxxlogging.h:
--------------------------------------------------------------------------------
1 | #ifndef CXXLOGGING_H_
2 | #define CXXLOGGING_H_
3 |
4 | #include "logging.h"
5 |
6 | typedef enum {
7 | LOG_LEVEL_FATAL = 0,
8 | LOG_LEVEL_ERROR = 1,
9 | LOG_LEVEL_WARNING = 2,
10 | LOG_LEVEL_DEBUG = 3,
11 | LOG_LEVEL_VERBOSE = 4
12 | } LogLevel;
13 |
14 | class Logger {
15 | public:
16 | void setLogLevel(LogLevel level);
17 |
18 | void log(LogLevel level, const char *tag, const char *fmt, ...);
19 |
20 | void LogFatal(const char *fmt, ...);
21 |
22 | private:
23 | LogLevel log_level_;
24 | };
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/xnucxx/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | include_directories(.)
3 |
4 | if(KERNELMODE)
5 | add_definitions(-DKERNELMODE)
6 | endif()
7 |
8 | set(xnucxx.SOURCE_FILE_LIST
9 | LiteMemOpt.cc
10 | LiteObject.cc
11 | LiteIterator.cc
12 | LiteCollection.cc
13 | LiteMutableBuffer.cc
14 | LiteMutableArray.cc
15 | )
16 |
17 | if(BUILD_INDEPENDENT_LIBRARY)
18 | add_library(xnucxx STATIC
19 | ${xnucxx.SOURCE_FILE_LIST}
20 | )
21 | endif()
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/xnucxx/LiteCollection.cc:
--------------------------------------------------------------------------------
1 | #include "xnucxx/LiteCollection.h"
2 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/xnucxx/LiteIterator.cc:
--------------------------------------------------------------------------------
1 | #include "xnucxx/LiteIterator.h"
2 | #include "xnucxx/LiteCollection.h"
3 | #include "xnucxx/LiteMemOpt.h"
4 |
5 | void LiteCollectionIterator::reset() {
6 | collection->initIterator(innerIterator);
7 | }
8 |
9 | bool LiteCollectionIterator::initWithCollection(const LiteCollectionInterface *inCollection) {
10 | int *ndxPtr = (int *)LiteMemOpt::alloc(sizeof(int));
11 | innerIterator = (void *)ndxPtr;
12 |
13 | inCollection->initIterator(this->innerIterator);
14 | collection = inCollection;
15 |
16 | return true;
17 | }
18 |
19 | LiteObject *LiteCollectionIterator::getNextObject() {
20 | LiteObject *retObj;
21 | collection->getNextObjectForIterator(this->innerIterator, &retObj);
22 | return retObj;
23 | }
24 |
25 | void LiteCollectionIterator::release() {
26 | if(innerIterator) {
27 | LiteMemOpt::free(innerIterator, sizeof(int));
28 |
29 | innerIterator = NULL;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/xnucxx/LiteMemOpt.cc:
--------------------------------------------------------------------------------
1 | #include "xnucxx/LiteMemOpt.h"
2 | #include
3 | #include
4 |
5 | #if 1
6 | void *_memcpy(void *dest, const void *src, int len) {
7 | return memcpy(dest, src, len);
8 | }
9 |
10 | void *_memset(void *dest, int ch, int count) {
11 | return memset(dest, ch, count);
12 | }
13 | #endif
14 |
15 | void *LiteMemOpt::alloc(int size) {
16 | void *result = malloc(size);
17 | return result;
18 | }
19 |
20 | void LiteMemOpt::free(void *address, int size) {
21 | return ::free(address);
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/xnucxx/LiteMutableBuffer.cc:
--------------------------------------------------------------------------------
1 | #include "xnucxx/LiteMutableBuffer.h"
2 | #include "xnucxx/LiteMemOpt.h"
3 |
4 | bool LiteMutableBuffer::initWithCapacity(uint32_t initCapacity) {
5 | if (initCapacity <= 0)
6 | return false;
7 |
8 | this->buffer = (uint8_t *)LiteMemOpt::alloc(initCapacity);
9 | this->buffer_cursor = buffer;
10 | this->buffer_capacity = initCapacity;
11 | return true;
12 | }
13 |
14 | uint32_t LiteMutableBuffer::ensureCapacity(uint32_t newCapacity) {
15 | if (newCapacity <= buffer_capacity)
16 | return buffer_capacity;
17 |
18 | // or use step
19 | newCapacity = newCapacity + (uint32_t)newCapacity / 2;
20 |
21 | // alloc new buffer
22 | uint8_t *newBuffer;
23 | newBuffer = (uint8_t *)LiteMemOpt::alloc(newCapacity);
24 | if(newBuffer == nullptr) {
25 | return 0;
26 | }
27 |
28 | // clear buffer content
29 | _memset(newBuffer, 'A', newCapacity);
30 |
31 | // copy the origin content
32 | uint32_t originContentSize = (uint32_t)(buffer_cursor - buffer);
33 | _memcpy(newBuffer, buffer, originContentSize);
34 |
35 | // free the origin
36 | uint32_t originBufferSize = buffer_capacity;
37 | LiteMemOpt::free(buffer, originBufferSize);
38 |
39 | // update info
40 | this->buffer = newBuffer;
41 | this->buffer_cursor = newBuffer + originContentSize;
42 | this->buffer_capacity = newCapacity;
43 |
44 | return newCapacity;
45 | }
46 |
47 | void LiteMutableBuffer::release() {
48 | if (buffer != NULL) {
49 | uint32_t originBufferSize = buffer_capacity;
50 | LiteMemOpt::free(buffer, originBufferSize);
51 |
52 | buffer = NULL;
53 | }
54 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/xnucxx/LiteObject.cc:
--------------------------------------------------------------------------------
1 | #include "xnucxx/LiteObject.h"
2 |
3 | void LiteObject::free() {
4 | return;
5 | }
6 |
7 | void LiteObject::release() {
8 | return;
9 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/xnucxx/xnucxx/LiteCollection.h:
--------------------------------------------------------------------------------
1 | #ifndef LITE_COLLECTION_H
2 | #define LITE_COLLECTION_H
3 |
4 | #include "xnucxx/LiteObject.h"
5 | #include "xnucxx/LiteIterator.h"
6 |
7 | class LiteCollectionInterface : public LiteObject, public LiteIteratorInterface::Delegate {
8 | public:
9 | virtual unsigned int getCount() = 0;
10 |
11 | virtual unsigned int getCapacity() = 0;
12 |
13 | virtual unsigned int ensureCapacity(unsigned int newCapacity) = 0;
14 |
15 | virtual bool initIterator(void *iterator) const = 0;
16 |
17 | virtual bool getNextObjectForIterator(void *iterator, LiteObject **ret) const = 0;
18 | };
19 |
20 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/xnucxx/xnucxx/LiteIterator.h:
--------------------------------------------------------------------------------
1 | #ifndef LITE_ITERATOR_H
2 | #define LITE_ITERATOR_H
3 |
4 | #include "xnucxx/LiteObject.h"
5 |
6 | class LiteIteratorInterface : public LiteObject {
7 | public:
8 | class Delegate {
9 | public:
10 | virtual bool initIterator(void *iterationContext) const = 0;
11 |
12 | virtual bool getNextObjectForIterator(void *iterationContext, LiteObject **nextObject) const = 0;
13 | };
14 |
15 | public:
16 | virtual void reset() = 0;
17 |
18 | virtual LiteObject *getNextObject() = 0;
19 | };
20 |
21 | class LiteCollectionInterface;
22 | class LiteCollectionIterator : public LiteIteratorInterface {
23 | protected:
24 | const LiteCollectionInterface *collection;
25 |
26 | void *innerIterator;
27 |
28 | public:
29 | explicit LiteCollectionIterator(const LiteCollectionInterface *collection) {
30 | initWithCollection(collection);
31 | }
32 |
33 | ~LiteCollectionIterator() {
34 | release();
35 | }
36 |
37 | // === LiteObject override ===
38 | void release() override;
39 |
40 | // === LiteIteratorInterface override ===
41 | void reset() override;
42 |
43 | LiteObject *getNextObject() override;
44 |
45 | bool initWithCollection(const LiteCollectionInterface *collection);
46 | };
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/xnucxx/xnucxx/LiteMemOpt.h:
--------------------------------------------------------------------------------
1 | #ifndef LITE_MEM_OPT_H
2 | #define LITE_MEM_OPT_H
3 |
4 | extern void *_memcpy(void *, const void *, int);
5 |
6 | extern void _bzero(void *, int);
7 |
8 | extern void *_memset(void *, int, int);
9 |
10 | class LiteMemOpt {
11 | public:
12 | static void *alloc(int size);
13 |
14 | static void free(void *address, int size);
15 | };
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/xnucxx/xnucxx/LiteMutableArray.h:
--------------------------------------------------------------------------------
1 | #ifndef LITE_MUTABLE_ARRAY_H
2 | #define LITE_MUTABLE_ARRAY_H
3 |
4 | #include "xnucxx/LiteCollection.h"
5 | #include "xnucxx/LiteIterator.h"
6 |
7 | class LiteMutableArray : public LiteCollectionInterface {
8 | protected:
9 | const LiteObject **array;
10 |
11 | unsigned int array_count;
12 |
13 | unsigned int array_capacity;
14 |
15 | public:
16 | explicit LiteMutableArray(int count);
17 |
18 | ~LiteMutableArray();
19 |
20 | // === LiteObject override ==
21 | void release() override;
22 |
23 | // === LiteCollectionInterface override ==
24 | unsigned int getCount() override;
25 |
26 | unsigned int getCapacity() override;
27 |
28 | unsigned int ensureCapacity(unsigned int newCapacity) override;
29 |
30 | // === LiteIteratorInterface::Delegate override ==
31 | bool initIterator(void *iterator) const override;
32 |
33 | bool getNextObjectForIterator(void *iterator, LiteObject **ret) const override;
34 |
35 | virtual LiteObject *getObject(int index);
36 |
37 | virtual bool pushObject(const LiteObject *object);
38 | };
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/xnucxx/xnucxx/LiteMutableBuffer.h:
--------------------------------------------------------------------------------
1 | #ifndef LITE_MUTABLE_BUFFER_H
2 | #define LITE_MUTABLE_BUFFER_H
3 |
4 | #include "xnucxx/LiteObject.h"
5 |
6 | class LiteMutableBuffer : public LiteObject {
7 | protected:
8 | uint8_t *buffer;
9 |
10 | uint8_t *buffer_cursor;
11 |
12 | uint32_t buffer_capacity;
13 |
14 | public:
15 | LiteMutableBuffer() {
16 | initWithCapacity(8);
17 | }
18 |
19 | LiteMutableBuffer(uint32_t size) {
20 | initWithCapacity(size);
21 | }
22 |
23 | ~LiteMutableBuffer() {
24 | release();
25 | }
26 |
27 | // === LiteObject override ==
28 | void release() override;
29 |
30 | virtual bool initWithCapacity(uint32_t initCapacity);
31 |
32 | virtual uint32_t ensureCapacity(uint32_t newCapacity);
33 |
34 | virtual inline uint32_t getSize() {
35 | return (uint32_t)(buffer_cursor - buffer);
36 | }
37 |
38 | virtual inline uint32_t getCapacity() {
39 | return buffer_capacity;
40 | }
41 |
42 | virtual inline void *getCursor() {
43 | return buffer_cursor;
44 | }
45 |
46 | virtual inline void *getRawBuffer() {
47 | return buffer;
48 | }
49 | };
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/external/xnucxx/xnucxx/LiteObject.h:
--------------------------------------------------------------------------------
1 | #ifndef LITE_OBJECT_H
2 | #define LITE_OBJECT_H
3 |
4 | #include "common/headers/common_header.h"
5 |
6 | class LiteObject {
7 | public:
8 | virtual void free();
9 |
10 | virtual void release();
11 | };
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InstructionRelocation/arm64/ARM64InstructionRelocation.h:
--------------------------------------------------------------------------------
1 | #ifndef INSTRUCTION_RELOCATION_ARM64_H
2 | #define INSTRUCTION_RELOCATION_ARM64_H
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "core/arch/arm64/constants-arm64.h"
7 |
8 | namespace zz {
9 | namespace arm64 {
10 |
11 | // Generate the relocated instruction
12 | void GenRelocateCodeAndBranch(void *buffer, AssemblyCodeChunk *origin, AssemblyCodeChunk *relocated);
13 |
14 | } // namespace arm64
15 | } // namespace zz
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InstructionRelocation/arm64/ARM64PCLiteralInstructionTable.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by jmpews on 2019/1/26.
3 | //
4 |
5 | #ifndef ARM64_PC_LITERAL_INSTRUCTION_TABLE_H
6 | #define ARM64_PC_LITERAL_INSTRUCTION_TABLE_H
7 |
8 | #endif
9 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InstructionRelocation/x64/X64InstructionRelocation.h:
--------------------------------------------------------------------------------
1 | #ifndef INSTRUCTION_RELOCATION_X64_H
2 | #define INSTRUCTION_RELOCATION_X64_H
3 |
4 | #include "common/headers/common_header.h"
5 |
6 | #include "core/arch/x64/constants-x64.h"
7 |
8 | #include "MemoryAllocator/AssemblyCodeBuilder.h"
9 |
10 | namespace zz {
11 | namespace x64 {
12 |
13 | // Generate the relocated instruction
14 | AssemblyCodeChunk *GenRelocateCodeAndBranch(void *buffer, int *relocate_size, addr_t from_ip, addr_t to_ip);
15 |
16 | } // namespace x64
17 | } // namespace zz
18 |
19 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InstructionRelocation/x86/X86InstructionRelocation.h:
--------------------------------------------------------------------------------
1 | #ifndef INSTRUCTION_RELOCATION_X64_H
2 | #define INSTRUCTION_RELOCATION_X64_H
3 |
4 | #include "common/headers/common_header.h"
5 |
6 | #include "core/arch/x86/constants-x86.h"
7 |
8 | #include "MemoryAllocator/AssemblyCodeBuilder.h"
9 |
10 | namespace zz {
11 | namespace x86 {
12 |
13 | // Generate the relocated instruction
14 | AssemblyCodeChunk *GenRelocateCodeAndBranch(void *buffer, int *relocate_size, addr_t from_pc, addr_t to_pc);
15 |
16 | } // namespace x86
17 | } // namespace zz
18 |
19 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/ExtraInternalPlugin/IntegrityReadCallback.cc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/cpp/Dobby/source/InterceptRouting/ExtraInternalPlugin/IntegrityReadCallback.cc
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/ExtraInternalPlugin/IntegrityReadCallback.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/cpp/Dobby/source/InterceptRouting/ExtraInternalPlugin/IntegrityReadCallback.h
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/ExtraInternalPlugin/NearBranchTrampoline/NearBranchTrampoline.h:
--------------------------------------------------------------------------------
1 | #ifndef PLUGIN_NEAR_BRANCH_TRAMPOLINE_H
2 | #define PLUGIN_NEAR_BRANCH_TRAMPOLINE_H
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "InterceptRouting/ExtraInternalPlugin/RegisterPlugin.h"
7 |
8 | class NearBranchTrampolinePlugin : public RoutingPlugin {
9 | // @Return: if false will continue to iter next plugin
10 | bool Prepare(InterceptRouting *routing) {
11 | return false;
12 | };
13 |
14 | bool Active(InterceptRouting *routing);
15 |
16 | bool GenerateTrampolineBuffer(InterceptRouting *routing, void *src, void *dst);
17 |
18 | };
19 |
20 | #endif
21 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/ExtraInternalPlugin/RegisterPlugin.cc:
--------------------------------------------------------------------------------
1 | #include "InterceptRouting/ExtraInternalPlugin/RegisterPlugin.h"
2 |
3 | LiteMutableArray *ExtraInternalPlugin::plugins;
4 |
5 | ExtraInternalPlugin *ExtraInternalPlugin::near_branch_trampoline = NULL;
6 |
7 | void ExtraInternalPlugin::registerPlugin(const char *name, ExtraInternalPlugin *plugin) {
8 | DLOG(1, "register %s plugin", name);
9 |
10 | if (ExtraInternalPlugin::plugins == NULL) {
11 | ExtraInternalPlugin::plugins = new LiteMutableArray(8);
12 | }
13 |
14 | ExtraInternalPlugin::plugins->pushObject(reinterpret_cast(plugin));
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/ExtraInternalPlugin/RegisterPlugin.h:
--------------------------------------------------------------------------------
1 | #ifndef EXTRA_INTERNAL_PLUGIN_H
2 | #define EXTRA_INTERNAL_PLUGIN_H
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "InterceptRouting/InterceptRouting.h"
7 |
8 | // Internal Plugin
9 | class ExtraInternalPlugin {
10 | public:
11 | static void registerPlugin(const char *name, ExtraInternalPlugin *plugin);
12 |
13 | public:
14 | // global plugin array
15 | static LiteMutableArray *plugins;
16 |
17 | static ExtraInternalPlugin *near_branch_trampoline;
18 | };
19 |
20 | // Plugin for Intercept Routing
21 | class RoutingPlugin : public ExtraInternalPlugin {
22 | public:
23 | // @Return: if false will continue to iter next plugin
24 | virtual bool Prepare(InterceptRouting *routing) = 0;
25 |
26 | // @Return: if false will continue to iter next plugin
27 | virtual bool Active(InterceptRouting *routing) = 0;
28 |
29 | // @Return: if false will continue to iter next plugin
30 | virtual bool GenerateTrampolineBuffer(InterceptRouting *routing, void *src, void *dst) = 0;
31 |
32 | private:
33 | char name_[256];
34 | };
35 |
36 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/InterceptRouting.h:
--------------------------------------------------------------------------------
1 | #ifndef INTERCEPT_ROUTING_H
2 | #define INTERCEPT_ROUTING_H
3 |
4 | #include "Interceptor.h"
5 | #include "MemoryAllocator/AssemblyCodeBuilder.h"
6 |
7 | extern CodeBufferBase *GenerateNormalTrampolineBuffer(addr_t from, addr_t to);
8 |
9 | extern void GenRelocateCodeAndBranch(void *buffer, AssemblyCodeChunk *origin, AssemblyCodeChunk *relocated);
10 |
11 | class InterceptRouting {
12 | public:
13 | InterceptRouting(HookEntry *entry) : entry_(entry) {
14 | entry->route = this;
15 |
16 | trampoline_ = NULL;
17 | trampoline_buffer_ = NULL;
18 | trampoline_target_ = NULL;
19 | }
20 |
21 | virtual void Dispatch() = 0;
22 |
23 | virtual void Prepare();
24 |
25 | virtual void Active();
26 |
27 | void Commit();
28 |
29 | HookEntry *GetHookEntry();
30 |
31 | void GenerateRelocatedCode();
32 |
33 | void GenerateTrampolineBuffer(void *src, void *dst);
34 |
35 | void SetTrampolineBuffer(CodeBufferBase *buffer) {
36 | trampoline_buffer_ = buffer;
37 | }
38 |
39 | CodeBufferBase *GetTrampolineBuffer() {
40 | return trampoline_buffer_;
41 | }
42 |
43 | void SetTrampolineTarget(void *address) {
44 | trampoline_target_ = address;
45 | }
46 |
47 | void *GetTrampolineTarget() {
48 | return trampoline_target_;
49 | }
50 |
51 | protected:
52 | HookEntry *entry_;
53 |
54 | AssemblyCodeChunk *origin_;
55 |
56 | AssemblyCodeChunk *relocated_;
57 |
58 | AssemblyCodeChunk *trampoline_;
59 |
60 | // trampoline buffer before active
61 | CodeBufferBase *trampoline_buffer_;
62 |
63 | void *trampoline_target_;
64 | };
65 | #endif
66 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/RoutingPlugin/DynamicBinaryInstrument/DynamicBinaryInstrumentExport.cc:
--------------------------------------------------------------------------------
1 | #include "dobby_internal.h"
2 |
3 | #include "InterceptRouting/InterceptRouting.h"
4 | #include "InterceptRouting/RoutingPlugin/DynamicBinaryInstrument/dynamic-binary-instrument.h"
5 |
6 | PUBLIC int DobbyInstrument(void *address, DBICallTy handler) {
7 | if (!address) {
8 | ERROR_LOG("the function address is 0x0.\n");
9 | return RS_FAILED;
10 | }
11 | DLOG(1, "[DobbyInstrument] Initialize at %p", address);
12 |
13 | // check if we already instruemnt
14 | HookEntry *entry = Interceptor::SharedInstance()->FindHookEntry(address);
15 | if (entry) {
16 | DynamicBinaryInstrumentRouting *route = (DynamicBinaryInstrumentRouting *)entry->route;
17 | if (route->handler == handler) {
18 | ERROR_LOG("instruction %s already been instrumented.", address);
19 | return RS_FAILED;
20 | }
21 | }
22 |
23 | entry = new HookEntry();
24 | entry->id = Interceptor::SharedInstance()->GetHookEntryCount();
25 | entry->type = kDynamicBinaryInstrument;
26 | entry->instruction_address = address;
27 |
28 | DLOG(1, "================ DynamicBinaryInstrumentRouting Start ================");
29 | DynamicBinaryInstrumentRouting *route = new DynamicBinaryInstrumentRouting(entry, (void *)handler);
30 | route->Dispatch();
31 | Interceptor::SharedInstance()->AddHookEntry(entry);
32 | route->Commit();
33 | DLOG(1, "================ DynamicBinaryInstrumentRouting End ================");
34 |
35 | return RS_SUCCESS;
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/RoutingPlugin/DynamicBinaryInstrument/dynamic-binary-instrument.cc:
--------------------------------------------------------------------------------
1 | #include "InterceptRouting/RoutingPlugin/DynamicBinaryInstrument/dynamic-binary-instrument.h"
2 |
3 | #include "dobby_internal.h"
4 |
5 | #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
6 |
7 | #include "InterceptRouting/RoutingPlugin/DynamicBinaryInstrument/intercept_routing_handler.h"
8 |
9 | void DynamicBinaryInstrumentRouting::Dispatch() {
10 | Prepare();
11 | BuildDynamicBinaryInstrumentRouting();
12 | }
13 |
14 | // Add dbi_call handler before running the origin instructions
15 | void DynamicBinaryInstrumentRouting::BuildDynamicBinaryInstrumentRouting() {
16 | // create closure trampoline jump to prologue_routing_dispath with the `entry_` data
17 | ClosureTrampolineEntry *closure_trampoline;
18 | // forward trampoline
19 |
20 | void *handler = (void *)instrument_routing_dispatch;
21 | #if __APPLE__
22 | #if __has_feature(ptrauth_calls)
23 | handler = __builtin_ptrauth_strip(handler, ptrauth_key_asia);
24 | #endif
25 | #endif
26 | closure_trampoline = ClosureTrampoline::CreateClosureTrampoline(entry_, handler);
27 | DLOG(1, "[closure bridge] Carry data %p ", entry_);
28 | DLOG(1, "[closure bridge] Create prologue_dispatch_bridge %p", closure_trampoline->address);
29 |
30 | // set trampoline target address
31 | this->SetTrampolineTarget(closure_trampoline->address);
32 |
33 | this->prologue_dispatch_bridge = closure_trampoline->address;
34 |
35 | GenerateTrampolineBuffer(entry_->target_address, GetTrampolineTarget());
36 |
37 | GenerateRelocatedCode();
38 | }
39 |
40 | #if 0
41 | void *DynamicBinaryInstrumentRouting::GetTrampolineTarget() {
42 | return this->prologue_dispatch_bridge;
43 | }
44 | #endif
45 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/RoutingPlugin/DynamicBinaryInstrument/dynamic-binary-instrument.h:
--------------------------------------------------------------------------------
1 | #ifndef DYNAMIC_BINARY_INSTRUMENT_H
2 | #define DYNAMIC_BINARY_INSTRUMENT_H
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "Interceptor.h"
7 |
8 | #include "InterceptRouting/InterceptRouting.h"
9 |
10 | #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
11 |
12 | #define X64InterceptRouting InterceptRouting
13 | #define ARM64InterceptRouting InterceptRouting
14 |
15 | class DynamicBinaryInstrumentRouting : public X64InterceptRouting {
16 | public:
17 | DynamicBinaryInstrumentRouting(HookEntry *entry, void *handler) : X64InterceptRouting(entry) {
18 | this->handler = handler;
19 | }
20 |
21 | void Dispatch();
22 |
23 | public:
24 | void *handler;
25 |
26 | private:
27 | virtual void BuildDynamicBinaryInstrumentRouting();
28 |
29 | private:
30 | void *prologue_dispatch_bridge;
31 |
32 | ;
33 | };
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/RoutingPlugin/DynamicBinaryInstrument/intercept_routing_handler.cc:
--------------------------------------------------------------------------------
1 | #include "InterceptRouting/RoutingPlugin/DynamicBinaryInstrument/intercept_routing_handler.h"
2 |
3 | #include "dobby_internal.h"
4 |
5 | #include "InterceptRouting/RoutingPlugin/DynamicBinaryInstrument/dynamic-binary-instrument.h"
6 |
7 | #include "TrampolineBridge/ClosureTrampolineBridge/closure-trampoline-common-handler.h"
8 |
9 | void instrument_call_forward_handler(RegisterContext *ctx, HookEntry *entry) {
10 | DynamicBinaryInstrumentRouting *route = (DynamicBinaryInstrumentRouting *)entry->route;
11 | if (route->handler) {
12 | DBICallTy handler;
13 | HookEntryInfo entry_info;
14 | entry_info.hook_id = entry->id;
15 | entry_info.instruction_address = entry->instruction_address;
16 | handler = (DBICallTy)route->handler;
17 | (*handler)(ctx, (const HookEntryInfo *)&entry_info);
18 | }
19 |
20 | // set prologue bridge next hop address with origin instructions that have been relocated(patched)
21 | set_routing_bridge_next_hop(ctx, entry->relocated_origin_instructions);
22 | }
23 |
24 | void instrument_routing_dispatch(RegisterContext *ctx, ClosureTrampolineEntry *closure_trampoline_entry) {
25 | HookEntry *entry = (HookEntry *)closure_trampoline_entry->carry_data;
26 | instrument_call_forward_handler(ctx, entry);
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/RoutingPlugin/DynamicBinaryInstrument/intercept_routing_handler.h:
--------------------------------------------------------------------------------
1 | #ifndef INTERCEPT_ROUTING_HANDLER_H
2 | #define INTERCEPT_ROUTING_HANDLER_H
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
7 |
8 | extern "C" {
9 | void instrument_routing_dispatch(RegisterContext *ctx, ClosureTrampolineEntry *entry);
10 | }
11 |
12 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/RoutingPlugin/FunctionInlineReplace/FunctionInlineReplaceExport.cc:
--------------------------------------------------------------------------------
1 | #include "dobby_internal.h"
2 |
3 | #include "Interceptor.h"
4 | #include "InterceptRouting/InterceptRouting.h"
5 | #include "InterceptRouting/RoutingPlugin/FunctionInlineReplace/function-inline-replace.h"
6 |
7 | PUBLIC int DobbyHook(void *address, void *replace_call, void **origin_call) {
8 | if (!address) {
9 | ERROR_LOG("function address is 0x0");
10 | return RS_FAILED;
11 | }
12 | DLOG(1, "[DobbyHook] Initialize at %p", address);
13 |
14 | // check if already hooked
15 | HookEntry *entry = Interceptor::SharedInstance()->FindHookEntry(address);
16 | if (entry) {
17 | FunctionInlineReplaceRouting *route = (FunctionInlineReplaceRouting *)entry->route;
18 | if (route->GetTrampolineTarget() == replace_call) {
19 | ERROR_LOG("function %p already been hooked.", address);
20 | return RS_FAILED;
21 | }
22 | }
23 |
24 | entry = new HookEntry();
25 | entry->id = Interceptor::SharedInstance()->GetHookEntryCount();
26 | entry->type = kFunctionInlineHook;
27 | entry->function_address = address;
28 |
29 | DLOG(1, "================ FunctionInlineReplaceRouting Start ================");
30 | FunctionInlineReplaceRouting *route = new FunctionInlineReplaceRouting(entry, replace_call);
31 | route->Dispatch();
32 | Interceptor::SharedInstance()->AddHookEntry(entry);
33 |
34 | // set origin call with relocated function
35 | *origin_call = entry->relocated_origin_function;
36 |
37 | // code patch & hijack original control flow entry
38 | route->Commit();
39 | DLOG(1, "================ FunctionInlineReplaceRouting End ================");
40 |
41 | return RS_SUCCESS;
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/RoutingPlugin/FunctionInlineReplace/function-inline-replace.cc:
--------------------------------------------------------------------------------
1 | #include "InterceptRouting/RoutingPlugin/FunctionInlineReplace/function-inline-replace.h"
2 |
3 | #include "dobby_internal.h"
4 |
5 | void FunctionInlineReplaceRouting::Dispatch() {
6 | Prepare();
7 | BuildReplaceRouting();
8 | }
9 |
10 | void FunctionInlineReplaceRouting::BuildReplaceRouting() {
11 | // direct => replace call
12 | this->SetTrampolineTarget(this->replace_call);
13 | DLOG(0, "Set trampoline target => %p", GetTrampolineTarget());
14 |
15 | GenerateTrampolineBuffer(entry_->target_address, GetTrampolineTarget());
16 |
17 | GenerateRelocatedCode();
18 | }
19 |
20 | #if 0
21 | void *FunctionInlineReplaceRouting::GetTrampolineTarget() {
22 | return this->replace_call;
23 | }
24 | #endif
25 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/RoutingPlugin/FunctionInlineReplace/function-inline-replace.h:
--------------------------------------------------------------------------------
1 | #ifndef FUNCTION_INLINE_REPLACE_H
2 | #define FUNCTION_INLINE_REPLACE_H
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "InterceptRouting/InterceptRouting.h"
7 | #include "Interceptor.h"
8 |
9 | #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
10 |
11 | class FunctionInlineReplaceRouting : public InterceptRouting {
12 | public:
13 | FunctionInlineReplaceRouting(HookEntry *entry, void *replace_call) : InterceptRouting(entry) {
14 | this->replace_call = replace_call;
15 | }
16 |
17 | void Dispatch() override;
18 |
19 | private:
20 | virtual void BuildReplaceRouting();
21 |
22 | private:
23 | void *replace_call;
24 | };
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/RoutingPlugin/FunctionWrapper/FunctionWrapperExport.cc:
--------------------------------------------------------------------------------
1 | #include "dobby_internal.h"
2 |
3 | #include "logging/logging.h"
4 |
5 | #include "Interceptor.h"
6 | #include "InterceptRouting/InterceptRouting.h"
7 |
8 | #include "function-wrapper.h"
9 |
10 | PUBLIC int DobbyWrap(void *function_address, PreCallTy pre_call, PostCallTy post_call) {
11 | DLOG(1, "Initialize 'DobbyWrap' hook at %p", function_address);
12 |
13 | Interceptor *interceptor = Interceptor::SharedInstance();
14 |
15 | HookEntry *entry = new HookEntry();
16 | entry->id = interceptor->entries->getCount();
17 | entry->type = kFunctionWrapper;
18 | entry->function_address = function_address;
19 |
20 | FunctionWrapperRouting *route = new FunctionWrapperRouting(entry);
21 | route->Dispatch();
22 | interceptor->AddHookEntry(entry);
23 | route->Commit();
24 |
25 | DLOG(0, "Finalize %p", function_address);
26 | return RS_SUCCESS;
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/RoutingPlugin/FunctionWrapper/function-wrapper.cc:
--------------------------------------------------------------------------------
1 | #include "dobby_internal.h"
2 |
3 | #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
4 |
5 | #include "intercept_routing_handler.h"
6 |
7 | #include "function-wrapper.h"
8 |
9 | void FunctionWrapperRouting::Dispatch() {
10 | Prepare();
11 | BuildPreCallRouting();
12 | BuildPostCallRouting();
13 | }
14 |
15 | // Add pre_call(prologue) handler before running the origin function,
16 | void FunctionWrapperRouting::BuildPreCallRouting() {
17 | // create closure trampoline jump to prologue_routing_dispath with the `entry_` data
18 | ClosureTrampolineEntry *cte = ClosureTrampoline::CreateClosureTrampoline(entry_, (void *)prologue_routing_dispatch);
19 | this->prologue_dispatch_bridge = cte->address;
20 |
21 | DLOG(0, "Create pre call closure trampoline to 'prologue_routing_dispatch' at %p", cte->address);
22 | }
23 |
24 | // Add post_call(epilogue) handler before `Return` of the origin function, as implementation is replace the origin
25 | // `Return Address` of the function.
26 | void FunctionWrapperRouting::BuildPostCallRouting() {
27 | // create closure trampoline jump to prologue_routing_dispath with the `entry_` data
28 | ClosureTrampolineEntry *closure_trampoline_entry;
29 | // format trampoline
30 | closure_trampoline_entry = ClosureTrampoline::CreateClosureTrampoline(entry_, (void *)epilogue_routing_dispatch);
31 | DLOG(0, "Create post call closure trampoline to 'prologue_routing_dispatch' at %p",
32 | closure_trampoline_entry->address);
33 |
34 | this->SetTrampolineTarget(closure_trampoline_entry->address);
35 | this->epilogue_dispatch_bridge = closure_trampoline_entry->address;
36 |
37 | GenerateTrampolineBuffer(entry_->target_address, GetTrampolineTarget());
38 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/RoutingPlugin/FunctionWrapper/function-wrapper.h:
--------------------------------------------------------------------------------
1 | #ifndef FUNCTION_WRAPPER_H
2 | #define FUNCTION_WRAPPER_H
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
7 | #include "InterceptRouting/InterceptRouting.h"
8 | #include "Interceptor.h"
9 |
10 | #if TARGET_ARCH_IA32
11 | #elif TARGET_ARCH_X64
12 | #include "InterceptRouting/x64/X64InterceptRouting.h"
13 | #elif TARGET_ARCH_ARM64
14 | #include "InterceptRouting/arm64/ARM64InterceptRouting.h"
15 | #elif TARGET_ARCH_ARM
16 | #else
17 | #error "unsupported architecture"
18 | #endif
19 |
20 | class FunctionWrapperRouting : public InterceptRouting {
21 | public:
22 | FunctionWrapperRouting(HookEntry *entry) : InterceptRouting(entry) {
23 | }
24 |
25 | void Dispatch();
26 |
27 | void *GetTrampolineTarget();
28 |
29 | private:
30 | void BuildPreCallRouting();
31 |
32 | void BuildPostCallRouting();
33 |
34 | private:
35 | void *prologue_dispatch_bridge;
36 |
37 | void *epilogue_dispatch_bridge;
38 | };
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/InterceptRouting/RoutingPlugin/FunctionWrapper/intercept_routing_handler.h:
--------------------------------------------------------------------------------
1 | #ifndef FUNCTION_WRAPPER_INTERCEPT_ROUTING_HANDLER_H
2 | #define FUNCTION_WRAPPER_INTERCEPT_ROUTING_HANDLER_H
3 |
4 | #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
5 | #include "Interceptor.h"
6 | #include "dobby_internal.h"
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif //__cplusplus
11 |
12 | // Dispatch the routing befor running the origin function
13 | void prologue_routing_dispatch(RegisterContext *ctx, ClosureTrampolineEntry *entry);
14 |
15 | // Dispatch the routing before the function return . (as it's implementation by relpace `return address` in the stack
16 | // ,or LR register)
17 | void epilogue_routing_dispatch(RegisterContext *ctx, ClosureTrampolineEntry *entry);
18 |
19 | void pre_call_forward_handler(RegisterContext *ctx, HookEntry *entry);
20 |
21 | void post_call_forward_handler(RegisterContext *ctx, HookEntry *entry);
22 |
23 | #ifdef __cplusplus
24 | }
25 | #endif //__cplusplus
26 |
27 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/Interceptor.cpp:
--------------------------------------------------------------------------------
1 | #include "Interceptor.h"
2 |
3 | #include "dobby_internal.h"
4 |
5 | Interceptor * Interceptor::priv_interceptor_ = nullptr;
6 |
7 | Interceptor *Interceptor::SharedInstance() {
8 | if (Interceptor::priv_interceptor_ == NULL) {
9 | Interceptor::priv_interceptor_ = new Interceptor();
10 | INIT_LIST_HEAD(&Interceptor::priv_interceptor_->hook_entry_list_);
11 | }
12 | return Interceptor::priv_interceptor_;
13 | }
14 |
15 | HookEntryListNode *Interceptor::FindHookEntryNode(void *address) {
16 | HookEntry *entry = NULL;
17 |
18 | struct list_head *node = NULL;
19 | for (node = hook_entry_list_.next; node != &hook_entry_list_; node = node->next) {
20 | if(((HookEntryListNode *)node)->info.target_address == address) {
21 | return (HookEntryListNode *)node;
22 | }
23 | }
24 |
25 | return NULL;
26 | }
27 |
28 | HookEntry *Interceptor::FindHookEntry(void *address) {
29 | HookEntryListNode *node = NULL;
30 | node = FindHookEntryNode(address);
31 | if(node)
32 | return &node->info;
33 |
34 | return NULL;
35 | }
36 |
37 |
38 |
39 | void Interceptor::AddHookEntry(HookEntry *entry) {
40 | HookEntryListNode *node = new HookEntryListNode ;
41 | node->info = *entry;
42 | list_add((struct list_head *)node, &hook_entry_list_);
43 | }
44 |
45 | void Interceptor::RemoveHookEntry(void *address) {
46 | HookEntryListNode *node = NULL;
47 | node = FindHookEntryNode(address);
48 | if(node) {
49 | list_del((struct list_head *)node);
50 | }
51 | }
52 |
53 | int Interceptor::GetHookEntryCount() {
54 | int count = 0;
55 |
56 | struct list_head *node = &hook_entry_list_;
57 | while((node = node->next) != &hook_entry_list_) {
58 | count += 1;
59 | }
60 | return count;
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/MemoryAllocator/AssemblyCodeBuilder.cc:
--------------------------------------------------------------------------------
1 | #include "MemoryAllocator/AssemblyCodeBuilder.h"
2 |
3 | #include "dobby_internal.h"
4 | #include "PlatformUnifiedInterface/ExecMemory/CodePatchTool.h"
5 |
6 | AssemblyCodeChunk *AssemblyCodeBuilder::FinalizeFromAddress(addr_t address, int size) {
7 | AssemblyCodeChunk *result = NULL;
8 | result = new AssemblyCodeChunk;
9 | result->init_region_range(address, size);
10 | return result;
11 | }
12 |
13 | AssemblyCodeChunk *AssemblyCodeBuilder::FinalizeFromTurboAssembler(AssemblerBase *assembler) {
14 | AssemblyCodeChunk *result = NULL;
15 |
16 | CodeBufferBase *code_buffer =NULL;
17 | code_buffer = (CodeBufferBase *)assembler->GetCodeBuffer();
18 |
19 | void *realized_address = assembler->GetRealizedAddress();
20 | if (realized_address == NULL) {
21 | int buffer_size = 0;
22 | {
23 | buffer_size = code_buffer->getSize();
24 | #if TARGET_ARCH_ARM64 || TARGET_ARCH_ARM
25 | // FIXME: need it ? actually ???
26 | // extra bytes for align needed
27 | buffer_size += 4;
28 | #endif
29 | }
30 |
31 | // assembler without specific memory address
32 | result = MemoryArena::AllocateCodeChunk(buffer_size);
33 | if (result == NULL)
34 | return NULL;
35 |
36 | realized_address = (void *)result->raw_instruction_start();
37 | assembler->SetRealizedAddress(realized_address);
38 | } else {
39 | result = AssemblyCodeBuilder::FinalizeFromAddress((addr_t)realized_address, code_buffer->getSize());
40 | }
41 |
42 | // Realize(Relocate) the buffer_code to the executable_memory_address, remove the ExternalLabels, etc, the pc-relative
43 | // instructions
44 | CodePatch(realized_address, (uint8_t *)code_buffer->getRawBuffer(), code_buffer->getSize());
45 |
46 | return result;
47 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/MemoryAllocator/AssemblyCodeBuilder.h:
--------------------------------------------------------------------------------
1 | #ifndef MemoryAllocator_AssemblyCodeBuilder_h
2 | #define MemoryAllocator_AssemblyCodeBuilder_h
3 |
4 | #include "MemoryAllocator/MemoryArena.h"
5 |
6 | #include "core/modules/assembler/assembler.h"
7 |
8 | using namespace zz;
9 |
10 | class AssemblyCodeBuilder {
11 | public:
12 | // realize the buffer address to runtime code, and create a corresponding Code Object
13 | static AssemblyCodeChunk *FinalizeFromAddress(addr_t address, int size);
14 |
15 | // realize the buffer address to runtime code, and create a corresponding Code Object
16 | static AssemblyCodeChunk *FinalizeFromTurboAssembler(AssemblerBase *assembler);
17 |
18 | // inline void init_region_range(addr_t address, int size) {
19 | // code_range_.address = (void *)address;
20 | // code_range_.length = size;
21 | // }
22 |
23 | // inline void re_init_region_range(addr_t address, int size) {
24 | // this->init_region_range(address, size);
25 | // }
26 |
27 | // inline addr_t raw_instruction_start() {
28 | // return (addr_t)code_range_.address;
29 | // };
30 |
31 | // inline int raw_instruction_size() {
32 | // return (int)code_range_.length;
33 | // };
34 |
35 | private:
36 | // AssemblyCodeChunk code_range_;
37 | };
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/MemoryAllocator/CodeBuffer/CodeBufferBase.h:
--------------------------------------------------------------------------------
1 | #ifndef CODE_BUFFER_BASE_H
2 | #define CODE_BUFFER_BASE_H
3 |
4 | #include "xnucxx/LiteMutableBuffer.h"
5 |
6 | class CodeBufferBase : public LiteMutableBuffer {
7 | public:
8 | CodeBufferBase() : LiteMutableBuffer() {
9 | }
10 |
11 | CodeBufferBase(int size) : LiteMutableBuffer(size) {
12 | }
13 |
14 | public:
15 | virtual CodeBufferBase *Copy();
16 |
17 | void Emit8(uint8_t data);
18 |
19 | void Emit16(uint16_t data);
20 |
21 | void Emit32(uint32_t data);
22 |
23 | void Emit64(uint64_t data);
24 |
25 | void EmitBuffer(void *buffer, int len);
26 |
27 | void EmitObject(LiteObject *object);
28 |
29 | #if 0 // Template Advanced won't enable even in userspace
30 | template T Load(int offset);
31 |
32 | template void Store(int offset, T value);
33 |
34 | template void Emit(T value);
35 | #endif
36 | };
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/MemoryAllocator/CodeBuffer/code-buffer-arm.h:
--------------------------------------------------------------------------------
1 | #ifndef CODE_BUFFER_ARM_H
2 | #define CODE_BUFFER_ARM_H
3 |
4 | #include "MemoryAllocator/CodeBuffer/CodeBufferBase.h"
5 |
6 | typedef int32_t arm_inst_t;
7 | typedef int16_t thumb1_inst_t;
8 | typedef int32_t thumb2_inst_t;
9 |
10 | class CodeBuffer : public CodeBufferBase {
11 | enum ExecuteState { ARMExecuteState, ThumbExecuteState };
12 |
13 | public:
14 | CodeBuffer() : CodeBufferBase() {
15 | }
16 |
17 | CodeBuffer(int size) : CodeBufferBase(size) {
18 | }
19 |
20 | public:
21 | arm_inst_t LoadARMInst(int offset);
22 |
23 | thumb1_inst_t LoadThumb1Inst(int offset);
24 |
25 | thumb2_inst_t LoadThumb2Inst(int offset);
26 |
27 | void RewriteAddr(int offset, addr32_t addr);
28 |
29 | void RewriteARMInst(int offset, arm_inst_t instr);
30 |
31 | void RewriteThumb1Inst(int offset, thumb1_inst_t instr);
32 |
33 | void RewriteThumb2Inst(int offset, thumb2_inst_t instr);
34 |
35 | void EmitARMInst(arm_inst_t instr);
36 |
37 | void EmitThumb1Inst(thumb1_inst_t instr);
38 |
39 | void EmitThumb2Inst(thumb2_inst_t instr);
40 |
41 | void Emit32(int32_t data);
42 | };
43 |
44 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/MemoryAllocator/CodeBuffer/code-buffer-arm64.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_ARM64)
3 |
4 | #include "MemoryAllocator/CodeBuffer/code-buffer-arm64.h"
5 |
6 | arm64_inst_t CodeBuffer::LoadInst(int offset) {
7 | return *reinterpret_cast(buffer + offset);
8 | }
9 |
10 | void CodeBuffer::FixBindLabel(int offset, arm64_inst_t instr) {
11 | *reinterpret_cast(buffer + offset) = instr;
12 | return;
13 | }
14 |
15 | void CodeBuffer::EmitInst(arm64_inst_t instr) {
16 | ensureCapacity(getSize() + sizeof(arm64_inst_t));
17 | *reinterpret_cast(getCursor()) = instr;
18 | buffer_cursor += sizeof(arm64_inst_t);
19 | return;
20 | }
21 |
22 | void CodeBuffer::Emit64(int64_t data) {
23 | ensureCapacity(getSize() + sizeof(int64_t));
24 | *reinterpret_cast(getCursor()) = data;
25 | buffer_cursor += sizeof(int64_t);
26 | return;
27 | }
28 |
29 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/MemoryAllocator/CodeBuffer/code-buffer-arm64.h:
--------------------------------------------------------------------------------
1 | #ifndef CODE_BUFFER_ARM64_H
2 | #define CODE_BUFFER_ARM64_H
3 |
4 | #include "MemoryAllocator/CodeBuffer/CodeBufferBase.h"
5 |
6 | typedef int32_t arm64_inst_t;
7 |
8 | class CodeBuffer : public CodeBufferBase {
9 |
10 | public:
11 | CodeBuffer() : CodeBufferBase() {
12 | }
13 |
14 | CodeBuffer(int size) : CodeBufferBase(size) {
15 | }
16 |
17 | public:
18 | arm64_inst_t LoadInst(int offset);
19 |
20 | void FixBindLabel(int offset, arm64_inst_t instr);
21 |
22 | void EmitInst(arm64_inst_t instr);
23 |
24 | void Emit64(int64_t data);
25 | };
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/MemoryAllocator/CodeBuffer/code-buffer-x64.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_X64)
3 |
4 | #include "MemoryAllocator/CodeBuffer/code-buffer-x64.h"
5 |
6 | void CodeBuffer::Emit32(int32_t data) {
7 | ensureCapacity(getSize() + sizeof(int32_t));
8 | *reinterpret_cast(getCursor()) = data;
9 | buffer_cursor += sizeof(int32_t);
10 | return;
11 | }
12 |
13 | void CodeBuffer::Emit64(int64_t data) {
14 | ensureCapacity(getSize() + sizeof(int64_t));
15 | *reinterpret_cast(getCursor()) = data;
16 | buffer_cursor += sizeof(int64_t);
17 | return;
18 | }
19 |
20 | void CodeBuffer::FixBindLabel(int offset, int32_t disp) {
21 | *reinterpret_cast(buffer + offset) = disp;
22 | return;
23 | }
24 |
25 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/MemoryAllocator/CodeBuffer/code-buffer-x64.h:
--------------------------------------------------------------------------------
1 | #ifndef CODE_BUFFER_X64_H
2 | #define CODE_BUFFER_X64_H
3 |
4 | #include "MemoryAllocator/CodeBuffer/CodeBufferBase.h"
5 |
6 | class CodeBuffer : public CodeBufferBase {
7 | public:
8 | CodeBuffer() : CodeBufferBase() {
9 | }
10 |
11 | CodeBuffer(int size) : CodeBufferBase(size) {
12 | }
13 |
14 | public:
15 | void FixBindLabel(int offset, int32_t disp);
16 |
17 | void Emit32(int32_t data);
18 |
19 | void Emit64(int64_t data);
20 | };
21 |
22 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/MemoryAllocator/CodeBuffer/code-buffer-x86.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_IA32)
3 |
4 | #include "MemoryAllocator/CodeBuffer/code-buffer-x86.h"
5 |
6 | void CodeBuffer::Emit32(int32_t data) {
7 | ensureCapacity(getSize() + sizeof(int32_t));
8 | *reinterpret_cast(getCursor()) = data;
9 | buffer_cursor += sizeof(int32_t);
10 | return;
11 | }
12 |
13 | void CodeBuffer::FixBindLabel(int offset, int32_t disp) {
14 | *reinterpret_cast(buffer + offset) = disp;
15 | return;
16 | }
17 |
18 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/MemoryAllocator/CodeBuffer/code-buffer-x86.h:
--------------------------------------------------------------------------------
1 | #ifndef CODE_BUFFER_X86_H
2 | #define CODE_BUFFER_X86_H
3 |
4 | #include "MemoryAllocator/CodeBuffer/CodeBufferBase.h"
5 |
6 | class CodeBuffer : public CodeBufferBase {
7 | public:
8 | CodeBuffer() : CodeBufferBase() {
9 | }
10 |
11 | CodeBuffer(int size) : CodeBufferBase(size) {
12 | }
13 |
14 | public:
15 | void FixBindLabel(int offset, int32_t disp);
16 |
17 | void Emit32(int32_t data);
18 | };
19 |
20 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/MemoryAllocator/MemoryArena.h:
--------------------------------------------------------------------------------
1 | #ifndef MemoryAllocator_MemoryArena_h
2 | #define MemoryAllocator_MemoryArena_h
3 |
4 | #include "xnucxx/LiteMutableArray.h"
5 |
6 | #include "PlatformUnifiedInterface/StdMemory.h"
7 |
8 | struct MemoryChunk : MemoryRange {
9 | inline void init_region_range(addr_t address, int size) {
10 | this->address = (void *)address;
11 | this->length = size;
12 | }
13 |
14 | inline void re_init_region_range(addr_t address, int size) {
15 | init_region_range(address, size);
16 | }
17 |
18 | inline void re_init_region_range(MemoryChunk *chunk) {
19 | init_region_range((addr_t)chunk->address, chunk->length);
20 | }
21 |
22 | inline addr_t raw_instruction_start() {
23 | return (addr_t)address;
24 | };
25 |
26 | inline size_t raw_instruction_size() {
27 | return length;
28 | };
29 | };
30 |
31 | typedef MemoryChunk AssemblyCodeChunk, WritableDataChunk;
32 |
33 | typedef struct {
34 | MemoryChunk page;
35 | addr_t page_cursor;
36 | MemoryPermission permission;
37 | LiteMutableArray *chunks;
38 | } PageChunk;
39 |
40 | class MemoryArena {
41 | public:
42 | static MemoryChunk *AllocateChunk(int alloc_size, MemoryPermission permission);
43 |
44 | static WritableDataChunk *AllocateDataChunk(int alloc_size);
45 |
46 | static AssemblyCodeChunk *AllocateCodeChunk(int alloc_size);
47 |
48 | static void Destroy(MemoryChunk *chunk);
49 |
50 | public:
51 | static LiteMutableArray *page_chunks;
52 | };
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/MemoryAllocator/NearMemoryArena.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef MemoryAllocator_NearMemoryArena_h
3 | #define MemoryAllocator_NearMemoryArena_h
4 |
5 | #include "MemoryAllocator/MemoryArena.h"
6 |
7 | class NearMemoryArena : public MemoryArena {
8 | public:
9 | NearMemoryArena();
10 |
11 | static MemoryChunk *AllocateChunk(addr_t position, size_t alloc_range, int alloc_size, MemoryPermission permission);
12 |
13 | static WritableDataChunk *AllocateDataChunk(addr_t position, size_t alloc_range, int alloc_size);
14 |
15 | static AssemblyCodeChunk *AllocateCodeChunk(addr_t position, size_t alloc_range, int alloc_size);
16 |
17 | static int PushPage(addr_t page_addr, MemoryPermission permission);
18 |
19 | static void Destroy(MemoryChunk *chunk);
20 |
21 | private:
22 | static LiteMutableArray *page_chunks;
23 | };
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/PlatformUnifiedInterface/ExecMemory/ClearCacheTool.h:
--------------------------------------------------------------------------------
1 | #ifndef PLATFORM_INTERFACE_CLEAR_CACHE_TOOL_H
2 | #define PLATFORM_INTERFACE_CLEAR_CACHE_TOOL_H
3 |
4 | void ClearCache(void *start, void *end);
5 |
6 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/PlatformUnifiedInterface/ExecMemory/CodePatchTool.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef PLATFORM_INTERFACE_CODE_PATCH_TOOL_H
3 | #define PLATFORM_INTERFACE_CODE_PATCH_TOOL_H
4 |
5 | #include "PlatformUnifiedInterface/StdMemory.h"
6 |
7 | MemoryOperationError CodePatch(void *address, uint8_t *buffer, uint32_t buffer_size);
8 |
9 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/PlatformUnifiedInterface/StdMemory.h:
--------------------------------------------------------------------------------
1 | #ifndef UNIFIED_INTERFACE_STD_MEMORY_H
2 | #define UNIFIED_INTERFACE_STD_MEMORY_H
3 |
4 | #include "common/headers/common_header.h"
5 |
6 | enum MemoryPermission { kNoAccess, kRead, kReadWrite, kReadWriteExecute, kReadExecute };
7 |
8 | typedef struct _MemoryRange {
9 | void * address;
10 | size_t length;
11 | } MemoryRange;
12 |
13 | typedef struct _MemoryRegion {
14 | void * address;
15 | size_t length;
16 | MemoryPermission permission;
17 | } MemoryRegion;
18 |
19 | typedef MemoryRegion MemoryPage;
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h:
--------------------------------------------------------------------------------
1 | #ifndef ASSEMBLY_CLOSURE_TRAMPOLINE_H
2 | #define ASSEMBLY_CLOSURE_TRAMPOLINE_H
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "xnucxx/LiteMutableArray.h"
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif //__cplusplus
11 |
12 | typedef struct _ClosureTrampolineEntry {
13 | void * carry_handler;
14 | void * carry_data;
15 | void * address;
16 | uintptr_t size;
17 | } ClosureTrampolineEntry;
18 |
19 | typedef void (*USER_CODE_CALL)(RegisterContext *ctx, ClosureTrampolineEntry *entry);
20 |
21 | void closure_trampoline_template();
22 |
23 | void closure_bridge_template();
24 |
25 | void *get_closure_bridge();
26 |
27 | #ifdef __cplusplus
28 | }
29 | #endif //__cplusplus
30 |
31 | class ClosureTrampoline {
32 | private:
33 | static LiteMutableArray *trampolines_;
34 |
35 | public:
36 | static ClosureTrampolineEntry *CreateClosureTrampoline(void *carry_data, void *carry_handler);
37 | };
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/arm/dummy/closure-bridge-template-arm.cc:
--------------------------------------------------------------------------------
1 | // .section __TEXT,__text,regular,pure_instructions
2 | // .ios_version_min 11, 0
3 |
4 | #if defined(ENABLE_CLOSURE_BRIDGE_TEMPLATE)
5 |
6 | #if defined(__WIN32__) || defined(__APPLE__)
7 | #define cdecl(s) "_" s
8 | #else
9 | #define cdecl(s) s
10 | #endif
11 |
12 | #define xASM(x) __asm(x)
13 |
14 | __attribute__((naked)) void closure_bridge_template() {
15 | xASM(".arm");
16 | xASM("sub sp, sp, #(14*4)");
17 | xASM("str lr, [sp, #(13*4)]");
18 | xASM("str r12, [sp, #(12*4)]");
19 | xASM("str r11, [sp, #(11*4)]");
20 | xASM("str r10, [sp, #(10*4)]");
21 | xASM("str r9, [sp, #(9*4)]");
22 | xASM("str r8, [sp, #(8*4)]");
23 | xASM("str r7, [sp, #(7*4)]");
24 | xASM("str r6, [sp, #(6*4)]");
25 | xASM("str r5, [sp, #(5*4)]");
26 | xASM("str r4, [sp, #(4*4)]");
27 | xASM("str r3, [sp, #(3*4)]");
28 | xASM("str r2, [sp, #(2*4)]");
29 | xASM("str r1, [sp, #(1*4)]");
30 | xASM("str r0, [sp, #(0*4)]");
31 |
32 | // dummy align
33 | xASM("sub sp, sp, #8");
34 |
35 | xASM("mov r0, sp");
36 | xASM("mov r1, r12");
37 | xASM("bl " cdecl("intercept_routing_common_bridge_handler"));
38 |
39 | // dummy align
40 | xASM("add sp, sp, #8");
41 |
42 | xASM("ldr r0, [sp], #4");
43 | xASM("ldr r1, [sp], #4");
44 | xASM("ldr r2, [sp], #4");
45 | xASM("ldr r3, [sp], #4");
46 | xASM("ldr r4, [sp], #4");
47 | xASM("ldr r5, [sp], #4");
48 | xASM("ldr r6, [sp], #4");
49 | xASM("ldr r7, [sp], #4");
50 | xASM("ldr r8, [sp], #4");
51 | xASM("ldr r9, [sp], #4");
52 | xASM("ldr r10, [sp], #4");
53 | xASM("ldr r11, [sp], #4");
54 | xASM("ldr r12, [sp], #4");
55 | xASM("ldr lr, [sp], #4");
56 |
57 | #if 1
58 | xASM("str r12, [sp, #-4]");
59 | xASM("ldr pc, [sp, #-4]");
60 | #else
61 | xASM("mov pc, r12");
62 | #endif
63 | }
64 |
65 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/arm/dummy/closure-trampoline-template-arm.S:
--------------------------------------------------------------------------------
1 | // .section __TEXT,__text,regular,pure_instructions
2 |
3 | #if defined(ENABLE_CLOSURE_BRIDGE_TEMPLATE)
4 |
5 | #if defined(__WIN32__) || defined(__APPLE__)
6 | #define cdecl(s) _##s
7 | #else
8 | #define cdecl(s) s
9 | #endif
10 |
11 | .align 4
12 |
13 | #if !defined(ENABLE_CLOSURE_TRAMPOLINE_CARRY_OBJECT_PTR)
14 |
15 | // closure trampoline carray the object pointer, and fetch required members at the runtime assembly code.
16 | // #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
17 | // #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
18 | #define OFFSETOF_ClourseTrampolineEntry_carry_data 4
19 | #define OFFSETOF_ClourseTrampolineEntry_carry_handler 0
20 | .globl cdecl(closure_trampoline_template)
21 | cdecl(closure_trampoline_template):
22 | ldr r12, ClourseTrampolineEntryPtr
23 | ldr pc, [r12, #0]
24 | ClourseTrampolineEntryPtr:
25 | .long 0
26 |
27 | #else
28 |
29 | ; closure trampoline just carray the required members from the object.
30 | .globl cdecl(closure_trampoline_template)
31 | cdecl(closure_trampoline_template):
32 | ldr r12, =carry_data
33 | ldr pc, =carry_handler
34 | carry_data:
35 | .long 0
36 | carry_handler:
37 | .long 0
38 | #endif
39 |
40 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/arm/helper-arm.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_ARM)
3 |
4 | #include "dobby_internal.h"
5 |
6 | void set_routing_bridge_next_hop(RegisterContext *ctx, void *address) {
7 | *reinterpret_cast(&ctx->general.regs.r12) = address;
8 | }
9 |
10 | void get_routing_bridge_next_hop(RegisterContext *ctx, void *address) {
11 | }
12 |
13 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/arm64/dummy/closure-trampoline-template-arm64.S:
--------------------------------------------------------------------------------
1 | // .section __TEXT,__text,regular,pure_instructions
2 |
3 | #if defined(ENABLE_CLOSURE_BRIDGE_TEMPLATE)
4 |
5 | #if defined(__WIN32__) || defined(__APPLE__)
6 | #define cdecl(s) _##s
7 | #else
8 | #define cdecl(s) s
9 | #endif
10 |
11 | .align 4
12 |
13 | #if !defined(ENABLE_CLOSURE_TRAMPOLINE_CARRY_OBJECT_PTR)
14 |
15 | // closure trampoline carray the object pointer, and fetch required members at the runtime assembly code.
16 | // #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
17 | // #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
18 | #define OFFSETOF_ClourseTrampolineEntry_carry_data 8
19 | #define OFFSETOF_ClourseTrampolineEntry_carry_handler 0
20 | .globl cdecl(closure_trampoline_template)
21 | cdecl(closure_trampoline_template):
22 | ldr x17, ClourseTrampolineEntryPtr
23 | ldr x16, OFFSETOF_ClourseTrampolineEntry_carry_data
24 | ldr x17, OFFSETOF_ClourseTrampolineEntry_carry_handler
25 | br x17
26 | ClourseTrampolineEntryPtr:
27 | .long 0
28 | .long 0
29 |
30 | #else
31 |
32 | ; closure trampoline just carray the required members from the object.
33 | .globl cdecl(closure_trampoline_template)
34 | cdecl(closure_trampoline_template):
35 | ldr x16, =carry_data
36 | ldr x17, =carry_handler
37 | br x17
38 | carry_data:
39 | .long 0
40 | .long 0
41 | carry_handler:
42 | .long 0
43 | .long 0
44 |
45 | #endif
46 |
47 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/arm64/dummy/dynamic-closure-trampoline-template-arm64.S:
--------------------------------------------------------------------------------
1 | // .section __TEXT,__text,regular,pure_instructions
2 |
3 | // For iOS, we can't allocate executable memory, but we can use `remap` doing some trick.
4 | // For details, please refer `libffi`
5 |
6 | #if defined(ENABLE_CLOSURE_BRIDGE_TEMPLATE)
7 |
8 | #if defined(__WIN32__) || defined(__APPLE__)
9 | #define cdecl(s) _##s
10 | #else
11 | #define cdecl(s) s
12 | #endif
13 |
14 | #define PAGE_MAX_SIZE 4096
15 | #define PAGE_MAX_SHIFT 14
16 |
17 | .align PAGE_MAX_SHIFT
18 | .globl cdecl(dynamic_closure_trampoline_table_page)
19 | cdecl(dynamic_closure_trampoline_table_page):
20 | .rept (PAGE_MAX_SIZE - 4 * 4) / 8 // sub dynamic_closure_trampoline_forward size
21 | adr x16, #0
22 | b cdecl(dynamic_closure_trampoline_forward)
23 | .endr
24 |
25 | cdecl(dynamic_closure_trampoline_forward):
26 | sub x16, x16, #0x4000 // [DynamicClosureTrampoline **]
27 | ldr x16, [x16, #0] // [DynamicClosureTrampoline *]
28 | ldr x17, [x16, #0] // trampolineTo
29 | br x17
30 |
31 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/arm64/helper-arm64.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_ARM64)
3 |
4 | #include "core/modules/assembler/assembler-arm64.h"
5 |
6 | #include "dobby_internal.h"
7 |
8 | using namespace zz::arm64;
9 |
10 | void set_routing_bridge_next_hop(RegisterContext *ctx, void *address) {
11 | *reinterpret_cast(&ctx->general.x[TMP_REG_0.code()]) = address;
12 | }
13 |
14 | void get_routing_bridge_next_hop(RegisterContext *ctx, void *address) {
15 | }
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/closure-trampoline-common-handler.cc:
--------------------------------------------------------------------------------
1 |
2 | #include "logging/logging.h"
3 |
4 | #include "TrampolineBridge/ClosureTrampolineBridge/closure-trampoline-common-handler.h"
5 |
6 | #if 0
7 | void get_routing_bridge_next_hop(RegisterContext *ctx, void *address) {
8 | }
9 |
10 | void set_routing_bridge_next_hop(RegisterContext *ctx, void *address) {
11 | }
12 | #endif
13 |
14 | // Closure bridge branch here unitily, then common_bridge_handler will dispatch to other handler.
15 | void intercept_routing_common_bridge_handler(RegisterContext *ctx, ClosureTrampolineEntry *entry) {
16 | DLOG(0, "Catch common bridge handler, carry data: %p, carry handler: %p", (HookEntry *)entry->carry_data,
17 | entry->carry_handler);
18 | USER_CODE_CALL UserCodeCall = (USER_CODE_CALL)entry->carry_handler;
19 |
20 | #if __APPLE__
21 | #if __has_feature(ptrauth_calls)
22 | UserCodeCall = (typeof(UserCodeCall))__builtin_ptrauth_sign_unauthenticated((void *)UserCodeCall, ptrauth_key_asia, 0);
23 | #endif
24 | #endif
25 |
26 | UserCodeCall(ctx, entry);
27 | return;
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/closure-trampoline-common-handler.h:
--------------------------------------------------------------------------------
1 | #ifndef CLOSURE_TRAMPOLINE_COMMON_HANDLER_H
2 | #define CLOSURE_TRAMPOLINE_COMMON_HANDLER_H
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
7 |
8 | #include "Interceptor.h"
9 |
10 | extern "C" {
11 | void intercept_routing_common_bridge_handler(RegisterContext *ctx, ClosureTrampolineEntry *entry);
12 | }
13 |
14 | void get_routing_bridge_next_hop(RegisterContext *ctx, void *address);
15 |
16 | void set_routing_bridge_next_hop(RegisterContext *ctx, void *address);
17 |
18 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/x64/X64AssemblyClosureTrampoline.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_X64)
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "core/modules/assembler/assembler-x64.h"
7 |
8 | #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
9 |
10 | extern void closure_trampoline_template();
11 |
12 | using namespace zz;
13 | using namespace zz::x64;
14 |
15 | ClosureTrampolineEntry *ClosureTrampoline::CreateClosureTrampoline(void *carry_data, void *carry_handler) {
16 |
17 | ClosureTrampolineEntry *entry = new ClosureTrampolineEntry;
18 |
19 | #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
20 | #define _ turbo_assembler_.
21 | #define __ turbo_assembler_.GetCodeBuffer()->
22 | TurboAssembler turbo_assembler_(0);
23 |
24 | char *push_rip_6 = (char *)"\xff\x35\x06\x00\x00\x00";
25 | char *jmp_rip_8 = (char *)"\xff\x25\x08\x00\x00\x00";
26 |
27 | __ EmitBuffer(push_rip_6, 6);
28 | __ EmitBuffer(jmp_rip_8, 6);
29 | __ Emit64((uint64_t)entry);
30 | __ Emit64((uint64_t)get_closure_bridge());
31 |
32 | AssemblyCodeChunk *code =
33 | AssemblyCodeBuilder::FinalizeFromTurboAssembler(reinterpret_cast(&turbo_assembler_));
34 |
35 | entry->address = (void *)code->raw_instruction_start();
36 | entry->carry_data = carry_data;
37 | entry->carry_handler = carry_handler;
38 | entry->size = code->raw_instruction_size();
39 |
40 | return entry;
41 | }
42 |
43 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/x64/dummy/closure-trampoline-template-x64.S:
--------------------------------------------------------------------------------
1 | #if defined(ENABLE_CLOSURE_BRIDGE_TEMPLATE)
2 |
3 | #if defined(__WIN32__) || defined(__APPLE__)
4 | #define cdecl(s) _##s
5 | #else
6 | #define cdecl(s) s
7 | #endif
8 |
9 | .align 4
10 |
11 | ; closure trampoline just carray the required members from the object.
12 | .globl cdecl(closure_trampoline_template)
13 | cdecl(closure_trampoline_template):
14 | push [rip+6+6]
15 | jmp [rip+6+8]
16 | carry_data:
17 | .long 0
18 | .long 0
19 | carry_handler:
20 | .long 0
21 | .long 0
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/x64/helper-x64.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_X64)
3 |
4 | #include "dobby_internal.h"
5 |
6 | void set_routing_bridge_next_hop(RegisterContext *ctx, void *address) {
7 | addr_t rsp = ctx->rsp;
8 |
9 | // ClosureTrampolineEntry reserved stack
10 | addr_t entry_placeholder_stack_addr = rsp - 8;
11 | *(addr_t *)entry_placeholder_stack_addr = (addr_t)address;
12 | }
13 |
14 | void get_routing_bridge_next_hop(RegisterContext *ctx, void *address) {
15 | }
16 |
17 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/x86/X86AssemblyClosureTrampoline.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_IA32)
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "core/modules/assembler/assembler-ia32.h"
7 |
8 | #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
9 |
10 | extern void closure_trampoline_template();
11 |
12 | using namespace zz;
13 | using namespace zz::x86;
14 |
15 | ClosureTrampolineEntry *ClosureTrampoline::CreateClosureTrampoline(void *carry_data, void *carry_handler) {
16 |
17 | ClosureTrampolineEntry *entry = new ClosureTrampolineEntry;
18 |
19 | #include "TrampolineBridge/ClosureTrampolineBridge/AssemblyClosureTrampoline.h"
20 | #define _ turbo_assembler_.
21 | #define __ turbo_assembler_.GetCodeBuffer()->
22 |
23 | AssemblyCodeChunk *cchunk = MemoryArena::AllocateCodeChunk(32);
24 | if (cchunk == nullptr) {
25 | return NULL;
26 | }
27 | // init assembler
28 | TurboAssembler turbo_assembler_(cchunk->address);
29 |
30 | int32_t offset = (int32_t)get_closure_bridge() - ((int32_t)cchunk->address + 18);
31 |
32 | _ sub(esp, Immediate(4, 32));
33 | _ mov(Address(esp, 4 * 0), Immediate((int32_t)entry, 32));
34 | _ jmp(Immediate(offset, 32));
35 |
36 | entry->address = (void *)cchunk->raw_instruction_start();
37 | entry->carry_data = carry_data;
38 | entry->carry_handler = carry_handler;
39 | entry->size = cchunk->raw_instruction_size();
40 |
41 | CodeBufferBase *buffer = reinterpret_cast(turbo_assembler_.GetCodeBuffer());
42 | CodePatch(cchunk->address, (uint8_t *)buffer->getRawBuffer(), buffer->getSize());
43 |
44 | return entry;
45 | }
46 |
47 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/ClosureTrampolineBridge/x86/helper-x86.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_IA32)
3 |
4 | #include "dobby_internal.h"
5 |
6 | void set_routing_bridge_next_hop(RegisterContext *ctx, void *address) {
7 | addr_t esp = ctx->esp;
8 |
9 | addr_t entry_placeholder_stack_addr = esp - 4;
10 | *(addr_t *)entry_placeholder_stack_addr = (addr_t)address;
11 | }
12 |
13 | void get_routing_bridge_next_hop(RegisterContext *ctx, void *address) {
14 | }
15 |
16 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/InterceptRoutingTrampoline/x64/trampoline-x64.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_X64)
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "core/modules/assembler/assembler-x64.h"
7 | #include "core/modules/codegen/codegen-x64.h"
8 |
9 | #include "InstructionRelocation/x64/X64InstructionRelocation.h"
10 |
11 | #include "MemoryAllocator/NearMemoryArena.h"
12 | #include "InterceptRouting/ExtraInternalPlugin/RegisterPlugin.h"
13 |
14 | using namespace zz::x64;
15 |
16 | static void **AllocIndirectStub(addr_t branch_address) {
17 | WritableDataChunk *forwardStub = NULL;
18 |
19 | forwardStub =
20 | NearMemoryArena::AllocateDataChunk((addr_t)branch_address, (size_t)2 * 1024 * 1024 * 1024, (int)sizeof(void *));
21 | if (forwardStub == nullptr) {
22 | ERROR_LOG("Not found near forward stub");
23 | return NULL;
24 | }
25 |
26 | return (void **)forwardStub->address;
27 | }
28 |
29 | CodeBufferBase *GenerateNormalTrampolineBuffer(addr_t from, addr_t to) {
30 | TurboAssembler turbo_assembler_((void *)from);
31 | #define _ turbo_assembler_.
32 |
33 | // branch
34 | void **branch_stub = AllocIndirectStub(from);
35 | *branch_stub = (void *)to;
36 |
37 | CodeGen codegen(&turbo_assembler_);
38 | codegen.JmpNearIndirect((uint64_t)branch_stub);
39 |
40 | CodeBufferBase *result = NULL;
41 | result = turbo_assembler_.GetCodeBuffer()->Copy();
42 | return result;
43 | }
44 |
45 | CodeBufferBase *GenerateNearTrampolineBuffer(InterceptRouting *routing, addr_t src, addr_t dst) {
46 | DLOG(0, "x64 near branch trampoline enable default");
47 | return NULL;
48 | }
49 |
50 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/TrampolineBridge/InterceptRoutingTrampoline/x86/trampoline-x86.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_IA32)
3 |
4 | #include "dobby_internal.h"
5 |
6 | #include "core/modules/assembler/assembler-ia32.h"
7 | #include "core/modules/codegen/codegen-ia32.h"
8 |
9 | #include "InstructionRelocation/x86/X86InstructionRelocation.h"
10 |
11 | #include "MemoryAllocator/NearMemoryArena.h"
12 | #include "InterceptRouting/ExtraInternalPlugin/RegisterPlugin.h"
13 |
14 | using namespace zz::x86;
15 |
16 | CodeBufferBase *GenerateNormalTrampolineBuffer(addr_t from, addr_t to) {
17 | TurboAssembler turbo_assembler_((void *)from);
18 | #define _ turbo_assembler_.
19 |
20 | CodeGen codegen(&turbo_assembler_);
21 | codegen.JmpNear((uint32_t)to);
22 |
23 | CodeBufferBase *result = NULL;
24 | result = turbo_assembler_.GetCodeBuffer()->Copy();
25 | return result;
26 | }
27 |
28 | CodeBufferBase *GenerateNearTrampolineBuffer(InterceptRouting *routing, addr_t src, addr_t dst) {
29 | DLOG(0, "x86 near branch trampoline enable default");
30 | return NULL;
31 | }
32 |
33 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/UserMode/ExecMemory/clear-cache-tool/clear-cache-tool-arm-dummy.cc:
--------------------------------------------------------------------------------
1 | #ifndef USER_MODE_CLEAR_CACHE_TOOL_H
2 | #define USER_MODE_CLEAR_CACHE_TOOL_H
3 |
4 | #include "core/arch/Cpu.h"
5 |
6 | #include "PlatformInterface/globals.h"
7 |
8 | #if !HOST_OS_IOS
9 | #include // for cache flushing.
10 | #endif
11 |
12 | void CpuFeatures::FlushICache(void *startp, void *endp) {
13 |
14 | #if HOST_OS_IOS
15 | // Precompilation never patches code so there should be no I cache flushes.
16 | CpuFeatures::ClearCache(startp, endp);
17 |
18 | #else
19 |
20 | register uint32_t beg asm("r0") = reinterpret_cast(startp);
21 | register uint32_t end asm("r1") = reinterpret_cast(endp);
22 | register uint32_t flg asm("r2") = 0;
23 |
24 | #ifdef __clang__
25 | // This variant of the asm avoids a constant pool entry, which can be
26 | // problematic when LTO'ing. It is also slightly shorter.
27 | register uint32_t scno asm("r7") = __ARM_NR_cacheflush;
28 |
29 | asm volatile("svc 0\n" : : "r"(beg), "r"(end), "r"(flg), "r"(scno) : "memory");
30 | #else
31 | // Use a different variant of the asm with GCC because some versions doesn't
32 | // support r7 as an asm input.
33 | asm volatile(
34 | // This assembly works for both ARM and Thumb targets.
35 |
36 | // Preserve r7; it is callee-saved, and GCC uses it as a frame pointer for
37 | // Thumb targets.
38 | " push {r7}\n"
39 | // r0 = beg
40 | // r1 = end
41 | // r2 = flags (0)
42 | " ldr r7, =%c[scno]\n" // r7 = syscall number
43 | " svc 0\n"
44 |
45 | " pop {r7}\n"
46 | :
47 | : "r"(beg), "r"(end), "r"(flg), [ scno ] "i"(__ARM_NR_cacheflush)
48 | : "memory");
49 | #endif
50 | #endif
51 | }
52 |
53 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/UserMode/ExecMemory/code-patch-tool-posix.cc:
--------------------------------------------------------------------------------
1 |
2 | #include "dobby_internal.h"
3 | #include "core/arch/Cpu.h"
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | #if !defined(__APPLE__)
10 | PUBLIC MemoryOperationError CodePatch(void *address, uint8_t *buffer, uint32_t buffer_size) {
11 |
12 | int page_size = (int)sysconf(_SC_PAGESIZE);
13 | uintptr_t page_align_address = ALIGN_FLOOR(address, page_size);
14 | int offset = (uintptr_t)address - page_align_address;
15 |
16 | #if defined(__ANDROID__) || defined(__linux__)
17 |
18 | // change page permission as rwx
19 | mprotect((void *)page_align_address, page_size, PROT_READ | PROT_WRITE | PROT_EXEC);
20 |
21 | // patch buffer
22 | memcpy((void *)((addr_t)page_align_address + offset), buffer, buffer_size);
23 |
24 | // restore page permission
25 | mprotect((void *)page_align_address, page_size, PROT_READ | PROT_EXEC);
26 | #endif
27 |
28 | addr_t clear_start_ = (addr_t)page_align_address + offset;
29 | ClearCache((void *)clear_start_, (void *)(clear_start_ + buffer_size));
30 |
31 | return kMemoryOperationSuccess;
32 | }
33 |
34 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/UserMode/ExecMemory/code-patch-tool-windows.cc:
--------------------------------------------------------------------------------
1 | #include "dobby_internal.h"
2 |
3 | #include
4 |
5 | using namespace zz;
6 |
7 | PUBLIC MemoryOperationError CodePatch(void *address, uint8_t *buffer, uint32_t buffer_size) {
8 | DWORD oldProtect;
9 | int pageSize;
10 |
11 | // Get page size
12 | SYSTEM_INFO si;
13 | GetSystemInfo(&si);
14 | pageSize = si.dwPageSize;
15 |
16 | void *addressPageAlign = (void *)ALIGN(address, pageSize);
17 |
18 | if (!VirtualProtect(addressPageAlign, pageSize, PAGE_EXECUTE_READWRITE, &oldProtect))
19 | return kMemoryOperationError;
20 |
21 | memcpy(address, buffer, buffer_size);
22 |
23 | if (!VirtualProtect(addressPageAlign, pageSize, oldProtect, &oldProtect))
24 | return kMemoryOperationError;
25 |
26 | return kMemoryOperationSuccess;
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/UserMode/ExecMemory/substrated/mach_interface_support/substrated.defs:
--------------------------------------------------------------------------------
1 | /*
2 | * Regenerate with:
3 | *
4 | * $(xcrun --sdk macosx -f mig) \
5 | * -isysroot $(xcrun --sdk macosx --show-sdk-path) \
6 | * -sheader substratedserver.h \
7 | * -server substratedserver.c \
8 | * -header substratedclient.h \
9 | * -user substratedclient.c \
10 | * substrated.defs
11 | */
12 |
13 | subsystem substrated 9000;
14 |
15 | #include
16 | #include
17 |
18 | routine substrated_mark (
19 | server : mach_port_t;
20 | task : vm_task_entry_t;
21 | source_address : mach_vm_address_t;
22 | source_size : mach_vm_size_t;
23 | inout target_address : mach_vm_address_t
24 | );
25 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/UserMode/MultiThreadSupport/ThreadSupport.cpp:
--------------------------------------------------------------------------------
1 | #include "MultiThreadSupport/ThreadSupport.h"
2 |
3 | using namespace zz;
4 |
5 | OSThread::LocalStorageKey ThreadSupport::thread_callstack_key_ = 0;
6 |
7 | // Get current CallStack
8 | CallStack *ThreadSupport::CurrentThreadCallStack() {
9 |
10 | // TODO: __attribute__((destructor)) is better ?
11 | if (!thread_callstack_key_) {
12 | thread_callstack_key_ = OSThread::CreateThreadLocalKey();
13 | }
14 |
15 | if (OSThread::HasThreadLocal(thread_callstack_key_)) {
16 | return static_cast(OSThread::GetThreadLocal(thread_callstack_key_));
17 | } else {
18 | CallStack *callstack = new CallStack();
19 | OSThread::SetThreadLocal(thread_callstack_key_, callstack);
20 | return callstack;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/UserMode/PlatformUtil/ProcessRuntimeUtility.h:
--------------------------------------------------------------------------------
1 | #ifndef GET_PROCESS_MODULE_MAP_H
2 | #define GET_PROCESS_MODULE_MAP_H
3 |
4 | #include "PlatformUnifiedInterface/StdMemory.h"
5 |
6 | #include
7 | #include
8 |
9 | typedef struct _RuntimeModule {
10 | char path[1024];
11 | void *load_address;
12 | } RuntimeModule;
13 |
14 | class ProcessRuntimeUtility {
15 | public:
16 | // ================================================================
17 | // Process Memory
18 |
19 | static std::vector GetProcessMemoryLayout();
20 |
21 | // ================================================================
22 | // Process Module
23 |
24 | static std::vector GetProcessModuleMap();
25 |
26 | static RuntimeModule GetProcessModule(const char *name);
27 | };
28 |
29 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/UserMode/PlatformUtil/Windows/ProcesssRuntimeUtility.cc:
--------------------------------------------------------------------------------
1 | #include "PlatformUtil/ProcessRuntimeUtility.h"
2 |
3 | #include
4 |
5 | #define LINE_MAX 2048
6 |
7 | // ================================================================
8 | // GetProcessMemoryLayout
9 |
10 | static bool memory_region_comparator(MemoryRegion a, MemoryRegion b) {
11 | return (a.address > b.address);
12 | }
13 |
14 | std::vector ProcessMemoryLayout;
15 | std::vector ProcessRuntimeUtility::GetProcessMemoryLayout() {
16 | if (!ProcessMemoryLayout.empty()) {
17 | ProcessMemoryLayout.clear();
18 | }
19 |
20 | return ProcessMemoryLayout;
21 | }
22 |
23 | // ================================================================
24 | // GetProcessModuleMap
25 |
26 | std::vector ProcessModuleMap;
27 |
28 | std::vector ProcessRuntimeUtility::GetProcessModuleMap() {
29 | if (!ProcessMemoryLayout.empty()) {
30 | ProcessMemoryLayout.clear();
31 | }
32 | return ProcessModuleMap;
33 | }
34 |
35 | RuntimeModule ProcessRuntimeUtility::GetProcessModule(const char *name) {
36 | std::vector ProcessModuleMap = GetProcessModuleMap();
37 | for (auto module : ProcessModuleMap) {
38 | if (strstr(module.path, name) != 0) {
39 | return module;
40 | }
41 | }
42 | return RuntimeModule{0};
43 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/UserMode/Thread/PlatformThread.cc:
--------------------------------------------------------------------------------
1 | #include "./PlatformThread.h"
2 |
3 | namespace zz {
4 | int OSThread::GetThreadLocalInt(LocalStorageKey key) {
5 | return static_cast(reinterpret_cast(GetThreadLocal(key)));
6 | }
7 |
8 | void OSThread::SetThreadLocalInt(LocalStorageKey key, int value) {
9 | SetThreadLocal(key, reinterpret_cast(static_cast(value)));
10 | }
11 |
12 | bool OSThread::HasThreadLocal(LocalStorageKey key) {
13 | return GetThreadLocal(key) != nullptr;
14 | }
15 |
16 | void *OSThread::GetExistingThreadLocal(LocalStorageKey key) {
17 | return GetThreadLocal(key);
18 | }
19 | } // namespace zz
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/UserMode/Thread/PlatformThread.h:
--------------------------------------------------------------------------------
1 | #ifndef USER_MODE_PLATFORM_THREAD_H
2 | #define USER_MODE_PLATFORM_THREAD_H
3 |
4 | #include "common/headers/common_header.h"
5 |
6 | namespace zz {
7 |
8 | class OSThread {
9 | public:
10 | typedef int LocalStorageKey;
11 |
12 | static int GetCurrentProcessId();
13 |
14 | static int GetCurrentThreadId();
15 |
16 | // Thread-local storage.
17 | static LocalStorageKey CreateThreadLocalKey();
18 |
19 | static void DeleteThreadLocalKey(LocalStorageKey key);
20 |
21 | static void *GetThreadLocal(LocalStorageKey key);
22 |
23 | static int GetThreadLocalInt(LocalStorageKey key);
24 |
25 | static void SetThreadLocal(LocalStorageKey key, void *value);
26 |
27 | static void SetThreadLocalInt(LocalStorageKey key, int value);
28 |
29 | static bool HasThreadLocal(LocalStorageKey key);
30 |
31 | static void *GetExistingThreadLocal(LocalStorageKey key);
32 | };
33 |
34 | } // namespace zz
35 |
36 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/UserMode/Thread/platform-thread-windows.cc:
--------------------------------------------------------------------------------
1 | #include "PlatformThread.h"
2 |
3 | using namespace zz;
4 |
5 | int OSThread::GetCurrentProcessId() {
6 | return 0;
7 | }
8 |
9 | int OSThread::GetCurrentThreadId() {
10 | return 0;
11 | }
12 |
13 | OSThread::LocalStorageKey OSThread::CreateThreadLocalKey() {
14 | return 0;
15 | }
16 |
17 | void OSThread::DeleteThreadLocalKey(LocalStorageKey key) {
18 | }
19 |
20 | void *OSThread::GetThreadLocal(LocalStorageKey key) {
21 | return NULL;
22 | }
23 |
24 | void OSThread::SetThreadLocal(LocalStorageKey key, void *value) {
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/common/headers/common_header.h:
--------------------------------------------------------------------------------
1 | #ifndef COMMON_HEADER_H
2 | #define COMMON_HEADER_H
3 |
4 | #include "common/macros/constants_macro.h"
5 | #include "common/macros/types_macro.h"
6 | #include "common/macros/platform_macro.h"
7 | #include "common/macros/utilities_macro.h"
8 |
9 | #include "logging/logging.h"
10 | #include "logging/check_logging.h"
11 |
12 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/common/macros/constants_macro.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef CONSTANTS_HEADER_H
3 | #define CONSTANTS_HEADER_H
4 |
5 | #define RT_FAILED -1
6 | #define RT_SUCCESS 0
7 |
8 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/common/macros/platform_macro.h:
--------------------------------------------------------------------------------
1 | #ifndef PLATFORM_HEADER_H
2 | #define PLATFORM_HEADER_H
3 |
4 | #if defined(_M_X64) || defined(__x86_64__)
5 | #define TARGET_ARCH_X64 1
6 | #elif defined(_M_IX86) || defined(__i386__)
7 | #define TARGET_ARCH_IA32 1
8 | #elif defined(__AARCH64EL__)
9 | #define TARGET_ARCH_ARM64 1
10 | #elif defined(__ARMEL__)
11 | #define TARGET_ARCH_ARM 1
12 | #elif defined(__mips64)
13 | #define TARGET_ARCH_MIPS64 1
14 | #elif defined(__MIPSEB__) || defined(__MIPSEL__)
15 | #define TARGET_ARCH_MIPS 1
16 | #elif defined(_ARCH_PPC)
17 | #define TARGET_ARCH_PPC 1
18 | #else
19 | #error Target architecture was not detected as supported by Dobby
20 | #endif
21 |
22 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/common/macros/types_macro.h:
--------------------------------------------------------------------------------
1 | #ifndef TYPES_HEADER_H
2 | #define TYPES_HEADER_H
3 |
4 | #include
5 |
6 | #ifndef __addr_32_64_t_defined
7 | #define __addr_32_64_t_defined
8 | typedef uint32_t addr32_t;
9 | typedef uint64_t addr64_t;
10 | #endif
11 |
12 | #ifndef __addr_t_defined
13 | #define __addr_t_defined
14 | typedef uintptr_t addr_t;
15 | #endif
16 |
17 | #ifndef __byte_defined
18 | #define __byte_defined
19 | typedef unsigned char byte_t;
20 | #endif
21 |
22 | #ifndef __uint_defined
23 | #define __uint_defined
24 | typedef unsigned int uint;
25 | #endif
26 |
27 | #ifndef __word_defined
28 | #define __word_defined
29 | typedef short word;
30 | #endif
31 |
32 | #ifndef __dword_defined
33 | #define __dword_defined
34 | typedef int dword;
35 | #endif
36 |
37 | #ifndef NULL
38 | #define NULL 0
39 | #endif
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/arch/Cpu.cc:
--------------------------------------------------------------------------------
1 |
2 | #include "core/arch/Cpu.h"
3 | #include "core/arch/CpuUtils.h"
4 |
5 | #include "xnucxx/LiteMemOpt.h"
6 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/arch/Cpu.h:
--------------------------------------------------------------------------------
1 | #ifndef CORE_ARCH_CPU_H
2 | #define CORE_ARCH_CPU_H
3 |
4 | #include "CpuRegister.h"
5 | #include "CpuFeature.h"
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/arch/CpuFeature.cc:
--------------------------------------------------------------------------------
1 |
2 | #include "core/arch/CpuFeature.h"
3 | #include "logging/logging.h"
4 |
5 | void CpuFeatures::ClearCache(void *start, void *end) {
6 | UNIMPLEMENTED();
7 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/arch/CpuFeature.h:
--------------------------------------------------------------------------------
1 | #ifndef CORE_ARCH_CPU_FEATURE_H
2 | #define CORE_ARCH_CPU_FEATURE_H
3 |
4 | #include "common/headers/common_header.h"
5 |
6 | class CpuFeatures {
7 | private:
8 | static void FlushICache(void *start, int size) {
9 | ClearCache(start, (void *)((addr_t)start + size));
10 | }
11 |
12 | static void FlushICache(void *start, void *end) {
13 | ClearCache(start, end);
14 | }
15 |
16 | static void ClearCache(void *start, void *end);
17 | };
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/arch/CpuRegister.cc:
--------------------------------------------------------------------------------
1 |
2 | #include "CpuRegister.h"
3 |
4 | constexpr RegisterBase RegisterBase::from_code(int code) {
5 | return RegisterBase{code};
6 | }
7 |
8 | constexpr RegisterBase RegisterBase::no_reg() {
9 | return RegisterBase{0};
10 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/arch/CpuRegister.h:
--------------------------------------------------------------------------------
1 | #ifndef CORE_ARCH_CPU_REGISTER_H
2 | #define CORE_ARCH_CPU_REGISTER_H
3 |
4 | class RegisterBase {
5 | public:
6 | static constexpr RegisterBase from_code(int code);
7 |
8 | static constexpr RegisterBase no_reg();
9 |
10 | virtual bool Is(const RegisterBase ®) const {
11 | return (reg.reg_code_ == this->reg_code_);
12 | }
13 |
14 | int code() const {
15 | return reg_code_;
16 | };
17 |
18 | protected:
19 | explicit constexpr RegisterBase(int code) : reg_code_(code) {
20 | }
21 |
22 | int reg_code_;
23 | };
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/arch/CpuUtils.h:
--------------------------------------------------------------------------------
1 | #ifndef CPU_UTILITY_H
2 | #define CPU_UTILITY_H
3 |
4 | /* Define the default attributes for the functions in this file. */
5 | #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
6 |
7 | #if defined(__i386__) || defined(__x86_64__)
8 | static __inline__ void __DEFAULT_FN_ATTRS __cpuid(int __info[4], int __level) {
9 | __asm__("cpuid" : "=a"(__info[0]), "=b"(__info[1]), "=c"(__info[2]), "=d"(__info[3]) : "a"(__level));
10 | }
11 |
12 | static __inline__ void __DEFAULT_FN_ATTRS __cpuidex(int __info[4], int __level, int __ecx) {
13 | __asm__("cpuid" : "=a"(__info[0]), "=b"(__info[1]), "=c"(__info[2]), "=d"(__info[3]) : "a"(__level), "c"(__ecx));
14 | }
15 | #endif
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/arch/arm/constants-arm.h:
--------------------------------------------------------------------------------
1 | #ifndef CORE_ARCH_CONSTANTS_ARM_H
2 | #define CORE_ARCH_CONSTANTS_ARM_H
3 |
4 | enum AddrMode { Offset = 0, PreIndex = 1, PostIndex = 2 };
5 |
6 | enum Condition {
7 | EQ = 0, // equal
8 | NE = 1, // not equal
9 | CS = 2, // carry set/unsigned higher or same
10 | CC = 3, // carry clear/unsigned lower
11 | MI = 4, // minus/negative
12 | PL = 5, // plus/positive or zero
13 | VS = 6, // overflow
14 | VC = 7, // no overflow
15 | HI = 8, // unsigned higher
16 | LS = 9, // unsigned lower or same
17 | GE = 10, // signed greater than or equal
18 | LT = 11, // signed less than
19 | GT = 12, // signed greater than
20 | LE = 13, // signed less than or equal
21 | AL = 14, // always (unconditional)
22 |
23 | };
24 |
25 | enum Shift {
26 | LSL = 0, // Logical shift left
27 | LSR = 1, // Logical shift right
28 | ASR = 2, // Arithmetic shift right
29 | ROR = 3, // Rotate right
30 | };
31 |
32 | enum {
33 | B0 = 1 << 0,
34 | B4 = 1 << 4,
35 | B5 = 1 << 5,
36 | B6 = 1 << 6,
37 | B7 = 1 << 7,
38 | B8 = 1 << 8,
39 | B9 = 1 << 9,
40 | B10 = 1 << 10,
41 | B12 = 1 << 12,
42 | B14 = 1 << 14,
43 | B15 = 1 << 15,
44 | B16 = 1 << 16,
45 | B17 = 1 << 17,
46 | B18 = 1 << 18,
47 | B19 = 1 << 19,
48 | B20 = 1 << 20,
49 | B21 = 1 << 21,
50 | B22 = 1 << 22,
51 | B23 = 1 << 23,
52 | B24 = 1 << 24,
53 | B25 = 1 << 25,
54 | B26 = 1 << 26,
55 | B27 = 1 << 27,
56 | B28 = 1 << 28,
57 | };
58 |
59 | enum InstructionFields {
60 | // Registers.
61 | kRdShift = 12,
62 | kRtShift = 12,
63 | kRmShift = 10,
64 | kRnShift = 16,
65 |
66 | // Condition
67 | kConditionShift = 28,
68 | };
69 |
70 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/arch/arm/registers-arm.h:
--------------------------------------------------------------------------------
1 | #ifndef ARCH_ARM_REGISTERS
2 | #define ARCH_ARM_REGISTERS
3 |
4 | #include "core/arch/arm/constants-arm.h"
5 | #include "core/arch/Cpu.h"
6 |
7 | namespace zz {
8 | namespace arm {
9 |
10 | #define GENERAL_REGISTERS(V) \
11 | V(r0) V(r1) V(r2) V(r3) V(r4) V(r5) V(r6) V(r7) V(r8) V(r9) V(r10) V(r11) V(r12) V(sp) V(lr) V(pc)
12 |
13 | enum RegisterCode {
14 | #define REGISTER_CODE(R) kRegCode_##R,
15 | GENERAL_REGISTERS(REGISTER_CODE)
16 | #undef REGISTER_CODE
17 | kRegAfterLast
18 | };
19 |
20 | class Register : public RegisterBase {
21 | public:
22 | explicit constexpr Register(int code) : RegisterBase(code) {
23 | }
24 |
25 | static constexpr Register Create(int code) {
26 | return Register(code);
27 | }
28 |
29 | static constexpr Register R(int code) {
30 | return Register(code);
31 | }
32 |
33 | bool Is(const Register ®) const {
34 | return (reg.reg_code_ == this->reg_code_);
35 | }
36 |
37 | bool IsValid() const {
38 | return (reg_code_ != 0);
39 | }
40 |
41 | int code() const {
42 | return reg_code_;
43 | }
44 |
45 | private:
46 | };
47 |
48 | typedef Register CPURegister;
49 |
50 | #define DECLARE_REGISTER(R) constexpr Register R = Register::Create(kRegCode_##R);
51 | GENERAL_REGISTERS(DECLARE_REGISTER)
52 | #undef DECLARE_REGISTER
53 |
54 | constexpr Register no_reg = Register::Create(0);
55 |
56 | } // namespace arm
57 | } // namespace zz
58 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/arch/x64/constants-x64.h:
--------------------------------------------------------------------------------
1 | #ifndef CORE_ARCH_CONSTANTS_X64_H
2 | #define CORE_ARCH_CONSTANTS_X64_H
3 |
4 | namespace zz {
5 | namespace x64 {
6 |
7 | enum ScaleFactor {
8 | TIMES_1 = 0,
9 | TIMES_2 = 1,
10 | TIMES_4 = 2,
11 | TIMES_8 = 3,
12 | TIMES_16 = 4,
13 | TIMES_HALF_WORD_SIZE = sizeof(void *) / 2 - 1
14 | };
15 |
16 | enum RexBits { REX_NONE = 0, REX_B = 1 << 0, REX_X = 1 << 1, REX_R = 1 << 2, REX_W = 1 << 3, REX_PREFIX = 1 << 6 };
17 |
18 | } // namespace x64
19 | } // namespace zz
20 |
21 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/arch/x86/constants-x86.h:
--------------------------------------------------------------------------------
1 | #ifndef CORE_ARCH_CONSTANTS_X86_H
2 | #define CORE_ARCH_CONSTANTS_X86_H
3 |
4 | namespace zz {
5 | namespace x86 {
6 |
7 | enum ScaleFactor {
8 | TIMES_1 = 0,
9 | TIMES_2 = 1,
10 | TIMES_4 = 2,
11 | TIMES_8 = 3,
12 | TIMES_16 = 4,
13 | TIMES_HALF_WORD_SIZE = sizeof(void *) / 2 - 1
14 | };
15 |
16 | } // namespace x86
17 | } // namespace zz
18 |
19 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/assembler/assembler-arch.h:
--------------------------------------------------------------------------------
1 | #ifndef CORE_ASSEMBLER_ARCH_H
2 | #define CORE_ASSEMBLER_ARCH_H
3 |
4 | #include "src/assembler.h"
5 |
6 | #if 0
7 | #if TARGET_ARCH_IA32
8 | #include "src/ia32/assembler-ia32.h"
9 | #elif TARGET_ARCH_X64
10 | #include "src/x64/assembler-x64.h"
11 | #elif TARGET_ARCH_ARM64
12 | #include "src/arm64/assembler-arm64.h"
13 | #elif TARGET_ARCH_ARM
14 | #include "src/arm/assembler-arm.h"
15 | #elif TARGET_ARCH_PPC
16 | #include "src/ppc/assembler-ppc.h"
17 | #elif TARGET_ARCH_MIPS
18 | #include "src/mips/assembler-mips.h"
19 | #elif TARGET_ARCH_MIPS64
20 | #include "src/mips64/assembler-mips64.h"
21 | #elif TARGET_ARCH_S390
22 | #include "src/s390/assembler-s390.h"
23 | #else
24 | #error Unknown architecture.
25 | #endif
26 | #endif
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/assembler/assembler-arm.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if TARGET_ARCH_ARM
3 |
4 | #include "core/modules/assembler/assembler-arm.h"
5 |
6 | namespace zz {
7 | namespace arm {
8 |
9 | void Assembler::EmitARMInst(arm_inst_t instr) {
10 | buffer_->EmitARMInst(instr);
11 | }
12 |
13 | void Assembler::EmitAddress(uint32_t value) {
14 | buffer_->Emit32(value);
15 | }
16 |
17 | } // namespace arm
18 | } // namespace zz
19 |
20 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/assembler/assembler-ia32.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if TARGET_ARCH_IA32
3 |
4 | #include "core/modules/assembler/assembler-ia32.h"
5 |
6 | using namespace zz::x86;
7 |
8 | void Assembler::jmp(Immediate imm) {
9 | buffer_->Emit8(0xE9);
10 | buffer_->Emit32((int)imm.value());
11 | }
12 |
13 | addr32_t TurboAssembler::CurrentIP() {
14 | return pc_offset() + (addr_t)realized_address_;
15 | }
16 |
17 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/assembler/assembler-x64.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_X64)
3 |
4 | #include "core/modules/assembler/assembler-x64.h"
5 |
6 | using namespace zz::x64;
7 |
8 | void Assembler::jmp(Immediate imm) {
9 | buffer_->Emit8(0xE9);
10 | buffer_->Emit32((int)imm.value());
11 | }
12 |
13 | uint64_t TurboAssembler::CurrentIP() {
14 | return pc_offset() + (addr_t)realized_address_;
15 | }
16 |
17 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/assembler/assembler-x86-shared.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_IA32)
3 |
4 | #include "core/modules/assembler/assembler-x86-shared.h"
5 |
6 | using namespace zz::x86shared;
7 |
8 | void Assembler::jmp(Immediate imm) {
9 | buffer_->Emit8(0xE9);
10 | buffer_->Emit32((int)imm.value());
11 | }
12 |
13 | uint64_t TurboAssembler::CurrentIP() {
14 | return pc_offset() + (addr_t)realized_address_;
15 | }
16 |
17 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/codegen/codegen-arm.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_ARM)
3 |
4 | #include "core/modules/codegen/codegen-arm.h"
5 |
6 | namespace zz {
7 | namespace arm {
8 |
9 | void CodeGen::LiteralLdrBranch(uint32_t address) {
10 | TurboAssembler *turbo_assembler_ = reinterpret_cast(this->assembler_);
11 | #define _ turbo_assembler_->
12 | _ ldr(pc, MemOperand(pc, -4));
13 | turbo_assembler_->GetCodeBuffer()->Emit32((addr_t)address);
14 | }
15 |
16 | } // namespace arm
17 | } // namespace zz
18 |
19 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/codegen/codegen-arm.h:
--------------------------------------------------------------------------------
1 | #ifndef CORE_CODEGEN_ARM_H
2 | #define CORE_CODEGEN_ARM_H
3 |
4 | #include "core/modules/codegen/codegen.h"
5 | #include "core/modules/assembler/assembler.h"
6 | #include "core/modules/assembler/assembler-arm.h"
7 |
8 | namespace zz {
9 | namespace arm {
10 |
11 | class CodeGen : public CodeGenBase {
12 | public:
13 | CodeGen(TurboAssembler *turbo_assembler) : CodeGenBase(turbo_assembler) {
14 | }
15 |
16 | void LiteralLdrBranch(uint32_t address);
17 | };
18 |
19 | } // namespace arm
20 | } // namespace zz
21 |
22 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/codegen/codegen-arm64.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_ARM64)
3 |
4 | #include "dobby_internal.h"
5 | #include "core/modules/codegen/codegen-arm64.h"
6 |
7 | namespace zz {
8 | namespace arm64 {
9 |
10 | void CodeGen::LiteralLdrBranch(uint64_t address) {
11 | TurboAssembler *turbo_assembler_ = reinterpret_cast(this->assembler_);
12 | #define _ turbo_assembler_->
13 | PseudoLabel address_ptr;
14 |
15 | _ Ldr(TMP_REG_0, &address_ptr);
16 | _ br(TMP_REG_0);
17 | _ PseudoBind(&address_ptr);
18 | _ EmitInt64(address);
19 | }
20 |
21 | } // namespace arm64
22 | } // namespace zz
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/codegen/codegen-arm64.h:
--------------------------------------------------------------------------------
1 | #ifndef CORE_CODEGEN_ARM64_H
2 | #define CORE_CODEGEN_ARM64_H
3 |
4 | #include "core/modules/codegen/codegen.h"
5 | #include "core/modules/assembler/assembler.h"
6 | #include "core/modules/assembler/assembler-arm64.h"
7 |
8 | namespace zz {
9 | namespace arm64 {
10 |
11 | class CodeGen : public CodeGenBase {
12 | public:
13 | CodeGen(TurboAssembler *turbo_assembler) : CodeGenBase(turbo_assembler) {
14 | }
15 | void LiteralLdrBranch(uint64_t address);
16 | };
17 |
18 | } // namespace arm64
19 | } // namespace zz
20 |
21 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/codegen/codegen-ia32.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_IA32)
3 |
4 | #include "core/modules/codegen/codegen-ia32.h"
5 |
6 | namespace zz {
7 | namespace x86 {
8 |
9 | void CodeGen::JmpNear(uint32_t address) {
10 | TurboAssembler *turbo_assembler_ = reinterpret_cast(this->assembler_);
11 | #define _ turbo_assembler_->
12 | #define __ turbo_assembler_->GetCodeBuffer()->
13 | uint32_t currIP = turbo_assembler_->CurrentIP() + 5;
14 | dword offset = (dword)(address - currIP);
15 |
16 | __ Emit8(0xe9);
17 | __ Emit32(offset);
18 | }
19 |
20 | } // namespace x86
21 | } // namespace zz
22 |
23 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/codegen/codegen-ia32.h:
--------------------------------------------------------------------------------
1 | #ifndef CORE_CODEGEN_X86_H
2 | #define CORE_CODEGEN_X86_H
3 |
4 | #include "core/modules/codegen/codegen.h"
5 | #include "core/modules/assembler/assembler.h"
6 | #include "core/modules/assembler/assembler-ia32.h"
7 |
8 | namespace zz {
9 | namespace x86 {
10 |
11 | class CodeGen : public CodeGenBase {
12 | public:
13 | CodeGen(TurboAssembler *turbo_assembler) : CodeGenBase(turbo_assembler) {
14 | }
15 |
16 | void JmpNear(uint32_t address);
17 | };
18 |
19 | } // namespace x86
20 | } // namespace zz
21 |
22 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/codegen/codegen-x64.cc:
--------------------------------------------------------------------------------
1 | #include "common/macros/platform_macro.h"
2 | #if defined(TARGET_ARCH_X64)
3 |
4 | #include "core/modules/codegen/codegen-x64.h"
5 |
6 | namespace zz {
7 | namespace x64 {
8 |
9 | void CodeGen::JmpNearIndirect(uint64_t address) {
10 | TurboAssembler *turbo_assembler_ = reinterpret_cast(this->assembler_);
11 | #define _ turbo_assembler_->
12 | #define __ turbo_assembler_->GetCodeBuffer()->
13 | uint64_t currIP = turbo_assembler_->CurrentIP() + 6;
14 | dword offset = (dword)(address - currIP);
15 |
16 | // RIP-relative addressing
17 | __ Emit8(0xFF);
18 | __ Emit8(0x25);
19 | __ Emit32(offset);
20 | }
21 |
22 | } // namespace x64
23 | } // namespace zz
24 |
25 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/codegen/codegen-x64.h:
--------------------------------------------------------------------------------
1 | #ifndef CORE_CODEGEN_X64_H
2 | #define CORE_CODEGEN_X64_H
3 |
4 | #include "core/modules/codegen/codegen.h"
5 | #include "core/modules/assembler/assembler.h"
6 | #include "core/modules/assembler/assembler-x64.h"
7 |
8 | namespace zz {
9 | namespace x64 {
10 |
11 | class CodeGen : public CodeGenBase {
12 | public:
13 | CodeGen(TurboAssembler *turbo_assembler) : CodeGenBase(turbo_assembler) {
14 | }
15 |
16 | void JmpNearIndirect(uint64_t address);
17 | };
18 |
19 | } // namespace x64
20 | } // namespace zz
21 |
22 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/codegen/codegen.h:
--------------------------------------------------------------------------------
1 | #ifndef CORE_CODEGEN_H
2 | #define CORE_CODEGEN_H
3 |
4 | #include "core/modules/assembler/assembler.h"
5 |
6 | using namespace zz;
7 |
8 | class CodeGenBase {
9 | public:
10 | CodeGenBase(AssemblerBase *assembler) : assembler_(assembler) {
11 | }
12 |
13 | protected:
14 | AssemblerBase *assembler_;
15 | };
16 |
17 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/core/modules/emulator/dummy.cc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/cpp/Dobby/source/core/modules/emulator/dummy.cc
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/dobby.cpp:
--------------------------------------------------------------------------------
1 | #if defined(__linux__) || defined(__APPLE__)
2 | #include
3 | #include
4 |
5 | #include "dobby_internal.h"
6 |
7 | #include "Interceptor.h"
8 |
9 | __attribute__((constructor)) static void ctor() {
10 | DLOG(-1, "================================");
11 | DLOG(-1, "Dobby");
12 | DLOG(-1, "================================");
13 |
14 | DLOG(-1, "dobby in debug log mode, disable with cmake flag \"-DDOBBY_DEBUG=OFF\"");
15 | }
16 |
17 | PUBLIC const char *DobbyBuildVersion() {
18 | return __DOBBY_BUILD_VERSION__;
19 | }
20 |
21 | PUBLIC int DobbyDestroy(void *address) {
22 | // check if we already hook
23 | HookEntry *entry = Interceptor::SharedInstance()->FindHookEntry(address);
24 | if (entry) {
25 | uint8_t *buffer = entry->origin_chunk_.chunk_buffer;
26 | uint32_t buffer_size = entry->origin_chunk_.chunk.length;
27 | #if defined(TARGET_ARCH_ARM)
28 | address = (void *)((addr_t)address - 1);
29 | #endif
30 | CodePatch(address, buffer, buffer_size);
31 | Interceptor::SharedInstance()->RemoveHookEntry(address);
32 | return RT_SUCCESS;
33 | }
34 |
35 | return RT_FAILED;
36 | }
37 |
38 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/source/dobby_internal.h:
--------------------------------------------------------------------------------
1 | #ifndef DOBBY_INTERNAL_H
2 | #define DOBBY_INTERNAL_H
3 |
4 | #include "dobby.h"
5 |
6 | #include "logging/logging.h"
7 | #include "logging/check_logging.h"
8 |
9 | #include "xnucxx/LiteMemOpt.h"
10 | #include "xnucxx/LiteMutableArray.h"
11 | #include "xnucxx/LiteMutableBuffer.h"
12 | #include "xnucxx/LiteIterator.h"
13 |
14 | #include "UnifiedInterface/platform.h"
15 |
16 | #include "PlatformUnifiedInterface/StdMemory.h"
17 | #include "PlatformUnifiedInterface/ExecMemory/CodePatchTool.h"
18 | #include "PlatformUnifiedInterface/ExecMemory/ClearCacheTool.h"
19 |
20 | #include "MemoryAllocator/MemoryArena.h"
21 | #include "MemoryAllocator/AssemblyCodeBuilder.h"
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | typedef struct _AssemblyCodeChunkBuffer {
30 | AssemblyCodeChunk chunk;
31 | uint8_t chunk_buffer[64];
32 | } AssemblyCodeChunkBuffer;
33 |
34 | typedef enum {
35 | kFunctionWrapper,
36 | kFunctionInlineHook,
37 | kDynamicBinaryInstrument
38 | } HookEntryType;
39 |
40 | typedef struct {
41 | int id;
42 | int type;
43 |
44 | union {
45 | void *target_address;
46 | void *function_address;
47 | void *instruction_address;
48 | };
49 |
50 | void *route;
51 |
52 | // fixed-instructions which we relocated(patched)
53 | union {
54 | void *relocated_origin_instructions;
55 | void *relocated_origin_function;
56 | };
57 |
58 | AssemblyCodeChunkBuffer origin_chunk_;
59 | } HookEntry;
60 |
61 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/tests/CMakelists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.5)
2 | project(test_dobby)
3 |
4 | set(PrimaryPath ..)
5 |
6 | include(${PrimaryPath}/cmake/Globals.cmake)
7 | include(${PrimaryPath}/cmake/Macros.cmake)
8 |
9 | set(CMAKE_CXX_STANDARD 11)
10 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
11 | set(CMAKE_C_STANDARD 11)
12 | enable_language(ASM)
13 |
14 |
15 | include_directories(
16 | ${PrimaryPath}/tests
17 | ${PrimaryPath}/source
18 | )
19 |
20 | include_directories(
21 | ${PrimaryPath}/source
22 | ${PrimaryPath}/source/UserMode
23 | ${PrimaryPath}/external
24 | ${PrimaryPath}/external/logging
25 | ${PrimaryPath}/external/xnucxx
26 | )
27 |
28 | add_subdirectory(${PrimaryPath} dobby.out)
29 |
30 | add_executable(tests_instr_relo_x64
31 | ${PrimaryPath}/source/InstructionRelocation/x64/X64IPRelativeOpcodeTable.cc
32 | ${PrimaryPath}/tests/InstructionRelocation/x64/test_x64_instruction_relocation.cc
33 | )
34 |
35 | add_executable(tests_instr_relo_aarch64
36 | ${PrimaryPath}/tests/InstructionRelocation/aarch64/test_aarch64_instruction_relocation.cc
37 | )
38 | target_link_libraries(tests_instr_relo_aarch64
39 | dobby
40 | )
--------------------------------------------------------------------------------
/app/src/main/cpp/Dobby/tests/InstructionRelocation/aarch64/test_aarch64_instruction_relocation.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #if defined(__WIN32__) || defined(__APPLE__)
5 | #define xcdecl(s) "_" s
6 | #else
7 | #define xcdecl(s) s
8 | #endif
9 |
10 | #define xASM(x) __asm(x)
11 |
12 | __attribute__((naked)) void pc_relative_instructions() {
13 | xASM("ldr x0, #4");
14 | xASM("nop");
15 | xASM("nop");
16 |
17 | xASM("nop");
18 | xASM("nop");
19 | xASM("ldr x0, #-4");
20 |
21 | xASM("adr x0, #4");
22 |
23 | xASM("adrp x0, #0x1000");
24 |
25 | xASM("tbz x0, #8, #4");
26 |
27 | xASM("tbz x0, #27, #-4");
28 |
29 | xASM("cbz x0, #4");
30 |
31 | xASM("cbz x0, #-4");
32 |
33 | xASM("cmp x0, x0");
34 | xASM("b.eq #-4");
35 | }
36 |
37 | __attribute__((naked)) void pc_relative_instructions_end() {
38 | }
39 |
40 | #include "InstructionRelocation/arm64/ARM64InstructionRelocation.h"
41 |
42 | extern zz::AssemblyCode *GenRelocateCodeAndBranch(void *buffer, int *relocate_size, addr_t from_pc, addr_t to_pc);
43 |
44 | extern "C" {
45 | int _main(int argc, const char **argv);
46 | }
47 |
48 | int _main(int argc, const char **argv) {
49 | LOG(1, "pc_relative_instructions: %p", pc_relative_instructions);
50 |
51 | char *relo_buffer = (char *)malloc(0x1000);
52 |
53 | int relo_size = (uint64_t)pc_relative_instructions_end - (uint64_t)pc_relative_instructions;
54 | zz::AssemblyCode *code = GenRelocateCodeAndBranch((void *)pc_relative_instructions, &relo_size, 0, 0);
55 |
56 | unsigned char *instruction_bytes = (unsigned char *)code->raw_instruction_start();
57 | for (int i = 0; i < code->raw_instruction_size(); i += 1) {
58 | printf("%.2x ", instruction_bytes[i]);
59 | }
60 |
61 | return 0;
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/cpp/FdPath.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | class FdPath {
6 | public:
7 | explicit FdPath(int fd) {
8 | snprintf(buf, sizeof(buf), "/proc/self/fd/%d", fd);
9 | }
10 |
11 | const char* c_str() {
12 | return buf;
13 | }
14 |
15 | private:
16 | char buf[40];
17 | };
--------------------------------------------------------------------------------
/app/src/main/cpp/base.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Administrator on 2021/11/16.
3 | //
4 | #include
5 | #include
6 | #ifndef MY_APPLICATION_BASE_H
7 | #define MY_APPLICATION_BASE_H
8 |
9 | #define targetLibName "libil2cpp.so"
10 |
11 | #define ENABLE true
12 | #define LOG_TAG "Imy"
13 | #if ENABLE
14 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
15 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
16 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
17 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
18 | #else
19 | #define LOGI(...)
20 | #define LOGD(...)
21 | #define LOGW(...)
22 | #define LOGE(...)
23 | #endif
24 |
25 | #endif //ANDROIDCPPSOLIB_LOGUTIL_H
26 | #ifndef DUMPER_BASE_H
27 | #define DUMPER_BASE_H
28 |
29 |
30 |
31 |
32 |
33 | #endif //DUMPER_BASE_H
34 |
--------------------------------------------------------------------------------
/app/src/main/cpp/libc/platform/bionic/page.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 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 | #pragma once
18 |
19 | // Get PAGE_SIZE and PAGE_MASK.
20 | #include
21 |
22 | // Returns the address of the page containing address 'x'.
23 | #define PAGE_START(x) ((x) & PAGE_MASK)
24 |
25 | // Returns the offset of address 'x' in its page.
26 | #define PAGE_OFFSET(x) ((x) & ~PAGE_MASK)
27 |
28 | // Returns the address of the next page after address 'x', unless 'x' is
29 | // itself at the start of a page.
30 | #define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE-1))
31 |
--------------------------------------------------------------------------------
/app/src/main/cpp/linker/fake_mmap.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by PC5000 on 2024/3/29.
3 | //
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include "fake_mmap.h"
11 | #include "linker.h"
12 | #include "log.h"
13 |
14 |
15 |
16 | void* fake_mmap64(void *addr, size_t length, int prot, int flags, int fd, off_t offset) {
17 | //判断宏定义 ENBALE_HIDE_MAP 是否等于1
18 | if (ENBALE_HIDE_MAP ==0) {
19 | //判断__addr是否等于0
20 | return mmap64(addr, length, prot, flags, fd, offset);
21 | } else{
22 | // 验证参数
23 |
24 | return mmap64(addr, length, prot, flags, fd, offset);
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/linker/fake_mmap.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by PC5000 on 2024/3/29.
3 | //
4 |
5 | #ifndef LINKERBRIDGE_FAKE_MMAP_H
6 | #define LINKERBRIDGE_FAKE_MMAP_H
7 |
8 | void* fake_mmap64(void* __addr, size_t __size, int __prot, int __flags, int __fd, off64_t __offset);
9 |
10 |
11 | #endif //LINKERBRIDGE_FAKE_MMAP_H
12 |
--------------------------------------------------------------------------------
/app/src/main/cpp/linker/linker.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by PC5000 on 2024/3/26.
3 | //
4 |
5 | #ifndef LINKERBRIDGE_LINKER_H
6 | #define LINKERBRIDGE_LINKER_H
7 | #include "android/dlext.h"
8 | #include "linker_soinfo.h"
9 | #define ON 1 //enbale hide in proc/self/maps
10 | #define OFF 0 // do not hide
11 |
12 | #define ENBALE_HIDE_MAP ON
13 | #define FAKE_MAPS_NAME ".Imy"
14 | #define FAKE_SEGMENT_NAME "linker_alloc"
15 | #define SUPPORTED_DT_FLAGS_1 (DF_1_NOW | DF_1_GLOBAL | DF_1_NODELETE | DF_1_PIE)
16 | int get_application_target_sdk_version();
17 |
18 |
19 | // Class used construct version dependency graph.
20 | class VersionTracker {
21 | public:
22 | VersionTracker() = default;
23 | bool init(const soinfo* si_from);
24 |
25 | const version_info* get_version_info(ElfW(Versym) source_symver) const;
26 | private:
27 | bool init_verneed(const soinfo* si_from);
28 | bool init_verdef(const soinfo* si_from);
29 | void add_version_info(size_t source_index, ElfW(Word) elf_hash,
30 | const char* ver_name, const soinfo* target_si);
31 |
32 | std::vector version_infos;
33 |
34 | DISALLOW_COPY_AND_ASSIGN(VersionTracker);
35 | };
36 | bool get_transparent_hugepages_supported();
37 | void* do_dlopen(const char* name, int flags,
38 | const android_dlextinfo* extinfo,
39 | const void* caller_addr);
40 | struct address_space_params {
41 | void* start_addr = nullptr;
42 | size_t reserved_size = 0;
43 | bool must_use_address = false;
44 | };
45 |
46 | struct platform_properties {
47 | #if defined(__aarch64__)
48 | bool bti_supported = false;
49 | #endif
50 | };
51 |
52 | ElfW(Versym) find_verdef_version_index(const soinfo* si, const version_info* vi);
53 |
54 |
55 | #endif //LINKERBRIDGE_LINKER_H
56 |
--------------------------------------------------------------------------------
/app/src/main/cpp/linker/linker_config.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * * Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * * Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 | * SUCH DAMAGE.
27 | */
28 |
29 | #include "linker_config.h"
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/cpp/linker/linker_config.h:
--------------------------------------------------------------------------------
1 |
2 | #pragma once
3 | #if defined(__LP64__)
4 | static constexpr const char* kLibPath = "lib64";
5 | #else
6 | static constexpr const char* kLibPath = "lib";
7 | #endif
--------------------------------------------------------------------------------
/app/src/main/cpp/linker/linker_globals.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by PC5000 on 2024/4/1.
3 | //
4 |
5 | #ifndef LINKERBRIDGE_LINKER_GLOBALS_H
6 | #define LINKERBRIDGE_LINKER_GLOBALS_H
7 |
8 | #include
9 | constexpr ElfW(Versym) kVersymNotNeeded = 0;
10 | constexpr ElfW(Versym) kVersymGlobal = 1;
11 | #endif //LINKERBRIDGE_LINKER_GLOBALS_H
12 |
--------------------------------------------------------------------------------
/app/src/main/cpp/linker/linker_main.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by PC5000 on 2024/3/27.
3 | //
4 |
5 | #include "linker_main.h"
6 | #include "linker_soinfo.h"
7 | #include "dobby.h"
8 | #include
9 | #include "log.h"
10 | #include "sys/auxv.h"
11 | static int get_android_system_version() {
12 | char os_version_str[PROP_VALUE_MAX + 1];
13 | __system_property_get("ro.build.version.release", os_version_str);
14 | int os_version_int = atoi(os_version_str);
15 | return os_version_int;
16 | }
17 |
18 |
19 | static char *get_android_linker_path() {
20 | #if __LP64__
21 | if (get_android_system_version() >= 10) {
22 | return "/apex/com.android.runtime/bin/linker64";
23 | } else {
24 | return "/system/bin/linker64";
25 | }
26 | #else
27 | if (get_android_system_version() >= 10) {
28 | return "/apex/com.android.runtime/bin/linker";
29 | } else {
30 | return "/system/bin/linker";
31 | }
32 | #endif
33 | }
34 |
35 |
36 | soinfo *solist_get_head() {
37 | soinfo *solist;
38 | static soinfo *(*solist_get_head)() = NULL;
39 | if (!solist_get_head)
40 | solist_get_head =
41 | (soinfo *(*)()) DobbySymbolResolver(get_android_linker_path(),
42 | "__dl__Z15solist_get_headv");
43 | solist = (soinfo *) solist_get_head();
44 |
45 | return solist;
46 | }
47 |
48 | soinfo *solist_get_somain() {
49 | static soinfo *(*solist_get_head)() = NULL;
50 | if (!solist_get_head)
51 | solist_get_head =
52 | (soinfo *(*)()) DobbySymbolResolver(get_android_linker_path(),
53 | "__dl__Z15solist_get_headv");
54 | LOGI("got soinfo head fun %p ", solist_get_head);
55 | return nullptr;
56 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/linker/linker_main.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by PC5000 on 2024/3/27.
3 | //
4 |
5 | #ifndef LINKERBRIDGE_LINKER_MAIN_H
6 | #define LINKERBRIDGE_LINKER_MAIN_H
7 | #include "vector"
8 | #include "../Dobby/builtin-plugin/BionicLinkerRestriction/bionic_linker_restriction.h"
9 |
10 | struct soinfo;
11 |
12 | soinfo* solist_get_somain();
13 | soinfo* solist_get_head();
14 | std::vector linker_get_solist();
15 |
16 | #endif //LINKERBRIDGE_LINKER_MAIN_H
17 |
--------------------------------------------------------------------------------
/app/src/main/cpp/linker/linker_tls.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * * Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * * Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 | * SUCH DAMAGE.
27 | */
28 |
29 | #pragma once
30 |
31 | #include
32 |
33 | #include "private/bionic_elf_tls.h"
34 | struct soinfo;
35 | void register_soinfo_tls(soinfo* si);
36 |
37 | struct TlsDynamicResolverArg {
38 | size_t generation;
39 | TlsIndex index;
40 | };
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/cpp/linker/log.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by PC5000 on 2024/3/27.
3 | //
4 | #include
5 | #include
6 | #ifndef LINKERBRIDGE_LOG_H
7 | #define LINKERBRIDGE_LOG_H
8 | #define ENABLE true
9 | #define LOG_TAG "MyLinker"
10 | #define LinkerTrace "LinkerTrace"
11 | #if ENABLE
12 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
13 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
14 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
15 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
16 | #else
17 | #define LOGI(...)
18 | #define LOGD(...)
19 | #define LOGW(...)
20 | #define LOGE(...)
21 | #endif
22 | #define TRACE_TYPE(...) __android_log_print(ANDROID_LOG_ERROR,LinkerTrace,__VA_ARGS__)
23 | #endif //LINKERBRIDGE_LOG_H
24 |
--------------------------------------------------------------------------------
/app/src/main/cpp/linker/mylinker.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by PC5000 on 2024/3/27.
3 | //
4 |
5 | #ifndef LINKERBRIDGE_MYLINKER_H
6 | #define LINKERBRIDGE_MYLINKER_H
7 | #include "linker.h"
8 | static void* dlopen_ext(const char* filename,
9 | int flags,
10 | const android_dlextinfo* extinfo,
11 | const void* caller_addr) {
12 | void* result = do_dlopen(filename, flags, extinfo, caller_addr);
13 | return result;
14 | }
15 | void* __loader_dlopen(const char* filename, int flags, const void* caller_addr) {
16 | return dlopen_ext(filename, flags, nullptr, caller_addr);
17 | }
18 | void* my_dlopen(const char* filename, int flag){
19 | const void* caller_addr = __builtin_return_address(0);
20 | return __loader_dlopen(filename, flag, caller_addr);
21 | }
22 |
23 | #endif //LINKERBRIDGE_MYLINKER_H
24 |
--------------------------------------------------------------------------------
/app/src/main/cpp/linker/private/bionic_elf_tls.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by PC5000 on 2024/3/29.
3 | //
4 |
5 |
6 | #include
7 | #include "bionic_elf_tls.h"
8 | #include "sys/param.h"
9 | bool __bionic_get_tls_segment(const ElfW(Phdr)* phdr_table, size_t phdr_count,
10 | ElfW(Addr) load_bias, TlsSegment* out){
11 | for (size_t i = 0; i < phdr_count; ++i) {
12 | const ElfW(Phdr)& phdr = phdr_table[i];
13 | if (phdr.p_type == PT_TLS) {
14 | *out = TlsSegment {
15 | phdr.p_memsz,
16 | phdr.p_align,
17 | reinterpret_cast(load_bias + phdr.p_vaddr),
18 | phdr.p_filesz,
19 | };
20 | return true;
21 | }
22 | }
23 | return false;
24 | }
25 |
26 | // Return true if the alignment of a TLS segment is a valid power-of-two. Also
27 | // cap the alignment if it's too high.
28 | bool __bionic_check_tls_alignment(size_t* alignment) {
29 | // N.B. The size does not need to be a multiple of the alignment. With
30 | // ld.bfd (or after using binutils' strip), the TLS segment's size isn't
31 | // rounded up.
32 | if (*alignment == 0 || !powerof2(*alignment)) {
33 | return false;
34 | }
35 | // Bionic only respects TLS alignment up to one page.
36 | *alignment = MIN(*alignment, PAGE_SIZE);
37 | return true;
38 | }
--------------------------------------------------------------------------------
/app/src/main/cpp/utils/FileUtils.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Administrator on 2022/7/28.
3 | //
4 |
5 | #ifndef DUMPER_FILEUTILS_H
6 | #define DUMPER_FILEUTILS_H
7 |
8 | #include
9 |
10 | using namespace std;
11 | class FileUtils {
12 | public:
13 | static string GetStringFromFile(const string& path);
14 | static string GetStringFromFile2(const string& path);
15 | static string GetConfigJson(const string path);
16 | static void writeLog (string log);
17 | };
18 |
19 |
20 | #endif //DUMPER_FILEUTILS_H
21 |
--------------------------------------------------------------------------------
/app/src/main/cpp/utils/ProcessRuntime.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by PC5000 on 2024/3/27.
3 | //
4 |
5 | #ifndef LINKERBRIDGE_PROCESSRUNTIME_H
6 | #define LINKERBRIDGE_PROCESSRUNTIME_H
7 |
8 | #include "vector"
9 | struct ElfModule{
10 | char path[1024];
11 | void* address;
12 | };
13 | static std::vector ElfModuleMap;
14 |
15 | class ProcessRuntime {
16 |
17 | public:
18 | static ElfModule GetTargetElfModule(const char* soName);
19 | static void GetCmdlineForPid(int pid, char *cmdlineBuffer, size_t bufferSize);
20 |
21 | };
22 |
23 |
24 | #endif //LINKERBRIDGE_PROCESSRUNTIME_H
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/linkerbridge/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.linkerbridge;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.TextView;
8 |
9 | import com.example.linkerbridge.databinding.ActivityMainBinding;
10 |
11 | public class MainActivity extends AppCompatActivity {
12 |
13 | // Used to load the 'linkerbridge' library on application startup.
14 | static {
15 | System.loadLibrary("imytest");
16 | }
17 |
18 | private ActivityMainBinding binding;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 |
24 | binding = ActivityMainBinding.inflate(getLayoutInflater());
25 | setContentView(binding.getRoot());
26 |
27 | binding.btn.setOnClickListener(new View.OnClickListener() {
28 | @Override
29 | public void onClick(View view) {
30 | loadSo2();
31 | }
32 | });
33 | // loadSo();
34 | }
35 |
36 | /**
37 | * A native method that is implemented by the 'linkerbridge' native library,
38 | * which is packaged with this application.
39 | */
40 | public native String stringFromJNI();
41 |
42 | public native void loadSo();
43 |
44 | public native void loadSo2();
45 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | linkerBridge
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/linkerbridge/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.linkerbridge;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | plugins {
3 | id 'com.android.application' version '8.2.2' apply false
4 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Enables namespacing of each library's R class so that its R class includes only the
19 | # resources declared in the library itself and none from the library's dependencies,
20 | # thereby reducing the size of the R class for that library
21 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IIIImmmyyy/ImyLinker/70be47efea2b83d864ddf7273b04f7093a8d6c0d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Mar 25 09:36:16 CST 2024
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 |
16 | rootProject.name = "linkerBridge"
17 | include ':app'
18 |
--------------------------------------------------------------------------------