Reload malloc:// bin info from the live buffer with obR - #6668
Conversation
Empty malloc:// is probed at open and lands on the dummy any plugin. Re-probe the live IO buffer after writes near offset 0 so rz-test FILE=malloc:// workflows pick up real magics without an explicit obR. Co-authored-by agent: Cursor Agent/cursor-grok-4.6-high
Co-authored-by agent: Codex/gpt-5.6-terra
The re-probe after a write no longer special-cases elf: any bin plugin that claims the buffer reloads bin info (mach0, elf64, pe, ...). Two weak claimers that made the broad gate unsafe are tightened instead: - avr no longer claims a buffer from the reset vector alone; it requires an interrupt vector table of realistic size (smallest known board has 19 vectors), so foreign shellcode decoding as rjmp stays on any. - when a plugin claims the data by magic but fails to load it, rz_bin_reload keeps the current bin file selected instead of leaving the bin without one. Also, the implicit re-probe no longer clobbers asm config or seeks to the entrypoint; scripts that set their own asm.arch/cpu before writing code keep disassembling as configured. Only the detected plugin becomes current. Co-authored-by agent: Hermes Agent/glm-5.3
|
done. the elf special case is gone: after a write the re-probe now accepts any plugin that claims the buffer, so mach0/elf64/pe/... all reload bin info, not just elf32. that broad gate was the reason the elf check existed though, some check_buffer implementations are loose enough to claim shellcode. so instead of narrowing the gate i tightened the claimers that actually misfire:
the implicit re-probe also stopped clobbering checked: |
1a2c270 to
c4a91c4
Compare
wargio
left a comment
There was a problem hiding this comment.
I feel like this should be done via a command to reload the bin & autodetect without discarding the current buffer as autodetecting this may do weird stuff.
|
@notxvilka @thestr4ng3r @Rot127 please have a look |
Implicit autodetection after wx clobbers scripts that set asm.arch then write code. `obR` already reloads from the live IO buffer without discarding it. Drop the write-path hook and the unrelated avr check_buffer change. Register the reloaded binfile on the core file so close still owns it. Co-authored-by agent: Cursor Agent/cursor-grok-4.6-high
|
probing on wx was not needed. dropped that. obR already reloads bin info from the current buffer without discarding it, so that can be used. wx leaves format as any, obR picks up elf/mach0 and the malloc bytes can stay. hex:// still detects at open because the buffer is already filled. |
Your checklist for this pull request
RZ_APIfunction and struct this PR changes.RZ_API).Detailed description
empty
malloc://lands on the dummyanyplugin at open. writing elf/mach0 magic into it used to leave format stuck onanyunless you reopened the file, which throws away the buffer.obRalready reloads bin info from the current IO buffer (the help text even mentions malloc://). this PR uses that instead of probing on everywx:wxdoes not change format. scripts that setasm.archthen write code are not surprised by a reload.obRre-runs plugin autodetection on the live buffer and does not discard it.hex://with magic already in the uri still detects at open (rz_core_bin_load).rizin -loads bin info after stdin is written intomalloc://.om/rz_core_file_malloc_copy_chunkwrites the copied bytes before bin load, so the probe sees the data.core_bin_reloadkeeps the replacement binfile on the core file after the old one is deleted.reverted an unrelated
avrcheck_buffertweak that was in an earlier revision of this PR.AI: Cursor Agent / cursor-grok-4.6-high for this rework. earlier revisions also used Codex / gpt-5.6-terra and Hermes Agent / glm-5.3. i reviewed the diff and checks.
Test plan
./build/test/unit/test_core_bin13/13 (write staysany;obRreloads elf and keeps the IO bytes; mach0 viaobR; hex:// elf at open)rz-test db/cmd/file_malloc6/6rizin -q malloc://128thenwx 7f45...;i~formatstaysany;obR;i~formatiself;e io.va=0; p8 4 @ 0still7f454c46Closing issues
closes #6607