diff --git a/README.md b/README.md index f51f9d879..bbd9e82cd 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ If you like my work, please consider supporting me on GitHub Sponsors, Patreon o
Data Inspector - - Interpreting data as many different types with endianess, decimal, hexadecimal and octal support and bit inversion + - Interpreting data as many different types with endianness, decimal, hexadecimal and octal support and bit inversion - Unsigned and signed integers (8, 16, 24, 32, 48, 64 bit) - Floats (16, 32, 64 bit) - Signed and Unsigned LEB128 @@ -158,7 +158,7 @@ If you like my work, please consider supporting me on GitHub Sponsors, Patreon o - Numeric Value search - Search for signed/unsigned integers and floats - Search for ranges of values - - Option to specify size and endianess + - Option to specify size and endianness - Option to ignore unaligned values
diff --git a/lib/libimhex/include/hex/helpers/utils.hpp b/lib/libimhex/include/hex/helpers/utils.hpp index 31f409e6b..e87281b55 100644 --- a/lib/libimhex/include/hex/helpers/utils.hpp +++ b/lib/libimhex/include/hex/helpers/utils.hpp @@ -152,7 +152,7 @@ namespace hex { using SizeType = typename SizeTypeImpl::Type; template - [[nodiscard]] constexpr T changeEndianess(const T &value, size_t size, std::endian endian) { + [[nodiscard]] constexpr T changeEndianness(const T &value, size_t size, std::endian endian) { if (endian == std::endian::native) return value; @@ -172,8 +172,8 @@ namespace hex { } template - [[nodiscard]] constexpr T changeEndianess(const T &value, std::endian endian) { - return changeEndianess(value, sizeof(value), endian); + [[nodiscard]] constexpr T changeEndianness(const T &value, std::endian endian) { + return changeEndianness(value, sizeof(value), endian); } [[nodiscard]] constexpr u128 bitmask(u8 bits) { diff --git a/lib/libimhex/source/api/theme_manager.cpp b/lib/libimhex/source/api/theme_manager.cpp index 0162e40da..be3f4ee75 100644 --- a/lib/libimhex/source/api/theme_manager.cpp +++ b/lib/libimhex/source/api/theme_manager.cpp @@ -73,7 +73,7 @@ namespace hex { if (color == 0x00000000) return ImVec4(0, 0, 0, -1); - return ImColor(hex::changeEndianess(color, std::endian::big)); + return ImColor(hex::changeEndianness(color, std::endian::big)); } nlohmann::json ThemeManager::exportCurrentTheme(const std::string &name) { @@ -90,7 +90,7 @@ namespace hex { for (const auto &[key, value] : handler.colorMap) { auto color = handler.getFunction(value); - theme["colors"][type][key] = fmt::format("#{:08X}", hex::changeEndianess(u32(color), std::endian::big)); + theme["colors"][type][key] = fmt::format("#{:08X}", hex::changeEndianness(u32(color), std::endian::big)); } } diff --git a/lib/libimhex/source/helpers/patches.cpp b/lib/libimhex/source/helpers/patches.cpp index 40faf230f..f60a03286 100644 --- a/lib/libimhex/source/helpers/patches.cpp +++ b/lib/libimhex/source/helpers/patches.cpp @@ -138,7 +138,7 @@ namespace hex { result.push_back(addressBytes[2]); result.push_back(addressBytes[1]); result.push_back(addressBytes[0]); - pushBytesBack(result, changeEndianess(bytes.size(), std::endian::big)); + pushBytesBack(result, changeEndianness(bytes.size(), std::endian::big)); for (auto byte : bytes) result.push_back(byte); @@ -189,7 +189,7 @@ namespace hex { result.push_back(addressBytes[2]); result.push_back(addressBytes[1]); result.push_back(addressBytes[0]); - pushBytesBack(result, changeEndianess(bytes.size(), std::endian::big)); + pushBytesBack(result, changeEndianness(bytes.size(), std::endian::big)); for (auto byte : bytes) result.push_back(byte); diff --git a/plugins/builtin/source/content/data_inspector.cpp b/plugins/builtin/source/content/data_inspector.cpp index 73433b031..97219242f 100644 --- a/plugins/builtin/source/content/data_inspector.cpp +++ b/plugins/builtin/source/content/data_inspector.cpp @@ -87,7 +87,7 @@ namespace hex::plugin::builtin { T value = 0x00; std::memcpy(&value, buffer.data(), std::min(sizeof(T), Size)); - return hex::format(format, hex::changeEndianess(value, Size, endian)); + return hex::format(format, hex::changeEndianness(value, Size, endian)); } template @@ -99,7 +99,7 @@ namespace hex::plugin::builtin { T value = 0x00; std::memcpy(&value, buffer.data(), std::min(sizeof(T), Size)); - auto number = hex::changeEndianess(value, Size, endian); + auto number = hex::changeEndianness(value, Size, endian); if (Size != sizeof(T)) number = hex::signExtend(Size * 8, number); @@ -222,7 +222,7 @@ namespace hex::plugin::builtin { const auto formatString = style == Style::Hexadecimal ? "{0:a}" : "{0:G}"; - auto value = hex::format(formatString, float16ToFloat32(hex::changeEndianess(result, endian))); + auto value = hex::format(formatString, float16ToFloat32(hex::changeEndianness(result, endian))); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; } @@ -235,7 +235,7 @@ namespace hex::plugin::builtin { const auto formatString = style == Style::Hexadecimal ? "{0:a}" : "{0:G}"; - auto value = hex::format(formatString, hex::changeEndianess(result, endian)); + auto value = hex::format(formatString, hex::changeEndianness(result, endian)); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; }, stringToFloat @@ -248,7 +248,7 @@ namespace hex::plugin::builtin { const auto formatString = style == Style::Hexadecimal ? "{0:a}" : "{0:G}"; - auto value = hex::format(formatString, hex::changeEndianess(result, endian)); + auto value = hex::format(formatString, hex::changeEndianness(result, endian)); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; }, stringToFloat @@ -261,7 +261,7 @@ namespace hex::plugin::builtin { const auto formatString = style == Style::Hexadecimal ? "{0:a}" : "{0:G}"; - auto value = hex::format(formatString, hex::changeEndianess(result, endian)); + auto value = hex::format(formatString, hex::changeEndianness(result, endian)); return [value] { ImGui::TextUnformatted(value.c_str()); return value; }; }, stringToFloat @@ -346,7 +346,7 @@ namespace hex::plugin::builtin { wchar_t wideChar = '\x00'; std::memcpy(&wideChar, buffer.data(), std::min(sizeof(wchar_t), buffer.size())); - auto c = hex::changeEndianess(wideChar, endian); + auto c = hex::changeEndianness(wideChar, endian); std::wstring_convert> converter("Invalid"); @@ -435,7 +435,7 @@ namespace hex::plugin::builtin { ImHexApi::Provider::get()->read(currSelection->address, stringBuffer.data(), stringBuffer.size()); for (auto &c : stringBuffer) - c = hex::changeEndianess(c, endian); + c = hex::changeEndianness(c, endian); auto it = std::remove_if(buffer.begin(), buffer.end(), [](auto c) { return c == 0x00; }); @@ -467,7 +467,7 @@ namespace hex::plugin::builtin { ContentRegistry::DataInspector::add("hex.builtin.inspector.time32", sizeof(u32), [](auto buffer, auto endian, auto style) { hex::unused(style); - auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast(buffer.data()), endian); + auto endianAdjustedTime = hex::changeEndianness(*reinterpret_cast(buffer.data()), endian); std::string value; try { @@ -482,7 +482,7 @@ namespace hex::plugin::builtin { ContentRegistry::DataInspector::add("hex.builtin.inspector.time64", sizeof(u64), [](auto buffer, auto endian, auto style) { hex::unused(style); - auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast(buffer.data()), endian); + auto endianAdjustedTime = hex::changeEndianness(*reinterpret_cast(buffer.data()), endian); std::string value; try { @@ -499,7 +499,7 @@ namespace hex::plugin::builtin { ContentRegistry::DataInspector::add("hex.builtin.inspector.time", sizeof(time_t), [](auto buffer, auto endian, auto style) { hex::unused(style); - auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast(buffer.data()), endian); + auto endianAdjustedTime = hex::changeEndianness(*reinterpret_cast(buffer.data()), endian); std::string value; try { @@ -530,7 +530,7 @@ namespace hex::plugin::builtin { DOSDate date = { }; std::memcpy(&date, buffer.data(), sizeof(DOSDate)); - date = hex::changeEndianess(date, endian); + date = hex::changeEndianness(date, endian); auto value = hex::format("{}/{}/{}", date.day, date.month, date.year + 1980); @@ -542,7 +542,7 @@ namespace hex::plugin::builtin { DOSTime time = { }; std::memcpy(&time, buffer.data(), sizeof(DOSTime)); - time = hex::changeEndianess(time, endian); + time = hex::changeEndianness(time, endian); auto value = hex::format("{:02}:{:02}:{:02}", time.hours, time.minutes, time.seconds * 2); @@ -555,10 +555,10 @@ namespace hex::plugin::builtin { GUID guid = { }; std::memcpy(&guid, buffer.data(), sizeof(GUID)); auto value = hex::format("{}{{{:08X}-{:04X}-{:04X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}}}", - (hex::changeEndianess(guid.data3, endian) >> 12) <= 5 && ((guid.data4[0] >> 4) >= 8 || (guid.data4[0] >> 4) == 0) ? "" : "Invalid ", - hex::changeEndianess(guid.data1, endian), - hex::changeEndianess(guid.data2, endian), - hex::changeEndianess(guid.data3, endian), + (hex::changeEndianness(guid.data3, endian) >> 12) <= 5 && ((guid.data4[0] >> 4) >= 8 || (guid.data4[0] >> 4) == 0) ? "" : "Invalid ", + hex::changeEndianness(guid.data1, endian), + hex::changeEndianness(guid.data2, endian), + hex::changeEndianness(guid.data3, endian), guid.data4[0], guid.data4[1], guid.data4[2], @@ -574,7 +574,7 @@ namespace hex::plugin::builtin { ContentRegistry::DataInspector::add("hex.builtin.inspector.rgba8", sizeof(u32), [](auto buffer, auto endian, auto style) { hex::unused(style); - ImColor value(hex::changeEndianess(*reinterpret_cast(buffer.data()), endian)); + ImColor value(hex::changeEndianness(*reinterpret_cast(buffer.data()), endian)); auto copyValue = hex::format("#{:02X}{:02X}{:02X}{:02X}", u8(0xFF * (value.Value.x)), u8(0xFF * (value.Value.y)), u8(0xFF * (value.Value.z)), u8(0xFF * (value.Value.w))); @@ -587,7 +587,7 @@ namespace hex::plugin::builtin { ContentRegistry::DataInspector::add("hex.builtin.inspector.rgb565", sizeof(u16), [](auto buffer, auto endian, auto style) { hex::unused(style); - auto value = hex::changeEndianess(*reinterpret_cast(buffer.data()), endian); + auto value = hex::changeEndianness(*reinterpret_cast(buffer.data()), endian); ImColor color((value & 0x1F) << 3, ((value >> 5) & 0x3F) << 2, ((value >> 11) & 0x1F) << 3, 0xFF); auto copyValue = hex::format("#{:02X}{:02X}{:02X}", u8(0xFF * (color.Value.x)), u8(0xFF * (color.Value.y)), u8(0xFF * (color.Value.z)), 0xFF); diff --git a/plugins/builtin/source/content/popups/hex_editor/popup_hex_editor_find.cpp b/plugins/builtin/source/content/popups/hex_editor/popup_hex_editor_find.cpp index bfded1755..373e51aea 100644 --- a/plugins/builtin/source/content/popups/hex_editor/popup_hex_editor_find.cpp +++ b/plugins/builtin/source/content/popups/hex_editor/popup_hex_editor_find.cpp @@ -251,7 +251,7 @@ namespace hex::plugin::builtin { std::endian endian = (endianness == Endianness::Little) ? std::endian::little : std::endian::big; - value = hex::changeEndianess(value, endian); + value = hex::changeEndianness(value, endian); } }; diff --git a/plugins/builtin/source/content/views/view_bookmarks.cpp b/plugins/builtin/source/content/views/view_bookmarks.cpp index e22177552..0106f60bd 100644 --- a/plugins/builtin/source/content/views/view_bookmarks.cpp +++ b/plugins/builtin/source/content/views/view_bookmarks.cpp @@ -172,7 +172,7 @@ namespace hex::plugin::builtin { result += "## Bookmarks\n\n"; for (const auto &[bookmark, editor] : bookmarks) { - result += hex::format("### {} [0x{:04X} - 0x{:04X}]\n\n", hex::changeEndianess(bookmark.color, std::endian::big) >> 8, bookmark.name, bookmark.region.getStartAddress(), bookmark.region.getEndAddress()); + result += hex::format("### {} [0x{:04X} - 0x{:04X}]\n\n", hex::changeEndianness(bookmark.color, std::endian::big) >> 8, bookmark.name, bookmark.region.getStartAddress(), bookmark.region.getEndAddress()); for (const auto &line : hex::splitString(bookmark.comment, "\n")) result += hex::format("> {}\n", line); diff --git a/plugins/builtin/source/content/views/view_find.cpp b/plugins/builtin/source/content/views/view_find.cpp index a977a4bea..7ef1ff600 100644 --- a/plugins/builtin/source/content/views/view_find.cpp +++ b/plugins/builtin/source/content/views/view_find.cpp @@ -160,7 +160,7 @@ namespace hex::plugin::builtin { T value = 0x00; std::memcpy(&value, bytes.data(), bytes.size()); - value = hex::changeEndianess(value, bytes.size(), endian); + value = hex::changeEndianness(value, bytes.size(), endian); if (std::signed_integral) value = hex::signExtend(bytes.size() * 8, value); @@ -456,7 +456,7 @@ namespace hex::plugin::builtin { DecayedType value = 0; reader.read(address, reinterpret_cast(&value), size); - value = hex::changeEndianess(value, size, settings.endian); + value = hex::changeEndianness(value, size, settings.endian); return value >= minValue && value <= maxValue; }, min); diff --git a/plugins/builtin/source/content/views/view_hex_editor.cpp b/plugins/builtin/source/content/views/view_hex_editor.cpp index 302e41ede..85e4c4e85 100644 --- a/plugins/builtin/source/content/views/view_hex_editor.cpp +++ b/plugins/builtin/source/content/views/view_hex_editor.cpp @@ -1141,8 +1141,8 @@ namespace hex::plugin::builtin { u64 value = 0; provider->read(selection->getStartAddress(), &value, selection->getSize()); - auto littleEndianValue = hex::changeEndianess(value, selection->size, std::endian::little); - auto bigEndianValue = hex::changeEndianess(value, selection->size, std::endian::big); + auto littleEndianValue = hex::changeEndianness(value, selection->size, std::endian::little); + auto bigEndianValue = hex::changeEndianness(value, selection->size, std::endian::big); auto canJumpTo = [provider](u64 value) { return (value >= provider->getBaseAddress()) && (value < (provider->getBaseAddress() + provider->getActualSize())); diff --git a/plugins/ui/source/ui/hex_editor.cpp b/plugins/ui/source/ui/hex_editor.cpp index dedfa97b1..5725d5957 100644 --- a/plugins/ui/source/ui/hex_editor.cpp +++ b/plugins/ui/source/ui/hex_editor.cpp @@ -914,12 +914,12 @@ namespace hex::ui { auto &visualizers = ContentRegistry::HexEditor::impl::getVisualizers(); { - bool hasEndianess = m_currDataVisualizer->getBytesPerCell() > 1; + bool hasEndianness = m_currDataVisualizer->getBytesPerCell() > 1; - if (!hasEndianess) + if (!hasEndianness) m_dataVisualizerEndianness = std::endian::native; - ImGui::BeginDisabled(!hasEndianess); + ImGui::BeginDisabled(!hasEndianness); { int sliderPos = m_dataVisualizerEndianness == std::endian::little ? 0 : 1; ImGui::PushItemWidth(60_scaled); diff --git a/tests/algorithms/source/endian.cpp b/tests/algorithms/source/endian.cpp index 80a851128..d97fa1f2a 100644 --- a/tests/algorithms/source/endian.cpp +++ b/tests/algorithms/source/endian.cpp @@ -3,7 +3,7 @@ #include TEST_SEQUENCE("32BitIntegerEndianSwap") { - TEST_ASSERT(hex::changeEndianess(0xAABBCCDD, std::endian::big) == 0xDDCCBBAA); + TEST_ASSERT(hex::changeEndianness(0xAABBCCDD, std::endian::big) == 0xDDCCBBAA); TEST_SUCCESS(); }; @@ -12,8 +12,8 @@ TEST_SEQUENCE("64BitFloatEndianSwap") { double floatValue = 1234.5; u64 integerValue = reinterpret_cast(floatValue); - double swappedFloatValue = hex::changeEndianess(floatValue, std::endian::big); - u64 swappedIntegerValue = hex::changeEndianess(integerValue, std::endian::big); + double swappedFloatValue = hex::changeEndianness(floatValue, std::endian::big); + u64 swappedIntegerValue = hex::changeEndianness(integerValue, std::endian::big); TEST_ASSERT(std::memcmp(&floatValue, &integerValue, 8) == 0 && std::memcmp(&swappedFloatValue, &swappedIntegerValue, 8) == 0);