NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
51.9k stars 5.89k forks source link

Start directory of executable inside debugger #6824

Closed Basssiiie closed 2 months ago

Basssiiie commented 3 months ago

Hello,

Is it possible to change or influence the starting directory for the process that is being debugged?

I'm trying to debug an executable that tries to read some local files at relative paths, but it can't find them because when the debugger is attached, it's looking at the D:\Programs\Ghidra\Debug\Debugger-agent-dbgeng\data\debugger-launchers\ directory instead of the folder where the executable is located. This causes the exe to throw errors because it cannot find the files.

I'm currently using Ghidra v11.1.2 with dbgeng on IN-VM on Windows 10.

Thank you for your time!

d-millar commented 3 months ago

@Basssiiie This may or may not work, but it's worth a shot....

(1) Using the "Debugger Targets" CreateConnection button, start "MS dbgeng.dll (Windbg)". (2) In the Objects' tree, open the "Connectors" node and highlight "Launch Process". (3) Use the "Launch (X)" button to pull up the advanced Launch dialog (4) Specify the starting directory in the "Dir" field.

There are a couple of kinds of "starting directory" from a Windows process's perspective. This will set one of them. Bear in mind too, some processes remember their starting directory from the last execution.

Basssiiie commented 3 months ago

Hey d-miller,

Thank you for your reply. Your suggestion works! That specific kind of "starting directory" was the one that's necessary for this executable. Thanks a lot!

Maybe it would be a nice feature request to make it not so hidden, and make it part of the simpler launch/configure flow within Ghidra? 🙂

d-millar commented 3 months ago

@Basssiiie Well, funny you should mention that - we're moving from the IN-VM record clients to a python-based model, which we're hoping will be more straightforward. The advanced options will be a separate launcher in the main toolbar menu for the new model.