I have done a lot of bootloader work. Unfortunately, I can't make very much of it public for various reasons.

So, even though I can't post any real code, I *can* tell you how I did it.

As it stands, my modified code simply prevents READS or WRITES by MCLoader unless the bootloader is "unlocked" under program control (or by the user through the serial or a net port). Once unlocked, it can be programmed on the next power up - only. After programming, the code locks the bootloader again. If the user fails to program it during that one power up cycle, it locks itself.

If your chip has more than 64K bytes of FLASH, then you will either have to write an assembly routine to write to the upper half, or else modify PBPPIC18.LIB to give you that access since ERASECODE and WRITECODE do not work above 0xffff.

If any one is interested, I'll post the technique.