Skip to content

Commit 9f5cab0

Browse files
committed
Check multiple files
1 parent 2f8c6a6 commit 9f5cab0

3 files changed

Lines changed: 57 additions & 20 deletions

File tree

PSMSVirtualDeviceManager/Classes/ClassCameraFirmwareWatchdog.vb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,25 @@
118118
End SyncLock
119119
End Sub
120120

121-
Public Sub RunFirmwareUploader()
121+
Public Function GetFirmwareInstallerPath() As String
122122
Dim sRootFolder As String = IO.Path.Combine(IO.Path.GetDirectoryName(Application.ExecutablePath), ClassLibusbDriver.DRV_PS4CAM_ROOT_NAME)
123123
Dim sInstallerPath As String = IO.Path.Combine(sRootFolder, ClassLibusbDriver.DRV_PS4CAM_FIRMWARE_NAME)
124+
125+
Return sInstallerPath
126+
End Function
127+
128+
Public Function GetFirmwarePath() As String
129+
Dim sRootFolder As String = IO.Path.Combine(IO.Path.GetDirectoryName(Application.ExecutablePath), ClassLibusbDriver.DRV_PS4CAM_ROOT_NAME)
124130
Dim sFirmwarePath As String = IO.Path.Combine(sRootFolder, ClassLibusbDriver.DRV_PS4CAM_FIRMWARE_BIN_NAME)
125131

132+
Return sFirmwarePath
133+
End Function
134+
135+
Public Sub RunFirmwareUploader()
136+
Dim sInstallerPath As String = GetFirmwareInstallerPath()
137+
Dim sFirmwarePath As String = GetFirmwarePath()
138+
Dim sRootFolder As String = IO.Path.GetDirectoryName(sInstallerPath)
139+
126140
If (Not IO.File.Exists(sFirmwarePath)) Then
127141
Throw New ArgumentException("Firmware file does not exist")
128142
End If

PSMSVirtualDeviceManager/Classes/ClassLibusbDriver.vb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,13 @@ Public Class ClassLibusbDriver
337337
Public Sub New()
338338
End Sub
339339

340+
Public Function GetDriverInstallerPath() As String
341+
Dim sRootFolder As String = IO.Path.Combine(IO.Path.GetDirectoryName(Application.ExecutablePath), DRV_WDI_ROOT_NAME)
342+
Dim sInstallerPath As String = IO.Path.Combine(sRootFolder, DRV_WDI_INSTALLER_NAME)
343+
344+
Return sInstallerPath
345+
End Function
346+
340347
Public Function InstallPlaystation4CamDriver64() As ENUM_WDI_ERROR
341348
For Each mConfig As STRUC_DEVICE_DRIVER_INFO In DRV_PS4CAM_WINUSB_CONFIGS
342349
'Remove device first so we speed up the driver installation using WDI
@@ -739,8 +746,8 @@ Public Class ClassLibusbDriver
739746
End Function
740747

741748
Private Function InternalInstallDriver64(mInfo As STRUC_DEVICE_DRIVER_INFO) As ENUM_WDI_ERROR
742-
Dim sRootFolder As String = IO.Path.Combine(IO.Path.GetDirectoryName(Application.ExecutablePath), DRV_WDI_ROOT_NAME)
743-
Dim sInstallerPath As String = IO.Path.Combine(sRootFolder, DRV_WDI_INSTALLER_NAME)
749+
Dim sInstallerPath As String = GetDriverInstallerPath()
750+
Dim sRootFolder As String = IO.Path.GetDirectoryName(sInstallerPath)
744751

745752
Using mProcess As New Process
746753
mProcess.StartInfo.FileName = sInstallerPath

PSMSVirtualDeviceManager/FormMain.vb

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Public Class FormMain
2424
Private g_bAutoClose As Boolean = False
2525
Private g_bAllowRestartPrompt As Boolean = False
2626
Private g_bInit As Boolean = False
27+
Private g_ForceReinstall As Boolean = False
2728

2829
Private g_mMutex As Threading.Mutex
2930
Private Const MUTEX_NAME As String = "PSMoveServiceEx_VDM_Mutex"
@@ -181,24 +182,35 @@ Public Class FormMain
181182
' Windows Explorer keeps blocking files because the zip has been downlaoded from the internet.
182183
' Sadly, blocked files can not run elevated such as for installing drivers.
183184
' So abort right here.
184-
Dim sExeConfig As String = String.Format("{0}.config", Application.ExecutablePath)
185-
186-
If (IO.File.Exists(sExeConfig)) Then
187-
If (ClassUtils.FileHasZoneIdentifier(sExeConfig)) Then
188-
Dim sBlockedMessage As New Text.StringBuilder
189-
sBlockedMessage.AppendLine("Windows Security blocked PSMoveServiceEx - Virtual Device Manager because it has been downloaded from the internet or another computer.")
190-
sBlockedMessage.AppendLine()
191-
sBlockedMessage.AppendLine("Make sure you unblock the PSMoveServiceEx - Virtual Device Manager ZIP archive you have downloaded (Right-Click on the ZIP archive, open properties and check 'Unblock') before extracting it.")
192-
sBlockedMessage.AppendLine("You can also use a third-party archive manager such as 7zip or WinRAR to extract the archive instead.")
193-
sBlockedMessage.AppendLine()
194-
sBlockedMessage.AppendLine("Application will now close.")
195-
196-
MessageBox.Show(sBlockedMessage.ToString, "Windows Security Warning", MessageBoxButtons.OK, MessageBoxIcon.Error)
197-
198-
Environment.Exit(-1)
199-
End
185+
Dim sCheckedFiles As New List(Of String)
186+
sCheckedFiles.Add(String.Format("{0}.config", Application.ExecutablePath))
187+
sCheckedFiles.Add((New ClassLibusbDriver).GetDriverInstallerPath())
188+
sCheckedFiles.Add((New ClassCameraFirmwareWatchdog).GetFirmwareInstallerPath())
189+
190+
For Each sFile As String In sCheckedFiles
191+
If (IO.File.Exists(sFile)) Then
192+
If (ClassUtils.FileHasZoneIdentifier(sFile)) Then
193+
Dim sBlockedMessage As New Text.StringBuilder
194+
sBlockedMessage.AppendLine("Windows Security blocked PSMoveServiceEx - Virtual Device Manager because it has been downloaded from the internet or another computer.")
195+
sBlockedMessage.AppendLine()
196+
sBlockedMessage.AppendLine("Make sure you unblock the PSMoveServiceEx - Virtual Device Manager ZIP archive you have downloaded (Right-Click on the ZIP archive, open properties and check 'Unblock') before extracting it.")
197+
sBlockedMessage.AppendLine()
198+
sBlockedMessage.AppendLine("Click OK to reinstall PSMoveServiceEx - Virtual Device Manager using the automatic updater to resolve the issue.")
199+
sBlockedMessage.AppendLine("Click CANCEL to close the program and do it manually.")
200+
201+
Select Case (MessageBox.Show(sBlockedMessage.ToString, "Windows Security Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Error))
202+
Case DialogResult.OK
203+
g_ForceReinstall = True
204+
205+
Case Else
206+
Environment.Exit(-1)
207+
End
208+
End Select
209+
210+
Exit For
211+
End If
200212
End If
201-
End If
213+
Next
202214
Catch ex As Exception
203215
ClassAdvancedExceptionLogging.WriteToLogMessageBox(ex)
204216
End Try
@@ -376,6 +388,10 @@ Public Class FormMain
376388
ClassAdvancedExceptionLogging.WriteToLogMessageBox(ex)
377389
End Try
378390

391+
If (g_ForceReinstall) Then
392+
g_mUCStartPage.StartVdmUpdateDownload()
393+
End If
394+
379395
g_bAllowRestartPrompt = True
380396
End Sub
381397

0 commit comments

Comments
 (0)