I was checking out the newish website StackOverflow.com, where you can post up technical questions, and other programmers answer them. Its actually fun, cause you can earn reputation points and ‘badges’ for answering questions and whatnot.
At any rate, I posted up this question about how to modify the age of a pdb file. I asked because our build process has been broken for a number of years, such that we were generating .PDB file that didn’t match the corresponding DLLs. It was an unfortuate side effect of having bad dependencies causing our application to relink when it didn’t need to. After each release engineering build target there is a packaging step that gathers the images (dlls and exes) needed for that target. However, the PDBs aren’t gathered until the end. Therefore, if an image was relinked between those two times, the newly relinked pdb and the original dll would be off by a few hours.
This could be worked around by using the .symopt +0×40 option in windbg. It forced the pdbs to work properly. However, they would not work in VisualStudio. Also, it meant we couldn’t run a symbol server, because with +0×40 it would just grab the first pdb of that name it found.
The great news is that I got an answer on stackoverflow! I was pointed to this site http://undocumented.rawol.com/ which contains the pdfs of the fantastic out of print book called “Undocumented Windows 2000 Secrets: A Programmers Cookbook”. The author goes into great detail about the PDB file format, and includes code samples. He even updated the website to include information about version 7.0 (what VisualStudio 2003 uses).
So how do you do it? There are potentially 3 places that contain age & signature information that need to match the corresponding image (dll or exe) file. Two of them are easy to find, because the signature is very recognizable. It is in the header of the file, and easily picked out with a hex editor. I even found this before I was pointed to the book website. In fact, the second reference, near the end of the file, is also a signature&age combination, so it is fairly easy to find as well. However, the last one is TRICKY. Each PDB file is a compound file, and is split into ’streams’. Each stream contains specific information. The 3rd stream contains a reference to the age, but not the signature. Since the age is only a simple 4byte integer value, it is very difficult to pick out on its own! But once I knew where to look, it was easy. I have modified a few releases by hand, but I hope to write a program to automate the process.