IDA: Don't produce C type header file if it's already available
This commit is contained in:
@@ -258,7 +258,7 @@ namespace Il2CppInspector.CLI
|
|||||||
|
|
||||||
// IDA Python script output
|
// IDA Python script output
|
||||||
using (new Benchmark("Generate IDAPython script")) {
|
using (new Benchmark("Generate IDAPython script")) {
|
||||||
new IDAPythonScript(appModel).WriteScriptToFile(options.PythonOutFile);
|
new IDAPythonScript(appModel).WriteScriptToFile(options.PythonOutFile, options.CppOutPath + Path.DirectorySeparatorChar + "il2cpp-types.h");
|
||||||
}
|
}
|
||||||
|
|
||||||
// C++ output
|
// C++ output
|
||||||
|
|||||||
@@ -21,11 +21,20 @@ namespace Il2CppInspector.Outputs
|
|||||||
|
|
||||||
public IDAPythonScript(AppModel model) => this.model = model;
|
public IDAPythonScript(AppModel model) => this.model = model;
|
||||||
|
|
||||||
public void WriteScriptToFile(string outputFile) {
|
public void WriteScriptToFile(string outputFile, string existingTypeHeaderFIle = null) {
|
||||||
|
|
||||||
// Write types file first
|
// Write types file first if it hasn't been specified
|
||||||
var typeHeaderFile = Path.Combine(Path.GetDirectoryName(outputFile), Path.GetFileNameWithoutExtension(outputFile) + ".h");
|
var typeHeaderFile = Path.Combine(Path.GetDirectoryName(outputFile), Path.GetFileNameWithoutExtension(outputFile) + ".h");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(existingTypeHeaderFIle))
|
||||||
writeTypes(typeHeaderFile);
|
writeTypes(typeHeaderFile);
|
||||||
|
else
|
||||||
|
typeHeaderFile = existingTypeHeaderFIle;
|
||||||
|
|
||||||
|
var typeHeaderRelativePath = Path.GetRelativePath(Path.GetDirectoryName(Path.GetFullPath(outputFile)),
|
||||||
|
Path.GetDirectoryName(Path.GetFullPath(typeHeaderFile)))
|
||||||
|
+ Path.DirectorySeparatorChar
|
||||||
|
+ Path.GetFileName(typeHeaderFile);
|
||||||
|
|
||||||
using var fs = new FileStream(outputFile, FileMode.Create);
|
using var fs = new FileStream(outputFile, FileMode.Create);
|
||||||
writer = new StreamWriter(fs, Encoding.ASCII);
|
writer = new StreamWriter(fs, Encoding.ASCII);
|
||||||
@@ -40,7 +49,7 @@ namespace Il2CppInspector.Outputs
|
|||||||
writeLine(
|
writeLine(
|
||||||
@"original_macros = ida_typeinf.get_c_macros()
|
@"original_macros = ida_typeinf.get_c_macros()
|
||||||
ida_typeinf.set_c_macros(original_macros + "";_IDA_=1"")
|
ida_typeinf.set_c_macros(original_macros + "";_IDA_=1"")
|
||||||
idc.parse_decls(""" + Path.GetFileName(typeHeaderFile) + @""", idc.PT_FILE)
|
idc.parse_decls(""" + typeHeaderRelativePath + @""", idc.PT_FILE)
|
||||||
ida_typeinf.set_c_macros(original_macros)");
|
ida_typeinf.set_c_macros(original_macros)");
|
||||||
|
|
||||||
writeMethods();
|
writeMethods();
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace Il2CppInspector
|
|||||||
}.WriteSingleFile(testPath + $@"\test-result{nameSuffix}.cs");
|
}.WriteSingleFile(testPath + $@"\test-result{nameSuffix}.cs");
|
||||||
|
|
||||||
new IDAPythonScript(appModel)
|
new IDAPythonScript(appModel)
|
||||||
.WriteScriptToFile(testPath + $@"\test-ida-result{nameSuffix}.py");
|
.WriteScriptToFile(testPath + $@"\test-ida-result{nameSuffix}.py", testPath + $@"\test-cpp-result{nameSuffix}\il2cpp-types.h");
|
||||||
|
|
||||||
new CppScaffolding(appModel)
|
new CppScaffolding(appModel)
|
||||||
.Write(testPath + $@"\test-cpp-result{nameSuffix}");
|
.Write(testPath + $@"\test-cpp-result{nameSuffix}");
|
||||||
|
|||||||
Reference in New Issue
Block a user