Skip to content

Commit e8bb73e

Browse files
committed
chore: drop windows 7 support
1 parent 2019bd6 commit e8bb73e

File tree

3 files changed

+74
-75
lines changed

3 files changed

+74
-75
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ A tiny judging environment for OI contest based on Lemon + LemonPlus
3030

3131
| 系统名称 | 版本号 | 架构 | DE / WM |
3232
|:-------------------:|:----------:|:----------:|:--------------:|
33-
| Windows | 7 | x86, amd64 | Untitled |
3433
| Windows | 10 | amd64 | Untitled |
34+
| Windows | 11 | amd64 | Untitled |
3535
| Manjaro | 20.0.1 | amd64 | KDE-Xorg; i3WM |
3636
| Arch | 2021-07-11 | amd64 | KDE-Xorg |
3737
| Arch | 2020-10-31 | amd64 | KDE-Wayland |

makespec/BUILDVERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
234
1+
235

src/core/judgingthread.cpp

Lines changed: 72 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -622,95 +622,93 @@ void JudgingThread::runProgram() {
622622
ZeroMemory(&sa, sizeof(sa));
623623
sa.bInheritHandle = TRUE;
624624

625-
if (IsWindows8OrGreater()) {
626-
// Create Window App Container (Windows 8+)
625+
PSID appContainerSID{nullptr};
626+
QString appContainerName = "Lemonlime" + getRandomString(10);
627627

628-
PSID appContainerSID{nullptr};
629-
QString appContainerName = "Lemonlime" + getRandomString(10);
628+
// Create Window App Container (Windows 8+)
630629

631-
auto hResult = CreateAppContainerProfile((const WCHAR *)(appContainerName.utf16()),
632-
(const WCHAR *)(appContainerName.utf16()),
633-
(const WCHAR *)(appContainerName.utf16()), nullptr, 0,
634-
&appContainerSID); // Without any Permissions
630+
auto hResult = CreateAppContainerProfile((const WCHAR *)(appContainerName.utf16()),
631+
(const WCHAR *)(appContainerName.utf16()),
632+
(const WCHAR *)(appContainerName.utf16()), nullptr, 0,
633+
&appContainerSID); // Without any Permissions
635634

636-
if (hResult != S_OK) {
637-
score = 0;
638-
result = CannotStartProgram;
639-
message = "Failed to create app container";
640-
return;
641-
}
635+
if (hResult != S_OK) {
636+
score = 0;
637+
result = CannotStartProgram;
638+
message = "Failed to create app container";
639+
return;
640+
}
642641

643-
auto cleanupContainer = qScopeGuard([&] {
644-
FreeSid(appContainerSID);
645-
DeleteAppContainerProfile((const WCHAR *)(appContainerName.utf16()));
646-
});
642+
auto cleanupContainer = qScopeGuard([&] {
643+
FreeSid(appContainerSID);
644+
DeleteAppContainerProfile((const WCHAR *)(appContainerName.utf16()));
645+
});
647646

648-
SECURITY_CAPABILITIES sc;
649-
ZeroMemory(&sc, sizeof(sc));
647+
SECURITY_CAPABILITIES sc;
648+
ZeroMemory(&sc, sizeof(sc));
650649

651-
sc.AppContainerSid = appContainerSID;
650+
sc.AppContainerSid = appContainerSID;
652651

653-
SIZE_T attributesSize;
652+
SIZE_T attributesSize;
654653

655-
InitializeProcThreadAttributeList(nullptr, 3, 0, &attributesSize);
654+
InitializeProcThreadAttributeList(nullptr, 3, 0, &attributesSize);
656655

657-
auto attributesListBuffer = std::make_unique<std::byte[]>(attributesSize);
658-
siex.lpAttributeList = reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(attributesListBuffer.get());
656+
auto attributesListBuffer = std::make_unique<std::byte[]>(attributesSize);
657+
siex.lpAttributeList = reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(attributesListBuffer.get());
659658

660-
if (! InitializeProcThreadAttributeList(siex.lpAttributeList, 3, 0, &attributesSize)) {
661-
score = 0;
662-
result = CannotStartProgram;
663-
message = "Internal error (Failed to InitializeProcThreadAttributeList())";
664-
return;
665-
}
659+
if (! InitializeProcThreadAttributeList(siex.lpAttributeList, 3, 0, &attributesSize)) {
660+
score = 0;
661+
result = CannotStartProgram;
662+
message = "Internal error (Failed to InitializeProcThreadAttributeList())";
663+
return;
664+
}
666665

667-
// Make App Run in App Container
668-
if (! UpdateProcThreadAttribute(siex.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_SECURITY_CAPABILITIES,
669-
&sc, sizeof(sc), nullptr, nullptr)) {
670-
score = 0;
671-
result = CannotStartProgram;
672-
message = "Internal error (Failed to UpdateProcThreadAttribute())";
673-
return;
674-
}
666+
// Make App Run in App Container
667+
if (! UpdateProcThreadAttribute(siex.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_SECURITY_CAPABILITIES, &sc,
668+
sizeof(sc), nullptr, nullptr)) {
669+
score = 0;
670+
result = CannotStartProgram;
671+
message = "Internal error (Failed to UpdateProcThreadAttribute())";
672+
return;
673+
}
675674

676-
// Ban Child Processs
675+
// Ban Child Processs
677676

678-
DWORD childProcessAttribute = PROCESS_CREATION_CHILD_PROCESS_RESTRICTED;
677+
DWORD childProcessAttribute = PROCESS_CREATION_CHILD_PROCESS_RESTRICTED;
679678

680-
if (! UpdateProcThreadAttribute(siex.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_CHILD_PROCESS_POLICY,
681-
&childProcessAttribute, sizeof(childProcessAttribute), nullptr,
682-
nullptr)) {
683-
score = 0;
684-
result = CannotStartProgram;
685-
message = "Internal error (Failed to UpdateProcThreadAttribute())";
686-
return;
687-
}
679+
if (! UpdateProcThreadAttribute(siex.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_CHILD_PROCESS_POLICY,
680+
&childProcessAttribute, sizeof(childProcessAttribute), nullptr,
681+
nullptr)) {
682+
score = 0;
683+
result = CannotStartProgram;
684+
message = "Internal error (Failed to UpdateProcThreadAttribute())";
685+
return;
686+
}
688687

689-
// Load dlls
690-
// Todo: If there's too many files under the path it'll be very slow
691-
for (auto f : environment.value("PATH").split(';')) {
692-
grantFileAccessPermissions(appContainerSID, (WCHAR *)f.utf16(), FILE_ALL_ACCESS);
693-
}
688+
// Load dlls
689+
// Todo: If there's too many files under the path it'll be very slow
690+
for (auto f : environment.value("PATH").split(';')) {
691+
grantFileAccessPermissions(appContainerSID, (WCHAR *)f.utf16(), FILE_ALL_ACCESS);
692+
}
694693

695-
if (! task->getStandardInputCheck()) {
696-
grantFileAccessPermissions(appContainerSID,
697-
(WCHAR *)(workingDirectory + task->getInputFileName()).utf16(),
698-
FILE_GENERIC_READ);
699-
}
694+
if (! task->getStandardInputCheck()) {
695+
grantFileAccessPermissions(appContainerSID,
696+
(WCHAR *)(workingDirectory + task->getInputFileName()).utf16(),
697+
FILE_GENERIC_READ);
698+
}
700699

701-
if (! task->getStandardOutputCheck()) {
702-
grantFileAccessPermissions(appContainerSID, (WCHAR *)(workingDirectory).utf16(),
703-
FILE_GENERIC_READ | FILE_ADD_FILE);
704-
grantFileAccessPermissions(appContainerSID,
705-
(WCHAR *)(workingDirectory + task->getOutputFileName()).utf16(),
706-
FILE_GENERIC_READ | FILE_GENERIC_WRITE);
707-
}
700+
if (! task->getStandardOutputCheck()) {
701+
grantFileAccessPermissions(appContainerSID, (WCHAR *)(workingDirectory).utf16(),
702+
FILE_GENERIC_READ | FILE_ADD_FILE);
703+
grantFileAccessPermissions(appContainerSID,
704+
(WCHAR *)(workingDirectory + task->getOutputFileName()).utf16(),
705+
FILE_GENERIC_READ | FILE_GENERIC_WRITE);
706+
}
708707

709-
if (task->getStandardInputCheck()) {
710-
siex.StartupInfo.hStdInput = CreateFileW((const WCHAR *)(inputFile.utf16()), GENERIC_READ,
711-
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
712-
&sa, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
713-
}
708+
if (task->getStandardInputCheck()) {
709+
siex.StartupInfo.hStdInput = CreateFileW((const WCHAR *)(inputFile.utf16()), GENERIC_READ,
710+
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, &sa,
711+
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
714712
}
715713

716714
if (task->getStandardOutputCheck()) {
@@ -737,11 +735,12 @@ void JudgingThread::runProgram() {
737735

738736
QString environmentValues = environment.toStringList().join(QChar('\0')) + '\0';
739737

740-
if (! CreateProcessW((WCHAR *)executableFile.utf16(), (WCHAR *)(arguments).utf16(), NULL, &sa, TRUE,
741-
HIGH_PRIORITY_CLASS | EXTENDED_STARTUPINFO_PRESENT | DETACHED_PROCESS,
738+
if (! CreateProcessW((WCHAR *)executableFile.utf16(), (WCHAR *)(arguments).toStdWString().data(), NULL,
739+
&sa, TRUE, HIGH_PRIORITY_CLASS | EXTENDED_STARTUPINFO_PRESENT | DETACHED_PROCESS,
742740
(LPVOID)(environmentValues.toLocal8Bit().data()),
743741
(const WCHAR *)(workingDirectory.utf16()), (STARTUPINFO *)(&siex), &pi)) {
744742
score = 0;
743+
qDebug() << GetLastError();
745744
result = CannotStartProgram;
746745
message = "Failed to create process";
747746
return;

0 commit comments

Comments
 (0)