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

Function checkPointer

Il2cppHook/_Ufunc.js:8254–8344  ·  view source on GitHub ↗
(value, throwErr = false, showLog = false)

Source from the content-addressed store, hash-verified

8252Object.defineProperty(exports, "__esModule", { value: true });
8253exports.checkPointer = void 0;
8254const checkPointer = (value, throwErr = false, showLog = false) => {
8255 if (Il2Cpp.module.base.isNull())
8256 return ptr(value);
8257 if (Process.arch == 'arm64' && typeof value === "string" && value.trim().startsWith('0x'))
8258 value = Number(value);
8259 if (typeof value === "number") {
8260 return calPointer(ptr(value));
8261 }
8262 else if (typeof value === "string") {
8263 return Module.findExportByName(null, value);
8264 }
8265 else if (typeof value === "function") {
8266 return value;
8267 }
8268 else if (typeof value === "object") {
8269 if (value instanceof NativePointer) {
8270 return calPointer(value);
8271 }
8272 else if (value instanceof (Array)) {
8273 if (!checkValue(value)) {
8274 if (throwErr)
8275 throw new Error("checkPointer: checkValue Error");
8276 else
8277 return ptr(0);
8278 }
8279 switch (value.length) {
8280 case 1:
8281 return Module.findExportByName(null, value[0]);
8282 case 2:
8283 return Module.findExportByName(value[0], value[1]);
8284 case 3:
8285 return find_method(value[0], value[1], value[2], value[3]);
8286 default:
8287 if (throwErr)
8288 throw new Error("checkPointer:UnKnow value length \nArray<> length must be 1,2,3");
8289 else
8290 return ptr(0);
8291 }
8292 }
8293 else {
8294 if (throwErr)
8295 throw new Error("checkPointer: Error type");
8296 else
8297 return ptr(0);
8298 }
8299 }
8300 return ptr(0);
8301 function calPointer(mPtr) {
8302 if (mPtr.isNull() || !mPtr.compare(soAddr))
8303 return mPtr;
8304 try {
8305 let tmpValue = Process.findModuleByAddress(mPtr);
8306 if (tmpValue === null) {
8307 let addValue = Il2Cpp.module.base.add(mPtr);
8308 let tmpModule = Process.findModuleByAddress(addValue);
8309 if (tmpModule === null) {
8310 if (throwErr)
8311 throw new Error("checkPointer: can't find module");

Callers 9

BreakerClass · 0.70
_Ufunc.jsFile · 0.70
constructorMethod · 0.70
setFunctionValueFunction · 0.70
attachNativeFunction · 0.70
cancelNopFunction · 0.70
detachAllFunction · 0.70
replaceFunctionFunction · 0.70
printCtxFunction · 0.70

Calls 3

isNullMethod · 0.80
calPointerFunction · 0.70
checkValueFunction · 0.70

Tested by

no test coverage detected