build: Fix cppcheck issues

This commit is contained in:
WerWolv
2025-07-10 13:57:08 +02:00
parent e58ce527c6
commit da2aa85a8a
40 changed files with 87 additions and 230 deletions

View File

@@ -40,7 +40,6 @@ set(LIBIMHEX_SOURCES
source/helpers/imgui_hooks.cpp
source/helpers/semantic_version.cpp
source/helpers/keys.cpp
source/helpers/freetype.cpp
source/helpers/udp_server.cpp
source/test/tests.cpp

View File

@@ -311,11 +311,15 @@ EXPORT_MODULE namespace hex {
}
[[nodiscard]] bool isUnlockable() const {
return std::all_of(this->parents.begin(), this->parents.end(), [](auto &parent) { return parent->achievement->isUnlocked(); });
return std::ranges::all_of(this->parents, [](const auto &parent) {
return parent->achievement->isUnlocked();
});
}
[[nodiscard]] bool isVisible() const {
return std::all_of(this->visibilityParents.begin(), this->visibilityParents.end(), [](auto &parent) { return parent->achievement->isUnlocked(); });
return std::ranges::all_of(this->visibilityParents, [](const auto &parent) {
return parent->achievement->isUnlocked();
});
}
[[nodiscard]] bool isUnlocked() const {

View File

@@ -731,7 +731,7 @@ EXPORT_MODULE namespace hex {
add(impl::Entry {
unlocalizedCategory,
unlocalizedName,
[=, ...args = std::forward<Args>(args)]() mutable {
[unlocalizedName, ...args = std::forward<Args>(args)]() mutable {
auto node = std::make_unique<T>(std::forward<Args>(args)...);
node->setUnlocalizedName(unlocalizedName);
return node;
@@ -1072,7 +1072,7 @@ EXPORT_MODULE namespace hex {
* @param unlocalizedName The unlocalized name of the formatter
* @param callback The function to call to format the data
*/
void addFindExportFormatter(const UnlocalizedString &unlocalizedName, const std::string fileExtension, const impl::FindExporterCallback &callback);
void addFindExportFormatter(const UnlocalizedString &unlocalizedName, const std::string &fileExtension, const impl::FindExporterCallback &callback);
}

View File

@@ -33,7 +33,7 @@ namespace hex {
m_valid = true;
}
~AutoReset() {
~AutoReset() override {
ImHexApi::System::impl::removeAutoResetObject(this);
}
@@ -85,8 +85,8 @@ namespace hex {
m_value.reset();
} else if constexpr (requires { m_value.clear(); }) {
m_value.clear();
} else if constexpr (requires(T t) { t = nullptr; }) {
m_value = nullptr;
} else if constexpr (std::is_pointer_v<T>) {
m_value = nullptr; // cppcheck-suppress nullPointer
} else {
m_value = { };
}

View File

@@ -1,60 +0,0 @@
#pragma once
#include "imgui.h"
#include <vector>
namespace hex::ft {
class Bitmap {
ImU32 m_width;
ImU32 m_height;
ImU32 m_pitch;
std::vector <ImU8> m_data;
public:
Bitmap(ImU32 width, ImU32 height, ImU32 pitch, ImU8 *data) : m_width(width), m_height(height), m_pitch(pitch), m_data(std::vector<ImU8>(data, data + pitch * height)) {}
Bitmap(ImU32 width, ImU32 height, ImU32 pitch) : m_width(width), m_height(height), m_pitch(pitch) { m_data.resize(pitch * height); }
void clear() { m_data.clear(); }
ImU32 getWidth() const { return m_width; }
ImU32 getHeight() const { return m_height; }
ImU32 getPitch() const { return m_pitch; }
const std::vector <ImU8> &getData() const { return m_data; }
ImU8 *getData() { return m_data.data(); }
void lcdFilter();
};
class RGBA {
public:
static ImU32 addAlpha(ImU8 r, ImU8 g, ImU8 b) {
color.rgbaVec[0] = r;
color.rgbaVec[1] = g;
color.rgbaVec[2] = b;
color.rgbaVec[3] = (r + g + b) / 3;//luminance
return color.rgba;
}
RGBA(ImU8 r, ImU8 g, ImU8 b, ImU8 a) {
color.rgbaVec[0] = r;
color.rgbaVec[1] = b;
color.rgbaVec[2] = g;
color.rgbaVec[3] = a;
}
explicit RGBA(ImU32 rgba) {
color.rgba = rgba;
}
union RGBAU {
ImU8 rgbaVec[4];
ImU32 rgba;
};
inline static RGBAU color;
};
}

View File

@@ -79,7 +79,7 @@ namespace hex::gl {
return *this;
}
auto operator-=(Vector other) {
auto operator-=(const Vector &other) {
for (size_t i = 0; i < Size; i++)
m_data[i] -= other.m_data[i];
@@ -156,7 +156,7 @@ namespace hex::gl {
}
private:
std::array<T, Size> m_data;
std::array<T, Size> m_data = { };
};
template<typename T, size_t Rows, size_t Columns>

View File

@@ -74,7 +74,7 @@ namespace hex {
[[nodiscard]] T get() const { return pointer; }
[[nodiscard]] T operator->() const { return pointer; }
[[nodiscard]] T operator*() const { return *pointer; }
[[nodiscard]] std::remove_pointer_t<T> operator*() const { return *pointer; }
[[nodiscard]] operator T() const { return pointer; }
T pointer;

View File

@@ -49,11 +49,11 @@ namespace hex {
private:
void run();
u16 m_port;
u16 m_port = 0;
Callback m_callback;
std::thread m_thread;
std::atomic<bool> m_running;
int m_socketFd;
int m_socketFd = -1;
};
}

View File

@@ -13,7 +13,7 @@ namespace hex::prv::undo {
class Operation : public ICloneable<Operation> {
public:
virtual ~Operation() = default;
~Operation() override = default;
virtual void undo(Provider *provider) = 0;
virtual void redo(Provider *provider) = 0;

View File

@@ -1105,7 +1105,7 @@ namespace hex {
impl::s_exportMenuEntries->push_back({ unlocalizedName, callback });
}
void addFindExportFormatter(const UnlocalizedString &unlocalizedName, const std::string fileExtension, const impl::FindExporterCallback &callback) {
void addFindExportFormatter(const UnlocalizedString &unlocalizedName, const std::string &fileExtension, const impl::FindExporterCallback &callback) {
log::debug("Registered new export formatter: {}", unlocalizedName.get());
impl::s_findExportEntries->push_back({ unlocalizedName, fileExtension, callback });

View File

@@ -83,12 +83,8 @@ namespace hex {
m_functions.getFeaturesFunction = getPluginFunction<PluginFunctions::GetSubCommandsFunc>("getFeatures");
}
Plugin::Plugin(const std::string &name, const hex::PluginFunctions &functions) {
m_handle = 0;
m_functions = functions;
m_path = name;
m_addedManually = true;
}
Plugin::Plugin(const std::string &name, const hex::PluginFunctions &functions) :
m_handle(0), m_path(name), m_addedManually(true), m_functions(functions) { }
Plugin::Plugin(Plugin &&other) noexcept {

View File

@@ -404,7 +404,7 @@ namespace hex {
if (s_tasks.empty()) {
std::scoped_lock lock(s_deferredCallsMutex);
for (auto &call : s_tasksFinishedCallbacks)
for (const auto &call : s_tasksFinishedCallbacks)
call();
s_tasksFinishedCallbacks.clear();
}

View File

@@ -1,60 +0,0 @@
#include "hex/helpers/freetype.hpp"
#include "imgui.h"
namespace hex::ft {
void Bitmap::lcdFilter() {
if (m_width * m_height == 0)
return;
std::vector <ImU8> h = {8, 0x4D, 0x55, 0x4D, 8};
auto paddedWidth = m_width + 4;
auto fWidth = paddedWidth + ((3 - (paddedWidth % 3)) % 3);
auto fPitch = (fWidth + 3) & (-4);
Bitmap f(fWidth, m_height, fPitch);
//std::vector<std::vector<ImU8>> fir(3, std::vector<ImU8>(3, 0));
// first output: h[0]*input[0]/255.0f;
// 2nd output: (h[1]*input[0] + h[0]*input[1])/255.0f;
// 3rd output: (h[2]*input[0] + h[1]*input[1] + h[0]*input[2])/255.0f;
// 4th output: (h[1]*input[0] + h[2]*input[1] + h[1]*input[2] + h[0]*input[3])/255.0f;
// ith output: (h[0]*input[5+i] + h[1]*input[i+6] + h[2]*input[i+7] + h[1]*input[i+8] + h[0]*input[i+9])/255.0f;
// aap output: (h[0]*input[N-4] + h[1]*input[N-3] + h[2]*input[N-2] + h[1]*input[N-1])/255.0f;
// ap output: (h[0]*input[N-3] + h[1]*input[N-2] + h[2]*input[N-1])/255.0f;
// p output: (h[0]*input[N-2] + h[1]*input[N-1] )/255.0f;
// last output: h[0]*input[N-1]/255.0f;
for (ImU32 y = 0; y < m_height; y++) {
auto fp = y * fPitch;
auto yp = y * m_pitch;
bool done = false;
for (ImU32 x = 0; x < 4; x++) {
ImU32 head = 0;
ImU32 tail = 0;
if (m_width >= x + 1) {
for (ImU32 i = 0; i < x + 1; i++) {
head += h[x - i] * m_data[yp + i];
tail += h[i] * m_data[yp + m_width - 1 - x + i];
}
f.m_data[fp + x] = head >> 8;
f.m_data[fp + paddedWidth - 1 - x] = tail >> 8;
} else {
done = true;
break;
}
}
if (done)
continue;
for (ImU32 x = 4; x < paddedWidth - 4; x++) {
ImU32 head = 0;
for (ImS32 i = 0; i < 5; i++) {
head += h[i] * m_data[yp + i + x - 4];
}
f.m_data[fp + x] = head >> 8;
}
}
clear();
m_width = f.m_width;
m_height = f.m_height;
m_pitch = f.m_pitch;
m_data = std::move(f.m_data);
}
}

View File

@@ -59,6 +59,7 @@ namespace hex {
m_url = std::move(other.m_url);
m_headers = std::move(other.m_headers);
m_body = std::move(other.m_body);
m_timeout = other.m_timeout;
return *this;
}
@@ -121,7 +122,7 @@ namespace hex {
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);
}
void setupFileUpload(CURL *curl, wolv::io::File &file, const std::string &fileName, const std::string &mimeName) {
void setupFileUpload(CURL *curl, const wolv::io::File &file, const std::string &fileName, const std::string &mimeName) {
curl_mime *mime = curl_mime_init(curl);
curl_mimepart *part = curl_mime_addpart(mime);

View File

@@ -277,6 +277,10 @@ namespace hex::gl {
Texture& Texture::operator=(Texture &&other) noexcept {
m_texture = other.m_texture;
other.m_texture = 0;
m_width = other.m_width;
m_height = other.m_height;
return *this;
}

View File

@@ -45,10 +45,6 @@ namespace hex {
return m_patches.rbegin()->first;
}
void resizeRaw(u64 newSize) override {
std::ignore = newSize;
}
void insertRaw(u64 offset, u64 size) override {
std::vector<std::pair<u64, u8>> patchesToMove;

View File

@@ -20,7 +20,7 @@ namespace hex::test {
if(!initPluginImpl("Built-in")) return false;
}
hex::Plugin *plugin = hex::PluginManager::getPlugin(name);
const auto *plugin = hex::PluginManager::getPlugin(name);
if (plugin == nullptr) {
hex::log::fatal("Plugin '{}' was not found !", name);
return false;

View File

@@ -18,7 +18,7 @@ namespace hex::messaging {
fullEventData.insert(fullEventData.end(), args.begin(), args.end());
u8 *data = &fullEventData[0];
const u8 *data = &fullEventData[0];
auto dataSize = fullEventData.size();
macosSendMessageToMainInstance(data, dataSize);

View File

@@ -379,7 +379,7 @@ namespace hex {
ImPlot::SetupAxes("hex.ui.common.address"_lang, "hex.builtin.information_section.info_analysis.entropy"_lang,
ImPlotAxisFlags_Lock | ImPlotAxisFlags_NoHighlight | ImPlotAxisFlags_NoSideSwitch,
ImPlotAxisFlags_Lock | ImPlotAxisFlags_NoHighlight | ImPlotAxisFlags_NoSideSwitch);
ImPlot::SetupAxisFormat(ImAxis_X1, impl::IntegerAxisFormatter, (void*)("0x%04llX"));
ImPlot::SetupAxisFormat(ImAxis_X1, impl::IntegerAxisFormatter, const_cast<void*>(reinterpret_cast<const void*>("0x%04llX")));
ImPlot::SetupMouseText(ImPlotLocation_NorthEast);
// Set the axis limit to [first block : last block]
@@ -754,7 +754,7 @@ namespace hex {
ImPlotAxisFlags_Lock | ImPlotAxisFlags_NoHighlight | ImPlotAxisFlags_NoSideSwitch);
ImPlot::SetupAxisScale(ImAxis_Y1, ImPlotScale_Log10);
ImPlot::SetupAxesLimits(-1, 256, 1, double(*std::ranges::max_element(m_valueCounts)) * 1.1F, ImGuiCond_Always);
ImPlot::SetupAxisFormat(ImAxis_X1, impl::IntegerAxisFormatter, (void*)("0x%02llX"));
ImPlot::SetupAxisFormat(ImAxis_X1, impl::IntegerAxisFormatter, const_cast<void*>(reinterpret_cast<const void*>("0x%02llX")));
ImPlot::SetupAxisTicks(ImAxis_X1, 0, 255, 17);
ImPlot::SetupMouseText(ImPlotLocation_NorthEast);
@@ -854,7 +854,7 @@ namespace hex {
100.1F,
ImGuiCond_Always);
ImPlot::SetupLegend(ImPlotLocation_South, ImPlotLegendFlags_Horizontal | ImPlotLegendFlags_Outside);
ImPlot::SetupAxisFormat(ImAxis_X1, impl::IntegerAxisFormatter, (void*)("0x%04llX"));
ImPlot::SetupAxisFormat(ImAxis_X1, impl::IntegerAxisFormatter, const_cast<void*>(reinterpret_cast<const void*>("0x%04llX")));
ImPlot::SetupMouseText(ImPlotLocation_NorthEast);
constexpr static std::array Names = { "iscntrl", "isprint", "isspace", "isblank",

View File

@@ -37,7 +37,7 @@ namespace hex::plugin::builtin {
m_unit = Unit::Unitless;
} else {
std::tie(m_unit, m_multiplier) = parseUnit(value.substr(index));
value = value.substr(0, index);
value.resize(index);
}
} else {
m_unit = Unit::Unitless;

View File

@@ -105,9 +105,8 @@ namespace hex::plugin::builtin {
if (buffer.size() < Size)
return { };
auto format = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? hex::format("0x{{0:0{}X}}", Size * 2) : hex::format("0o{{0:0{}o}}", Size * 3));
return hex::format(format, bufferToInteger<T, Size>(buffer, endian));
const auto formatString = (style == Style::Decimal) ? "{0:d}" : ((style == Style::Hexadecimal) ? hex::format("0x{{0:0{}X}}", Size * 2) : hex::format("0o{{0:0{}o}}", Size * 3));
return hex::format(formatString, bufferToInteger<T, Size>(buffer, endian));
}
template<std::integral T, size_t Size = sizeof(T)>
@@ -371,7 +370,7 @@ namespace hex::plugin::builtin {
},
[](const std::string &value, std::endian endian) -> std::vector<u8> {
std::vector<u8> bytes;
auto wideString = wolv::util::utf8ToWstring(value.c_str());
auto wideString = wolv::util::utf8ToWstring(value);
if (!wideString.has_value())
return bytes;
@@ -733,7 +732,7 @@ namespace hex::plugin::builtin {
} else {
value = hex::format("{0:%a, %d.%m.%Y %H:%M:%S}", *time);
}
} catch (fmt::format_error &e) {
} catch (const fmt::format_error &e) {
value = "Invalid";
}

View File

@@ -199,9 +199,9 @@ namespace hex::plugin::builtin {
std::shared_ptr<pl::ptrn::Pattern> jsonToPattern(pl::core::Evaluator *evaluator, auto function) {
auto object = std::make_shared<pl::ptrn::PatternStruct>(evaluator, 0, 0, 0);
std::vector<std::shared_ptr<pl::ptrn::Pattern>> patterns;
try {
std::vector<std::shared_ptr<pl::ptrn::Pattern>> patterns;
jsonToPattern(evaluator, function(), patterns);
object->setEntries(patterns);
@@ -280,7 +280,6 @@ namespace hex::plugin::builtin {
auto bytes = params[0].toBytes();
auto encodingDefinition = params[1].toString();
std::string value;
EncodingFile encodingFile(EncodingFile::Type::Thingy, encodingDefinition);
auto pattern = std::make_shared<PatternEncodedString>(evaluator, evaluator->getReadOffset(), bytes.size(), 0);

View File

@@ -99,6 +99,7 @@ namespace hex::plugin::builtin {
socket.writeString(packet);
auto receivedPacket = socket.readString(6);
std::ignore = receivedPacket;
}
bool enableNoAckMode(const wolv::net::SocketClient &socket) {
@@ -157,7 +158,7 @@ namespace hex::plugin::builtin {
if (size <= CacheLineSize) {
std::scoped_lock lock(m_cacheLock);
const auto &cacheLine = std::find_if(m_cache.begin(), m_cache.end(), [&](auto &line) {
const auto &cacheLine = std::ranges::find_if(m_cache, [&](const auto &line) {
return line.address == alignedOffset;
});

View File

@@ -102,7 +102,7 @@ namespace hex::plugin::builtin {
if (!data.empty() && checksum != 0x00)
throw std::runtime_error("Checksum mismatch");
while (std::isspace(string[offset]) && offset < string.length())
while (offset < string.length() && std::isspace(string[offset]))
offset++;
// Construct region
@@ -145,7 +145,7 @@ namespace hex::plugin::builtin {
}
}
while (std::isspace(string[offset]) && offset < string.length())
while (offset < string.length() && std::isspace(string[offset]))
offset++;
}

View File

@@ -57,21 +57,21 @@ namespace hex::plugin::builtin {
return value;
};
enum class RecordType {
Header = 0x00,
Data16 = 0x01,
Data24 = 0x02,
Data32 = 0x03,
Reserved = 0x04,
Count16 = 0x05,
Count24 = 0x06,
StartAddress32 = 0x07,
StartAddress24 = 0x08,
StartAddress16 = 0x09,
} recordType;
bool endOfFile = false;
try {
enum class RecordType {
Header = 0x00,
Data16 = 0x01,
Data24 = 0x02,
Data32 = 0x03,
Reserved = 0x04,
Count16 = 0x05,
Count24 = 0x06,
StartAddress32 = 0x07,
StartAddress24 = 0x08,
StartAddress16 = 0x09,
} recordType;
bool endOfFile = false;
while (offset < string.length()) {
// Parse record start
if (c() != 'S')
@@ -159,7 +159,7 @@ namespace hex::plugin::builtin {
break;
}
while (std::isspace(string[offset]) && offset < string.length())
while (offset < string.length() && std::isspace(string[offset]))
offset++;
}
} catch (const std::runtime_error &e) {

View File

@@ -13,7 +13,6 @@ namespace hex::plugin::builtin {
void drawColorPicker() {
static std::array<float, 4> pickedColor = { 0 };
static std::string rgba8;
struct BitValue {
int bits;

View File

@@ -9,8 +9,6 @@
namespace hex::plugin::builtin {
void drawEuclidianAlgorithm() {
static u64 a, b;
static i64 gcdResult = 0;
static i64 lcmResult = 0;
static i64 p = 0, q = 0;
@@ -37,6 +35,8 @@ namespace hex::plugin::builtin {
ImGui::NewLine();
if (ImGuiExt::BeginBox()) {
static u64 a = 0, b = 0;
bool hasChanged = false;
hasChanged = ImGui::InputScalar("A", ImGuiDataType_U64, &a) || hasChanged;
hasChanged = ImGui::InputScalar("B", ImGuiDataType_U64, &b) || hasChanged;

View File

@@ -30,7 +30,7 @@ namespace hex::plugin::builtin {
if (ImGui::BeginListBox("##files", { -FLT_MIN, 10 * ImGui::GetTextLineHeightWithSpacing() })) {
u32 index = 0;
for (auto &file : files) {
for (const auto &file : files) {
if (ImGui::Selectable(wolv::util::toUTF8String(file).c_str(), index == selectedIndex))
selectedIndex = index;
index++;
@@ -41,7 +41,7 @@ namespace hex::plugin::builtin {
ImGui::TableNextColumn();
ImGui::BeginDisabled(selectedIndex <= 0);
ImGui::BeginDisabled(selectedIndex == 0);
{
if (ImGui::ArrowButton("move_up", ImGuiDir_Up)) {
std::iter_swap(files.begin() + selectedIndex, files.begin() + selectedIndex - 1);

View File

@@ -74,9 +74,9 @@ namespace hex::plugin::builtin {
i64 precision;
} ieee754 = {};
std::string specialNumbers[] = {
"inf" , "Inf", "INF" , "nan" , "Nan" , "NAN",
"qnan","Qnan", "QNAN", "snan", "Snan", "SNAN"
constexpr static std::array SpecialNumbers = {
"inf" , "Inf", "INF" , "nan" , "Nan" , "NAN",
"qnan","Qnan", "QNAN", "snan", "Snan", "SNAN"
};
@@ -345,7 +345,7 @@ namespace hex::plugin::builtin {
}
};
const static auto FloatToBits = [&specialNumbers](IEEE754 &ieee754, std::string decimalFloatingPointNumberString, int totalBitCount) {
const static auto FloatToBits = [](IEEE754 &ieee754, std::string decimalFloatingPointNumberString, int totalBitCount) {
// Always obtain sign first.
if (decimalFloatingPointNumberString[0] == '-') {
@@ -362,7 +362,7 @@ namespace hex::plugin::builtin {
// Detect and use special numbers.
for (u32 i = 0; i < 12; i++) {
if (decimalFloatingPointNumberString == specialNumbers[i]) {
if (decimalFloatingPointNumberString == SpecialNumbers[i]) {
inputType = InputType(i/3);
matchFound = true;
break;

View File

@@ -238,15 +238,15 @@ namespace hex::plugin::decompress {
if (blockSize == ZSTD_CONTENTSIZE_UNKNOWN) {
// Data uses stream compression
ZSTD_inBuffer dataIn = { (void*)source, sourceSize, 0 };
ZSTD_inBuffer dataIn = { static_cast<const void*>(source), sourceSize, 0 };
size_t outSize = ZSTD_DStreamOutSize();
std::vector<u8> outVec(outSize);
const u8* out = outVec.data();
u8* out = outVec.data();
size_t lastRet = 0;
while (dataIn.pos < dataIn.size) {
ZSTD_outBuffer dataOut = { (void*)out, outSize, 0 };
ZSTD_outBuffer dataOut = { reinterpret_cast<void*>(out), outSize, 0 };
size_t ret = ZSTD_decompressStream(dctx, &dataOut, &dataIn);
if (ZSTD_isError(ret)) {

View File

@@ -111,10 +111,6 @@ namespace hex::plugin::disasm {
class ArchitectureARM64 : public CapstoneArchitecture {
public:
ArchitectureARM64(cs_mode mode = cs_mode(0)) : CapstoneArchitecture(BuiltinArchitecture::ARM64, mode) {}
void drawSettings() override {
CapstoneArchitecture::drawSettings();
}
};
class ArchitectureMIPS : public CapstoneArchitecture {
@@ -213,19 +209,11 @@ namespace hex::plugin::disasm {
class ArchitectureSystemZ : public CapstoneArchitecture {
public:
ArchitectureSystemZ(cs_mode mode = cs_mode(0)) : CapstoneArchitecture(BuiltinArchitecture::SYSZ, mode) {}
void drawSettings() override {
CapstoneArchitecture::drawSettings();
}
};
class ArchitectureXCore : public CapstoneArchitecture {
public:
ArchitectureXCore(cs_mode mode = cs_mode(0)) : CapstoneArchitecture(BuiltinArchitecture::XCORE, mode) {}
void drawSettings() override {
CapstoneArchitecture::drawSettings();
}
};
class ArchitectureM68K : public CapstoneArchitecture {
@@ -262,10 +250,6 @@ namespace hex::plugin::disasm {
class ArchitectureTMS320C64X : public CapstoneArchitecture {
public:
ArchitectureTMS320C64X(cs_mode mode = cs_mode(0)) : CapstoneArchitecture(BuiltinArchitecture::TMS320C64X, mode) {}
void drawSettings() override {
CapstoneArchitecture::drawSettings();
}
};
class ArchitectureM680X : public CapstoneArchitecture {
public:
@@ -305,10 +289,6 @@ namespace hex::plugin::disasm {
class ArchitectureEVM : public CapstoneArchitecture {
public:
ArchitectureEVM(cs_mode mode = cs_mode(0)) : CapstoneArchitecture(BuiltinArchitecture::EVM, mode) {}
void drawSettings() override {
CapstoneArchitecture::drawSettings();
}
};
#if CS_API_MAJOR >= 5
@@ -316,10 +296,6 @@ namespace hex::plugin::disasm {
class ArchitectureWASM : public CapstoneArchitecture {
public:
ArchitectureWASM(cs_mode mode = cs_mode(0)) : CapstoneArchitecture(BuiltinArchitecture::WASM, mode) {}
void drawSettings() override {
CapstoneArchitecture::drawSettings();
}
};
class ArchitectureRISCV : public CapstoneArchitecture {

View File

@@ -47,7 +47,7 @@ namespace hex::script::loader {
if (library == "cimgui") {
return getExport<void*>(ImHexApi::System::getLibImHexModuleHandle(), symbolName);
} else if (library == "ImHex") {
return getExport<void*>(hex::getContainingModule((void*)&pInvokeOverride), symbolName);
return getExport<void*>(hex::getContainingModule(reinterpret_cast<void*>(&pInvokeOverride)), symbolName);
}
return nullptr;
@@ -141,9 +141,9 @@ namespace hex::script::loader {
}
#if defined (OS_WINDOWS)
hostfxr_set_runtime_property_value(ctx, STRING("PINVOKE_OVERRIDE"), utf8ToUtf16(hex::format("{}", (void*)pInvokeOverride)).c_str());
hostfxr_set_runtime_property_value(ctx, STRING("PINVOKE_OVERRIDE"), utf8ToUtf16(hex::format("{}", reinterpret_cast<void*>(pInvokeOverride))).c_str());
#else
hostfxr_set_runtime_property_value(ctx, STRING("PINVOKE_OVERRIDE"), hex::format("{}", (void*)pInvokeOverride).c_str());
hostfxr_set_runtime_property_value(ctx, STRING("PINVOKE_OVERRIDE"), hex::format("{}", reinterpret_cast<void*>(pInvokeOverride)).c_str());
#endif
hostfxr_set_error_writer([](const char_t *message) {

View File

@@ -74,6 +74,7 @@ namespace hex::ui {
m_selectedFiles.insert(fileIt);
} else {
if (selected) {
// cppcheck-suppress eraseDereference
m_selectedFiles.erase(fileIt);
} else {
m_selectedFiles.insert(fileIt);

View File

@@ -360,7 +360,7 @@ namespace hex::ui {
bool shouldReset = false;
if (ImGui::Button(hex::format(" {} {}", ICON_VS_EYE_WATCH, value).c_str(), ImVec2(width, ImGui::GetTextLineHeight()))) {
auto previousPattern = m_currVisualizedPattern;
const auto *previousPattern = m_currVisualizedPattern;
m_currVisualizedPattern = &pattern;
auto lastVisualizerError = m_visualizerDrawer.getLastVisualizerError();
if (!lastVisualizerError.empty() || m_currVisualizedPattern != previousPattern)
@@ -575,7 +575,7 @@ namespace hex::ui {
auto value = pattern.getValue();
auto valueString = pattern.toString();
if (auto enumPattern = dynamic_cast<pl::ptrn::PatternBitfieldFieldEnum*>(&pattern); enumPattern != nullptr) {
if (const auto *enumPattern = dynamic_cast<pl::ptrn::PatternBitfieldFieldEnum*>(&pattern); enumPattern != nullptr) {
if (ImGui::BeginCombo("##Enum", pattern.getFormattedValue().c_str())) {
auto currValue = pattern.getValue().toUnsigned();
for (auto &[name, enumValue] : enumPattern->getEnumValues()) {

View File

@@ -941,7 +941,7 @@ namespace hex::plugin::visualizers {
s_shouldReset = true;
processInputEvents(s_rotation, s_translation, s_scaling, s_nearLimit, s_farLimit);
auto *iterable = dynamic_cast<pl::ptrn::IIterable*>(indicesPattern.get());
const auto *iterable = dynamic_cast<pl::ptrn::IIterable*>(indicesPattern.get());
if (iterable != nullptr && iterable->getEntryCount() > 0) {
auto content = iterable->getEntry(0);
while (content->getSize() == 0) {

View File

@@ -31,7 +31,7 @@ namespace hex::plugin::visualizers {
bitfield->forEachEntry(0, bitfield->getEntryCount(), [&](u64, pl::ptrn::Pattern *entry) {
size_t bitSize;
if (auto bitfieldField = dynamic_cast<pl::ptrn::PatternBitfieldField*>(entry); bitfieldField != nullptr)
if (const auto *bitfieldField = dynamic_cast<pl::ptrn::PatternBitfieldField*>(entry); bitfieldField != nullptr)
bitSize = bitfieldField->getBitSize();
else
bitSize = entry->getSize() * 8;

View File

@@ -9,7 +9,7 @@
namespace hex::plugin::visualizers {
std::vector<u32> getIndices(pl::ptrn::Pattern *colorTablePattern, u64 width, u64 height);
ImGuiExt::Texture getTexture(pl::ptrn::Pattern *colorTablePattern, std::vector<u32>& indices, u64 width, u64 height);
ImGuiExt::Texture getTexture(pl::ptrn::Pattern *colorTablePattern, const std::vector<u32> &indices, u64 width, u64 height);
void drawImageVisualizer(pl::ptrn::Pattern &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
@@ -75,7 +75,7 @@ namespace hex::plugin::visualizers {
}
}
ImGuiExt::Texture getTexture(pl::ptrn::Pattern *colorTablePattern, std::vector<u32>& indices, u64 width, u64 height) {
ImGuiExt::Texture getTexture(pl::ptrn::Pattern *colorTablePattern, const std::vector<u32> &indices, u64 width, u64 height) {
std::vector<u32> colorTable = patternToArray<u32>(colorTablePattern);
auto colorCount = colorTable.size();
auto indexCount = indices.size();
@@ -89,7 +89,7 @@ namespace hex::plugin::visualizers {
image[i] = colorTable[index];
}
void *tmp = image.data();
ImU8 *data = static_cast<ImU8 *>(tmp);
auto *data = static_cast<const ImU8 *>(tmp);
ImGuiExt::Texture texture = ImGuiExt::Texture::fromBitmap(data, indexCount*4, width, height, ImGuiExt::Texture::Filter::Nearest);
return texture;
}
@@ -97,9 +97,9 @@ namespace hex::plugin::visualizers {
std::vector<u32> getIndices(pl::ptrn::Pattern *pattern, u64 width, u64 height) {
auto indexCount = width * height / pattern->getSize();
std::vector<u32> indices;
auto *iterable = dynamic_cast<pl::ptrn::IIterable *>(pattern);
const auto *iterable = dynamic_cast<pl::ptrn::IIterable *>(pattern);
if (iterable == nullptr || iterable->getEntryCount() <= 0)
if (iterable == nullptr || iterable->getEntryCount() == 0)
return indices;
auto content = iterable->getEntry(0);
auto byteCount = content->getSize();

View File

@@ -86,6 +86,8 @@ namespace hex::plugin::yara {
YaraRule::Rule newRule;
newRule.identifier = rule->identifier;
newRule.matches.push_back({ "", Region::Invalid(), true });
resultContext.matchedRules.emplace_back(std::move(newRule));
}
break;
@@ -171,7 +173,7 @@ namespace hex::plugin::yara {
return context.buffer.data();
};
iterator.file_size = [](YR_MEMORY_BLOCK_ITERATOR *iterator) -> u64 {
auto &context = *static_cast<ScanContext *>(iterator->context);
const auto &context = *static_cast<ScanContext *>(iterator->context);
return context.region.size;
};