To change CID and MID, we only need modify three file: misc, board_info and mfg. sdxx are not needed, because
/dev/block/bootdevice/by-name/misc -> /dev/block/sde1
/dev/block/bootdevice/by-name/board_info -> /dev/block/sdf1
/dev/block/bootdevice/by-name/mfg -> /dev/block/sdf2
misc for Software Version
board_info for CID
mfg for MID
Steps with TWRP:
0. Connect the phone to the PC and reboot to TWRP
adb reboot recovery
adb shell
you can also do the following steps with rooted android and busybox. In this way you need to add prefix "busybox " to dd
1. Check your original data
Software Version:
dd if=/dev/block/bootdevice/by-name/misc bs=1 skip=2208 count=11
CID:
dd if=/dev/block/bootdevice/by-name/board_info bs=1 skip=20 count=8
MID:
dd if=/dev/block/bootdevice/by-name/mfg bs=1 skip=16384 count=16
2. If the original data match your current value, then you can do the following step.
Just in case, back up the original file
dd if=/dev/block/bootdevice/by-name/misc of=/external_sd/misc.img
dd if=/dev/block/bootdevice/by-name/board_info of=/external_sd/board_info.img
dd if=/dev/block/bootdevice/by-name/mfg of=/external_sd/mfg.img
Set a lower version than your RUU which will be flashed.
printf 1.01.001.01 | dd conv=notrunc of=/dev/block/bootdevice/by-name/misc bs=1 seek=2208
or just clear it.
dd if=/dev/zero of=/dev/block/bootdevice/by-name/misc bs=1 seek=2208 count=11
Set your desired CID. (HTC__001 below)
printf HTC__001 | dd conv=notrunc of=/dev/block/bootdevice/by-name/board_info bs=1 seek=20
Set your desired MID. (2PZC1000 below) Please note that each character is separated by \x00
printf "2\x00P\x00Z\x00C\x001\x000\x000\x000\x00" | dd conv=notrunc of=/dev/block/bootdevice/by-name/mfg bs=1 seek=16384
3. Repeat commands in step 1 to check the result.
P.S.
If you got "dd: conv option disabled" in step 2, you need to download busybox to enable this feature.
download link
adb push ./busybox-armv8l /tmp/
adb shell "chmod 755 /tmp/busybox-armv8l;mv /tmp/busybox-armv8l /tmp/busybox"
then add prefix "/tmp/busybox " to all dd command.