Changing image in an executable


i'm trying to change a JPEG image that is in a compiled program. The program was compiled using Delphi . I don't know which exact version.

I've tried to make my own application, and change the picture in it using Resource Hacker. I have succeeded in doing so, by making another application with a picture, and coping the binary data from one to another.

I didn't succeed with this application. Perhaps I should use the same version of the compiler that was used to compile the original program? Or is there a tool to simplify all of this?

I have chosen the maximum of the points I can give for an answer.

Thank you,
Jaka "|SNap|" Jančar,
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I have used this by itself to change an immage in a exe or dll file

You need to use a tool like this in conjunction with a tool for developing the images.

Resource Hacker
As far as I know, jpeg pictures cannot be stored inside the exe/dll. BMP pictures, icons, dialog boxes, string lists, shortcuts can.
Anyway I've always done similar things with MS Visual studio 5/6.
Open file -> select the exe -> select the "open as" - resource and open.

Make sure you store the backup of that exe
SNapAuthor Commented:
CrazyOne: I have written in my question, that i have used Resource Hacker, and it didn't work. Probably because delphi "encodes" the images in a different way on different versions.

dschwartzer: They _CAN_ be.
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

You probably ran into a software where as the developer wanted to ensure that their image is protected from being overlaid by another image.  They do this by hashing the image or crc the image and then stored the value in the data section (mangled if needed).  Then at launch time, the software would hash or crc the image and compare the value, if it's different then they exited the program.

You did everything correctly in terms of using Resource Hacker to replace the object.  This embedding is standard for Windows resource for storing (Windows expect to locate the resource at specific places) and is independent of delphi.

To hack it you should try a good debugger and trace the code object - find the hash alogrithm, the hash value, and the storage location of the hash value; and Then hash your image through the same alogrithm (you can embed your image and let the program hash it - and get the hash value) then change the hash value stored in the program.  

Cracking software or ill-use is illegal.

SNapAuthor Commented:
I could change some other picture in the program, so I also found this two options:
1) I can change BMPs but not JPEGs because of different size/encoding/whatever
2) a checksum, like you said

So i'll try to change the image with some other versions of Delphi, if that might be a problem.

The odd thing is that when I launch a program with the changed JPEG image, it doesn't crash or anything, but just closes instantly. That's a pretty good indication of a CRC.

Anyway, if it's a checksum I would definitely need more precise instructions how to achieve that.

Unfortunately, I can't post the program somewhere online, but I ensure you that what i'm doing isn't illegal.
If the program shuts down instead of crashes, it's an indication that the author is checking to make sure that it had NOT been modified by someone - perhaps to attach a trojan on the software.  You are right about swapping the BMP/JPG - it's because of different format and different rendering of the image.  The function that was called - handle only specific format.  So, you will have to stick the specific file type.

You will need to put it through debug and spend time (may be a lot of time) on getting to the hash signature's location in order to change it.  I am sure that if the author went through the process of securing his/her work from being cracked and a trojan/virus/worm inserted into the program.  It will be difficult but not impossible to get to it.

Since it's code dependent - I am sure that no one here would have the time to trace the code in order to tell you how to insert and patch the hash signature.

The question is, is it worth the time to do what you want to do?   Send the author a message to see what he/she did and if it's possible for you to obtain the direction on inserting your own graphic and hash signature.

SNapAuthor Commented:
I unfortunately can't contact the author.

Any advice on how to start debugging?
Yeah, get a debugger such as softIce and load the program in to debug.  Use the tools that came with your debugger to analyze the code to see what it's doing and what functions it is calling.  It would be easier if you have the source code.  Without the source code, it requires a lot of knowledge in order debugg and understand what it is doing.

Once you have it loaded, set up the address location of the image as the stop point.  What you want for it to do is to stop executing when the image is reference...... from there you will trace the instruction execution - one instruction at a time and see what it is doing.......examine and look for hash calculation of any sort.... and modify the instruction logic to force the program to continue execution instead of exiting or quitting.  Hope you have time....

debug in windows won't do this job but I will use it to give you a quick example.  I presume that you are running windows 2000.  

Start, run, type in cmd and press enter.
change directory to c:\winnt\system32.  use dir to see if cmd.exe is there.
type debug cmd.exe and press enter... you are now in debugging mode to debug the program cmd.exe
type ? and press enter - debug will list the commands
type r and press enter - to display the registers
type t and press enter - to execute one instruction at a time

As you can see it takes a lot of time - and a good understanding of assembly to go through the logic.  A good debugger would be much quicker than using debug.  But you get the idea.

type q and press enter - to quit debugging

Sorry, but the lesson on debug - cracking a program would be beyond the scope of thread conversation as it is very complex and will take lots of time.... I hope I get you started on your way cracking this program, which is what you are doing....



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
May be the author is still debugging the code to get to the hash signature...<G>  It's the only way to crack a program.....

SNapAuthor Commented:
Actually, i have accomplished what i wanted with a much simpler trick. But Gnart obviously put a lot of effort into explaining debugging to me, so he deserves the points.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 2000

From novice to tech pro — start learning today.