unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.59k stars 1.34k forks source link

EIP value in callback UC_HOOK_MEM_UNMAPPED depends on UC_HOOK_CODE registration (x86) #2040

Open boborjan2 opened 5 days ago

boborjan2 commented 5 days ago

I get different eip values in the unmapped mem callback for the very same binary if I register a code hook instead of a block hook. Seemingly eip gets updated in some part of the code that depends on the existance of a code hook. (if there is a code hook, eip precisely points to the instruction making the failed access) What I see is that env->eip is different is store_helper() where the unmapped hook is called from. I haven't made any deep analysis hoping the phenomenon might ring some bells regarding code hook implementation.

Thanks for the help, Viktor

wtdcode commented 5 days ago

1643