MCPcopy Create free account
hub / github.com/deathmemory/FridaContainer / traceJavaMethodsCore

Function traceJavaMethodsCore

utils/FCAnd.ts:490–583  ·  view source on GitHub ↗
(clsname: string)

Source from the content-addressed store, hash-verified

488 }
489
490 function traceJavaMethodsCore(clsname: string) {
491 const tag = 'traceJavaMethodsCore';
492 let detail: { methods: string | any[]; white: boolean; } | null = null;
493 if (null != clsWhitelist) {
494 detail = clsWhitelist[clsname];
495 }
496 let cls = Java.use(clsname);
497 let methods = cls.class.getDeclaredMethods();
498 DMLog.i(tag, 'trace cls: ' + clsname + ', method size: ' + methods.length);
499 methods.forEach(function (method: any) {
500 let methodName = method.getName();
501 // DMLog.i('traceJavaMethodsCore.methodname', methodName);
502 if (null != detail && typeof (detail) == 'object') {
503 if ((detail.methods.indexOf(methodName) > -1) != detail.white) {
504 return true; // next forEach
505 }
506 }
507
508 if ('invoke' == methodName) {
509 return true; // 跳过并继续执行下一个 forEach
510 }
511 let methodOverloads = cls[methodName].overloads;
512 if (null != methodOverloads) {
513 methodOverloads.forEach(function (overload: any) {
514 try {
515 let methodDesc = getMethodDescription(clsname, overload);
516 DMLog.i(tag, 'hookmethod: ' + methodDesc);
517 overload.implementation = function () {
518 let tid = Process.getCurrentThreadId();
519 let tname = Java.use("java.lang.Thread").currentThread().getName();
520 sendContent({
521 tid: tid,
522 status: 'entry',
523 tname: tname,
524 classname: clsname,
525 method: methodDesc,
526 args: arguments
527 });
528
529 let retval = overload.apply(this, arguments);
530
531 sendContent({
532 tid: tid,
533 status: 'exit',
534 tname: tname,
535 classname: clsname,
536 method: methodDesc,
537 retval: retval
538 });
539 return retval;
540 }
541 }
542 catch (e: any) {
543 DMLog.d(tag, 'overload.implementation exception:\t' + overload.methodName + "\t" + e.toString());
544 }
545 });
546 }
547 })

Callers 1

traceJavaMethods_customFunction · 0.85

Calls 5

getMethodDescriptionFunction · 0.85
sendContentFunction · 0.85
iMethod · 0.80
dMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected