Re: how replace a function in data & program memory during running my code.(Using Mik
Usually bootloaders are designed to rewrite all of the application flash memory, except for the bootloader area itself. Cautious people are even protecting the bootloader area against unintended overwrite by hardware fuses and provide a safe recovery in case of bootloader failure.
Rewriting only part of the application is generally possible, but the memory layout has to consider it. The flash self rewrite feature is operating on erase block entities of the respective microprocessor. You have to care, that no other code is sharing the rewritten block of memory. Most PIC compilers have compiler commands for it, e.g. #org statements.