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

Export with embedded pck is broken when changing PE metadata with rcedit #33466

Closed
Wavesonics opened this issue Nov 9, 2019 · 33 comments · Fixed by #56093
Closed

Export with embedded pck is broken when changing PE metadata with rcedit #33466

Wavesonics opened this issue Nov 9, 2019 · 33 comments · Fixed by #56093

Comments

@Wavesonics
Copy link
Contributor

Godot version: 3.2 beta 1

OS/device including version:
Windows 10

Issue description:
Running an executable that was exported with embedded pck fails to run with the following error:
Error: Could not load game data at path '.'. Is the .pck file missing?

Steps to reproduce:

  1. Enable "Embeded Pck" in export options
  2. Export (either release or debug, doesn't matter)

Minimal reproduction project:

@Wavesonics Wavesonics changed the title Godot 3.2 Beta 1: Exported with embedded pck is broken 3.2 Beta 1: Exported with embedded pck is broken Nov 9, 2019
@akien-mga akien-mga added this to the 3.2 milestone Nov 9, 2019
@RandomShaper
Copy link
Member

@akien-mga, I'll check this more thoroughly later, but for now it'd be helpful knowing if the export templates are signed.

@akien-mga
Copy link
Member

They are signed indeed, but as per #32310 this shouldn't prevent the embedded PCK from working, it should only lose the signature on export.

But maybe @Wavesonics signed the exported binary themselves, in which case it would be a duplicate of #32310.

@Wavesonics
Copy link
Contributor Author

@akien-mga I did not sign my windows binaries, nor is Code signing is not enabled in my export options.

@Wavesonics
Copy link
Contributor Author

I went to make a minimal case project for this bug, but may have instead uncovered a different bug: #33549

@Wavesonics
Copy link
Contributor Author

Ah I think I found the problem. I am using rcedit-x64.exe to change the icon for the Windows exe, that must screw up the signing that @akien-mga is talking about?

In my windows export options I have an icon specified under the Application header.

If I remove that, it runs just fine, presumable because it doesn't run rcedit-x64.exe?

@Wavesonics
Copy link
Contributor Author

If the issue is the fact that the template is signed, and then this icon program modifies the template, thus invalidating the signature. Are we in "how did this ever work" territory?

@bruvzg
Copy link
Member

bruvzg commented Nov 29, 2019

  • If export template is signed (why is it?), both using rcedit and embedding PCK will break signature and result in corrupted executable, that can't be signed later. But neither shouldn't prevent it from running.
  • If executable is signed after embedding PCK, it won't run.
  • If rcedit changes are applied after embedding PCK, it won't run (this is most likely the case here).

@akien-mga akien-mga changed the title 3.2 Beta 1: Exported with embedded pck is broken Export with embedded pck is broken when changing PE metadata with rcedit Jan 19, 2020
@akien-mga
Copy link
Member

At the very least we should add clear documentation on the export tutorials about limitations of the embedded PCK.

Users are lured in by the "all in one" aspect but there are lots of non-obvious drawbacks to the approach.

@RandomShaper
Copy link
Member

Yes, current problems with resource editing and signing could be considered known issues for the time being.
Both can be fixed. I'll work on it the next chance I have.

@akien-mga
Copy link
Member

* If export template is signed (why is it?), both using `rcedit` and embedding PCK will break signature and result in corrupted executable, that can't be signed later. But neither shouldn't prevent it from running.

I disabled signing of export templates as of 3.2 RC 2.

@akien-mga akien-mga modified the milestones: 3.2, 4.0 Jan 22, 2020
akien-mga added a commit to godotengine/godot-build-scripts that referenced this issue Jan 22, 2020
This causes issues for people who want to embed the PCK,
change PE data with rcedit or sign the executable themselves.

See godotengine/godot#32310 and godotengine/godot#33466.
@derac
Copy link

derac commented Feb 26, 2020

Is there any workaround for using PCK embedding and having a custom icon at the same time?

@RandomShaper
Copy link
Member

There's a potential megahack: tampering the current icon image data in the file with the one you want to use.

@akien-mga
Copy link
Member

You can replace the icon with rcedit in the export template itself, so that it's already good before exporting with embedded PCK.

@RandomShaper
Copy link
Member

You can replace the icon with rcedit in the export template itself, so that it's already good before exporting with embedded PCK.

Much better. :)

@BlooRabbit
Copy link

You can replace the icon with rcedit in the export template itself, so that it's already good before exporting with embedded PCK.

Not quite sure how you do that. Are there instructions somewhere on this strategy ? many thanks. It is true that for non-professionnal gamedevs (speaking for myself), being able to ship one single .exe file does sound more appealing.

@Calinou
Copy link
Member

Calinou commented Mar 21, 2020

@Tsar333 rcedit is a command-line utility you can call manually. Download an executable and run it from a command prompt for instructions.

It is true that for non-professionnal gamedevs (speaking for myself), being able to ship one single .exe file does sound more appealing.

I would really advise distributing a ZIP archive with the executable and PCK for two reasons:

  • You get compression, so people can download your game faster.
  • You avoid false positives thrown by antivirus programs and Web browsers. They generally dislike having people download executables directly, but they're fine with it if it's packed in a ZIP archive.

@eyeEmotion
Copy link

So... what are the constraints now? Because one time I can export an exe with the pck embed in it, but most of the time not. That while I didn't change my export settings. And I've done all the .ico and .png changes.

@eyeEmotion
Copy link

eyeEmotion commented May 3, 2020

Ok, this is weird. Although my game works fine in Godot (F5 or F6), when exporting it, there is all sort of weird things happening. Previous mentioned problem, but also game breaking problem.
I have some code in my game to detect if the input is from a keyboard or controller. If it's from the keyboard, certain camera-effects shouldn't be executed. This works fine in Godot itself... and when finally able to export the game, it also does work with the executable... but only for a while.

When I just exported it and tested it, everything worked fine. Now, a few hours later testing it again, the problem occurs again. And I also noticed that the icon image of my executable has changed from the one I made/chose, to the one of Godot again. So what is happening here? Why is the executable fine at first and a few hours later, while doing nothing with it, this happens.
Hope this gets fixed, because if you can't export your game, why bother then.

Edit - so I'm getting closer to the weirdness. Exported it again, everything works fine. I close the executable, then I close Godot, then I launch the executable again... and again the problems occurs. So is there something that isn't being exported that make these problems occur when Godot itself isn't running?

@Calinou
Copy link
Member

Calinou commented May 3, 2020

@eyeEmotion If you export your project with a non-embedded PCK then export it again with an embedded PCK, the non-embedded PCK will take priority. This will be fixed by #37937.

As a workaround, remove the PCK file that's next to the exported project executable.

@eyeEmotion
Copy link

I've done all those things. I've always first removed the old files before exporting the new files.
Removing the "personal" icon in the export seems to help to be able to export the embed pck. But whatever I do, after a while my the game "breaks" some code in trying to execute a function it shouldn't be able to execute. This only happens with the exported file. Don't know if it happens with the Linux/MAC OS version, since I don't have them (although they are available to download on my itch.io game-page.
And it's just a simple code: detect if _input is InputEventKey, set variable either to true or false. That variable is used in another function that will only execute it when it's a controller. So pretty straightforward.
It's just so strange that the first few starts of the executable, this works just fine and then all of a sudden, it doesn't anymore. Even with the seperate exe and pck.

@follower
Copy link
Contributor

I investigated the use of rcedit recently and encountered this comment which suggests it may no longer be a reliable option.

(I did note that Kaitai Struct does have a PE specification file if anyone wants to code an alternative. ;D )

@kukosek
Copy link

kukosek commented Dec 2, 2020

funny bug, yesterday we were exporting our game to windows (last day of game off game jam) used rcedit only to find out we cant use embedded pck then.

@RandomShaper
Copy link
Member

Just as a reminder, I know there are multiple issues with PCK embedding. I have plans to provide a better implementation, that is not as fragile as the current one. I don't know exactly when I'll be able to do it, but that'll happen.

@MikeTeok
Copy link

MikeTeok commented Oct 2, 2021

Holy sh**ttt, I found out that as long as I filled File Version and Product Version, this issue will be gone.

@madelfagam
Copy link

Holy sh**ttt, I found out that as long as I filled File Version and Product Version, this issue will be gone.

yes it really works! I indicated random numbers in these two fields and after export everything worked out.

@madelfagam
Copy link

yes it really works! I indicated random numbers in these two fields and after export everything worked out.

Oops, it seems this only works if the executable is at the root folder of the game's resources ...

@MikeTeok
Copy link

MikeTeok commented Oct 4, 2021

yes it really works! I indicated random numbers in these two fields and after export everything worked out.

Oops, it seems this only works if the executable is at the root folder of the game's resources ...

Weird, I didn't export at the game's folder, I exported far far away from source code. I filled with 1.0.0 instead of random number tho. Not sure if it matters.

@nathanfranke
Copy link
Contributor

I can reproduce this on Linux using strip.

[nathan@arch .export]$ ./Test.x86_64 
Godot Engine v3.3.4.stable.official.faf3f883d - https://godotengine.org
OpenGL ES 3.0 Renderer: NVIDIA GeForce GTX 960/PCIe/SSE2
OpenGL ES Batching: ON
 
[nathan@arch .export]$ strip Test.x86_64 -o test

[nathan@arch .export]$ ./test
Error: Couldn't load project data at path ".". Is the .pck file missing?
If you've renamed the executable, the associated .pck file should also be renamed to match the executable's name (without the extension).

GNU strip (GNU Binutils) 2.36.1
Kernel 5.10.76-1-lts

Project is exported on 3.3.4:
Test9_1.zip

@Deozaan
Copy link

Deozaan commented Nov 27, 2021

I was pretty sure this got fixed sometime in 3.3.x and I didn't have to resort to weird hacks to get a custom icon and metadata while embedding the PCK file. Maybe I was wrong about that.

But I'm definitely experiencing it again in 3.4.

@magni-inter-pix
Copy link

magni-inter-pix commented Nov 27, 2021

Yeah, I’m in the same situation. I’m close to finalizing my project and it randomly happens when exporting to windows.
I just tested with 3.4.1 RC1 and that bug is still there
Sometimes I get an error while exporting:

ERROR: Failed to export the project for platform 'Windows Desktop'.
   at: _export_project_to_path (editor/project_export.cpp:863)

Sometimes it does export, but I get an error when starting the exe:

Error: Couldn't load project data at path ".". Is the .pck file missing?
If you've renamed the executable, the associated .pck file should also be renamed to match the executable's name (without the extension)

Sometimes it did export good from 3.4.0, randomly

When I export with the checkbox “Embed pck” unchecked, the export does work
The problem is because of rcedit as mentioned here:
https://github.com/godotengine/godot/issues/45345#issuecomment-798772388

It started after I added icons. Disabling rcedit also fixes the issue, but I want the exported executable in one .exe with an icon, so I’m going to need to use resource hacker to get my windows icon in when this is not fixed shortly I presume.

@Eric-pixel-0
Copy link

Eric-pixel-0 commented Mar 16, 2022

My project has worked normally
I can't find what I did

https://github.com/Eric-pixel-0/memoriaMusical.git

@Calinou
Copy link
Member

Calinou commented Mar 28, 2022

Can anyone check if #57850 fixes this issue? You can try 4.0alpha5 or building the 3.x branch from source (both editor and Windows export template)?

@nathanfranke
Copy link
Contributor

I can still reproduce on 11d40d7 with my steps above.

$ ./test.x86_64 
Godot Engine v3.5.beta.custom_build.11d40d76a - https://godotengine.org
OpenGL ES 3.0 Renderer: NVIDIA GeForce GTX 960/PCIe/SSE2
Async. shader compilation: OFF
 
$ strip test.x86_64 
$ ./test.x86_64 
Error: Couldn't load project data at path ".". Is the .pck file missing?
If you've renamed the executable, the associated .pck file should also be renamed to match the executable's name (without the extension).

I think my issue is not caused by the windows icon, but an underlying way that the pck file is embedded.

@akien-mga akien-mga modified the milestones: 4.0, 3.5 Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.