File: rasm.lsp

package info (click to toggle)
radare2 0.9.6-3.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 17,496 kB
  • ctags: 45,959
  • sloc: ansic: 240,999; sh: 3,645; makefile: 2,520; python: 1,212; asm: 312; ruby: 214; awk: 209; perl: 188; lisp: 169; java: 23; xml: 17; php: 6
file content (44 lines) | stat: -rwxr-xr-x 960 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/newlisp
;
; RAsm wrapper for newlisp
;  --pancake'2011

(context 'RAsm)
(if (= ostype "OSX")
	(constant 'SOEXT "dylib")
	(constant 'SOEXT "so")
)
(constant 'RASMLIB (append "/usr/lib/libr_asm." SOEXT))

; from r_asm
(import RASMLIB "r_asm_new")
(import RASMLIB "r_asm_free")
(import RASMLIB "r_asm_use")
(import RASMLIB "r_asm_set_bits")
(import RASMLIB "r_asm_set_big_endian")
(import RASMLIB "r_asm_mdisassemble_hexstr")
(import RASMLIB "r_asm_massemble")
; from r_util
(import RASMLIB "r_list_get_n")
(import RASMLIB "r_list_length")

(define (RAsm:new)
	(r_asm_new)
)

(define (RAsm:set-arch a arch _bits endian)
	(r_asm_use a arch)
	(r_asm_set_bits a _bits)
	(r_asm_set_big_endian a endian)
)

(define (RAsm:disassemble-hex a x)
	(let (acode (r_asm_mdisassemble_hexstr a x))
		(get-string (+ acode 0x50))))

(define (RAsm:assemble a x)
	(let (acode (r_asm_massemble a x))
		(if (= acode 0)
			"" (get-string (+ acode 0x30)))))

(context 'MAIN)