  The energy injected from dark matter annihilation and decay processes
potentially raises the ionisation of the intergalactic medium and leaves
visible footprints on the anisotropy maps of the cosmic microwave background
(CMB). Galactic foregrounds emission in the microwave bands contaminate the CMB
measurement and may affect the search for dark matter's signature. In this
paper, we construct a full CMB data and foreground simulation based on the
design of the next-generation ground-based CMB experiments. The foreground
residual after the components separation on maps is fully considered in our
data analysis, accounting for various contamination from the emission of
synchrotron, thermal dust, free-free and spinning dust. We analyse the
corresponding sensitivity on dark matter parameters from the temperature and
polarization maps, and we find that the CMB foregrounds leave a non-zero yet
controllable impact on the sensitivity. Comparing with statistics-only
analysis, the CMB foreground residual leads to a factor of at most 19%
weakening on energy-injection constraints, depending on the specific dark
matter process and experimental configuration. Strong limits on dark matter
annihilation rate and decay lifetime can be expected after foreground
subtraction.
