Skip to content

Commit

Permalink
Add better il2cpp_array_size_t definition for script outputs in versi…
Browse files Browse the repository at this point in the history
…ons post 2017.2.1, fix some other cpp gen issues
  • Loading branch information
LukeFZ committed Dec 2, 2023
1 parent f1cb0d1 commit e9434f4
Show file tree
Hide file tree
Showing 6 changed files with 2,815 additions and 2,769 deletions.
4 changes: 2 additions & 2 deletions Il2CppInspector.Common/Cpp/CppDeclarationGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ private static CppNamespace CreateNamespace() {
}
/* Reserve commonly defined C++ symbols for MSVC DLL projects */
/* This is not an exhaustive list! (windows.h etc.) */
foreach (var symbol in new[] {"_int32", "DEFAULT_CHARSET", "FILETIME", "NULL", "SYSTEMTIME", "stderr", "stdin", "stdout"}) {
foreach (var symbol in new[] {"_int8", "_int16", "_int32", "_int64", "DEFAULT_CHARSET", "FILETIME", "NULL", "SYSTEMTIME", "stderr", "stdin", "stdout"}) {
ns.ReserveName(symbol);
}
/* Reserve builtin keywords in IDA */
Expand All @@ -586,7 +586,7 @@ private static CppNamespace CreateNamespace() {
"__ptr32", "__ptr64", "__pure", "__restrict", "__return_ptr", "__shifted", "__spoils", "__stdcall", "__struct_ptr",
"__thiscall", "__thread", "__unaligned", "__usercall", "__userpurge",
"_cs", "_ds", "_es", "_ss", "far", "flat", "near",
"Mask", "Region", "Pointer", "GC" }) {
"Mask", "Region", "Pointer", "GC", "Time" /* wtf? */ }) {
ns.ReserveName(keyword);
}
/* Reserve builtin keywords for Ghidra */
Expand Down
11 changes: 6 additions & 5 deletions Il2CppInspector.Common/Cpp/CppType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public override string ToString(string format = "") {

sb.Append(Name + (Name.Length > 0 ? " " : ""));

sb.Append("{");
sb.Append('{');
foreach (var field in Fields.Values.SelectMany(f => f)) {
var fieldString = field.ToString(format);
var suffix = ";";
Expand All @@ -399,18 +399,19 @@ public override string ToString(string format = "") {
suffix = "";
}

sb.Append("\n ");
foreach (var fieldStr in fieldString.Split('\n'))
var parts = fieldString.Split('\n');
foreach (var part in parts)
{
sb.Append(fieldStr);
sb.Append("\n ");
sb.Append(part);
}

sb.Append(suffix);
}

sb.Append($"\n}}{(format == "o"? $" /* Size: 0x{SizeBytes:x2} */" : "")};");

sb.Append("\n");
sb.Append('\n');
return sb.ToString();
}
}
Expand Down
Loading

0 comments on commit e9434f4

Please sign in to comment.