Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utility to change the icon #375

Open
TrueCat17 opened this issue May 22, 2023 · 0 comments
Open

Utility to change the icon #375

TrueCat17 opened this issue May 22, 2023 · 0 comments

Comments

@TrueCat17
Copy link

Many cross-platform engines and applications need to set the icon for the *.exe file regardless of the platform.
Judging by the fact that almost everywhere Windows or Wine is required to change an icon, there is simply no solution to this problem.

It seems to be a common and not so difficult task, but all over the Internet I found exactly 1 way to do this (and even then - the result is problematic).
There is a lot of information about how to extract information (including the icon), how to change the file with third-party utilities or with their partial use, but nothing about how you can simply change the icon without win-api.

The way I found (from the renpy/launcher project) uses your library, which is why I'm referring here.
change_icon.py - edited (without internal dependencies) file from renpy.
python change_icon.py old.exe icon.ico new.exe

In my case, the resulting file has the desired icon, runs in Wine, but (suddenly) doesn't run in Windows.

Uncommenting the newpe.print_info() line at the very beginning produces the following warning:
Invalid relocation information. VirtualAddress outside of Image: 0x688ef2f1

Regarding the same output, pe (original exe) immediately shows that the part with Base relocations (at the bottom of the output) is simply missing.
I tried to fix it by adding the last couple of commented lines.
After that, the part with relocations reappeared, but now the file does not run anywhere at all.

This is not the first time I spend several days trying to solve this problem, but nothing comes of it, because I am very poorly versed in all these tables, sections, headers, sizes, addresses, offsets, etc.

Perhaps there is a person here who can once and for all solve this problem for the entire Internet?
Of course, it would be nice to make a separate python module for this, rather than just posting an answer here, but this is no longer relevant to the current topic.
Thanks.

change_icon.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant