Search Tools Links Login

Strip out Strings of exe files


This is a small little bit code that will rip out all the string in a file. Start a new program and place this code in to the General Declarations select of the Form. Also you will need to add a command button to the form as well. Then press F5.

Module

Public Sub sDumpStrings(strFile As String, strTextFile As String, intMinSize As Integer)
    
    If Len(Dir(strFile)) = 0 Then Exit Sub
    Dim b() As Byte
    Dim hFile As Integer
    Dim bIsString As Boolean
    Dim i As Long
    Dim lngLen As Long
    Dim strLine As String
    Const strCompare = "[A-Z a-z 0-9,.!?@#$%]"
    hFile = FreeFile
    Open strFile For Binary As #hFile
    lngLen = LOF(hFile)
    ReDim b(1 To lngLen)
    Get #hFile, , b
    Close #hFile
    
    hFile = FreeFile
    Open strTextFile For Output As #hFile
    
    For i = 1 To lngLen
        If Chr(b(i)) Like strCompare Then
            If Chr(b(i + 1)) Like strCompare Then
                strLine = strLine & Chr(b(i))
            ElseIf i > 1 Then
                If Chr(b(i - 1)) Like strCompare Then
                    strLine = strLine & Chr(b(i))
                    If Len(strLine) > intMinSize Then
                        Print #hFile, strLine
                        Debug.Print strLine
                    End If
                    strLine = ""
                End If
            End If
        End If
    Next

    Close #hFile
    MsgBox "All done", vbInformation
    
End Sub

Usage

Private Sub Command1_Click()
    sDumpStrings "C:\Windows\Notepad.exe", "C:\Notepad.txt", 15
    ' Change the filename if you like
    
End Sub

Private Sub Form_Load()
    Command1.Caption = "Strip out Strings"
    
End Sub

About this post

Posted: 2019-09-27
By: BenJones
Viewed: 291 times

Categories

Visual Basic 6

Attachments

No attachments for this post

Special Instructions

This code originally appeared on AndreaVB.com, and has been republished here with the permission of Andrea Tincani.


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.