@@ -21,6 +21,7 @@ fn session() -> Session {
2121fn test_llil_info ( _session : & Session ) {
2222 let out_dir = env ! ( "OUT_DIR" ) . parse :: < PathBuf > ( ) . unwrap ( ) ;
2323 let view = binaryninja:: load ( out_dir. join ( "atox.obj" ) ) . expect ( "Failed to create view" ) ;
24+ let image_base = view. original_image_base ( ) ;
2425
2526 let entry_function = view. entry_point_function ( ) . unwrap ( ) ;
2627 let llil_function = entry_function. low_level_il ( ) . unwrap ( ) ;
@@ -32,7 +33,7 @@ fn test_llil_info(_session: &Session) {
3233 // 0 @ 00025f10 (LLIL_SET_REG.d edi = (LLIL_REG.d edi))
3334 let instr_0 = llil_instr_iter. next ( ) . unwrap ( ) ;
3435 assert_eq ! ( instr_0. index, LowLevelInstructionIndex ( 0 ) ) ;
35- assert_eq ! ( instr_0. address( ) , 0x00025f10 ) ;
36+ assert_eq ! ( instr_0. address( ) , image_base + 0x00025f10 ) ;
3637 println ! ( "{:?}" , instr_0) ;
3738 println ! ( "{:?}" , instr_0. kind( ) ) ;
3839 match instr_0. kind ( ) {
@@ -49,7 +50,7 @@ fn test_llil_info(_session: &Session) {
4950 // 1 @ 00025f12 (LLIL_PUSH.d push((LLIL_REG.d ebp)))
5051 let instr_1 = llil_instr_iter. next ( ) . unwrap ( ) ;
5152 assert_eq ! ( instr_1. index, LowLevelInstructionIndex ( 1 ) ) ;
52- assert_eq ! ( instr_1. address( ) , 0x00025f12 ) ;
53+ assert_eq ! ( instr_1. address( ) , image_base + 0x00025f12 ) ;
5354 println ! ( "{:?}" , instr_1. kind( ) ) ;
5455 match instr_1. kind ( ) {
5556 LowLevelILInstructionKind :: Push ( op) => {
@@ -72,7 +73,7 @@ fn test_llil_info(_session: &Session) {
7273 // 2 @ 00025f13 (LLIL_SET_REG.d ebp = (LLIL_REG.d esp) {__saved_ebp})
7374 let instr_2 = llil_instr_iter. next ( ) . unwrap ( ) ;
7475 assert_eq ! ( instr_2. index, LowLevelInstructionIndex ( 2 ) ) ;
75- assert_eq ! ( instr_2. address( ) , 0x00025f13 ) ;
76+ assert_eq ! ( instr_2. address( ) , image_base + 0x00025f13 ) ;
7677 println ! ( "{:?}" , instr_2. kind( ) ) ;
7778 match instr_2. kind ( ) {
7879 LowLevelILInstructionKind :: SetReg ( op) => {
@@ -88,7 +89,7 @@ fn test_llil_info(_session: &Session) {
8889 // 3 @ 00025f15 (LLIL_SET_REG.d eax = (LLIL_LOAD.d [(LLIL_ADD.d (LLIL_REG.d ebp) + (LLIL_CONST.d 8)) {arg1}].d))
8990 let instr_3 = llil_instr_iter. next ( ) . unwrap ( ) ;
9091 assert_eq ! ( instr_3. index, LowLevelInstructionIndex ( 3 ) ) ;
91- assert_eq ! ( instr_3. address( ) , 0x00025f15 ) ;
92+ assert_eq ! ( instr_3. address( ) , image_base + 0x00025f15 ) ;
9293 println ! ( "{:?}" , instr_3. kind( ) ) ;
9394 match instr_3. kind ( ) {
9495 LowLevelILInstructionKind :: SetReg ( op) => {
@@ -104,7 +105,7 @@ fn test_llil_info(_session: &Session) {
104105 // 4 @ 00025f18 (LLIL_PUSH.d push((LLIL_REG.d eax)))
105106 let instr_4 = llil_instr_iter. next ( ) . unwrap ( ) ;
106107 assert_eq ! ( instr_4. index, LowLevelInstructionIndex ( 4 ) ) ;
107- assert_eq ! ( instr_4. address( ) , 0x00025f18 ) ;
108+ assert_eq ! ( instr_4. address( ) , image_base + 0x00025f18 ) ;
108109 println ! ( "{:?}" , instr_4. kind( ) ) ;
109110 match instr_4. kind ( ) {
110111 LowLevelILInstructionKind :: Push ( op) => {
@@ -116,7 +117,7 @@ fn test_llil_info(_session: &Session) {
116117 // 5 @ 00025f19 (LLIL_CALL call((LLIL_CONST_PTR.d __crt_interlocked_read_32)))
117118 let instr_5 = llil_instr_iter. next ( ) . unwrap ( ) ;
118119 assert_eq ! ( instr_5. index, LowLevelInstructionIndex ( 5 ) ) ;
119- assert_eq ! ( instr_5. address( ) , 0x00025f19 ) ;
120+ assert_eq ! ( instr_5. address( ) , image_base + 0x00025f19 ) ;
120121 println ! ( "{:?}" , instr_5. kind( ) ) ;
121122 match instr_5. kind ( ) {
122123 LowLevelILInstructionKind :: Call ( op) => {
@@ -127,7 +128,7 @@ fn test_llil_info(_session: &Session) {
127128 // 6 @ 00025f1e (LLIL_SET_REG.d esp = (LLIL_ADD.d (LLIL_REG.d esp) + (LLIL_CONST.d 4)))
128129 let instr_6 = llil_instr_iter. next ( ) . unwrap ( ) ;
129130 assert_eq ! ( instr_6. index, LowLevelInstructionIndex ( 6 ) ) ;
130- assert_eq ! ( instr_6. address( ) , 0x00025f1e ) ;
131+ assert_eq ! ( instr_6. address( ) , image_base + 0x00025f1e ) ;
131132 println ! ( "{:?}" , instr_6. kind( ) ) ;
132133 match instr_6. kind ( ) {
133134 LowLevelILInstructionKind :: SetReg ( op) => {
@@ -143,7 +144,7 @@ fn test_llil_info(_session: &Session) {
143144 // 7 @ 00025f21 (LLIL_SET_REG.d ebp = (LLIL_POP.d pop))
144145 let instr_7 = llil_instr_iter. next ( ) . unwrap ( ) ;
145146 assert_eq ! ( instr_7. index, LowLevelInstructionIndex ( 7 ) ) ;
146- assert_eq ! ( instr_7. address( ) , 0x00025f21 ) ;
147+ assert_eq ! ( instr_7. address( ) , image_base + 0x00025f21 ) ;
147148 println ! ( "{:?}" , instr_7. kind( ) ) ;
148149 match instr_7. kind ( ) {
149150 LowLevelILInstructionKind :: SetReg ( op) => {
@@ -159,7 +160,7 @@ fn test_llil_info(_session: &Session) {
159160 // 8 @ 00025f22 (LLIL_RET <return> jump((LLIL_POP.d pop)))
160161 let instr_8 = llil_instr_iter. next ( ) . unwrap ( ) ;
161162 assert_eq ! ( instr_8. index, LowLevelInstructionIndex ( 8 ) ) ;
162- assert_eq ! ( instr_8. address( ) , 0x00025f22 ) ;
163+ assert_eq ! ( instr_8. address( ) , image_base + 0x00025f22 ) ;
163164 println ! ( "{:?}" , instr_8. kind( ) ) ;
164165 match instr_8. kind ( ) {
165166 LowLevelILInstructionKind :: Ret ( op) => {
@@ -173,10 +174,11 @@ fn test_llil_info(_session: &Session) {
173174fn test_llil_visitor ( _session : & Session ) {
174175 let out_dir = env ! ( "OUT_DIR" ) . parse :: < PathBuf > ( ) . unwrap ( ) ;
175176 let view = binaryninja:: load ( out_dir. join ( "atox.obj" ) ) . expect ( "Failed to create view" ) ;
177+ let image_base = view. original_image_base ( ) ;
176178 let platform = view. default_platform ( ) . unwrap ( ) ;
177179
178180 // Sample function: __crt_strtox::c_string_character_source<char>::validate
179- let sample_function = view. function_at ( & platform, 0x2bd80 ) . unwrap ( ) ;
181+ let sample_function = view. function_at ( & platform, image_base + 0x2bd80 ) . unwrap ( ) ;
180182 let llil_function = sample_function. low_level_il ( ) . unwrap ( ) ;
181183 let llil_basic_blocks = llil_function. basic_blocks ( ) ;
182184 let llil_basic_block_iter = llil_basic_blocks. iter ( ) ;
0 commit comments