on most g40 ecus it's pretty easy, but some have no chip socket and have the eeprom chip soldered directly to the pcb. You wont know till you open it up.
undo the four screws that hold the plastic cover on the ECU, then slide off the cover revealing the PCB itself.
The chip lives underneath a metal rf shield. The shield is removed by pushing in two tabs, one on either side of it and then lifting it up. Now you'll see if the chip is in a socket or not. Here is a picture I found of underneath the shield:
The chip is the rectangle shaped IC.
If it's in a nice socket then just use a small flat blade screw driver to ease it out from end to end being careful not to bend any pins. Then push the new chip in place ensuring the legs are lining up. Be careful to put the chip in the same way round!!! Chips have a semi circle notch on one end so make sure this is on the same end as the chip you take out.
The main other thing to watch out for is static damage. I'll guess that you haven't got an anti-static wrist strap and earthing point so I'll just say don't do this while wearing a big woolly jumper or anything! Don't leave the ECU open for any longer than is absolutely necessary, get the shield back in place as soon as you can. Also try not to touch any of the components apart from the one(s) you absolutely have to (i.e. the chip itself).
If you find your chip is soldered directly to the PCB then it's a job for a professional really, or at least someone with a decent soldering iron and soldering skills. If this is the case I can do it for you for a few bob if you post it to me. Or someone like Andy from PPP possibly would too.