// blog

Reading a File Format Nobody Documented: Getting Data Out of an Old Program

When an old program’s data is in a format nobody documented, the program itself is the documentation. We disassembled Virtual Salesman 3’s executable, matched its calls to the published source, and found the scrambling: a 4-byte seed, then every value shifted by a key built from the seed and a 1,024-entry table inside the program. A decoder that leaves no byte unread on every sample file, and totals that match the program’s own to the bit, prove the format is right.

Last updated 2 min read

A hex dump of an old data file, marked with question marks

The hardest part of moving an old program to the web is often not the screens. It’s the data. Virtual Salesman 3, a Delphi program from 2006, saved each company, inventory and document as its own binary file, and the files were scrambled.

The program’s source is public, but one unit was missing: EncryptedFile, the code that reads and writes those files. Without it the program can’t even be compiled. So the format had to come from the program itself.

1. Start from what you know

The source shows what each file holds, in order: ReadString for the file type, ReadInteger for the version, then the fields. And we knew the first value of a transaction file is the text VV3Transaction. That’s a known plaintext: something to look for.

2. Read the program

A disassembler (we used LLVM’s objdump, which reads Windows programs too) turns VS3.exe back into machine instructions. Searching for the text VV3Transaction led to the code that loads a transaction, and its calls lined up one for one with the source: read a string, read an integer, read a float. From there, the read functions themselves.

3. The scrambling

  • The file starts with a 4-byte seed.
  • Every value after it is a 4-byte number, shifted by a key.
  • The key is half the seed, rounded the way Delphi rounds (halves go to the even number), plus the next entry of a 1,024-entry table stored inside the program.
  • Text is a length, then one number per character, in the Windows-1252 code page. Money and dates are the 32 bits of a Delphi Single.

4. Prove it

A guess that decodes the first few values isn’t enough. Three checks made it certain:

  • Nothing left over. All 9 sample files in the repository decode to their last byte, with no byte unread and none missing.
  • The text makes sense. Names with accents come out right: “Marc-André”, “Votre numéro federal”.
  • The numbers agree. Recomputing each document’s totals with the program’s own arithmetic gives exactly the bits it saved.

5. Make it part of the product

The decoder became the web version’s importer. Upload the old files and it reads them, repairs what it can (like counters that fell behind), cuts card numbers to their last four digits, and reports what it did. A damaged file is listed and left out, not half imported.

Most old programs keep their data somewhere easier: an Access database, Paradox tables, a local SQL Server. Even when they don’t, the data can be got out. The case study has the decoding code, and the importer is on the web version’s Import page. Stuck with data in an old format? Tell us about it.