 |
|
 |
it use it to run a vb.net(2008) exe . it Will Receive a error.
the MethodInfo is:"method = {Void Main(System.String[])}"
no like Example programme:"method = {Void Main()}"
if i Modify my vb.net programme to use sub main,it will be OK.
but new Problem is : the vb.net programme can't be us the "My" Namespace.
and,i'am sorry of my Terrible english.
thank's!
|
|
|
|
 |
|
 |
This is posible to implement in vb6?
It can be posible, with this method, load in memory Third party applications or may be builded in special form to run only in memory?
|
|
|
|
 |
|
 |
//NOTE: You have to invoke it on a newly created thread.
MethodInfo method;
private void Form1_Load(object sender, EventArgs e)
{
System.Threading.Thread thd;
System.Threading.ThreadStart ts;
Assembly a = Assembly.Load(LoadEXE()); //load exe into byte array
method = a.EntryPoint;
ts = new System.Threading.ThreadStart(RunNewApp);
thd = new System.Threading.Thread(ts);
thd.Start();
}
private void RunNewApp()
{
if (method != null)
{
method.Invoke(null, null);
}
}
|
|
|
|
 |
|
 |
can this be done in java ?
|
|
|
|
 |
|
 |
//this loads a jar from an http address and instantiates the class 'classname'
//just put some code in the constructor of the class if you want to execute it
//when it's instantiated
public void RunClass(String httpfileaddr, String classname) {
URLClassLoader clazzLoader ;
Class clazz = null;
URL url = null;
try {
url = new URL(httpfileaddr);
} catch (MalformedURLException ex) {
Logger.getLogger(cLoader.class.getName()).log(Level.SEVERE, null, ex);
}
clazzLoader = new URLClassLoader(new URL[]{url});
try {
clazz = clazzLoader.loadClass(classname);
Thread.currentThread().setContextClassLoader(clazzLoader);
} catch (ClassNotFoundException ex) {
Logger.getLogger(cLoader.class.getName()).log(Level.SEVERE, null, ex);
}
try {
clazz.newInstance();
} catch (InstantiationException ex) {
Logger.getLogger(cLoader.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(cLoader.class.getName()).log(Level.SEVERE, null, ex);
}
}
|
|
|
|
 |
|
 |
I modified the code a bit to look into a different directory and pick out my .exe, but I'm getting an error that says:
"Could not load file or assembly '589312 bytes loaded from WinLauncher, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."
The posted code works with the included .exe and some other .exe that I have, so why would it bomb out on another .exe? Maybe .DLL files need to be loaded into memory as well? if so, how would i do this?
EDIT: i think this has to do with my executable being unmanaged code. is there another way to load unmanaged executables?
modified on Thursday, July 31, 2008 5:26 PM
|
|
|
|
 |
|
 |
Once the program is loaded into memory and is running you can delete the EXE or remove the media with no problem. Don't you remember shuffling floppies under DOS?
I even tested it with a .net program today.
This looks like the wrong solution to a non-existent problem.
|
|
|
|
 |
|
 |
This is EXTREMELY useful.
Just think: Load the target EXE into a byte array. Then encrypt it with System.Security.Cryptography.Rijndaelmanaged using a sha256 of the password as key, and then convert the encrypted EXE to a base64 string.
Then you can make a new project, hard code the base64 string and have a password promt. Then the password decrypt the EXE, and run it from memory as described here. Everything is done in a Try...Catch...End Try block so if wrong password is supplied then it can "MsgBox" the user about it.
This can also be used to build a Anti-Piracy wrapper for a application by encrypting it with a key that is a result from a calculation on a valid CD-key. Incorrect CD-key = the application wont decrypt.
Also you can use this to fetch a encrypted EXE from a server and then decrypt it in-memory with a hard-coded key. Now updating has never been as easy as putting your updated EXE into your webspace and Voilá, the application is up2date for everyone that has previously downloaded your application.
This could also be used in Anti-Piracy situations, by just having a CGI script to encrypt your EXE with the supplied serial number as key, and then the target application who downloaded the encrypted EXE decryptes it using the serial as key.
Of course you have a hard coded "salt" value in the application so not anybody with the correct serial can decrypt for themselves.
Then if you see that a specific serial is used at multiple places, just ban that serial and your application can never be used by that serial any longer, since the client application can no longer download the encrypted EXE.
Another fun thing you can do if you let your client fetch the EXE from the internet, is that if the serial in question is marked as piracy, you could make your server send a encrypted variant of some software that install itself in startup and keylog, screenlog, and records sound from attached mic and take some snaps if theres a webcam. Then stuff everything in a packet and then into your server, that will log IP & time too.
Its s simple matter of prosecuting that person for piracy after that, since you both have IP evidence and *image evidence*.
|
|
|
|
 |
|
 |
How can I load cmd.exe file and pass the "dir/p" as a argument? And after that I need to track the output.
|
|
|
|
 |
|
 |
ur code is amazing and i downloaded ur program and it worked well but when i tried to create my own program that run exe file it gave me the error that u said in ur note could u help me to prevent this error plz (
Best Wishes
|
|
|
|
 |
|
 |
not an author, but...
acutally, i use boxedapp to launch my exe secure, it can run any EXE (not only .net) from memory without additional temporary files on disk.
btw it also provide a simple function specific for .net (C++ / Delphi notation!):
execute .net from memory
|
|
|
|
 |
|
 |
Hi Evereyone,
"Load an exe file and run it from memory" forum's decision by Mr.Gianni Marzaloni (ZofM) is looking nice. Could you make it in VB, please?
Thanx,
Ulambayar
|
|
|
|
 |
|
 |
I have the same problem too. I need the answer. How to write that in VB .Net? I am looking around and the best I got was this:
http://www.thescripts.com/forum/thread363965.html[^]
using Reflection.Assembly.GetExecutingAssembly().GetMani festResourceStream("")
but I can't get it working. Please Help.
Ash
|
|
|
|
 |
|
 |
try changing
using Reflection.Assembly.GetExecutingAssembly().GetMani festResourceStream("")
to
using Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("")
|
|
|
|
 |
|
 |
Here is the code which works in VB 2005.
Dim fs As New IO.FileStream("C:\\MyFile.exe", IO.FileMode.Open, IO.FileAccess.Read)
Dim br As BinaryReader = New BinaryReader(fs)
Dim bin As Byte() = br.ReadBytes(Convert.ToInt32(fs.Length))
fs.Close()
br.Close()
Dim a As Assembly = Assembly.Load(bin)
Dim method As MethodInfo = a.EntryPoint
Dim o As Object = a.CreateInstance(method.Name)
method.Invoke(o, New Object() {Nothing})
But, unfortunately, I always got error about “Application.SetCompatibleTextRenderingDefault”
Does anybody have idea what to do about how to overcome this ?
|
|
|
|
 |
|
 |
Hello! Nice code! I tried a small demo-project, and it shows up that the .exe is only started, when it has been compiled with /clr:pure or /clr:save. When using an .exe compiled with /clr only, I got an exception in Assembly.Load: Unverifiable code failed policy check (exception from HRESULT: 0x80131402).
Has anyone a solution for this or is it just not possible to load an assembly compiled with /clr?
|
|
|
|
 |
|
 |
Hi Everyone,
I want to know how to execute a resource of type (.exe file) directly from within my VB application without having to create a .exe file. I mean, running the .exe (resource) directing into memory so that, the file isn't visible to anyone.
Thanks in advance.
Bye!
|
|
|
|
 |
|
|
 |
|
 |
Hi Rahul,
If you have solution for that question, share it with me, please?
Thanx,
Ulambayar
|
|
|
|
 |
|
|
 |
|
 |
check boxedapp sdk , it supports starting a process from a memory block.
|
|
|
|
 |
|
 |
These methods don't work with all exe files.
Some unmanaged compilations can't be loaded by assembly
|
|
|
|
 |
|
 |
Yes, because this approach using .net feature to load assembly. To load native EXE files or mixed-mode assemblies it's possible to use boxedapp sdk. But I still can't understand how does they doing this?...
thnx.
|
|
|
|
 |
|
 |
I'm wondering how we can use this technique. One use case could be that we load the EXE into the memory and delete it from the HDD. After we finish the run, copy it back to the HDD. This way we can ensure a single instance of the application across the network (if we map network drives).
- It's easier to make than to correct a mistake.
|
|
|
|
 |
|
 |
This will not work for mixed-mode MC++ assemblies. Instead you will get some wacko COM exception with no idea what went wrong.
It's the same reason why mixed-mode MC++ assemblies with controls cant be used on the designer surface.
|
|
|
|
 |