* Fix build of libr/vapi/t and some bugs in vapis

* Fix some minor random warnings
This commit is contained in:
pancake 2010-01-07 22:26:03 +01:00
parent 5ef595db09
commit ec4673b6e1
17 changed files with 63 additions and 62 deletions

View File

@ -21,7 +21,7 @@ Code analysis module
* TODO: Add static plugin support here
Analysis an = new Analysis ();
var an = new rAnalysis ();
io.bind (an);
an.set ("x86");
var ctx = new Analysis.Context(an);

View File

@ -72,6 +72,11 @@ int splitlines(const char *a, int len, struct line **lr)
const char * const plast = a + len - 1;
struct line *l;
if (a == NULL) {
eprintf ("null pointer received\n");
return 0;
}
/* count the lines */
i = 1; /* extra line for sentinel */
for (p = a; p < a + len; p++)

View File

@ -45,7 +45,7 @@ int main(int argc, char **argv)
struct r_hash_t ctx;
const ut8 *c;
int i;
r_hash_init(&ctx, R_HASH_ALL);
//r_hash_init(&ctx, R_TRUE, R_HASH_ALL);
c = r_hash_do_md5(&ctx, buf, size);
printf("MD5: ");
for(i=0;i<R_HASH_SIZE_MD5;i++) { printf("%02x", c[i]); }

View File

@ -17,8 +17,7 @@ static int do_hash(const char *algo, const ut8 *buf, int len, int bsize)
if (bsize>len)
bsize = len;
//r_hash_state_init(&ctx, R_HASH_ALL);
r_hash_init(&ctx, algobit);
r_hash_init(&ctx, R_TRUE, algobit);
/* iterate over all algorithm bits */
for(i=1;i<0xf00000;i<<=1) {
@ -54,6 +53,7 @@ int main(int argc, char **argv)
const ut8 *buf = NULL;
int c, buf_len = 0;
int bsize = 0;
int ret = 0;
while ((c = getopt(argc, argv, "Va:s:b:h")) != -1) {
switch( c ) {
@ -77,10 +77,9 @@ int main(int argc, char **argv)
if (optind<argc)
buf = (const ut8*)r_file_slurp(argv[optind], &buf_len);
if (buf == NULL) {
if (buf == NULL)
do_help(0);
return 1;
}
else ret = do_hash(algo, buf, buf_len, bsize);
return do_hash(algo, buf, buf_len, bsize);
return ret;
}

View File

@ -7,8 +7,7 @@
#include <lualib.h>
#include <lauxlib.h>
// XXX
#define LIBDIR "/usr/lib"
#define LIBDIR PREFIX"/lib"
static lua_State *L;

View File

@ -100,7 +100,7 @@ static int r_reg_set_word(struct r_reg_item_t *item, int idx, char *word) {
else item->packed_size = atoi(word)*8;
break;
default:
printf("WRf\n");
eprintf ("register set fail\n");
ret = R_FALSE;
}
return ret;

View File

@ -2,7 +2,7 @@
/* This vapi has been manually generated by me */
[Compact]
[CCode (cheader_filename="r_hash.h", cprefix="r_hash_", cname="struct r_hash_t", free_function="r_hash_state_free")]
[CCode (cheader_filename="r_hash.h", cprefix="r_hash_", cname="struct r_hash_t", free_function="r_hash_free")]
public class Radare.rHash {
[CCode (cprefix="R_HASH_")]
[Flags]
@ -15,7 +15,7 @@ public class Radare.rHash {
SHA512 = 16,
}
[CCode (cprefix="R_HASH_", cname="int")]
[CCode (cprefix="R_HASH_SIZE_", cname="int")]
public enum Size {
MD4 = 16,
MD5 = 16,
@ -41,7 +41,7 @@ public class Radare.rHash {
/* methods */
public rHash(bool rst);
// public void init(int rst, Algorithm bits);
public void init(int rst, int bits);
public void init(bool rst, int bits);
public uint8 *do_md4(uint8 *input, uint32 len);
public uint8 *do_md5(uint8 *input, uint32 len);
public uint8 *do_sha1(uint8 *input, uint32 len);

View File

@ -25,7 +25,7 @@ namespace Radare {
public int size;
public int offset;
public int packed_size;
public Register.Type type;
public rRegister.Type type;
}
[Compact]
@ -39,15 +39,15 @@ namespace Radare {
[CCode (cname="struct r_reg_set_t", destroy_function="", free_function="" )]
public class Set {
public rRegister.Arena arena;
public Radare.List<rRegister.Arena*> arenas;
public Radare.List<rRegister.Item*> regs;
public rList<rRegister.Arena*> arenas;
public rList<rRegister.Item*> regs;
}
public rRegister();
public bool set_profile(string file);
public bool set_profile_string(string profile);
public rRegister.Item get(string name, int type = -1);
public Radare.List<rRegister.Item*> get_list(rRegister.Type type);
public rList<rRegister.Item*> get_list(rRegister.Type type);
public uint64 get_value(rRegister.Item item);
public bool set_value(rRegister.Item item, uint64 val);

View File

@ -2,10 +2,9 @@
[CCode (cheader_filename="r_syscall.h", cprefix="r_", lower_case_cprefix="r_")]
namespace Radare {
[Compact]
[CCode (cname="struct r_syscall_t", free_function="r_syscall_free")]
public class Syscall {
[CCode (cname="struct r_syscall_t", free_function="r_syscall_free", cprefix="r_syscall_")]
public class rSyscall {
[CCode (cprefix="R_SYSCALL_OS_")]
public enum OS {
@ -19,7 +18,7 @@ namespace Radare {
X86 = 0, PPC, ARM, MIPS, SPARC
}
public Syscall();
public rSyscall();
public void setup(int os, int arch);
public void setup_file(string file);
public int get(string syscall);

View File

@ -73,7 +73,7 @@ namespace Radare {
[CCode (cname="")]
public G @free(G arg);
[CCode (cname="ralist_get", generic_type_pos=2)]
public unowned G get(int type=0);
public unowned G get(); //int type=0);
[CCode (cname="ralist_iterator")]
public rList<unowned G> iterator();
}
@ -97,11 +97,11 @@ namespace Radare {
[CCode (cprefix="rarray_", cheader_filename="r_types.h", cname="void")]
public static class rArray<G> {
[CCode (cname="rarray_next", generic_type_pos=2)]
public bool next(int type=0);
public bool next(); //int type=0);
[CCode (cname="")]
public G @free(G arg);
[CCode (cname="rarray_get", generic_type_pos=2)]
public unowned G get(int type=0);
public unowned G get(); //int type=0);
[CCode (cname="rarray_iterator")] //, generic_type_pos=2)]
public rArray<G> iterator();
}

View File

@ -1,18 +1,18 @@
all: core regs hash sc socket asm search iter bin db io list array
all: core regs hash sc socket asm search iter bin db io array
@true
array:
valac --vapidir=.. array.vala --pkg r_bin --pkg r_util
regs:
valac --pkg r_reg regs.vala --pkg r_util
valac --vapidir=.. --pkg r_reg regs.vala --pkg r_util
lang:
valac lang.vala --pkg r_lang --pkg r_util
# XXX
list:
valac -o list list_c.c list.vala --pkg r_util --vapidir=. --vapidir=${PWD}/.. -X -I. --pkg list
#list:
# valac -o list list_c.c list.vala --pkg r_util --vapidir=. --vapidir=${PWD}/.. -X -I. --pkg list
genie:
valac --vapidir=.. --pkg r_asm --pkg libr asm.gs

View File

@ -4,7 +4,7 @@
using Radare;
void main(string[] args) {
var bin = new Bin();
var bin = new rBin();
if (args.length==1)
error("No file given");
@ -12,10 +12,10 @@ void main(string[] args) {
error("Cannot open file");
print("Entrypoint: 0x%08llx\n", bin.get_entry().offset);
foreach (Bin.Symbol *f in bin.get_symbols())
foreach (rBin.Symbol *f in bin.get_symbols())
print(" - 0x%08llx %s\n", f->offset, f->name);
foreach (Bin.Section *f in bin.get_sections())
foreach (rBin.Section *f in bin.get_sections())
print(" - 0x%08llx %s\n", f->offset, f->name);
bin.close();

View File

@ -2,7 +2,6 @@ using Radare;
void main()
{
int ret;
var db = new rDatabase();
db.add_id(0, 4);

View File

@ -6,26 +6,28 @@ public class HashExample
{
private static void printChecksum(string str, uint8 *buf, int size)
{
stdout.printf(str);
print (str);
for(int i=0;i<size; i++)
stdout.printf("%02x", buf[i]);
stdout.printf("\n");
print ("%02x", buf[i]);
print ("\n");
}
public static void main(string[] args)
{
/* calculate crc32 */
stdout.printf("CRC32: %x\n", rHash.crc32("hello", 5));
print ("CRC32: %x\n", rHash.crc32("hello", 5));
/* directly calculate md5 */
var st = new rHash(true);
printChecksum("Single MD5: ", (uint8*)st.do_md5("helloworld", 10), rHash.Size.MD5);
var st = new rHash (true);
printChecksum ("Single MD5: ",
(uint8*)st.do_md5 ("helloworld", 10), rHash.Size.MD5);
/* incrementally calculate md5 */
st = new rHash(false);
st.do_md5("hello", 5);
st.do_md5("world", 5);
printChecksum("Incremental MD5: ", (uint8*)st.do_md5(null,0), rHash.Size.MD5);
st.init(rHash.Algorithm.ALL);
st = new rHash (false);
st.do_md5 ("hello", 5);
st.do_md5 ("world", 5);
printChecksum ("Incremental MD5: ",
(uint8*)st.do_md5 (null,0), rHash.Size.MD5);
st.init (true, rHash.Algorithm.ALL);
}
}

View File

@ -8,9 +8,9 @@ public class IterableObject {
}
}
Radare.Iter<IterableObject>* get_iter_list ()
rIter<IterableObject>* get_iter_list ()
{
Iter<IterableObject> list = new Iter<IterableObject>(5);
rIter<IterableObject> list = new rIter<IterableObject>(5);
list.set(0, new IterableObject("patata"));
list.set(1, new IterableObject("cacatua"));

View File

@ -1,22 +1,20 @@
using Radare;
void main() {
var reg = new rRegister();
reg.set_profile_string (
"gpr eip .32 0 0\n" +
"gpr eax .32 4 0\n"
);
Register reg = new Register();
reg.set_value (reg.get ("eax"), 666);
reg.set_profile_string("""
gpr eip .32 0 0
gpr eax .32 4 0
"""
);
reg.set_value(reg.get("eax"), 666);
rList<rRegister.Item*> head =
reg.get_list (rRegister.Type.GPR);
Radare.List<Register.Item*> head =
reg.get_list(Register.Type.GPR);
foreach(Register.Item* item in head) {
stdout.printf(" - %s (%d) = 0x%08llx\n",
foreach (rRegister.Item* item in head) {
print (" - %s (%d) = 0x%08llx\n",
item->name, item->size,
reg.get_value(item));
reg.get_value (item));
}
}

View File

@ -5,8 +5,8 @@ public class SyscallExample
{
public static void main(string[] args)
{
Syscall sc = new Syscall();
sc.setup(Syscall.ARCH.X86, Syscall.OS.LINUX);
stdout.printf("write = %d\n", sc.get("write"));
var sc = new rSyscall();
sc.setup (rSyscall.ARCH.X86, rSyscall.OS.LINUX);
print ("write = %d\n", sc.get("write"));
}
}