-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[API] Memory editor extension (#110)
* Working on memory editor bindings for #109 * Initial working implementation * Add mising entry for imgui_club in .gitmodules * Sorry, fixing readme link type and description for memory editor. * Rename .club package to .memedit * Rename _club.h to _memedit.h
- Loading branch information
Showing
9 changed files
with
251 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import imgui.extension.memedit.MemoryEditor; | ||
import imgui.flag.ImGuiCond; | ||
import imgui.internal.ImGui; | ||
import imgui.type.ImBoolean; | ||
import org.lwjgl.system.MemoryUtil; | ||
|
||
import java.awt.*; | ||
import java.net.URI; | ||
import java.nio.ByteBuffer; | ||
|
||
public class ExampleImGuiMemoryEditor { | ||
private static final String URL = "https://github.com/ocornut/imgui_club"; | ||
private static ByteBuffer demoData; | ||
private static MemoryEditor memoryEditor; | ||
private static ImBoolean showingMemoryEditor = new ImBoolean(false); | ||
|
||
static { | ||
demoData = MemoryUtil.memASCII("Welcome to the demo for Dear ImGui Memory Editor." + | ||
"\n The git repo is located at " + URL + "." + | ||
"You can use this memory editor to view the raw memory values at some pointer location."); | ||
|
||
memoryEditor = new MemoryEditor(); | ||
} | ||
|
||
public static void show(ImBoolean showImGuiMemoryEditor) { | ||
ImGui.setNextWindowSize(400, 200, ImGuiCond.Once); | ||
ImGui.setNextWindowPos(ImGui.getMainViewport().getPosX() + 100, ImGui.getMainViewport().getPosY() + 100, ImGuiCond.Once); | ||
if (ImGui.begin("ImGuiMemoryEditor Demo", showImGuiMemoryEditor)) { | ||
ImGui.text("This a demo for ImGui MemoryEditor"); | ||
|
||
ImGui.alignTextToFramePadding(); | ||
ImGui.text("Repo:"); | ||
ImGui.sameLine(); | ||
if (ImGui.button(URL)) { | ||
try { | ||
Desktop.getDesktop().browse(new URI(URL)); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
ImGui.checkbox("Memory Editor", showingMemoryEditor); | ||
if (showingMemoryEditor.get()) { | ||
memoryEditor.drawWindow("Example Data", MemoryUtil.memAddress(demoData), demoData.capacity()); | ||
} | ||
} | ||
ImGui.end(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
imgui-binding/src/main/java/imgui/extension/memedit/MemoryEditor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package imgui.extension.memedit; | ||
|
||
import imgui.binding.ImGuiStructDestroyable; | ||
|
||
/** | ||
* ImGui Club Memory Editor extension for ImGui | ||
* Repo: https://github.com/ocornut/imgui_club | ||
*/ | ||
public final class MemoryEditor extends ImGuiStructDestroyable { | ||
|
||
/*JNI | ||
#include "_memedit.h" | ||
#define MEMORY_EDITOR ((MemoryEditor*)STRUCT_PTR) | ||
*/ | ||
|
||
public MemoryEditor() { | ||
|
||
} | ||
|
||
public MemoryEditor(final long ptr) { | ||
super(ptr); | ||
} | ||
|
||
@Override | ||
protected long create() { | ||
return nCreate(); | ||
} | ||
|
||
private native long nCreate(); /* | ||
return (intptr_t)(new MemoryEditor()); | ||
*/ | ||
|
||
public native void gotoAddrAndHighlight(long addrMin, long addrMax); /* | ||
MEMORY_EDITOR->GotoAddrAndHighlight(addrMin, addrMax); | ||
*/ | ||
|
||
public void calcSizes(final MemoryEditorSizes s, final long memSize, final long baseDisplayAddr) { | ||
nCalcSizes(s.ptr, memSize, baseDisplayAddr); | ||
} | ||
|
||
public native void nCalcSizes(long ptr, long memSize, long baseDisplayAddr); /* | ||
MEMORY_EDITOR->CalcSizes(*((MemoryEditor::Sizes*)ptr), static_cast<size_t>(memSize), static_cast<size_t>(baseDisplayAddr)); | ||
*/ | ||
|
||
public void drawWindow(final String title, final long memData, final long memSize) { | ||
drawWindow(title, memData, memSize, 0x000); | ||
} | ||
|
||
public native void drawWindow(String title, long memData, long memSize, long baseDisplayAddr); /* | ||
MEMORY_EDITOR->DrawWindow(title, reinterpret_cast<void*>(memData), static_cast<size_t>(memSize), static_cast<size_t>(baseDisplayAddr)); | ||
*/ | ||
|
||
public void drawContents(final long memData, final long memSize) { | ||
drawContents(memData, memSize, 0x0000); | ||
} | ||
|
||
public native void drawContents(long memData, long memSize, long baseDisplayAddr); /* | ||
MEMORY_EDITOR->DrawContents(reinterpret_cast<void*>(memData), static_cast<size_t>(memSize), static_cast<size_t>(baseDisplayAddr)); | ||
*/ | ||
|
||
public void drawOptionsLine(final MemoryEditorSizes s, final long memData, final long memSize, final long baseDisplayAddr) { | ||
nDrawOptionsLine(s.ptr, memData, memSize, baseDisplayAddr); | ||
} | ||
|
||
public native void nDrawOptionsLine(long ptr, long memData, long memSize, long baseDisplayAddr); /* | ||
MEMORY_EDITOR->DrawOptionsLine(*((MemoryEditor::Sizes*)ptr), reinterpret_cast<void*>(memData), static_cast<size_t>(memSize), static_cast<size_t>(baseDisplayAddr)); | ||
*/ | ||
|
||
public void drawPreviewLine(final MemoryEditorSizes s, final long memDataVoid, final long memSize, final long baseDisplayAddr) { | ||
nDrawPreviewLine(s.ptr, memDataVoid, memSize, baseDisplayAddr); | ||
} | ||
|
||
public native void nDrawPreviewLine(long ptr, long memDataVoid, long memSize, long baseDisplayAddr); /* | ||
MEMORY_EDITOR->DrawPreviewLine(*((MemoryEditor::Sizes*)ptr), reinterpret_cast<void*>(memDataVoid), static_cast<size_t>(memSize), static_cast<size_t>(baseDisplayAddr)); | ||
*/ | ||
} |
109 changes: 109 additions & 0 deletions
109
imgui-binding/src/main/java/imgui/extension/memedit/MemoryEditorSizes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package imgui.extension.memedit; | ||
|
||
import imgui.binding.ImGuiStructDestroyable; | ||
|
||
public final class MemoryEditorSizes extends ImGuiStructDestroyable { | ||
|
||
/*JNI | ||
#include "_memedit.h" | ||
#define MEMORY_EDITOR_SIZES ((MemoryEditor::Sizes*)STRUCT_PTR) | ||
*/ | ||
|
||
public MemoryEditorSizes() { | ||
|
||
} | ||
|
||
public MemoryEditorSizes(final long ptr) { | ||
super(ptr); | ||
} | ||
|
||
@Override | ||
protected long create() { | ||
return nCreate(); | ||
} | ||
|
||
private native long nCreate(); /* | ||
return (intptr_t)(new MemoryEditor::Sizes()); | ||
*/ | ||
|
||
public native void setAddrDigitsCount(int addrDigitsCount); /* | ||
MEMORY_EDITOR_SIZES->AddrDigitsCount = addrDigitsCount; | ||
*/ | ||
|
||
public native int getAddrDigitsCount(); /* | ||
return MEMORY_EDITOR_SIZES->AddrDigitsCount; | ||
*/ | ||
|
||
public native void setLineHeight(float lineHeight); /* | ||
MEMORY_EDITOR_SIZES->LineHeight = lineHeight; | ||
*/ | ||
|
||
public native float getLineHeight(); /* | ||
return MEMORY_EDITOR_SIZES->LineHeight; | ||
*/ | ||
|
||
public native void setGlyphWidth(float glyphWidth); /* | ||
MEMORY_EDITOR_SIZES->GlyphWidth = glyphWidth; | ||
*/ | ||
|
||
public native float getGlyphWidth(); /* | ||
return MEMORY_EDITOR_SIZES->GlyphWidth; | ||
*/ | ||
|
||
public native void setHexCellWidth(float hexCellWidth); /* | ||
MEMORY_EDITOR_SIZES->HexCellWidth = hexCellWidth; | ||
*/ | ||
|
||
public native float getHexCellWidth(); /* | ||
return MEMORY_EDITOR_SIZES->HexCellWidth; | ||
*/ | ||
|
||
public native void setSpacingBetweenMidCols(float spacingBetweenMidCols); /* | ||
MEMORY_EDITOR_SIZES->SpacingBetweenMidCols = spacingBetweenMidCols; | ||
*/ | ||
|
||
public native float getSpacingBetweenMidCols(); /* | ||
return MEMORY_EDITOR_SIZES->SpacingBetweenMidCols; | ||
*/ | ||
|
||
public native void setPosHexStart(float posHexStart); /* | ||
MEMORY_EDITOR_SIZES->PosHexStart = posHexStart; | ||
*/ | ||
|
||
public native float getPosHexStart(); /* | ||
return MEMORY_EDITOR_SIZES->PosHexStart; | ||
*/ | ||
|
||
public native void setPosHexEnd(float posHexEnd); /* | ||
MEMORY_EDITOR_SIZES->PosHexEnd = posHexEnd; | ||
*/ | ||
|
||
public native float getPosHexEnd(); /* | ||
return MEMORY_EDITOR_SIZES->PosHexEnd; | ||
*/ | ||
|
||
public native void setPosAsciiStart(float posAsciiStart); /* | ||
MEMORY_EDITOR_SIZES->PosAsciiStart = posAsciiStart; | ||
*/ | ||
|
||
public native float getPosAsciiStart(); /* | ||
return MEMORY_EDITOR_SIZES->PosAsciiStart; | ||
*/ | ||
|
||
public native void setPosAsciiEnd(float posAsciiEnd); /* | ||
MEMORY_EDITOR_SIZES->PosAsciiEnd = posAsciiEnd; | ||
*/ | ||
|
||
public native float getPosAsciiEnd(); /* | ||
return MEMORY_EDITOR_SIZES->PosAsciiEnd; | ||
*/ | ||
|
||
public native void setWindowWidth(float windowWidth); /* | ||
MEMORY_EDITOR_SIZES->WindowWidth = windowWidth; | ||
*/ | ||
|
||
public native float getWindowWidth(); /* | ||
return MEMORY_EDITOR_SIZES->WindowWidth; | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#pragma once | ||
|
||
#include "_common.h" | ||
#include "imgui_memory_editor.h" |
Submodule imgui_club
added at
d4cd98