Skip to content

Instantly share code, notes, and snippets.

@ocornut
Last active March 5, 2026 13:43
Show Gist options
  • Select an option

  • Save ocornut/0673e37e54aff644298b to your computer and use it in GitHub Desktop.

Select an option

Save ocornut/0673e37e54aff644298b to your computer and use it in GitHub Desktop.
Mini memory editor for dear imgui (to embed in your game/tools)
// Mini memory editor for Dear ImGui (to embed in your game/tools)
// Animated GIF: https://twitter.com/ocornut/status/894242704317530112
// THE MEMORY EDITOR CODE HAS MOVED TO GIT:
// https://github.com/ocornut/imgui_club/tree/master/imgui_memory_editor
// Click "Revisions" on the Gist to see old version.
@ocornut

ocornut commented Aug 6, 2017

Copy link
Copy Markdown
Author

Hello @leiradel, sorry I missed your question earlier.
It is a little tricky because the InputText widget is currently always "owning" the active text.
I've came up with a workaround by rewriting the content of the text. The gist above has been update to v0.11.

And here is the test code I used to verify it worked:

static unsigned char ram[0x1000] = { 0 };
if ((ImGui::GetFrameCount() % 60) == 0)
    for (int n = 0; n < 0x1000; n++)
        ram[n] = ((n % 16) << 4) | ((ram[n]+1) & 0x0F);
static MemoryEditor mem_editor;
mem_editor.Draw("Test", ram, 0x1000);

@bkaradzic

bkaradzic commented Aug 7, 2017

Copy link
Copy Markdown

I had to add following to build:

#include <stdio.h>
#pragma GCC diagnostic ignored "-Wparentheses"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wtype-limits"
imgui_memory_editor.h:229:94: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
                     bool is_next_byte_highlighted = (n + 1 == Rows) || (addr + 1 < mem_size) && ((HighlightMax != (size_t)-1 && addr + 1 < HighlightMax) || (HighlightFn && HighlightFn(mem_data, addr + 1)));
imgui_memory_editor.h:286:24: error: suggest explicit braces to avoid ambiguous ‘else’ [-Werror=parentheses]
                     if (data_write && sscanf(DataInputBuf, "%X", &data_input_value) == 1
imgui_memory_editor.h:387:26: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits]
             if (GotoAddr >= 0 && GotoAddr < mem_size)

@ocornut

ocornut commented Aug 7, 2017

Copy link
Copy Markdown
Author

@bkaradzic: thanks, all 4 (inc. stdio) should be fixed now.

@hinxx

hinxx commented Mar 9, 2018

Copy link
Copy Markdown

Great gadget @ocornut!
If only I could get a callback when user changes a byte..

@hinxx

hinxx commented Mar 9, 2018

Copy link
Copy Markdown

.. or is it WriteFn() I want ..

@hinxx

hinxx commented Mar 9, 2018

Copy link
Copy Markdown

.. yes

@Jenrikku

Jenrikku commented Jul 14, 2022

Copy link
Copy Markdown

Hello! I know this gist is pretty old now but I find it very interesting. Could it be possible to update it so it works with the newest versions of imgui?
Nevermind! I see that it has been moved. It's really nice, by the way.

@ocornut

ocornut commented Jul 14, 2022

Copy link
Copy Markdown
Author

The header of the file has a link to the repository where this is now located and up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment