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
Comments
|
This came up in a discussion a while back too. There are currently two ways:
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. |
|
Hi @mrexodia I am planning on attempting to implement this feature, below is the description of the possibility I am thinking:
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 |
|
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. |
|
Hi @mrexodia , Thanks for the input, I went through the flow how the command line options are changed and I am using the same to change the I almost completed the process, but stuck at the point where you are capturing the command line arguments from instructions as follows: can you please guide me how to find current directory equivalents for these instructions? Thanks |
|
You can find some relevant code here: https://github.com/sonicmouse/ProcCmdLine/blob/master/ProcessHelper.cpp#L66 This is just to get it, but to set it you modify the UNICODE_STRING to point to your newly allocated buffer. |
|
Hi @mrexodia , thanks for the pointer, I think that pointer given by you will work for getting the initial directory that is set(through writing to PEB location), but my question is while setting the initial directory. If you see for changing the command line: Line 2577 in a6313b4
Here we are running a function called fixgetcommandlinesbase(), this is changing the buffers some other place also using kernelbase:GetCommandLineA & kernelbase:GetCommandLineP and patchcmdline() function.Line 2436 in a6313b4
I similarly used Please guide me if I am on wrong track or anything wrong in my understanding so far. Thanks, PS: The |
|
Hm, I think you would have to reverse engineer and see what |
|
Is this issue suddenly about changing working directory at runtime? I thought this was about changing working directory at startup time. It's a parameter of CreateProcessW. |
|
You can already change the working directory at startup time, with the
command “init”
…On Thu, 10 Mar 2022 at 20:07, Dan Weiss ***@***.***> wrote:
Is this issue suddenly about changing working directory at runtime? I
thought this was about changing working directory at startup time.
—
Reply to this email directly, view it on GitHub
<#2833 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AASYFGPPCGDYA3NIXOQ5L7DU7JB5DANCNFSM5OFSSPPQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
It's about having the debugged EXE start up with a specific initial directory, and this option being remembered until the debugger is closed, or another EXE is opened in the debugger. Using the Restart command should keep it the startup directory the same. I created this issue before discovering the "init" command, due to not finding this anywhere in the documentation. I had checked the online help for how to set the startup directory. Looking for words like 'initial directory', 'startup directory', 'working directory', etc led nowhere. It turns out the documentation for the "init" command uses the phrase "Current Folder", which is different than any term I was looking for, Even with the "Init" command supporting setting a start directory, it's just as unfriendly as running it from the command prompt, especially if the setting doesn't persist after using the Restart button. |
|
If it cannot be modified at runtime the current idea for the implementation can be changed. I’ll update the documentation to include those phrases in the meantime. |
|
Applications can change the working directory, but they can't change the Command Line parameters. So changing the Current Working Directory and changing the Initial Directory really should be two different things. They shouldn't be unified under one text field. Not like the situation with the Command Line parameters, which don't change, so specifying the "now" value and the "next time" value are the same thing for command line parameters. |
|
🤷🏻♂️ I think it's fine. Once there is a function to change the working directory the details can be changed. For example if you set the working directory at the system breakpoint that could be the initial directory for the next startup. |
|
Hi @mrexodia , I tried searching for how SetCurrentDirectory() is implemented for reverse engineering, but couldn't find it, can you please help me here, may be I haven't put enough efforts here. |
|
I’m afraid it might be a bit more complicated than I thought. I’ll try to take a look, but I forgot that the working directory is more intricate than the command line |
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.
The text was updated successfully, but these errors were encountered: