The Thunbnail is in the EXIF header of the image, this header is at the beginning of JPEG files. Read the JPEG and EXIF data sheets for more info.
I know about the EXIF information and also that it is completely optional. I don't know if the Explorer respects this information, I think it would just create it's own thumbnail and stores it in thumbs.db like every other thumbnail.
Since XP SP2 (or even older) it does
respect this thumbnail, it does not shrink the image in full resolution, it searches for the smallest thumbnail in exif (there can be more than one!) but wich has greater or equal dimensions like the thumbnail to be created. Then it saves his own one in thumbs.db.