#!/usr/bin/env python3
"""列出Frida exports中所有可用的方法名"""
import frida
import time

device = frida.get_device_manager().add_remote_device("192.168.0.12:27042")
session = device.attach(7239)

with open("/Users/karuo/Documents/GitHub/workphone-sdk/sdk/agent/hook/wechat_hook_v2.js", "r") as f:
    src = f.read()

script = session.create_script(src)
script.on("message", lambda m, d: None)
script.load()
time.sleep(2)

exports = script.exports_sync
methods = [x for x in dir(exports) if not x.startswith("_")]
print(f"Total methods: {len(methods)}")
print("---")
for m in sorted(methods):
    print(m)

# 测试ping
print("---")
print(f"ping() = {exports.ping()}")

# 测试几个方法名格式
test_names = ["getConnectionStatus", "getconnectionstatus", "get_connection_status",
              "getProcessInfo", "getprocessinfo", "get_process_info",
              "takeScreenshot", "takescreenshot", "take_screenshot"]
print("---")
for name in test_names:
    fn = getattr(exports, name, None)
    print(f"  {name}: {'EXISTS' if fn else 'NOT FOUND'}")

script.unload()
session.detach()
