From d7cdfe39dc55cee0b645a6350ba12c1cf32f4c62 Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Fri, 20 Sep 2024 12:03:32 +0200 Subject: [PATCH] [Mounted images] Fixed sync issues and #169 --- MainForm.Designer.vb | 8 ++++---- MainForm.vb | 15 +++++++++++++-- Panels/Img_Ops/MountedImgMgr.vb | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/MainForm.Designer.vb b/MainForm.Designer.vb index 52e2cd57..cb873413 100644 --- a/MainForm.Designer.vb +++ b/MainForm.Designer.vb @@ -3993,7 +3993,7 @@ Partial Class MainForm Me.TableLayoutPanel2.ColumnCount = 3 Me.TableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 32.4200897!)) Me.TableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 67.5799103!)) - Me.TableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 141.0!)) + Me.TableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 142.0!)) Me.TableLayoutPanel2.Controls.Add(Me.ProjNameEditBtn, 2, 0) Me.TableLayoutPanel2.Controls.Add(Me.LinkLabel1, 1, 3) Me.TableLayoutPanel2.Controls.Add(Me.Panel8, 1, 0) @@ -4042,7 +4042,7 @@ Partial Class MainForm Me.Panel8.Dock = System.Windows.Forms.DockStyle.Fill Me.Panel8.Location = New System.Drawing.Point(51, 3) Me.Panel8.Name = "Panel8" - Me.Panel8.Size = New System.Drawing.Size(96, 23) + Me.Panel8.Size = New System.Drawing.Size(95, 23) Me.Panel8.TabIndex = 8 ' 'projName @@ -4051,7 +4051,7 @@ Partial Class MainForm Me.projName.Dock = System.Windows.Forms.DockStyle.Fill Me.projName.Location = New System.Drawing.Point(0, 0) Me.projName.Name = "projName" - Me.projName.Size = New System.Drawing.Size(96, 23) + Me.projName.Size = New System.Drawing.Size(95, 23) Me.projName.TabIndex = 2 Me.projName.Text = "projName" Me.projName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft @@ -4061,7 +4061,7 @@ Partial Class MainForm Me.projNameText.Dock = System.Windows.Forms.DockStyle.Fill Me.projNameText.Location = New System.Drawing.Point(0, 0) Me.projNameText.Name = "projNameText" - Me.projNameText.Size = New System.Drawing.Size(96, 21) + Me.projNameText.Size = New System.Drawing.Size(95, 21) Me.projNameText.TabIndex = 4 Me.projNameText.Text = "projName" Me.projNameText.Visible = False diff --git a/MainForm.vb b/MainForm.vb index b1b6f859..54783db3 100644 --- a/MainForm.vb +++ b/MainForm.vb @@ -176,6 +176,7 @@ Public Class MainForm ' Refactored listings for 0.6 Public MountedImages As New List(Of MountedImage) + Public ImageDetectionComplete As Boolean Public MountedImageImgFiles(65535) As String Public MountedImageMountDirs(65535) As String @@ -862,8 +863,13 @@ Public Class MainForm imageStatus = ImageWatcher.Status.Invalid End Select Dim imageVersion As New Version() - imageVersion = New Version(FileVersionInfo.GetVersionInfo(imageInfo.MountPath & "\Windows\system32\ntoskrnl.exe").ProductVersion) - MountedImages.Add(New MountedImage(imageInfo.ImageFilePath, imageInfo.ImageIndex, imageInfo.MountPath, imageStatus, (imageInfo.MountMode = DismMountMode.ReadWrite), imageVersion)) + If File.Exists(imageInfo.MountPath & "\Windows\system32\ntoskrnl.exe") Then + imageVersion = New Version(FileVersionInfo.GetVersionInfo(imageInfo.MountPath & "\Windows\system32\ntoskrnl.exe").ProductVersion) + MountedImages.Add(New MountedImage(imageInfo.ImageFilePath, imageInfo.ImageIndex, imageInfo.MountPath, imageStatus, (imageInfo.MountMode = DismMountMode.ReadWrite), imageVersion)) + Else + ' Could not get image version. Skip mounted image + Continue For + End If Next MountedImageImgFiles = MountedImageImgFileList.ToArray() MountedImageImgIndexes = MountedImageImgIndexList.ToArray() @@ -14820,13 +14826,18 @@ Public Class MainForm Private Sub MountedImageDetectorBW_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles MountedImageDetectorBW.DoWork Do + ImageDetectionComplete = False If MountedImageDetectorBW.CancellationPending Or ImgBW.IsBusy Then Exit Do DetectMountedImages(False) + ImageDetectionComplete = True Thread.Sleep(1000) Loop End Sub Private Sub MountedImageDetectorBW_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles MountedImageDetectorBW.RunWorkerCompleted + If e.Error IsNot Nothing Then + Throw New Exception("The mounted image detector has stopped unexpectedly. Check the error information below:" & CrLf & CrLf, e.Error) + End If Select Case Language Case 0 Select Case My.Computer.Info.InstalledUICulture.ThreeLetterWindowsLanguageName diff --git a/Panels/Img_Ops/MountedImgMgr.vb b/Panels/Img_Ops/MountedImgMgr.vb index 060a7ed1..93be9253 100644 --- a/Panels/Img_Ops/MountedImgMgr.vb +++ b/Panels/Img_Ops/MountedImgMgr.vb @@ -377,6 +377,7 @@ Public Class MountedImgMgr Private Sub DetectorBW_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles DetectorBW.ProgressChanged If DetectorBW.CancellationPending Then Exit Sub + If Not MainForm.ImageDetectionComplete Then Exit Sub If MainForm.MountedImages.Count <= 0 Then ListView1.Items.Clear() Exit Sub