Skip to content

Commit ca84d40

Browse files
committed
Commit for v1.1.2
1 parent 4b321d3 commit ca84d40

3 files changed

+201
-82
lines changed

README.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To remove it silently:
3636

3737
## Troubleshooting
3838

39-
The installer creates a log file on the path `C:\Users\(Username)\AppData\Local\Temp\Setup Log (Year-Month-Day) #XXX.txt`.
39+
The installer creates a log file on the path `C:\Users\ (Username) \AppData\Local\Temp\Setup Log (Year-Month-Day) #XXX.txt` with full information, as well as `C:\Program Files\Hack Windows Installer\Log-FontData.txt`. The later only contains a subset of the first.
4040

4141
If you are using EMET: If the "Only trusted fonts" option is activated, you need to declare Hack as trusted or it will not be usable.
4242

@@ -45,14 +45,12 @@ If you are using EMET: If the "Only trusted fonts" option is activated, you need
4545

4646
Any constructive contribution is very welcome!
4747

48-
In order to fix a bug you have encountered, we require the log file from the installer. To view this log file, do the following:
48+
In order to fix a bug you have encountered, we require the log file. To view this log file, do the following:
4949

50-
- Click Start -> Click Run -> Enter *%temp%* to open your TEMP folder
51-
- Locate the file called Setup Log 2016-04-26 #xxx.txt where XXX should be 001
52-
- Double-click it and look into it to make sure it's the setup log from our installer. In the third line it should say *HackWindowsInstaller.exe*
53-
- Check the file for any information that you do not want others to see. For example, line 3,4 and 10 contain the paths where the setup is started from and how your TEMP folder is called. Just delete these lines. The other lines should be safe and only contain common information.
54-
- Open a new [issue](https://github.com/source-foundry/Hack-windows-installer/issues/new) in the Hack-Windows-Installer repository
55-
- Paste the entire text (minus the lines noted above) there
50+
- Open the folder `C:\Program Files\Hack Windows Installer`
51+
- Locate the file called `Log-FontData.txt`
52+
- Open a new [issue](https://github.com/source-foundry/Hack-windows-installer/issues/new)
53+
- Paste the entire text of the log file
5654

5755

5856
## License

src/HackWindowsInstaller.iss

+103-36
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
//Update this when releasing a new version
18-
#define public Version '1.1.0'
18+
#define public Version '1.1.2'
1919

2020
//This defines in which sub folder of this project the current files are located
2121
#define public HackMonospaced_Sourcefolder 'Hack_v2_020'
@@ -47,6 +47,11 @@
4747
#define public FontCacheService 'FontCache'
4848
#define public FontCache30Service 'FontCache3.0.0.0'
4949

50+
//File name of the FontState Log
51+
#define public LogFontDataFilename 'Log-FontData.txt'
52+
#define public LogFontDataFilenameOld 'Log-FontData-old.txt'
53+
54+
5055

5156
//Total number of font entries we have
5257
#define total_fonts 4
@@ -240,8 +245,10 @@ Filename: "{app}\InstallInfo.ini"; Section: "Main"; Key: "Version"; String: "{#V
240245
Filename: "{app}\InstallInfo.ini"; Section: "Main"; Key: "Name"; String: "{#AppName}"
241246

242247
[UninstallDelete]
243-
;Delete Install Info
248+
;Delete install Info
244249
Type: files; Name: "{app}\InstallInfo.ini"
250+
;Delete log files
251+
Type: files; Name: "{app}\Log*.txt"
245252

246253

247254

@@ -292,7 +299,7 @@ const
292299
293300
var
294301
//Custom "prepare to install" page
295-
customPrepareToInstall: TOutputProgressWizardPage;
302+
customProgressPage: TOutputProgressWizardPage;
296303
297304
//All font files included in this setup
298305
FontFiles: array of string;
@@ -314,6 +321,9 @@ var
314321
//If this true we will make changes to this system
315322
ChangesRequired:boolean;
316323
324+
//In memory buffer for the "Font" messages written to the special log file ({#LogFontDataFilename})
325+
FontStateBuffer: array of string;
326+
317327
318328
// #######################################################################################
319329
// Service control code from http://www.vincenzo.net/isxkb/index.php?title=Service_-_Functions_to_Start%2C_Stop%2C_Install%2C_Remove_a_Service
@@ -463,6 +473,20 @@ begin
463473
464474
end;
465475
476+
//Logs to the internal buffer which will then be written to the installation folder at the end of the setup
477+
procedure LogAsImportant(message:string);
478+
var
479+
curSize: integer;
480+
begin
481+
//Always write the message to the "normal" log as well
482+
483+
log(message);
484+
485+
curSize:=GetArrayLength(FontStateBuffer);
486+
SetArrayLength(FontStateBuffer, curSize+1);
487+
FontStateBuffer[curSize]:=message;
488+
end;
489+
466490
467491
procedure InitializeWizard;
468492
var
@@ -483,7 +507,7 @@ begin
483507
484508
//subTitle contains [name] which we need to replace
485509
StringChangeEx(subTitle, '[name]', '{#AppName}', True);
486-
customPrepareToInstall:=CreateOutputProgressPage(title, subTitle);
510+
customProgressPage:=CreateOutputProgressPage(title, subTitle);
487511
end;
488512
489513
@@ -510,8 +534,9 @@ var
510534
i:integer;
511535
entryFound:boolean;
512536
registryFontValue:string;
537+
expectedFontValue:string;
513538
begin
514-
log('IsSetupFontSameAsInstalledFont(): ' + fileName);
539+
LogAsImportant('IsSetupFontSameAsInstalledFont(): ' + fileName);
515540
516541
result:=false;
517542
entryFound:=false;
@@ -522,21 +547,27 @@ begin
522547
if FontFiles[i]=fileName then begin
523548
entryFound:=true;
524549
550+
//If the hash of the file does not match the font installed, the registry check is not required since we need to install it anyway
525551
if FontFilesHashes[i]=InstalledFontsHashes[i] then begin
552+
expectedFontValue:=FontFilesNames[i]+' (TrueType)';
553+
LogAsImportant(' Hash matches, checking for registry value: ' + expectedFontValue);
554+
526555
//Now check if the font registration info in the registry also matches
527-
if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', FontFilesNames[i]+' (TrueType)', registryFontValue) then begin
556+
if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', expectedFontValue, registryFontValue) then begin
528557
//Does the value point to the same file as we have in setup?
529558
if registryFontValue=fileName then begin
559+
LogAsImportant(' Registry data matches, installation not required');
530560
result:=true; //all is exactly as expected
531-
end else begin
532-
log(' File name in registry is different, installation required');
561+
end else begin
562+
LogAsImportant(' Value found : ' + registryFontValue);
563+
LogAsImportant(' File name in registry is different, installation required');
533564
end;
534565
end else begin
535-
log(' Font not found in registry, installation required');
566+
LogAsImportant(' Font not found in registry, installation required');
536567
end;
537568
end else begin
538-
log(' Hash values (Setup/Windows): ' + FontFilesHashes[i] + ' / ' + InstalledFontsHashes[i]);
539-
log(' File is different, installation required');
569+
LogAsImportant(' Hash values (Setup/Windows): ' + FontFilesHashes[i] + ' / ' + InstalledFontsHashes[i]);
570+
LogAsImportant(' File is different, installation required');
540571
end;
541572
542573
end;
@@ -559,14 +590,15 @@ var
559590
begin
560591
result:=false;
561592
562-
log('Checking for differences between fonts in setup and this system');
593+
LogAsImportant('Checking for differences between fonts in setup and this system');
563594
564595
for i := 0 to GetArrayLength(FontFiles)-1 do begin
565596
if IsSetupFontSameAsInstalledFont(FontFiles[i]) then begin
566597
//File is the same, ignore
567598
end else begin
568599
//We have a change, installation is required!
569-
log(' Found difference for file ' + FontFiles[i]);
600+
LogAsImportant(' Found difference for file ' + FontFiles[i]);
601+
LogAsImportant(' Installation required.');
570602
571603
//One detected difference is enough to result TRUE
572604
result:=true;
@@ -635,24 +667,33 @@ var
635667
currentFontFileNameWindows:string;
636668
637669
begin
638-
log('---BeforeInstallAction START---');
670+
LogAsImportant('---BeforeInstallAction START---');
671+
672+
//Write system information to log file
673+
LogAsImportant('Setup version: {#Version}');
674+
LogAsImportant('Font version.: {#HackMonospaced_Version}');
675+
LogAsImportant('Local time...: ' + GetDateTimeString('yyyy-dd-mm hh:nn', '-', ':'));
676+
LogAsImportant('Fonts folder.: ' + ExpandConstant('{fonts}'));
677+
LogAsImportant('Dest folder..: ' + ExpandConstant('{app}'));
678+
639679
640-
customPrepareToInstall.SetProgress(0, 0);
641-
customPrepareToInstall.Show;
680+
681+
customProgressPage.SetProgress(0, 0);
682+
customProgressPage.Show;
642683
643684
try
644685
begin
645-
686+
646687
//Calculate the SHA1 hash for *ALL* fonts we support
647-
customPrepareToInstall.SetText('Calculating hashes for fonts already installed...', '');
688+
customProgressPage.SetText('Calculating hashes for fonts already installed...', '');
648689
649690
SetArrayLength(InstalledFontsHashes, GetArrayLength(FontFiles));
650691
651-
log('---HASH CALCULATION---');
692+
LogAsImportant('---HASH CALCULATION---');
652693
for i := 0 to GetArrayLength(FontFiles)-1 do begin
653694
currentFont:=FontFiles[i];
654-
log('Calculating hash for '+currentFont);
655-
log(' File from setup: ' + FontFilesHashes[i]);
695+
LogAsImportant('Calculating hash for '+currentFont);
696+
LogAsImportant(' File from setup: ' + FontFilesHashes[i]);
656697
657698
currentFontFileNameWindows:=ExpandConstant('{fonts}\'+currentFont);
658699
@@ -663,9 +704,9 @@ begin
663704
InstalledFontsHashes[i]:='-NOT FOUND-';
664705
end;
665706
666-
log(' File in \fonts : ' + InstalledFontsHashes[i]);
707+
LogAsImportant(' File in \fonts : ' + InstalledFontsHashes[i]);
667708
end;
668-
log('----------------------');
709+
LogAsImportant('----------------------');
669710
670711
671712
//Set it to false by default
@@ -685,10 +726,10 @@ begin
685726
FontCache30Service_Stopped:=false;
686727
687728
if ChangesRequired=true then begin
688-
customPrepareToInstall.SetText('Stopping service {#FontCacheService}...','');
729+
customProgressPage.SetText('Stopping service {#FontCacheService}...','');
689730
FontCacheService_Stopped:=StopNTService2('{#FontCacheService}');
690731
691-
customPrepareToInstall.SetText('Stopping service {#FontCache30Service}...','');
732+
customProgressPage.SetText('Stopping service {#FontCache30Service}...','');
692733
FontCache30Service_Stopped:=StopNTService2('{#FontCache30Service}')
693734
end;
694735
@@ -697,50 +738,76 @@ begin
697738
698739
end;
699740
finally
700-
customPrepareToInstall.Hide;
741+
customProgressPage.Hide;
701742
end;
702743
703744
BeforeInstallActionWasRun:=true;
704-
log('---BeforeInstallAction END---');
745+
LogAsImportant('---BeforeInstallAction END---');
705746
end;
706747
707748
708749
709750
//Show a custom prepare to install page in order to give the user output what we are doing
710751
procedure AfterInstallAction();
752+
var
753+
appDestinationFolder:string;
754+
711755
begin
712756
log('---AfterInstallAction START---');
713757
714-
customPrepareToInstall.SetProgress(0, 0);
715-
customPrepareToInstall.Show;
758+
customProgressPage.SetProgress(0, 0);
759+
customProgressPage.Show;
716760
717761
try
718762
begin
719763
720764
//Start the service the before action has stopped
721-
customPrepareToInstall.SetText('Starting service {#FontCacheService}...','');
765+
customProgressPage.SetText('Starting service {#FontCacheService}...','');
722766
if FontCacheService_Stopped=true then begin
723767
StartNTService2('{#FontCacheService}');
724768
FontCacheService_Stopped:=false;
725769
end;
726770
727-
customPrepareToInstall.SetText('Starting service {#FontCache30Service}...','');
771+
customProgressPage.SetText('Starting service {#FontCache30Service}...','');
728772
if FontCache30Service_Stopped=true then begin
729773
StartNTService2('{#FontCache30Service}');
730774
FontCache30Service_Stopped:=false;
731775
end;
732776
733-
734-
//Finally, inform windows that fonts have changed (just to be sure we do this always)
777+
//Inform windows that fonts have changed (just to be sure we do this always)
735778
//See https://msdn.microsoft.com/en-us/library/windows/desktop/dd183326%28v=vs.85%29.aspx
736779
SendBroadcastMessage(29, 0, 0);
737780
//HWND_BROADCAST = -1
738781
//WM_FONTCHANGE = 0x1D = 29
739782
740-
783+
customProgressPage.SetText('Storing font data...','');
784+
785+
//Write the buffer to disk. We better make sure that {app} exists.
786+
appDestinationFolder:=ExpandConstant('{app}');
787+
appDestinationFolder:=AddBackslash(appDestinationFolder);
788+
if DirExists(appDestinationFolder) then begin
789+
790+
//Check if there is already a current log. If so, rename it.
791+
If FileExists(appDestinationFolder + '{#LogFontDataFilename}') then begin
792+
793+
//Check if and "old" file already exists. If so, delete it.
794+
If FileExists(appDestinationFolder + '{#LogFontDataFilenameOld}') then begin
795+
DeleteFile(appDestinationFolder + '{#LogFontDataFilenameOld}');
796+
end;
797+
798+
//Rename current file to old
799+
RenameFile(appDestinationFolder + '{#LogFontDataFilename}', appDestinationFolder + '{#LogFontDataFilenameOld}');
800+
end;
801+
802+
//Save the buffer
803+
log('Saving font state to ' + appDestinationFolder + '{#LogFontDataFilename}');
804+
SaveStringsToFile(appDestinationFolder + '{#LogFontDataFilename}', FontStateBuffer, false); //do not append
805+
end;
806+
807+
741808
end;
742809
finally
743-
customPrepareToInstall.Hide;
810+
customProgressPage.Hide;
744811
end;
745812
746813
log('---AfterInstallAction END---');
@@ -755,7 +822,7 @@ begin
755822
756823
log('---NeedRestart---');
757824
if ChangesRequired then
758-
log(' Changes detected, require reboot');
825+
LogAsImportant(' Changes detected, require reboot');
759826
760827
result:=ChangesRequired;
761828

0 commit comments

Comments
 (0)