All exes compiled can be decompiled (but with some hardship )
but delphi application forms are saved as dfms inside exe which can be seen easily (with reshacker) (soooo easily ) can i overcome these problems ,first i thought of copying dfm data to oncreate procedure so i can hide my form information .
tell me a good solution for this ,
i do not like to use compressors
and my application is bit large so i cant port resourese one by one to a dll. i need an effective solution.
.dfm files are not stored as txt when they're linked into the final PE file. They are converted to a tagged binary format that is placed into an RCDATA Windows resource. For the images, they are stored as the raw binary. While building your application, the .dfm files can be stored as text or binary (right click the form designer and there is a selection for choosing one or the other). This only affects the format of the .dfm file itself. It has zero affect on its format once it is linked into your final binary.
You can try to convert the images to constant arrays (there are many tools that will read a binary and write out an array decl in various language formats) and use it as an include file. Another thing is to encrypt the images using a one-way algorithm like RSA or PGP. This won't keep someone from decrypting the image, but it will keep someone from replacing it since they won't have the private key.
If this is about protecting your applications images you are already on the losing side:
https://stackoverflow.com/questions/455623/how-can-i-prevent-users-from-taking-screenshots-of-my-application-window
It is always possible to make screenshots of a running application.
Related
I have a few scripts that I would like my program to work with. However, I would like to know if it is possible for me to store these scripts (eg. batch, javascript, vb scripts etc) in my application as a resource.
How would I go about doing this?
You can store your scripts in resource files. But for example Batch Files need to be file on disk, so you will need to unpack them before working.
There are components to store arbitrary file/files or string in DFM
For example there are such in rxLib/JediVCL but i believe many VCL libs have one or another kind of DFM Storage component.
For example i used to store Firebird Embedded database in DFM to save it into TEMP and use while running.
However that is akin for manual re-reading file into DFM each time you update it. Rather annoying to say sincerely.
One more approach is linking text into resources. You can look into DUnit sources to see how it was done. You would also have .rc file included in project, so that it would be compiler into .res when making .exe
This approach is fragile towards ansi/unicode text interpretations.
Frankly, before i found DUnit in Delphi XE2 (it was disabled due to IDE bug) i tried to make SF's vanilla DUnit to run there. And i failed - the non-unicode text files linked into resource was totally corrupt when reading with unicode-enabled Delphi.
Look here and there, try both approaches and choose the one that suits you more.
Here is a good article that explains how you can add almost anything in a resource file and compile it with your application: http://delphi.about.com/od/objectpascalide/a/embed_resources.htm
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
how to store settings in resource
I have a record with strings, Integers, etc. This record is used as settings for a file that gets read later. How can I convert a record to binary data (or string) and save to it a RCDATA and read it back to a record? If possible native code and/or WinAPI only. Thanks for your help.
About RCDATA:
i ask google "resource editor opensource delphi"
and it told me http://melander.dk/reseditor/
This program surely can read and write resources.
The page's footer also contains links to three more opensource delphi programs that also can do it.
So i hope you would find what u need there. Among piles of other useful code :-)
But - WHAT RCDATA do you want to use ??? OF what file ? some DLL ? or your own project EXE ?
RCDATA is for reading, not writing. It is not typical use. If the DLL or EXE is loaded - you would not be given rights to write into file new RCDATA. And your own running EXe is always open.
About turning to binary - that is VERY dependent on data types u use. Before you would show the data - no one would be able to tell you for sure.
Most lazy approaches would be:
1) Make mirror class from TComponent with published properties mirroring record fields. Assign those properties from record and do TComponent.SaveToStream.
2) Use JsonObject from Progdigy to make text file in JSon format
3) use some XML to save/read. For example TXMLDocument in higher Delphi versions (but it has its gotchas if created with nil Owner) or Jedi CodeLib has XML.
You can search Torry.net for a lot of XML or JSON libs.
But best of all - Google for "serializing in Delphi" and find tutorial detailing the troubles and solutions.
I'm using Delphi.
I want to know how to extract (all) the icons from an exe file and insert them into another, preserving the order and the index of the icons.
I found some samples of Delphi code using Google but the problem is that it doesn't extract them all.
And I've found some compiled programs (exes) that do one or the other but not both.
Why do I need this: because I have to start some exe files (that have those icons) from virtualized applications. And I want to make some external exe files that have the same name and the same icons.
Thank you for your help.
The source is available for Colin Wilson's XN Resource Editor. It should have what you need.
http://www.wilsonc.demon.co.uk/d10resourceeditor.htm
Alternatively you have the Delphi sample 'ResXplor'. If it's not distributed in your version it's also avalaible to download here: http://radstudiodemos.svn.sourceforge.net/viewvc/radstudiodemos/branches/RadStudio_XE/Delphi/VCL/resXplor/
There was a similar question about extracting icons. PrivateExtractIcons gives you access to specific image sizes in an icon resource, but you need to know the sizes ahead of time, and Microsoft warns that this method is not for general use.
There is a working example of extracting the entire icon resource with all of the image sizes on Delphi Praxis. The example has a problem with 256 pixel images, so it would have to be tweaked to account for these.
I'm compiling my application with Delphi 2010. My problem (it may not be a problem for anybody else) is that when you open that EXE with any resource editor you can see RCDATA which holds forms data. I don't like an idea of my program being "exposed" so I want to ask you is there any trick to remove that information from EXE or encrypt it that nobody (at least from resource editor) can see it?
You may create your forms fully via source.
opposite: you can't use the form designer.
with gexperts you can convert existing forms to source.
encrypting and compressing is not a solution. when the app can load the resources a engineer can it do, too.
I have written a DFM compressor that works inside of the Delphi IDE to compress DFMs at compile time. It then decompresses them on the fly at runtime.
I sell it for $15 US and it comes with src.
It currently works with D7, D2006, D2007 and D2009. I don't own D2010 but I have recently gotten XE and I will be upgrading it and making it available for XE as well in the near future. If someone makes a request for XE, or even D2010 compatibility, I'll work to make that happen sooner.
It's called the DeForM System and can be found here.
I use it for a number of my personal projects.
You would need to modify VCL source code to teach form loader to take resources elsewhere. Also, compilation would require post-build step or stripping resources from the compiled EXE and moving them to a separate encrypted file (for example). All of this is manual work, I never heard of any automation for described tasks.
One thing you could do IF your forms are finalized (i.e. they won't be modified further) is take GExperts and use their Component To Code expert to create forms and their contents in runtime. But modification of such forms will require changes in code.
It actually just holds published property of the components you drop on your forms and the form itself (actually the content of DFM file for each form), not any source code. So even if somebody extracts that data, they can at most produce a form visually looking the same as your form, but none of the codes you wrote for the form.
One way to hide such data from resource editors is to build all the components you use in your form at runtime, not using the form designer. This way, the DFM resource will not contain their data. As far as I remember, there are tools which are able to receive a DFM file as input, and generate runtime code for component creations automatically (e.g. GExpert), so that you could copy\paste the code in your form's OnCreate event-handler.
Another option is to use an EXE compressor. A compressor will compress your EXE file so the content of the file will be changed and not usable until being decompressed. Tools like UPX can compress your EXE file and decompress it on the fly when you execute the EXE. Take note that using known compressors like UPX has the drawback that many cracking tools or crackers can detect them and automatically decompress the EXE before processing it. So if you need more security, you'd better go for custom compressors.
I haven't used it, but Citadel for Delphi does automatic compression and encryption of DFM resources in your EXE. It doesn't look like they've updated past Delphi 2009 yet, but it's exactly what you're looking for.
I'm using the IdFTP (Indy 10) component to download some files (zip and txt) from a remote location. Before getting each file I set the TransferType to binary.
IdFTP.TransferType := ftBinary;
IdFTP.Get(ASource, ADest, AOverwrite);
I expect that both text and binary files can be downloaded using the binary mode. However it looks like text files contents is messed up while zip files are downloaded correctly. If I set the TransferType to ASCII for text files it works as expected. How can I detect which TransferType to set for a given file? Is there a common denominator or auto setting?
I don't see how the Binary flag can mess up transferred files. Binary type means the server transfers the files without any processing, as is.
The only thing that an FTP server should use the ASCII flag for, is to correctly handle the end of line in text files, usually (1) either only Line Feed in Unix or (2)Carriage Return + Line Feed in Windows. But nowadays most text editors handle both in either system.
So the safest is use only ASCII flag for very well known text files, probably only files with a .txt extension, and use Binary flag for all the others.
When in doubt, rule it out (!) - try transferring the files from the server using the Windows commandline FTP program, and see if text files still come out wrong. The program will transfer binary (command BIN) or text (command ASCII). If you transfer files with this and they still arrive differently to your expectation, then something is being done at the server end*. If they arrive fine, then either you (or Indy) are doing something. :-)
*In what way are the text files messed up? If you're transferring unicode text files, you might be better off transferring them as BINary anyway. I must admit that, as #unknown (yahoo) said, in most cases you should probably stick to BIN mode.
I guess it would also depend on how you are viewing the text file, ANSI or WideChar as to whether the text is messed up or not.