mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-03 19:01:31 +00:00
* r_core
- Minor fixup in r_core_asm_strsearch * vapi - Add asmsearch.vala - Some updates
This commit is contained in:
parent
df9434b1ec
commit
e02c81ddf1
@ -47,14 +47,16 @@ R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut6
|
||||
RList *hits;
|
||||
ut64 at, toff = core->offset;
|
||||
ut8 *buf;
|
||||
char *tok, *tokens[1024], *code = NULL;
|
||||
char *tok, *tokens[1024], *code = NULL, *ptr;
|
||||
int idx, tidx, ret, len;
|
||||
int tokcount, matchcount;
|
||||
|
||||
if (!(ptr = strdup (input)))
|
||||
return NULL;
|
||||
if (!(hits = r_core_asm_hit_list_new ()))
|
||||
return NULL;
|
||||
for (tokcount=0;;tokcount++) {
|
||||
if (tokcount==0) tok = (char*)strtok ((char*)input, ";");
|
||||
if (tokcount==0) tok = (char*)strtok (ptr, ";");
|
||||
else tok = (char*)strtok (NULL, ";");
|
||||
if (tok == NULL)
|
||||
break;
|
||||
@ -115,5 +117,7 @@ R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut6
|
||||
}
|
||||
r_asm_set_pc (core->assembler, toff);
|
||||
free (buf);
|
||||
free (ptr);
|
||||
free (code);
|
||||
return hits;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace Radare {
|
||||
|
||||
public RBin();
|
||||
|
||||
public int load(string file, int dummy);
|
||||
public int load(string file, bool dummy);
|
||||
public int list();
|
||||
public uint64 get_baddr();
|
||||
public RBin.Addr get_main();
|
||||
@ -43,7 +43,7 @@ namespace Radare {
|
||||
public int32 vsize;
|
||||
public int64 rva;
|
||||
public int64 offset;
|
||||
public int32 rwx;
|
||||
public int32 srwx;
|
||||
}
|
||||
|
||||
[CCode (cname="RBinSymbol", free_function="", ref_function="", unref_function="")]
|
||||
|
@ -16,7 +16,7 @@ namespace Radare {
|
||||
public void list(string? foo, int bar);
|
||||
}
|
||||
|
||||
[CCode (cname="RConfigNode", free_function="")]
|
||||
[CCode (cname="RConfigNode", free_function="", unref_function="")]
|
||||
public class RConfigNode {
|
||||
string name;
|
||||
int hash;
|
||||
|
@ -61,8 +61,8 @@ public class RCore {
|
||||
|
||||
[CCode (cname="RCoreAsmHit", free_function="", ref_function="", unref_function="")]
|
||||
public class AsmHit {
|
||||
string code;
|
||||
uint64 addr;
|
||||
public string code;
|
||||
public uint64 addr;
|
||||
}
|
||||
|
||||
/* files */
|
||||
|
@ -1,4 +1,4 @@
|
||||
all: plugin.so bin lang core regs hash sc socket asm search db io list rgot
|
||||
all: plugin.so bin lang core asmsearch regs hash sc socket asm search db io list rgot
|
||||
@true
|
||||
|
||||
plugin.so:
|
||||
@ -65,7 +65,6 @@ core:
|
||||
-lr_lib -Wl,-R../../lib -L../../lib \
|
||||
-lr_parse -Wl,-R../../parse -L../../parse \
|
||||
-lr_flags -Wl,-R../../flags -L../../flags \
|
||||
-lr_meta -Wl,-R../../meta -L../../meta \
|
||||
-lr_print -Wl,-R../../print -L../../print \
|
||||
-lr_config -Wl,-R../../config -L../../config \
|
||||
-lr_search -Wl,-R../../search -L../../search \
|
||||
@ -75,6 +74,9 @@ core:
|
||||
-lr_bp -Wl,-R../../bp -L../../bp \
|
||||
-g -o core
|
||||
|
||||
asmsearch:
|
||||
valac --vapidir=.. asmsearch.vala --pkg r_core --pkg r_bin -o asmsearch
|
||||
|
||||
search:
|
||||
valac -C --vapidir=${PWD}/.. search.vala --pkg r_search --pkg r_util
|
||||
gcc search.c `pkg-config gobject-2.0 --libs --cflags` -I../../../libr/include/ \
|
||||
@ -103,4 +105,4 @@ socket:
|
||||
gcc socket.c `pkg-config gobject-2.0 --libs --cflags` -I../../../libr/include/ -lr_socket -Wl,-R../../socket -L../../socket -o socket
|
||||
|
||||
clean:
|
||||
-rm -f *.c hash sc *.o *.h core socket asm search bin io rgot reloc
|
||||
-rm -f *.c hash sc *.o *.h core socket asm search bin io rgot reloc asmsearch
|
||||
|
14
swig/vapi/t/asmsearch.vala
Normal file
14
swig/vapi/t/asmsearch.vala
Normal file
@ -0,0 +1,14 @@
|
||||
using Radare;
|
||||
|
||||
public static void main(string[] args)
|
||||
{
|
||||
var c = new RCore();
|
||||
var b = new RBin();
|
||||
c.file_open("/bin/ls", 0);
|
||||
b.load("/bin/ls", false);
|
||||
uint64 baddr = b.get_baddr();
|
||||
foreach (var scn in b.get_sections())
|
||||
if ((scn.srwx & 0x1) != 0)
|
||||
foreach (var hit in c.asm_strsearch("jmp e; ret", scn.offset, scn.offset+scn.size))
|
||||
print("0x%08"+uint64.FORMAT_MODIFIER+"x - %s\n", baddr+hit.addr, hit.code);
|
||||
}
|
@ -7,7 +7,7 @@ public void main (string[] args) {
|
||||
error ("Usage: %s <file>\n", args[0]);
|
||||
|
||||
var bin = new RBin ();
|
||||
if (bin.load (args[1], null) != 1)
|
||||
if (bin.load (args[1], false) != 1)
|
||||
error ("Cannot open binary file\n");
|
||||
|
||||
uint64 baddr = bin.get_baddr();
|
||||
|
Loading…
Reference in New Issue
Block a user