The possibility to use $gamma$--ray data from the Galactic Center (GC) to constrain the cosmological evolution of the Universe in a phase prior to primordial nucleosyntesis, namely around the time of cold dark matter (CDM) decoupling, is analyzed. The basic idea is that in a modified cosmological scenario, where the Hubble expansion rate is enhanced with respect to the standard case, the CDM decoupling is anticipated and the relic abundance of a given dark matter (DM) candidate enhanced. This implies that the present amount of CDM in the Universe may be explained by a Weakly Interacting Massive Particle (WIMP) which possesses annihilation cross section (much) larger than in standard cosmology. This enhanced annihilation implies larger fluxes of indirect detection signals of CDM. We show that the HESS measurements can set bounds for WIMPs heavier than a few hundreds of GeV, depending on the actual DM halo profile. These results are complementary to those obtained in a previous analysis based on cosmic antiprotons. For a Moore DM profile, $gamma$--ray data limit the maximal Hubble rate enhancement to be below a factor of 100. Moreover, a WIMP heavier than 1 TeV is not compatible with a cosmological scenario with enhanced expansion rate prior to Big Bang Nucleosynthesis (BBN). Less steep DM profiles provide less stringent bounds, depending of the cosmological scenario.