Skip to content

Commit

Permalink
* Added Genie examples in the vapi test directory
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jul 13, 2009
1 parent 1275f31 commit a8a6619
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
20 changes: 10 additions & 10 deletions libr/vapi/r_search.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ namespace Radare.Search {
STRING,
AES
}

[Compact]
[CCode (cname="struct r_search_t", free_function="r_search_free", cprefix="r_search_")]
public class State {
public State(Mode mode);
public bool set_mode(Mode mode);
public bool set_string_limits(uint32 min, uint32 max);
public class Searcher {
public Searcher (Mode mode);
public bool set_mode (Mode mode);
public bool set_string_limits (uint32 min, uint32 max);
public bool begin();
//public bool set_callback(delegate callback, pointer user);
public bool update(out uint64 from, uint8 *buf, uint32 len);
public bool update_i(uint64 from, uint8 *buf, uint32 len);
public bool update(out uint64 from, uint8 *buf, long len);
public bool update_i(uint64 from, uint8 *buf, long len);
public bool kw_add(string kw, string binmask);
public bool kw_add_hex(string kw, string binmask);
public bool kw_add_bin(string kw, uint32 kw_len, string binmask, uint32 bm_len);
public bool kw_add_bin(string kw, uint32 kw_len, string binmask, long bm_len);
public bool kw_list();
public int set_callback(Search.Callback cb, void *user);
public int set_callback(Radare.Search.Callback cb, void *user);
}


[Compact]
[CCode (cname="struct r_search_kw_t")]
public struct Keyword {
Expand All @@ -41,5 +41,5 @@ namespace Radare.Search {
public uint32 count;
}

public static delegate int Callback(Search.Keyword s, void *user, uint64 addr);
public static delegate int Callback(Radare.Search.Keyword s, void *user, uint64 addr);
}
4 changes: 4 additions & 0 deletions libr/vapi/t/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
all: core hash sc socket asm search bin
@true

genie:
valac --vapidir=.. --pkg r_asm --pkg libr asm.gs
valac --vapidir=.. --pkg r_search --pkg libr search.gs

sc:
valac -C --vapidir=${PWD}/.. sc.vala --pkg r_syscall
gcc sc.c `pkg-config gobject-2.0 --libs --cflags` -I../../include/ -lr_syscall -Wl,-R../../syscall -L../../syscall -o sc
Expand Down
18 changes: 18 additions & 0 deletions libr/vapi/t/asm.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
uses
Radare

init
var st = new Asm()
st.set("asm_x86_olly")
st.set_syntax(Asm.Syntax.INTEL)
st.set_bits(32)
st.set_big_endian(false)
st.set_pc(0x8048000)

/* Disassembler test */
op : Radare.Asm.Aop
var buf = "\x83\xe4\xf0"
st.disassemble(out op, buf, 3)
print "opcode: %s", op.buf_asm
print "bytes: %s", op.buf_hex
print "length: %d", op.inst_len
10 changes: 10 additions & 0 deletions libr/vapi/t/search.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
uses
Radare.Search

init
var s = new Searcher(Mode.KEYWORD)
s.kw_add("lib", "")
s.begin()

var str = "foo is pure lib"
s.update_i(0, str, str.len())
4 changes: 2 additions & 2 deletions libr/vapi/t/search.vala
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* radare - LGPL - Copyright 2009 pancake<nopcode.org> */

using Radare;
using Radare.Search;

public class SearchExample
{
public static void main(string[] args)
{
string buf = "liblubliuamlibfoo";
Search.State s = new Search.State(Search.Mode.KEYWORD);
var s = new Searcher(Mode.KEYWORD);
s.kw_add("lib", "");
s.set_callback(
(kw, user, addr) => {
Expand Down

0 comments on commit a8a6619

Please sign in to comment.