Compare commits

..

6 Commits

Author SHA1 Message Date
WerWolv
c977baecc4 Fixed crash when snprintf failed in formatter 2020-11-23 00:35:26 +01:00
WerWolv
2ab2f5e675 Improved block size text 2020-11-23 00:34:53 +01:00
WerWolv
6a38f1e9f3 Truncate file size to 2 digits after comma 2020-11-23 00:22:51 +01:00
WerWolv
f0eba69c4a Fixed time_t decoding crash on Linux 2020-11-23 00:20:29 +01:00
WerWolv
cea366e135 Fixed crash when scrolling disassembler options child off screen 2020-11-23 00:12:53 +01:00
WerWolv
d752c7434f Fixed crash when no patterns folder exists 2020-11-23 00:12:33 +01:00
5 changed files with 8 additions and 7 deletions

View File

@@ -21,7 +21,7 @@ namespace hex {
template<typename ... Args>
inline std::string format(const std::string &format, Args ... args) {
size_t size = snprintf( nullptr, 0, format.c_str(), args ... );
ssize_t size = snprintf( nullptr, 0, format.c_str(), args ... );
if( size <= 0 )
return "";
@@ -65,7 +65,7 @@ namespace hex {
break;
}
std::string result = std::to_string(value);
std::string result = hex::format("%.2f", value);
switch (unitIndex) {
case 0: result += " Bytes"; break;

View File

@@ -72,7 +72,7 @@ namespace hex {
auto endianAdjustedTime = hex::changeEndianess(this->m_previewData.time32, this->m_endianess);
std::tm * ptm = _localtime32(&endianAdjustedTime);
char buffer[32];
if (std::strftime(buffer, 32, "%a, %d.%m.%Y %H:%M:%S", ptm))
if (ptm != nullptr && std::strftime(buffer, 32, "%a, %d.%m.%Y %H:%M:%S", ptm))
this->m_cachedData.emplace_back("__time32_t", buffer);
else
this->m_cachedData.emplace_back("__time32_t", "Invalid");
@@ -82,7 +82,7 @@ namespace hex {
auto endianAdjustedTime = hex::changeEndianess(this->m_previewData.time64, this->m_endianess);
std::tm * ptm = _localtime64(&endianAdjustedTime);
char buffer[64];
if (std::strftime(buffer, 64, "%a, %d.%m.%Y %H:%M:%S", ptm) != 0)
if (ptm != nullptr && std::strftime(buffer, 64, "%a, %d.%m.%Y %H:%M:%S", ptm) != 0)
this->m_cachedData.emplace_back("__time64_t", buffer);
else
this->m_cachedData.emplace_back("__time64_t", "Invalid");

View File

@@ -211,8 +211,8 @@ namespace hex {
break;
}
ImGui::EndChild();
}
ImGui::EndChild();
ImGui::NewLine();
if (ImGui::Button("Disassemble"))

View File

@@ -174,7 +174,7 @@ namespace hex {
ImGui::NewLine();
ImGui::LabelText("Block size", "2048 blocks à %lu bytes", this->m_blockSize);
ImGui::LabelText("Block size", "2048 blocks of %lu bytes", this->m_blockSize);
ImGui::LabelText("Average entropy", "%.8f", this->m_averageEntropy);
ImGui::LabelText("Highest entropy block", "%.8f", this->m_highestBlockEntropy);

View File

@@ -107,7 +107,8 @@ namespace hex {
preprocessor.addDefaultPragramHandlers();
for (auto &entry : std::filesystem::directory_iterator("patterns")) {
std::error_code errorCode;
for (auto &entry : std::filesystem::directory_iterator("patterns", errorCode)) {
if (!entry.is_regular_file())
continue;