MCPcopy Create free account
hub / github.com/sensepost/objection / getClassMethodsOverloads

Function getClassMethodsOverloads

agent/src/android/hooking.ts:210–256  ·  view source on GitHub ↗
(className: string,
  methodsAllowList: string[] = [], loader?: string)

Source from the content-addressed store, hash-verified

208};
209
210export const getClassMethodsOverloads = (className: string,
211 methodsAllowList: string[] = [], loader?: string): Promise<JavaMethodsOverloadsResult> => {
212
213 return wrapJavaPerform(() => {
214 const result: JavaMethodsOverloadsResult = {};
215 const clazz = loader !== null ? getClassHandleWithLoaderClassName(className, loader) : Java.use(className);
216
217 if (clazz === null) {
218 throw new Error("Could not find class!");
219 }
220
221 // TODO(cduplooy): The below line can fail with Error: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/datastore/core/DataStore;
222 // This seems to involve custom class loaders...
223 const methods = clazz.class.getDeclaredMethods()
224 .map(method => genericMethodNameToMethodOnly(method.toGenericString()));
225 methods.forEach(methodName => {
226 if (methodsAllowList.length === 0 || (methodsAllowList.length > 0 && methodsAllowList.includes(methodName))) {
227 const overloads = clazz[methodName].overloads;
228 result[methodName] = {
229 'argTypes': overloads.map(overload => overload.argumentTypes),
230 'returnType': overloads.map(overload => overload.returnType),
231 'methodName': overloads.map(overload => overload.methodName),
232 'handle': overloads.map(overload => overload.handle),
233 'holder': overloads.map(overload => overload.holder),
234 'type': overloads.map(overload => overload.type),
235 };
236 }
237 });
238
239 // Finally append the constructor details
240 if (clazz.class.getConstructors().length > 0) {
241 if (methodsAllowList.length === 0 || (methodsAllowList.length > 0 && methodsAllowList.includes("$init"))) {
242 const overloads = clazz['$init'].overloads;
243 result['$init'] = {
244 'argTypes': overloads.map(overload => overload.argumentTypes),
245 'returnType': overloads.map(overload => overload.returnType),
246 'methodName': overloads.map(overload => overload.methodName),
247 'handle': overloads.map(overload => overload.handle),
248 'holder': overloads.map(overload => overload.holder),
249 'type': overloads.map(overload => overload.type),
250 };
251 }
252 }
253
254 return result;
255 });
256};
257
258export const watch = (pattern: string, dargs: boolean, dbt: boolean, dret: boolean): Promise<void> => {
259

Callers

nothing calls this directly

Calls 3

wrapJavaPerformFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…