MCPcopy
hub / github.com/APKLab/APKLab / parseMethodFromLine

Function parseMethodFromLine

src/tools/frida.ts:88–112  ·  view source on GitHub ↗

* Parse a .method directive line and class context into SmaliMethod.

(
    line: string,
    className: string,
)

Source from the content-addressed store, hash-verified

86 * Parse a .method directive line and class context into SmaliMethod.
87 */
88function parseMethodFromLine(
89 line: string,
90 className: string,
91): SmaliMethod | null {
92 // .method public static foo(ILjava/lang/String;)V
93 const match = line.match(
94 /\.method\s+(?:(?:public|private|protected|static|final|synthetic|bridge|varargs|declared-synchronized|abstract|native|strictfp|constructor)\s+)*(\S+)\(([^)]*)\)(\S+)/,
95 );
96 if (!match) return null;
97
98 const methodName = match[1];
99 const paramStr = match[2];
100 const returnType = match[3];
101 const isStatic = /\bstatic\b/.test(line);
102 const isConstructor = methodName === "<init>" || methodName === "<clinit>";
103
104 return {
105 className: smaliTypeToJava("L" + className + ";"),
106 methodName,
107 paramTypes: parseSmaliParams(paramStr),
108 returnType,
109 isStatic,
110 isConstructor,
111 };
112}
113
114/**
115 * Get the class name from the .class directive in the document.

Callers 2

generateHookFunction · 0.85
frida.test.tsFile · 0.85

Calls 2

smaliTypeToJavaFunction · 0.85
parseSmaliParamsFunction · 0.85

Tested by

no test coverage detected