MCPcopy Create free account
hub / github.com/axhlzy/Il2CppHookScripts / replaceFunction

Function replaceFunction

Il2cppHook/_Ufunc.js:8481–8498  ·  view source on GitHub ↗
(mPtr, callBack, TYPENOP = true)

Source from the content-addressed store, hash-verified

8479};
8480exports.detachAll = detachAll;
8481function replaceFunction(mPtr, callBack, TYPENOP = true) {
8482 if (typeof mPtr == "number")
8483 mPtr = ptr(mPtr);
8484 let src_ptr = mPtr;
8485 mPtr = checkPointer(mPtr);
8486 if (String(arr_nop_addr).indexOf(String(mPtr)) == -1) {
8487 arr_nop_addr.push(String(mPtr));
8488 }
8489 else {
8490 Interceptor.revert(mPtr);
8491 }
8492 let srcFunc = new NativeFunction(mPtr, 'pointer', ['pointer', 'pointer', 'pointer', 'pointer']);
8493 Interceptor.replace(mPtr, new NativeCallback((arg0, arg1, arg2, arg3) => {
8494 LOGW("\nCalled " + (TYPENOP ? "Replaced" : "Nop") + " function ---> " + mPtr + " (" + src_ptr.sub(Il2Cpp.module.base) + ")");
8495 let ret = callBack(srcFunc, arg0, arg1, arg2, arg3);
8496 return ret == null ? ptr(0) : ret;
8497 }, 'pointer', ['pointer', 'pointer', 'pointer', 'pointer']));
8498}
8499exports.replaceFunction = replaceFunction;
8500const getFunctionAddrFromCls = (clsptr, funcName) => {
8501 if (typeof clsptr == "string")

Callers 1

nopFunctionFunction · 0.70

Calls 3

revertMethod · 0.80
checkPointerFunction · 0.70
LOGWFunction · 0.70

Tested by

no test coverage detected