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

Ability to set initial directrory #2833

Open
Dwedit opened this issue Feb 11, 2022 · 3 comments
Open

Ability to set initial directrory #2833

Dwedit opened this issue Feb 11, 2022 · 3 comments

Comments

@Dwedit
Copy link

@Dwedit Dwedit commented Feb 11, 2022

Feature type

Quality of life

Describe the feature

It seems that you can change the command line arguments using the File menu. But there is no way to do something similar to change the starting directory.

So far, the only way I found to change the starting directory was to restart X64dbg from the command line, explicitly passing in the command line and startup directory parameters.

So is there a way to simply add a second text box to the "Change Command Line" dialog box to specify the initial directory?

Using the "chd" command in the debugger does not affect the startup directory for the debugged application.

@mrexodia
Copy link
Member

@mrexodia mrexodia commented Feb 24, 2022

This came up in a discussion a while back too. There are currently two ways:

  1. Use x96dbg.exe (the launcher) to start your application from the directory you want
    • This has the issue of not remembering the working directory on restart
  2. Use the init command to specify the command line and working directory. This won't remember the working directory on restart either, but at least you can favorite the command.

I think it's a good idea to add functionality to change the working directory (similar to the command line), and then also handle saving the working directory in a similar way.

@rajkumarananthu
Copy link
Contributor

@rajkumarananthu rajkumarananthu commented Mar 6, 2022

Hi @mrexodia I am planning on attempting to implement this feature, below is the description of the possibility I am thinking:

  1. Add an action to change the initial directory to file menu.
  2. Get the absolute path from the user, which should be set as current folder.
  3. Set the current folder using current folder member in INIT_STRUCT using dbgcreatedebugthread.
  4. When using the run action or restart as admin, we will use this path to pass to ShellExecuteW() function as current working directory.

I didn't get the last part "saving the working directory". Can you please explain it and please let me know what you think of my approach. And also if possible can you assign this issue to me.

Thanks
Rajkumar Ananthu.

@mrexodia
Copy link
Member

@mrexodia mrexodia commented Mar 6, 2022

Thanks for picking this up! Check out the code related to the command line here: https://github.com/x64dbg/x64dbg/blob/development/src/dbg/commandline.cpp

The option changes the command line while the process is running (by modifying the UNICODE_STRING in the PEB). This is a bit more flexible and it makes it so you don’t have to worry about the CreateProcess call used to start the debuggee.

Perhaps you can start by implementing a command that sets the working directory, the GUI should only be a few lines from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants