43 if (!SetInformationJobObject(g_ContainerJob, JobObjectExtendedLimitInformation, &limits,
sizeof(limits))) {
56 if (GetFileAttributesA(mlPath.c_str()) != INVALID_FILE_ATTRIBUTES) {
60 if (!CreateContainerJob()) {
64 STARTUPINFOA startupInfo;
65 PROCESS_INFORMATION processInformation;
67 ZeroMemory(&startupInfo,
sizeof(startupInfo));
68 startupInfo.cb =
sizeof(startupInfo);
69 ZeroMemory(&processInformation,
sizeof(processInformation));
71 for (
auto containerType : extensibility) {
75 DWORD creationFlags = CREATE_SUSPENDED;
77 DWORD creationFlags = CREATE_SUSPENDED | CREATE_NO_WINDOW;
82 (LPSTR)cmdStr.c_str(),
99 BOOL assigned = AssignProcessToJobObject(g_ContainerJob, processInformation.hProcess);
101 ResumeThread(processInformation.hThread);
104 TerminateProcess(processInformation.hProcess, 1);
106 CloseHandle(processInformation.hThread);
107 CloseHandle(processInformation.hProcess);
129 if (exe.empty() || GetFileAttributesW(exe.c_str()) == INVALID_FILE_ATTRIBUTES) {
131 std::cerr <<
"PanoptesDetector.exe is not next to the service; behavioral rules are off" << std::endl;
134 if (!CreateContainerJob()) {
138 std::wstring folder = exe.substr(0, exe.find_last_of(L
'\\'));
139 std::wstring commandLine = L
"\"" + exe + L
"\" -rules \"" + folder + L
"\\rules\"";
143 commandLine += L
" -debug-service";
144 DWORD creationFlags = CREATE_SUSPENDED;
146 DWORD creationFlags = CREATE_SUSPENDED | CREATE_NO_WINDOW;
149 STARTUPINFOW startupInfo{};
150 startupInfo.cb =
sizeof(startupInfo);
151 PROCESS_INFORMATION processInformation{};
152 if (!CreateProcessW(exe.c_str(), commandLine.data(), NULL, NULL, FALSE, creationFlags, NULL,
153 folder.c_str(), &startupInfo, &processInformation)) {
154 std::cerr <<
"Failed to start PanoptesDetector.exe (error " << GetLastError() <<
")" << std::endl;
159 BOOL assigned = AssignProcessToJobObject(g_ContainerJob, processInformation.hProcess);
161 ResumeThread(processInformation.hThread);
164 TerminateProcess(processInformation.hProcess, 1);
166 CloseHandle(processInformation.hThread);
167 CloseHandle(processInformation.hProcess);