Also diese Version scheint tatsächlich zu funktionieren , ihr müsst lediglich beachten , das es nur mit Windows Forms Anwendungen funktioniert. Und ihr müsst die Besagte Ressource als "Eingebettete Ressource" festlegen , dann sollte es Problemlos Funktionieren.

Autor:
DeathAdder

Quelle:
HackHound.org

Benötigte Namensräume:

Code:
Imports System
Imports System.Windows.Forms
Imports System.Reflection
Imports System.IO
Imports System.Runtime.CompilerServices
QuellCode:
Code:
Private Function ReadExeFromFile(ByVal filename As String) As Byte()
        Dim fs As New FileStream(filename, FileMode.Open, FileAccess.Read)
        Dim exeData As Byte() = New Byte(fs.Length - 1) {}
        fs.Read(exeData, 0, System.Convert.ToInt32(fs.Length))
        fs.Close()
        Return exeData
    End Function

    Private Function ReadExeFromResources(ByVal filename As String) As Byte()
        Dim CurrentAssembly As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly()
        Dim Resource As String = String.Empty
        Dim ArrResources As String() = CurrentAssembly.GetManifestResourceNames()
        For Each Resource In ArrResources
            If Resource.IndexOf(filename) > -1 Then _
                Exit For
        Next
        Dim ResourceStream As IO.Stream = CurrentAssembly.GetManifestResourceStream(Resource)
        If ResourceStream Is Nothing Then
            Return Nothing
        End If
        Dim ResourcesBuffer(CInt(ResourceStream.Length) - 1) As Byte
        ResourceStream.Read(ResourcesBuffer, 0, ResourcesBuffer.Length)
        ResourceStream.Close()
        Return ResourcesBuffer
    End Function

    Private Function StringToByteArray(ByVal str As String) As Byte()
        Dim encoding As New System.Text.ASCIIEncoding()
        Return encoding.GetBytes(str)
    End Function

    Private Sub RunFromMemory(ByVal bytes As Byte())
        Dim assembly As Assembly = assembly.Load(bytes)
        Dim entryPoint As MethodInfo = [assembly].EntryPoint
        Dim objectValue As Object = RuntimeHelpers.GetObjectValue([assembly].CreateInstance(entryPoint.Name))
        entryPoint.Invoke(RuntimeHelpers.GetObjectValue(objectValue), New Object() {New String() {"1"}})
    End Sub
Aufruf:
Code:
Dim x As New Threading.Thread(AddressOf RunFromMemory)
x.Start(ReadExeFromResources("EmbeddedExe.exe"))
MfG , Sawyer