SamboyCoding / Cpp2IL

Work-in-progress tool to reverse unity's IL2CPP toolchain.
MIT License
1.56k stars 178 forks source link

How to get il2cpp functions? #220

Closed feuerball11 closed 1 year ago

feuerball11 commented 1 year ago

Hi :-) I was previously using the JSON output from IL2CPPInspector, but as this project is deprecated, I need to think about what I will use going forward. While CPP2IL doesn't support JSON output, I could imagine adding that myself. However, what I currently don't see, is a way to get il2cpp functions like il2cpp_array_new il2cpp_value_box il2cpp_object_new

Which I currently need for my project. How would I get the pointers to these functions, with Cpp2IL?

For Context: I need these pointers for an Cpp dll injection project, that does runtime hooking to these pointers.

SamboyCoding commented 1 year ago

Those functions are just exported from the binary. you could simply iterate over the exports.

feuerball11 commented 1 year ago

So they would be part of LibCpp2IlGlobalMapper.MethodRefs ?

SamboyCoding commented 1 year ago

No.

feuerball11 commented 1 year ago

Can you give me a hint where I need to look then? Sry, I'm not that deep into how the whole il2cpp metadata works, so I have trouble finding it myself.

SamboyCoding commented 1 year ago

They're not in metadata. They're ordinary binary exports, unrelated to anything IL2CPP.

feuerball11 commented 1 year ago

Ah, now I understand. Is there anything in cpp2il already, that can parse the exports? If not, it looks like IL2CPPInpsector has some code for that, I guess I could just port that over.

lilmayofuksu commented 1 year ago

you can simply get their pointers with GetProcAddress

SamboyCoding commented 1 year ago

you can simply get their pointers with GetProcAddress

No you can't.

Is there anything in cpp2il already, that can parse the exports?

Exports are already parsed, Il2CppBinary base class has methods related to getting them by name.

feuerball11 commented 1 year ago

Awesome. That was the hint I needed. Thanks a lot :-) I can now try to write a JSON export, with the data I need.