Skip to content

feat: paste from file popup for pasting data from another file#2793

Open
jiishiin wants to merge 1 commit into
WerWolv:masterfrom
jiishiin:master
Open

feat: paste from file popup for pasting data from another file#2793
jiishiin wants to merge 1 commit into
WerWolv:masterfrom
jiishiin:master

Conversation

@jiishiin

@jiishiin jiishiin commented Jul 21, 2026

Copy link
Copy Markdown

Feature

Paste from File popup for pasting data from another file

Reason for implementation

Pasting very large amount of bytes (like 2.5 GB) from clipboard either freezes ImHex or doesn't paste anything. This feature lets you to paste data from source file to destination file (if selected from hex editor, it will be set as the default destination).

Screenshots

imhex_context_menu imhex_paste_from_file

Feature Description

I have added a feature to paste data directly from another file since pasting large size of data from the clipboard doesn't work as expected.

It has following features -

  1. File selector: Allows to select the files opened in Hex Editor

  2. Region Selection Toggle: It allows to select the region of the selected file directly from Hex Editor.

  3. Shows the Begin area of the current selection

  4. Shows the End area of the current selection

  5. Clear currently selected region

  6. Swap File: Its swaps the source and destination

  7. Input the selection region manually

  8. Paste Modes: Has multiple modes of paste operation

    • Paste Over Selection :- Paste the selected source region over the selected destination region. If the source region is smaller than the destination region, the remaining bytes in the destination region are left unchanged.

    • Paste Everything :- Paste the entire selected source region starting at the begin address of the selected destination region. The destination file will be resized to fit the source region data.

    • Replace Selection :- Replace the selected destination region with the selected source region. The selected destination region will be resized to fit the selected source region data.

    • Insert Everything :- Insert the entire selected source region starting at the begin address of the selected destination region, shifting the existing data forward.

  9. Hint Box: Shows information regarding paste operation.

  10. Recommendation Toggle: When enabled automatically shows the recommended paste modes based on the destination selection size.

    • It checks whether the destination selection is single byte, multi byte or zero byte.
  11. Input Base Toggle: Switch between hexadecimal and decimal view of the input region/size.

  12. Apply: Perform the selected operation.

  13. Cancel: Close or cancel the paste from file popup.

Video

imhex_paste_from_file.mp4

Known issues

  • Implementation uses raw read, write, insert and remove provider APIs, so patches won't work for changes done using this feature. Means undo/redo will not work for modification done using this feature. So use with caution.

  • This feature does not allows source and destination file to be the same.

  • The right outer vertical boarder (using _BordersOuterV flag) near the action buttons is off by 1 pixel. Seems to be an issue with ImGui. Its working correctly with all outer boarders (using _BordersOuter flag).

image

@jiishiin

Copy link
Copy Markdown
Author

@WerWolv Please have a look at this feature pull request.

@jiishiin jiishiin changed the title [Feature] Paste from File popup for pasting data from another file feat: paste from file popup for pasting data from another file Jul 21, 2026
@jiishiin

Copy link
Copy Markdown
Author

Hello @paxcut, I have implemented this feature to allow pasting of larger data from another file since pasting large data from clipboard makes ImHex not-responding. If ImHex is accepting feature PRs, can you review this?

@paxcut

paxcut commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

I saw this yesterday and I was very impressed with the level of detail and the massive amount of options available. I work mostly on the pattern editor and can fix simple bugs and review small PRs outside of that, so this is a bit too big for me to handle. OTOH the code is self contained and there are not many changes to existing systems so I may get permission to review it but I need to ask first.

I couldn't find any mention of an undo feature either as a proper feature or as a limitation. Would the builtin undo/redo system be able to recover data in case of an accidental paste?

The last thing I wanted to mention is the reason posted for the creation of this feature. Is the pasting of large files using the clipboard breaking a know issue? How big are we talking about? Is it just slow or does it hang ImHex?
I see this feature as an alternative to using the clipboard, not as a substitute, so us developers should look into what is happening on that end too.

@jiishiin

jiishiin commented Jul 22, 2026

Copy link
Copy Markdown
Author

I have mentioned the limitation of not being able to undo/redo in the known issues (1st point) section due to the uses of RAW provider api's for write/insert/remove. When I had used the normal provider APIs, its was causing the same not responding issue.
Since the write operation is done in a chunk of 4KB, the amount of undo/redo will be very large for a very large data if normal write/insert/remove provider api is used. So I had to use the raw apis.

The reason for this feature was, I was trying to fix a corrupted video file, so I had to replace some of the atoms in the corrupted video file highlighted by the mp4 pattern. While copy/pasting data ( i think it was over 2.5 GB) the ImHex won't either respond, or doesn't paste anything. I think similar behavior was reported a long back (Issue #1270).

Now the only way to revert an accidental paste is to close the file without saving. I will add a warning regarding the undo/redo limitation for now.

@jiishiin

Copy link
Copy Markdown
Author

@paxcut I have added a warning regarding the undo/redo limitation.
image

@jiishiin
jiishiin force-pushed the master branch 3 times, most recently from 69d177a to 2513536 Compare July 22, 2026 18:38
@jiishiin

Copy link
Copy Markdown
Author

The warning is now always shown.
image

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.

2 participants