| 168 | // Check if the dsc binary parent process is WinStore.App or Explorer.exe |
| 169 | #[cfg(windows)] |
| 170 | fn check_store() { |
| 171 | use std::io::Read; |
| 172 | |
| 173 | let sys = System::new_with_specifics(RefreshKind::nothing().with_processes(ProcessRefreshKind::everything())); |
| 174 | // get current process |
| 175 | let Ok(current_pid) = get_current_pid() else { |
| 176 | return; |
| 177 | }; |
| 178 | |
| 179 | // get parent process |
| 180 | let Some(current_process) = sys.process(current_pid) else { |
| 181 | return; |
| 182 | }; |
| 183 | let Some(parent_process_pid) = current_process.parent() else { |
| 184 | return; |
| 185 | }; |
| 186 | let Some(parent_process) = sys.process(parent_process_pid) else { |
| 187 | return; |
| 188 | }; |
| 189 | |
| 190 | // MS Store runs app using `sihost.exe` |
| 191 | if parent_process.name().eq_ignore_ascii_case("sihost.exe") || parent_process.name().eq_ignore_ascii_case("explorer.exe") { |
| 192 | eprintln!("{}", t!("main.storeMessage")); |
| 193 | // wait for keypress |
| 194 | let _ = io::stdin().read(&mut [0u8]).unwrap(); |
| 195 | exit(util::EXIT_INVALID_ARGS); |
| 196 | } |
| 197 | } |