Residues of Eisenstein series and generalized Shalika models for SO4n