Back in late 2002, I did a couple of articles for the now-defunct Handheld Computing Developer newsletter under the title "The Secret World of Palm OS". Since that site is gone, I'm reprinting those articles here for your reference. This article was originally published in December 2002. —ben
Q: What is a PRC file?
A: You can think of a PRC file as a kind of archive, like a ZIP file. It holds a collection of resources for easy storage in a file system. PRC stands for "Palm OS Resource Collection". PRC files are most often used to hold Palm OS applications, although they can also be used for shared libraries, overlays, and miscellaneous data storage. On the device, this collection is often called a resource database, since you use the same Database Manager functions to manipulate a PRC as you would a normal database.
Q: How is a PRC file organized?
A: PRC file starts with a header. This structure gives key information like the name of the database, when it was created, when it was modified, and what is its status. There is a section in this header that describes flags: the do-not-copy flag is included here, along with the bundle flag, the reset-after-installation flag, and the hidden flag. After this header, there is an optional block of data called the application info chunk. This usually isn't used in resource databases. Another optional chunk follows that holds sort information, and then you have the list of resources. Each resource starts with a header giving its type, ID number, and size.
Q: What is a PDB file?
A: A PDB file is a stored form of a Palm OS database. Plain Palm OS databases differ from resource databases in how they store their records. Rather than identifying records based on a type and ID number, records are all assumed to be the same type, and they have headers that give a unique ID and category information. PDB files share the same header format as PRC files, and also have optional application info and sort info sections.
Q: How can I make my own PRC file on my desktop machine?
A: Usually, developers use a tool like CodeWarrior for Palm OS, PRC-Tools, PocketStudio, or NS/Basic to create their PRC files. However, if you need to create PRC files for a special purpose, there are a few really useful tools.
First, you can use PilRC version 2.9 or later to directly generate a PRC file from your RCP file describing all of its resources. The "-ro" command-line option directs PilRC to output a PRC file containing all of the specified resources, rather than outputting a collection of binary files, one per resource. PilRC has other command-line parameters that let you specify some of the PRC parameters, although the output PRC file defaults to type 'RESO' and creator 'pRES'.
Second, there is a really useful tool called par, created by David Williams. par is an PRC/PDB file manipulator built around David's libprc. It lets you modify any attributes, add resources, and delete resources from PRC files. par is modeled after the ar tool long available on Unix systems to handle system archives.
Q: What can I use to inspect a PRC file?
A: My favorite tool for this is Regis Nicolas's PRC Explorer. This is a freeware tool that runs on Windows and lets you open and inspect all of the contents of PRC files. It includes viewers for forms, bitmaps, fonts, and a disassembler for 68K code resources. It also can take resources from a PRC file and output them in RCP format for editing and recompilation using PilRC.
Q: In the PalmRez pref panel, there is an option to "sort resources by size". Why did Palm add this option?
A: As best I can tell, this option was important back in the days of Palm OS 2.0 and earlier. On those devices, the storage heap was divided into several 64K heaps, and memory fragmentation in the storage heap was a big problem. By sorting the resources in the PRC file so the smaller resources were listed first, you would make a PRC file that would be easier to install into the device. This is because the small resources would be placed in memory first, tending to fill in the small holes in memory, leaving the large unused sections for the larger resources at the end of the file. On modern devices with a unified storage heap, this isn't a problem.
Q: Where can I find out more about the PRC and PDB formats?
A: The Palm OS SDK comes with a document called "Palm File Format Spec.pdf". This describes the format of these files in detail. This document doesn't talk about how specific applications use PRC and PDB files to hold their information, however, so if you need to format of an application, you need to contact the application's authors or look at the source code and documentation for the application if available.
Ben Combee is the technical lead for the Metrowerks CodeWarrior for Palm OS Platform development tools. He lives in Austin, TX, where he spends his free time as a writer and technical advisor for the public access TV program "The Show With No Name".
