IDA: Don't produce C type header file if it's already available

This commit is contained in:
Katy Coe
2020-07-28 19:23:53 +02:00
parent 4978348d8f
commit 7b9c28fdf3
3 changed files with 15 additions and 6 deletions

View File

@@ -258,7 +258,7 @@ namespace Il2CppInspector.CLI
// IDA Python script output
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

View File

@@ -21,11 +21,20 @@ namespace Il2CppInspector.Outputs
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");
writeTypes(typeHeaderFile);
if (string.IsNullOrEmpty(existingTypeHeaderFIle))
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);
writer = new StreamWriter(fs, Encoding.ASCII);
@@ -40,7 +49,7 @@ namespace Il2CppInspector.Outputs
writeLine(
@"original_macros = ida_typeinf.get_c_macros()
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)");
writeMethods();

View File

@@ -55,7 +55,7 @@ namespace Il2CppInspector
}.WriteSingleFile(testPath + $@"\test-result{nameSuffix}.cs");
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)
.Write(testPath + $@"\test-cpp-result{nameSuffix}");