The structure of stars with massive envelopes (Menv ≥ 14 Msun) and degenerate neutron cores is discussed. In such stars, most of the luminosity arises from thermonuclear reactions taking place at the base of the convective envelope. The proton-rich material in this region, continuously linked to the outer regions by convection, provides an ideal site for the rp-process. In addition, material may repeatedly pass through the burning zone, with large intervals between each passage, allowing the formation of heavy nuclei up to A ̃ 150. Evolutionary calculations are presented of the structure of such stars and of the nucleosynthesis in their envelopes. A lower mass limit of 14 Msun is found for stars of this type. Assuming a lifetime of ≥ 105 yr, a significant fraction, ̃5 per cent, of the envelope mass is converted to metals beyond iron, and, for a restricted range of masses (depending on the somewhat uncertain details of envelope convection), some of the p-nuclei are produced in relative abundances reminiscent of those found for the Solar system. The abundance peak at molybdenum is, however, not reproduced. If Thorne-Żytkow objects are a later stage in the evolution of massive X-ray binaries then, even if only a small fraction of Thorne-Żytkow objects produce the more massive p-nuclei, the progenitor population is sufficiently large to account for the observed abundances of some of these nuclei.