Skip to content

Commit 525f3d3

Browse files
committed
Updates to Filters
Updates to boot sector hex editor
1 parent faf1fe0 commit 525f3d3

File tree

9 files changed

+178
-69
lines changed

9 files changed

+178
-69
lines changed

DiskImageTool/DiskImage/BootSector.vb

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,38 @@
146146
End Set
147147
End Property
148148

149-
Public Shared Function CheckJumpInstruction(Value() As Byte, CheckNOP As Boolean) As Boolean
150-
Return (Value(0) = &HEB And (Not CheckNOP Or Value(2) = &H90)) Or Value(0) = &HE9
149+
Public Function CheckJumpInstruction(CheckNOP As Boolean) As Boolean
150+
Return CheckJumpInstruction(JmpBoot, CheckNOP)
151+
End Function
152+
153+
Public Function CheckJumpInstruction(CheckNOP As Boolean, CheckDestination As Boolean) As Boolean
154+
Return CheckJumpInstruction(JmpBoot, CheckNOP, CheckDestination)
155+
End Function
156+
157+
Public Shared Function CheckJumpInstruction(Jmp() As Byte, CheckNOP As Boolean) As Boolean
158+
Return CheckJumpInstruction(Jmp, CheckNOP, False)
159+
End Function
160+
161+
Public Shared Function CheckJumpInstruction(Jmp() As Byte, CheckNOP As Boolean, CheckDestination As Boolean) As Boolean
162+
Dim Result As Boolean = False
163+
164+
If Jmp(0) = &HEB And (Not CheckNOP Or Jmp(2) = &H90) Then
165+
If CheckDestination Then
166+
Dim Offset As UShort = Jmp(1) + 2
167+
Result = (Offset < BootSectorOffsets.BootStrapSignature)
168+
Else
169+
Result = True
170+
End If
171+
ElseIf Jmp(0) = &HE9 Then
172+
If CheckDestination Then
173+
Dim Offset As UShort = BitConverter.ToUInt16(Jmp, 1) + 3
174+
Result = (Offset < BootSectorOffsets.BootStrapSignature)
175+
Else
176+
Result = True
177+
End If
178+
End If
179+
180+
Return Result
151181
End Function
152182

153183
Public Shared Function GenerateVolumeSerialNumber(Value As Date) As UInteger
@@ -172,13 +202,12 @@
172202
End If
173203
End Function
174204

175-
Public Function GetBootStrapOffset(Jmp() As Byte) As UShort
176-
Dim JumpInstruction As Byte = Jmp(0)
205+
Public Shared Function GetBootStrapOffset(Jmp() As Byte) As UShort
177206
Dim Offset As UShort
178207

179-
If JumpInstruction = &HEB Then
208+
If Jmp(0) = &HEB Then
180209
Offset = Jmp(1) + 2
181-
ElseIf JumpInstruction = &HE9 Then
210+
ElseIf Jmp(0) = &HE9 Then
182211
Offset = BitConverter.ToUInt16(Jmp, 1) + 3
183212
Else
184213
Offset = 0
@@ -219,10 +248,6 @@
219248
Return ValidExtendedBootSignature.Contains(ExtendedBootSignature)
220249
End Function
221250

222-
Public Function HasValidJumpInstruction(CheckNOP As Boolean) As Boolean
223-
Return CheckJumpInstruction(JmpBoot, CheckNOP)
224-
End Function
225-
226251
Public Function IsBootSectorRegion(Offset As UInteger) As Boolean
227252
Return Disk.OffsetToSector(Offset) = BOOT_SECTOR
228253
End Function

DiskImageTool/FilterMethods.vb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Disk_UnknownFormat
77
Disk_CustomFormat
88
Disk_NOBPB
9+
Disk_NoBootLoader
910
DIsk_CustomBootLoader
1011
Disk_MismatchedImageSize
1112
Disk_MismatchedMediaDescriptor
@@ -83,6 +84,8 @@
8384
Caption = "Disk - Custom Format"
8485
Case FilterTypes.Disk_NOBPB
8586
Caption = "Disk - No BPB"
87+
Case FilterTypes.Disk_NoBootLoader
88+
Caption = "Disk - No Boot Loader"
8689
Case FilterTypes.DIsk_CustomBootLoader
8790
Caption = "Disk - Custom Boot Loader"
8891
Case FilterTypes.Disk_MismatchedImageSize

DiskImageTool/FloppyDB.vb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ Public Class FloppyDB
103103
End If
104104
End Function
105105

106+
Public Function IsVerifiedImage(Disk As Disk) As Boolean
107+
Dim Result = TitleFind(Disk)
108+
If Result.TitleData IsNot Nothing Then
109+
If Result.TitleData.GetStatus = FloppyDBStatus.Verified Then
110+
Return True
111+
End If
112+
End If
113+
114+
Return False
115+
End Function
116+
106117
Public Function TitleCount() As Integer
107118
Return _TitleDictionary.Count
108119
End Function

DiskImageTool/Forms/BootSectorForm.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ Public Class BootSectorForm
243243
ElseIf Control Is TxtHiddenSectors Then
244244
Return Control.Text = "0"
245245
ElseIf Control Is HexJumpInstruction Then
246-
Return BootSector.CheckJumpInstruction(HexJumpInstruction.GetHex, True)
246+
Return BootSector.CheckJumpInstruction(HexJumpInstruction.GetHex, True, True)
247247
Else
248248
Return True
249249
End If
@@ -281,7 +281,7 @@ Public Class BootSectorForm
281281
End If
282282
HexBox1.Height = LineCount * 13 + 4
283283

284-
If BootSector.HasValidJumpInstruction(False) Then
284+
If BootSector.CheckJumpInstruction(False, True) Then
285285
If BootStrapStart >= DataStart Then
286286
Dim Start = BootStrapStart - DataStart
287287
HexBox1.Highlight(Start, DataLength - Start, Color.Green, Color.White)

DiskImageTool/Forms/ImageLoadForm.Designer.vb

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DiskImageTool/Forms/ImageLoadForm.vb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Public Class ImageLoadForm
1010
Private ReadOnly _FileFilterExt As List(Of String)
1111
Private ReadOnly _Files() As String
1212
Private ReadOnly _LoadedFileNames As Dictionary(Of String, LoadedImageData)
13-
Private ReadOnly _LoadedImages As List(Of LoadedImageData)
1413
Private ReadOnly _Parent As MainForm
1514
Private _Activated As Boolean = False
1615
Private _Counter As Integer = 0
16+
Private _ImageCount As Integer = 0
1717
Private _EndScan As Boolean = False
1818
Private _SelectedImageData As LoadedImageData = Nothing
1919
Private _Visible As Boolean = False
@@ -29,15 +29,8 @@ Public Class ImageLoadForm
2929
_LoadedFileNames = LoadedFileNames
3030
_FileFilterExt = FileFilterExt
3131
_ArchiveFilterExt = ArchiveFilterExt
32-
_LoadedImages = New List(Of LoadedImageData)
3332
End Sub
3433

35-
Public ReadOnly Property LoadedImages As List(Of LoadedImageData)
36-
Get
37-
Return _LoadedImages
38-
End Get
39-
End Property
40-
4134
Public ReadOnly Property SelectedImageData As LoadedImageData
4235
Get
4336
Return _SelectedImageData
@@ -169,8 +162,12 @@ Public Class ImageLoadForm
169162
End If
170163
If _Counter Mod 10 = 0 Then
171164
LblScanning.Text = "Scanning... " & _Counter & " files"
165+
lblScanning2.Text = _ImageCount & " images loaded"
166+
LblScanning.Refresh()
167+
lblScanning2.Refresh()
172168
End If
173169
ElseIf e.ProgressPercentage = 2 Then
170+
_ImageCount += 1
174171
Dim ImageData As LoadedImageData = e.UserState
175172
_Parent.ComboImages.Items.Add(ImageData)
176173
End If

DiskImageTool/HexView/HexViews.vb

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,39 +107,45 @@ Module HexViews
107107
Dim BootStrapLength = BootSectorOffsets.BootStrapSignature - BootStrapStart
108108

109109
Dim ForeColor As Color
110-
If Disk.BootSector.HasValidJumpInstruction(False) Then
110+
If Disk.BootSector.CheckJumpInstruction(False, True) Then
111111
ForeColor = Color.Green
112112
Else
113113
ForeColor = Color.Black
114114
End If
115115

116116
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.JmpBoot, ForeColor)
117117
If Disk.IsValidImage Then
118-
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.OEMName, Color.Red)
119-
HighlightedRegions.AddBPBoffset(BPBOoffsets.BytesPerSector, Color.Blue)
120-
HighlightedRegions.AddBPBoffset(BPBOoffsets.SectorsPerCluster, Color.Blue)
121-
HighlightedRegions.AddBPBoffset(BPBOoffsets.ReservedSectorCount, Color.Blue)
122-
HighlightedRegions.AddBPBoffset(BPBOoffsets.NumberOfFATs, Color.Blue)
123-
HighlightedRegions.AddBPBoffset(BPBOoffsets.RootEntryCount, Color.Blue)
124-
HighlightedRegions.AddBPBoffset(BPBOoffsets.SectorCountSmall, Color.Blue)
125-
HighlightedRegions.AddBPBoffset(BPBOoffsets.MediaDescriptor, Color.Blue)
126-
HighlightedRegions.AddBPBoffset(BPBOoffsets.SectorsPerFAT, Color.Blue)
127-
HighlightedRegions.AddBPBoffset(BPBOoffsets.SectorsPerTrack, Color.Blue)
128-
HighlightedRegions.AddBPBoffset(BPBOoffsets.NumberOfHeads, Color.Blue)
129-
HighlightedRegions.AddBPBoffset(BPBOoffsets.HiddenSectors, Color.Blue)
130-
131-
If Disk.BootSector.HasValidExtendedBootSignature And BootStrapStart >= BootSectorOffsets.FileSystemType + BootSectorSizes.FileSystemType Then
132-
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.DriveNumber, Color.Purple)
133-
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.Reserved, Color.Purple)
134-
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.ExtendedBootSignature, Color.Purple)
135-
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.VolumeSerialNumber, Color.Purple)
136-
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.VolumeLabel, Color.Purple)
137-
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.FileSystemType, Color.Purple)
118+
If Disk.BootSector.CheckJumpInstruction(False) AndAlso Disk.BootSector.BPB.IsValid Then
119+
If BootStrapStart < 3 Or BootStrapStart >= BootSectorOffsets.OEMName + BootSectorSizes.OEMName Then
120+
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.OEMName, Color.Red)
121+
End If
122+
If BootStrapStart < 3 Or BootStrapStart >= BPBOoffsets.HiddenSectors + BPBSizes.HiddenSectors Then
123+
HighlightedRegions.AddBPBoffset(BPBOoffsets.BytesPerSector, Color.Blue)
124+
HighlightedRegions.AddBPBoffset(BPBOoffsets.SectorsPerCluster, Color.Blue)
125+
HighlightedRegions.AddBPBoffset(BPBOoffsets.ReservedSectorCount, Color.Blue)
126+
HighlightedRegions.AddBPBoffset(BPBOoffsets.NumberOfFATs, Color.Blue)
127+
HighlightedRegions.AddBPBoffset(BPBOoffsets.RootEntryCount, Color.Blue)
128+
HighlightedRegions.AddBPBoffset(BPBOoffsets.SectorCountSmall, Color.Blue)
129+
HighlightedRegions.AddBPBoffset(BPBOoffsets.MediaDescriptor, Color.Blue)
130+
HighlightedRegions.AddBPBoffset(BPBOoffsets.SectorsPerFAT, Color.Blue)
131+
HighlightedRegions.AddBPBoffset(BPBOoffsets.SectorsPerTrack, Color.Blue)
132+
HighlightedRegions.AddBPBoffset(BPBOoffsets.NumberOfHeads, Color.Blue)
133+
HighlightedRegions.AddBPBoffset(BPBOoffsets.HiddenSectors, Color.Blue)
134+
End If
135+
136+
If Disk.BootSector.HasValidExtendedBootSignature And BootStrapStart >= BootSectorOffsets.FileSystemType + BootSectorSizes.FileSystemType Then
137+
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.DriveNumber, Color.Purple)
138+
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.Reserved, Color.Purple)
139+
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.ExtendedBootSignature, Color.Purple)
140+
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.VolumeSerialNumber, Color.Purple)
141+
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.VolumeLabel, Color.Purple)
142+
HighlightedRegions.AddBootSectorOffset(BootSectorOffsets.FileSystemType, Color.Purple)
143+
End If
138144
End If
139145
End If
140146

141147
If BootStrapStart > 2 And BootStrapLength > 1 Then
142-
If Disk.BootSector.HasValidJumpInstruction(False) Then
148+
If Disk.BootSector.CheckJumpInstruction(False, True) Then
143149
HighlightedRegions.AddItem(BootStrapStart, BootStrapLength, ForeColor, "Boot Strap Code")
144150
Else
145151
HighlightedRegions.AddItem(BootStrapStart, BootStrapLength, ForeColor)

0 commit comments

Comments
 (0)