diff --git a/GBM/Forms/frmSettings.Designer.vb b/GBM/Forms/frmSettings.Designer.vb index e2595dd..834ad2c 100644 --- a/GBM/Forms/frmSettings.Designer.vb +++ b/GBM/Forms/frmSettings.Designer.vb @@ -187,7 +187,7 @@ Partial Class frmSettings 'btnSave ' Me.btnSave.DialogResult = System.Windows.Forms.DialogResult.OK - Me.btnSave.Location = New System.Drawing.Point(586, 305) + Me.btnSave.Location = New System.Drawing.Point(586, 326) Me.btnSave.Name = "btnSave" Me.btnSave.Size = New System.Drawing.Size(75, 23) Me.btnSave.TabIndex = 5 @@ -197,7 +197,7 @@ Partial Class frmSettings 'btnCancel ' Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel - Me.btnCancel.Location = New System.Drawing.Point(667, 305) + Me.btnCancel.Location = New System.Drawing.Point(667, 326) Me.btnCancel.Name = "btnCancel" Me.btnCancel.Size = New System.Drawing.Size(75, 23) Me.btnCancel.TabIndex = 6 @@ -295,11 +295,13 @@ Partial Class frmSettings Me.grp7z.Controls.Add(Me.lblLocation) Me.grp7z.Controls.Add(Me.txt7zArguments) Me.grp7z.Controls.Add(Me.lblArguments) + Me.grp7z.Controls.Add(Me.lbl7zCopyright) Me.grp7z.Controls.Add(Me.cboCompression) Me.grp7z.Controls.Add(Me.lblCompression) + Me.grp7z.Controls.Add(Me.lbl7zProduct) Me.grp7z.Location = New System.Drawing.Point(12, 183) Me.grp7z.Name = "grp7z" - Me.grp7z.Size = New System.Drawing.Size(360, 102) + Me.grp7z.Size = New System.Drawing.Size(360, 137) Me.grp7z.TabIndex = 1 Me.grp7z.TabStop = False Me.grp7z.Text = "7z Options" @@ -365,23 +367,23 @@ Partial Class frmSettings ' 'lbl7zCopyright ' - Me.lbl7zCopyright.Location = New System.Drawing.Point(375, 265) + Me.lbl7zCopyright.Location = New System.Drawing.Point(6, 110) Me.lbl7zCopyright.Name = "lbl7zCopyright" - Me.lbl7zCopyright.Size = New System.Drawing.Size(363, 20) + Me.lbl7zCopyright.Size = New System.Drawing.Size(348, 17) Me.lbl7zCopyright.TabIndex = 8 - Me.lbl7zCopyright.TextAlign = System.Drawing.ContentAlignment.TopRight + Me.lbl7zCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'lbl7zProduct ' - Me.lbl7zProduct.Location = New System.Drawing.Point(375, 246) + Me.lbl7zProduct.Location = New System.Drawing.Point(6, 93) Me.lbl7zProduct.Name = "lbl7zProduct" - Me.lbl7zProduct.Size = New System.Drawing.Size(363, 20) + Me.lbl7zProduct.Size = New System.Drawing.Size(348, 17) Me.lbl7zProduct.TabIndex = 7 - Me.lbl7zProduct.TextAlign = System.Drawing.ContentAlignment.TopRight + Me.lbl7zProduct.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'btnDefaults ' - Me.btnDefaults.Location = New System.Drawing.Point(12, 305) + Me.btnDefaults.Location = New System.Drawing.Point(12, 326) Me.btnDefaults.Name = "btnDefaults" Me.btnDefaults.Size = New System.Drawing.Size(110, 23) Me.btnDefaults.TabIndex = 4 @@ -392,15 +394,13 @@ Partial Class frmSettings ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(749, 336) + Me.ClientSize = New System.Drawing.Size(749, 361) Me.Controls.Add(Me.btnDefaults) Me.Controls.Add(Me.grp7z) Me.Controls.Add(Me.grpBackup) Me.Controls.Add(Me.grpPaths) Me.Controls.Add(Me.btnCancel) - Me.Controls.Add(Me.lbl7zCopyright) Me.Controls.Add(Me.btnSave) - Me.Controls.Add(Me.lbl7zProduct) Me.Controls.Add(Me.grpGeneral) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False diff --git a/GBM/Game Backup Monitor.vbproj b/GBM/Game Backup Monitor.vbproj index 3ef7522..c471e95 100644 --- a/GBM/Game Backup Monitor.vbproj +++ b/GBM/Game Backup Monitor.vbproj @@ -283,7 +283,6 @@ VbMyResourcesResXFileCodeGenerator My.Resources Designer - Resources.Designer.vb @@ -329,24 +328,12 @@ PreserveNewest - - PreserveNewest - PreserveNewest - - PreserveNewest - - - PreserveNewest - PreserveNewest - - PreserveNewest - diff --git a/GBM/Managers/mgrBackup.vb b/GBM/Managers/mgrBackup.vb index 0a1e77d..2a1de0e 100644 --- a/GBM/Managers/mgrBackup.vb +++ b/GBM/Managers/mgrBackup.vb @@ -170,38 +170,43 @@ Public Class mgrBackup Try If Directory.Exists(sSavePath) Then - 'Need to delete any prior archive if it exists, the 7za utility does not support overwriting or deleting existing archives. - 'If we let 7za update existing archives it will lead to excessive bloat with games that routinely add and remove files with many different file names. - If File.Exists(sBackupFile) Then - File.Delete(sBackupFile) - End If + If Settings.Is7zUtilityValid Then + 'Need to delete any prior archive if it exists, the 7za utility does not support overwriting or deleting existing archives. + 'If we let 7za update existing archives it will lead to excessive bloat with games that routinely add and remove files with many different file names. + If File.Exists(sBackupFile) Then + File.Delete(sBackupFile) + End If - prs7z.StartInfo.Arguments = "a" & oSettings.Prepared7zArguments & "-t7z -mx" & oSettings.CompressionLevel & " -i@""" & mgrPath.IncludeFileLocation & """ -x@""" & mgrPath.ExcludeFileLocation & """ """ & sBackupFile & """ -r" - prs7z.StartInfo.FileName = oSettings.Utility7zLocation - prs7z.StartInfo.UseShellExecute = False - prs7z.StartInfo.RedirectStandardOutput = True - prs7z.StartInfo.CreateNoWindow = True - prs7z.Start() - RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_BackupInProgress, sSavePath), False, ToolTipIcon.Info, True) - While Not prs7z.StandardOutput.EndOfStream - If CancelOperation Then - prs7z.Kill() - RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorFullAbort, oGame.Name), True, ToolTipIcon.Error, True) - Exit While - End If - RaiseEvent UpdateLog(prs7z.StandardOutput.ReadLine, False, ToolTipIcon.Info, False) - End While - prs7z.WaitForExit() - If Not CancelOperation Then - If prs7z.ExitCode = 0 Then - RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_BackupComplete, New String() {oGame.Name, mgrCommon.GetFileSize(sBackupFile)}), False, ToolTipIcon.Info, True) - bBackupCompleted = True - Else - RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_BackupWarnings, oGame.Name), True, ToolTipIcon.Warning, True) - bBackupCompleted = False + prs7z.StartInfo.Arguments = "a" & oSettings.Prepared7zArguments & "-t7z -mx" & oSettings.CompressionLevel & " -i@""" & mgrPath.IncludeFileLocation & """ -x@""" & mgrPath.ExcludeFileLocation & """ """ & sBackupFile & """ -r" + prs7z.StartInfo.FileName = oSettings.Utility7zLocation + prs7z.StartInfo.UseShellExecute = False + prs7z.StartInfo.RedirectStandardOutput = True + prs7z.StartInfo.CreateNoWindow = True + prs7z.Start() + RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_BackupInProgress, sSavePath), False, ToolTipIcon.Info, True) + While Not prs7z.StandardOutput.EndOfStream + If CancelOperation Then + prs7z.Kill() + RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorFullAbort, oGame.Name), True, ToolTipIcon.Error, True) + Exit While + End If + RaiseEvent UpdateLog(prs7z.StandardOutput.ReadLine, False, ToolTipIcon.Info, False) + End While + prs7z.WaitForExit() + If Not CancelOperation Then + If prs7z.ExitCode = 0 Then + RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_BackupComplete, New String() {oGame.Name, mgrCommon.GetFileSize(sBackupFile)}), False, ToolTipIcon.Info, True) + bBackupCompleted = True + Else + RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_BackupWarnings, oGame.Name), True, ToolTipIcon.Warning, True) + bBackupCompleted = False + End If End If + prs7z.Dispose() + Else + RaiseEvent UpdateLog(App_Invalid7zDetected, True, ToolTipIcon.Error, True) + bBackupCompleted = False End If - prs7z.Dispose() Else RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorNoSavePath, oGame.Name), True, ToolTipIcon.Error, True) bBackupCompleted = False diff --git a/GBM/Managers/mgrCommon.vb b/GBM/Managers/mgrCommon.vb index 93a4835..87d88b3 100644 --- a/GBM/Managers/mgrCommon.vb +++ b/GBM/Managers/mgrCommon.vb @@ -5,6 +5,23 @@ Imports System.Security.Principal Public Class mgrCommon + 'These need to be updated when upgrading the packaged 7z utility + Private Shared sUtility64Hash As String = "05ACEE3BAC0C6C4E396116EF27B953F992DE8D28DD14D317977F45692304C318" 'v16.02 7za.exe x64 + Private Shared sUtility32Hash As String = "7AA7056DB4348229A288EEF49027B94C0D8D1A3C3AEDC6FA89B640334C7B37E9" 'v16.02 7za.exe x86 + + Public Shared ReadOnly Property UtilityHash As String + Get + Select Case mgrPath.ReleaseType + Case 64 + Return sUtility64Hash + Case 32 + Return sUtility32Hash + Case Else + Return sUtility32Hash + End Select + End Get + End Property + Public Shared ReadOnly Property BuildVersion As Integer Get Return My.Application.Info.Version.Build diff --git a/GBM/Managers/mgrRestore.vb b/GBM/Managers/mgrRestore.vb index ba02fc4..358d912 100644 --- a/GBM/Managers/mgrRestore.vb +++ b/GBM/Managers/mgrRestore.vb @@ -231,32 +231,37 @@ Public Class mgrRestore Try If File.Exists(sBackupFile) Then - prs7z.StartInfo.Arguments = "x" & oSettings.Prepared7zArguments & """" & sBackupFile & """ -o""" & sExtractPath & Path.DirectorySeparatorChar & """ -aoa -r" - prs7z.StartInfo.FileName = oSettings.Utility7zLocation - prs7z.StartInfo.UseShellExecute = False - prs7z.StartInfo.RedirectStandardOutput = True - prs7z.StartInfo.CreateNoWindow = True - prs7z.Start() - RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_RestoreInProgress, sExtractPath), False, ToolTipIcon.Info, True) - While Not prs7z.StandardOutput.EndOfStream - If CancelOperation Then - prs7z.Kill() - RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorFullAbort, oBackupInfo.Name), True, ToolTipIcon.Error, True) - Exit While - End If - RaiseEvent UpdateLog(prs7z.StandardOutput.ReadLine, False, ToolTipIcon.Info, False) - End While - prs7z.WaitForExit() - If Not CancelOperation Then - If prs7z.ExitCode = 0 Then - RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_RestoreComplete, oBackupInfo.Name), False, ToolTipIcon.Info, True) - bRestoreCompleted = True - Else - RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_RestoreWarnings, oBackupInfo.Name), True, ToolTipIcon.Warning, True) - bRestoreCompleted = False + If Settings.Is7zUtilityValid Then + prs7z.StartInfo.Arguments = "x" & oSettings.Prepared7zArguments & """" & sBackupFile & """ -o""" & sExtractPath & Path.DirectorySeparatorChar & """ -aoa -r" + prs7z.StartInfo.FileName = oSettings.Utility7zLocation + prs7z.StartInfo.UseShellExecute = False + prs7z.StartInfo.RedirectStandardOutput = True + prs7z.StartInfo.CreateNoWindow = True + prs7z.Start() + RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_RestoreInProgress, sExtractPath), False, ToolTipIcon.Info, True) + While Not prs7z.StandardOutput.EndOfStream + If CancelOperation Then + prs7z.Kill() + RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_ErrorFullAbort, oBackupInfo.Name), True, ToolTipIcon.Error, True) + Exit While + End If + RaiseEvent UpdateLog(prs7z.StandardOutput.ReadLine, False, ToolTipIcon.Info, False) + End While + prs7z.WaitForExit() + If Not CancelOperation Then + If prs7z.ExitCode = 0 Then + RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_RestoreComplete, oBackupInfo.Name), False, ToolTipIcon.Info, True) + bRestoreCompleted = True + Else + RaiseEvent UpdateLog(mgrCommon.FormatString(mgrRestore_RestoreWarnings, oBackupInfo.Name), True, ToolTipIcon.Warning, True) + bRestoreCompleted = False + End If End If + prs7z.Dispose() + Else + RaiseEvent UpdateLog(App_Invalid7zDetected, True, ToolTipIcon.Error, True) + bRestoreCompleted = False End If - prs7z.Dispose() Else RaiseEvent UpdateLog(mgrRestore_ErrorNoBackup, True, ToolTipIcon.Error, True) End If diff --git a/GBM/Managers/mgrSettings.vb b/GBM/Managers/mgrSettings.vb index e600206..94ecf4d 100644 --- a/GBM/Managers/mgrSettings.vb +++ b/GBM/Managers/mgrSettings.vb @@ -178,6 +178,23 @@ Public Class mgrSettings End Set End Property + ReadOnly Property Is7zUtilityValid As Boolean + Get + 'We don't use a packaged 7za on Unix, assume valid. + If mgrCommon.IsUnix Then + Return True + End If + + If s7zLocation = String.Empty Then + 'Verify stored hash of the default utility if we're using it + Return mgrCommon.UtilityHash = mgrHash.Generate_SHA256_Hash(mgrPath.Default7zLocation) + Else + 'When using a custom utility assume it's valid, we have no way to be sure. + Return True + End If + End Get + End Property + ReadOnly Property Utility7zLocation As String Get 'Return default utility when custom setting is not used diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 647982c..5e7f05b 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -87,6 +87,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to 7-Zip (7za.exe) failed to be validated and has been prevented from running. The application may be corrupted or has been modified by another application. Verify your PC's security and re-install GBM to solve this problem.. + ''' + Friend ReadOnly Property App_Invalid7zDetected() As String + Get + Return ResourceManager.GetString("App_Invalid7zDetected", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to [PARAM] KB. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 0a5e08d..53ad278 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -1630,4 +1630,7 @@ You have chosen a custom utility that does not appear to be 7-Zip Console (7za). GBM only supports the use of 7-Zip. + + 7-Zip (7za.exe) is invalid and has been prevented from running. + \ No newline at end of file diff --git a/GBM/Utilities/x64/7za.dll b/GBM/Utilities/x64/7za.dll deleted file mode 100644 index 4bc3a64..0000000 Binary files a/GBM/Utilities/x64/7za.dll and /dev/null differ diff --git a/GBM/Utilities/x64/7zxa.dll b/GBM/Utilities/x64/7zxa.dll deleted file mode 100644 index 4fa6de0..0000000 Binary files a/GBM/Utilities/x64/7zxa.dll and /dev/null differ diff --git a/GBM/Utilities/x86/7za.dll b/GBM/Utilities/x86/7za.dll deleted file mode 100644 index f63e760..0000000 Binary files a/GBM/Utilities/x86/7za.dll and /dev/null differ diff --git a/GBM/Utilities/x86/7zxa.dll b/GBM/Utilities/x86/7zxa.dll deleted file mode 100644 index e5591ac..0000000 Binary files a/GBM/Utilities/x86/7zxa.dll and /dev/null differ