Thanks to visit codestin.com
Credit goes to github.com

Skip to content

python: Support CPUID hooks #1618

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

Merged
merged 2 commits into from
May 17, 2022
Merged

python: Support CPUID hooks #1618

merged 2 commits into from
May 17, 2022

Conversation

ekilmer
Copy link
Contributor

@ekilmer ekilmer commented May 16, 2022

This functionality seems to be missing for the Python bindings when it was added in these commits 9d8a309 7bb7562

Not sure if there's anything else that's missing (or incorrect) for the bindings, but this works for me. I mostly followed the pattern of the other callbacks.

@mrexodia
Copy link
Contributor

Thanks a lot, I also needed this recently from python and had to manually modify the package...

@wtdcode
Copy link
Member

wtdcode commented May 17, 2022

Hello, thanks for your PR. Note the target branch should be the dev branch and you miss the python annotations.

@ekilmer ekilmer changed the base branch from master to dev May 17, 2022 21:30
@ekilmer
Copy link
Contributor Author

ekilmer commented May 17, 2022

I've made the changes @wtdcode . Let me know if there's anything else blocking this PR for merging.

@@ -817,6 +824,8 @@ def hook_add(self, htype: int, callback: UC_HOOK_CALLBACK_TYPE , user_data: Any=
cb = ctypes.cast(UC_HOOK_INSN_OUT_CB(self._hook_insn_out_cb), UC_HOOK_INSN_OUT_CB)
if arg1 in (x86_const.UC_X86_INS_SYSCALL, x86_const.UC_X86_INS_SYSENTER): # SYSCALL/SYSENTER instruction
cb = ctypes.cast(UC_HOOK_INSN_SYSCALL_CB(self._hook_insn_syscall_cb), UC_HOOK_INSN_SYSCALL_CB)
if arg1 == x86_const.UC_X86_INS_CPUID: # CPUID instruction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See UC_HOOK_CALLBACK_TYPE and add this hook to the possible callback types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

@wtdcode wtdcode merged commit 2800561 into unicorn-engine:dev May 17, 2022
@wtdcode
Copy link
Member

wtdcode commented May 17, 2022

Merged and welcome! ;)

@ekilmer ekilmer deleted the python-binding-hook-cpuid branch May 17, 2022 22:19
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

Successfully merging this pull request may close these issues.

3 participants