We consider the risk model with capital injections studied by Nie et al. (Ann Actuar Sci 5:195–209, 2011; Scand Actuar J 2015:301–318, 2015). We construct a Gerber–Shiu function and show that whilst this tool is not efficient for finding the ultimate ruin probability, it provides an effective way of studying ruin related quantities in finite time. In particular, we find a general expression for the joint distribution of the time of ruin and the number of claims until ruin, and find an extension of Prabhu’s (Ann Math Stat 32:757–764, 1961) formula for the finite time survival probability in the classical risk model. We illustrate our results in the case of exponentially distributed claims and obtain some interesting identities. In particular, we generalise results from the classical risk model and prove the identity of two known formulae for that model.