C++: Add MethodInfo to scaffolding output (#84)
This commit is contained in:
@@ -173,12 +173,19 @@ typedef size_t uintptr_t;
|
|||||||
writeCode("using namespace app;");
|
writeCode("using namespace app;");
|
||||||
writeLine("");
|
writeLine("");
|
||||||
|
|
||||||
foreach (var method in model.Methods.Values.Where(m => m.HasCompiledCode)) {
|
foreach (var method in model.Methods.Values) {
|
||||||
|
if (method.HasCompiledCode) {
|
||||||
var arguments = string.Join(", ", method.CppFnPtrType.Arguments.Select(a => a.Type.Name + " " + (a.Name == "this" ? "__this" : a.Name)));
|
var arguments = string.Join(", ", method.CppFnPtrType.Arguments.Select(a => a.Type.Name + " " + (a.Name == "this" ? "__this" : a.Name)));
|
||||||
|
|
||||||
writeCode($"DO_APP_FUNC(0x{method.MethodCodeAddress - model.Package.BinaryImage.ImageBase:X8}, {method.CppFnPtrType.ReturnType.Name}, "
|
writeCode($"DO_APP_FUNC(0x{method.MethodCodeAddress - model.Package.BinaryImage.ImageBase:X8}, {method.CppFnPtrType.ReturnType.Name}, "
|
||||||
+ $"{method.CppFnPtrType.Name}, ({arguments}));");
|
+ $"{method.CppFnPtrType.Name}, ({arguments}));");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (method.HasMethodInfo) {
|
||||||
|
writeCode($"DO_APP_FUNC_METHODINFO(0x{method.MethodInfoPtrAddress - model.Package.BinaryImage.ImageBase:X8}, {method.CppFnPtrType.Name}__MethodInfo);");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writer.Close();
|
writer.Close();
|
||||||
|
|
||||||
// Write metadata version
|
// Write metadata version
|
||||||
|
|||||||
@@ -1187,10 +1187,12 @@ EndGlobal
|
|||||||
|
|
||||||
// Application-specific functions
|
// Application-specific functions
|
||||||
#define DO_APP_FUNC(a, r, n, p) extern r (*n) p
|
#define DO_APP_FUNC(a, r, n, p) extern r (*n) p
|
||||||
|
#define DO_APP_FUNC_METHODINFO(a, n) extern struct MethodInfo * n
|
||||||
namespace app {
|
namespace app {
|
||||||
#include "il2cpp-functions.h"
|
#include "il2cpp-functions.h"
|
||||||
}
|
}
|
||||||
#undef DO_APP_FUNC
|
#undef DO_APP_FUNC
|
||||||
|
#undef DO_APP_FUNC_METHODINFO
|
||||||
|
|
||||||
// TypeInfo pointers
|
// TypeInfo pointers
|
||||||
#define DO_TYPEDEF(a, n) extern n ## __Class** n ## __TypeInfo
|
#define DO_TYPEDEF(a, n) extern n ## __Class** n ## __TypeInfo
|
||||||
@@ -1216,10 +1218,12 @@ namespace app {
|
|||||||
|
|
||||||
// Application-specific functions
|
// Application-specific functions
|
||||||
#define DO_APP_FUNC(a, r, n, p) r (*n) p
|
#define DO_APP_FUNC(a, r, n, p) r (*n) p
|
||||||
|
#define DO_APP_FUNC_METHODINFO(a, n) struct MethodInfo * n
|
||||||
namespace app {
|
namespace app {
|
||||||
#include "il2cpp-functions.h"
|
#include "il2cpp-functions.h"
|
||||||
}
|
}
|
||||||
#undef DO_APP_FUNC
|
#undef DO_APP_FUNC
|
||||||
|
#undef DO_APP_FUNC_METHODINFO
|
||||||
|
|
||||||
// TypeInfo pointers
|
// TypeInfo pointers
|
||||||
#define DO_TYPEDEF(a, n) n ## __Class** n ## __TypeInfo
|
#define DO_TYPEDEF(a, n) n ## __Class** n ## __TypeInfo
|
||||||
@@ -1243,8 +1247,10 @@ void init_il2cpp()
|
|||||||
|
|
||||||
// Define function addresses
|
// Define function addresses
|
||||||
#define DO_APP_FUNC(a, r, n, p) n = (r (*) p)(baseAddress + a)
|
#define DO_APP_FUNC(a, r, n, p) n = (r (*) p)(baseAddress + a)
|
||||||
|
#define DO_APP_FUNC_METHODINFO(a, n) n = (struct MethodInfo *)(baseAddress + a)
|
||||||
#include "il2cpp-functions.h"
|
#include "il2cpp-functions.h"
|
||||||
#undef DO_APP_FUNC
|
#undef DO_APP_FUNC
|
||||||
|
#undef DO_APP_FUNC_METHODINFO
|
||||||
|
|
||||||
// Define TypeInfo variables
|
// Define TypeInfo variables
|
||||||
#define DO_TYPEDEF(a, n) n ## __TypeInfo = (n ## __Class**) (baseAddress + a);
|
#define DO_TYPEDEF(a, n) n ## __TypeInfo = (n ## __Class**) (baseAddress + a);
|
||||||
|
|||||||
Reference in New Issue
Block a user