Programming a PIC with a PIC
I agree with what Wouter said.

I also sell PIC programmers on the side.  All the software and firmware for my programmers is included in the Development Software release at www.embedinc.com/picprg/sw.htm.  There is a lot of complexity there, but that is because this software/firmware has to support so many different programming algorithms.  Microchip's POD (Programming Obfuscation Division) has some very clever people that consistantly dream up new and different little things you have to do to program PICs.  Despite their best efforts though, it is still possible to program all the various PICs, but it requires a lot of digging and reading between the lines of the sometimes outright wrong documentation.  The software/firmware in that release would be vastly smaller if all PICs were programmed the same way.

Fortunately, your firmware can be specific to the particular PIC you are trying to program.  You have to get the programming spec and read it carefuly, but you can afford to ignore all the other programming specs.  You can probably make use of a bunch of lower level firmware modules I have, especially for the USBProg programmers.  That is the EUSB firmware, which also uses common files names PICPRG_xxx.INS.ASPIC.  All of that firmware is intended to run on a PIC 18, so much of it should be usable directly.

I usually have the programmer present roughly a address/read/write interface and have the host software deal with the higher levels.  Fortunately, the higher levels is the relatively easy part.  You will have to look in the host software for examples of the erase algorithms.  I push those onto the host since each one is run only once per programming operation, so speed is not a big issue.

Ask here if you have any more specific questions.