Allow ASLR to be disabled on Windows

On Windows, it is possible to disable ASLR when creating a process.
This patch adds code to do this, and hooks it up to gdb's existing
disable-randomization feature.  Because the Windows documentation
cautions that this isn't available on all versions of Windows, the
CreateProcess wrapper function is updated to make the attempt, and
then fall back to the current approach if it fails.
This commit is contained in:
Tom Tromey
2021-09-08 08:20:29 -06:00
parent 8fea1a81c7
commit bcb9251f02
6 changed files with 164 additions and 4 deletions

View File

@ -586,6 +586,7 @@ create_process (const char *program, char *args,
(inferior_cwd.empty ()
? NULL
: gdb_tilde_expand (inferior_cwd.c_str ()).c_str()),
get_client_state ().disable_randomization,
&si, /* start info */
pi); /* proc info */

View File

@ -165,6 +165,11 @@ public:
{ return true; }
const char *pid_to_exec_file (int pid) override;
bool supports_disable_randomization () override
{
return windows_nat::disable_randomization_available ();
}
};
/* The sole Windows process. */