Unpacking an executable from within a library in C/C++ -


I am developing a library that uses one or more helpful executables while doing business. For my current implementation it is necessary that the user has auxiliary support installed on the system in a useful place. To work properly for the library, the helper app should be in the right place and the correct version should be.

I would like to remove the requirement that the system is configured in the above manner.

Is there a way to bundle executable assistant in the library, it can be unexpected on runtime, can be installed in a temporary directory, and can be used for a run period ? Temporary executable can be removed at the end of the run.

I personally considered creating a file that contains an unsigned char array that contains the text of executable. It will be done on time compilation as part of the manufacturing process. In the runtime this string will be written in the file, which will be executable.

Would it be possible to do such a task without writing executable (perhaps some kind of RAM disk) on disk? I could imagine some virus scanners and other security software which was objecting to such operation. Should I be worried about other concerns?

The library is being developed in C / C ++ for cross-platform use on Windows and Linux.

You can use a binary file to convert to a C header file.

  $ echo-A "" 001 \ 002 \ 005 "> X.binary $ xxd -i x.binary unsigned letter x_binary [] = {0x01, 0x02, 0x05}; unsigned Int x_binary_len = 3;  

xxd * Nix is ​​very standard on the system, and it is available on Windows with Sigwin or Minzid, or even in the WinMaster installer This is a very cross-platform way to include binary data in the compiled code.

Use of another approach at the end of the executable To attach data - IIRC you get objcopy and use it for PE on Windows

An approach makes me feel a bit better Just attach the raw data directly at the end of your executable file. In the executable, you look for the end of the file, and read it in a number, which shows the size of the attached binary data, then you look backwards There are many bytes, and R fread copy that data and copy it to the file system, where you can call it as an executable file, it is accidentally possible.

If you add binary data, then it works with both Windows PE files and * nickle ELF files - none of them read before the "border" of executables.

P> Of course, if you need to attach several files, you can either add a tar / zip file to your extension, or you will need some additional advanced data structures Has been read.

You also want to add your executable too.

You may also be interested in this, which is one of the fastest-decompressing compression libraries, they have a MiniLZO library which you can use for very light decompressors. However, the LGO library GPL is licensed, therefore may be it means that you can not include it in your source code unless your code gets GPLD. On the other hand, commercial licenses are available.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -