Solar coronal shocks are very common phenomena in the solar atmosphere and are believed to be the drivers of solar type II radio bursts. However, the microphysical nature of these emissions is still an open question. This paper proposes that electron cyclotron maser (ECM) emission is responsible for the generation of radiation from the coronal shocks. In the present model, an energetic ion beam accelerated by the shock first excites the Alfven wave (AW), then the excited AW leads to the formation of a density-depleted duct along the foreshock boundary of the shock. In this density-depleted duct, the energetic electron beam produced via the shock acceleration can effectively excite radio emission by ECM instability. Our results show that this model may potentially be applied to solar type II radio bursts.