You have a huge problem.
First, paternity - given that NH apparently has jurisdiction (assuming that's where the current orders are from?) you would have to file there...and serve both parents. Since Legal Dad apparently wants to be Dad there's at least a chance that the court will allow him to remain so and might not even allow a challenge given the length of time that has passed. Do you have ANY idea what Mom actually wants, in terms of who she wants to be Dad?
Second, Mom's sentence - even if she serves the entire sentence there are two problems. First, if you file to establish paternity and file for custody, the chances of it being heard in court before Mom is released are slim at best. So she'll likely be out, and will likely want custody herself. Then, she'll be fighting a custody battle with her ex-husband who is the legal father and who will by that point have at least 6 months worth of status quo on his side.
This is a mess, and you absolutely need an attorney. First, one on NH (again assuming that's the state with jurisdiction), and possibly one in VA.
If the court will not order a DNA paternity test, it's case closed unfortunately - at best you might be able to file for visitation, but that's also sketchy.

