I used the following program to get Unity's console output:
function LogHook(): void {
const UnityEngine_Application = UnityEngineCoreModule.class('UnityEngine.Application');
const CallLogCallback = UnityEngine_Application.method('CallLogCallback');
const UnityEngine_LogType = UnityEngineCoreModule.class('UnityEngine.LogType')
Interceptor.attach(Il2CppUtil.getFunctionByAddress(Il2Cpp.module, CallLogCallback.relativeVirtualAddress), {
onEnter: args => {
let name = Il2CppUtil.getEnumName(args[3].toInt32(), UnityEngine_LogType);
let color = 'm';
switch (name) {
case 'Error':
color = '31m';
break;
case 'Assert':
color = '36m';
break;
case 'Warning':
color = '33m';
break;
case 'Log':
color = '34m';
break;
case 'Exception':
color = '31;43m';
break;
}
Logger.log('[1;' + color + '<' + name + '> from Unity' + ':\n' + Il2CppUtil.readCSharpString(args[1])?.replace(/<\/*color.*?>/g, '') + '[m\n ' + '[1;30m' + Il2CppUtil.readCSharpString(args[2])?.replace(/\n/g, '\n ') + '[m');
}
});
}
It works fine when errors are not generated by frida calling C# functions, like this:
But when a function called by frida and produce fault, does not show the error output, such as call DeserializeObject method of the class Newtonsoft.Json.JsonConvert , if a Json deserialization error occurred, The console hook code above is not called, so you can't see the detailed C# layer error message. It looks like:
Is there any way to make the frida call function display log information as well?
I used the following program to get Unity's console output:
It works fine when errors are not generated by frida calling C# functions, like this:![IMG_20230329_113827.png](https://user-images.githubusercontent.com/65601588/228423502-b3b923d3-babb-435b-b0ad-b51cac4dbf6f.png)
But when a function called by frida and produce fault, does not show the error output, such as call DeserializeObject method of the class Newtonsoft.Json.JsonConvert , if a Json deserialization error occurred, The console hook code above is not called, so you can't see the detailed C# layer error message. It looks like:
Is there any way to make the frida call function display log information as well?