@@ -25,34 +25,53 @@ def test_arm_qnx_sqrt(self):
2525 ql .run ()
2626
2727 def test_set_api_arm_qnx_sqrt (self ):
28+ self .set_api_puts_onenter = False
29+ self .set_api_puts_onexit = False
30+ self .set_api_printf_onenter = False
31+ self .set_api_printf_onexit = False
32+
2833 def my_puts_onenter (ql : Qiling ):
2934 params = ql .os .resolve_fcall_params ({'s' : STRING })
3035
3136 print (f'puts("{ params ["s" ]} ")' )
37+ self .set_api_puts_onenter = True
3238 return QL_CALL_BLOCK
3339
3440 def my_puts_onexit (ql : Qiling ):
3541 print (f'after puts' )
42+ self .set_api_puts_onexit = True
3643 return QL_CALL_BLOCK
3744
3845 def my_printf_onenter (ql : Qiling ):
3946 params = ql .os .resolve_fcall_params ({'s' : STRING })
4047
4148 print (f'printf("{ params ["s" ]} ")' )
49+ self .set_api_printf_onenter = True
4250 return QL_CALL_BLOCK
4351
4452 def my_printf_onexit (ql : Qiling ):
4553 print (f'after printf' )
54+ self .set_api_printf_onexit = True
4655 return QL_CALL_BLOCK
4756
4857 ql = Qiling (["../examples/rootfs/arm_qnx/bin/hello_sqrt" ], "../examples/rootfs/arm_qnx" , verbose = QL_VERBOSE .DEBUG )
4958 ql .set_api ('puts' , my_puts_onenter , QL_INTERCEPT .ENTER )
5059 ql .set_api ('printf' , my_printf_onenter , QL_INTERCEPT .ENTER )
5160
52- ql .set_api ('puts' , my_puts_onexit , QL_INTERCEPT .EXIT )
61+ # ql.set_api('puts', my_puts_onexit, QL_INTERCEPT.EXIT)
5362 ql .set_api ('printf' , my_printf_onexit , QL_INTERCEPT .EXIT )
5463
5564 ql .run ()
5665
66+ self .assertEqual (False , self .set_api_puts_onenter )
67+ self .assertEqual (False , self .set_api_puts_onexit )
68+ self .assertEqual (True , self .set_api_printf_onenter )
69+ self .assertEqual (True , self .set_api_printf_onexit )
70+
71+ del self .set_api_puts_onenter
72+ del self .set_api_puts_onexit
73+ del self .set_api_printf_onenter
74+ del self .set_api_printf_onexit
75+
5776if __name__ == "__main__" :
5877 unittest .main ()
0 commit comments