| 285 | } |
| 286 | |
| 287 | void AppManagerWinImpl::InjectCaptureDllForNormalApp() { |
| 288 | if (target_pid_ <= 0) { |
| 289 | return; |
| 290 | } |
| 291 | |
| 292 | auto processes = ProcessHelper::GetProcessList(false); |
| 293 | ProcessInfoPtr target_process_info = nullptr; |
| 294 | for (const auto& process : processes) { |
| 295 | if (process->pid_ == target_pid_) { |
| 296 | target_process_info = process; |
| 297 | auto process_exe_name = FileUtil::GetFileNameFromPath(process->exe_full_path_); |
| 298 | //LOGI("Find the pid: {}, exe : {}", process->pid_, process_exe_name); |
| 299 | break; |
| 300 | } |
| 301 | } |
| 302 | if (!target_process_info) { |
| 303 | LOGI("Can't find process info now: {}", target_pid_); |
| 304 | return; |
| 305 | } |
| 306 | |
| 307 | if (!target_process_info->Valid()) { |
| 308 | auto target_exe_name = FileUtil::GetFileNameFromPath(settings_->app_.game_path_); |
| 309 | LOGE("Can't find app to inject, pid: {}, search for by exe: {}", target_pid_, target_exe_name); |
| 310 | uint32_t pid_by_exe = 0; |
| 311 | for (const auto& process : processes) { |
| 312 | auto process_exe_name = FileUtil::GetFileNameFromPath(process->exe_full_path_); |
| 313 | if (process_exe_name == target_exe_name) { |
| 314 | LOGI("find target process exe: {}, pid: {}", target_exe_name, pid_by_exe); |
| 315 | pid_by_exe = process->pid_; |
| 316 | break; |
| 317 | } |
| 318 | } |
| 319 | if (pid_by_exe == 0) { |
| 320 | LOGE("find by exe failed, return."); |
| 321 | return; |
| 322 | } |
| 323 | target_pid_ = pid_by_exe; |
| 324 | } |
| 325 | |
| 326 | if (settings_->capture_.capture_video_type_ == Capture::kCaptureScreen) { |
| 327 | AddFoundPid(target_process_info); |
| 328 | } |
| 329 | if (settings_->capture_.IsVideoInnerCapture()){ |
| 330 | auto result = WinHelper::IsDllInjected(target_process_info->pid_, kX86DllName, kX64DllName); |
| 331 | auto process_exe_name = FileUtil::GetFileNameFromPath(target_process_info->exe_full_path_); |
| 332 | if (result.ok_ && result.value_) { |
| 333 | LOGI("Pid: {} for: {} is already injected....", target_process_info->pid_, process_exe_name); |
| 334 | return; |
| 335 | } else { |
| 336 | LOGI("Not injected, will inject for pid: {}, exe: {}", target_process_info->pid_, process_exe_name); |
| 337 | } |
| 338 | |
| 339 | AddFoundPid(target_process_info); |
| 340 | |
| 341 | // before inject |
| 342 | MsgBeforeInject msg_before_inject{ |
| 343 | .pid_ = target_process_info->pid_, |
| 344 | }; |
nothing calls this directly
no test coverage detected