Well so far, no one has actually provided me with any help so I turned to the vb forums to see if anyone could help out here.

I'm in the process of writing a crypter for personal and learning reasons.

Essentially what it does, is takes the bytes of the .exe files, encrypts them using encryption methods, and then creates a new .exe file and writes all the bytes.

The problem I'm having is once the file is written, the .exe doesn't open. I think this is because all of the bytes aren't being written for some reason, help would be appreciated!

When I open the .exe in notepad++, all the bytes from the first file are NOT in the second file, only some which is why I think it's corrupting. Plus the file size isn't the same.

Here's the basis of what I have
Code:
    Public Shared Function forD24(ByVal input As Byte()) As String
        Dim out As New System.Text.StringBuilder 
        ' Dim base64data As String = Convert.ToBase64String(input)
        Dim base64data As String = input.ToString()
        Dim arr As String() = Split0923(base64data, 100) 
        For i As Integer = 0 To arr.Length - 1 
            If i = arr.Length - 1 Then  
                out.Append(Chr(34) & arr(i) & Chr(34))
            Else 'I is smaller than arr.Length - 1 (i < arr.Length - 1)
                out.Append(Chr(34) & arr(i) & Chr(34) & " & _" & vbNewLine)
            End If
        Next
        Return out.ToString
    End Function
Code:
    Private Sub dat(ByVal dat As Byte())
        Dim bit As [Byte]() = dat
        KP.Write(bit, 0, bit.Length) 'Writes file bytes to mem stream (NOT WORKING)
    End Sub

       Dim q As Byte() = IO.File.ReadAllBytes(showDir.Text) 'File to encrypt
        dat(q)
        Dim bit(KP.Length) As Byte
        Dim data As [Byte]() = bit
        data = New [Byte](256) {}
        Dim bytes As Int32 = KP.Read(data, 0, data.Length)
        Dim responseData As [String] = [String].Empty
        responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)
        MsgBox("This:" & responseData) 'DOESNT PRINT ANYTHING
        ' Dim input As Byte() = ECT.RijEC(q) 'Encryption
        Dim input As Byte() = q 'Forget encryption for now, I can't even write all the bytes properly...
        src = src.Replace("%3%", IK93.forD24(input)) 'Formating the bytes to string

        GE.GEN_EX(stub_OUT & "12345", src, ICON_PATH) 'Generates the .exe file