 |
|
|
 |
|
|
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
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.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
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*.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
How can I load cmd.exe file and pass the "dir/p" as a argument? And after that I need to track the output.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
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
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
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
|
| Sign In·View Thread·PermaLink | 2.67/5 (3 votes) |
|
|
|
 |
|
|
 |
|
|
try changing using Reflection.Assembly.GetExecutingAssembly().GetMani festResourceStream("") to using Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("")
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
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 ?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
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?
|
| Sign In·View Thread·PermaLink | 1.33/5 (2 votes) |
|
|
|
 |
|
|
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!
|
| Sign In·View Thread·PermaLink | 2.33/5 (3 votes) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
These methods don't work with all exe files. Some unmanaged compilations can't be loaded by assembly
|
| Sign In·View Thread·PermaLink | 5.00/5 (2 votes) |
|
|
|
 |
|
|
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.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
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.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi,
// create an istance of the Startup form Main method object o = a.CreateInstance(method.Name); doesn't seem to make any sense to try to create an instance from a method. o will always be null. As the entry point method is always static you can just call Invoke without any instance:
method.Invoke(null, null);
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
I think that without creating assembly instance you can't invoke any method inside that assembly.
Greatings,
Preky
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Preky wrote: I think that without creating assembly instance you can't invoke any method inside that assembly.
Unless it's static.
___________________________________ Tozzi is right: Gaia is getting rid of us. My Blog [ITA]
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Yes of course. But loading assembly doesn't make it static or does it? Can you provide snippet where you don't need make call to CreateInstance and can Invoke method... I haven't been working with reflection so much so I'm interested in your statment as signature of Invoke is
[C#] public object Invoke(object, object[]);
Greatings,
Preky
-- modified at 5:09 Tuesday 25th April, 2006
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I meant, when the method you need to invoke is static (or Shared in VB) you don't need to create an instance of the class. You may use the Invoke method to call it.
Maybe you can try and post the results. 
___________________________________ Tozzi is right: Gaia is getting rid of us. My Blog [ITA]
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Ok, now I have figured out what you were targeting 
I have to admit I don't recall callling static method from assembly with reflection but what you should send to Invoke signature as obj param (The instance that created this method.)?
Greatings,
Preky
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Preky wrote: what you should send to Invoke signature as obj param (The instance that created this method.)?
Don't know. Here you are the expert guy.
___________________________________ Tozzi is right: Gaia is getting rid of us. My Blog [ITA]
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
OK. The answer is simple (I haven't stated that I am, in any way - the irony of your reply is telling me you have misunderstood me but never mind )
Before calling static method I think IsStatic should be called and obj param of Invoke should be null. I found it but didn't try it out.
MethodInfo method = a.EntryPoint; if (method != null && method.IsStatic) { // invoke the application starting point method.Invoke(null, null);
Hope this helps.
Greatings,
Preky
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |