Skip to content

Commit fa5b794

Browse files
committed
implement process checking for running processes using C APIs via FFI
1 parent c3a806e commit fa5b794

9 files changed

Lines changed: 316 additions & 144 deletions

File tree

.github/workflows/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
(Get-Content -Path "inno-setup.iss") -replace '#define MyAppVersion "[\d\.]+"', "#define MyAppVersion `"${{ env.NEW_VERSION }}`"" | Set-Content -Path "inno-setup.iss"
3131
shell: pwsh
3232

33+
- name: Compile C code
34+
run: gcc -shared -o process_checker.dll process_checker.c -lpsapi -O3
35+
working-directory: native_utils
36+
3337
- run: flutter gen-l10n
3438
working-directory: gui
3539

common/lib/src/commands/security_command.dart

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,16 @@ Virus and Threat Protections Status: ${_securityService.statusDefenderProtection
5151
exit(0);
5252
}
5353

54-
// TODO: Remove this whenever a new playbook gets released
55-
final isAMETempAvailable = await Directory(ameTemp).exists();
56-
if (isAMETempAvailable) {
54+
if (!isProcessRunning('explorer.exe')) {
5755
await Process.run('explorer.exe', const []);
5856
await Future.delayed(const Duration(seconds: 5));
5957
}
60-
//
6158

6259
stdout.writeln('$tag Disabling Windows Defender...');
6360

6461
stdout.writeln(
65-
'$tag Checking if Virus and Threat Protections are enabled...');
62+
'$tag Checking if Virus and Threat Protections are enabled...',
63+
);
6664
int count = 0;
6765
while (_securityService.statusDefenderProtections) {
6866
if (count > 10) {
@@ -72,7 +70,8 @@ Virus and Threat Protections Status: ${_securityService.statusDefenderProtection
7270

7371
if (!_securityService.statusDefenderProtectionTamper) {
7472
await _shell.run(
75-
'PowerShell -EP Unrestricted -NonInteractive -NoLogo -NoP Set-MpPreference -DisableRealtimeMonitoring \$true');
73+
'PowerShell -EP Unrestricted -NonInteractive -NoLogo -NoP Set-MpPreference -DisableRealtimeMonitoring \$true',
74+
);
7675
break;
7776
}
7877

@@ -84,10 +83,6 @@ Virus and Threat Protections Status: ${_securityService.statusDefenderProtection
8483
}
8584
await Process.run('taskkill', ['/f', '/im', 'SecHealthUI.exe']);
8685

87-
if (isAMETempAvailable) {
88-
await Process.run('taskkill', ['/f', '/im', 'explorer.exe']);
89-
}
90-
9186
try {
9287
await _securityService.disableDefender();
9388
} on Exception catch (e) {

0 commit comments

Comments
 (0)