vfsfitvnm / frida-il2cpp-bridge

A Frida module to dump, trace or hijack any Il2Cpp application at runtime, without needing the global-metadata.dat file.
https://github.com/vfsfitvnm/frida-il2cpp-bridge/wiki
MIT License
974 stars 199 forks source link

Writing log while tracing from app #250

Closed thienha1 closed 1 year ago

thienha1 commented 1 year ago

Like this:

0x01a2f3e4 ┌─System.String.Concat(str0 = "Creating AndroidJavaClass from ", str1 = "com.unity3d.player.UnityPlayer");
0x01a3cfbc │ ┌─System.String.FastAllocateString(length = 61);
0x01a3cfbc │ └─System.String.FastAllocateString = "Creating AndroidJavaClass from com.unity3d.player.UnityPlayer";
0x01a3f118 │ ┌─System.String.FillStringChecked(dest = "Creating AndroidJavaClass from com.unity3d.player.UnityPlayer", destPos = 0, src = "Creating AndroidJavaClass from ");
0x01a3f118 │ └─System.String.FillStringChecked;
0x01a3f118 │ ┌─System.String.FillStringChecked(dest = "Creating AndroidJavaClass from com.unity3d.player.UnityPlayer", destPos = 31, src = "com.unity3d.player.UnityPlayer");
0x01a3f118 │ └─System.String.FillStringChecked;
0x01a2f3e4 └─System.String.Concat = "Creating AndroidJavaClass from com.unity3d.player.UnityPlayer";

0x01a41f60 ┌─System.String.Replace(this = com.unity3d.player.UnityPlayer, oldChar = 46, newChar = 47);
0x01a4346c │ ┌─System.String.IndexOfUnchecked(this = com.unity3d.player.UnityPlayer, value = 46, startIndex = 0, count = 30);
0x01a4346c │ └─System.String.IndexOfUnchecked = 3;
0x01a3cfbc │ ┌─System.String.FastAllocateString(length = 30);
0x01a3cfbc │ └─System.String.FastAllocateString = "com/unity3d/player/UnityPlayer";
0x01a41f60 └─System.String.Replace = "com/unity3d/player/UnityPlayer";

Convert to Untitled It will save my time and no need scroll up in command prompt anymore!! Can you help me do this?

vfsfitvnm commented 1 year ago

On Linux you can redirect the output to a file:

frida -p stuff -f etc > trace.log

Alternatively, you can override the global console.log function so it writes to a file instead (take a look at https://frida.re/docs/javascript-api/#file)

berkedel commented 1 year ago

You can override the global console.log below

(globalThis as any).console.log = function (...msg: [string]) {
  const fd = new File(Il2Cpp.applicationDataPath + "/tracer.log", "a")
  const content = msg.join(" ")
  try {
    fd.write(content)
  } finally {
    fd.close()
  }
}
350030173 commented 1 year ago

use cmder on windows