Closed sinyo1015 closed 2 years ago
Yes, you can create a System.Exception
(or whatever is called) object and then call its method (can't remember if it's static or not) to throw it.
Alternatively, there's also a il2cpp export (e.g. il2cpp_exception_throw
).
How do I call it without return/throw keyword? Or is it possible just to invoke as normal method from exception class? Could you give some example to do it?
Or is it possible just to invoke as normal method from exception class
static System.Void ReportUnhandledException(System.Exception exception);
Or is it possible just to invoke as normal method from exception class
static System.Void ReportUnhandledException(System.Exception exception);
I cant find this method
Well, it depends on the unity version you are using. Just print the System.Exception
class you will probably find one. You can dump the application and look for methods such as static System\.Void \w+\(System\.Exception \w+\)\;
as well
first , i called Il2Cpp.installExceptionListener('all')
to catch the exception happened in il2cpp thread
as the above shown , the expception can be catched via hook the __ctx_thrown
when we hook a function or replace a function , then we want to know who called the function , we need to backtrace , but frida's api backtrace can not provide so much detail infomation , so i hava an idea
first , implement this function , once called the function , it create an exception , then throw this exception , so the detail backtrace can generate ?
some example below
Il2Cpp.Domain.assembly("Assembly-CSharp").image.class("XXX").method("XXX").implementation = function (message) {
var il2cpp_raise_exception = new NativeFunction(Module.getExportByName(null , 'il2cpp_raise_exception') , 'void' , ['pointer'])
// var systemException = Il2Cpp.Image.corlib.class("System.Exception").new()
var exp = Il2Cpp.Domain.assembly("Assembly-CSharp").image.class("LitJson.JsonException").new()
Il2Cpp.installExceptionListener('all')
il2cpp_raise_exception(exp)
}
but only output this , don't cantain any infomation like backtrace .
the idea like java self backtrace
i wonder is there a way to implement this function like java backtrace ?
I had the same idea few months ago, so I tried implementing it but I couldn't make it for the same reason you pointed out.
Code you might find helpful: https://github.com/vfsfitvnm/frida-il2cpp-bridge/commit/78fd8ef78fc289458514899fa25fc39a5764718d
Is there any way to emulate throwing an exception inside method implementation?
Because I need the backtrace methods to determine which methods get called and the game itself send back the backtrace into the game server.
Thanks!