Replies: 3 comments 11 replies
-
@mxtsdev Will take a stab at answering these from memory - am traveling and can’t verify my answers right now, so take what I say with a grain of salt. Am pretty sure the Windows debuggers do not support saving breakpoints between runs. Ghidra will save them in the Breakpoints window, but you will have to re-enable them for each run. We considered re-enabling them automatically, but that has downsides as well, e.g. what if you wanted them saved but not enabled. All of that said, there’s a possibility if you restart from the Interpreter console that the underlying debugger will do the right thing. Haven’t tested this. Re conhost, I don’t believe so. It’s an interesting question, but I’m unaware of support for this in the dbgeng/dbgmodel API. Re exception information, I will have to check whether that’s available from the Interpreter. I am pretty sure the break event does not provide more info than we expose, but again I should check that. Re memory regions, for most targets forcing full view is not your best option. Assuming you have a populated Module list in the Modules window, most of the modules should map to loaded Ghidra programs by name. There are several reasons why they might not - the program could have been compiled with a different name, renamed on the file system, or renamed when loaded into Ghidra. The pull-down allows you to map a listed module to an existing program and that mapping will be remembered across runs. The process name should be a property on the process node in the Objects list, but we’re could definitely consider adding it to the display. Saving Event/Exception settings also seems like a pretty reasonable idea. |
Beta Was this translation helpful? Give feedback.
-
OK, getting back to work here....and I have an answer on the conhost question. If you start up dbgeng or dbgmodel in Targets, open Object->Connectors, select "Launch process", and then use the "Launch (X)" button to start debugging your target, you will notice a number of additional options for controlling the target/debugging session. In particular, the field "Create Flags" defaults to 1, which is DEBUG_PROCESS. If you set this to 2 (DEBUG_ONLY_THIS_PROCESS), only your target will be debugged and conhost will be ignored. On other fronts, have a fix in to add the executable name to the process node in Objects and a fix to write exception info to the Interpreter console. Looked into saving event/exception settings, but this is not something windbg does by default and there does not appear to be an obviously relevant API call. We can probably do it in Ghidra proper, but it's a bit messy. In the meantime, you could put the equivalent "sx*" commands in a file and execute that from the Interpreter on start-up. (Not ideal, I realize, but may take me a while to code up a clean Ghidra-only solution.) |
Beta Was this translation helpful? Give feedback.
-
Yep, the debugger is fully scriptable. As with all of Ghidra, the entire API is exposed. Dan has also simplified things considerably by writing a FlatDebuggerAPI, similar to the main flat API, that simplifies standard debugger tasks. That said, callbacks from inside debugger events are (I believe) currently restricted to the capabilities of the underlying native debugger, e.g. I don't believe it's currently possible to call Ghidra's scripting interface from inside a breakpoint handler. |
Beta Was this translation helpful? Give feedback.
-
After using the debugger in Ghidra for a while I have a few additional questions that I have not been able to find an answer to. They all pertain to dbgeng IN-VM debugger on a Windows x86-64 target.
Is it possible to set/enable breakpoints before a module is loaded and have these breakpoints activate when the module is loaded and remain set/enabled between (re)launches?
Is it possible to avoid attaching to the conhost process and focus solely on my target? Upon launch, the debugger is suspended in conhost multiple times, and I have to manually switch to the process I want to debug.
Is it possible to obtain more detailed information when the debugger breaks on an exception? I can't discern which exceptions are causing the debugger to suspend in order to disable automatic suspend for those exceptions.
Can anything be done when memory regions fail to be mapped correctly except manually activating “Force full view” on each launch? I have a bunch of dynamic memory regions that do not get mapped and are not loaded(saved?) in the trace. Goto fails, the memory can’t be viewed, and even with "Force full view" the right-click action "Goto ram:" in the registers view remains hidden for all those regions.
Some related notes:
Beta Was this translation helpful? Give feedback.
All reactions