java.lang.Object
ghidra.features.bsim.query.client.tables.SQLComplexTable
ghidra.features.bsim.query.client.tables.ExeTable

public class ExeTable extends SQLComplexTable
  • Field Details

  • Constructor Details

    • ExeTable

      public ExeTable(SQLStringTable archtable, SQLStringTable compilertable, SQLStringTable repositorytable, SQLStringTable pathtable, ExeToCategoryTable exeCategoryTable)
      Constructor
      Parameters:
      archtable - the architecture table
      compilertable - the compiler table
      repositorytable - the repository table
      pathtable - the path table
      exeCategoryTable - the category table
  • Method Details

    • close

      public void close()
      Overrides:
      close in class SQLComplexTable
    • create

      public void create(Statement st) throws SQLException
      Description copied from class: SQLComplexTable
      Creates the db table.
      Specified by:
      create in class SQLComplexTable
      Parameters:
      st - the query statement
      Throws:
      SQLException - if there is a problem
    • drop

      public void drop(Statement st) throws SQLException
      Description copied from class: SQLComplexTable
      Drops the current table. NOTE: If explicitly created index tables exist they should be removed first or this method override.
      Overrides:
      drop in class SQLComplexTable
      Parameters:
      st - the query statement
      Throws:
      SQLException - if there is a problem with the execute update command
    • delete

      public int delete(long id) throws SQLException
      Description copied from class: SQLComplexTable
      Deletes the row with the given id from the db. Users must set the DELETE_STMT string to delete the exact table they need.
      Overrides:
      delete in class SQLComplexTable
      Parameters:
      id - the database row ID
      Returns:
      the number of deleted rows
      Throws:
      SQLException - if there is a problem creating or executing the query
    • extractExecutableRow

      protected static void extractExecutableRow(ResultSet pgres, ExeTable.ExecutableRow res) throws SQLException
      Pulls information out of the given ExeTable.ExecutableRow object into the given ResultSet
      Parameters:
      pgres - the result set
      res - the executable row
      Throws:
      SQLException - if there is a problem parsing the result set
    • extractExecutableRows

      public int extractExecutableRows(ResultSet rs, List<ExecutableRecord> vecres, DescriptionManager res, int max) throws SQLException, LSHException
      Creates ExecutableRecord objects from ResultSet and stores them in the given list.
      Parameters:
      rs - the result set
      vecres - the list of executable records
      res - the description manager
      max - the max number of rows to return
      Returns:
      the number of rows returned
      Throws:
      SQLException - if there is an problem parsing the result set
      LSHException - if there is an problem creating the executable record
    • makeExecutableRecord

      public ExecutableRecord makeExecutableRecord(DescriptionManager manager, ExeTable.ExecutableRow row) throws SQLException, LSHException
      Make an ExecutableRecord within the DescriptionManager container, given database row information
      Parameters:
      manager - is the DescriptionManager that will contain the new record
      row - is the columnar values for the executable from the database
      Returns:
      the new ExecutableRecord
      Throws:
      SQLException - if there is a problem parsing the table objects
      LSHException - if there is a problem creating a new exec library or record
    • querySingleExecutable

      public ExecutableRecord querySingleExecutable(DescriptionManager manage, String name, String arch, String cname) throws SQLException, LSHException
      Query for a unique executable based on -name- and possibly other metadata
      Parameters:
      manage - the container to store the result
      name - the name the executable must match
      arch - the architecture the executable must match (may be zero length)
      cname - the compiler name the executable must match (may be zero length)
      Returns:
      the unique resulting ExecutableRecord or null, if none or more than 1 is found
      Throws:
      SQLException - if there is a problem querying for the executable name
      LSHException - if there is a problem querying for the executable name or transferring the exec
    • queryNameExeMatch

      public int queryNameExeMatch(List<ExecutableRecord> vecres, DescriptionManager res, String nm, int max) throws SQLException, LSHException
      Executes a database query to return a list of records matching an executalble name filter.
      Parameters:
      vecres - the list of executable records to populate
      res - the description manager
      nm - the name to query for
      max - the max number of records to return
      Returns:
      the number of records returned
      Throws:
      SQLException - if there is a problem creating the query statement
      LSHException - if there is a problem extracting executable rows
    • querySingleExecutableId

      public ExeTable.ExecutableRow querySingleExecutableId(long id) throws SQLException
      Query for a single executable based on its exetable -id-
      Parameters:
      id - the exetable id
      Returns:
      the executable row
      Throws:
      SQLException - if there is a problem creating or executing the query
    • queryMd5ExeMatch

      public ExeTable.ExecutableRow queryMd5ExeMatch(String md5) throws SQLException
      Return the executable with matching md5 (if any)
      Parameters:
      md5 - the md5 hash to query
      Returns:
      the ExecutableRow data or null
      Throws:
      SQLException - if there is a problem creating or executing the query
    • queryExeCount

      public int queryExeCount(String filterMd5, String filterExeName, long filterArch, long filterCompilerName, boolean includeFakes) throws SQLException
      Returns a count of all records in the database matching the filter criteria.
      Parameters:
      filterMd5 - md5 must contain this
      filterExeName - exe name must contain this
      filterArch - if non-zero, force matching architecture id
      filterCompilerName - if non-zero, force matching compiler id
      includeFakes - if true, include MD5s that start with 'bbbbbbbbaaaaaaa'
      Returns:
      total number of records in the database
      Throws:
      SQLException - when preparing or executing the query
    • queryAllExe

      public List<ExeTable.ExecutableRow> queryAllExe(int limit, String filterMd5, String filterExeName, long filterArch, long filterCompilerName, ExeTable.ExeTableOrderColumn sortColumn, boolean includeFakes) throws SQLException
      Returns a list of all rows in the exe table matching a given filter.
      Parameters:
      limit - the max number of results to return
      filterMd5 - md5 must contain this
      filterExeName - exe name must contain this
      filterArch - if non-zero architecture must match this id
      filterCompilerName - if non-zero compiler must match this id
      sortColumn - the name of the column that should define the sorting order
      includeFakes - if false, will exclude generated MD5s starting with "bbbbbbbbaaaaaaaa"
      Returns:
      list of executables
      Throws:
      SQLException - when preparing or executing the query
    • insert

      public long insert(Object... arguments) throws SQLException
      Description copied from class: SQLComplexTable
      Inserts a row(s) into the db. The arguments passed to this function are by definition not known, so they are left as a variable-length list of Object instances, to be interpreted by the implementer.
      Specified by:
      insert in class SQLComplexTable
      Parameters:
      arguments - any arguments required for the insert
      Returns:
      to be defined by the implementor
      Throws:
      SQLException - if there is a problem executing the insert command
    • updateExecutable

      public void updateExecutable(ExecutableRecord.Update rec) throws SQLException
      Updates records in the database with information in the given ExecutableRecord.
      Parameters:
      rec - the executable record to update
      Throws:
      SQLException - if there is a problem creating or executing the query