You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What i would like to know is how can i read for example here the MemoryStream of the argument.
This code is just an example (and wrong) what i tried but cannot get it working.
Would be happy if someone could tell me how to hook a specific function
and the function has one argument "m = System.IO.MemoryStream"
and i want to read the bytes of it.
Il2Cpp.perform(()=>{console.log("Unity Version: "+Il2Cpp.unityVersion);// Trace all methods in Assembly-CSharp containing "serialize" in the namevartrace=Il2Cpp.trace(true).assemblies(Il2Cpp.domain.assembly("Assembly-CSharp")).filterClasses(clazz=>clazz.name.toLowerCase().includes("player")).filterMethods(method=>method.name.toLowerCase().includes("position")).and().attach();// Hook each serialize methodtrace.on('enter',function(args){// Check if any of the arguments are an instance of MemoryStreamfor(leti=0;i<this.method.parameterCount;i++){constparamType=this.method.parameterType(i);if(paramType.name.includes("MemoryStream")){constmemoryStream=newIl2Cpp.Object(args[i]);console.log("MemoryStream passed to "+this.method.name);// Read the internal buffer of MemoryStream (using internal fields/methods)constbuffer=memoryStream.field("internalBuffer").value;constposition=memoryStream.field("position").value;constlength=memoryStream.field("length").value;console.log(`MemoryStream internal buffer at position ${position}, length ${length}`);// Optionally, read the buffer dataconstbufferContent=buffer.readByteArray(length);console.log("Buffer Content (in bytes):");// Print the buffer content as a hex stringlethexString="";for(leti=0;i<bufferContent.length;i++){hexString+=bufferContent[i].toString(16).padStart(2,'0')+" ";}console.log(hexString);break;// Stop once MemoryStream is found}}});trace.on('leave',function(retval){console.log("Method "+this.method.name+" finished.");});});
Thank you
The text was updated successfully, but these errors were encountered:
Ezriral
changed the title
Arguments Values
Read Argument Values
Nov 9, 2024
Il2Cpp.Tracer is designed to quickly trace the invocation of a bulk of methods. Currently, it's not possible to pass a custom printer for a certain Il2Cpp.Type (but this could be a nice to have feature!).
If know in advance the method you want to hook, you should override the implementation of the specific method you want to hook and supply the logic to dump the MemoryStream.
What i would like to know is how can i read for example here the MemoryStream of the argument.
This code is just an example (and wrong) what i tried but cannot get it working.
Would be happy if someone could tell me how to hook a specific function
and the function has one argument "m = System.IO.MemoryStream"
and i want to read the bytes of it.
Thank you
The text was updated successfully, but these errors were encountered: