diff --git a/CrashHandler b/CrashHandler index 45e7b85..e45c581 160000 --- a/CrashHandler +++ b/CrashHandler @@ -1 +1 @@ -Subproject commit 45e7b85144f5b581540fe0d72fc9a71c3b4fcabc +Subproject commit e45c581d38b5b80bf3aeae27a9286a144e0a7183 diff --git a/Download Manager/Components/DebugForm.Designer.cs b/Download Manager/Components/DebugForm.Designer.cs new file mode 100644 index 0000000..989e9f8 --- /dev/null +++ b/Download Manager/Components/DebugForm.Designer.cs @@ -0,0 +1,170 @@ + +namespace DownloadManager.Components +{ + partial class DebugForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DebugForm)); + richTextBox1 = new RichTextBox(); + pictureBox1 = new PictureBox(); + darkTabControl = new DownloadManager.Controls.DarkTabControl(); + crashHandlerPage = new TabPage(); + checkBox1 = new CheckBox(); + button2 = new Button(); + button1 = new Button(); + tabPage2 = new TabPage(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); + darkTabControl.SuspendLayout(); + crashHandlerPage.SuspendLayout(); + SuspendLayout(); + // + // richTextBox1 + // + richTextBox1.BackColor = Color.Black; + richTextBox1.BorderStyle = BorderStyle.None; + richTextBox1.ForeColor = Color.White; + richTextBox1.Location = new Point(48, 12); + richTextBox1.Name = "richTextBox1"; + richTextBox1.ReadOnly = true; + richTextBox1.ScrollBars = RichTextBoxScrollBars.Vertical; + richTextBox1.Size = new Size(447, 32); + richTextBox1.TabIndex = 1001; + richTextBox1.Text = "This form is used for debugging Download Manager, some options here may distrupt current downloads or make Download Manager behave unexpectedly."; + // + // pictureBox1 + // + pictureBox1.BackColor = Color.Transparent; + pictureBox1.BackgroundImage = Properties.Resources.warn; + pictureBox1.BackgroundImageLayout = ImageLayout.Zoom; + pictureBox1.Location = new Point(12, 12); + pictureBox1.Name = "pictureBox1"; + pictureBox1.Size = new Size(30, 32); + pictureBox1.TabIndex = 1000; + pictureBox1.TabStop = false; + // + // darkTabControl + // + darkTabControl.Controls.Add(crashHandlerPage); + darkTabControl.Controls.Add(tabPage2); + darkTabControl.DrawMode = TabDrawMode.OwnerDrawFixed; + darkTabControl.Location = new Point(12, 62); + darkTabControl.Name = "darkTabControl"; + darkTabControl.SelectedIndex = 0; + darkTabControl.Size = new Size(776, 376); + darkTabControl.TabBackColor = Color.FromArgb(31, 31, 31); + darkTabControl.TabForeColor = Color.FromArgb(241, 241, 241); + darkTabControl.TabIndex = 1002; + darkTabControl.TextAlign = ContentAlignment.TopLeft; + // + // crashHandlerPage + // + crashHandlerPage.Controls.Add(checkBox1); + crashHandlerPage.Controls.Add(button2); + crashHandlerPage.Controls.Add(button1); + crashHandlerPage.Location = new Point(4, 25); + crashHandlerPage.Name = "crashHandlerPage"; + crashHandlerPage.Padding = new Padding(3); + crashHandlerPage.Size = new Size(768, 347); + crashHandlerPage.TabIndex = 0; + crashHandlerPage.Text = "CrashHandler"; + crashHandlerPage.UseVisualStyleBackColor = true; + // + // checkBox1 + // + checkBox1.AutoSize = true; + checkBox1.Checked = true; + checkBox1.CheckState = CheckState.Checked; + checkBox1.Location = new Point(6, 35); + checkBox1.Name = "checkBox1"; + checkBox1.Size = new Size(212, 20); + checkBox1.TabIndex = 2; + checkBox1.Text = "Program.allowBypassCrashHandler"; + checkBox1.UseVisualStyleBackColor = true; + checkBox1.CheckedChanged += checkBox1_CheckedChanged; + // + // button2 + // + button2.Location = new Point(87, 6); + button2.Name = "button2"; + button2.Size = new Size(94, 23); + button2.TabIndex = 1; + button2.Text = "Test Crash Ext"; + button2.UseVisualStyleBackColor = true; + button2.Click += button2_Click; + // + // button1 + // + button1.Location = new Point(6, 6); + button1.Name = "button1"; + button1.Size = new Size(75, 23); + button1.TabIndex = 0; + button1.Text = "Test Crash"; + button1.UseVisualStyleBackColor = true; + button1.Click += button1_Click; + // + // tabPage2 + // + tabPage2.Location = new Point(4, 25); + tabPage2.Name = "tabPage2"; + tabPage2.Padding = new Padding(3); + tabPage2.Size = new Size(768, 347); + tabPage2.TabIndex = 1; + tabPage2.Text = "tabPage2"; + tabPage2.UseVisualStyleBackColor = true; + // + // DebugForm + // + AutoScaleDimensions = new SizeF(7F, 16F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(darkTabControl); + Controls.Add(richTextBox1); + Controls.Add(pictureBox1); + FormBorderStyle = FormBorderStyle.FixedSingle; + Icon = (Icon)resources.GetObject("$this.Icon"); + Name = "DebugForm"; + Text = "DebugForm"; + ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); + darkTabControl.ResumeLayout(false); + crashHandlerPage.ResumeLayout(false); + crashHandlerPage.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private RichTextBox richTextBox1; + private PictureBox pictureBox1; + private Controls.DarkTabControl darkTabControl; + private TabPage crashHandlerPage; + private TabPage tabPage2; + private Button button2; + private Button button1; + private CheckBox checkBox1; + } +} \ No newline at end of file diff --git a/Download Manager/Components/DebugForm.cs b/Download Manager/Components/DebugForm.cs new file mode 100644 index 0000000..be08121 --- /dev/null +++ b/Download Manager/Components/DebugForm.cs @@ -0,0 +1,35 @@ +namespace DownloadManager.Components +{ + public partial class DebugForm : Form + { + public DebugForm() + { + InitializeComponent(); + } + + // Crash test + public void button1_Click(object sender, EventArgs e) + { + throw new Exception("Manually Initiated Crash"); + } + + // Crash test extended + private void button2_Click(object sender, EventArgs e) + { + try + { + throw new Exception("This is a test inner exception.\nTest text."); + } + catch (Exception ex) + { + throw new Exception("Manually Initiated Crash\nLine 2.\nLine 3\nLine 4", ex); + } + } + + // Allow bypassing crash handler with debugger attached (default: true) + private void checkBox1_CheckedChanged(object sender, EventArgs e) + { + Program.allowBypassCrashHandler = checkBox1.Checked; + } + } +} diff --git a/Download Manager/Components/DebugForm.resx b/Download Manager/Components/DebugForm.resx new file mode 100644 index 0000000..209baec --- /dev/null +++ b/Download Manager/Components/DebugForm.resx @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAHRwAAAEAIABIDQAAFgAAACgAAAAdAAAAOAAAAAEAIAAAAAAAsAwAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAA/wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAP8ABP////////////////////////////////////////////////////////////// + /////////////////////////////////////////wAE/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAD/AAT//wAE//////////////////////////////////////////////////////////////////// + ////////////////////////////////////AAT//wAE/wAAAAAAAAAAAAAAAAAAAAAAAAAA/wAE//8A + BP//AAT/////////////AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP////////////8ABP//AAT//wAE/wAAAAAAAAAAAAAAAP8ABP//AAT//wAE//8A + BP////////////8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP///////wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE/////////////wAE//8ABP//AAT//wAE/wAAAAD/AAT//wAE//8ABP//AAT//wAE//// + /////////wAE//8ABP//AAT//wAE//8ABP////////////////////////////8ABP//AAT//wAE//8A + BP//AAT/////////////AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT///////// + ////AAT//wAE//8ABP//AAT///////////////////////////////////////8ABP//AAT//wAE//8A + BP////////////8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP////////////8A + BP//AAT//wAE//////////////////////////////////////////////////8ABP//AAT//wAE//// + /////////wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE/////////////wAE//8A + BP////////////////////////////////////////////////////////////8ABP//AAT///////// + ////AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT/////////////AAT///////// + //////////////////////////////////////////////////////////////8ABP////////////8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP////////////// + /////////////////////////////////////////////////////////wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP////////////////////////////8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//// + /////////////////////////wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT///////// + ////////////////////AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP////////////// + //////////////8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//////////////////// + /////////wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT///////////////////////// + ////AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP////////////////////////////8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE/////////////////////////////wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT/////////////////////////////AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP////////////////////////////8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE/wAAAAD/AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE/////////////////////////////wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP8AAAAAAAAAAAAAAAD/AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT/////////////////////////////AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT/AAAAAAAAAAAAAAAAAAAAAAAAAAD/AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP////////////////////////////8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE/////////////////////////////wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8A + BP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT/AAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAT//wAE//8ABP//AAT//wAE//8A + BP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE//8ABP//AAT//wAE/wAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAPwAAfj4AAD48AAAeOAAADjAAAAYgAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAIwAAAGOAAADjwAAB4+AAA+PwA + Afg= + + + \ No newline at end of file diff --git a/Download Manager/Components/Extentions/Exception.cs b/Download Manager/Components/Extentions/Exception.cs new file mode 100644 index 0000000..e2d833f --- /dev/null +++ b/Download Manager/Components/Extentions/Exception.cs @@ -0,0 +1,43 @@ +namespace DownloadManager.Components.Extentions +{ + public static class ExceptionExt + { + /// + /// Get all inner exceptions of an exception. + /// + /// Any exception. + /// An array of Exceptions contained in the InnerExceptions property of the specified Exception. If there are no inner exceptions, returns null. + public static Exception[]? GetInnerExceptions(this Exception ex) + { + if (ex == null) + { + // If the exception object is null, return null (as there wont be any InnerException) + return null; + } + + // Declare variables + Exception currentException = ex; + List exceptions = new List(); + Exception[]? exceptionsArray = null; + + while (currentException != null) + { + // Set the current exception to the next inner exception of the current exception + currentException = currentException.InnerException; + if (currentException != null) + { + // While there are inner exceptions and they are not null, add them to the list + exceptions.Add(currentException); + } + } + + // If there are inner exceptions, convert the list to an array + if (exceptions.Count > 0) + exceptionsArray = exceptions.ToArray(); + + // Return the array of inner exceptions + // If there are no inner exceptions, the array will be null + return exceptionsArray; + } + } +} diff --git a/Download Manager/Controls/DarkTabControl.cs b/Download Manager/Controls/DarkTabControl.cs index 999c254..4ef9c68 100644 --- a/Download Manager/Controls/DarkTabControl.cs +++ b/Download Manager/Controls/DarkTabControl.cs @@ -190,11 +190,16 @@ public Color TabForeColor protected override void Dispose(bool disposing) { - _backBrush.Dispose(); - _tabBackBrush.Dispose(); - _tabForeBrush.Dispose(); + try + { + _backBrush.Dispose(); + _tabBackBrush.Dispose(); + _tabForeBrush.Dispose(); - base.Dispose(disposing); + base.Dispose(disposing); + } + catch (ObjectDisposedException) { } + catch (NullReferenceException) { } } private StringFormat _tabTextFormat = new StringFormat(); diff --git a/Download Manager/DownloadForm.Designer.cs b/Download Manager/DownloadForm.Designer.cs index feefc6e..dbea78a 100644 --- a/Download Manager/DownloadForm.Designer.cs +++ b/Download Manager/DownloadForm.Designer.cs @@ -404,12 +404,14 @@ private void InitializeComponent() Controls.Add(label1); FormBorderStyle = FormBorderStyle.FixedSingle; Icon = (Icon)resources.GetObject("$this.Icon"); + KeyPreview = true; Margin = new Padding(4, 3, 4, 3); MaximizeBox = false; Name = "DownloadForm"; Text = "Download Manager"; FormClosing += DownloadForm_FormClosing; Shown += DownloadForm_Shown; + KeyDown += DownloadForm_KeyDown; Move += DownloadForm_Move; trayContextMenu.ResumeLayout(false); trayContextMenu.PerformLayout(); diff --git a/Download Manager/DownloadForm.cs b/Download Manager/DownloadForm.cs index 985e601..c284062 100644 --- a/Download Manager/DownloadForm.cs +++ b/Download Manager/DownloadForm.cs @@ -392,5 +392,15 @@ private void trayIcon_MouseClick(object sender, MouseEventArgs e) catch { } } } + + private void DownloadForm_KeyDown(object sender, KeyEventArgs e) + { + // If CRTL+ALT+F3 is pressed and debug mode is enabled + if (e.Control && e.Alt && e.KeyCode == Keys.F3 && Program.DEBUG) + { + Components.DebugForm debugForm = new Components.DebugForm(); + debugForm.Show(); + } + } } } diff --git a/Download Manager/DownloadForm.resx b/Download Manager/DownloadForm.resx index ac9c604..f131eae 100644 --- a/Download Manager/DownloadForm.resx +++ b/Download Manager/DownloadForm.resx @@ -130,36 +130,6 @@ 578, 17 - - - iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAABGdBTUEAALGPC/xhBQAAALVJREFUSEvt - lsEKhTAMBHvw/39ZqVCIwyYxrd46MBfd7IKX91pzONp5rsrOEB6vyG4Jj6iCGcqNBwwrFcwouXXDkKeC - Gc+pwa6CmcjyYFfBTOYedVUwk7lHXRXMZO5RVwUzmenoDOygctQez8AOmo5Wh3nD7tejb4dVnt2lUftc - 4WX5vFsate8szGQd8jc1OrAZPuN7lXH/PXgHFVXHY3DAgy8IBwd/jHJDwk+1IrtDeDwjOwcX0yc3iCi8 - xmMAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAABGdBTUEAALGPC/xhBQAAAIxJREFUSEvt - lsEOgCAMxfj/n9ZgwsHasQDxtia9dbyjthZwtXadyjen8PhEvq3w6KPBZmWYsWqwEbn1wCjUYBO4N9g1 - 2ExcH+wabBJrNNZgk1ijsQabxBqNNdgk1uiv1miswSZx/ZtqsJm49/dgsAl8DQ4YqQYbkVsvGH802KwM - Dnh0It+ewuMd+ebgBsVAe9nXw0aFAAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL - DAAACwwBP0AiyAAAAaZJREFUSEutliHTAVEUhrcJBJUiin6JGaMqgqIIkiBIgmAEQTDDCMYQFIEqEBWa - 5HeYOd+cb+fu3X3P3rvX8sy85e55z8O4A88zQJ5H3wZ3WsHyN8HdsQSFbJboeBRLnLJcEi0WbuKgVCgQ - XS70z2wml9rCQkWSOCiVy0T3uy4yo5FcHpewUGESB6VKhej1wppPvy8lSUJFsxkVi3KngxUNP8P5JOFk - IuallMPvykToVScKcdYq5fDnaKJeTy20Szl8c02cTniisQiTpZz1GlfaSRC6STmHA66Ox0HIcZNmMkTn - MyqiOAo5blLOZoMazfPpf21ixxA3qe2WKvhiYc+QZKmLULHdyn5M7FKb8P3GE5/5XO5xkubzRPs9rtPw - palW8VQzHsudVikLbzdcownf0kYDn2oGAyGLl34iVGm3cUrT7cr5iDSNUKXXw2lNqyXmtbRWw3GNTagy - HGLL5/EgKpWi0shvKi9HXIQq02m0e70SFYtSKP49hMWfCFVWK7/LXxa5nFmoCAZYlkaostuJM3RFwOFf - BB2xYOmb4G4rWE4T3Kn4A4N1j/QSrk7eAAAAAElFTkSuQmCC - - AAABAAEAHRwAAAEAIABIDQAAFgAAACgAAAAdAAAAOAAAAAEAIAAAAAAAsAwAAAAAAAAAAAAAAAAAAAAA @@ -220,6 +190,36 @@ AAAAAAAAAAAAAPwAAfj4AAD48AAAeOAAADjAAAAYgAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAIwAAAGOAAADjwAAB4+AAA+PwA Afg= + + + + + iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAABGdBTUEAALGPC/xhBQAAALVJREFUSEvt + lsEKhTAMBHvw/39ZqVCIwyYxrd46MBfd7IKX91pzONp5rsrOEB6vyG4Jj6iCGcqNBwwrFcwouXXDkKeC + Gc+pwa6CmcjyYFfBTOYedVUwk7lHXRXMZO5RVwUzmenoDOygctQez8AOmo5Wh3nD7tejb4dVnt2lUftc + 4WX5vFsate8szGQd8jc1OrAZPuN7lXH/PXgHFVXHY3DAgy8IBwd/jHJDwk+1IrtDeDwjOwcX0yc3iCi8 + xmMAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAABGdBTUEAALGPC/xhBQAAAIxJREFUSEvt + lsEOgCAMxfj/n9ZgwsHasQDxtia9dbyjthZwtXadyjen8PhEvq3w6KPBZmWYsWqwEbn1wCjUYBO4N9g1 + 2ExcH+wabBJrNNZgk1ijsQabxBqNNdgk1uiv1miswSZx/ZtqsJm49/dgsAl8DQ4YqQYbkVsvGH802KwM + Dnh0It+ewuMd+ebgBsVAe9nXw0aFAAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAAB0AAAAcCAYAAACdz7SqAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL + DAAACwwBP0AiyAAAAaZJREFUSEutliHTAVEUhrcJBJUiin6JGaMqgqIIkiBIgmAEQTDDCMYQFIEqEBWa + 5HeYOd+cb+fu3X3P3rvX8sy85e55z8O4A88zQJ5H3wZ3WsHyN8HdsQSFbJboeBRLnLJcEi0WbuKgVCgQ + XS70z2wml9rCQkWSOCiVy0T3uy4yo5FcHpewUGESB6VKhej1wppPvy8lSUJFsxkVi3KngxUNP8P5JOFk + IuallMPvykToVScKcdYq5fDnaKJeTy20Szl8c02cTniisQiTpZz1GlfaSRC6STmHA66Ox0HIcZNmMkTn + MyqiOAo5blLOZoMazfPpf21ixxA3qe2WKvhiYc+QZKmLULHdyn5M7FKb8P3GE5/5XO5xkubzRPs9rtPw + palW8VQzHsudVikLbzdcownf0kYDn2oGAyGLl34iVGm3cUrT7cr5iDSNUKXXw2lNqyXmtbRWw3GNTagy + HGLL5/EgKpWi0shvKi9HXIQq02m0e70SFYtSKP49hMWfCFVWK7/LXxa5nFmoCAZYlkaostuJM3RFwOFf + BB2xYOmb4G4rWE4T3Kn4A4N1j/QSrk7eAAAAAElFTkSuQmCC @@ -232,6 +232,9 @@ If the file does not match the provided hash it will be downloaded and verified This is optional and not required for the download. If you do not have a file hash leave this option blank and no file verification will take place. If you do have a file hash ensure the combo-box has the correct value or file verification will fail. + + 733, 17 + 830, 17 diff --git a/Download Manager/Program.cs b/Download Manager/Program.cs index 3f83d40..1f5f66b 100644 --- a/Download Manager/Program.cs +++ b/Download Manager/Program.cs @@ -1,3 +1,4 @@ +using DownloadManager.Components.Extentions; using System.Diagnostics; using System.Text; @@ -5,7 +6,8 @@ namespace DownloadManager { internal static class Program { - private const bool DEBUG = true; + public const bool DEBUG = true; + public static bool allowBypassCrashHandler = true; /// /// The main entry point for the application. @@ -20,7 +22,7 @@ static void Main() // Enable hardware acceleration System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); - if (DEBUG == true) + if (!Debugger.IsAttached && DEBUG == true) { MessageBox.Show("Debug mode is on. You can now attach a debugger.\nTo turn it off, go to Program.cs and set DEBUG to false.\nPress OK to continue...", "Download Manager - DEBUG", MessageBoxButtons.OK, MessageBoxIcon.Information); } @@ -56,18 +58,52 @@ static void Main() } catch (Exception ex) { + if (Debugger.IsAttached && allowBypassCrashHandler) + { + throw; + } + // Define exception information - string exceptionType = Convert.ToString(ex.GetType()); - string exceptionMessage = ex.Message; + string exceptionType = ex.GetType().FullName; + string exceptionMessage = ex.Message.Replace(Environment.NewLine, "\\n"); string[] exceptionStackTraceOld = ex.StackTrace.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); StringBuilder exceptionStackTraceNew = new StringBuilder(); + // Append exception message and type to the new StackTrace foreach (string line in exceptionStackTraceOld) { // Append new StackTrace line to new StackTrace - exceptionStackTraceNew.Append('"' + line + '"' + " "); + exceptionStackTraceNew.Append('"' + line + "\" "); + } + + // Inner exceptions + if (ex.InnerException != null) + { + // Append inner exceptions header to the new StackTrace + exceptionStackTraceNew.Append("\n\"Inner Exceptions:\"\n\"======================\" "); + + // Use GetInnerExceptions extension method to get all inner exceptions and add them to the new StackTrace + foreach (Exception innerException in ex.GetInnerExceptions()) + { + // Append inner exception message and type to the new StackTrace + exceptionStackTraceNew.Append('"' + innerException.Message + $"({innerException.GetType().FullName})\" "); + + // Append inner exception StackTrace to the new (if it exists) + if (innerException.StackTrace != null) + { + // Split the inner exception StackTrace into lines + string[] oldInnerStackTrace = innerException.StackTrace.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); + + // Append each line of the inner exception StackTrace to the new + foreach (string line in oldInnerStackTrace) + { + exceptionStackTraceNew.Append('"' + line + "\" "); + } + } + } } + // Create CrashHandler process ProcessStartInfo crashInfo = new ProcessStartInfo(); crashInfo.FileName = "CrashHandler.exe";