Skip to content

Commit b9d642b

Browse files
committed
Add more logging to code and update changelog + v. and UI changes
1 parent 4a5238f commit b9d642b

4 files changed

Lines changed: 94 additions & 22 deletions

File tree

SignToolGUI/Forms/ChangelogForm.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,31 @@ private void ChangelogForm_Load(object sender, EventArgs e)
1919
private void PopulateChangelog()
2020
{
2121
// Changelog content
22-
var changelogContent = " Version 1.3.1 (13-03-2025):\n" +
22+
var changelogContent = " Version 1.4.0.0 (13-03-2025):\n" +
2323
" - Changed so only Code Sign certificates with a private key is showed in the tool to select\n" +
2424
" - Added a link to the Azure Portal to find your Trusted Signing accounts\n" +
2525
" - Added a option to set if you will add a timestamp when signing or not \n" +
2626
" (supported for .pfx and Certificate Store cert´s)\n" +
2727
" - Added some more error handling and logging\n" +
2828
" - Added support for more v. of the Windows SDK\n" +
29+
" - Added a 'Select all' option to mass select files to sign\n" +
2930
" - Some small minor UI changes\n\n" +
30-
" Version 1.3 (18-07-2024):\n" +
31+
" Version 1.3.0.0 (18-07-2024):\n" +
3132
" - Add support for Microsoft Trusted Signing\n" +
3233
" - Add check for if tool is code signed (via Windows API, valid or valid with my Code Signing\n" +
3334
" Certificate via Thumbprint hosted on GitHub)\n" +
3435
" - Add multiple timestamp servers" +
3536
" - Add save to logfile\n" +
3637
" - Bug fixes\n" +
3738
" > Like Certificate Store certs will reset on every sign\n\n" +
38-
" Version 1.2.2 (04-07-2024):\n" +
39+
" Version 1.2.2.0 (04-07-2024):\n" +
3940
" - Add code to DPI aware and SignTool via API\n" +
4041
" - Add more status messages to statusstrip for file operations\n" +
4142
" - Performance tweaks\n" +
4243
" - Change arch for default signtool.exe\n" +
4344
" - GUI changes\n" +
4445
" - Bug fixes\n\n" +
45-
" Version 1.2.1 (09-08-2023):\n" +
46+
" Version 1.2.1.0 (09-08-2023):\n" +
4647
" - Major release\n" +
4748
" - Added feature to find if signtool.exe is installed on the computer\n" +
4849
" - UI updates\n" +
@@ -52,25 +53,25 @@ private void PopulateChangelog()
5253
" - Minor changes\n" +
5354
" - Update shipped signtool.exe to last v.\n" +
5455
" - Updated to.net 4.8\n\n" +
55-
" Version 1.2 (30-06-2022):\n" +
56+
" Version 1.2.0.0 (30-06-2022):\n" +
5657
" - Feature additions\n" +
5758
" - Addressed issues\n\n" +
58-
" Version 1.0.4 (31-05-2021):\n" +
59+
" Version 1.0.4.0 (31-05-2021):\n" +
5960
" - Significant changes of logic and signing\n" +
6061
" - Overhauled GUI\n\n" +
61-
" Version 1.0.3 (30-04-2021):\n" +
62+
" Version 1.0.3.0 (30-04-2021):\n" +
6263
" - Fixed some bugs when signing multiple files at once from a folder\n" +
6364
" - Fixed issue for ECC SHA512 bug\n" +
6465
" - Performance enhancements\n\n" +
65-
" Version 1.0.2 (31-03-2021):\n" +
66+
" Version 1.0.2.0 (31-03-2021):\n" +
6667
" - More features added\n" +
6768
" - Several fixes in GUI text\n" +
6869
" - Performance tweaks\n" +
6970
" - UI enhancements\n\n" +
70-
" Version 1.0.1 (21-01-2021):\n" +
71+
" Version 1.0.1.0 (21-01-2021):\n" +
7172
" - Initial updates\n" +
7273
" - Bug fixes\n\n" +
73-
" Version 1.0 (11-01-2021):\n" +
74+
" Version 1.0.0.0 (11-01-2021):\n" +
7475
" - First release";
7576

7677
// Set the content in the RichTextBox control

SignToolGUI/Forms/MainForm.Designer.cs

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SignToolGUI/Forms/MainForm.cs

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,9 @@ private void buttonShowAllCertDataPopup_Click(object sender, EventArgs e)
13981398
// Retrieving the text from the label
13991399
var certificateInfo = labelCertificateInformation.Text;
14001400

1401+
// Log the certificate information popup message
1402+
Message("User view the certificate information popup for certificate '" + comboBoxCertificatesInStore.Text + "'", EventType.Information, 1042);
1403+
14011404
// Displaying the data in a MessageBox
14021405
MessageBox.Show(certificateInfo, @"Certificate Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
14031406
}
@@ -1418,11 +1421,18 @@ private void buttonSaveLog_Click(object sender, EventArgs e)
14181421
{
14191422
// Write the output to the file
14201423
File.WriteAllText(sfd.FileName, textBoxOutput.Text);
1424+
1425+
// Log the saving of the output to the file message
1426+
Message("Output saved to file: '" + sfd.FileName + "'", EventType.Information, 1038);
14211427
}
14221428
catch (Exception exception)
14231429
{
14241430
// Show an error message if the file could not be saved
14251431
MessageBox.Show(exception.ToString(), @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
1432+
1433+
// Log the error message
1434+
Message("Error saving output to file: " + exception.Message, EventType.Error, 1044);
1435+
14261436
throw;
14271437
}
14281438
}
@@ -1545,7 +1555,21 @@ private bool VerifyConfiguration()
15451555

15461556
private void linkLabelOpenTrustedSigningPortal_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
15471557
{
1548-
Process.Start("https://portal.azure.com/#browse/Microsoft.CodeSigning%2Fcodesigningaccounts");
1558+
try
1559+
{
1560+
Process.Start("https://portal.azure.com/#browse/Microsoft.CodeSigning%2Fcodesigningaccounts");
1561+
1562+
// Log the opening of the URL message
1563+
Message("User clicked the 'Open Trusted Signing Portal' link to open the URL: 'https://portal.azure.com/#browse/Microsoft.CodeSigning%2Fcodesigningaccounts'", EventType.Information, 1040);
1564+
}
1565+
catch (Exception ex)
1566+
{
1567+
// Show an error message if the URL could not be opened
1568+
MessageBox.Show(@"Failed to open the URL. Error: " + ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
1569+
1570+
// Log the error message
1571+
Message("Failed to open the URL: " + ex.Message, EventType.Error, 1041);
1572+
}
15491573
}
15501574

15511575
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
@@ -1566,7 +1590,9 @@ private void changelogToolStripMenuItem_Click(object sender, EventArgs e)
15661590

15671591
private void CheckedListBoxFiles_KeyDown(object sender, KeyEventArgs e)
15681592
{
1593+
// Initialize the deleted files counter
15691594
int deletedFilesCount = 0;
1595+
15701596
// Check if the Delete key on the keyboard is pressed
15711597
if (e.KeyCode != Keys.Delete)
15721598
return; // If not, do nothing and exit the method
@@ -1592,11 +1618,17 @@ private void CheckedListBoxFiles_KeyDown(object sender, KeyEventArgs e)
15921618

15931619
// Update the status label with the count of deleted files
15941620
statusLabel.Text = $@"[INFO] {deletedFilesCount} file(s) deleted from the file list";
1621+
1622+
// Log the deletion of the file from the list message and the number of files deleted
1623+
Message($"User have deleted {deletedFilesCount} file(s) from the list of files to sign", EventType.Information, 1042);
15951624
}
15961625
}
15971626

15981627
private void ButtonAddFiles_Click(object sender, EventArgs e)
15991628
{
1629+
// Log the add files button click message
1630+
Message("User clicked the 'Add Files' button to add files to the list of files to sign", EventType.Information, 1041);
1631+
16001632
// Show the OpenFileDialog and add the selected files to the list
16011633
openFileDialog.Multiselect = true;
16021634
openFileDialog.Filter = @"Executables and scripts (*.exe;*.dll;*.sys;*.ocx;*.ps1;*.msi;*.cat;*.cab;*.appx;*.appxbundle;*.msix;*.msixbundle)|*.exe;*.dll;*.sys;*.ocx;*.ps1;*.msi;*.cat;*.cab;*.appx;*.appxbundle;*.msix;*.msixbundle|All Files (*.*)|*.*";
@@ -1627,6 +1659,9 @@ private void ButtonAddFiles_Click(object sender, EventArgs e)
16271659
totalFiles = 0; // Or handle it according to your application's needs
16281660
}
16291661

1662+
// Log the number of files selected and user action
1663+
Message("User have selected " + openFileDialog.FileNames.Length + " file(s) to add to the list of files to sign", EventType.Information, 1039);
1664+
16301665
// calc added files
16311666
var addedFiles = totalFiles - currentFiles;
16321667

@@ -1656,8 +1691,14 @@ private void ButtonAddDirectory_Click(object sender, EventArgs e)
16561691
searchOption = SearchOption.AllDirectories;
16571692
}
16581693

1694+
// Log the search for files message
1695+
Message("Searching for files in the source folder selected to be added to the list of files to sign...", EventType.Information, 1039);
1696+
16591697
// Set filter for file extension and add all files from selected folder
16601698
var files = GetFiles(folderBrowserDialog.SelectedPath, "*.exe;*.dll;*.sys;*.ocx;*.ps1", searchOption);
1699+
1700+
// Log the search for files completion message
1701+
Message("Files found in the source folder selected to be added to the list of files", EventType.Information, 1040);
16611702

16621703
// loop in all files
16631704
foreach (var file in files)
@@ -1669,6 +1710,9 @@ private void ButtonAddDirectory_Click(object sender, EventArgs e)
16691710
var totalFiles = checkedListBoxFiles?.Items.Count ?? 0;
16701711
var addedFiles = totalFiles - currentFiles;
16711712

1713+
// Log the number of files added to the list and completion message
1714+
Message("User have added " + addedFiles + " file(s) to the list of files to sign", EventType.Information, 1041);
1715+
16721716
// show status
16731717
statusLabel.Text = @"[INFO] " + addedFiles + @" file(s) imported to File List from selected folder";
16741718
}
@@ -1700,6 +1744,9 @@ private void ButtonSelectPFXCertificate_Click(object sender, EventArgs e)
17001744
// Open the OpenFileDialog to select a PFX file for signing
17011745
try
17021746
{
1747+
// Log the browse for PFX file message
1748+
Message("User is browsing for a PFX file for signing...", EventType.Information, 1040);
1749+
17031750
// Create a new instance of the OpenFileDialog class.
17041751
var fileDialog = new OpenFileDialog
17051752
{
@@ -1710,17 +1757,26 @@ private void ButtonSelectPFXCertificate_Click(object sender, EventArgs e)
17101757

17111758
// Check if the dialog result is OK and set the selected file to the text box.
17121759
if (fileDialog.ShowDialog() == DialogResult.OK) textBoxPFXFile.Text = fileDialog.FileName;
1760+
1761+
// Log the PFX file selected message
1762+
Message("User have selected the PFX file: '" + textBoxPFXFile.Text + "'", EventType.Information, 1042);
17131763
}
17141764
catch (Exception ex)
17151765
{
17161766
int num = (int)MessageBox.Show(ex.Message, Globals.MsgBox.Error, MessageBoxButtons.OK, MessageBoxIcon.Hand);
1767+
1768+
// Log the error message when selecting the PFX file
1769+
Message("Error selecting the PFX file: " + ex.Message, EventType.Error, 1043);
17171770
}
17181771
}
17191772

17201773
private void ButtonShowSigningCertificate_Click(object sender, EventArgs e)
17211774
{
17221775
try
17231776
{
1777+
// Log the display of the signing certificate message
1778+
Message("User is displaying the signing certificate...", EventType.Information, 1044);
1779+
17241780
// Check if the Windows Certificate Store radio button is selected.
17251781
if (radioButtonWindowsCertificateStore.Checked)
17261782
{
@@ -1730,6 +1786,9 @@ private void ButtonShowSigningCertificate_Click(object sender, EventArgs e)
17301786

17311787
// Display the selected certificate from the signing certificates list.
17321788
X509Certificate2UI.DisplayCertificate(new X509Certificate2((X509Certificate)_signingCerts[comboBoxCertificatesInStore.SelectedIndex - 1]));
1789+
1790+
// Log the display of the signing certificate completion message from store
1791+
Message("User have displayed the signing certificate from the Windows Certificate Store", EventType.Information, 1045);
17331792
}
17341793
else
17351794
{
@@ -1738,6 +1797,9 @@ private void ButtonShowSigningCertificate_Click(object sender, EventArgs e)
17381797

17391798
// Display the certificate obtained from the PFX file.
17401799
X509Certificate2UI.DisplayCertificate(GetCertificateFromPfx());
1800+
1801+
// Log the display of the signing certificate completion message from PFX file
1802+
Message("User have displayed the signing certificate from the .PFX file", EventType.Information, 1046);
17411803
}
17421804

17431805
// Check if the PFX Certificate radio button is selected.
@@ -1746,15 +1808,21 @@ private void ButtonShowSigningCertificate_Click(object sender, EventArgs e)
17461808
// If the label for certificate information is not null, update it with the certificate info.
17471809
if (labelCertificateInformation != null)
17481810
labelCertificateInformation.Text = GetCertificateInfo(GetCertificateFromPfx());
1811+
1812+
// Log the display of the signing certificate completion message from PFX file to the UI
1813+
Message("Displayed the signing certificate from the .PFX file to the UI", EventType.Information, 1047);
17491814
}
17501815
}
1751-
catch (Exception)
1816+
catch (Exception ex)
17521817
{
1753-
//int num = (int)MessageBox.Show(ex.Message, Txt.MsgBox.warning, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
1818+
// TODO make error massage better for the user
1819+
//int num = (int)MessageBox.Show(ex.Message, @"Error when showing certificate data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
1820+
1821+
// Log the error message when displaying the signing certificate
1822+
Message("Error displaying the signing certificate: " + ex.Message, EventType.Error, 1047);
17541823
}
17551824
}
17561825

1757-
17581826
#endregion Sign options - GUI
17591827

17601828
#region Sign files - GUI
@@ -1786,6 +1854,9 @@ private void CheckBoxAll_CheckedChanged(object sender, EventArgs e)
17861854
// Set the checked state of each item to match the state of the "Select All" checkbox.
17871855
checkedListBoxFiles.SetItemChecked(i, isChecked);
17881856
}
1857+
1858+
// Log the "Select All" checkbox state change.
1859+
Message("User have " + (isChecked ? "checked" : "unchecked") + " the 'Select All' checkbox for file(s) to sign", EventType.Information, 1042);
17891860
}
17901861

17911862
#endregion Sign files - GUI

SignToolGUI/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.3.1.0")]
36-
[assembly: AssemblyFileVersion("1.3.1.0")]
35+
[assembly: AssemblyVersion("1.4.0.0")]
36+
[assembly: AssemblyFileVersion("1.4.0.0")]

0 commit comments

Comments
 (0)