Add execve() test

This commit is contained in:
Justine Tunney 2022-04-21 19:56:21 -07:00
parent 38728cef79
commit a259e43d84
7 changed files with 75 additions and 13 deletions

View file

@ -60,7 +60,12 @@ textwindows noasan int mkntcmdline(char16_t cmdline[ARG_MAX], const char *prog,
int slashes, n;
bool needsquote;
char16_t cbuf[2];
char *ansiargv[2];
size_t i, j, k, s;
if (!argv[0]) {
bzero(ansiargv, sizeof(ansiargv));
argv = ansiargv;
}
for (arg = prog, k = i = 0; arg; arg = argv[++i]) {
if (i) APPEND(u' ');
if ((needsquote = NeedsQuotes(arg))) APPEND(u'"');

View file

@ -44,12 +44,12 @@ CreateProcess(const char16_t *opt_lpApplicationName, char16_t *lpCommandLine,
opt_lpCurrentDirectory, lpStartupInfo,
opt_out_lpProcessInformation);
if (!ok) __winerr();
NTTRACE(
"CreateFile(%#hs, %#hs, %s, %s, %hhhd, %u, %p, %#hs, %p, %p) → %hhhd% m",
opt_lpApplicationName, lpCommandLine,
DescribeNtSecurityAttributes(opt_lpProcessAttributes),
DescribeNtSecurityAttributes(opt_lpThreadAttributes), bInheritHandles,
dwCreationFlags, opt_lpEnvironment, opt_lpCurrentDirectory, lpStartupInfo,
opt_out_lpProcessInformation, ok);
NTTRACE("CreateProcess(%#hs, %#!hs, %s, %s, %hhhd, %u, %p, %#hs, %p, %p) → "
"%hhhd% m",
opt_lpApplicationName, lpCommandLine,
DescribeNtSecurityAttributes(opt_lpProcessAttributes),
DescribeNtSecurityAttributes(opt_lpThreadAttributes), bInheritHandles,
dwCreationFlags, opt_lpEnvironment, opt_lpCurrentDirectory,
lpStartupInfo, opt_out_lpProcessInformation, ok);
return ok;
}

View file

@ -42,7 +42,7 @@ bool32 CreateProcess(const char16_t *opt_lpApplicationName,
const char16_t *opt_lpCurrentDirectory,
const struct NtStartupInfo *lpStartupInfo,
struct NtProcessInformation *opt_out_lpProcessInformation)
paramsnonnull((2, 9));
paramsnonnull((9));
uint32_t GetThreadId(int64_t hThread); /* cf. NT_TID */
uint32_t GetProcessId(int64_t hProcess); /* cf. NT_PID */

View file

@ -251,7 +251,7 @@ __msabi static textwindows wontreturn void WinMainNew(const char16_t *cmdline) {
* @param hInstance call GetModuleHandle(NULL) from main if you need it
*/
__msabi textwindows int64_t WinMain(int64_t hInstance, int64_t hPrevInstance,
const char *lpCmdLine, int nCmdShow) {
const char *lpCmdLine, int64_t nCmdShow) {
const char16_t *cmdline;
extern char os asm("__hostos");
extern uint64_t ts asm("kStartTsc");