CheapWindowsHosting.com | Run external app directly from RAM. You can load the specific file into a Byte [] Array with a StreamReader () or even download it from WEB via a direct link provided.
The point of this technique is to maintain anonymity to a fragile file, thus leaving no chance to a reverse engineer to crack the details.
Also note, to keep the variables such as the one referencing the MethodInfo()
on a Class
basis. You then should Dispose()
or set to Nothing
these variables at the FormClosing()
Event to prevent memory leak.
Dim method As System.Reflection.MethodInfo
Sub Run
Dim bb() As Byte = IO.File.ReadAllBytes("file.exe")
Try
Dim a As System.Reflection.Assembly = System.Reflection.Assembly.Load(bb)
'or a = Reflection.Assembly.Load(New WebClient().DownloadData("https://...."))
method = a.EntryPoint
If (Not method Is Nothing) Then
Dim o As Object = a.CreateInstance(method.Name)
method.Invoke(o, Nothing)
'if your app receives parameters
'method.Invoke(o, New Object() {New String(){"Hello}})
Else
Throw New NullReferenceException("method is null.")
End If
Catch ex As Exception
MsgBox(ex.Message & vbCrLf & "File length: = " & bb.Length.ToString)
End Try
End Sub
If your app is WinForms and not ConsoleApplication, then follow the steps below:
Your external application needs to start from a Main() Sub
to be compatible with this. Otherwise, change the solution property of your external app:
ApplicationFramework
Module1
)Module1
Module1
Public Sub Main()
Application.Run(New Form1)
'Form1 is your first WinForm that your app displays
End Sub
or if your app receives parameters:
Public Sub Main(ByVal args As String())
Application.Run(New Form1)
'Form1 is your first WinForm that your app displays
End Sub
I hope this post helpful for you 🙂