a) Underexposed images: set the blending mode of this duplicate layer to screen to lighten the image
b) Overexposed images: set the blending mode of the new layer to multiply to darken the image
2. If step 2 is not enough just repeat it and lower the opacity of that layer until it looks good.