PDA

View Full Version : Question regarding the final .exe



el33t
13th August 2011, 08:13
Ok, so I have a program which make use of resources like images , big pdf files (through poppler) etc. etc. Now, when I compile the program in release mode, I get a single .exe file as the end-result. This is understandable since all files I mentioned above (images, pdfs) are part of the resource and thus gets embedded into the final .exe upon compilation. However, I'm looking to do something else. What I want is :

-> I want the final .exe and resource files to be separate. However, it should be in such a manner that the image and pdf files cannot be readable by the user(it should be in some binary form etc.)..

Possible?

Any assistance would be appreciated.

Regards.

wysota
13th August 2011, 08:19
You can have the files encrypted, for example in a SQLite database. You can look in our wiki how to use encrypted SQLite databases. Just be aware that if you store the encryption key in your program, someone could extract it and decrypt the database.

el33t
13th August 2011, 08:41
You can have the files encrypted, for example in a SQLite database. You can look in our wiki how to use encrypted SQLite databases. Just be aware that if you store the encryption key in your program, someone could extract it and decrypt the database.

Thanks for the quick response.

I think encrypting them would be fine because I'm not actually looking for a high level security measure. What I want is that my files should be not so easily readable (easy as in going to the main folder of the program and retrieving all the .pdf and images just like that)...

[BTW, just so you might be curious why I want to do something like this, my program is a mini encyclopedia about underwater animals. It will have A LOT of .mp3, pdf , images files. I do not want them to all be compiled into single .exe.]

However, if you have any other alternative, please feel free to post.

Regards.

squidge
13th August 2011, 10:22
Is there any particular reason why you don't want them compiled into the EXE? This would indeed be the easiest way of doing it and it would protect people from just using the files themselves. The data wouldn't be encrypted, but there would be no filenames, so you would not be able to extract them easily.

Note that only the required resources are loaded at runtime, the others are loaded as and when necessary, so your file can easily be 100MB+ without worry

Other alternatives would be archive formats like ZIP - you could encrypt the archive and only your program knows the password (but anyone with enough time can figure out the password from your exe). Going further, you could name all your files 0000, 0001, etc, and have a DB which maps the file you want to the file number.

el33t
13th August 2011, 10:32
Note that only the required resources are loaded at runtime, the others are loaded as and when necessary, so your file can easily be 100MB+ without worry


Ok, now that clear things up for me. I was in the misunderstanding that all the files get loaded up during run-time...

Ok, so suppose I have ~ 1 GB of mixed resources(pdf, image, mp3, vid etc...) , once I release my program, will I get a single .exe of ~ 1 GB? Is that right?

squidge
13th August 2011, 19:17
Yes, but I wouldn't create an executable file of 1GB. If you really need that more storage then a better way would be a seperate file.

Otherwise, every time you adjust your executable, the linker has to deal with ~1GB of resource data.

el33t
13th August 2011, 23:33
If you really need that more storage then a better way would be a seperate file.

Hmmm.... So if I decide to separate my exe and resource files, which is the easiest method you recommend?

squidge
14th August 2011, 12:01
Easiest? Probably a password protected ZIP file. Quite easy to find the password however as you'll be passing it plain text through libraries.
Most secure? Your own archive format (no prewritten software for unpacking it then, anyone wishing to have the data has to write their own)

wysota
14th August 2011, 20:15
I think there is a way to have an external resource file and attach it to your exe during runtime. Have a look at External Binary Resources section in the docs.

squidge
14th August 2011, 23:05
Nice wysota. That would give a sort of transparent ZIP functionality. I don't think you can encrypt such resources though, so you'll have to do it yourself once the appropriate file has been loaded?

el33t
14th August 2011, 23:31
I think there is a way to have an external resource file and attach it to your exe during runtime. Have a look at External Binary Resources section in the docs.

I'll give it a look. Thanks.

wysota
15th August 2011, 15:10
Nice wysota. That would give a sort of transparent ZIP functionality. I don't think you can encrypt such resources though, so you'll have to do it yourself once the appropriate file has been loaded?

I think the OP doesn't really want encryption but rather a blob-like solution where he can throws all his files into and prevent (l)users from messing around with them too easily. If you want encryption then you either need to encrypt the contents of each file separately before placing it in the resource or encrypt the whole resource file and decrypt it on the fly (which has an obvious drawback that anyone can access the decrypted version of the file).

el33t
16th August 2011, 11:16
I think the OP doesn't really want encryption but rather a blob-like solution where he can throws all his files into and prevent (l)users from messing around with them too easily. If you want encryption then you either need to encrypt the contents of each file separately before placing it in the resource or encrypt the whole resource file and decrypt it on the fly (which has an obvious drawback that anyone can access the decrypted version of the file).

Yes, this is what I want. Nothing much fancy like encryption.

Ok, so I used external binary resources by following the instructions in the official documentation but here's the problem. The program compiled fine and all the resources worked fine in-program. However what I was expecting was to get a single file (maybe a .dat or a .bin or something like that...) containing all the resources mentioned in my .qrc file. If something like this was possible, then I could just pack the main .exe along with this .dat/.bin file whatever and off coarse the other qt .dlls like qtcore.dll etc...

The reason I'm doing all this is because I don't want my .exe to be something like 1-2GB (Since I'll be using a lot of heavy resources like videos and audios). And on the other hand, I don't want people to leech my resources from the main folder just like that...

squidge
16th August 2011, 13:21
Don't you get an RCC file containing all your resources? So you just have EXE + RCC ?

el33t
20th August 2011, 07:42
Don't you get an RCC file containing all your resources? So you just have EXE + RCC ?

Yes, you are right...... My problem is now solved. And sorry for the extremely late reply....

THANKS A LOT ALL THOSE ABOVE WHO TOOK THEIR PRECIOUS TIME TO ASSIST ME WITH MY PROBLEM. REGARDS