Skip to content

Update ImHex to latest, preserving additions#1

Open
the-claw wants to merge 423 commits into
davidgiven:masterfrom
the-claw:master
Open

Update ImHex to latest, preserving additions#1
the-claw wants to merge 423 commits into
davidgiven:masterfrom
the-claw:master

Conversation

@the-claw

@the-claw the-claw commented Jun 29, 2026

Copy link
Copy Markdown

Updates the ImHex codebase to the latest master version from https://github.com/WerWolv/ImHex to address a bug in imgui which has been recently resolved in both imgui and ImHex.

This PR simply merges in the latest master changes from WerWolv/ImHex - there were no conflicts to resolve or anything, so to avoid a lengthy review you could just merge the changes into davidgiven/ImHex yourself and disregard this PR.

See the companion PR for fixes to incompatibilities between fluxengine's Gui2 code and the current ImHex version.

WerWolv and others added 30 commits December 17, 2025 16:56
<!--
Please provide as much information as possible about what your PR aims
to do.
PRs with no description will most likely be closed until more
information is provided.
If you're planing on changing fundamental behaviour or add big new
features, please open a GitHub Issue first before starting to work on
it.
If it's not something big and you still want to contact us about it,
feel free to do so !
-->

### Problem description
<!-- Describe the bug that you fixed/feature request that you
implemented, or link to an existing issue describing it -->

### Implementation description
<!-- Explain what you did to correct the problem -->

### Screenshots
<!-- If your change is visual, take a screenshot showing it. Ideally,
make before/after sceenshots -->

### Additional things
<!-- Anything else you would like to say -->
…olv#2574)

<!--
Please provide as much information as possible about what your PR aims
to do.
PRs with no description will most likely be closed until more
information is provided.
If you're planing on changing fundamental behaviour or add big new
features, please open a GitHub Issue first before starting to work on
it.
If it's not something big and you still want to contact us about it,
feel free to do so !
-->

### Problem description
<!-- Describe the bug that you fixed/feature request that you
implemented, or link to an existing issue describing it -->

### Implementation description
<!-- Explain what you did to correct the problem -->

### Screenshots
<!-- If your change is visual, take a screenshot showing it. Ideally,
make before/after sceenshots -->

### Additional things
<!-- Anything else you would like to say -->
(cherry picked from commit 5a85356)
<!--
Please provide as much information as possible about what your PR aims
to do.
PRs with no description will most likely be closed until more
information is provided.
If you're planing on changing fundamental behaviour or add big new
features, please open a GitHub Issue first before starting to work on
it.
If it's not something big and you still want to contact us about it,
feel free to do so !
-->

### Problem description
<!-- Describe the bug that you fixed/feature request that you
implemented, or link to an existing issue describing it -->

### Implementation description
<!-- Explain what you did to correct the problem -->

### Screenshots
<!-- If your change is visual, take a screenshot showing it. Ideally,
make before/after sceenshots -->

### Additional things
<!-- Anything else you would like to say -->
<!--
Please provide as much information as possible about what your PR aims
to do.
PRs with no description will most likely be closed until more
information is provided.
If you're planing on changing fundamental behaviour or add big new
features, please open a GitHub Issue first before starting to work on
it.
If it's not something big and you still want to contact us about it,
feel free to do so !
-->

### Problem description
<!-- Describe the bug that you fixed/feature request that you
implemented, or link to an existing issue describing it -->

### Implementation description
<!-- Explain what you did to correct the problem -->

### Screenshots
<!-- If your change is visual, take a screenshot showing it. Ideally,
make before/after sceenshots -->

### Additional things
<!-- Anything else you would like to say -->
WerWolv and others added 28 commits April 20, 2026 23:28
The problem is caused by calculating space used by strings using
string.length() which only works if every char in the string is encoded
in 1 byte. The wrongly calculated space is then used to truncate the
string at the wrong place. Finally, the wrongly calculated space is used
to align the log entries which results in misalignment. The fix consists
on counting utf-8 characters to calculate the spaces and using a
function designed to work on utf-8 strings that returns sub-stings.

A further problem with alignment was caused when using CJK chars that
are wider than regular half-width characters which throws the space
calculations off. This was fixed by detecting when CJK glyphs are being
used and adjusting the sizes using a reasonable approximation that 1 CJK
char ~ 1.75 half-width chars.

Compare the two images. Before the PR:

<img width="1665" height="858" alt="zoomit"
src="https://github.com/user-attachments/assets/9d1a467d-a0fa-4cf6-882f-51712044234f"
/>

and after the PR: 

<img width="1925" height="863" alt="after"
src="https://github.com/user-attachments/assets/bb905f79-8bb5-4bd3-85b5-fb36327bc19b"
/>

Note how the utf-8 strings are truncated more than they should and that
for those same entries the alignment is lost but are not with the
changes. The image shows how CJK glyphs are handled.
…erWolv#2718)

<!--
Please provide as much information as possible about what your PR aims
to do.
PRs with no description will most likely be closed until more
information is provided.
If you're planing on changing fundamental behaviour or add big new
features, please open a GitHub Issue first before starting to work on
it.
If it's not something big and you still want to contact us about it,
feel free to do so !
-->

### Problem description
Commit
WerWolv@f813656
introduced a nullptr dereference that happens on the first frame of a
provider being opened.

```
[12:03:47] [INFO]  [main | Main]                Switching to workspace 'Default'
Process 89715 stopped
* thread #1, name = 'ImHex 🔍', stop reason = signal SIGSEGV: address not mapped to object (fault address=0x0)
    frame #0: 0x00007fffcdd43958 ui.hexpluglib`::drawEditor() at hex_editor.cpp:648:46
   645 	                ImGui::TableSetupScrollFreeze(0, 2);
   646 	
   647 	                // Row address column
-> 648 	                u64 maxAddress = m_provider->getActualSize();
    	                                             ^
   649 	                if (maxAddress > 0)
   650 	                    maxAddress--;
   651 	                if ((m_scrollPosition + m_visibleRowCount) * bytesPerRow < maxAddress)
(lldb) bt
* thread #1, name = 'ImHex 🔍', stop reason = signal SIGSEGV: address not mapped to object (fault address=0x0)
  * frame #0: 0x00007fffcdd43958 ui.hexpluglib`::drawEditor() at hex_editor.cpp:648:46
    frame #1: 0x00007fffcdd4954b ui.hexpluglib`::draw() at hex_editor.cpp:1409:15
    frame WerWolv#2: 0x00007fffdc01eb21 diffing.hexplug`::drawDiffColumn() at view_diff.cpp:64:30
    frame WerWolv#3: 0x00007fffdc01d56d diffing.hexplug`::drawContent() at view_diff.cpp:271:28
    frame WerWolv#4: 0x00007ffff7af7413 libimhex.so.1.39.0.WIP`::draw() at view.cpp:201:23
    frame WerWolv#5: 0x0000555555593e7d imhex`::frame() at window.cpp:759:23
    frame WerWolv#6: 0x000055555559237d imhex`hex::Window::fullFrame() at window.cpp:200:19
    frame WerWolv#7: 0x00005555555948b5 imhex`::loop() at window.cpp:297:19
    frame WerWolv#8: 0x00005555555c211c imhex`::runImHex() at desktop.cpp:54:28
    frame WerWolv#9: 0x00005555555836a6 imhex`main at main.cpp:73:12
    frame WerWolv#10: 0x00007ffff682f43b libc.so.6`___lldb_unnamed_symbol_2b3c0 + 123
    frame WerWolv#11: 0x00007ffff682f4eb libc.so.6`__libc_start_main + 139
    frame WerWolv#12: 0x00005555555831d5 imhex`_start + 37
```

### Implementation description
If nullptr check guard.
{fmt} library can deal with all the issues caused by utf-8 chars in
logs. Original code used {fmt} but only to pad the spaces calculated
assuming 1 byte per char.

Also included code to change the windows console to use utf-8 and named
the syntax highlighting task like other tasks created near it.
The other half of the issue was that the structures that the data
inspector was using to store the 16 bit values were using a 32 bit
underlying type instead of a 16 bit. That worked ok for little endian,
but with 4 bytes the resulting value was actually the next u16 after the
one selected.
The feature that selects and highlight's matching delimiters stores the
line and column for the match. If you delete the matching delimiter
while the highlighting is on, then the code was trying to access a
non-existent line causing an exception. Fixed a bug that didn't assign
the right colors when a custom types, a global placed variable and a
member of that custom type shared the same name. Some names were
changed. Some other code was optimized.
<!--
Please provide as much information as possible about what your PR aims
to do.
PRs with no description will most likely be closed until more
information is provided.
If you're planing on changing fundamental behaviour or add big new
features, please open a GitHub Issue first before starting to work on
it.
If it's not something big and you still want to contact us about it,
feel free to do so !
-->

### Problem description
When launching ImHex for the first time, the welcome screen has a small
typo where there's a missing space between "for" and "Reverse Engineers"
<!-- Describe the bug that you fixed/feature request that you
implemented, or link to an existing issue describing it -->


### Implementation description

I looked up the string definition in the source code, found that it's
located here:

https://github.com/WerWolv/ImHex/blob/3a8f19cc90b60176b6d35fb26c7d50451555b6b3/plugins/builtin/source/content/out_of_box_experience.cpp#L112

and fixed the typo
<!-- Explain what you did to correct the problem -->

### Screenshots
<!-- If your change is visual, take a screenshot showing it. Ideally,
make before/after sceenshots -->
<img width="1274" height="716" alt="image"
src="https://github.com/user-attachments/assets/30841caf-7905-41d0-b86f-c9fa47f9833e"
/>

Co-authored-by: paxcut <53811119+paxcut@users.noreply.github.com>
Doing
```cpp
{
}
```
or 
```cpp
{
{
}
}
```
was making imhex crash when closing folds. The cases were not considered
during development because they are illegal pattern language
statements.fix was to adjust the code to accommodate for them.
…pups. (WerWolv#2738)

Don't open the pattern suggestion popup if there are no suggestions or
if a pattern is already loaded for that provider.
Both Devil May Cry HD Collection.tar and AC Unity.tar fail to download
in the Content Store because of the spaces in the file names. Apparently
curl will generate errors if the url link contains spaces. the fix is to
url encode the spaces only, a process known as 'urlify'ing the link.

The implementation uses boost regex replace to perform the substitution
when the link is added to the entry. Perhaps a better fix would be to
patch the python code that generates the Store response, but I don't
have merge permissions on that repository and all the testing I have
done indicates that the problem has been resolved.
Fixes issue WerWolv#2745. White spaces were missing when syntactic colors and
show white spaces were both off. Also a crash could occur when adding
new lines at the end of the file.
Changed the download parameters to improve the rate of failure but if it
doesn't download we skip the no-gpu package generation and continue the
build.
I looked for the self-hosted version on werwolv.net but there is no
downloads folder there anymore.
Allow skipping moving the windows No-GPU version without making the nightly build fail.
This attempts to fix the problems described in issue WerWolv#2748. When a
selection is deleted, the selection ends are changed correctly, but the
interactive selection is not so attempting to use it after the deletion
produces unexpected results.

The fix is to update the interactive selection as well. I also made some
code more efficient by removing the creation of temporary objects that
were not necessary. Some code was repeated several times, so I move the
code into their own function. Cleaned the code handling mouse clicks and
added some `using` typedefs to shorten code.
The exact same error occurring while building plutosvg has been fixed on the last VS 2026 which is 2 days old. Since we are still using 2022 we have to use the published workaround of disabling some optimization. We can't edit plutosvg code so the optimization needs to be disabled for the whole build.
Archlinux needs to change some headers to include `fmt/format.hpp`
instead of `fmt/core.hpp`.
The archlinux build will not be fixed until the PR in disassembler repo
gets merged by somebody with push permissions there.

MSVC builds had last change reverted because not only it did not fix the
build errors, but it added some extra ones. Seeing how this was the only
workaround we can apply we probably will need to update the compiler to
2026 and wait for the version that has the fix to be used in github
actions.

Weirdly enough, both msvc builds went through, so maybe the ICE only occurs sometimes.
fixes issue WerWolv#2758. Problem was caused by the improper parsing of the
template arguments during the association of the variable type with the
variable name. The fix uses the fact that template arguments containing
comparison or shift operators must be enclosed with parentheses to avoid
syntactic ambiguity, so when parentheses are detected they are used to
skip parsing of what they surround. There was a lot of code duplication
in the code that looked for matching delimiter which was removed and the
detection and handling of the separate delimiter pairs was simplified
greatly.

During the time it took to create this PR other problems in the pattern
editor were discovered and their fixes are also included.
* The matching delimiter for templates was also set incorrectly when
operators that could cause syntactic ambiguity were used.
* The block identification line was drawn when cursor was near the block
delimiters instead of anywhere within the block. The code blocks are
slightly different from code folds (e.g. imports and comments) and
correspond to indentation level so m_globalBlocks was renamed to
m_indentBlocks and its generation separated from the generation of code
folds. An upcoming PR will handle real auto indentation extended to
support pasting and deletion.
* If code folding was disabled both matching delimiter highlights and
block id line were also disabled.
* ImHex crashed if lines were inserted while semantic highlighting was
taking place which can only occur on very large patterns. The detection
of task interruption needed to be fixed.
* m_changesWereParsed had the same information as
m_hasUnevaluatedChanges, so it was removed and the latter was renamed to
the more accurate m_hasUnparsedChanges.
* Some functions were moved to more sensible files and some remain to be
moved to minimize this Pr changes.
Catch up with latest ImHex codebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.