Insert the tip of a pry bar between the underside of the siding piece directly above the flashing, and pry the siding away from the flashing just enough to access the flashing nails.
Remove the flashing nails by prying them out of the flashing with a claw hammer.
Pull the old flashing away from the window.
Remove any old caulking from the edge of the window frame by scraping the residue with a putty knife and wiping down the window edge with a damp paper towel.
Cut a new length of window flashing with metal snips, using the old flashing piece as a measuring tool.
Apply silicone caulk along the entire length of the window edge with a caulking gun.
Slide the new flashing under the shingle and press the flashing into the caulk.
Drive new flashing nails through each hole within the flashing to secure it in place.