Skip to content

Commit

Permalink
Add dll_name from export directory to output
Browse files Browse the repository at this point in the history
  • Loading branch information
HoundThe authored and PeterMatula committed Feb 10, 2022
1 parent e8060dd commit 76cc944
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/retdec/fileformat/types/export_table/export_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@ class ExportTable
std::string expHashCrc32; ///< exphash CRC32
std::string expHashMd5; ///< exphash MD5
std::string expHashSha256; ///< exphash SHA256
std::string dllName;
public:
/// @name Setters
/// @{
void setDllName(const std::string& dllName);
/// @}

/// @name Getters
/// @{
std::size_t getNumberOfExports() const;
const std::string& getExphashCrc32() const;
const std::string& getExphashMd5() const;
const std::string& getExphashSha256() const;
const std::string& getDllName() const;
const Export* getExport(std::size_t exportIndex) const;
const Export* getExport(const std::string &name) const;
const Export* getExportOnAddress(unsigned long long address) const;
Expand Down
2 changes: 2 additions & 0 deletions src/fileformat/file_format/pe/pe_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,8 @@ void PeFormat::loadExports()
exportTable->addExport(newExport);
}

exportTable->setDllName(formatParser->getExportDirectory().getNameString());

loadExpHash();

for(auto&& addressRange : formatParser->getExportDirectoryOccupiedAddresses())
Expand Down
10 changes: 10 additions & 0 deletions src/fileformat/types/export_table/export_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ using namespace retdec::utils;
namespace retdec {
namespace fileformat {

void ExportTable::setDllName(const std::string& dllName)
{
this->dllName = dllName;
}

/**
* Get number of stored exports
* @return Number of stored exports
Expand Down Expand Up @@ -50,6 +55,11 @@ const std::string& ExportTable::getExphashSha256() const
return expHashSha256;
}

const std::string& ExportTable::getDllName() const
{
return dllName;
}

/**
* Get selected export
* @param exportIndex Index of selected export (indexed from 0)
Expand Down
5 changes: 5 additions & 0 deletions src/fileinfo/file_information/file_information.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,11 @@ void FileInformation::setDepsListFailedToLoad(const std::string & depsList)
failedDepsList = depsList;
}

std::string FileInformation::getExportDllName() const
{
return exportTable.getDllName();
}

/**
* Get number of stored exports
* @return Number of stored exports
Expand Down
1 change: 1 addition & 0 deletions src/fileinfo/file_information/file_information.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class FileInformation
/// @name Getters of @a exportTable
/// @{
std::size_t getNumberOfStoredExports() const;
std::string getExportDllName() const;
std::string getExphashCrc32() const;
std::string getExphashMd5() const;
std::string getExphashSha256() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ std::string ExportTable::getExphashSha256() const
return table ? table->getExphashSha256() : "";
}

std::string ExportTable::getDllName() const
{
return table ? table->getDllName() : "";
}

/**
* Get export name
* @param position Index of selected export from table (indexed from 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ExportTable
std::string getExphashCrc32() const;
std::string getExphashMd5() const;
std::string getExphashSha256() const;
std::string getDllName() const;
std::string getExportName(std::size_t position) const;
std::string getExportAddressStr(std::size_t position, std::ios_base &(* format)(std::ios_base &)) const;
std::string getExportOrdinalNumberStr(std::size_t position, std::ios_base &(* format)(std::ios_base &)) const;
Expand Down
1 change: 1 addition & 0 deletions src/fileinfo/file_presentation/json_presentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,7 @@ bool JsonPresentation::present()
}

serializeString(writer, "inputFile", fileinfo.getPathToFile());
serializeString(writer, "dllName", fileinfo.getExportDllName());

presentErrors(writer);
presentLoaderError(writer);
Expand Down
7 changes: 7 additions & 0 deletions src/fileinfo/file_presentation/plain_presentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,13 @@ bool PlainPresentation::present()
<< utils::version::getVersionStringShort() << "\n";
}
Log::info() << "Input file : " << fileinfo.getPathToFile() << "\n";

const std::string& dllName = fileinfo.getExportDllName();
if (!dllName.empty())
{
Log::info() << "Dll name : " << dllName << "\n";
}

presentSimple(BasicPlainGetter(fileinfo), false);
presentCompiler();
presentLanguages();
Expand Down

0 comments on commit 76cc944

Please sign in to comment.