Originally Posted by
mwardy:
“A start on a cunning plan would be if someone could figure out why the junk stripper from jack plug runnable in Excel (post 40, and modified for general use by grahamlthompson in post 67) gets kicked out of a HD recording at the point where encryption seems to assert itself (post 69 from son_t). It's such a simple program this seems like spectacular behaviour.
”
THe following code dumps the last blocks of data (in decimal) junk to col 1 and a to col 2 of worksheet 1. Note I got the nos of bytes wrong in my initial post (forgot VB arrays start at zero). On a SD file the data is all zeros
Public Sub trimTS()
' Dim object to store data
Dim DestSheet As Object
Set DestSheet = Sheets(1)
' Dim Row counter
Dim rowcounter As Integer
rc = 1
' erase contents of sheet 1)
With DestSheet
.Cells.ClearContents
End With
' Dim Loop Counter
Dim LC As Integer
' Dimension array variable junk to hold 4 bytes
Dim junk(3) As Byte
' Dim array variable a to hold 188 bytes
Dim a(187) As Byte
' Dim Single Byte Constant as 47Hex
Const sync_byte As Byte = &H47
' note this declares variable fni and fno out as a variant will work but Dim fni as string, fno as string is more efficient
Dim fni As String, fno As String
fni = Application.GetOpenFilename(, , "File To Open")
fno = Application.GetSaveAsFilename(, , , "File Name To Save")
' open source file to read byte by byte as file 1
Open fni For Binary Access Read As #1
' open destination file to write byte by byte as file 2
Open fno For Binary Access Write As #2
' read first 4 bytes from source file - forgot 0 element
Get #1, , junk
' read next 188 bytes from source file
Get #1, , a
'MsgBox a(0)
' continue until first byte in 188 byte block is not 47Hex
While a(0) = sync_byte
' write 187 byte block to output file
Put #2, , a
' read next 3 bytes from source
Get #1, , junk
' read next 187 bytes from source
Get #1, , a
' loop back to while statement
Wend
' close both source and destination files
Close
' dump the contents of junk and a to sheet 1
For LC = 0 To 3
DestSheet.Cells(rc, 1) = junk(LC)
rc = rc + 1
Next
rc = 1
For LC = 0 To 187
DestSheet.Cells(rc, 2) = a(LC)
rc = rc + 1
Next
End Sub