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

Document pdex.bin file format and improve conversion script #24

Merged
merged 3 commits into from
Jul 15, 2024

Conversation

castholm
Copy link
Collaborator

@castholm castholm commented Dec 28, 2023

I documented the pdex.bin file format. It is essentially a stripped-down ELF file consisting of metadata, a program segment and relocation entries.

I also rewrote pdex2elf.py, which did not actually work with modern pdex.bin files. I'm late to the Playdate game but I suspect (much) older versions of the SDK produced executable files in a much different format from what is in use currently.

The new pdex2elf.py script creates well-formed ELF file that can be analyzed by readelf or objdump and decompiled by Ghidra, and it can even be compiled back by pdc into a bit-for-bit idential copy of the original pdex.bin. I tested it with both some of my own WIP games as well as some non-encrypted games from the catalog and they round-tripped perfectly.

It is a PowerShell script which I expect to be a bit controversial 😛 but PS is the only shell scripting-like language I'm proficient in so take it for what it is. If you would like to port the functionality to Python or whatever you have my blessing. Update: I've now ported it to Python.

@castholm
Copy link
Collaborator Author

@jaames Pinging just in case you haven't yet seen this PR.

@gatesphere
Copy link
Contributor

As of SDK 2.5.0, pdc now supports multi-segment pdex.elf files. Unknown if @castholm's script above will need any adjustments for this.

@castholm
Copy link
Collaborator Author

castholm commented Jun 1, 2024

I believe that multi-segment fix is just so that the pdc compiler itself properly reads all segements in the input ELF file. It shouldn't have any effects on the pdex.bin format itself or the script's ability to round-trip a pdex.bin.

@castholm
Copy link
Collaborator Author

Ported the PowerShell script to Python.

@castholm castholm changed the title Document pdex.bin file format and add improved conversion script Document pdex.bin file format and improve conversion script Jul 15, 2024
@castholm castholm merged commit 30646bc into cranksters:main Jul 15, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants