mirror of
https://github.com/rizinorg/rz-lang.git
synced 2026-11-09 12:51:24 -10:00
37 lines
862 B
Python
37 lines
862 B
Python
# Example Python Anal plugin written in Python
|
|
# ============================================
|
|
#
|
|
# -- pancake @ nopcode.org
|
|
#
|
|
# The rzlang.plugin function exposes a way to register new plugins
|
|
# into the RCore instance. This API is only available from RLang.
|
|
# You must call with with '#!python test.py' or 'rz -i test.py ..'
|
|
|
|
import rzlang
|
|
|
|
def pyasm(a):
|
|
def assemble(s):
|
|
print("Assembling %s"%(s))
|
|
return [ 1, 2, 3, 4 ]
|
|
|
|
def disassemble(buf, buflen, pc):
|
|
try:
|
|
return [ 2, f"opcode {buf[0]}" ]
|
|
except:
|
|
print("err")
|
|
print(sys.exc_info())
|
|
return [ 2, "opcode" ]
|
|
return {
|
|
"name": "MyPyDisasm",
|
|
"arch": "pyarch",
|
|
"bits": 32,
|
|
"license": "GPL",
|
|
"desc": "disassembler plugin in python",
|
|
"assemble": assemble,
|
|
"disassemble": disassemble,
|
|
}
|
|
|
|
if not rzlang.plugin("asm", pyasm):
|
|
print("Failed to register the python asm plugin.")
|
|
|