The filing of a bankruptcy stops foreclosure proceedings during the pendency of the bankruptcy. Sometimes bankruptcy is not the first line of defense against foreclosure. If you have been mistreated by the mortgage company, such a claim is best first presented in state court. If the foreclosure has just been filed, you need to speak to us immediately so that any state court ( non bankruptcy) defenses can be presented or at least preserved. If the mortgage company has already taken a judgment against you, it is possible that you allowed that to happen while being promised a loan modification. This also might require state court action.
Whatever the status of your foreclosure, bankruptcy provides a backstop should the assertion of your state court rights fail or be otherwise impractical.