In the compound Poisson insurance risk model under a dividend barrier strategy, this paper aims to analyze jointly the aggregate discounted claim amounts until ruin and the total discounted dividends until ruin, which represent the insurer's payments to its policyholders and shareholders, respectively. To this end, we introduce a Gerber-Shiu-type function, which further incorporates the higher moments of these two quantities. This not only unifies the individual study of various ruin-related quantities, but also allows for new measures concerning covariances to be calculated. The integro-differential equation satisfied by the generalized Gerber-Shiu function and the boundary condition are derived. In particular, when the claim severity is distributed as a combination of exponentials, explicit expressions for this Gerber-Shiu function in some special cases are given. Numerical examples involving the covariances between any two of (i) the aggregate discounted claims until ruin, (ii) the discounted dividend payments until ruin and (iii) the time of ruin are presented along with some interpretations.