File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed
Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 33sleigh = create_sleigh_context ("/Users/maroed/RustroverProjects/code_reuse_synthesis_artifacts/crackers/libz.so.1" , "/Applications/ghidra" )
44j = sleigh .make_jingle_context ()
55state = State (j )
6- bv = state . read_varnode ( VarNode ( 2 , 100 , 2 ))
7- print (bv + bv )
6+
7+ print (state . register ( "RAX" ) == state . ram ( 0x8000_0000 , 8 ) )
Original file line number Diff line number Diff line change 11use crate :: bitvec:: adapt_bv;
22use crate :: jingle_context:: PythonJingleContext ;
33use jingle:: modeling:: State ;
4- use jingle:: sleigh:: VarNode ;
4+ use jingle:: sleigh:: { ArchInfoProvider , VarNode } ;
5+ use pyo3:: exceptions:: PyRuntimeError ;
56use pyo3:: prelude:: * ;
67
7- #[ pyclass( unsendable, name= "State" ) ]
8+ #[ pyclass( unsendable, name = "State" ) ]
89pub struct PythonState {
910 state : State < ' static > ,
1011}
@@ -18,7 +19,23 @@ impl PythonState {
1819 } )
1920 }
2021
21- pub fn read_varnode ( & self , varnode : & VarNode ) -> PyResult < PyObject > {
22+ pub fn varnode ( & self , varnode : & VarNode ) -> PyResult < PyObject > {
2223 adapt_bv ( self . state . read_varnode ( varnode) ?)
2324 }
25+
26+ pub fn register ( & self , name : & str ) -> PyResult < PyObject > {
27+ let vn = self
28+ . state
29+ . get_register ( name)
30+ . ok_or ( PyRuntimeError :: new_err ( "Queried nonexistent register" ) ) ?;
31+ adapt_bv ( self . state . read_varnode ( vn) ?)
32+ }
33+
34+ pub fn ram ( & self , offset : u64 , length : usize ) -> PyResult < PyObject > {
35+ adapt_bv ( self . state . read_varnode ( & VarNode {
36+ offset,
37+ size : length,
38+ space_index : self . state . get_code_space_idx ( ) ,
39+ } ) ?)
40+ }
2441}
You can’t perform that action at this time.
0 commit comments