This repository has been archived by the owner on Apr 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathACBuild.iss
315 lines (289 loc) · 10.3 KB
/
ACBuild.iss
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define AppId "{{CCCDBFCF-CD8B-4728-915A-DCB71C1118BE}"
#define MyAppName "AlphaConsole"
#define MyAppPublisher "AlphaConsole"
#define MyAppURL "http://www.alphaconsole.net"
#define MyAppExeName "AlphaConsole.exe"
#define SourceFiles "dist\dedac"
#define MyAppVersion GetFileVersion(SourceFiles + "\" + MyAppExeName)
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={#AppId}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName=C:\AlphaConsole
DisableDirPage=yes
DisableProgramGroupPage=yes
OutputBaseFilename={#MyAppName}_Setup_{#MyAppVersion}
SetupIconFile=source\assets\img\app_icon.ico
Compression=lzma
SolidCompression=yes
OutputDir=dist
CloseApplicationsFilter=*.exe,*.dll,*.chm,RocketLeague.exe
CloseApplications=force
PrivilegesRequired=admin
DisableWelcomePage=yes
DisableReadyPage=yes
DisableFinishedPage=yes
AllowCancelDuringInstall=no
[InstallDelete]
Type: files; Name: "{app}\*.*"
Type: dirifempty; Name: "{app}"
Type: files; Name: "{userdesktop}\Alpha Console.lnk"
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "{#SourceFiles}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
//Source: "{#SourceFiles}\resources\app.asar.unpacked\xapofx1_5.dll"; DestDir: "{app}\.."; Flags: ignoreversion
//Source: "{#SourceFiles}\resources\app.asar.unpacked\discord-rpc.dll"; DestDir: "{app}\.."; Flags: ignoreversion
//[Icons]
//Name: "{commondesktop}\Alpha Console"; Filename: "{app}\{#MyAppExeName}"
[Dirs]
Name: "{app}"; Permissions: users-full
[UninstallDelete]
Type: files; Name: "{app}\*.*"
Type: dirifempty; Name: "{app}"
Type: files; Name: "{userdesktop}\Alpha Console.lnk"
[Code]
#ifdef UNICODE
#define AW "W"
#else
#define AW "A"
#endif
const
OPEN_EXISTING = 3;
GENERIC_READ = $80000000;
FILE_WRITE_ATTRIBUTES = $0100;
INVALID_HANDLE_VALUE = 4294967295;
type
FILETIME = record
LowDateTime: DWORD;
HighDateTime: DWORD;
end;
SYSTEMTIME = record
Year: WORD;
Month: WORD;
DayOfWeek: WORD;
Day: WORD;
Hour: WORD;
Minute: WORD;
Second: WORD;
Milliseconds: WORD;
end;
var
UserPage: TInputFileWizardPage;
FileSelector: TInputFileWizardPage;
function GetHKLM: Integer;
begin
if IsWin64 then
Result := HKLM64
else
Result := HKLM32;
end;
function IsAppRunning(const FileName: string): Boolean;
var
FWMIService: Variant;
FSWbemLocator: Variant;
FWbemObjectSet: Variant;
begin
Result := false;
FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
FWMIService := FSWbemLocator.ConnectServer('', 'root\CIMV2', '', '');
FWbemObjectSet := FWMIService.ExecQuery(Format('SELECT Name FROM Win32_Process Where Name="%s"',[FileName]));
Result := (FWbemObjectSet.Count > 0);
FWbemObjectSet := Unassigned;
FWMIService := Unassigned;
FSWbemLocator := Unassigned;
end;
function CreateFile(lpFileName: string; dwDesiredAccess, dwShareMode,
lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes: DWORD;
hTemplateFile: THandle): THandle;
external 'CreateFile{#AW}@kernel32.dll stdcall';
function CloseHandle(hObject: THandle): BOOL;
external '[email protected] stdcall';
function GetFileTime(hFile: THandle; out lpCreationTime, lpLastAccessTime, lpLastWriteTime: TFileTime): BOOL;
external '[email protected] stdcall';
function SetFileTime(hFile: THandle; const lpCreationTime, lpLastAccessTime, lpLastWriteTime: TFileTime): BOOL;
external '[email protected] stdcall';
function FileTimeToSystemTime(FileTime: TFileTime; var SystemTime: SYSTEMTIME): Boolean;
external '[email protected] stdcall';
function SystemTimeToFileTime(SystemTime: SYSTEMTIME; var FileTime: TFileTime): Boolean;
external '[email protected] stdcall';
function GetSystemTime(var SystemTime: SYSTEMTIME): Boolean;
external '[email protected] stdcall';
function IsValidRLPath(const Path: string): Boolean;
var
folder: string;
rlexists: Boolean;
manifestexists: Boolean;
manifestTimeValid: Boolean;
manifestTimeLessThan7Days: Boolean;
FileHandle: THandle;
CreationTime: TFileTime;
LastWriteTime: TFileTime;
LastAccessTime: TFileTime;
LastWriteTimeSys: SYSTEMTIME;
SystemTime: SYSTEMTIME;
begin
Result := false;
manifestTimeLessThan7Days := false;
folder := ExtractFilePath(Path)
rlexists := FileExists(Path)
manifestexists := FileExists(folder + '\..\..\..\..\appmanifest_252950.acf')
if manifestexists then begin
FileHandle := CreateFile(folder + '\..\..\..\..\appmanifest_252950.acf', GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if FileHandle <> INVALID_HANDLE_VALUE then
try
manifestTimeValid := Boolean(GetFileTime(FileHandle, CreationTime, LastAccessTime, LastWriteTime));
if manifestTimeValid then
GetSystemTime(SystemTime);
FileTimeToSystemTime(LastWriteTime,LastWriteTimeSys);
if (LastWriteTimeSys.Year <> SystemTime.Year) and (SystemTime.Year - LastWriteTimeSys.Year = 1) then begin
if (LastWriteTimeSys.Month = 12) and (SystemTime.Month = 1) and (LastWriteTimeSys.Day - SystemTime.Day > 24) then
manifestTimeLessThan7Days := true
end else begin
if (LastWriteTimeSys.Month <> SystemTime.Month) and (SystemTime.Month - LastWriteTimeSys.Month = 1) then begin
if (LastWriteTimeSys.Day - SystemTime.Day) > 24 then
manifestTimeLessThan7Days := true
end else begin
if SystemTime.Day - LastWriteTimeSys.Day < 7 then
manifestTimeLessThan7Days := true
end;
end;
finally
CloseHandle(FileHandle);
end;
end;
Result := rlexists and manifestexists and manifestTimeLessThan7Days
end;
function FindRLUninstallKey(out ResultFolder: string) : Boolean;
var
InstallFolder : String;
begin
if RegQueryStringValue(GetHKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 252950', 'InstallLocation', InstallFolder) then begin
if IsValidRLPath(InstallFolder + '\Binaries\Win32\RocketLeague.exe') then begin
ResultFolder := InstallFolder + '\Binaries\Win32\AlphaConsole'
Result := true
Exit end end;
Result := false;
end;
function InputFileCheck(Page: TWizardPage): Boolean;
var
Path: string;
OPath: string;
RLIndex: Integer;
begin
Result := True;
OPath := Trim(TInputFileWizardPage(Page).Values[0]);
Path := OPath
if Length(OPath) = 0 then
begin
MsgBox('No path specified.', mbError, MB_OK);
Result := False;
end
else begin
RLIndex := Pos('\RocketLeague.exe', Path);
if RLIndex > 0 then begin
Path := Copy(OPath, 0, RLIndex)
end;
if IsValidRLPath(Path + '\RocketLeague.exe') then begin
Path := Path + '\'
WizardForm.DirEdit.Text := ExtractFilePath(Path) + '\AlphaConsole';
end else begin
MsgBox('RocketLeague.exe is not located in the selected path.', mbError, MB_OK);
Result := False;
end
end
end;
const
BN_CLICKED = 0;
WM_COMMAND = $0111;
CN_BASE = $BC00;
CN_COMMAND = CN_BASE + WM_COMMAND;
WM_QUIT = $0010;
function InitializeUninstall(): Boolean;
var
ErrorCode: Integer;
rlwinHwnd: longint;
retVal : boolean;
MsgResult: Integer;
begin
ShellExec('open','taskkill.exe','/f /im {#MyAppExeName}','',SW_HIDE,ewNoWait,ErrorCode);
ShellExec('open','tskill.exe',' {#MyAppName}','',SW_HIDE,ewNoWait,ErrorCode);
Result := True;
while IsAppRunning('RocketLeague.exe') do begin
MsgResult := MsgBox('AlphaConsole is trying to update but Rocket League is running. Please close it before continuing.', mbError, MB_OKCANCEL);
if MsgResult = IDCANCEL then begin
Result := False
Break;
end end;
end;
procedure InitializeWizard();
var
rlFolder : String;
originalInstallation : String;
begin
if not(WizardForm.DirEdit.Text = 'C:\AlphaConsole') then begin
if not(IsValidRLPath(WizardForm.DirEdit.Text + '\..\RocketLeague.exe')) then
WizardForm.DirEdit.Text := 'C:\AlphaConsole'
end;
if WizardForm.DirEdit.Text = 'C:\AlphaConsole' then begin
if IsValidRLPath('C:\Program Files (x86)\Steam\steamapps\common\rocketleague\Binaries\Win32\RocketLeague.exe') then begin
WizardForm.DirEdit.Text := 'C:\Program Files (x86)\Steam\steamapps\common\rocketleague\Binaries\Win32\AlphaConsole'
end
else begin
if FindRLUninstallKey(rlFolder) then
WizardForm.DirEdit.Text := rlFolder
else begin
UserPage := CreateInputFilePage(wpSelectDir, 'Select Rocket League Folder', 'Find RocketLeague.exe', 'The Setup could not find RocketLeague.exe. Please select it using the dialog below: ')
UserPage.Add('Location of RocketLeague.exe:', 'RocketLeague.exe|RocketLeague.exe', 'RocketLeague.exe');
UserPage.OnNextButtonClick := @InputFileCheck;
end
end
end;
end;
procedure CurPageChanged(CurPageID: Integer);
var
winHwnd: longint;
rlwinHwnd: longint;
Param: Longint;
ResultCode: Integer;
Running: Boolean;
retVal : boolean;
MsgResult: Integer;
begin
if CurPageID = wpReady then
begin
Param := 0 or BN_CLICKED shl 16;
PostMessage(WizardForm.NextButton.Handle, CN_COMMAND, Param, 0);
end;
end;
function InitializeSetup(): Boolean;
var
MsgResult: Integer;
begin
Result := True;
while IsAppRunning('RocketLeague.exe') do begin
MsgResult := MsgBox('AlphaConsole is trying to update but Rocket League is running. Please close it before continuing.', mbError, MB_OKCANCEL);
if MsgResult = IDCANCEL then begin
Result := False
Break;
end;
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
Param: Longint;
ResultCode: Integer;
begin
if CurStep = ssPostInstall then
ExecAsOriginalUser(ExpandConstant('{app}\{#MyAppExeName}'), '', '', SW_SHOWNORMAL, ewNoWait, ResultCode);
end;