Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 20th, 2012  |  syntax: None  |  size: 21.38 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ## syslog.c
  2. #include "MobileDevice.h"
  3. #include <assert.h>
  4.  
  5. static void cb(am_device_notification_callback_info *info, void *foo) {
  6.     struct am_device *dev;
  7.     CFStringRef error;
  8.     printf("... %x\n", info->msg);
  9.     if(info->msg == ADNCI_MSG_CONNECTED) {
  10.         dev = info->dev;
  11.         afc_connection *socket = NULL;
  12.         AMDeviceConnect(dev);
  13.         assert(AMDeviceIsPaired(dev));
  14.         assert(AMDeviceValidatePairing(dev) == 0);
  15.         assert(AMDeviceStartSession(dev) == 0);
  16.         AMDeviceStartService(dev, CFSTR("com.apple.syslog_relay"), (void*)&socket, NULL);
  17.         printf("socket=%p\n", socket);
  18.         char c;
  19.         while(recv((int) socket, &c, 1, 0) == 1) {
  20.             if(c != 0)
  21.                 putchar(c);
  22.         }
  23.     }
  24. }
  25. int main(int argc, char **argv) {
  26.     am_device_notification *notif;
  27.     int ret = AMDeviceNotificationSubscribe(cb, 0, 0, NULL, &notif);
  28.     CFRunLoopRun();
  29. }
  30. ## MobileDevice.h
  31. /* ----------------------------------------------------------------------------
  32.  *   MobileDevice.h - interface to MobileDevice.framework
  33.  *   $LastChangedDate: 2007-07-09 18:59:29 -0700 (Mon, 09 Jul 2007) $
  34.  *
  35.  * Copied from http://iphonesvn.halifrag.com/svn/iPhone/
  36.  * With modifications from Allen Porter and Scott Turner
  37.  *
  38.  * ------------------------------------------------------------------------- */
  39.  
  40. #ifndef MOBILEDEVICE_H
  41. #define MOBILEDEVICE_H
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47. #if defined(WIN32)
  48. #include <CoreFoundation.h>
  49. typedef unsigned int mach_error_t;
  50. #elif defined(__APPLE__)
  51. #include <CoreFoundation/CoreFoundation.h>
  52. #include <mach/error.h>
  53. #endif 
  54.  
  55. /* Error codes */
  56. #define MDERR_APPLE_MOBILE  (err_system(0x3a))
  57. #define MDERR_IPHONE        (err_sub(0))
  58.  
  59. /* Apple Mobile (AM*) errors */
  60. #define MDERR_OK                ERR_SUCCESS
  61. #define MDERR_SYSCALL           (ERR_MOBILE_DEVICE | 0x01)
  62. #define MDERR_OUT_OF_MEMORY     (ERR_MOBILE_DEVICE | 0x03)
  63. #define MDERR_QUERY_FAILED      (ERR_MOBILE_DEVICE | 0x04)
  64. #define MDERR_INVALID_ARGUMENT  (ERR_MOBILE_DEVICE | 0x0b)
  65. #define MDERR_DICT_NOT_LOADED   (ERR_MOBILE_DEVICE | 0x25)
  66.  
  67. /* Apple File Connection (AFC*) errors */
  68. #define MDERR_AFC_OUT_OF_MEMORY 0x03
  69.  
  70. /* USBMux errors */
  71. #define MDERR_USBMUX_ARG_NULL   0x16
  72. #define MDERR_USBMUX_FAILED     0xffffffff
  73.  
  74. /* Messages passed to device notification callbacks: passed as part of
  75.  * am_device_notification_callback_info. */
  76. #define ADNCI_MSG_CONNECTED     1
  77. #define ADNCI_MSG_DISCONNECTED  2
  78. #define ADNCI_MSG_UNKNOWN       3
  79.  
  80. #define AMD_IPHONE_PRODUCT_ID   0x1290
  81. #define AMD_IPHONE_SERIAL       "3391002d9c804d105e2c8c7d94fc35b6f3d214a3"
  82.  
  83. /* Services, found in /System/Library/Lockdown/Services.plist */
  84. #define AMSVC_AFC                   CFSTR("com.apple.afc")
  85. #define AMSVC_BACKUP                CFSTR("com.apple.mobilebackup")
  86. #define AMSVC_CRASH_REPORT_COPY     CFSTR("com.apple.crashreportcopy")
  87. #define AMSVC_DEBUG_IMAGE_MOUNT     CFSTR("com.apple.mobile.debug_image_mount")
  88. #define AMSVC_NOTIFICATION_PROXY    CFSTR("com.apple.mobile.notification_proxy")
  89. #define AMSVC_PURPLE_TEST           CFSTR("com.apple.purpletestr")
  90. #define AMSVC_SOFTWARE_UPDATE       CFSTR("com.apple.mobile.software_update")
  91. #define AMSVC_SYNC                  CFSTR("com.apple.mobilesync")
  92. #define AMSVC_SCREENSHOT            CFSTR("com.apple.screenshotr")
  93. #define AMSVC_SYSLOG_RELAY          CFSTR("com.apple.syslog_relay")
  94. #define AMSVC_SYSTEM_PROFILER       CFSTR("com.apple.mobile.system_profiler")
  95.  
  96. typedef unsigned int afc_error_t;
  97. typedef unsigned int usbmux_error_t;
  98. typedef unsigned int service_conn_t;
  99.  
  100. struct am_recovery_device;
  101.  
  102. typedef struct am_device_notification_callback_info {
  103.     struct am_device *dev;  /* 0    device */
  104.     unsigned int msg;       /* 4    one of ADNCI_MSG_* */
  105. } __attribute__ ((packed)) am_device_notification_callback_info;
  106.  
  107. /* The type of the device restore notification callback functions.
  108.  * TODO: change to correct type. */
  109. typedef void (*am_restore_device_notification_callback)(struct
  110.     am_recovery_device *);
  111.  
  112. /* This is a CoreFoundation object of class AMRecoveryModeDevice. */
  113. typedef struct am_recovery_device {
  114.     unsigned char unknown0[8];                          /* 0 */
  115.     am_restore_device_notification_callback callback;   /* 8 */
  116.     void *user_info;                                    /* 12 */
  117.     unsigned char unknown1[12];                         /* 16 */
  118.     unsigned int readwrite_pipe;                        /* 28 */
  119.     unsigned char read_pipe;                            /* 32 */
  120.     unsigned char write_ctrl_pipe;                      /* 33 */
  121.     unsigned char read_unknown_pipe;                    /* 34 */
  122.     unsigned char write_file_pipe;                      /* 35 */
  123.     unsigned char write_input_pipe;                     /* 36 */
  124. } __attribute__ ((packed)) am_recovery_device;
  125.  
  126. /* A CoreFoundation object of class AMRestoreModeDevice. */
  127. typedef struct am_restore_device {
  128.     unsigned char unknown[32];
  129.     int port;
  130. } __attribute__ ((packed)) am_restore_device;
  131.  
  132. /* The type of the device notification callback function. */
  133. typedef void(*am_device_notification_callback)(struct
  134.     am_device_notification_callback_info *, void* arg);
  135.  
  136. /* The type of the _AMDDeviceAttached function.
  137.  * TODO: change to correct type. */
  138. typedef void *amd_device_attached_callback;
  139.  
  140.  
  141. typedef struct am_device {
  142.     unsigned char unknown0[16]; /* 0 - zero */
  143.     unsigned int device_id;     /* 16 */
  144.     unsigned int product_id;    /* 20 - set to AMD_IPHONE_PRODUCT_ID */
  145.     char *serial;               /* 24 - set to AMD_IPHONE_SERIAL */
  146.     unsigned int unknown1;      /* 28 */
  147.     unsigned char unknown2[4];  /* 32 */
  148.     unsigned int lockdown_conn; /* 36 */
  149.     unsigned char unknown3[8];  /* 40 */
  150. } __attribute__ ((packed)) am_device;
  151.  
  152. typedef struct am_device_notification {
  153.     unsigned int unknown0;                      /* 0 */
  154.     unsigned int unknown1;                      /* 4 */
  155.     unsigned int unknown2;                      /* 8 */
  156.     am_device_notification_callback callback;   /* 12 */
  157.     unsigned int unknown3;                      /* 16 */
  158. } __attribute__ ((packed)) am_device_notification;
  159.  
  160. typedef struct afc_connection {
  161.     unsigned int handle;            /* 0 */
  162.     unsigned int unknown0;          /* 4 */
  163.     unsigned char unknown1;         /* 8 */
  164.     unsigned char padding[3];       /* 9 */
  165.     unsigned int unknown2;          /* 12 */
  166.     unsigned int unknown3;          /* 16 */
  167.     unsigned int unknown4;          /* 20 */
  168.     unsigned int fs_block_size;     /* 24 */
  169.     unsigned int sock_block_size;   /* 28: always 0x3c */
  170.     unsigned int io_timeout;        /* 32: from AFCConnectionOpen, usu. 0 */
  171.     void *afc_lock;                 /* 36 */
  172.     unsigned int context;           /* 40 */
  173. } __attribute__ ((packed)) afc_connection;
  174.  
  175. typedef struct afc_directory {
  176.     unsigned char unknown[0];   /* size unknown */
  177. } __attribute__ ((packed)) afc_directory;
  178.  
  179. typedef struct afc_dictionary {
  180.     unsigned char unknown[0];   /* size unknown */
  181. } __attribute__ ((packed)) afc_dictionary;
  182.  
  183. typedef unsigned long long afc_file_ref;
  184.  
  185. typedef struct usbmux_listener_1 {                  /* offset   value in iTunes */
  186.     unsigned int unknown0;                  /* 0        1 */
  187.     unsigned char *unknown1;                /* 4        ptr, maybe device? */
  188.     amd_device_attached_callback callback;  /* 8        _AMDDeviceAttached */
  189.     unsigned int unknown3;                  /* 12 */
  190.     unsigned int unknown4;                  /* 16 */
  191.     unsigned int unknown5;                  /* 20 */
  192. } __attribute__ ((packed)) usbmux_listener_1;
  193.  
  194. typedef struct usbmux_listener_2 {
  195.     unsigned char unknown0[4144];
  196. } __attribute__ ((packed)) usbmux_listener_2;
  197.  
  198. typedef struct am_bootloader_control_packet {
  199.     unsigned char opcode;       /* 0 */
  200.     unsigned char length;       /* 1 */
  201.     unsigned char magic[2];     /* 2: 0x34, 0x12 */
  202.     unsigned char payload[0];   /* 4 */
  203. } __attribute__ ((packed)) am_bootloader_control_packet;
  204.  
  205. /* ----------------------------------------------------------------------------
  206.  *   Public routines
  207.  * ------------------------------------------------------------------------- */
  208.  
  209. void AMDSetLogLevel(int level);
  210.  
  211. /*  Registers a notification with the current run loop. The callback gets
  212.  *  copied into the notification struct, as well as being registered with the
  213.  *  current run loop. dn_unknown3 gets copied into unknown3 in the same.
  214.  *  (Maybe dn_unknown3 is a user info parameter that gets passed as an arg to
  215.  *  the callback?) unused0 and unused1 are both 0 when iTunes calls this.
  216.  *  In iTunes the callback is located from $3db78e-$3dbbaf.
  217.  *
  218.  *  Returns:
  219.  *      MDERR_OK            if successful
  220.  *      MDERR_SYSCALL       if CFRunLoopAddSource() failed
  221.  *      MDERR_OUT_OF_MEMORY if we ran out of memory
  222.  */
  223.  
  224. mach_error_t AMDeviceNotificationSubscribe(am_device_notification_callback
  225.     callback, unsigned int unused0, unsigned int unused1, void* //unsigned int
  226.     dn_unknown3, struct am_device_notification **notification);
  227.  
  228. /*  Connects to the iPhone. Pass in the am_device structure that the
  229.  *  notification callback will give to you.
  230.  *
  231.  *  Returns:
  232.  *      MDERR_OK                if successfully connected
  233.  *      MDERR_SYSCALL           if setsockopt() failed
  234.  *      MDERR_QUERY_FAILED      if the daemon query failed
  235.  *      MDERR_INVALID_ARGUMENT  if USBMuxConnectByPort returned 0xffffffff
  236.  */
  237.  
  238. mach_error_t AMDeviceConnect(struct am_device *device);
  239.  
  240. /*  Calls PairingRecordPath() on the given device, than tests whether the path
  241.  *  which that function returns exists. During the initial connect, the path
  242.  *  returned by that function is '/', and so this returns 1.
  243.  *
  244.  *  Returns:
  245.  *      0   if the path did not exist
  246.  *      1   if it did
  247.  */
  248.  
  249. int AMDeviceIsPaired(struct am_device *device);
  250.  
  251. /*  iTunes calls this function immediately after testing whether the device is
  252.  *  paired. It creates a pairing file and establishes a Lockdown connection.
  253.  *
  254.  *  Returns:
  255.  *      MDERR_OK                if successful
  256.  *      MDERR_INVALID_ARGUMENT  if the supplied device is null
  257.  *      MDERR_DICT_NOT_LOADED   if the load_dict() call failed
  258.  */
  259.  
  260. mach_error_t AMDeviceValidatePairing(struct am_device *device);
  261.  
  262. /*  Creates a Lockdown session and adjusts the device structure appropriately
  263.  *  to indicate that the session has been started. iTunes calls this function
  264.  *  after validating pairing.
  265.  *
  266.  *  Returns:
  267.  *      MDERR_OK                if successful
  268.  *      MDERR_INVALID_ARGUMENT  if the Lockdown conn has not been established
  269.  *      MDERR_DICT_NOT_LOADED   if the load_dict() call failed
  270.  */
  271.  
  272. mach_error_t AMDeviceStartSession(struct am_device *device);
  273.  
  274. /* Starts a service and returns a handle that can be used in order to further
  275.  * access the service. You should stop the session and disconnect before using
  276.  * the service. iTunes calls this function after starting a session. It starts
  277.  * the service and the SSL connection. unknown may safely be
  278.  * NULL (it is when iTunes calls this), but if it is not, then it will be
  279.  * filled upon function exit. service_name should be one of the AMSVC_*
  280.  * constants. If the service is AFC (AMSVC_AFC), then the handle is the handle
  281.  * that will be used for further AFC* calls.
  282.  *
  283.  * Returns:
  284.  *      MDERR_OK                if successful
  285.  *      MDERR_SYSCALL           if the setsockopt() call failed
  286.  *      MDERR_INVALID_ARGUMENT  if the Lockdown conn has not been established
  287.  */
  288.  
  289. mach_error_t AMDeviceStartService(struct am_device *device, CFStringRef
  290.     service_name, service_conn_t *handle, unsigned int *
  291.     unknown);
  292.  
  293. mach_error_t AMDeviceStartHouseArrestService(struct am_device *device, CFStringRef identifier, void *unknown, service_conn_t *handle, unsigned int *what);
  294.  
  295. /* Stops a session. You should do this before accessing services.
  296.  *
  297.  * Returns:
  298.  *      MDERR_OK                if successful
  299.  *      MDERR_INVALID_ARGUMENT  if the Lockdown conn has not been established
  300.  */
  301.  
  302. mach_error_t AMDeviceStopSession(struct am_device *device);
  303.  
  304. /* Opens an Apple File Connection. You must start the appropriate service
  305.  * first with AMDeviceStartService(). In iTunes, io_timeout is 0.
  306.  *
  307.  * Returns:
  308.  *      MDERR_OK                if successful
  309.  *      MDERR_AFC_OUT_OF_MEMORY if malloc() failed
  310.  */
  311.  
  312. afc_error_t AFCConnectionOpen(service_conn_t handle, unsigned int io_timeout,
  313.     struct afc_connection **conn);
  314.  
  315. /* Pass in a pointer to an afc_device_info structure. It will be filled. */
  316. afc_error_t AFCDeviceInfoOpen(afc_connection *conn, struct
  317.     afc_dictionary **info);
  318.  
  319. /* Turns debug mode on if the environment variable AFCDEBUG is set to a numeric
  320.  * value, or if the file '/AFCDEBUG' is present and contains a value. */
  321. void AFCPlatformInit();
  322.  
  323. /* Opens a directory on the iPhone. Pass in a pointer in dir to be filled in.
  324.  * Note that this normally only accesses the iTunes sandbox/partition as the
  325.  * root, which is /var/root/Media. Pathnames are specified with '/' delimiters
  326.  * as in Unix style.
  327.  *
  328.  * Returns:
  329.  *      MDERR_OK                if successful
  330.  */
  331.  
  332. afc_error_t AFCDirectoryOpen(afc_connection *conn, const char *path,
  333.                              struct afc_directory **dir);
  334.  
  335. /* Acquires the next entry in a directory previously opened with
  336.  * AFCDirectoryOpen(). When dirent is filled with a NULL value, then the end
  337.  * of the directory has been reached. '.' and '..' will be returned as the
  338.  * first two entries in each directory except the root; you may want to skip
  339.  * over them.
  340.  *
  341.  * Returns:
  342.  *      MDERR_OK                if successful, even if no entries remain
  343.  */
  344.  
  345. afc_error_t AFCDirectoryRead(afc_connection *conn/*unsigned int unused*/, struct afc_directory *dir,
  346.     char **dirent);
  347.  
  348. afc_error_t AFCDirectoryClose(afc_connection *conn, struct afc_directory *dir);
  349. afc_error_t AFCDirectoryCreate(afc_connection *conn, const char *dirname);
  350. afc_error_t AFCRemovePath(afc_connection *conn, const char *dirname);
  351. afc_error_t AFCRenamePath(afc_connection *conn, const char *from, const char *to);
  352. afc_error_t AFCLinkPath(afc_connection *conn, long long int linktype, const char *target, const char *linkname);
  353.  
  354. /* Returns the context field of the given AFC connection. */
  355. unsigned int AFCConnectionGetContext(afc_connection *conn);
  356.  
  357. /* Returns the fs_block_size field of the given AFC connection. */
  358. unsigned int AFCConnectionGetFSBlockSize(afc_connection *conn);
  359.  
  360. /* Returns the io_timeout field of the given AFC connection. In iTunes this is
  361.  * 0. */
  362. unsigned int AFCConnectionGetIOTimeout(afc_connection *conn);
  363.  
  364. /* Returns the sock_block_size field of the given AFC connection. */
  365. unsigned int AFCConnectionGetSocketBlockSize(afc_connection *conn);
  366.  
  367. /* Closes the given AFC connection. */
  368. afc_error_t AFCConnectionClose(afc_connection *conn);
  369.  
  370. /* Registers for device notifications related to the restore process. unknown0
  371.  * is zero when iTunes calls this. In iTunes,
  372.  * the callbacks are located at:
  373.  *      1: $3ac68e-$3ac6b1, calls $3ac542(unknown1, arg, 0)
  374.  *      2: $3ac66a-$3ac68d, calls $3ac542(unknown1, 0, arg)
  375.  *      3: $3ac762-$3ac785, calls $3ac6b2(unknown1, arg, 0)
  376.  *      4: $3ac73e-$3ac761, calls $3ac6b2(unknown1, 0, arg)
  377.  */
  378.  
  379. unsigned int AMRestoreRegisterForDeviceNotifications(
  380.     am_restore_device_notification_callback dfu_connect_callback,
  381.     am_restore_device_notification_callback recovery_connect_callback,
  382.     am_restore_device_notification_callback dfu_disconnect_callback,
  383.     am_restore_device_notification_callback recovery_disconnect_callback,
  384.     unsigned int unknown0,
  385.     void *user_info);
  386.  
  387. /* Causes the restore functions to spit out (unhelpful) progress messages to
  388.  * the file specified by the given path. iTunes always calls this right before
  389.  * restoring with a path of
  390.  * "$HOME/Library/Logs/iPhone Updater Logs/iPhoneUpdater X.log", where X is an
  391.  * unused number.
  392.  */
  393.  
  394. unsigned int AMRestoreEnableFileLogging(char *path);
  395.  
  396. /* Initializes a new option dictionary to default values. Pass the constant
  397.  * kCFAllocatorDefault as the allocator. The option dictionary looks as
  398.  * follows:
  399.  * {
  400.  *      NORImageType => 'production',
  401.  *      AutoBootDelay => 0,
  402.  *      KernelCacheType => 'Release',
  403.  *      UpdateBaseband => true,
  404.  *      DFUFileType => 'RELEASE',
  405.  *      SystemImageType => 'User',
  406.  *      CreateFilesystemPartitions => true,
  407.  *      FlashNOR => true,
  408.  *      RestoreBootArgs => 'rd=md0 nand-enable-reformat=1 -progress'
  409.  *      BootImageType => 'User'
  410.  *  }
  411.  *
  412.  * Returns:
  413.  *      the option dictionary   if successful
  414.  *      NULL                    if out of memory
  415.  */
  416.  
  417. CFMutableDictionaryRef AMRestoreCreateDefaultOptions(CFAllocatorRef allocator);
  418.  
  419. /* ----------------------------------------------------------------------------
  420.  *   Less-documented public routines
  421.  * ------------------------------------------------------------------------- */
  422.  
  423. /* mode 2 = read, mode 3 = write */
  424. afc_error_t AFCFileRefOpen(afc_connection *conn, const char *path,
  425.     unsigned long long mode, afc_file_ref *ref);
  426. afc_error_t AFCFileRefSeek(afc_connection *conn, afc_file_ref ref,
  427.     unsigned long long offset1, unsigned long long offset2);
  428. afc_error_t AFCFileRefRead(afc_connection *conn, afc_file_ref ref,
  429.     void *buf, unsigned int *len);
  430. afc_error_t AFCFileRefSetFileSize(afc_connection *conn, afc_file_ref ref,
  431.     unsigned long long offset);
  432. afc_error_t AFCFileRefWrite(afc_connection *conn, afc_file_ref ref,
  433.     const void *buf, unsigned int len);
  434. afc_error_t AFCFileRefClose(afc_connection *conn, afc_file_ref ref);
  435.  
  436. afc_error_t AFCFileInfoOpen(afc_connection *conn, const char *path, struct
  437.     afc_dictionary **info);
  438. afc_error_t AFCKeyValueRead(struct afc_dictionary *dict, char **key, char **
  439.     val);
  440. afc_error_t AFCKeyValueClose(struct afc_dictionary *dict);
  441.  
  442. unsigned int AMRestorePerformRecoveryModeRestore(struct am_recovery_device *
  443.     rdev, CFDictionaryRef opts, void *callback, void *user_info);
  444. unsigned int AMRestorePerformRestoreModeRestore(struct am_restore_device *
  445.     rdev, CFDictionaryRef opts, void *callback, void *user_info);
  446.  
  447. struct am_restore_device *AMRestoreModeDeviceCreate(unsigned int unknown0,
  448.     unsigned int connection_id, unsigned int unknown1);
  449.  
  450. unsigned int AMRestoreCreatePathsForBundle(CFStringRef restore_bundle_path,
  451.     CFStringRef kernel_cache_type, CFStringRef boot_image_type, unsigned int
  452.     unknown0, CFStringRef *firmware_dir_path, CFStringRef *
  453.     kernelcache_restore_path, unsigned int unknown1, CFStringRef *
  454.     ramdisk_path);
  455.  
  456. unsigned int AMDeviceGetConnectionID(struct am_device *device);
  457. mach_error_t AMDeviceEnterRecovery(struct am_device *device);
  458. mach_error_t AMDeviceDisconnect(struct am_device *device);
  459. mach_error_t AMDeviceRetain(struct am_device *device);
  460. mach_error_t AMDeviceRelease(struct am_device *device);
  461. CFStringRef AMDeviceCopyValue(struct am_device *device, unsigned int, CFStringRef cfstring);
  462. CFStringRef AMDeviceCopyDeviceIdentifier(struct am_device *device);
  463.  
  464. typedef void (*notify_callback)(CFStringRef notification, void *data);
  465.  
  466. mach_error_t AMDPostNotification(service_conn_t socket, CFStringRef  notification, CFStringRef userinfo);
  467. mach_error_t AMDObserveNotification(void *socket, CFStringRef notification);
  468. mach_error_t AMDListenForNotifications(void *socket, notify_callback cb, void *data);
  469. mach_error_t AMDShutdownNotificationProxy(void *socket);
  470.                    
  471. /*edits by geohot*/
  472. mach_error_t AMDeviceDeactivate(struct am_device *device);
  473. mach_error_t AMDeviceActivate(struct am_device *device, CFMutableDictionaryRef);
  474. /*end*/
  475.  
  476. void *AMDeviceSerialize(struct am_device *device);
  477. void AMDAddLogFileDescriptor(int fd);
  478. kern_return_t AMDeviceSendMessage(service_conn_t socket, void *unused, CFPropertyListRef plist);
  479. kern_return_t AMDeviceReceiveMessage(service_conn_t socket, CFDictionaryRef options, CFPropertyListRef * result);
  480.  
  481. /* ----------------------------------------------------------------------------
  482.  *   Semi-private routines
  483.  * ------------------------------------------------------------------------- */
  484.  
  485. /*  Pass in a usbmux_listener_1 structure and a usbmux_listener_2 structure
  486.  *  pointer, which will be filled with the resulting usbmux_listener_2.
  487.  *
  488.  *  Returns:
  489.  *      MDERR_OK                if completed successfully
  490.  *      MDERR_USBMUX_ARG_NULL   if one of the arguments was NULL
  491.  *      MDERR_USBMUX_FAILED     if the listener was not created successfully
  492.  */
  493.  
  494. usbmux_error_t USBMuxListenerCreate(struct usbmux_listener_1 *esi_fp8, struct
  495.     usbmux_listener_2 **eax_fp12);
  496.  
  497. /* ----------------------------------------------------------------------------
  498.  *   Less-documented semi-private routines
  499.  * ------------------------------------------------------------------------- */
  500.  
  501. usbmux_error_t USBMuxListenerHandleData(void *);
  502.  
  503. /* ----------------------------------------------------------------------------
  504.  *   Private routines - here be dragons
  505.  * ------------------------------------------------------------------------- */
  506.  
  507. /* AMRestorePerformRestoreModeRestore() calls this function with a dictionary
  508.  * in order to perform certain special restore operations
  509.  * (RESTORED_OPERATION_*). It is thought that this function might enable
  510.  * significant access to the phone. */
  511.  
  512. typedef unsigned int (*t_performOperation)(struct am_restore_device *rdev,
  513.     CFDictionaryRef op); // __attribute__ ((regparm(2)));
  514.  
  515. #ifdef __cplusplus
  516. }
  517. #endif
  518.  
  519. #endif