diff --git a/libr/core/cmd_debug.c b/libr/core/cmd_debug.c index 2c7fe0c1eb..b679fdae0c 100644 --- a/libr/core/cmd_debug.c +++ b/libr/core/cmd_debug.c @@ -584,6 +584,7 @@ static int cmd_debug_map_snapshot(RCore *core, const char *input) { "dms*", "", "list snapshots in r2 commands", "dms", " addr", "take snapshot with given id of map at address", "dms", "-id", "delete memory snapshot", + "dmsA", " id", "apply memory snapshot", "dmsC", " id comment", "add comment for given snapshot", "dmsd", " id", "hexdiff given snapshot. See `ccc`.", "dmsw", "", "snapshot of the writable maps", @@ -658,6 +659,9 @@ static int cmd_debug_map_snapshot(RCore *core, const char *input) { case ' ': r_debug_snap (core->dbg, r_num_math (core->num, input + 1)); break; + case 'A': + r_debug_snap_set (core->dbg, atoi (input + 1)); + break; case 'C': r_debug_snap_comment (core->dbg, atoi (input + 1), strchr (input, ' ')); break; diff --git a/libr/debug/snap.c b/libr/debug/snap.c index ce58edaa50..3d1311ed74 100644 --- a/libr/debug/snap.c +++ b/libr/debug/snap.c @@ -78,6 +78,23 @@ R_API RDebugSnap* r_debug_snap_get (RDebug *dbg, ut64 addr) { return NULL; } +R_API int r_debug_snap_set (RDebug *dbg, int idx) { + RDebugSnap *snap; + RListIter *iter; + ut32 count = 0; + if (!dbg || idx < 0) + return 0; + r_list_foreach (dbg->snaps, iter, snap) { + if (count == idx) { + eprintf ("Writing %d bytes to 0x%08"PFMT64x"...\n", snap->size, snap->addr); + dbg->iob.write_at (dbg->iob.io, snap->addr, snap->data, snap->size); + break; + } + count++; + } + return 1; +} + static int r_debug_snap_map (RDebug *dbg, RDebugMap *map) { RDebugSnap *snap; if (map->size<1) { diff --git a/libr/include/r_debug.h b/libr/include/r_debug.h index 2f4b1eded4..d98a80613d 100755 --- a/libr/include/r_debug.h +++ b/libr/include/r_debug.h @@ -499,6 +499,7 @@ R_API int r_debug_snap(RDebug *dbg, ut64 addr); R_API int r_debug_snap_comment (RDebug *dbg, int idx, const char *msg); R_API int r_debug_snap_all(RDebug *dbg, int perms); R_API RDebugSnap* r_debug_snap_get (RDebug *dbg, ut64 addr); +R_API int r_debug_snap_set (RDebug *dbg, int idx); /* plugin pointers */ extern RDebugPlugin r_debug_plugin_native;