Skip to content

Commit

Permalink
Lz loader error category (avast#630)
Browse files Browse the repository at this point in the history
* Added an isLoadableAnyway category for loader errors

* Fixed whitespaces

* Fixed whitespaces

* Replaced 0/1 with false/true

* Dummy commit to force test builds
  • Loading branch information
ladislav-zezula authored and metthal committed Sep 3, 2019
1 parent a641267 commit 63f03e7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/retdec/fileformat/file_format/file_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct LoaderErrorInfo
std::uint32_t loaderErrorCode; // Loader error code, cast to uint32_t
const char * loaderError;
const char * loaderErrorUserFriendly;
bool isLoadableAnyway;
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/fileformat/file_format/pe/pe_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ void PeFormat::initLoaderErrorInfo(PeLib::LoaderError ldrError)
_ldrErrInfo.loaderErrorCode = static_cast<std::uint32_t>(ldrError);
_ldrErrInfo.loaderError = getLoaderErrorString(ldrError, false);
_ldrErrInfo.loaderErrorUserFriendly = getLoaderErrorString(ldrError, true);
_ldrErrInfo.isLoadableAnyway = getLoaderErrorLoadableAnyway(ldrError);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ std::size_t BasicPlainGetter::loadInformation(std::vector<std::string> &desc, st

// Save the title for loader error (if there was a loader error detected)
if(loaderErrorUserFriendly != nullptr)
{
desc.push_back("Loader error : ");
desc.push_back("Loadable anyway : ");
}

desc.push_back("Architecture : ");
desc.push_back("Endianness : ");
Expand All @@ -65,8 +68,11 @@ std::size_t BasicPlainGetter::loadInformation(std::vector<std::string> &desc, st
info.push_back(fileinfo.getFileType());

// Save the text loader error
if(loaderErrorUserFriendly != nullptr)
if (loaderErrorUserFriendly != nullptr)
{
info.push_back(loaderErrorUserFriendly);
info.push_back(fileinfo.getLoaderErrorInfo().isLoadableAnyway ? "Yes" : "No");
}

info.push_back(fileinfo.getTargetArchitecture());
info.push_back(fileinfo.getEndianness());
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 @@ -146,6 +146,7 @@ void JsonPresentation::presentLoaderError(Json::Value &root) const
loaderErrorNode["code"] = ldrErrInfo.loaderErrorCode;
loaderErrorNode["code_text"] = ldrErrInfo.loaderError;
loaderErrorNode["description"] = ldrErrInfo.loaderErrorUserFriendly;
loaderErrorNode["loadable_anyway"] = ldrErrInfo.isLoadableAnyway ? "true" : "false";

root["loaderError"] = loaderErrorNode;
}
Expand Down

0 comments on commit 63f03e7

Please sign in to comment.