Added basic 7za validation

This commit is contained in:
Michael J. Seiferling
2016-05-25 15:20:44 -06:00
parent ab240b610c
commit 7f19ae6345
12 changed files with 122 additions and 79 deletions
+13 -13
View File
@@ -187,7 +187,7 @@ Partial Class frmSettings
'btnSave 'btnSave
' '
Me.btnSave.DialogResult = System.Windows.Forms.DialogResult.OK 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.Name = "btnSave"
Me.btnSave.Size = New System.Drawing.Size(75, 23) Me.btnSave.Size = New System.Drawing.Size(75, 23)
Me.btnSave.TabIndex = 5 Me.btnSave.TabIndex = 5
@@ -197,7 +197,7 @@ Partial Class frmSettings
'btnCancel 'btnCancel
' '
Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel 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.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(75, 23) Me.btnCancel.Size = New System.Drawing.Size(75, 23)
Me.btnCancel.TabIndex = 6 Me.btnCancel.TabIndex = 6
@@ -295,11 +295,13 @@ Partial Class frmSettings
Me.grp7z.Controls.Add(Me.lblLocation) Me.grp7z.Controls.Add(Me.lblLocation)
Me.grp7z.Controls.Add(Me.txt7zArguments) Me.grp7z.Controls.Add(Me.txt7zArguments)
Me.grp7z.Controls.Add(Me.lblArguments) Me.grp7z.Controls.Add(Me.lblArguments)
Me.grp7z.Controls.Add(Me.lbl7zCopyright)
Me.grp7z.Controls.Add(Me.cboCompression) Me.grp7z.Controls.Add(Me.cboCompression)
Me.grp7z.Controls.Add(Me.lblCompression) Me.grp7z.Controls.Add(Me.lblCompression)
Me.grp7z.Controls.Add(Me.lbl7zProduct)
Me.grp7z.Location = New System.Drawing.Point(12, 183) Me.grp7z.Location = New System.Drawing.Point(12, 183)
Me.grp7z.Name = "grp7z" 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.TabIndex = 1
Me.grp7z.TabStop = False Me.grp7z.TabStop = False
Me.grp7z.Text = "7z Options" Me.grp7z.Text = "7z Options"
@@ -365,23 +367,23 @@ Partial Class frmSettings
' '
'lbl7zCopyright '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.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.TabIndex = 8
Me.lbl7zCopyright.TextAlign = System.Drawing.ContentAlignment.TopRight Me.lbl7zCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleRight
' '
'lbl7zProduct '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.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.TabIndex = 7
Me.lbl7zProduct.TextAlign = System.Drawing.ContentAlignment.TopRight Me.lbl7zProduct.TextAlign = System.Drawing.ContentAlignment.MiddleRight
' '
'btnDefaults '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.Name = "btnDefaults"
Me.btnDefaults.Size = New System.Drawing.Size(110, 23) Me.btnDefaults.Size = New System.Drawing.Size(110, 23)
Me.btnDefaults.TabIndex = 4 Me.btnDefaults.TabIndex = 4
@@ -392,15 +394,13 @@ Partial Class frmSettings
' '
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font 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.btnDefaults)
Me.Controls.Add(Me.grp7z) Me.Controls.Add(Me.grp7z)
Me.Controls.Add(Me.grpBackup) Me.Controls.Add(Me.grpBackup)
Me.Controls.Add(Me.grpPaths) Me.Controls.Add(Me.grpPaths)
Me.Controls.Add(Me.btnCancel) Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.lbl7zCopyright)
Me.Controls.Add(Me.btnSave) Me.Controls.Add(Me.btnSave)
Me.Controls.Add(Me.lbl7zProduct)
Me.Controls.Add(Me.grpGeneral) Me.Controls.Add(Me.grpGeneral)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False Me.MaximizeBox = False
-13
View File
@@ -283,7 +283,6 @@
<Generator>VbMyResourcesResXFileCodeGenerator</Generator> <Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<CustomToolNamespace>My.Resources</CustomToolNamespace> <CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType> <SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -329,24 +328,12 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="References\Mono.Data.Sqlite.dll" /> <Content Include="References\Mono.Data.Sqlite.dll" />
<Content Include="Utilities\x64\7za.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Utilities\x64\7za.exe"> <Content Include="Utilities\x64\7za.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Utilities\x64\7zxa.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Utilities\x86\7za.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Utilities\x86\7za.exe"> <Content Include="Utilities\x86\7za.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Utilities\x86\7zxa.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="x86\sqlite3.dll" /> <Content Include="x86\sqlite3.dll" />
<None Include="Resources\gbm.ico" /> <None Include="Resources\gbm.ico" />
<Content Include="Resources\Admin.png" /> <Content Include="Resources\Admin.png" />
+5
View File
@@ -170,6 +170,7 @@ Public Class mgrBackup
Try Try
If Directory.Exists(sSavePath) Then If Directory.Exists(sSavePath) Then
If Settings.Is7zUtilityValid Then
'Need to delete any prior archive if it exists, the 7za utility does not support overwriting or deleting existing archives. '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 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 If File.Exists(sBackupFile) Then
@@ -202,6 +203,10 @@ Public Class mgrBackup
End If End If
End If End If
prs7z.Dispose() prs7z.Dispose()
Else
RaiseEvent UpdateLog(App_Invalid7zDetected, True, ToolTipIcon.Error, True)
bBackupCompleted = False
End If
Else Else
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorNoSavePath, oGame.Name), True, ToolTipIcon.Error, True) RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorNoSavePath, oGame.Name), True, ToolTipIcon.Error, True)
bBackupCompleted = False bBackupCompleted = False
+17
View File
@@ -5,6 +5,23 @@ Imports System.Security.Principal
Public Class mgrCommon 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 Public Shared ReadOnly Property BuildVersion As Integer
Get Get
Return My.Application.Info.Version.Build Return My.Application.Info.Version.Build
+5
View File
@@ -231,6 +231,7 @@ Public Class mgrRestore
Try Try
If File.Exists(sBackupFile) Then If File.Exists(sBackupFile) Then
If Settings.Is7zUtilityValid Then
prs7z.StartInfo.Arguments = "x" & oSettings.Prepared7zArguments & """" & sBackupFile & """ -o""" & sExtractPath & Path.DirectorySeparatorChar & """ -aoa -r" prs7z.StartInfo.Arguments = "x" & oSettings.Prepared7zArguments & """" & sBackupFile & """ -o""" & sExtractPath & Path.DirectorySeparatorChar & """ -aoa -r"
prs7z.StartInfo.FileName = oSettings.Utility7zLocation prs7z.StartInfo.FileName = oSettings.Utility7zLocation
prs7z.StartInfo.UseShellExecute = False prs7z.StartInfo.UseShellExecute = False
@@ -257,6 +258,10 @@ Public Class mgrRestore
End If End If
End If End If
prs7z.Dispose() prs7z.Dispose()
Else
RaiseEvent UpdateLog(App_Invalid7zDetected, True, ToolTipIcon.Error, True)
bRestoreCompleted = False
End If
Else Else
RaiseEvent UpdateLog(mgrRestore_ErrorNoBackup, True, ToolTipIcon.Error, True) RaiseEvent UpdateLog(mgrRestore_ErrorNoBackup, True, ToolTipIcon.Error, True)
End If End If
+17
View File
@@ -178,6 +178,23 @@ Public Class mgrSettings
End Set End Set
End Property 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 ReadOnly Property Utility7zLocation As String
Get Get
'Return default utility when custom setting is not used 'Return default utility when custom setting is not used
+9
View File
@@ -87,6 +87,15 @@ Namespace My.Resources
End Get End Get
End Property End Property
'''<summary>
''' 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&apos;s security and re-install GBM to solve this problem..
'''</summary>
Friend ReadOnly Property App_Invalid7zDetected() As String
Get
Return ResourceManager.GetString("App_Invalid7zDetected", resourceCulture)
End Get
End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to [PARAM] KB. ''' Looks up a localized string similar to [PARAM] KB.
'''</summary> '''</summary>
+3
View File
@@ -1630,4 +1630,7 @@
<data name="frmSettings_WarningLocation" xml:space="preserve"> <data name="frmSettings_WarningLocation" xml:space="preserve">
<value>You have chosen a custom utility that does not appear to be 7-Zip Console (7za). GBM only supports the use of 7-Zip.</value> <value>You have chosen a custom utility that does not appear to be 7-Zip Console (7za). GBM only supports the use of 7-Zip.</value>
</data> </data>
<data name="App_Invalid7zDetected" xml:space="preserve">
<value>7-Zip (7za.exe) is invalid and has been prevented from running.</value>
</data>
</root> </root>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.