1
0
mirror of synced 2024-11-24 15:50:16 +01:00

fix: Inverted logic when checking for libmagic error

This commit is contained in:
WerWolv 2021-09-09 01:56:48 +02:00
parent 4cc637c0b2
commit a8c9e96b72
4 changed files with 51 additions and 40 deletions

View File

@ -231,7 +231,7 @@ struct MemoryEditor
if (ImGui::Begin(title, p_open, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNavInputs))
{
if (DataPreviewAddr != DataPreviewAddrOld || DataPreviewAddrEnd != DataPreviewAddrEndOld) {
Region selectionRegion = { std::min(DataPreviewAddr, DataPreviewAddrEnd) + base_display_addr, std::max(DataPreviewAddr, DataPreviewAddrEnd) - std::min(DataPreviewAddr, DataPreviewAddrEnd) };
hex::Region selectionRegion = { std::min(DataPreviewAddr, DataPreviewAddrEnd) + base_display_addr, std::max(DataPreviewAddr, DataPreviewAddrEnd) - std::min(DataPreviewAddr, DataPreviewAddrEnd) };
hex::EventManager::post<hex::EventRegionSelected>(selectionRegion);
}

View File

@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
#include <cstddef>
constexpr static const auto ImHexApiURL = "https://api.werwolv.net/imhex";
constexpr static const auto GitHubApiURL = "https://api.github.com/repos/WerWolv/ImHex";
@ -17,7 +18,12 @@ using s32 = std::int32_t;
using s64 = std::int64_t;
using s128 = __int128_t;
struct Region {
u64 address;
size_t size;
};
namespace hex {
struct Region {
u64 address;
size_t size;
};
}

View File

@ -1,6 +1,7 @@
#pragma once
#include <cstddef>
#include <hex.hpp>
#include <type_traits>
namespace hex {
@ -59,53 +60,55 @@ namespace hex {
template<typename T>
struct is_integral : public is_integral_helper<std::remove_cvref_t<T>>::type { };
template<typename>
struct is_signed_helper : public std::false_type { };
template<>
struct is_signed_helper<s8> : public std::true_type { };
template<typename>
struct is_signed_helper : public std::false_type { };
template<>
struct is_signed_helper<s16> : public std::true_type { };
template<>
struct is_signed_helper<s8> : public std::true_type { };
template<>
struct is_signed_helper<s32> : public std::true_type { };
template<>
struct is_signed_helper<s16> : public std::true_type { };
template<>
struct is_signed_helper<s64> : public std::true_type { };
template<>
struct is_signed_helper<s32> : public std::true_type { };
template<>
struct is_signed_helper<s128> : public std::true_type { };
template<>
struct is_signed_helper<s64> : public std::true_type { };
template<>
struct is_signed_helper<char> : public std::true_type { };
template<>
struct is_signed_helper<s128> : public std::true_type { };
template<>
struct is_signed_helper<float> : public std::true_type { };
template<>
struct is_signed_helper<char> : public std::true_type { };
template<>
struct is_signed_helper<double> : public std::true_type { };
template<>
struct is_signed_helper<float> : public std::true_type { };
template<>
struct is_signed_helper<long double> : public std::true_type { };
template<>
struct is_signed_helper<double> : public std::true_type { };
template<typename T>
struct is_signed : public is_signed_helper<std::remove_cvref_t<T>>::type { };
template<>
struct is_signed_helper<long double> : public std::true_type { };
template<typename>
struct is_floating_point_helper : public std::false_type { };
template<typename T>
struct is_signed : public is_signed_helper<std::remove_cvref_t<T>>::type { };
template<>
struct is_floating_point_helper<float> : public std::true_type { };
template<>
struct is_floating_point_helper<double> : public std::true_type { };
template<typename>
struct is_floating_point_helper : public std::false_type { };
template<>
struct is_floating_point_helper<long double> : public std::true_type { };
template<>
struct is_floating_point_helper<float> : public std::true_type { };
template<typename T>
struct is_floating_point : public is_floating_point_helper<std::remove_cvref_t<T>>::type { };
template<>
struct is_floating_point_helper<double> : public std::true_type { };
template<>
struct is_floating_point_helper<long double> : public std::true_type { };
template<typename T>
struct is_floating_point : public is_floating_point_helper<std::remove_cvref_t<T>>::type { };
}
@ -132,6 +135,7 @@ namespace hex {
// [concepts.arithmetic]
namespace hex {
template<class T>
concept integral = hex::is_integral<T>::value;
@ -143,6 +147,7 @@ namespace hex {
template<class T>
concept floating_point = std::is_floating_point<T>::value;
}
namespace hex {

View File

@ -56,7 +56,7 @@ namespace hex::magic {
magic_t ctx = magic_open(MAGIC_NONE);
ON_SCOPE_EXIT { magic_close(ctx); };
if (magic_load(ctx, magicFiles->c_str()))
if (magic_load(ctx, magicFiles->c_str()) == 0)
return magic_buffer(ctx, data.data(), data.size()) ?: "";
}
@ -77,7 +77,7 @@ namespace hex::magic {
magic_t ctx = magic_open(MAGIC_MIME);
ON_SCOPE_EXIT { magic_close(ctx); };
if (magic_load(ctx, magicFiles->c_str()))
if (magic_load(ctx, magicFiles->c_str()) == 0)
return magic_buffer(ctx, data.data(), data.size()) ?: "";
}