Different states have different laws for taking someone's home, and although people commonly use the term foreclosure in all states, some states don't actually require foreclosure at all.
Foreclosure is a judicial proceeding, where the occupant of the home has an opportunity to be heard and the sale must be approved by the Court. Kansas is an example of a "Judicial Foreclosure" state.
Some states don't require a judicial proceeding. In states like Missouri, there is actually no mortage at all. Instead, there is a Deed of Trust, held by a Trustee. In order to take your home in missouri, the lender simply notifies you of a Trustee's Sale and sells your home. No court involvement is required.
File an Answer
If we've established that your state had judicial foreclosure, it is time to file an answer to the petition for foreclosure. Simply filing an answer forces the matter to be placed on a trial docket and slows the process down. If you choose, you can start the "discovery" process now and ask for accountings and signed notes.
Otherwise, you just wait for the attorneys on the other side to file a motion for summary judgment. Once they file that, you will have a statutory period of time in which to file an answer. Whether or not you file may not even be important. What is important is that you have probably already bought yourself two to three months of additional time before the sale of your home.
Work the Modification
If you are trying for a modification, you should be contacting the lender every day. Submit whatever paperwork they require, and everytime they tell you they don't have it, submit it again. Plan on spending tens of hours on the phone, (usually on hold), trying to move your modification forward. This is a long and arduous process, but if you don't stay on top of it, you will NEVER get a modification.
When All Else Fails
Before your house is sold, you may want to consider a bankruptcy. Chapter 7 or 13 will create an automatic "stay" on any proceedings against you. Of course, if you can't afford to keep the house the lender will file a motion to lift the stay and they will likely win. But, it can buy you more time, and may change your financial position enough to stay in the home.
If your house is sold in most states, that simply means that ownership has changed hands. You still have residential possession of the property, and like any renter, you can't be thrown out without an eviction. Some states even allow you to live in the property during the redemption period, (the statutory period of time in which you can redeem the home by paying it off). If you work with the eviction attorneys, they will often allow you to sign a "consent judgment" and negotiate a day to be out of the property.
Call an Attorney
The steps in a loan modification are not always that complicated. Knowing the system certainly helps, but you CAN do it on your own. The reason that many people hire an attorney to do it for them is that they simply don't have the time to spend on the phone, or aren't organized enough to get everything turned in.
On the other hand, the steps in defending foreclosure or filing bankruptcy are very difficult. Like most things under the law, you have the right to file on your own. But then, you probably have the right to give yourself cataract surgery, too. You just might not be that happy with the results.