Skip to content

Conversation

@PhilippTakacs
Copy link
Contributor

This function allows to run from the current instruction pointer. Can be used when you allready manage all registers, so you don't need to read the instruction pointer and start unicorn with it.

for detailed error).
*/
UNICORN_EXPORT
uc_err uc_emu_run(uc_engine *uc, uint64_t until, uint64_t timeout,
Copy link
Member

Choose a reason for hiding this comment

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

I like the idea but I feel that the state after uc_emu_start is not always safe to start immediately, like those after errors.

uc_emu_start with a pc write shall reset states in most cases, but uc_emu_run does not. Do you think that introduces potential issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might be, I need to think about it a bit. But I have a few questions:

  • Which error states are not save to start immediately from?
  • does a pc write restore from a context does have the same effect?

Copy link
Member

Choose a reason for hiding this comment

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

Which error states are not save to start immediately from?

I can not really come up with one so I think this PR is mostly safe to go but let me review others firstly.

does a pc write restore from a context does have the same effect?

Writing a pc is always making the emulator to a clean state, at least I design it in this way.

@PhilippTakacs
Copy link
Contributor Author

An alternative way would be to implement this the other way around. So read the pc and call uc_emu_start. This way the pc write is done every time and state is reseted.

@wtdcode
Copy link
Member

wtdcode commented Jan 16, 2026

An alternative way would be to implement this the other way around. So read the pc and call uc_emu_start. This way the pc write is done every time and state is reseted.

But then that is not really worth a new API because users could do that by themselves.

@PhilippTakacs
Copy link
Contributor Author

I have added this to have a simpler API, not to avoid the reg_write. I just run into a bug because I forgot to update my local pc variable. I believe I'm not the only one who depends on a correct set pc register and just reads the pc to pass it to uc_emu_start. I would say having a simple to use API for this cases is worth it.

This function allows to run from the current instruction pointer.
Can be used when you allready manage all registers, so you don't need
to read the instruction pointer and start unicorn with it.
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.

2 participants