{"id":13482727,"url":"https://github.com/PAGalaxyLab/YAHFA","last_synced_at":"2025-03-27T13:32:32.981Z","repository":{"id":41168880,"uuid":"86668534","full_name":"PAGalaxyLab/YAHFA","owner":"PAGalaxyLab","description":"Yet Another Hook Framework for ART","archived":false,"fork":false,"pushed_at":"2024-07-22T23:50:28.000Z","size":365,"stargazers_count":1560,"open_issues_count":51,"forks_count":351,"subscribers_count":74,"default_branch":"master","last_synced_at":"2024-10-30T16:41:09.838Z","etag":null,"topics":["android","hook","hook-framework"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PAGalaxyLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-30T06:45:05.000Z","updated_at":"2024-10-29T09:53:39.000Z","dependencies_parsed_at":"2024-10-30T16:41:47.404Z","dependency_job_id":null,"html_url":"https://github.com/PAGalaxyLab/YAHFA","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PAGalaxyLab%2FYAHFA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PAGalaxyLab%2FYAHFA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PAGalaxyLab%2FYAHFA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PAGalaxyLab%2FYAHFA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PAGalaxyLab","download_url":"https://codeload.github.com/PAGalaxyLab/YAHFA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245854610,"owners_count":20683389,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","hook","hook-framework"],"created_at":"2024-07-31T17:01:04.969Z","updated_at":"2025-03-27T13:32:32.598Z","avatar_url":"https://github.com/PAGalaxyLab.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"YAHFA\n----------------\n\n[![Build Status](https://github.com/PAGalaxyLab/YAHFA/workflows/Android%20CI/badge.svg)](https://github.com/PAGalaxyLab/YAHFA/actions)\n[![Download](https://badgen.net/github/release/PAGalaxyLab/YAHFA)](https://github.com/PAGalaxyLab/YAHFA/releases/latest/download/library-release.aar)\n[![Maven](https://badgen.net/maven/v/maven-central/io.github.pagalaxylab/yahfa)](https://repo1.maven.org/maven2/io/github/pagalaxylab/yahfa/)\n\n## Introduction\n\nYAHFA is a hook framework for Android ART. It provides an efficient way for Java method hooking or replacement. Currently it supports:\n\n- ~~Android 5.0(API 21)~~\n- ~~Android 5.1(API 22)~~\n- ~~Android 6.0(API 23)~~\n- Android 7.0(API 24)\n- Android 7.1(API 25)\n- Android 8.0(API 26)\n- Android 8.1(API 27)\n- Android 9(API 28)\n- Android 10(API 29)\n- Android 11(API 30)\n- Android 12(DP1)\n\n(Support for version \u003c= 6.0 is broken after commit [9824bdd](https://github.com/PAGalaxyLab/YAHFA/commit/9824bdd9d958fd0eca43537b6288bb04da191036).)\n\nwith ABI:\n\n- x86\n- x86_64\n- armeabi-v7a\n- arm64-v8a\n\nYAHFA is utilized by [VirtualHook](https://github.com/rk700/VirtualHook) so that applications can be hooked without root permission.\n\nPlease take a look at this [article](http://rk700.github.io/2017/03/30/YAHFA-introduction/) and this [one](http://rk700.github.io/2017/06/30/hook-on-android-n/) for a detailed introduction.\n\n[更新说明](https://github.com/rk700/YAHFA/wiki/%E6%9B%B4%E6%96%B0%E8%AF%B4%E6%98%8E)\n\n## Setup\n\nAdd Maven central repo in `build.gradle`:\n\n```\nbuildscript {\n    repositories {\n        mavenCentral()\n    }\n}\n\nallprojects {\n    repositories {\n        mavenCentral()\n    }\n}\n```\n\nThen add YAHFA as a dependency:\n\n```\ndependencies {\n    implementation 'io.github.pagalaxylab:yahfa:0.10.0'\n}\n```\n\nYAHFA depends on [dlfunc](https://github.com/rk700/dlfunc) after commit [5b60df8](https://github.com/PAGalaxyLab/YAHFA/commit/5b60df8af85fab2b4901cf881c7e9362010c0472) for calling `MakeInitializedClassesVisiblyInitialized` explicitly on Android R, and Android Gradle Plugin version 4.1+ is required for that native library dependency.\n\n## Usage\n\nTo hook a method:\n\n```java\nHookMain.backupAndHook(Method target, Method hook, Method backup);\n```\n\nwhere `backup` would be a placeholder for invoking the target method. Set `backup` to null or just use `HookMain.hook(Method target, Method hook)` if the original code is not needed.\n\nBoth `hook` and `backup` are static methods, and their parameters should match the ones of `target`. Please take a look at [demoPlugin](https://github.com/rk700/YAHFA/tree/master/demoPlugin) on how these methods are defined.\n\n## Workaround for Method Inlining\n\nHooking would fail for methods that are compiled to be inlined. For example:\n\n```\n0x00004d5a: f24a7e81  movw    lr, #42881\n0x00004d5e: f2c73e11  movt    lr, #29457\n0x00004d62: f6495040  movw    r0, #40256\n0x00004d66: f2c70033  movt    r0, #28723\n0x00004d6a: 4641      mov     r1, r8\n0x00004d6c: 1c32      mov     r2, r6\n0x00004d6e: 47f0      blx     lr\n```\n\nHere the value of register `lr` is hardcoded instead of reading from entry point field of `ArtMethod`.\n\nA simple workaround is to build the APP with debuggable option on, in which case the inlining optimization will not apply. However the option `--debuggable` of `dex2oat` is not available until API 23. So please take a look at machine instructions of the target when the hook doesn't work.\n\n## License\n\nYAHFA is distributed under GNU GPL V3.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPAGalaxyLab%2FYAHFA","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPAGalaxyLab%2FYAHFA","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPAGalaxyLab%2FYAHFA/lists"}