Implement support for a SYS:ENV attribute on executable
__flatten_process_args() does now have the executable path as an additional (optional) parameter. If specified, the function will read the file's SYS:ENV attribute (if set) and use its value to modified the environment it is preparing for the new process. Currently supported attribute values are strings consisting of "<var>=<value>" substrings separated by "\0" (backslash zero), with '\' being used as an escape character. The environment will be altered to contain the specified "<var>=<value>" elements, replacing a preexisting <var> element (if any). A possible use case would be setting a SYS:ENV attribute with value "DISABLE_ASLR=1" on an executable that needs ASLR disabled.
This commit is contained in:
@@ -90,15 +90,15 @@ load_program(const char* const* args, int32 argCount, bool traceLoading)
|
||||
mutableArgs[0] = programPath.c_str();
|
||||
|
||||
// count environment variables
|
||||
int envCount = 0;
|
||||
int32 envCount = 0;
|
||||
while (environ[envCount] != NULL)
|
||||
envCount++;
|
||||
|
||||
// flatten the program args and environment
|
||||
char** flatArgs = NULL;
|
||||
size_t flatArgsSize;
|
||||
error = __flatten_process_args(mutableArgs, argCount, environ, envCount,
|
||||
&flatArgs, &flatArgsSize);
|
||||
error = __flatten_process_args(mutableArgs, argCount, environ, &envCount,
|
||||
mutableArgs[0], &flatArgs, &flatArgsSize);
|
||||
|
||||
// load the program
|
||||
thread_id thread;
|
||||
|
||||
Reference in New Issue
Block a user