MemoryEditor: port of imgui_club imgui_memory_editor v0.59 (buffer / ByteData / byte tables), tests, Roblox + LÖVE examples
This commit is contained in:
commit
10bd6c45d1
18 files changed
+1852
No files matched your search
@@ -0,0 +1,5 @@
|
||||
function love.conf(t)
|
||||
t.window.title = "Memory Editor - LÖVE example"
|
||||
t.window.width, t.window.height = 1280, 800
|
||||
t.window.resizable = true
|
||||
end
|
||||
@@ -0,0 +1,45 @@
|
||||
-- Memory editor over a LÖVE ByteData: love examples/love (uses tools/core/build/imgui_love.lua)
|
||||
local ROOT = love.filesystem.getSource() .. "/../../" -- repo root
|
||||
local f = assert(io.open(ROOT .. "tools/core/build/imgui_love.lua", "rb"), "missing tools/core: git submodule update --init")
|
||||
local G = assert(loadstring(f:read("*a"), "@imgui_love.lua"))(); f:close()
|
||||
local MemoryEditor = assert(loadfile(ROOT .. "MemoryEditor.lua"))()(G)
|
||||
local ImGui = G.ImGui
|
||||
|
||||
data = love.data.newByteData(0x400) -- global: tests/love.lua checks it
|
||||
local ptr = require("ffi").cast("uint8_t*", data:getFFIPointer())
|
||||
for i = 0x40, 0x3FF do ptr[i] = (i * 37) % 256 end
|
||||
local frame = 0
|
||||
|
||||
mem_edit = MemoryEditor.new()
|
||||
mem_edit.OptShowDataPreview = true
|
||||
|
||||
function love.load()
|
||||
ImGui.CreateContext()
|
||||
local io = ImGui.GetIO()
|
||||
io.IniFilename = nil
|
||||
G.ImGui_ImplLove.Init({ root = ROOT .. "tools/core/" })
|
||||
io.Fonts:AddFontDefault()
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
frame = frame + 1
|
||||
ptr[0], ptr[1] = frame % 256, math.floor(frame / 256) % 256
|
||||
G.ImGui_ImplLove.NewFrame()
|
||||
ImGui.NewFrame()
|
||||
mem_edit:DrawWindow("Memory Editor", data) -- size defaults to data:getSize()
|
||||
ImGui.Render()
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
love.graphics.clear(0.45, 0.55, 0.60, 1)
|
||||
G.ImGui_ImplLove.RenderDrawData(ImGui.GetDrawData())
|
||||
end
|
||||
|
||||
function love.mousemoved(x, y) G.ImGui_ImplLove.MouseMoved(x, y) end
|
||||
function love.mousepressed(x, y, b) G.ImGui_ImplLove.MousePressed(x, y, b) end
|
||||
function love.mousereleased(x, y, b) G.ImGui_ImplLove.MouseReleased(x, y, b) end
|
||||
function love.wheelmoved(x, y) G.ImGui_ImplLove.WheelMoved(x, y) end
|
||||
function love.keypressed(k) G.ImGui_ImplLove.KeyPressed(k) end
|
||||
function love.keyreleased(k) G.ImGui_ImplLove.KeyReleased(k) end
|
||||
function love.textinput(t) G.ImGui_ImplLove.TextInput(t) end
|
||||
function love.focus(f) G.ImGui_ImplLove.Focus(f) end
|
||||
@@ -0,0 +1,35 @@
|
||||
-- Memory editor over a Roblox buffer (live-updating counter at 0x00, a float at 0x10, a string at 0x20).
|
||||
local RS = game:GetService("ReplicatedStorage")
|
||||
local RunService = game:GetService("RunService")
|
||||
local G = require(RS:WaitForChild("ImGui"))
|
||||
local MemoryEditor = require(RS:WaitForChild("MemoryEditor"))(G)
|
||||
local ImGui = G.ImGui
|
||||
|
||||
local data = buffer.create(0x400)
|
||||
buffer.writef32(data, 0x10, math.pi)
|
||||
buffer.writestring(data, 0x20, "Hello from a Roblox buffer!")
|
||||
for i = 0x40, 0x3FF do buffer.writeu8(data, i, (i * 37) % 256) end
|
||||
|
||||
local mem_edit = MemoryEditor.new()
|
||||
mem_edit.OptShowDataPreview = true
|
||||
local mem_edit2 = MemoryEditor.new() -- DrawContents() inside your own window, highlighting even bytes
|
||||
mem_edit2.HighlightFn = function(mem, off) return buffer.readu8(mem, off) % 2 == 0 end
|
||||
|
||||
ImGui.CreateContext()
|
||||
G.ImGui_ImplRoblox.Init() -- defaults to LocalPlayer.PlayerGui
|
||||
local frame = 0
|
||||
RunService.RenderStepped:Connect(function()
|
||||
frame += 1
|
||||
buffer.writeu32(data, 0x00, frame)
|
||||
G.ImGui_ImplRoblox.NewFrame()
|
||||
ImGui.NewFrame()
|
||||
mem_edit:DrawWindow("Memory Editor", data) -- size defaults to buffer.len(data)
|
||||
local _, visible = ImGui.Begin("Memory Editor (DrawContents)") -- returns (open, visible)
|
||||
if visible then
|
||||
ImGui.Text("frame = %d (the u32 at 0x00)", frame)
|
||||
mem_edit2:DrawContents(data, 0x80, 0x1000) -- first 0x80 bytes, displayed from address 0x1000
|
||||
end
|
||||
ImGui.End()
|
||||
ImGui.Render()
|
||||
G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData())
|
||||
end)
|
||||
Reference in new issue
Block a user