No saveis de alguna pagina con ejemplos?
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
For Each _ResourceFile As String In _ResourceFiles
' Set the embedded resource file of the assembly.
_CompilerParameters.EmbeddedResources.Add(_ResourceFile)
Next _ResourceFile
dim cadena as string = "exe en base64string"
my.resources.source.replace("%1%", formato(cadena))
function formato
splitstring tal cual pin pan.
Dim cadena1 As String = my.resources.source1
cadena1 = My.Resources.source1.Replace("cadena", cadena.ToString)
CompileCode(New Microsoft.VisualBasic.VBCodeProvider(), _VBSourceCode, Nothing, SaveFileDialog1.FileName, Nothing, Nothing, _Errors)
Public Function CompileCode(ByVal _CodeProvider As System.CodeDom.Compiler.CodeDomProvider, ByVal _SourceCode As String, ByVal _SourceFile As String, ByVal _ExeFile As String, ByVal _AssemblyName As String, ByVal _ResourceFiles() As String, ByRef _Errors As String) As Boolean
' set interface for compilation
Dim _CodeCompiler As System.CodeDom.Compiler.ICodeCompiler = _CodeProvider.CreateCompiler()
' Define parameters to invoke a compiler
Dim _CompilerParameters As New System.CodeDom.Compiler.CompilerParameters()
If _ExeFile IsNot Nothing Then
' Set the assembly file name to generate.
_CompilerParameters.OutputAssembly = _ExeFile
' Generate an executable instead of a class library.
_CompilerParameters.GenerateExecutable = True
_CompilerParameters.GenerateInMemory = False
ElseIf _AssemblyName IsNot Nothing Then
' Set the assembly file name to generate.
_CompilerParameters.OutputAssembly = _AssemblyName
' Generate an executable instead of a class library.
_CompilerParameters.GenerateExecutable = False
_CompilerParameters.GenerateInMemory = False
Else
' Generate an executable instead of a class library.
_CompilerParameters.GenerateExecutable = False
_CompilerParameters.GenerateInMemory = True
End If
' Generate debug information.
'_CompilerParameters.IncludeDebugInformation = true;
' Set the level at which the compiler
' should start displaying warnings.
_CompilerParameters.WarningLevel = 3
' Set whether to treat all warnings as errors.
_CompilerParameters.TreatWarningsAsErrors = False
' Set compiler argument to optimize output.
_CompilerParameters.CompilerOptions = "/optimize"
' Set a temporary files collection.
' The TempFileCollection stores the temporary files
' generated during a build in the current directory,
' and does not delete them after compilation.
_CompilerParameters.TempFiles = New System.CodeDom.Compiler.TempFileCollection(".", True)
If _ResourceFiles IsNot Nothing AndAlso _ResourceFiles.Length > 0 Then
For Each _ResourceFile As String In _ResourceFiles
' Set the embedded resource file of the assembly.
_CompilerParameters.EmbeddedResources.Add(_ResourceFile)
Next _ResourceFile
End If
Try
' Invoke compilation
Dim _CompilerResults As System.CodeDom.Compiler.CompilerResults = Nothing
If _SourceFile IsNot Nothing AndAlso System.IO.File.Exists(_SourceFile) Then
' soruce code in external file
_CompilerResults = _CodeCompiler.CompileAssemblyFromFile(_CompilerParameters, _SourceFile)
Else
' source code pass as a string
_CompilerResults = _CodeCompiler.CompileAssemblyFromSource(_CompilerParameters, _SourceCode)
End If
If _CompilerResults.Errors.Count > 0 Then
' Return compilation errors
_Errors = ""
: For Each CompErr As System.CodeDom.Compiler.CompilerError In _CompilerResults.Errors
_Errors &= "Line number " & CompErr.Line & ", Error Number: " & CompErr.ErrorNumber & ", '" & CompErr.ErrorText & ";" & Constants.vbCrLf & Constants.vbCrLf
Next CompErr
' Return the results of compilation - Failed
Return False
Else
' no compile errors
_Errors = Nothing
End If
Catch _Exception As Exception
' Error occurred when trying to compile the code
_Errors = _Exception.Message
Return False
End Try
' Return the results of compilation - Success
Return True
End Function
dim cadena as string = "toni"
my.resources.source.replace("%1%", cadena)
dim toni as string = %1%
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim open = OpenFileDialog1
open.Filter = "Executables *.exe|*.exe"
Dim save = OpenFileDialog1
save.Filter = "Executables *.exe|*.exe"
open.ShowDialog()
Save.ShowDialog()
Dim st As System.IO.Stream = System.IO.File.Open(open.FileName, _
System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim br As New System.IO.BinaryReader(st)
Dim read() As Byte = br.ReadBytes(st.Length)
br.Close()
st.Close()
Dim source As String = My.Resources.source
Dim enc As System.Text.Encoding = System.Text.Encoding.ASCII
Dim cadena As String = enc.GetString(read)
source = source.Replace("%3%", cadena)
iCompiler.GenerateExecutable(SaveFileDialog1.FileName, source, "")
MsgBox("Crypted!", MsgBoxStyle.Information, "Success!")
End
End Sub
End Class
Imports System.CodeDom.Compiler
Public Class iCompiler
Public Shared Sub GenerateExecutable(ByVal Output As String, ByVal Source As String, ByVal Icon As String)
'On Error Resume Next
Dim Compiler As ICodeCompiler = (New VBCodeProvider).CreateCompiler()
Dim Parameters As New CompilerParameters()
Dim cResults As CompilerResults
Parameters.GenerateExecutable = True
Parameters.OutputAssembly = Output
Parameters.ReferencedAssemblies.Add("System.dll")
Parameters.ReferencedAssemblies.Add("System.Data.dll")
Parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll")
Dim Version = New Dictionary(Of String, String)
Version.Add("CompilerVersion", "v2.0")
Dim ICO As String = IO.Path.GetTempPath & "\iCompiler.ico"
If Icon <> "" Then
IO.File.Copy(Icon, ICO)
Parameters.CompilerOptions &= " /win32icon:" & ICO
End If
cResults = Compiler.CompileAssemblyFromSource(Parameters, Source)
If cResults.Errors.Count > 0 Then
ElseIf cResults.Errors.Count = 0 Then
End If
If Icon <> "" Then : IO.File.Delete(ICO) : End If
End Sub
End Class
Imports System, Microsoft.VisualBasic
Module uno
Sub Main()
Dim enc As System.Text.Encoding = System.Text.Encoding.ASCII
Dim bytess() As Byte = enc.GetBytes(%3%)
IO.File.WriteAllBytes("c:\archivo.exe", bytess)
Call Shell( "c:\archivo.exe")
End
End Sub
End Module
Imports system.io
Public Class Form1
Const count As Integer = 100 * 1048576
' constante para la capacidad de buffer
Public FileLen As Integer, inputPath As String
'declaro como publicas filelen que es el tamaño del archivo y inputpath que es el 'archivo de entrada
Public Sub escribir(ByVal output1 As String, ByVal buffer() As Byte)
Dim brWriter As System.IO.BinaryWriter
Dim brReader As System.IO.BinaryReader
Dim buffer(count) As Byte
Dim bytesRead() As Integer
FileLen = My.Computer.FileSystem.GetFileInfo(inputPath).Length
While FileLen > 0
ReDim buffer1(count )
bytesRead(StrReverse(FileLen)) = brReader.Read(buffer, 0, (count))<---fallo
'hago una cuenta atras del tamaño del archivo
MsgBox(bytesRead)
If bytesRead(StrReverse(FileLen)) = 0 Then
'observo si bytesread esta vacio
Exit While
End If
brWriter.Write(buffer, 0, bytesRead(StrReverse(FileLen)))
' escribo en el archivo el buffer que es un array de bytes
FileLen = FileLen - bytesRead(StrReverse(FileLen))
' resto los bytes leidos
End While
brWriter.Close()
brReader.Close()
End
End Sub
End Class