How does iMazing reboot/shutdown iPhone remotely?

Solution 1:

The protocol used for communicating between the iOS device and the host program (such as for example iTunes) actually specifically allows for rebooting and shutting down the device.

You can find an open source and free implementation of the protocol called libimobiledevice here.

The library is a collection of many different tools. You'll need the one called idevicediagnostics so that you can run commands like:

idevicediagnostics reboot

idevicediagnostics shutdown

If you want to do this from your own program, you can find the source code for the idevicediagnostics program (that uses the library) here:

https://github.com/libimobiledevice/libimobiledevice/blob/master/tools/idevicediagnostics.c