Skip to content

Commit

Permalink
More fixes for the vapis
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed May 9, 2024
1 parent 987d4dd commit 908ee34
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion vapi/r_anal.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Radare {
// public RList<MetaItem> meta;
public RList<Refline> reflines;
public RReg reg;
public RSyscall syscall;
// public RSyscall syscall;

/* bindiffing options
-- THIS IS PRIVATE --
Expand Down
8 changes: 4 additions & 4 deletions vapi/r_asm.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class RAsm {
/**
* The supported assembler syntax variations.
*/
[CCode (cprefix="R_ASM_SYNTAX_", cname="int")]
[CCode (cprefix="R_ARCH_SYNTAX_", cname="int")]
public enum Syntax {
/**
* Use default syntax provided by the disassembler
Expand Down Expand Up @@ -126,11 +126,11 @@ public class RAsm {
public bool use(string name);
/*
public bool set_arch(string name, int bits);
public bool set_bits(int bits);
public bool set_syntax(Syntax syntax);
*/
public bool set_pc(uint64 addr);
public bool set_bits(int bits);
public bool set_big_endian(bool big);
*/
public bool set_syntax(Syntax syntax);
// TODO: Use Code? instead of op??
public int disassemble(RAnal.Op op, uint8* buf, int length);
/**
Expand Down
2 changes: 1 addition & 1 deletion vapi/r_util.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Radare {
}
#endif
[Compact]
[CCode (cheader_filename="r_util.h", lower_case_cprefix="r_strbuf_", cname="RStrBuf", init_function="", unref_function="")]
[CCode (cheader_filename="r_util.h", lower_case_cprefix="r_strbuf_", cname="RStrBuf", unref_function="")]
public class RStrBuf {
public void init ();
public RStrBuf (string str);
Expand Down
5 changes: 4 additions & 1 deletion vapi/t/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include ../../config.mk

TESTS=core asm lang regs sc hash sc
TESTS=core asm asm2 lang regs sc hash sc
ALLTESTS=$(TESTS) bin socket search list

all: $(ALLTESTS)
Expand Down Expand Up @@ -72,6 +72,9 @@ asm:
#valac --vapidir=.. --pkg r_asm asm.vala
valac --vapidir=.. --pkg r_anal --pkg r_asm --pkg r_syscall asm.vala

asm2:
valac asm2.gs --pkg r_asm --pkg r_anal --vapidir=..

bin:
valac --vapidir=.. bin.vala --pkg r_bin --pkg r_util

Expand Down
18 changes: 0 additions & 18 deletions vapi/t/asm.gs

This file was deleted.

4 changes: 2 additions & 2 deletions vapi/t/asm.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class RAsmExample
{
RAsm st = new RAsm();
st.use("x86.olly");
st.set_bits(32);
/*
st.set_syntax(RAsm.Syntax.INTEL);
st.set_bits(32);
st.set_big_endian(false);
st.set_pc(0x8048000);
st.set_parser(RAsm.Parser.PSEUDO,
Expand All @@ -21,7 +21,7 @@ public class RAsmExample
*/

RAnal.Op op = new RAnal.Op();
uint8 *buf = "\x83\xe4\xf0";
uint8 *buf = (uint8*)"\x83\xe4\xf0";
string buf2 = "jmp _foo;nop;nop;nop;_foo:push eax";
if (st.disassemble(op, buf, 3) <1) {
stderr.printf ("internal error\n");
Expand Down
20 changes: 20 additions & 0 deletions vapi/t/asm2.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
uses
Radare

init
var st = new RAsm()
st.use("mips")
// st.set_syntax(RAsm.Syntax.INTEL)
st.set_bits(64)
st.set_big_endian(true)
st.set_pc(0x8048000)

/* Disassembler test */
var op = new RAnal.Op()
// var buf = "\x83\xe4\xf0\x20"
var buf = "\x41\x55\x41\x54"
var res = st.disassemble(op, buf, 4)
print "result: %d", res
print "opcode: %s", op.mnemonic
// print "bytes: %s", op.buf_hex
print "length: %d", op.size

0 comments on commit 908ee34

Please sign in to comment.