MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / getRunningUSVFSProcesses

Function getRunningUSVFSProcesses

src/usvfsconnector.cpp:297–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297std::vector<HANDLE> getRunningUSVFSProcesses()
298{
299 std::vector<DWORD> pids;
300
301 {
302 size_t count = 0;
303 DWORD* buffer = nullptr;
304 if (!::usvfsGetVFSProcessList2(&count, &buffer)) {
305 log::error("failed to get usvfs process list");
306 return {};
307 }
308
309 if (buffer) {
310 pids.assign(buffer, buffer + count);
311 std::free(buffer);
312 }
313 }
314
315 const auto thisPid = GetCurrentProcessId();
316 std::vector<HANDLE> v;
317
318 const auto rights =
319 PROCESS_QUERY_LIMITED_INFORMATION | // exit code, image name, etc.
320 SYNCHRONIZE | // wait functions
321 PROCESS_SET_QUOTA | PROCESS_TERMINATE; // add to job
322
323 for (auto&& pid : pids) {
324 if (pid == thisPid) {
325 continue; // obviously don't wait for MO process
326 }
327
328 HANDLE handle = ::OpenProcess(rights, FALSE, pid);
329
330 if (handle == INVALID_HANDLE_VALUE) {
331 const auto e = GetLastError();
332
333 log::warn("failed to open usvfs process {}: {}", pid, formatSystemMessage(e));
334
335 continue;
336 }
337
338 v.push_back(handle);
339 }
340
341 return v;
342}

Callers 1

Calls 1

assignMethod · 0.80

Tested by

no test coverage detected