8

Resource files (.RES) accept any kind of binary files but if it is an exe file how can I run it?

3
  • 4
    A lot of malware does it. What is your reason to work that way insted of using the polite way of an installer/uninstaller? When your software runs on someone's else machine, it should be well-behaved. Commented May 23, 2011 at 7:24
  • Interesting observation... what happened to the OP? Commented May 24, 2011 at 2:10
  • I would use it to extract a app updater to update my application from a remote server, then the new application would delete it the next execution. Commented Aug 22, 2013 at 20:19

4 Answers 4

12

You would have to extract it as a file to disk and execute it.

Although you don't have to extract it to disk, as Cosmin Prund says in a comment, if you don't it requires a lot of hard work.

Sign up to request clarification or add additional context in comments.

4 Comments

+1 At least this is by far the simplest and most obvious solution.
One must remember, however, not to extract the file to the same directory as the current application, because the latter most likely resides in the read-only Program Files folder. Instead, one should use the current user's temporary directory.
You don't have to extract it to disk. It's just that not extracting it to disk requires lots of hard work and the use of undocumented Windows functionality.
One must remember if you extract it to the user's temp directory that another session could be sharing the same temp directory (Terminal Services) - be use to use a unique name.
6

http://sites.google.com/site/delphibasics/home/delphibasicssnippets/memoryexecutionunit-winxpwinvistawin7

Take a look at this memory execution unit.It allows you to execute an exe from memory without dumping it on disk.

3 Comments

The link is just a great solution and it can be easily changed to work with resources. Take a look at TResourceStream (delphidabbler.com/articles?article=3) and you will only need to change the FileToBytes function (probably rename it too so the name suggests its purpose, maybe ResourceToBytes?).
Can I execute 32 bit exe file in memory by using an 64 bit application? Is it possible with the routine above?
Tried uExecFromMem and works excellent AFTER switch off virus warning "Virtool:Win32/DelfInject.gen!BI" for the compiled version of this code. I'm afraid this can't be used in genuine programs, that's sad :-(
1

Yes it is possible. There is a Delphi library to do this somewhere on the web, but I cannot for the life of me remember what it's called. It allows you to execute a normal exe file no-matter where it is in memory. So you can load it into a stream, or just embed it in a resource.

I realize that my reply is a bit depressing since i dont remember the name of the library, but at least you now know that it can be done. If you google around for "execute PE exe from memory" and "Delphi" then I'm sure you will find it.

Comments

0

You might want to take a look at Orean's XBundler: http://www.oreans.com/xbundler.php

I use their licensing product (WinLicense) and have been very happy with the product, their support, responsiveness and updates.

In fact, I'm about to buy XBundler so I can ship a dll securely embedded in my exe.

Tom

5 Comments

Whenever a post a link to a commercial product that I use and that is directly relevant to the OP, I get down-voted with no explanation. Perhaps some SO readers are allergic to commercial software? (If I were king of SO, I'd prohibit downvotes without an explanation... but that's a topic for another day...)
I definitely agree with the sentiment about -1 votes without explanation; your post (and other posts) don't really look like the work of our usual spam-artists :) but this specific post could definitely use some copy-and-paste examples on how to call the exe once bundled, or some other indication that you've successfully used their product for just this reason. (Or, perhaps, some reason why it is a difficult enough problem to justify a commercial program.) I'm just saying that the bar for links to commercial software is much higher than most other posts...
+1 Good suggestion, sarnold. I hadn't thought of that. I'll include examples in future posts of this kind of thing. Thank you.
Broken link.........
Yes, no surprise that the link is still broken, 13 years later! Try Googling it. The first result is this: oreans.com/help/tm/hm_xbundler.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.