Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting PC in uc_cb_insn_sys_t callback does not take effect in ARM64 architecture #2058

Open
3093292237 opened this issue Dec 4, 2024 · 3 comments

Comments

@3093292237
Copy link

I am encountering an issue with the Unicorn Engine where setting the PC (Program Counter) in the uc_cb_insn_sys_t callback does not appear to take effect. Despite writing a new value to the PC register within the callback, the emulation continues to execute from the original PC value.
Notice that the emulation continues executing from the original PC address, not the updated one.

@wtdcode
Copy link
Member

wtdcode commented Dec 7, 2024

That should be expected because PC is not synced for those hooks.

What's your use case?

@3093292237
Copy link
Author

@wtdcode
I'm using the C API and I have added the following hook with the type UC_HOOK_INSN. When I try to modify the value of the PC in the callback, it doesn't take effect. This issue can be easily reproduced with the following code:
uc_hook_add(uc, &hook_INSN_MRS, UC_HOOK_INSN, (void*) instruction_handler, nullptr, 1, 0, UC_ARM64_INS_MRS)
This should clearly convey your issue with modifying the PC within the UC_HOOK_INSN callback.

@3093292237
Copy link
Author

@wtdcode The prototype of this hook is as follows:
uint32_t instruction_handler(uc_engine *uc, uc_arm64_reg reg,
const uc_arm64_cp_reg *cp_reg,
void *user_data)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants