Public Class Main #Region " Declarations " Private Const _PAGE_SIZE As Integer = 16384 #End Region #Region " Public Methods " Public Shared Sub Main(ByVal args() As String) Try If args.Length > 0 Then 'Do command line processing _ExtractBootImage(args(0), args(1)) Else 'Do GUI-based processing Dim ofd As New OpenFileDialog ofd.DefaultExt = "73V" ofd.CheckFileExists = True ofd.CheckPathExists = True ofd.Filter = "TI-73 Explorer AppVars (*.73v)|*.73v|All Files (*.*)|*.*" ofd.FilterIndex = 0 ofd.Multiselect = False ofd.Title = "Select TI-73 Explorer AppVar" If ofd.ShowDialog() = DialogResult.OK Then Dim sfd As New SaveFileDialog sfd.Filter = "Binary Image (*.bin)|*.bin|All Files (*.*)|*.*" sfd.FilterIndex = 0 sfd.Title = "Enter Location to Save Binary Image" If sfd.ShowDialog() = DialogResult.OK Then _ExtractBootImage(ofd.FileName, sfd.FileName) End If End If End If Catch ex As Exception MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub #End Region #Region " Private Methods " Private Shared Sub _ExtractBootImage(ByVal calcPath As String, ByVal binPath As String) Dim calcFile As New IO.FileStream(calcPath, IO.FileMode.Open, IO.FileAccess.Read) Dim buffer() As Byte = New Byte(_PAGE_SIZE) {} calcFile.Seek(&H37, IO.SeekOrigin.Begin) calcFile.Read(buffer, 0, 2) calcFile.Seek(BitConverter.ToInt16(buffer, 0) + 4, IO.SeekOrigin.Current) calcFile.Read(buffer, 0, _PAGE_SIZE) calcFile.Close() Dim binFile As New IO.FileStream(binPath, IO.FileMode.Create) binFile.Write(buffer, 0, _PAGE_SIZE) binFile.Close() End Sub #End Region End Class