| 57 | } |
| 58 | |
| 59 | void Kernel::UpdateInjection(bool enableInjection, std::optional<uint32_t> currentlyTargettedPid, |
| 60 | std::optional<std::string> overrideTargetName, |
| 61 | const GfxLayer::Extension::OverlayConfig& cfg) |
| 62 | { |
| 63 | HandleMarshalledException_(); |
| 64 | auto config = cfg; |
| 65 | pInjectorComplex->SetActive(enableInjection); |
| 66 | if (enableInjection) { |
| 67 | if (overrideTargetName) { |
| 68 | pInjectorComplex->ChangeTarget(std::move(*overrideTargetName)); |
| 69 | } |
| 70 | else if (currentlyTargettedPid) { |
| 71 | try { |
| 72 | auto hProc = cwin::OpenProcess(*currentlyTargettedPid); |
| 73 | auto modName = cwin::GetExecutableModulePath(hProc).filename().string(); |
| 74 | pInjectorComplex->ChangeTarget(std::move(modName)); |
| 75 | } |
| 76 | catch (...) { |
| 77 | pmlog_warn("Failed target process lookup").pmwatch(*currentlyTargettedPid); |
| 78 | pInjectorComplex->ChangeTarget({}); |
| 79 | } |
| 80 | } |
| 81 | pInjectorComplex->UpdateConfig(cfg); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | void Kernel::ClearOverlay() |
| 86 | { |