Use a tool like Partitions Backup to make an image of your efs , modem , and persist partitions. Step-by-Step: IMEI Repair Magisk Verified Method
If you are having trouble, tell me what device and chipset you have, and I can suggest a more tailored method.
This occurs during custom ROM flashing, downgrading firmware, or accidental partition wipes (specifically the EFS or NVRAM partitions). The device displays an "Invalid IMEI," "IMEI 0," or "Null" status, losing all network connectivity.
: He patched his boot image using topjohnwu’s Magisk , giving him the MagiskSU needed to write to the device’s protected EFS partition.