7

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.
    – user160694
    May 23, 2011 at 7:24
  • Interesting observation... what happened to the OP?
    – Vector
    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.
    – NaN
    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.

4
  • +1 At least this is by far the simplest and most obvious solution. May 22, 2011 at 19:53
  • 5
    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. May 22, 2011 at 21:49
  • 2
    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. May 23, 2011 at 7:30
  • 1
    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.
    – Ian Boyd
    Jun 18, 2011 at 13:13
5

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
  • 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?).
    – Pateman
    May 23, 2011 at 8:55
  • Can I execute 32 bit exe file in memory by using an 64 bit application? Is it possible with the routine above? Apr 22, 2013 at 9:02
  • 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 :-(
    – Codebeat
    Feb 21, 2015 at 6:02
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.

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

3
  • 2
    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...) May 23, 2011 at 11:15
  • 1
    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...
    – sarnold
    May 24, 2011 at 0:51
  • +1 Good suggestion, sarnold. I hadn't thought of that. I'll include examples in future posts of this kind of thing. Thank you. May 24, 2011 at 18:44

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.