Files
luma/Sources/LumaCore/Models/TracerTargetScope.swift
Ole André Vadla Ravnås 2d7cb2ed58 tracer: Support Java method hooks via the bridge
Add a javaMethod anchor kind and the matching java-method scope
so the tracer can target JVM methods. Resolution uses
Java.enumerateMethods through the bridge; attachment replaces
each method's implementation and restores it on detach.

The bridge isn't bundled into our agent, since only one copy
can live in a process at a time. Instead it's marked external
so frida-compile leaves the imports as runtime lookups, and our
agent does `await import("frida-java-bridge")` on demand. If
the user hasn't installed the package via the Packages panel,
we surface a message pointing them there.

To let frida-compile honour the external, LumaBundleCompiler
grew a --external <name> flag that forwards to
BuildOptions.externals. Both the Xcode Run Script phase and the
GTK Makefile now pass --package [email protected] (for
TypeScript types) alongside --external frida-java-bridge (so
the runtime code isn't embedded).

Java resolves to no native address, so ProcessNode.resolve and
the instruction annotation map throw / skip rather than trying
to materialise one. The seed code for new Java hooks matches
frida-tools' pattern: log args via JSON.stringify.
2026-04-16 14:33:59 +02:00

39 lines
1.4 KiB
Swift

public enum TracerTargetScope: String, CaseIterable, Codable, Sendable {
case function
case relativeFunction = "relative-function"
case absoluteInstruction = "absolute-instruction"
case imports
case module
case objcMethod = "objc-method"
case swiftFunc = "swift-func"
case javaMethod = "java-method"
case debugSymbol = "debug-symbol"
public var label: String {
switch self {
case .function: return "Function"
case .relativeFunction: return "Relative Function"
case .absoluteInstruction: return "Instruction"
case .imports: return "All Module Imports"
case .module: return "All Module Exports"
case .objcMethod: return "Objective-C Method"
case .swiftFunc: return "Swift Function"
case .javaMethod: return "Java Method"
case .debugSymbol: return "Debug Symbol"
}
}
public var placeholder: String {
switch self {
case .function: return "[Module!]Function"
case .relativeFunction: return "Module!Offset"
case .absoluteInstruction: return "0x1234"
case .imports, .module: return "Module"
case .objcMethod: return "-[*Auth foo:bar:], +[Foo foo*], or *[Bar baz]"
case .swiftFunc: return "*SomeModule*!SomeClassPrefix*.*secret*()"
case .javaMethod: return "com.example.*!*"
case .debugSymbol: return "Function"
}
}
}