| 540 | } |
| 541 | |
| 542 | void ProcessConnected(DWORD processId) |
| 543 | { |
| 544 | alreadyAttached.insert(processId); |
| 545 | |
| 546 | QString process = S(GetModuleFilename(processId).value_or(L"???")); |
| 547 | QMetaObject::invokeMethod(This, [process, processId] |
| 548 | { |
| 549 | ui.processCombo->addItem(QString::number(processId, 16).toUpper() + ": " + QFileInfo(process).fileName()); |
| 550 | }); |
| 551 | if (process == "???") return; |
| 552 | |
| 553 | // This does add (potentially tons of) duplicates to the file, but as long as I don't perform Ω(N^2) operations it shouldn't be an issue |
| 554 | QTextFile(GAME_SAVE_FILE, QIODevice::WriteOnly | QIODevice::Append).write((process + "\n").toUtf8()); |
| 555 | |
| 556 | QStringList allProcesses = QString(QTextFile(HOOK_SAVE_FILE, QIODevice::ReadOnly).readAll()).split("\n", QString::SkipEmptyParts); |
| 557 | auto hookList = std::find_if(allProcesses.rbegin(), allProcesses.rend(), [&](QString hookList) { return hookList.contains(process); }); |
| 558 | if (hookList != allProcesses.rend()) |
| 559 | for (auto hookInfo : hookList->split(" , ")) |
| 560 | if (auto hp = HookCode::Parse(S(hookInfo))) Host::InsertHook(processId, hp.value()); |
| 561 | else swscanf_s(S(hookInfo).c_str(), L"|%I64d:%I64d:%[^\n]", &savedThreadCtx, &savedThreadCtx2, savedThreadCode, (unsigned)std::size(savedThreadCode)); |
| 562 | } |
| 563 | |
| 564 | void ProcessDisconnected(DWORD processId) |
| 565 | { |
nothing calls this directly
no test coverage detected