@@ -952,6 +952,35 @@ static void test_x86_eflags_reserved_bit()
952
952
OK (uc_close (uc ));
953
953
}
954
954
955
+ static void test_x86_nested_uc_emu_start_exits_cb (uc_engine * uc , uint64_t addr ,
956
+ size_t size , void * data )
957
+ {
958
+ OK (uc_emu_start (uc , code_start + 5 , code_start + 6 , 0 , 0 ));
959
+ }
960
+
961
+ static void test_x86_nested_uc_emu_start_exits ()
962
+ {
963
+ uc_engine * uc ;
964
+ // cmp eax, 0
965
+ // jnz t
966
+ // nop <-- nested emu_start
967
+ // t:mov dword ptr [eax], 0
968
+ char code [] = "\x83\xf8\x00\x75\x01\x90\xc7\x00\x00\x00\x00\x00" ;
969
+ uc_hook hk ;
970
+ uint32_t r_pc ;
971
+
972
+ uc_common_setup (& uc , UC_ARCH_X86 , UC_MODE_32 , code , sizeof (code ) - 1 );
973
+
974
+ OK (uc_hook_add (uc , & hk , UC_HOOK_CODE , test_x86_nested_uc_emu_start_exits_cb ,
975
+ NULL , code_start , code_start ));
976
+ OK (uc_emu_start (uc , code_start , code_start + 5 , 0 , 0 ));
977
+ OK (uc_reg_read (uc , UC_X86_REG_EIP , & r_pc ));
978
+
979
+ TEST_CHECK (r_pc == code_start + 5 );
980
+
981
+ OK (uc_close (uc ));
982
+ }
983
+
955
984
TEST_LIST = {
956
985
{"test_x86_in" , test_x86_in },
957
986
{"test_x86_out" , test_x86_out },
@@ -983,4 +1012,5 @@ TEST_LIST = {
983
1012
{"test_x86_nested_emu_stop" , test_x86_nested_emu_stop },
984
1013
{"test_x86_64_nested_emu_start_error" , test_x86_64_nested_emu_start_error },
985
1014
{"test_x86_eflags_reserved_bit" , test_x86_eflags_reserved_bit },
1015
+ {"test_x86_nested_uc_emu_start_exits" , test_x86_nested_uc_emu_start_exits },
986
1016
{NULL , NULL }};
0 commit comments