Reading The Palm Desktop Files

A project I took on was to access the Windows DAT files created by the Palm Desktop software. Not being particularly familiar with C programming, I choose to approach the problem with a combination of QBasic and Perl programming.

The starting point was to find out the data structure of the files. A great beginning was Nico Seessle's page on the subject. The specifications Nico documented are pretty close to structure that I found by examining the files. Some minor differences were found, likely due to revisions to the desktop software. The bigger issues were figuring out how to read and interpret the storage structures.


The Cstring storage format is pretty straightforward;

Visually, a sixteen byte string "this is a string" would be stored as follows

Offset      Value   Description

    0          0x10    Hex string length of 16
    1          this is a string  

For a longer (over 254 bytes) string, it would look like this

Offset      Value   Description

    0          0xFF     Flag, string over 254 bytes
    1          0x012C Short, dec val 300
    3          a very long string of 300 characters...

The following Perl code will read a Cstring correctly:

read (ADDR, $length, 1) or die "unable to read $1\n";
  $length = unpack ("C", $length);
  if ($length == 0xFF) {
      read (ADDR, $length, 2) or die "unable to read$1\n";
      $length = unpack ("s", $length);
  read (ADDR, $string, $length) or 
        die "unable to read$1\n" unless ($length == 0);

The following QBasic example program reads the memopad.dat file. This program has to deal with the issues of;

  1. converting the shorts and longs to a usable form
  2. reading Cstrings

Pay particular attention to the GetShort, GetLong, GetStrg routines at the end... they are the key. Also, note that the shorts and longs are stored in memopad.dat in least significant to most significant byte order, i.e., the long value for integer 1 is stored as

Shorts are the same way, integer 1 would be stored as

The conversion routines in memopad.bas take this into account. Be aware that longs can have a value that ranges from 0 to 4,294,967,295 so you need to make sure that the data type you use in your chosen language supports a number that large.