I meet with many people who ask me whether they can legalize their status based on their residence in the United States. Unfortunately, the only law that currently exists like that requires residence in the United States since 1972, so these cases are rare.
The confusion seems to stem from a different law that applies to someone in deportation proceedings only, called cancellation of removal. An individual living in the United States without permission who appears before immigration judge may be eligible for this defense if he has continuously lived in the U.S. for at least 10 years, has been a person of good moral character, and whose U.S. citizen or permanent resident spouse, parent or child would suffer exceptionally and unusually extreme hardship in the event of deportation. This law applies only as a defense in immigration court and is not something one can apply for on your own. Only the Department of Homeland Security can put you in front of an immigration judge.
If immigration arrests you and you think you may be eligible for this defense, you should ask for a hearing before an immigration judge. You should not sign anything agreeing to your departure from the United States before seeing a judge. If you qualify to apply for this defense, the immigration service will grant you temporary work authorization while your case is pending. It usually takes about three years for the immigration judge to finalize your case, and you will have at least two hearings before the immigration judge. If you can show 10 years of residence from the time immigration arrested you and have no criminal record that disqualifies you, the hardest part in most of these cases is showing the required hardship to your family members, which is a very high standard.
It is extremely important to thoroughly document your case with items such as medical and school records, letters from family and friends, your own personal declaration about why you deserve permanent residence, proof of citizenship or residence for all your family members in the United States, articles about the violence in your home country, employment records, and tax returns. If you win your case, the judge can approve you for permanent residence. If you lose, the immigration judge can either order your deportation or grant you voluntary departure. Although not required, it is a good idea to hire a reputable immigration attorney to assist you.