forked from einsiedler90/Whonix-Starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
whonixstarter_main.pas
104 lines (84 loc) · 2.38 KB
/
whonixstarter_main.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
(*
* Whonix Starter ( whonixstarter_main.pas )
*
* Copyright: 2012 - 2023 ENCRYPTED SUPPORT LP <[email protected]>
* Author: [email protected]
* License: See the file COPYING for copying conditions.
*)
unit WhonixStarter_Main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
ComCtrls, Process, WhonixStarterAppConfig;
type
{ TMainForm }
TMainForm = class(TForm)
ButtonStartStop: TButton;
ButtonAdvanced: TButton;
procedure ButtonAdvancedClick(Sender: TObject);
procedure ButtonStartStopClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
end;
var
MainForm: TMainForm;
implementation
uses WhonixStarter_Error;
{$R *.lfm}
{ TMainForm }
procedure TMainForm.ButtonAdvancedClick(Sender: TObject);
var
Process: TProcess;
begin
if not FileExists(AppConfig.VirtualBoxPath) then
begin
ErrorForm.MemoError.Lines.Text := 'binary "VirtualBox" not found';
ErrorForm.ShowModal;
end;
Process := TProcess.Create(nil);
Process.CommandLine := AppConfig.VirtualBoxPath;
Process.Execute;
Process.Free;
end;
procedure TMainForm.ButtonStartStopClick(Sender: TObject);
var
ProcessA, ProcessB: TProcess;
begin
if not FileExists(AppConfig.VBoxManagePath) then
begin
ErrorForm.MemoError.Lines.Text := 'binary "VBoxManage" not found';
ErrorForm.ShowModal;
end;
if (ButtonStartStop.Caption = 'Start Whonix') then
begin
ProcessA := TProcess.Create(nil);
ProcessA.CommandLine := AppConfig.VBoxManagePath +
' startvm Whonix-Workstation-Xfce';
ProcessA.Execute;
ProcessB := TProcess.Create(nil);
ProcessB.CommandLine := AppConfig.VBoxManagePath +
' startvm Whonix-Gateway-Xfce';
ProcessB.Execute;
ButtonStartStop.Caption := 'Stop Whonix';
end
else
if (ButtonStartStop.Caption = 'Stop Whonix') then
begin
ProcessA := TProcess.Create(nil);
ProcessA.CommandLine := AppConfig.VBoxManagePath +
' controlvm Whonix-Workstation-Xfce poweroff';
ProcessA.Execute;
ProcessB := TProcess.Create(nil);
ProcessB.CommandLine := AppConfig.VBoxManagePath +
' controlvm Whonix-Gateway-Xfce poweroff';
ProcessB.Execute;
ButtonStartStop.Caption := 'Start Whonix';
end;
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
MainForm.Icon.LoadFromResourceName(Hinstance, 'MAINICON');
end;
end.