mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-17 12:48:41 +00:00
Implement wcf command for new io cache ##io
This commit is contained in:
parent
635c434337
commit
bc96eae13c
@ -1324,7 +1324,6 @@ static char *__current_filename(RCore *core) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if !USE_NEW_IO_CACHE_API
|
||||
static ut64 __va2pa(RCore *core, ut64 va) {
|
||||
RIOMap *map = r_io_map_get_at (core->io, va);
|
||||
if (map) {
|
||||
@ -1332,7 +1331,6 @@ static ut64 __va2pa(RCore *core, ut64 va) {
|
||||
}
|
||||
return va;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void cmd_wcf(RCore *core, const char *dfn) {
|
||||
char *sfn = __current_filename (core);
|
||||
@ -1343,12 +1341,14 @@ static void cmd_wcf(RCore *core, const char *dfn) {
|
||||
size_t sfs;
|
||||
ut8 *sfb = (ut8*)r_file_slurp (sfn, &sfs);
|
||||
if (sfb) {
|
||||
#if USE_NEW_IO_CACHE_API
|
||||
R_LOG_TODO ("wcf not supported yet with the new io cache");
|
||||
#else
|
||||
void **iter;
|
||||
#if USE_NEW_IO_CACHE_API
|
||||
r_pvector_foreach (core->io->cache->vec, iter) {
|
||||
RIOCacheItem *c = *iter;
|
||||
#else
|
||||
r_pvector_foreach (&core->io->cache, iter) {
|
||||
RIOCache *c = *iter;
|
||||
#endif
|
||||
const ut64 ps = r_itv_size (c->itv);
|
||||
const ut64 va = r_itv_begin (c->itv);
|
||||
const ut64 pa = __va2pa (core, va);
|
||||
@ -1358,7 +1358,6 @@ static void cmd_wcf(RCore *core, const char *dfn) {
|
||||
R_LOG_ERROR ("Out of bounds patch at 0x%08"PFMT64x, pa);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// patch buffer
|
||||
r_file_dump (dfn, sfb, sfs, false);
|
||||
free (sfb);
|
||||
|
@ -336,6 +336,31 @@ idx=2 addr=0x00000006 size=3 000000 -> 909090 (written)
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=wcf should commit all the changes to a file
|
||||
FILE=bins/lua/hello.lua
|
||||
CMDS=<<EOF
|
||||
e io.cache=true
|
||||
rm .tmp_file
|
||||
s 0x0000002B
|
||||
wx 7272
|
||||
wcf .tmp_file
|
||||
cat .tmp_file
|
||||
rm .tmp_file
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
local c = 0
|
||||
|
||||
function hello(msg)
|
||||
print("Herro "..msg)
|
||||
c = c + 1
|
||||
end
|
||||
|
||||
hello("World")
|
||||
hello(c)
|
||||
hello(c)
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=wx pcache
|
||||
FILE=bins/pe/b.exe
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user