I still have some sources I wrote ages ago (1998), to search the hard disk for certain viruses (namely Tai-Pan, NPOX, Parity Boot B and Delwin) and to remove them. The sources can be found under
http://www.joachimrohde.com/cms/xoops/modules/mydownloads/visit.php?cid=2&lid=12 if you want to have a look.
They are written in Pascal and Assembly, comments are only available in German, but they are out-dated anyway.
When I wrote this little piece of code the book "Virus: Detection and Elimination" (
http://www.amazon.com/Virus-Detection-Elimination-Rune-Skardhamar/dp/012647690X/ref=sr_1_1?ie=UTF8&s=books&qid=1252077958&sr=8-1) was quite handy. It's full of (assembly) sources. There are a few other technical books which are newer, but I haven't read any of them, so I can't make any suggestions.
I guess you'll need a good understanding of reverse engineering (and thus of machine code & your decompiler) for analyzing the malware (The book "Know your enemy" comes in handy here). Writing the part to detect and remove the malware, will be peanuts.