Class ExecutableRecord
java.lang.Object
ghidra.features.bsim.query.description.ExecutableRecord
- All Implemented Interfaces:
Comparable<ExecutableRecord>
Metadata about a specific executable, as stored in a BSim database
There are two basic varieties:
Normal executables, which can be viewed as a container of functions where
each function has a body and an address (and a corresponding feature vector)
Library executables, which contains functions that can only be identified by
name and have no body (or corresponding feature vector)
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final Date
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ExecutableRecord
(String md5) Constructor for searching within a DescriptionManagerExecutableRecord
(String enm, String arc, RowKey id) Constructor for a "library" executableExecutableRecord
(String md5, String execName, String compilerName, String architecture, Date date, RowKey id, String repo, String path) Construct a normal (non-library) record.ExecutableRecord
(String md5, String enm, String cnm, String arc, Date dt, List<CategoryRecord> uc, RowKey id, String repo, String pth) Construct a normal (non-library) record. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
calcLibraryMd5Placeholder
(String enm, String arc) Generate a placeholder md5 string for a library executable based just on its name and architectureboolean
protected void
boolean
Compare the set of categories that -this- and -op2- belong toint
Compare just the metadata portion (names and versions) of two ExecutableRecords We do NOT compare categories as these may not have been read into the object yetint
boolean
diffForUpdate
(ExecutableRecord.Update res, ExecutableRecord fromDB) Assuming this is a (possibly) updated variant of another executable metadata record Prepare an Update record describing the difference between the two recordsboolean
getCategory
(String type) Return the executable's settings for a specific category typegetDate()
Get all the category settings of a specific type in alphabetic order.getMd5()
getPath()
getRowId()
int
boolean
hasCategory
(String type, String value) Determine if an executable has been set with a specific category valueint
hashCode()
boolean
boolean
static boolean
isLibraryHash
(String md5) Identify whether an md5 string is a placeholder hash (as generated bycalcLibraryMd5Placeholder(java.lang.String, java.lang.String)
)printRaw()
Get the formatted raw executable metadata as a stringstatic ExecutableRecord
restoreXml
(XmlPullParser parser, DescriptionManager man) Build a newExecutableRecord
by deserializing from an XML streamvoid
Serialize this executable (meta-data) to an XML streamprotected void
protected void
setCategory
(List<CategoryRecord> cats) protected void
setRepository
(String repo, String newpath) Set the repository and path Strings for an executable, replacing any previous setting.protected void
protected void
setXrefIndex
(int val) toString()
-
Field Details
-
EMPTY_DATE
-
ALREADY_STORED
public static final int ALREADY_STORED- See Also:
-
LIBRARY
public static final int LIBRARY- See Also:
-
CATEGORIES_SET
public static final int CATEGORIES_SET- See Also:
-
METADATA_NAME
public static final int METADATA_NAME- See Also:
-
METADATA_ARCH
public static final int METADATA_ARCH- See Also:
-
METADATA_COMP
public static final int METADATA_COMP- See Also:
-
METADATA_DATE
public static final int METADATA_DATE- See Also:
-
METADATA_REPO
public static final int METADATA_REPO- See Also:
-
METADATA_PATH
public static final int METADATA_PATH- See Also:
-
METADATA_LIBR
public static final int METADATA_LIBR- See Also:
-
-
Constructor Details
-
ExecutableRecord
Constructor for searching within a DescriptionManager- Parameters:
md5
- is hash of executable being searched for
-
ExecutableRecord
public ExecutableRecord(String md5, String execName, String compilerName, String architecture, Date date, RowKey id, String repo, String path) Construct a normal (non-library) record. Fill-in all fields except categories. Categories are marked as NOT set- Parameters:
md5
- is the md5 checksumexecName
- is the executable namecompilerName
- is the compiler namearchitecture
- is the processor architecturedate
- is the date of ingest (may be null)id
- is the row id of the recordrepo
- is the repository containing the executable (may be null)path
- is the path to the executable (may be null)
-
ExecutableRecord
public ExecutableRecord(String md5, String enm, String cnm, String arc, Date dt, List<CategoryRecord> uc, RowKey id, String repo, String pth) Construct a normal (non-library) record. Fill-in all fields.- Parameters:
md5
- is the md5 checksumenm
- is the executable namecnm
- is the compiler namearc
- is the architecturedt
- is the date of ingest (may be null)uc
- is the categories (may be null, categories are considered SET regardless)id
- is the row id of the recordrepo
- is the repository containing the executable (may be null)pth
- is the path to the executable (may be null)
-
ExecutableRecord
Constructor for a "library" executable- Parameters:
enm
- is the name of the libraryarc
- is the architecture for functions in the libraryid
- is the database (row) id of the record (may be null)
-
-
Method Details
-
calcLibraryMd5Placeholder
Generate a placeholder md5 string for a library executable based just on its name and architecture- Parameters:
enm
- is the name of the libraryarc
- is the architecture- Returns:
- the placeholder md5 String
-
setRepository
Set the repository and path Strings for an executable, replacing any previous setting. Truncate any trailing slash.- Parameters:
repo
- is (URL) string indicating which repository contains this executablenewpath
- is the path, relative to the repository, to the executable- Throws:
IllegalArgumentException
- if invalid repo URL specified
-
setRowId
-
setAlreadyStored
protected void setAlreadyStored() -
setXrefIndex
protected void setXrefIndex(int val) -
setCategory
-
cloneCategories
-
getAllCategories
- Returns:
- the list of
CategoryRecord
s associated with this executable
-
getCategory
Return the executable's settings for a specific category type- Parameters:
type
- is the category type- Returns:
- the list of settings with this type (or null)
-
hasCategory
Determine if an executable has been set with a specific category value- Parameters:
type
- is the type of category to checkvalue
- is the value to check for- Returns:
- true if the executable has that value, false otherwise
-
getMd5
- Returns:
- the MD5 hash of the executable
-
getNameExec
- Returns:
- the name of the executable
-
getArchitecture
- Returns:
- the architecture associated with the executable
-
getNameCompiler
- Returns:
- the name of the compiler that built this executable
-
getDate
- Returns:
- the date this executable was ingested into the database
-
getRepository
- Returns:
- the URL of the repository containing this executable
-
getPath
- Returns:
- the (repository relative) path to the executable
-
isLibrary
public boolean isLibrary()- Returns:
- true if this executable is a "library" (functions identified only by name)
-
isAlreadyStored
public boolean isAlreadyStored()- Returns:
- true if this database record has already been stored in the database
-
categoriesAreSet
public boolean categoriesAreSet()- Returns:
- true if categories have been queried in (does not mean that it has any categories)
-
getURLString
- Returns:
- the fully formed URL to this executable or null
-
getExeCategoryAlphabetic
Get all the category settings of a specific type in alphabetic order. Multiple values are returned in a single String separated by ','- Parameters:
type
- is the type of category to retrieve- Returns:
- the concatenated list of settings
-
getRowId
- Returns:
- the database (row) id of this executable object
-
getXrefIndex
public int getXrefIndex()- Returns:
- the internal cross-referencing index for this executable
-
saveXml
Serialize this executable (meta-data) to an XML stream- Parameters:
fwrite
- is the XML stream- Throws:
IOException
- if there are I/O errors writing to the stream
-
isLibraryHash
Identify whether an md5 string is a placeholder hash (as generated bycalcLibraryMd5Placeholder(java.lang.String, java.lang.String)
)- Parameters:
md5
- is the md5 string- Returns:
- true if it is a placeholder, false otherwise
-
restoreXml
public static ExecutableRecord restoreXml(XmlPullParser parser, DescriptionManager man) throws LSHException Build a newExecutableRecord
by deserializing from an XML stream- Parameters:
parser
- is the XML parserman
- is the DescriptionManager that should hold the new executable- Returns:
- the new ExecutableRecord
- Throws:
LSHException
- if there are inconsistencies in the XML description
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ExecutableRecord>
-
compareMetadata
Compare just the metadata portion (names and versions) of two ExecutableRecords We do NOT compare categories as these may not have been read into the object yet- Parameters:
o
- is ExecutableRecord to compare with this- Returns:
- bit vector with a 1 bit for every field that differs
-
compareCategory
Compare the set of categories that -this- and -op2- belong to- Parameters:
op2
- is executable to compare with this- Returns:
- true if the categories are exactly the same
-
diffForUpdate
Assuming this is a (possibly) updated variant of another executable metadata record Prepare an Update record describing the difference between the two records- Parameters:
res
- is the Update record to fill infromDB
- is the other ExecutableRecord metadata- Returns:
- true if overall there has been an update
-
printRaw
Get the formatted raw executable metadata as a string- Returns:
- formatted metadata
-