Commit Graph

104 Commits

Author SHA1 Message Date
Katy Coe
c6175989cf C++: Add #pragma to disable MSVC C4309 enum truncation warnings 2020-08-01 03:35:07 +02:00
Katy Coe
0bfc5750ad IDA: Abstract idc.set_cmt into SetComment 2020-07-29 01:34:36 +02:00
Katy Coe
7b9c28fdf3 IDA: Don't produce C type header file if it's already available 2020-07-28 19:23:53 +02:00
Katy Coe
4978348d8f C++/IDA: Output text files as ASCII instead of UTF8 (Ghidra fix) 2020-07-28 04:13:43 +02:00
Katy Coe
867ddea168 IDA: Separate type declarations into own header file 2020-07-28 02:40:47 +02:00
Katy Coe
7fa80a4848 C++: Allow il2cpp-types.h to be output independently; include conditional disassembler pre-amble 2020-07-28 02:26:15 +02:00
Katy Coe
59f5083235 C++: Add #pragma to disable MSVC C4369 enum range warnings 2020-07-25 16:55:40 +02:00
Katy Coe
44a5fe009a C++: Output il2cpp-api-functions.h with unavailable exports elided 2020-07-24 17:20:37 +02:00
Katy Coe
deeb8daa97 Unity/C++: Significant re-factoring of Unity header management (see description)
Extract resource handling to UnityResource
Add API header resource helpers
Fix UnityVersion ToString() when Min == Max
Replace fixed list of Il2Cpp header reserved names with parsed names from actual selected headers (solves TypeInfo/MemberInfo problems in 5.3.0-5.3.4 (metadata v16-20))
Use CppDeclarationGenerator when initializing CppTypeCollection to ensure all Il2Cpp header symbols are reserved
Process API headers in CppTypeCollection.FromUnityHeaders
Move #define IS_32BIT handling to UnityHeaders
Update tests
2020-07-22 19:01:33 +02:00
Katy Coe
2f3b0d7276 AppModel/IDA: Typed MethodInvokers for 5.3.0-5.6.7 don't use Il2CppMethodPointer 2020-07-20 22:48:40 +02:00
Katy Coe
ccb401bb12 IL2CPP: Add Binary.GetAPIExports() 2020-07-20 17:09:19 +02:00
Katy Coe
386a666fff C++: Output DLL injection boilerplate project 2020-07-19 15:44:26 +02:00
Katy Coe
f7d2dd6e2d C++: Output method pointers and signatures 2020-07-18 21:47:33 +02:00
Katy Coe
6d50ab7546 C++: Output Il2CppClass* (TypeInfo) pointers 2020-07-18 21:23:23 +02:00
Katy Coe
7124149fef C++: Output IL2CPP API function pointers 2020-07-18 19:47:45 +02:00
Katy Coe
632d1d2d9b C++: Generate output in a folder 2020-07-18 19:18:08 +02:00
Katy Coe
f5e5037a9b AppModel: Add AppType.Name 2020-07-18 03:54:54 +02:00
Katy Coe
307cf29dcd C++: Re-factor custom attribute generator signature handling 2020-07-18 03:33:33 +02:00
Katy Coe
d1501db903 IDA: Produced typed RuntimeInvoker methods 2020-07-17 04:29:38 +02:00
Katy Coe
fc313de0b2 IDA: Produce typed CustomAttributesCacheGenerator methods 2020-07-17 03:23:15 +02:00
Katy Coe
8bcdadd7b4 IDA: Tidy up output ordering and titling 2020-07-16 14:43:04 +02:00
Katy Coe
0808fe966a AppModel: IDA output integration; item groups 2020-07-16 12:37:39 +02:00
Katy Coe
6e796a200f AppModel: Generate composite type mappings 2020-07-13 19:52:04 +02:00
Katy Coe
20d0ffcdfe AppModel: Move C++ type ordering to model 2020-07-13 17:55:32 +02:00
Katy Coe
873a6c98f6 AppModel: First iteration of ApplicationModel API
Integrate with C++ scaffolding
Add new tests
Rename Il2CppModel to TypeModel
Incomplete IDAPython integration
CLI and GUI support
Update README.md
2020-07-09 03:48:50 +02:00
Katy Coe
117a440b58 Outputs: Fix C++ output crash for il2cpp versions <19 2020-07-02 20:08:53 +02:00
Katy Coe
24e4c65c4c Outputs: Add MSVC/GCC option to CppScaffolding and CLI 2020-07-02 15:18:15 +02:00
Katy Coe
c59245ec56 Outputs: Add C++ output module 2020-07-02 14:21:40 +02:00
Katy Coe
23db04c369 Minor re-organization 2020-06-30 00:13:18 +02:00
Robert Xiao
9e455fdabe Renaming for clarity.
Renamed the class CppDeclarations => CppDeclarationGenerator to better reflect
its function and emphasize its statefulness.

Renamed Visit{Type,Method} => Include{Type,Method} to clarify that these methods
include the type or method into the generator state.

Renamed GenerateVisitedTypes => GenerateRemainingTypeDeclarations to clarify
that it outputs *remaining* declarations, i.e. declarations that haven't been
generated yet.
2020-06-29 22:10:45 +02:00
Robert Xiao
393d26b2a3 Move non-output to new CppUtils namespace
We prefer to have the Outputs directory contain just one file or
namespace per output module, so we'll move all C++-related stuff to a
new CppUtils namespace instead.
2020-06-29 22:10:45 +02:00
Robert Xiao
de6d9e2230 Move duplicated sanitizeIdentifier to Extensions
Also ensure that the identifier always starts with an underscore or
letter, which fixes issues with obfuscated identifiers.
2020-06-29 22:10:45 +02:00
Robert Xiao
95ee085374 Comments and minor refactoring into lambdas 2020-06-29 22:10:45 +02:00
Robert Xiao
3ccbab2461 Add/modify copyright notices 2020-06-29 22:10:45 +02:00
Robert Xiao
b7c93ffcc7 Type string literals as System.String 2020-06-29 22:10:45 +02:00
Robert Xiao
67acd18c03 Finish types implementation: vtables and classes.
Also fix a few minor bugs involving arrays and enums. Both should not
have __Class structures generated.
2020-06-29 22:10:45 +02:00
Robert Xiao
930202dfdd Handle idc.SetType return value correctly.
Apparently, idc.SetType returns True if the type is set for the first
time, False if the type is updated, and None if the type couldn't be set
(rather differently from what the documentation says).
2020-06-29 22:10:45 +02:00
Robert Xiao
75744a31dc First whack at type structs for IDA.
This commit only includes instance field structs, not class
structs/vtables/static fields.
2020-06-29 22:10:45 +02:00
Robert Xiao
caa7eaf870 Improve MetadataUsages and add types for globals
- Add string contents to names of StringLiteral objects to improve
decompilation output
- Add string constants for metadata version < 19 via an enum (if you can
identify and type il2cpp_codegen_string_literal_from_index correctly,
all enums resolve nicely to their string contents)
- Add types to metadata usages and globals
- Send method definitions & method references through writeMethods
for consistency
2020-06-29 22:10:45 +02:00
Robert Xiao
359b99fded Automatically infer function ends in IDA.
The problem with using an end param in IDA is that IDA will quite
stupidly treat the function end as gospel even if it makes no sense
(e.g. a single "function" spanning many MB because there are no symbols
in between). Leaving out end, on the other hand, tells IDA there's a
function at a given starting address but lets IDA figure out the end by
itself, which it usually does correctly.
2020-06-29 22:10:45 +02:00
Robert Xiao
34f0d4ceef Add header files for every known Unity version.
We want to get types into the IDA output, and to do that we need
accurate types for the Il2Cpp structures. Unfortunately, some crucial
types like Il2CppClass change between versions without any corresponding
metadata changes, meaning that we have to manually identify the version
outside of the Inspector somehow (e.g. by looking at the version number
embedded in Unity asset files). This patch adds header files for *every*
known Unity version from 5.3.0 to 2019.3.8, merging them into version
ranges where header files don't change.

It also adds front-end support for supplying the version number in both
the CLI and GUI. The GUI is given the ability to guess the version
number approximately to reduce the number of choices presented to the
user.
2020-06-29 22:10:45 +02:00
Katy Coe
181d3ad600 CS: Don't output redundant interfaces in type declarations 2020-06-22 22:56:26 +02:00
Katy Coe
ef22c6628b CS: Fix enumeration scoping on default field values (CS0103) 2020-06-22 18:38:16 +02:00
Katy Coe
ca113fb055 CLI: Handle attempted output to directory that is file gracefully 2020-06-20 19:34:34 +02:00
Robert Xiao
6ddb502e96 Refactor TypeInfo names and fix out/in
Replace the deeply nested ternaries in TypeInfo with if-statements for
clarity.
Remove in/out from CSharpName, keeping it only on immediate type params
in CSharpTypeDeclarationName (refactored to a method).
Rearrange name-related properties and methods to group them all together
into a region for easier navigation.
2020-06-20 10:17:48 +02:00
Robert Xiao
5224429b0a Fix {{ typo in CSharpCodeStubs 2020-06-17 08:18:15 +02:00
Robert Xiao
7fce43aba0 Fix IDA writeUsages for metadata <19
This fixes a NullReferenceException that was being thrown for IDA script
generation for metadata 16 files (e.g. as generated by Il2Cpp v5.3.0f4).
2020-06-16 23:30:53 +02:00
Callie LeFave
dee6c45056 Fix CSharp output paths on POSIX filesystems 2020-06-16 12:25:10 +02:00
Katy Coe
40ab603c56 C#: Don't output field offsets for open generic types 2020-02-28 11:01:38 +01:00
Katy Coe
168c955558 C#: Set static and instance constructor defaults correctly (CS0120) 2020-02-24 12:24:04 +01:00