The state legislature has passed a measure intended to counter a court ruling that made it easier for lenders to win cases against homeowners.