First off, don't confuse replacing an ECM with repairing one. The end result might be the same -- you can drive your car again, after all -- but engine control modules and units do sometimes go bad, and they aren't really designed to be repaired -- at least, not by the owner or by an average mechanic. It shouldn't be too hard to swap out a faulty ECM for a new one, but that's about as user-friendly as this process can get. Quite simply, it takes specialized knowledge and specific tools to repair, not replace, an ECM.
Actually repairing an ECM requires disassembling the unit and performing some pretty detailed, precision-critical electronics work. It's similar to repairing the motherboard in a desktop computer -- assuming it can be repaired it all. Some experts recommend removing and opening the unit, and sniffing around for the telltale signs of electrical damage (if you've never smelled it before, consider yourself lucky -- but you'll probably still be able to identify the chemical tang of burned metal). Also, if there is any corrosion from acid or moisture damage, it'll probably be easily visible. If you're not planning to do the repairs yourself, the only benefit to this step is that you'll know you're on the right track with your diagnosis. That said, the absence of such evidence does not mean the ECM is fine. Got that?
Your options are to buy a new ECM, or send in your old one and wait for it to be repaired (and you can probably guess which one costs less). So even if you or your mechanic suspects the ECM might be the source of your trouble, you should troubleshoot and eliminate all other potential problems before pulling the ECM and installing a new one. Replacement can cost anywhere from several hundred to several thousand dollars, and can be made more complicated (and expensive) if the ECM has to be modified to accommodate security systems, smart keys, immobilizers, or anything else electronic that is specifically configured to your car. And don't forget that many ECM repair services are happy to return a unit they determine is beyond repair (if certain areas of the processor have been damaged, vital data cannot be retrieved). This might seem baffling at first -- you might wonder what purpose a completely fried ECM could possibly serve -- but remember that the unit stores all kinds of personal data from your car, which some people might not want left hanging around forever in some random warehouse.
It's worth noting that, just as a bad ECM can cause all sorts of electrical problems, the inverse is also true -- faulty or malfunctioning sensors can actually damage your ECM. That's another argument in favor of following a thorough troubleshooting procedure before assuming the source of a problem. If you know you have a faulty sensor or two, get them replaced as soon as possible.