libimobiledevice-win32 / imobiledevice-net

.NET (C#, VB.NET,...) bindings for libimobiledevice
GNU Lesser General Public License v2.1
305 stars 76 forks source link

exit recovery api #149

Closed oznotes closed 4 years ago

oznotes commented 4 years ago

I'm trying to make the exit recovery mode work in C#

considering how it is done in irecovery.exe : https://github.com/libimobiledevice/libirecovery/blob/master/tools/irecovery.c

tihs is where it happens in C Code . I have converted this C code into C# and applied it wont work.


irecv_client_t client = NULL;

    for (i = 0; i <= 5; i++) {
        debug("Attempting to connect... \n");

        irecv_error_t err = irecv_open_with_ecid(&client, ecid);
        if (err == IRECV_E_UNSUPPORTED) {
            fprintf(stderr, "ERROR: %s\n", irecv_strerror(err));
            return -1;
        }
        else if (err != IRECV_E_SUCCESS)
            sleep(1);
        else
            break;

        if (i == 5) {
            fprintf(stderr, "ERROR: %s\n", irecv_strerror(err));
            return -1;
        }

irecv_device_t device = NULL;
irecv_devices_get_device_by_client(client, &device);
irecv_setenv(client, "auto-boot", "true");

only thing i dont have is ecid and it is 0 maybe proper ecid is not given, going through C code wont get the ecid as well it is set ulong ecid = 0;

even though it wont work each api call will return success , any recommendation ?

WHots commented 4 years ago

var recoverydevice = LibiMobileDevice.Instance.Recovery;

RecoveryClientHandle recoveryClientHandle = null; RecoveryDeviceHandle recoveryDeviceHandle = null;

ulong ecid = 0;

recoverydevice.irecv_open_with_ecid(out recoveryClientHandle, ecid); recoverydevice.irecv_devices_get_device_by_client(recoveryClientHandle, out recoveryDeviceHandle);

recoverydevice.irecv_setenv(recoveryClientHandle, "auto-boot", "true"); recoverydevice.irecv_saveenv(recoveryClientHandle);

recoverydevice.irecv_reboot(recoveryClientHandle);

This works for me.

oznotes commented 4 years ago

Yes , Worked pretty neat .

WHots commented 4 years ago

On Thu, Jul 23, 2020 at 12:38 PM Oz notifications@github.com wrote:

Yes , Worked pretty neat .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/libimobiledevice-win32/imobiledevice-net/issues/149#issuecomment-663139075, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANO7WTFGTRKHPGJBVRV2KKTR5BYQHANCNFSM4NHCIPGQ .

Hey, you have any code examples of shutting down & reboot the devices ?