Skip to content

Commit 56c5b1b

Browse files
committed
fix(judge): close #251
From https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw We know that > If both lpApplicationName and lpCommandLine are non-NULL, the null-terminated string pointed to by lpApplicationName specifies the module to execute, and the null-terminated string pointed to by lpCommandLine specifies the command line. The new process can use GetCommandLine to retrieve the entire command line. Console processes written in C can use the argc and argv arguments to parse the command line. Because argv[0] is the module name, C programmers generally repeat the module name as the first token in the command line. So if we want to use paramater lpApplicationName, we have to repeat it in lpCommandLine. Considering this, I choose to leave lpApplicationName null.
1 parent a5d3ab8 commit 56c5b1b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/core/judgingthread.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,10 @@ void JudgingThread::runProgram() {
898898

899899
QString environmentValues = environment.toStringList().join(QChar('\0')) + '\0';
900900

901-
if (! CreateProcessW((WCHAR *)executableFile.utf16(), (WCHAR *)(arguments).toStdWString().data(), NULL,
902-
&sa, TRUE, HIGH_PRIORITY_CLASS | EXTENDED_STARTUPINFO_PRESENT | DETACHED_PROCESS,
901+
QString commandLine = QString(R"("%1" %2)").arg(executableFile).arg(arguments);
902+
903+
if (! CreateProcessW(nullptr, (WCHAR *)(commandLine).utf16(), nullptr, &sa, TRUE,
904+
HIGH_PRIORITY_CLASS | EXTENDED_STARTUPINFO_PRESENT | DETACHED_PROCESS,
903905
(LPVOID)(environmentValues.toLocal8Bit().data()),
904906
(const WCHAR *)(workingDirectory.utf16()), (STARTUPINFO *)(&siex), &pi)) {
905907
score = 0;

0 commit comments

Comments
 (0)