  We present one-dimensional models of the hot gas in dark-matter halos, which
both predict the existence of cool cores and explain their structure. Our
models are directly applicable to semi-analytic models (SAMs) of galaxy
formation. We have previously argued that filaments of cold (~10^4 K) gas
condense out of the intracluster medium (ICM) in hydrostatic and thermal
equilibrium when the ratio of the thermal instability timescale to the
free-fall time $t_{TI}/t_{ff}$ falls below 5-10. This criterion corresponds to
an upper limit on the density of the ICM and motivates a model in which a
density core forms wherever $t_{TI}/t_{ff} \lesssim 10$. Consistent with
observations and numerical simulations, this model predicts larger and more
tenuous cores for lower-mass halos---while the core density in a cluster may be
as large as ~ 0.1 cm^{-3}, the core density in the Galactic halo should not
exceed ~ 10^{-4} cm^{-3}. We can also explain the large densities in smaller
mass halos (galactic `coronae') if we include the contribution of the central
galaxy to the gravitational potential. Our models produce a favorable match to
the observational X-ray luminosity-temperature (Lx-Tx) relation. For halo
masses $\lesssim 10^{13}$ Msun the core size approaches the virial radius.
Thus, most of the baryons in such halos cannot be in the hot ICM, but either in
the form of stars or in the form of hot gas beyond the virial radius. Because
of the smaller mass in the ICM and much larger mass available for star
formation, the majority of the baryons in low mass halos ($\lesssim 10^{13}$
Msun) can be expelled beyond the virial radius due to supernova feedback. This
can account for the baryons `missing' from low mass halos, such as the Galactic
halo.
