- ' 1 Boite de texte = > txtFile
- ' 1 Boutton commande = > CmdLoad
- ' 1 Boite de texte = > txtHex 'avec multiline = true et scrollbar = vertical
- ' 1 Boite de texte = > txtBin 'avec multiline = true et scrollbar = vertical
-
- Private Sub cmdLoad_Click()
- If Dir$(txtFile.Text) = "" Then MsgBox "Fichier inconnu": Exit Sub
- txtHex.Text = ""
- txtBin.Text = ""
- Dim aText As String, b$, t$, h$, k As Long, i As Long, j As Long, l As Long
- Open txtFile.Text For Binary As 1
- If LOF(1) > 20& * 1024& Then
- If MsgBox("Le fichier sera peut-être trop gros pour pouvoir être décompiler par votre disque dur (suivant votre processeur et RAM), voulez-vous continuer ?", vbYesNo) = vbNo Then Close 1: Exit Sub
- End If
- aText = Space$(LOF(1))
- Get 1, , aText
- Close 1
- For k = 1 To Len(aText) + 16 - (Len(aText) Mod 16) Step 16
- txtHex.SelStart = Len(txtHex.Text)
- txtBin.SelStart = Len(txtBin.Text)
- If k > 1 Then
- txtHex.SelText = vbCrLf
- txtHex.SelStart = Len(txtHex.Text)
- txtBin.SelText = vbCrLf
- txtBin.SelStart = Len(txtBin.Text)
- End If
- t$ = Hex$(k - 1): If Len(t$) < 4 Then t$ = String$(4 - Len(t$), "0") & t$
- t$ = t$ & " "
- For i = k To k + 15
- h$ = "00"
- If i <= Len(aText) Then
- j = Asc(Mid$(aText, i, 1))
- h$ = Hex$(j)
- If Len(h$) < 2 Then h$ = "0" & h$
- End If
- t$ = t$ & " " & h$
- Next
- txtHex.SelText = t$
- t$ = ""
- For i = k To k + 15
- b$ = "00000000"
- If i <= Len(aText) Then
- b$ = ""
- j = Asc(Mid$(aText, i, 1))
- For l = 0 To 7
- If (2 ^ l) And j Then b$ = "1" & b$ Else b$ = "0" & b$
- Next
- End If
- t$ = t$ & " " & b$
- Next
- txtBin.SelText = t$
- Next
- End Sub
' 1 Boite de texte = > txtFile
' 1 Boutton commande = > CmdLoad
' 1 Boite de texte = > txtHex 'avec multiline = true et scrollbar = vertical
' 1 Boite de texte = > txtBin 'avec multiline = true et scrollbar = vertical
Private Sub cmdLoad_Click()
If Dir$(txtFile.Text) = "" Then MsgBox "Fichier inconnu": Exit Sub
txtHex.Text = ""
txtBin.Text = ""
Dim aText As String, b$, t$, h$, k As Long, i As Long, j As Long, l As Long
Open txtFile.Text For Binary As 1
If LOF(1) > 20& * 1024& Then
If MsgBox("Le fichier sera peut-être trop gros pour pouvoir être décompiler par votre disque dur (suivant votre processeur et RAM), voulez-vous continuer ?", vbYesNo) = vbNo Then Close 1: Exit Sub
End If
aText = Space$(LOF(1))
Get 1, , aText
Close 1
For k = 1 To Len(aText) + 16 - (Len(aText) Mod 16) Step 16
txtHex.SelStart = Len(txtHex.Text)
txtBin.SelStart = Len(txtBin.Text)
If k > 1 Then
txtHex.SelText = vbCrLf
txtHex.SelStart = Len(txtHex.Text)
txtBin.SelText = vbCrLf
txtBin.SelStart = Len(txtBin.Text)
End If
t$ = Hex$(k - 1): If Len(t$) < 4 Then t$ = String$(4 - Len(t$), "0") & t$
t$ = t$ & " "
For i = k To k + 15
h$ = "00"
If i <= Len(aText) Then
j = Asc(Mid$(aText, i, 1))
h$ = Hex$(j)
If Len(h$) < 2 Then h$ = "0" & h$
End If
t$ = t$ & " " & h$
Next
txtHex.SelText = t$
t$ = ""
For i = k To k + 15
b$ = "00000000"
If i <= Len(aText) Then
b$ = ""
j = Asc(Mid$(aText, i, 1))
For l = 0 To 7
If (2 ^ l) And j Then b$ = "1" & b$ Else b$ = "0" & b$
Next
End If
t$ = t$ & " " & b$
Next
txtBin.SelText = t$
Next
End Sub