Skip to content

Commit

Permalink
Fixed environment/command line tables passed in at OS/2 process entry.
Browse files Browse the repository at this point in the history
This worked before on EMX-based binaries, but this fix makes it also work
on binaries compiled with Watcom C.
  • Loading branch information
icculus committed Oct 16, 2016
1 parent 544033f commit 6454917
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lx_loader.c
Expand Up @@ -346,6 +346,7 @@ static __attribute__((noreturn)) void runLxModule(LxModule *lxmod, const int arg
{
// Eventually, the environment table looks like this (double-null to terminate list): var1=a\0var2=b\0var3=c\0\0
// The command line looks like this: \0argv0\0argv1 argv2 argvN\0\0
// Between env and cmd is the exe name: argv0\0

size_t len = 1;
for (int i = 0; i < argc; i++) {
Expand All @@ -367,6 +368,8 @@ static __attribute__((noreturn)) void runLxModule(LxModule *lxmod, const int arg
len++; // terminator
} // for

len += strlen(argv[0]) + 1; // for the exe name.

const char *default_os2path = "PATH=C:\\home\\icculus\\Dropbox\\emx\\bin;C:\\home\\icculus"; // !!! FIXME: noooooope.
for (int i = 0; envp[i]; i++) {
const char *str = envp[i];
Expand Down Expand Up @@ -402,6 +405,10 @@ static __attribute__((noreturn)) void runLxModule(LxModule *lxmod, const int arg
}
*(ptr++) = '\0';

// put the exe name between the environment and the command line.
strcpy(ptr, argv[0]);
ptr += strlen(argv[0]) + 1;

char *cmd = ptr;
strcpy(ptr, argv[0]);
ptr += strlen(argv[0]);
Expand Down

0 comments on commit 6454917

Please sign in to comment.