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

Is there a way to executu multiple command or a script in conditional breakpoint? #3335

Open
ShadowZzj opened this issue Apr 10, 2024 · 9 comments
Labels
feature The issue requests a new feature. priority The issue has priority. question The issue is a question.

Comments

@ShadowZzj
Copy link

When the breakpoint is hit, I want to do two things. bp eax and bp ebx. Is there a way to automatically do that? I have tried conditional breakpoint, but it seems only support one command. Also, I've tried the script way using scriptload, but it just load the script and will not execute it automatically. I need to switch to the script window and execute it manually

@mrexodia
Copy link
Member

There is no (working) way to invoke a script on a breakpoint right now. But for your thing specifically you can use a ; to separate commands. Note that this doesn't scale nicely, but a command like bp eax; bp ebx should work fine. Another possibility is to write a plugin that does as many commands as you like (possibly in C# using https://github.com/x64dbg/DotX64Dbg)

@mrexodia mrexodia added the question The issue is a question. label Apr 10, 2024
@justanotheranonymoususer
Copy link
Contributor

I just discovered the ; way, it's cool that it works but it's a pain in the ass to work with.
Best I could do is to have a script that runs SetBreakpointCommand, but with each change I need to do the following:

  • save script file
  • switch to script tab
  • reload script
  • pause debugged app
  • run script
  • resume app and go back to cpu tab

If I could do all of the above in one click it would be so much better! Maybe I need to script the script runner

@torusrxxx
Copy link
Member

Current breakpoint command just runs a few commands without changing x64dbg to a paused state first, therefore some commands, like "run", could not be used. x64dbg have to properly enter a paused state before starting executing script. This has a big performance penalty. I think we need a separate property for conditional breakpoint where you can specify a label in the script to execute, so x64dbg knows it need to use a slower and different approach to properly handle this. This also means if your script contains no "run" command in this section, then the debuggee will be left in paused state.

@xorhex
Copy link

xorhex commented Jul 17, 2024

Hmm, the ; trick does not seem to work.

Screenshot from 2024-07-17 10-51-42

The first command gets executed but the remaining ones do not. Am I missing something?

Screenshot from 2024-07-17 10-53-18

Same thing happens when I use the command box at the bottom of the debugger window as well.

@mrexodia
Copy link
Member

You missed the documentation: https://help.x64dbg.com/en/latest/introduction/ConditionalBreakpoint.html#notes

You should not use commands that can change the running state of the debuggee (such as run) inside the breakpoint command, because these commands are unstable when used here. You can use break condition, command condition or $breakpointcondition instead.

@torusrxxx
Copy link
Member

There will be a new option "Script safe breakpoint". When enabled, x64dbg will properly enter a paused state before starting to execute commands, and then the user can use any command.

@torusrxxx torusrxxx added feature The issue requests a new feature. priority The issue has priority. labels Aug 25, 2024
@mrexodia
Copy link
Member

I think we should consider just making this the default @torusrxxx. The way things are designed currently is only causing confusion... That being said, it's a bit tricky because we'd have to schedule the commands on the command thread?

@torusrxxx
Copy link
Member

torusrxxx commented Aug 25, 2024

This way it will be slower, considering all the things that need to do when x64dbg is paused, including updating all GUI views, calling plugin callbacks, sending command to the command thread, etc. Certainly this feature should be disabled when the command is just to set EAX to 0. And don't forget the script will also be responsible to call run afterwards, we can't use break condition anymore (by making x64dbg into paused state the result of break condition is ignored).

@mrexodia
Copy link
Member

Perhaps then it will be better to introduce a way to set a full script in the conditional breakpoint tab? With the recent refactors from #3317 it is possible to set a newline-separated breakpoint command. If the users sets a multi-line script their intention was probably to schedule that script on a different thread (vs modifying the $breakpointcondition variable, which seems to be rather less likely scenario).

If possible, I just want to avoid adding more checkboxes with niche meanings that will only confuse the users...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature The issue requests a new feature. priority The issue has priority. question The issue is a question.
Projects
None yet
Development

No branches or pull requests

5 participants