Socket
Socket
Sign inDemoInstall

wtf.s1.pudge:thread-inspector-bhook

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wtf.s1.pudge:thread-inspector-bhook

thread native hook library


Version published
Maintainers
1
Source

android-thread-inspector

一个追踪 java 及 native 线程创建的 Flipper 插件

preview

集成

建议仅在仅在 Debug buildType 下集成该插件,用于调试。

添加依赖

debugImplementation "wtf.s1.pudge:thread-inspector-flipper:x.x.x"
debugImplementation "wtf.s1.pudge:thread-inspector-bhook:x.x.x"

在 src/debug/DebugApp.kt 中初始化

class DebugApp: App() {

    override fun onCreate() {
        super.onCreate()
        SoLoader.init(this, false)

        if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(this)) {
            val client = AndroidFlipperClient.getInstance(this)
            client.addPlugin(S1ThreadPlugin())
            client.start()
        }
    }

    override fun attachBaseContext(base: Context?) {
        ByteHook.init(
            ByteHook.ConfigBuilder()
                .setMode(ByteHook.Mode.AUTOMATIC)
                .setDebug(BuildConfig.DEBUG)
                .build()
        )
        S1ThreadHooker.hookThread()
        super.attachBaseContext(base)
    }
}

原理

使用了 bhookpthread_createpthread_setname_np函数进行 hook。

已知问题

  • java 线程 id 与 linux 线程 id 不一致,导致 hook 之前获取到的 java 线程会重复显示
  • 1.x 版本不提供 native 的堆栈信息

协议

MIT

感谢 bhookkoom 的贡献者

FAQs

Package last updated on 15 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc