mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-2308 Refactored parsing dialog adding includepaths and Achitecture,
handle noreturn tags
This commit is contained in:
parent
a4776892bd
commit
08b20d5d21
28 changed files with 1948 additions and 493 deletions
|
@ -31,6 +31,7 @@ import java.io.IOException;
|
|||
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.app.util.cparser.C.CParserUtils;
|
||||
import ghidra.app.util.cparser.C.CParserUtils.CParseResults;
|
||||
import ghidra.app.util.cparser.C.ParseException;
|
||||
import ghidra.program.model.data.DataTypeManager;
|
||||
import ghidra.program.model.data.FileDataTypeManager;
|
||||
|
@ -55,14 +56,16 @@ public class CreateDefaultGDTArchivesScript extends GhidraScript {
|
|||
|
||||
}
|
||||
|
||||
private void parseHeaderFilesToGDT(File outputDir, String gdtName, String languageID, String compiler, String[] filenames, String[] args)
|
||||
private void parseHeaderFilesToGDT(File outputDir, String gdtName, String languageID, String compiler,
|
||||
String[] filenames, String includePaths[], String[] args)
|
||||
throws ParseException, ghidra.app.util.cparser.CPP.ParseException, IOException {
|
||||
DataTypeManager openTypes[] = null;
|
||||
|
||||
parseHeaderFilesToGDT(openTypes, outputDir, gdtName, languageID, compiler, filenames, args);
|
||||
parseHeaderFilesToGDT(openTypes, outputDir, gdtName, languageID, compiler, filenames, includePaths, args);
|
||||
}
|
||||
|
||||
private void parseHeaderFilesToGDT(DataTypeManager openTypes[], File outputDir, String gdtName, String languageID, String compiler, String[] filenames, String[] args)
|
||||
private void parseHeaderFilesToGDT(DataTypeManager openTypes[], File outputDir, String gdtName, String languageID, String compiler,
|
||||
String[] filenames, String[] includePaths, String[] args)
|
||||
throws ParseException, ghidra.app.util.cparser.CPP.ParseException, IOException {
|
||||
|
||||
String dataTypeFile = outputDir + File.separator + gdtName + ".gdt";
|
||||
|
@ -71,9 +74,9 @@ public class CreateDefaultGDTArchivesScript extends GhidraScript {
|
|||
|
||||
FileDataTypeManager dtMgr = FileDataTypeManager.createFileArchive(f);
|
||||
|
||||
String messages = CParserUtils.parseHeaderFiles(openTypes, filenames, args, dtMgr, languageID, compiler, null, monitor);
|
||||
CParseResults results = CParserUtils.parseHeaderFiles(openTypes, filenames, includePaths, args, dtMgr, languageID, compiler, monitor);
|
||||
|
||||
Msg.info(this, messages);
|
||||
Msg.info(this, results.getFormattedParseMessage(null));
|
||||
|
||||
dtMgr.save();
|
||||
dtMgr.close();
|
||||
|
@ -276,14 +279,16 @@ public class CreateDefaultGDTArchivesScript extends GhidraScript {
|
|||
"wscapi.h",
|
||||
"wsdapi.h",
|
||||
"wspiapi.h",
|
||||
|
||||
"rpcproxy.h",
|
||||
};
|
||||
|
||||
String includePaths[] = {
|
||||
headerFilePath+"/VC/VS12/src",
|
||||
headerFilePath+"/VC/VS12/include",
|
||||
headerFilePath+"/VC/SDK/v7.1A/Include",
|
||||
};
|
||||
|
||||
String args[] = {
|
||||
"-I"+headerFilePath+"/VC/VS12/src",
|
||||
"-I"+headerFilePath+"/VC/VS12/include",
|
||||
"-I"+headerFilePath+"/VC/SDK/v7.1A/Include",
|
||||
"-D_M_IX86=300",
|
||||
"-D_MSC_VER=1200",
|
||||
"-D_INTEGRAL_MAX_BITS=32",
|
||||
|
@ -294,8 +299,6 @@ public class CreateDefaultGDTArchivesScript extends GhidraScript {
|
|||
"-D_USE_ATTRIBUTES_FOR_SAL",
|
||||
"-D_CRTBLD",
|
||||
"-D_OPENMP_NOFORCE_MANIFEST",
|
||||
"-DSTRSAFE_LIB",
|
||||
"-DSTRSAFE_LIB_IMPL",
|
||||
"-DLPSKBINFO=LPARAM",
|
||||
"-DCONST=const",
|
||||
"-D_CRT_SECURE_NO_WARNINGS",
|
||||
|
@ -312,7 +315,7 @@ public class CreateDefaultGDTArchivesScript extends GhidraScript {
|
|||
"-D__inner_checkReturn=",
|
||||
};
|
||||
|
||||
parseHeaderFilesToGDT(outputDirectory, "windows_vs12_32_new", "x86:LE:32:default", "windows", filenames, args);
|
||||
parseHeaderFilesToGDT(outputDirectory, "windows_vs12_32_new", "x86:LE:32:default", "windows", filenames, includePaths, args);
|
||||
}
|
||||
|
||||
|
||||
|
@ -494,14 +497,16 @@ public class CreateDefaultGDTArchivesScript extends GhidraScript {
|
|||
"wscapi.h",
|
||||
"wsdapi.h",
|
||||
"wspiapi.h",
|
||||
|
||||
"rpcproxy.h",
|
||||
};
|
||||
|
||||
String includePaths[] = {
|
||||
headerFilePath+"/VC/VS12/src",
|
||||
headerFilePath+"/VC/VS12/include",
|
||||
headerFilePath+"/VC/SDK/v7.1A/Include",
|
||||
};
|
||||
|
||||
String args[] = {
|
||||
"-I"+headerFilePath+"/VC/VS12/src",
|
||||
"-I"+headerFilePath+"/VC/VS12/include",
|
||||
"-I"+headerFilePath+"/VC/SDK/v7.1A/Include",
|
||||
"-D_MSC_VER=1200",
|
||||
"-D_INTEGRAL_MAX_BITS=64",
|
||||
"-DWINVER=0x0900",
|
||||
|
@ -513,8 +518,6 @@ public class CreateDefaultGDTArchivesScript extends GhidraScript {
|
|||
"-D_USE_ATTRIBUTES_FOR_SAL",
|
||||
"-D_CRTBLD",
|
||||
"-D_OPENMP_NOFORCE_MANIFEST",
|
||||
"-DSTRSAFE_LIB",
|
||||
"-DSTRSAFE_LIB_IMPL",
|
||||
"-DLPSKBINFO=LPARAM",
|
||||
"-DCONST=const",
|
||||
"-D_CRT_SECURE_NO_WARNINGS",
|
||||
|
@ -532,7 +535,7 @@ public class CreateDefaultGDTArchivesScript extends GhidraScript {
|
|||
"-D__inner_checkReturn=",
|
||||
};
|
||||
|
||||
parseHeaderFilesToGDT(outputDirectory, "windows_vs12_64_new", "x86:LE:64:default", "windows", filenames, args);
|
||||
parseHeaderFilesToGDT(outputDirectory, "windows_vs12_64_new", "x86:LE:64:default", "windows", filenames, includePaths, args);
|
||||
}
|
||||
|
||||
|
||||
|
@ -761,12 +764,15 @@ public class CreateDefaultGDTArchivesScript extends GhidraScript {
|
|||
"arpa/tftp.h",
|
||||
};
|
||||
|
||||
String includePaths[] = {
|
||||
headerFilePath+"/linux/include",
|
||||
headerFilePath+"/linux/include/sys",
|
||||
headerFilePath+"/linux/gcc/include",
|
||||
headerFilePath+"/linux/x86_64-redhat-linux5E/include",
|
||||
headerFilePath+"/linux/x86_64-redhat-linux5E/include/sys",
|
||||
};
|
||||
|
||||
String args[] = {
|
||||
"-I"+headerFilePath+"/linux/include",
|
||||
"-I"+headerFilePath+"/linux/include/sys",
|
||||
"-I"+headerFilePath+"/linux/gcc/include",
|
||||
"-I"+headerFilePath+"/linux/x86_64-redhat-linux5E/include",
|
||||
"-I"+headerFilePath+"/linux/x86_64-redhat-linux5E/include/sys",
|
||||
"-D_X86_",
|
||||
"-D__STDC__",
|
||||
"-D_GNU_SOURCE",
|
||||
|
@ -782,7 +788,7 @@ public class CreateDefaultGDTArchivesScript extends GhidraScript {
|
|||
"-Daligned_u64=uint64_t",
|
||||
};
|
||||
|
||||
parseHeaderFilesToGDT(outputDirectory, "generic_clib_64_new", "x86:LE:64:default", "gcc", filenames, args);
|
||||
parseHeaderFilesToGDT(outputDirectory, "generic_clib_64_new", "x86:LE:64:default", "gcc", filenames, includePaths, args);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1011,12 +1017,15 @@ public class CreateDefaultGDTArchivesScript extends GhidraScript {
|
|||
"arpa/tftp.h",
|
||||
};
|
||||
|
||||
String includePaths[] = {
|
||||
headerFilePath+"/linux/include",
|
||||
headerFilePath+"/linux/include/sys",
|
||||
headerFilePath+"/linux/gcc/include",
|
||||
headerFilePath+"/linux/x86_64-redhat-linux5E/include",
|
||||
headerFilePath+"/linux/x86_64-redhat-linux5E/include/sys",
|
||||
};
|
||||
|
||||
String args[] = {
|
||||
"-I"+headerFilePath+"/linux/include",
|
||||
"-I"+headerFilePath+"/linux/include/sys",
|
||||
"-I"+headerFilePath+"/linux/gcc/include",
|
||||
"-I"+headerFilePath+"/linux/x86_64-redhat-linux5E/include",
|
||||
"-I"+headerFilePath+"/linux/x86_64-redhat-linux5E/include/sys",
|
||||
"-D_X86_",
|
||||
"-D__STDC__",
|
||||
"-D_GNU_SOURCE",
|
||||
|
@ -1032,6 +1041,6 @@ public class CreateDefaultGDTArchivesScript extends GhidraScript {
|
|||
"-Daligned_u64=uint64_t",
|
||||
};
|
||||
|
||||
parseHeaderFilesToGDT(outputDirectory, "generic_clib_new", "x86:LE:32:default", "gcc", filenames, args);
|
||||
parseHeaderFilesToGDT(outputDirectory, "generic_clib_new", "x86:LE:32:default", "gcc", filenames, includePaths, args);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue