<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.theiphonewiki.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DarkMalloc</id>
	<title>The iPhone Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.theiphonewiki.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DarkMalloc"/>
	<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/wiki/Special:Contributions/DarkMalloc"/>
	<updated>2026-07-31T03:52:17Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.14</generator>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=Main_Page&amp;diff=9348</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=Main_Page&amp;diff=9348"/>
		<updated>2010-09-22T18:23:15Z</updated>

		<summary type="html">&lt;p&gt;DarkMalloc: Disagree with this; the name calibre of skills doesn't quite match that of the others.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- Logo by iHassan --&amp;gt;&lt;br /&gt;
[[Image:Iptwiki.png|center]]&lt;br /&gt;
&amp;lt;!-- Added a split column information box- computid --&amp;gt;&lt;br /&gt;
{{:Main Page/Welcome}}&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width:100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color:lime; text-align:center; width:25%;&amp;quot;| '''[[Jailbreak (S5L8920+)|Find bootrom exploit allowing unsigned code exec via USB (S5L8920+)]]'''&lt;br /&gt;
|style=&amp;quot;background-color:orange; text-align:center; width:25%;&amp;quot;| '''[[Jailbreak (S5L8920+)|Find bootrom exploit allowing unsigned code exec on startup (S5L8920+)]]'''&lt;br /&gt;
|style=&amp;quot;background-color:orange; text-align:center; width:25%;&amp;quot;| '''[[X-Gold 608 Unlock|Break Chain of Trust (X-Gold 608)]]'''&lt;br /&gt;
|style=&amp;quot;background-color:orange; text-align:center; width:25%;&amp;quot;| '''[[X-Gold 618 Unlock|Break Chain of Trust (X-Gold 618)]]'''&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{col-begin}}&lt;br /&gt;
{{col-2}}&lt;br /&gt;
{{HeadingA|Software}}&lt;br /&gt;
* [[/|Filesystem]]&lt;br /&gt;
* [[Firmware]]&lt;br /&gt;
* [[iTunes]]&lt;br /&gt;
** [[iTunes Errors]]&lt;br /&gt;
** [[iTunes Modes]]&lt;br /&gt;
* [[Keys]]&lt;br /&gt;
** [[AES Keys]]&lt;br /&gt;
** [[Apple Certificate]]&lt;br /&gt;
** [[Baseband RSA Keys|RSA Keys]]&lt;br /&gt;
** [[Baseband TEA Keys|TEA Keys]]&lt;br /&gt;
** [[NCK]]&lt;br /&gt;
* [[Protocols]]&lt;br /&gt;
** [[Normal Mode]]&lt;br /&gt;
** [[Recovery Mode (Protocols)|Recovery Mode]]&lt;br /&gt;
** [[Restore Mode]]&lt;br /&gt;
** [[DFU (Protocol)|DFU]]&lt;br /&gt;
** [[Baseband Bootrom Protocol]]&lt;br /&gt;
** [[Interactive Mode|Baseband Bootloader Protocol]]&lt;br /&gt;
* [[System Log|System Log (syslog)]]&lt;br /&gt;
&lt;br /&gt;
====Jailbreak Software====&lt;br /&gt;
* [[blackra1n]]&lt;br /&gt;
* [[iBrickr]]&lt;br /&gt;
* [[iLiberty / iLiberty+]]&lt;br /&gt;
* [[iNdependence]]&lt;br /&gt;
* [[JailbreakMe]]&lt;br /&gt;
* [[purplera1n]]&lt;br /&gt;
* [[PwnageTool]]&lt;br /&gt;
* [[redsn0w]]&lt;br /&gt;
* [[sn0wbreeze]]&lt;br /&gt;
* [[Spirit]]&lt;br /&gt;
* [[ZiPhone]]&lt;br /&gt;
&lt;br /&gt;
{{col-2}}&lt;br /&gt;
{{HeadingB|Hardware}}&lt;br /&gt;
====[[iPhone]]====&lt;br /&gt;
* [[M68ap|iPhone (m68ap)]]&lt;br /&gt;
* [[N82ap|iPhone 3G (n82ap)]]&lt;br /&gt;
* [[N88ap|iPhone 3GS (n88ap)]]&lt;br /&gt;
* [[N90ap|iPhone 4 (n90ap)]]&lt;br /&gt;
&lt;br /&gt;
====[[iPod touch]]====&lt;br /&gt;
* [[N45ap|iPod touch (n45ap)]]&lt;br /&gt;
* [[N72ap|iPod touch 2G (n72ap)]]&lt;br /&gt;
* [[N18ap|iPod touch 3G (n18ap)]]&lt;br /&gt;
* [[N81ap|iPod touch 4G (n81ap)]]&lt;br /&gt;
&lt;br /&gt;
====[[iPad]]====&lt;br /&gt;
* [[K48ap|iPad (k48ap)]]&lt;br /&gt;
&lt;br /&gt;
====Processors====&lt;br /&gt;
* [[S5L8900]] ([[M68ap|iPhone]], [[N45ap|iPod touch]], [[N82ap|iPhone 3G]])&lt;br /&gt;
* [[S5L8720]] ([[N72ap|iPod touch 2G]])&lt;br /&gt;
* [[S5L8920]] ([[N88ap|iPhone 3GS]])&lt;br /&gt;
* [[S5L8922]] ([[N18ap|iPod touch 3G]])&lt;br /&gt;
* [[S5L8930]] ([[k48ap|iPad]], [[n90ap|iPhone 4]], [[n81ap|iPod touch 4G]])&lt;br /&gt;
* [[Baseband Device]]&lt;br /&gt;
&lt;br /&gt;
====Other====&lt;br /&gt;
* [[Bluetooth]]&lt;br /&gt;
{{col-end}}&lt;br /&gt;
&lt;br /&gt;
{{col-begin}}&lt;br /&gt;
{{col-2}}&lt;br /&gt;
{{HeadingA|Development}}&lt;br /&gt;
&lt;br /&gt;
====iPhone Hackers====&lt;br /&gt;
* [[User:Planetbeing|planetbeing]]&lt;br /&gt;
* [[User:MuscleNerd|MuscleNerd]]&lt;br /&gt;
* [[User:Comex|comex]]&lt;br /&gt;
* [[User:Geohot|geohot]]&lt;br /&gt;
====iPhone Hacker Teams====&lt;br /&gt;
* [[iPhone Dev Team]]&lt;br /&gt;
* [[Chronic Dev (team)|Chronic Dev]]&lt;br /&gt;
&lt;br /&gt;
====Application Development====&lt;br /&gt;
* [[Toolchain]] (Includes tutorials)&lt;br /&gt;
* [[Toolchain 2.0]] (Includes tutorials)&lt;br /&gt;
* [[Frameworks]]&lt;br /&gt;
* [[MobileDevice Library]]&lt;br /&gt;
* [[Apple Certification Process]]&lt;br /&gt;
* [[Bypassing iPhone Code Signatures]]&lt;br /&gt;
* [[Distribution Methods]]&lt;br /&gt;
&lt;br /&gt;
====Application Copy Protection====&lt;br /&gt;
* [[Copy Protection Overview]]&lt;br /&gt;
* [[Application Structure and Signatures]]&lt;br /&gt;
* [[Mach-O Loading Process]]&lt;br /&gt;
* [[Bugging Debuggers]]&lt;br /&gt;
* [[Defeating Cracks]]&lt;br /&gt;
{{col-2}}&lt;br /&gt;
{{HeadingB|Help}}&lt;br /&gt;
&lt;br /&gt;
====Guides====&lt;br /&gt;
* [[Tutorials]]&lt;br /&gt;
* [[Useful Links]]&lt;br /&gt;
&lt;br /&gt;
====Definitions====&lt;br /&gt;
* [[Activation]]&lt;br /&gt;
* [[Baseband Device|Baseband]]&lt;br /&gt;
* [[Baseband Bootloader|Bootloader]]&lt;br /&gt;
* [[Bootrom]] / [[VROM]]&lt;br /&gt;
* [[CHIPID]]&lt;br /&gt;
* [[CPID]]&lt;br /&gt;
* [[DFU Mode]]&lt;br /&gt;
* [[ECID]]&lt;br /&gt;
* [[iBEC]]&lt;br /&gt;
* [[iBoot]]&lt;br /&gt;
* [[iBSS]]&lt;br /&gt;
* [[Jailbreak]]&lt;br /&gt;
** [[Tethered jailbreak]]&lt;br /&gt;
** [[Untethered jailbreak]]&lt;br /&gt;
* [[Kernel]]&lt;br /&gt;
* [[LLB]]&lt;br /&gt;
* [[NAND]]&lt;br /&gt;
* [[NOR]]&lt;br /&gt;
* [[NORID]]&lt;br /&gt;
* [[SHSH]]&lt;br /&gt;
* [[Unlock]]&lt;br /&gt;
{{col-end}}&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot; style=&amp;quot;background-color:orange; width:100%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot; style=&amp;quot;background-color:orange; text-align:center;&amp;quot;| [[Disclaimer]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
__NOTOC____NOEDITSECTION__&lt;/div&gt;</summary>
		<author><name>DarkMalloc</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=AES_Keys&amp;diff=6617</id>
		<title>AES Keys</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=AES_Keys&amp;diff=6617"/>
		<updated>2010-06-22T16:20:13Z</updated>

		<summary type="html">&lt;p&gt;DarkMalloc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The SoC in each device have an AES coprocessor with the [[GID-key]] and [[UID-key]] built in.&lt;br /&gt;
&lt;br /&gt;
==Running The Engine==&lt;br /&gt;
Currently, there are four ways to run the hardware AES engine:&lt;br /&gt;
* Use the AES payload released on OpenPwn.&lt;br /&gt;
* Patch iBoot to jump to aes_decrypt.&lt;br /&gt;
* Use [http://github.com/planetbeing/iphonelinux/tree/master OpenIBoot].&lt;br /&gt;
* Use the crypto bundle provided in xpwn to utilize it via userland. This method requires a kernel patch.&lt;br /&gt;
&lt;br /&gt;
If you want to decrypt [[IMG3]] files you need to use this. The [[GID-key]] currently has not been extracted from the phone, so the only way to use it is on the phone itself.&lt;br /&gt;
&lt;br /&gt;
See [[Easier method of getting Img3 Key / IV]] for an iBoot patch.&lt;br /&gt;
&lt;br /&gt;
==AES crypto payload==&lt;br /&gt;
http://forums.openpwn.org/viewtopic.php?f=8&amp;amp;t=19&amp;amp;p=101#p101&lt;br /&gt;
&lt;br /&gt;
==Key 0x837==&lt;br /&gt;
Generated by encrypting 345A2D6C5050D058780DA431F0710E15 with the [[S5L8900]] [[GID-key]] to get 188458A6D15034DFE386F23B61D43774  &lt;br /&gt;
&lt;br /&gt;
It is used as the encryption key in the [[IMG2 File Format]]. With the introduction of [[IMG3]] in 2.0, [[KBAG]]s are now used instead of the 0x837 key.&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
[http://wikee.iphwn.org/s5l8900:encryption_keys The dev team's wiki page]&lt;/div&gt;</summary>
		<author><name>DarkMalloc</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=AES_Keys&amp;diff=6616</id>
		<title>AES Keys</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=AES_Keys&amp;diff=6616"/>
		<updated>2010-06-22T16:19:58Z</updated>

		<summary type="html">&lt;p&gt;DarkMalloc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The SoC in each device have an AES coprocessor with the [[GID-key]] and [[UID-key]] built in.&lt;br /&gt;
&lt;br /&gt;
==Running The Engine==&lt;br /&gt;
Currently, there are four ways to run the hardware AES engine:&lt;br /&gt;
* Use the AES payload released on OpenPwn&lt;br /&gt;
* Patch iBoot to jump to aes_decrypt.&lt;br /&gt;
* Use [http://github.com/planetbeing/iphonelinux/tree/master OpenIBoot].&lt;br /&gt;
* Use the crypto bundle provided in xpwn to utilize it via userland. This method requires a kernel patch.&lt;br /&gt;
&lt;br /&gt;
If you want to decrypt [[IMG3]] files you need to use this. The [[GID-key]] currently has not been extracted from the phone, so the only way to use it is on the phone itself.&lt;br /&gt;
&lt;br /&gt;
See [[Easier method of getting Img3 Key / IV]] for an iBoot patch.&lt;br /&gt;
&lt;br /&gt;
==AES crypto payload==&lt;br /&gt;
http://forums.openpwn.org/viewtopic.php?f=8&amp;amp;t=19&amp;amp;p=101#p101&lt;br /&gt;
&lt;br /&gt;
==Key 0x837==&lt;br /&gt;
Generated by encrypting 345A2D6C5050D058780DA431F0710E15 with the [[S5L8900]] [[GID-key]] to get 188458A6D15034DFE386F23B61D43774  &lt;br /&gt;
&lt;br /&gt;
It is used as the encryption key in the [[IMG2 File Format]]. With the introduction of [[IMG3]] in 2.0, [[KBAG]]s are now used instead of the 0x837 key.&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
[http://wikee.iphwn.org/s5l8900:encryption_keys The dev team's wiki page]&lt;/div&gt;</summary>
		<author><name>DarkMalloc</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=MobileDevice_Library&amp;diff=6439</id>
		<title>MobileDevice Library</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=MobileDevice_Library&amp;diff=6439"/>
		<updated>2010-05-27T18:52:38Z</updated>

		<summary type="html">&lt;p&gt;DarkMalloc: Undo revision 6438 by DarkMalloc (Talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;MobileDevice Library is used by [[iTunes]] to transfer data between iPhone and computer over the USB connection.&lt;br /&gt;
&lt;br /&gt;
===PC Windows : iTunesMobileDevice.dll===&lt;br /&gt;
&lt;br /&gt;
* Location : Location is stored in '''iTunesMobileDeviceDLL''' registry value under '''HKLM\SOFTWARE\Apple Inc.\Apple Mobile Device Support\Shared''' key. Usually - C:\Program Files\Common Files\Apple\Mobile Device Support\bin\iTunesMobileDevice.dll.&lt;br /&gt;
&lt;br /&gt;
* Supporting CoreFoundation.dll (used for CFStringRef, CFPropertyListRef management) is located in the same dir (when using iTunes prior 9.0). &lt;br /&gt;
&lt;br /&gt;
* For iTunes 9.0 location of CoreFoundation.dll is stored in '''InstallDir''' registry value under '''HKLM\SOFTWARE\Apple Inc.\Apple Application Support''' key, usually C:\Program Files\Common Files\Apple\Apple Application Support\. CoreFoundation.dll from Mobile Device Support\bin should not be used.&lt;br /&gt;
&lt;br /&gt;
===Mac OSX : MobileDevice.framework===&lt;br /&gt;
&lt;br /&gt;
* Location : /System/Library/PrivateFrameworks/MobileDevice.framework&lt;br /&gt;
* Export command : &amp;quot;nm /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===MobileDevice Header (mobiledevice.h)===&lt;br /&gt;
&lt;br /&gt;
Reverse engineered C header for MobileDevice Library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/* ----------------------------------------------------------------------------&lt;br /&gt;
 *   MobileDevice.h - interface to MobileDevice.framework &lt;br /&gt;
 * ------------------------------------------------------------------------- */&lt;br /&gt;
#pragma once&lt;br /&gt;
&lt;br /&gt;
#ifndef MOBILEDEVICE_H&lt;br /&gt;
#define MOBILEDEVICE_H&lt;br /&gt;
&lt;br /&gt;
#ifdef __cplusplus&lt;br /&gt;
extern &amp;quot;C&amp;quot; {&lt;br /&gt;
#endif&lt;br /&gt;
	&lt;br /&gt;
#ifndef __GCC__&lt;br /&gt;
#pragma pack&lt;br /&gt;
#define __PACK&lt;br /&gt;
#else&lt;br /&gt;
#define __PACK __attribute__((__packed__))&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#if defined(WIN32)&lt;br /&gt;
#define __DLLIMPORT [DllImport(&amp;quot;iTunesMobileDevice.dll&amp;quot;)]&lt;br /&gt;
	using namespace System::Runtime::InteropServices;&lt;br /&gt;
#include &amp;lt;CoreFoundation.h&amp;gt;&lt;br /&gt;
	typedef unsigned int mach_error_t;&lt;br /&gt;
#elif defined(__APPLE__)&lt;br /&gt;
#define __DLLIMPORT&lt;br /&gt;
#include &amp;lt;CoreFoundation/CoreFoundation.h&amp;gt;&lt;br /&gt;
#include &amp;lt;mach/error.h&amp;gt;&lt;br /&gt;
#endif	&lt;br /&gt;
	&lt;br /&gt;
	/* Error codes */&lt;br /&gt;
#define MDERR_APPLE_MOBILE  (err_system(0x3a))&lt;br /&gt;
#define MDERR_IPHONE        (err_sub(0))&lt;br /&gt;
	&lt;br /&gt;
	/* Apple Mobile (AM*) errors */&lt;br /&gt;
#define MDERR_OK                ERR_SUCCESS&lt;br /&gt;
#define MDERR_SYSCALL           (ERR_MOBILE_DEVICE | 0x01)&lt;br /&gt;
#define MDERR_OUT_OF_MEMORY     (ERR_MOBILE_DEVICE | 0x03)&lt;br /&gt;
#define MDERR_QUERY_FAILED      (ERR_MOBILE_DEVICE | 0x04) &lt;br /&gt;
#define MDERR_INVALID_ARGUMENT  (ERR_MOBILE_DEVICE | 0x0b)&lt;br /&gt;
#define MDERR_DICT_NOT_LOADED   (ERR_MOBILE_DEVICE | 0x25)&lt;br /&gt;
	&lt;br /&gt;
	/* Apple File Connection (AFC*) errors */&lt;br /&gt;
#define MDERR_AFC_OUT_OF_MEMORY 0x03&lt;br /&gt;
	&lt;br /&gt;
	/* USBMux errors */&lt;br /&gt;
#define MDERR_USBMUX_ARG_NULL   0x16&lt;br /&gt;
#define MDERR_USBMUX_FAILED     0xffffffff&lt;br /&gt;
	&lt;br /&gt;
	/* Messages passed to device notification callbacks: passed as part of&lt;br /&gt;
	 * am_device_notification_callback_info. */&lt;br /&gt;
#define ADNCI_MSG_CONNECTED     1&lt;br /&gt;
#define ADNCI_MSG_DISCONNECTED  2&lt;br /&gt;
#define ADNCI_MSG_UNSUBSCRIBED  3&lt;br /&gt;
	&lt;br /&gt;
#define AMD_IPHONE_PRODUCT_ID   0x1290&lt;br /&gt;
	//#define AMD_IPHONE_SERIAL       &amp;quot;&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
	/* Services, found in /System/Library/Lockdown/Services.plist */&lt;br /&gt;
#define AMSVC_AFC                   CFSTR(&amp;quot;com.apple.afc&amp;quot;)&lt;br /&gt;
#define AMSVC_BACKUP                CFSTR(&amp;quot;com.apple.mobilebackup&amp;quot;)&lt;br /&gt;
#define AMSVC_CRASH_REPORT_COPY     CFSTR(&amp;quot;com.apple.crashreportcopy&amp;quot;)&lt;br /&gt;
#define AMSVC_DEBUG_IMAGE_MOUNT     CFSTR(&amp;quot;com.apple.mobile.debug_image_mount&amp;quot;)&lt;br /&gt;
#define AMSVC_NOTIFICATION_PROXY    CFSTR(&amp;quot;com.apple.mobile.notification_proxy&amp;quot;)&lt;br /&gt;
#define AMSVC_PURPLE_TEST           CFSTR(&amp;quot;com.apple.purpletestr&amp;quot;)&lt;br /&gt;
#define AMSVC_SOFTWARE_UPDATE       CFSTR(&amp;quot;com.apple.mobile.software_update&amp;quot;)&lt;br /&gt;
#define AMSVC_SYNC                  CFSTR(&amp;quot;com.apple.mobilesync&amp;quot;)&lt;br /&gt;
#define AMSVC_SCREENSHOT            CFSTR(&amp;quot;com.apple.screenshotr&amp;quot;)&lt;br /&gt;
#define AMSVC_SYSLOG_RELAY          CFSTR(&amp;quot;com.apple.syslog_relay&amp;quot;)&lt;br /&gt;
#define AMSVC_SYSTEM_PROFILER       CFSTR(&amp;quot;com.apple.mobile.system_profiler&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	typedef unsigned int afc_error_t;&lt;br /&gt;
	typedef unsigned int usbmux_error_t;&lt;br /&gt;
	&lt;br /&gt;
	struct am_recovery_device;&lt;br /&gt;
	&lt;br /&gt;
	struct am_device_notification_callback_info {&lt;br /&gt;
		struct am_device *dev;  /* 0    device */ &lt;br /&gt;
		unsigned int msg;       /* 4    one of ADNCI_MSG_* */&lt;br /&gt;
                struct am_device_notification* subscription; &lt;br /&gt;
	} __PACK;&lt;br /&gt;
	&lt;br /&gt;
	/* The type of the device restore notification callback functions.&lt;br /&gt;
	 * TODO: change to correct type. */&lt;br /&gt;
	typedef void (*am_restore_device_notification_callback)(struct am_recovery_device *);&lt;br /&gt;
	&lt;br /&gt;
	/* This is a CoreFoundation object of class AMRecoveryModeDevice. */&lt;br /&gt;
	struct am_recovery_device {&lt;br /&gt;
		unsigned char unknown0[8];                          /* 0 */&lt;br /&gt;
		am_restore_device_notification_callback callback;   /* 8 */&lt;br /&gt;
		void *user_info;                                    /* 12 */&lt;br /&gt;
		unsigned char unknown1[12];                         /* 16 */&lt;br /&gt;
		unsigned int readwrite_pipe;                        /* 28 */&lt;br /&gt;
		unsigned char read_pipe;                            /* 32 */&lt;br /&gt;
		unsigned char write_ctrl_pipe;                      /* 33 */&lt;br /&gt;
		unsigned char read_unknown_pipe;                    /* 34 */&lt;br /&gt;
		unsigned char write_file_pipe;                      /* 35 */&lt;br /&gt;
		unsigned char write_input_pipe;                     /* 36 */&lt;br /&gt;
	} __PACK;&lt;br /&gt;
	&lt;br /&gt;
	/* A CoreFoundation object of class AMRestoreModeDevice. */&lt;br /&gt;
	struct am_restore_device {&lt;br /&gt;
		unsigned char unknown[32];&lt;br /&gt;
		int port;&lt;br /&gt;
	} __PACK;&lt;br /&gt;
	&lt;br /&gt;
	/* The type of the device notification callback function. */&lt;br /&gt;
	typedef void(*am_device_notification_callback)(struct am_device_notification_callback_info *, int cookie);&lt;br /&gt;
	&lt;br /&gt;
	/* The type of the _AMDDeviceAttached function.&lt;br /&gt;
	 * TODO: change to correct type. */&lt;br /&gt;
	typedef void *amd_device_attached_callback;&lt;br /&gt;
	&lt;br /&gt;
	/* The type of the device restore notification callback functions.&lt;br /&gt;
	 * TODO: change to correct type. */&lt;br /&gt;
	typedef void (*am_restore_device_notification_callback)(struct am_recovery_device *);&lt;br /&gt;
&lt;br /&gt;
	/* Structure that contains internal data used by AMDevice... functions. Never try &lt;br /&gt;
         * to access its members directly! Use AMDeviceCopyDeviceIdentifier, &lt;br /&gt;
         * AMDeviceGetConnectionID, AMDeviceRetain, AMDeviceRelease instead. */&lt;br /&gt;
	struct am_device {&lt;br /&gt;
		unsigned char unknown0[16]; /* 0 - zero */&lt;br /&gt;
		unsigned int device_id;     /* 16 */&lt;br /&gt;
		unsigned int product_id;    /* 20 - set to AMD_IPHONE_PRODUCT_ID */&lt;br /&gt;
		char *serial;               /* 24 - set to UDID, Unique Device Identifier */&lt;br /&gt;
		unsigned int unknown1;      /* 28 */&lt;br /&gt;
		unsigned int unknown2;      /* 32 - reference counter, increased by AMDeviceRetain, decreased by AMDeviceRelease*/&lt;br /&gt;
		unsigned int lockdown_conn; /* 36 */&lt;br /&gt;
		unsigned char unknown3[8];  /* 40 */&lt;br /&gt;
#if (__ITUNES_VER &amp;gt; 740)&lt;br /&gt;
		unsigned int unknown4;      /* 48 - used to store CriticalSection Handle*/&lt;br /&gt;
#endif&lt;br /&gt;
#if (__ITUNES_VER &amp;gt;= 800)&lt;br /&gt;
		unsigned char unknown5[24];  /* 52 */&lt;br /&gt;
#endif&lt;br /&gt;
	} __PACK;&lt;br /&gt;
	&lt;br /&gt;
	struct am_device_notification {&lt;br /&gt;
		unsigned int unknown0;                      /* 0 */&lt;br /&gt;
		unsigned int unknown1;                      /* 4 */&lt;br /&gt;
		unsigned int unknown2;                      /* 8 */&lt;br /&gt;
		am_device_notification_callback callback;   /* 12 */ &lt;br /&gt;
		unsigned int cookie;                      /* 16 */&lt;br /&gt;
	} __PACK;&lt;br /&gt;
	&lt;br /&gt;
	struct afc_connection {&lt;br /&gt;
		unsigned int handle;            /* 0 */&lt;br /&gt;
		unsigned int unknown0;          /* 4 */&lt;br /&gt;
		unsigned char unknown1;         /* 8 */&lt;br /&gt;
		unsigned char padding[3];       /* 9 */&lt;br /&gt;
		unsigned int unknown2;          /* 12 */&lt;br /&gt;
		unsigned int unknown3;          /* 16 */&lt;br /&gt;
		unsigned int unknown4;          /* 20 */&lt;br /&gt;
		unsigned int fs_block_size;     /* 24 */&lt;br /&gt;
		unsigned int sock_block_size;   /* 28: always 0x3c */&lt;br /&gt;
		unsigned int io_timeout;        /* 32: from AFCConnectionOpen, usu. 0 */&lt;br /&gt;
		void *afc_lock;                 /* 36 */&lt;br /&gt;
		unsigned int context;           /* 40 */&lt;br /&gt;
	} __PACK;&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	struct afc_device_info {&lt;br /&gt;
		unsigned char unknown[12];  /* 0 */&lt;br /&gt;
	} __PACK;&lt;br /&gt;
&lt;br /&gt;
	struct afc_directory {&lt;br /&gt;
		unsigned char unknown[0];   /* size unknown */&lt;br /&gt;
	} __PACK;&lt;br /&gt;
&lt;br /&gt;
	struct afc_dictionary {&lt;br /&gt;
		unsigned char unknown[0];   /* size unknown */&lt;br /&gt;
	} __PACK;&lt;br /&gt;
	&lt;br /&gt;
	typedef unsigned long long afc_file_ref;&lt;br /&gt;
	&lt;br /&gt;
	struct usbmux_listener_1 {                  /* offset   value in iTunes */&lt;br /&gt;
		unsigned int unknown0;                  /* 0        1 */&lt;br /&gt;
		unsigned char *unknown1;                /* 4        ptr, maybe device? */&lt;br /&gt;
		amd_device_attached_callback callback;  /* 8        _AMDDeviceAttached */&lt;br /&gt;
		unsigned int unknown3;                  /* 12 */&lt;br /&gt;
		unsigned int unknown4;                  /* 16 */&lt;br /&gt;
		unsigned int unknown5;                  /* 20 */&lt;br /&gt;
	} __PACK;&lt;br /&gt;
	&lt;br /&gt;
	struct usbmux_listener_2 {&lt;br /&gt;
		unsigned char unknown0[4144];&lt;br /&gt;
	} __PACK;&lt;br /&gt;
	&lt;br /&gt;
	struct am_bootloader_control_packet {&lt;br /&gt;
		unsigned char opcode;       /* 0 */&lt;br /&gt;
		unsigned char length;       /* 1 */&lt;br /&gt;
		unsigned char magic[2];     /* 2: 0x34, 0x12 */&lt;br /&gt;
		unsigned char payload[0];   /* 4 */&lt;br /&gt;
	} __PACK;&lt;br /&gt;
	&lt;br /&gt;
	/* ----------------------------------------------------------------------------&lt;br /&gt;
	 *   Public routines&lt;br /&gt;
	 * ------------------------------------------------------------------------- */&lt;br /&gt;
	&lt;br /&gt;
	/*  Registers a notification with the current run loop. The callback gets&lt;br /&gt;
	 *  copied into the notification struct, as well as being registered with the&lt;br /&gt;
	 *  current run loop. Cookie gets copied into cookie in the same.&lt;br /&gt;
	 *  (Cookie is a user info parameter that gets passed as an arg to&lt;br /&gt;
	 *  the callback) unused0 and unused1 are both 0 when iTunes calls this.&lt;br /&gt;
	 *&lt;br /&gt;
	 *  Never try to acces directly or copy contents of dev and subscription fields &lt;br /&gt;
	 *  in am_device_notification_callback_info. Treat them as abstract handles. &lt;br /&gt;
	 *  When done with connection use AMDeviceRelease to free resources allocated for am_device.&lt;br /&gt;
	 *  &lt;br /&gt;
	 *  Returns:&lt;br /&gt;
	 *      MDERR_OK            if successful&lt;br /&gt;
	 *      MDERR_SYSCALL       if CFRunLoopAddSource() failed&lt;br /&gt;
	 *      MDERR_OUT_OF_MEMORY if we ran out of memory&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceNotificationSubscribe(am_device_notification_callback callback, &lt;br /&gt;
								unsigned int unused0, unsigned int unused1, &lt;br /&gt;
								unsigned int cookie, &lt;br /&gt;
								struct am_device_notification **subscription);&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
        /* Unregisters notifications. Buggy (iTunes 8.2): if you subscribe, unsubscribe and subscribe again, arriving &lt;br /&gt;
           notifications will contain cookie and subscription from 1st call to subscribe, not the 2nd one. iTunes &lt;br /&gt;
           calls this function only once on exit.&lt;br /&gt;
        */&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceNotificationUnsubscribe(am_device_notification* subscription);&lt;br /&gt;
&lt;br /&gt;
	/*  Returns device_id field of am_device structure&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT unsigned int AMDeviceGetConnectionID(struct am_device *device);&lt;br /&gt;
&lt;br /&gt;
	/*  Returns serial field of am_device structure&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT CFStringRef AMDeviceCopyDeviceIdentifier(struct am_device *device);&lt;br /&gt;
&lt;br /&gt;
	/*  Connects to the iPhone. Pass in the am_device structure that the&lt;br /&gt;
	 *  notification callback will give to you.&lt;br /&gt;
	 *&lt;br /&gt;
	 *  Returns:&lt;br /&gt;
	 *      MDERR_OK                if successfully connected&lt;br /&gt;
	 *      MDERR_SYSCALL           if setsockopt() failed&lt;br /&gt;
	 *      MDERR_QUERY_FAILED      if the daemon query failed&lt;br /&gt;
	 *      MDERR_INVALID_ARGUMENT  if USBMuxConnectByPort returned 0xffffffff&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceConnect(struct am_device *device);&lt;br /&gt;
	&lt;br /&gt;
	/*  Calls PairingRecordPath() on the given device, than tests whether the path&lt;br /&gt;
	 *  which that function returns exists. During the initial connect, the path&lt;br /&gt;
	 *  returned by that function is '/', and so this returns 1.&lt;br /&gt;
	 *&lt;br /&gt;
	 *  Returns:&lt;br /&gt;
	 *      0   if the path did not exist&lt;br /&gt;
	 *      1   if it did&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceIsPaired(struct am_device *device);&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDevicePair(struct am_device *device);&lt;br /&gt;
	&lt;br /&gt;
	/*  iTunes calls this function immediately after testing whether the device is&lt;br /&gt;
	 *  paired. It creates a pairing file and establishes a Lockdown connection.&lt;br /&gt;
	 *&lt;br /&gt;
	 *  Returns:&lt;br /&gt;
	 *      MDERR_OK                if successful&lt;br /&gt;
	 *      MDERR_INVALID_ARGUMENT  if the supplied device is null&lt;br /&gt;
	 *      MDERR_DICT_NOT_LOADED   if the load_dict() call failed&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceValidatePairing(struct am_device *device);&lt;br /&gt;
	&lt;br /&gt;
	/*  Creates a Lockdown session and adjusts the device structure appropriately&lt;br /&gt;
	 *  to indicate that the session has been started. iTunes calls this function&lt;br /&gt;
	 *  after validating pairing.&lt;br /&gt;
	 *&lt;br /&gt;
	 *  Returns:&lt;br /&gt;
	 *      MDERR_OK                if successful&lt;br /&gt;
	 *      MDERR_INVALID_ARGUMENT  if the Lockdown conn has not been established&lt;br /&gt;
	 *      MDERR_DICT_NOT_LOADED   if the load_dict() call failed&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceStartSession(struct am_device *device);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	/* Reads various device settings. One of domain or cfstring arguments should be NULL.&lt;br /&gt;
         *&lt;br /&gt;
         * Possible values for cfstring:&lt;br /&gt;
	 * ActivationState&lt;br /&gt;
	 * ActivationStateAcknowledged&lt;br /&gt;
	 * BasebandBootloaderVersion&lt;br /&gt;
	 * BasebandVersion&lt;br /&gt;
	 * BluetoothAddress&lt;br /&gt;
	 * BuildVersion&lt;br /&gt;
	 * DeviceCertificate&lt;br /&gt;
	 * DeviceClass&lt;br /&gt;
	 * DeviceName&lt;br /&gt;
	 * DevicePublicKey&lt;br /&gt;
	 * FirmwareVersion&lt;br /&gt;
	 * HostAttached&lt;br /&gt;
	 * IntegratedCircuitCardIdentity&lt;br /&gt;
	 * InternationalMobileEquipmentIdentity&lt;br /&gt;
	 * InternationalMobileSubscriberIdentity&lt;br /&gt;
	 * ModelNumber&lt;br /&gt;
	 * PhoneNumber&lt;br /&gt;
	 * ProductType&lt;br /&gt;
	 * ProductVersion&lt;br /&gt;
	 * ProtocolVersion&lt;br /&gt;
	 * RegionInfo&lt;br /&gt;
	 * SBLockdownEverRegisteredKey&lt;br /&gt;
	 * SIMStatus&lt;br /&gt;
	 * SerialNumber&lt;br /&gt;
	 * SomebodySetTimeZone&lt;br /&gt;
	 * TimeIntervalSince1970&lt;br /&gt;
	 * TimeZone&lt;br /&gt;
	 * TimeZoneOffsetFromUTC&lt;br /&gt;
	 * TrustedHostAttached&lt;br /&gt;
	 * UniqueDeviceID&lt;br /&gt;
	 * Uses24HourClock&lt;br /&gt;
	 * WiFiAddress&lt;br /&gt;
	 * iTunesHasConnected&lt;br /&gt;
         *&lt;br /&gt;
         * Possible values for domain:&lt;br /&gt;
         * com.apple.mobile.battery&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT CFStringRef AMDeviceCopyValue(struct am_device *device, CFStringRef domain, CFStringRef cfstring);&lt;br /&gt;
	&lt;br /&gt;
	/* Starts a service and returns a socket file descriptor that can be used in order to further&lt;br /&gt;
	 * access the service. You should stop the session and disconnect before using&lt;br /&gt;
	 * the service. iTunes calls this function after starting a session. It starts &lt;br /&gt;
	 * the service and the SSL connection. service_name should be one of the AMSVC_*&lt;br /&gt;
	 * constants.&lt;br /&gt;
	 *&lt;br /&gt;
	 * Returns:&lt;br /&gt;
	 *      MDERR_OK                if successful&lt;br /&gt;
	 *      MDERR_SYSCALL           if the setsockopt() call failed&lt;br /&gt;
	 *      MDERR_INVALID_ARGUMENT  if the Lockdown conn has not been established&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceStartService(struct am_device *device, CFStringRef &lt;br /&gt;
									  service_name, int *socket_fd);&lt;br /&gt;
	&lt;br /&gt;
	/* Stops a session. You should do this before accessing services.&lt;br /&gt;
	 *&lt;br /&gt;
	 * Returns:&lt;br /&gt;
	 *      MDERR_OK                if successful&lt;br /&gt;
	 *      MDERR_INVALID_ARGUMENT  if the Lockdown conn has not been established&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceStopSession(struct am_device *device);&lt;br /&gt;
	&lt;br /&gt;
	/* Decrements reference counter and, if nothing left, releases resources hold &lt;br /&gt;
	 * by connection, invalidates  pointer to device&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT void AMDeviceRelease(struct am_device *device);&lt;br /&gt;
&lt;br /&gt;
	/* Increments reference counter&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT void AMDeviceRetain(struct am_device *device);&lt;br /&gt;
&lt;br /&gt;
	/* Opens an Apple File Connection. You must start the appropriate service&lt;br /&gt;
	 * first with AMDeviceStartService(). In iTunes, io_timeout is 0.&lt;br /&gt;
	 *&lt;br /&gt;
	 * Returns:&lt;br /&gt;
	 *      MDERR_OK                if successful&lt;br /&gt;
	 *      MDERR_AFC_OUT_OF_MEMORY if malloc() failed&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCConnectionOpen(int socket_fd, unsigned int io_timeout,&lt;br /&gt;
								  struct afc_connection **conn);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        /* Copy an enviromental variable value from iBoot&lt;br /&gt;
         */&lt;br /&gt;
        __DLLIMPORT CFStringRef AMRecoveryModeCopyEnvironmentVariable(struct am_recovery_device *rdev, CFStringRef var);&lt;br /&gt;
	&lt;br /&gt;
	/* Pass in a pointer to an afc_dictionary structure. It will be filled. You can&lt;br /&gt;
	 * iterate it using AFCKeyValueRead. When done use AFCKeyValueClose. Possible keys:&lt;br /&gt;
	 * FSFreeBytes - free bytes on system device for afc2, user device for afc&lt;br /&gt;
	 * FSBlockSize - filesystem block size&lt;br /&gt;
	 * FSTotalBytes - size of device&lt;br /&gt;
	 * Model - iPhone1,1 etc.&lt;br /&gt;
&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCDeviceInfoOpen(struct afc_connection *conn, struct&lt;br /&gt;
								  afc_dictionary **info);&lt;br /&gt;
	&lt;br /&gt;
	/* Turns debug mode on if the environment variable AFCDEBUG is set to a numeric&lt;br /&gt;
	 * value, or if the file '/AFCDEBUG' is present and contains a value. */&lt;br /&gt;
#if defined(__APPLE__)&lt;br /&gt;
	void AFCPlatformInitialize();&lt;br /&gt;
#endif&lt;br /&gt;
	&lt;br /&gt;
	/* Opens a directory on the iPhone. Pass in a pointer in dir to be filled in.&lt;br /&gt;
	 * Note that this normally only accesses the iTunes sandbox/partition as the&lt;br /&gt;
	 * root, which is /var/root/Media. Pathnames are specified with '/' delimiters&lt;br /&gt;
	 * as in Unix style. Use UTF-8 to specify non-ASCII symbols in path.&lt;br /&gt;
	 *&lt;br /&gt;
	 * Returns:&lt;br /&gt;
	 *      MDERR_OK                if successful&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCDirectoryOpen(struct afc_connection *conn, char *path, struct&lt;br /&gt;
								 afc_directory **dir);&lt;br /&gt;
	&lt;br /&gt;
	/* Acquires the next entry in a directory previously opened with&lt;br /&gt;
	 * AFCDirectoryOpen(). When dirent is filled with a NULL value, then the end&lt;br /&gt;
	 * of the directory has been reached. '.' and '..' will be returned as the&lt;br /&gt;
	 * first two entries in each directory except the root; you may want to skip&lt;br /&gt;
	 * over them.&lt;br /&gt;
	 *&lt;br /&gt;
	 * Returns:&lt;br /&gt;
	 *      MDERR_OK                if successful, even if no entries remain&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCDirectoryRead(struct afc_connection *conn, struct afc_directory *dir,&lt;br /&gt;
								 char **dirent);&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCDirectoryClose(afc_connection *conn, struct afc_directory *dir);&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCDirectoryCreate(afc_connection *conn, char *dirname);&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCRemovePath(afc_connection *conn, char *dirname);&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCRenamePath(afc_connection *conn, char *oldpath, char *newpath);&lt;br /&gt;
&lt;br /&gt;
#if (__ITUNES_VER &amp;gt;= 800)&lt;br /&gt;
	/* Creates symbolic or hard link&lt;br /&gt;
         * linktype - int64: 1 means hard link, 2 - soft (symbolic) link&lt;br /&gt;
         * target - absolute or relative path to link target&lt;br /&gt;
         * linkname - absolute path where to create new link&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCLinkPath(struct afc_connection *conn, long long int linktype, const char *target, &lt;br /&gt;
								                              const char *linkname);&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
	/* Opens file for reading or writing without locking it in any way. afc_file_ref should not be shared between threads - &lt;br /&gt;
         * opening file in one thread and closing it in another will lead to possible crash.&lt;br /&gt;
	 * path - UTF-8 encoded absolute path to file&lt;br /&gt;
	 * mode 2 = read, mode 3 = write; unknown = 0 &lt;br /&gt;
	 * ref - receives file handle&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCFileRefOpen(struct afc_connection *conn, char *path, unsigned&lt;br /&gt;
							   long long int mode, afc_file_ref *ref);&lt;br /&gt;
	/* Reads specified amount (len) of bytes from file into buf. Puts actual count of read bytes into len on return&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCFileRefRead(struct afc_connection *conn, afc_file_ref ref,&lt;br /&gt;
							   void *buf, unsigned int *len);&lt;br /&gt;
	/* Writes specified amount (len) of bytes from buf into file.&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCFileRefWrite(struct afc_connection *conn, afc_file_ref ref,&lt;br /&gt;
								void *buf, unsigned int len);&lt;br /&gt;
	/* Moves the file pointer to a specified location.&lt;br /&gt;
	 * offset - Number of bytes from origin (int64)&lt;br /&gt;
	 * origin - 0 = from beginning, 1 = from current position, 2 = from end&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCFileRefSeek(struct afc_connection *conn, afc_file_ref ref,&lt;br /&gt;
							   unsigned long long offset, int origin, int unused);&lt;br /&gt;
&lt;br /&gt;
	/* Gets the current position of a file pointer into offset argument.&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCFileRefTell(struct afc_connection *conn, afc_file_ref ref,&lt;br /&gt;
							   unsigned long long* offset);&lt;br /&gt;
&lt;br /&gt;
	/*  Truncates a file at the specified offset.&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCFileRefSetFileSize(struct afc_connection *conn, afc_file_ref ref,&lt;br /&gt;
							   unsigned long long offset);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCFileRefLock(struct afc_connection *conn, afc_file_ref ref);&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCFileRefUnlock(struct afc_connection *conn, afc_file_ref ref);&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCFileRefClose(struct afc_connection *conn, afc_file_ref ref);&lt;br /&gt;
&lt;br /&gt;
	/* Opens dictionary describing specified file or directory (iTunes below 8.2 allowed using AFCGetFileInfo&lt;br /&gt;
	   to get the same information)&lt;br /&gt;
	*/&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCFileInfoOpen(struct afc_connection *conn, char *path, struct&lt;br /&gt;
								afc_dictionary **info);&lt;br /&gt;
&lt;br /&gt;
	/* Reads next entry from dictionary. When last entry is read, function returns NULL in key argument&lt;br /&gt;
	   Possible keys:&lt;br /&gt;
	     &amp;quot;st_size&amp;quot;:     val - size in bytes&lt;br /&gt;
	     &amp;quot;st_blocks&amp;quot;:   val - size in blocks&lt;br /&gt;
	     &amp;quot;st_nlink&amp;quot;:    val - number of hardlinks&lt;br /&gt;
	     &amp;quot;st_ifmt&amp;quot;:     val - &amp;quot;S_IFDIR&amp;quot; for folders&lt;br /&gt;
	                        &amp;quot;S_IFLNK&amp;quot; for symlinks&lt;br /&gt;
	     &amp;quot;LinkTarget&amp;quot;:  val - path to symlink target&lt;br /&gt;
	*/&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCKeyValueRead(struct afc_dictionary *dict, char **key, char **&lt;br /&gt;
								val);&lt;br /&gt;
	/* Closes dictionary&lt;br /&gt;
	*/&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCKeyValueClose(struct afc_dictionary *dict);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	/* Returns the context field of the given AFC connection. */&lt;br /&gt;
	__DLLIMPORT unsigned int AFCConnectionGetContext(struct afc_connection *conn);&lt;br /&gt;
	&lt;br /&gt;
	/* Returns the fs_block_size field of the given AFC connection. */&lt;br /&gt;
	__DLLIMPORT unsigned int AFCConnectionGetFSBlockSize(struct afc_connection *conn);&lt;br /&gt;
	&lt;br /&gt;
	/* Returns the io_timeout field of the given AFC connection. In iTunes this is&lt;br /&gt;
	 * 0. */&lt;br /&gt;
	__DLLIMPORT unsigned int AFCConnectionGetIOTimeout(struct afc_connection *conn);&lt;br /&gt;
	&lt;br /&gt;
	/* Returns the sock_block_size field of the given AFC connection. */&lt;br /&gt;
	__DLLIMPORT unsigned int AFCConnectionGetSocketBlockSize(struct afc_connection *conn);&lt;br /&gt;
	&lt;br /&gt;
	/* Closes the given AFC connection. */&lt;br /&gt;
	__DLLIMPORT afc_error_t AFCConnectionClose(struct afc_connection *conn);&lt;br /&gt;
	&lt;br /&gt;
	/* Registers for device notifications related to the restore process. unknown0&lt;br /&gt;
	 * is zero when iTunes calls this. In iTunes,&lt;br /&gt;
	 * the callbacks are located at:&lt;br /&gt;
	 *      1: $3ac68e-$3ac6b1, calls $3ac542(unknown1, arg, 0)&lt;br /&gt;
	 *      2: $3ac66a-$3ac68d, calls $3ac542(unknown1, 0, arg)&lt;br /&gt;
	 *      3: $3ac762-$3ac785, calls $3ac6b2(unknown1, arg, 0)&lt;br /&gt;
	 *      4: $3ac73e-$3ac761, calls $3ac6b2(unknown1, 0, arg)&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT unsigned int AMRestoreRegisterForDeviceNotifications(&lt;br /&gt;
				am_restore_device_notification_callback dfu_connect_callback,&lt;br /&gt;
				am_restore_device_notification_callback recovery_connect_callback,&lt;br /&gt;
				am_restore_device_notification_callback dfu_disconnect_callback,&lt;br /&gt;
				am_restore_device_notification_callback recovery_disconnect_callback,&lt;br /&gt;
				unsigned int unknown0,&lt;br /&gt;
				void *user_info);&lt;br /&gt;
	&lt;br /&gt;
	/* Causes the restore functions to spit out (unhelpful) progress messages to&lt;br /&gt;
	 * the file specified by the given path. iTunes always calls this right before&lt;br /&gt;
	 * restoring with a path of&lt;br /&gt;
	 * &amp;quot;$HOME/Library/Logs/iPhone Updater Logs/iPhoneUpdater X.log&amp;quot;, where X is an&lt;br /&gt;
	 * unused number.&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT unsigned int AMRestoreEnableFileLogging(char *path);&lt;br /&gt;
	&lt;br /&gt;
	/* Initializes a new option dictionary to default values. Pass the constant&lt;br /&gt;
	 * kCFAllocatorDefault as the allocator. The option dictionary looks as&lt;br /&gt;
	 * follows:&lt;br /&gt;
	 * {&lt;br /&gt;
	 *      NORImageType =&amp;gt; 'production',&lt;br /&gt;
	 *      AutoBootDelay =&amp;gt; 0,&lt;br /&gt;
	 *      KernelCacheType =&amp;gt; 'Release',&lt;br /&gt;
	 *      UpdateBaseband =&amp;gt; true,&lt;br /&gt;
	 *      DFUFileType =&amp;gt; 'RELEASE',&lt;br /&gt;
	 *      SystemImageType =&amp;gt; 'User',&lt;br /&gt;
	 *      CreateFilesystemPartitions =&amp;gt; true,&lt;br /&gt;
	 *      FlashNOR =&amp;gt; true,&lt;br /&gt;
	 *      RestoreBootArgs =&amp;gt; 'rd=md0 nand-enable-reformat=1 -progress'&lt;br /&gt;
	 *      BootImageType =&amp;gt; 'User'&lt;br /&gt;
	 *  }&lt;br /&gt;
	 *&lt;br /&gt;
	 * Returns:&lt;br /&gt;
	 *      the option dictionary   if successful&lt;br /&gt;
	 *      NULL                    if out of memory&lt;br /&gt;
	 */ &lt;br /&gt;
	__DLLIMPORT CFMutableDictionaryRef AMRestoreCreateDefaultOptions(CFAllocatorRef allocator);&lt;br /&gt;
	&lt;br /&gt;
	/* ----------------------------------------------------------------------------&lt;br /&gt;
	 *   Less-documented public routines&lt;br /&gt;
	 * ------------------------------------------------------------------------- */&lt;br /&gt;
	&lt;br /&gt;
	__DLLIMPORT unsigned int AMRestorePerformRecoveryModeRestore(struct am_recovery_device *&lt;br /&gt;
				rdev, CFDictionaryRef opts, void *callback, void *user_info);&lt;br /&gt;
	__DLLIMPORT unsigned int AMRestorePerformRestoreModeRestore(struct am_restore_device *&lt;br /&gt;
				rdev, CFDictionaryRef opts, void *callback, void *user_info);&lt;br /&gt;
	__DLLIMPORT struct am_restore_device *AMRestoreModeDeviceCreate(unsigned int unknown0,&lt;br /&gt;
				unsigned int connection_id, unsigned int unknown1);&lt;br /&gt;
	__DLLIMPORT unsigned int AMRestoreCreatePathsForBundle(CFStringRef restore_bundle_path,&lt;br /&gt;
				CFStringRef kernel_cache_type, CFStringRef boot_image_type, unsigned int&lt;br /&gt;
				unknown0, CFStringRef *firmware_dir_path, CFStringRef *&lt;br /&gt;
				kernelcache_restore_path, unsigned int unknown1, CFStringRef *&lt;br /&gt;
				ramdisk_path);&lt;br /&gt;
	__DLLIMPORT unsigned int AMRestoreModeDeviceReboot(struct am_restore_device *rdev);	// Added by JB 30.07.2008&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceEnterRecovery(struct am_device *device);&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceDisconnect(struct am_device *device);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	/* to use this, start the service &amp;quot;com.apple.mobile.notification_proxy&amp;quot;, handle will be the socket to use */&lt;br /&gt;
	typedef void (*NOTIFY_CALLBACK)(CFSTR notification, USERDATA data);&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDPostNotification(SOCKET socket, CFStringRef  notification, CFStringRef userinfo);&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDObserveNotification(SOCKET socket, CFSTR notification);&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDListenForNotifications(SOCKET socket, NOTIFY_CALLBACK cb, USERDATA data);&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDShutdownNotificationProxy(SOCKET socket);&lt;br /&gt;
	&lt;br /&gt;
	/*edits by geohot*/&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceDeactivate(struct am_device *device);&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceActivate(struct am_device *device, CFDictionaryRef dict);&lt;br /&gt;
	__DLLIMPORT mach_error_t AMDeviceRemoveValue(struct am_device *device, unsigned int, CFStringRef cfstring);&lt;br /&gt;
	&lt;br /&gt;
	/* ----------------------------------------------------------------------------&lt;br /&gt;
	 *   Semi-private routines&lt;br /&gt;
	 * ------------------------------------------------------------------------- */&lt;br /&gt;
	&lt;br /&gt;
	/*  Pass in a usbmux_listener_1 structure and a usbmux_listener_2 structure&lt;br /&gt;
	 *  pointer, which will be filled with the resulting usbmux_listener_2.&lt;br /&gt;
	 *&lt;br /&gt;
	 *  Returns:&lt;br /&gt;
	 *      MDERR_OK                if completed successfully&lt;br /&gt;
	 *      MDERR_USBMUX_ARG_NULL   if one of the arguments was NULL&lt;br /&gt;
	 *      MDERR_USBMUX_FAILED     if the listener was not created successfully&lt;br /&gt;
	 */&lt;br /&gt;
	__DLLIMPORT usbmux_error_t USBMuxListenerCreate(struct usbmux_listener_1 *esi_fp8, struct&lt;br /&gt;
										usbmux_listener_2 **eax_fp12);&lt;br /&gt;
	&lt;br /&gt;
	/* ----------------------------------------------------------------------------&lt;br /&gt;
	 *   Less-documented semi-private routines&lt;br /&gt;
	 * ------------------------------------------------------------------------- */&lt;br /&gt;
	__DLLIMPORT usbmux_error_t USBMuxListenerHandleData(void *);&lt;br /&gt;
	&lt;br /&gt;
	/* ----------------------------------------------------------------------------&lt;br /&gt;
	 *   Private routines - here be dragons&lt;br /&gt;
	 * ------------------------------------------------------------------------- */&lt;br /&gt;
	&lt;br /&gt;
	/* AMRestorePerformRestoreModeRestore() calls this function with a dictionary&lt;br /&gt;
	 * in order to perform certain special restore operations&lt;br /&gt;
	 * (RESTORED_OPERATION_*). It is thought that this function might enable&lt;br /&gt;
	 * significant access to the phone. */&lt;br /&gt;
	&lt;br /&gt;
	/*&lt;br /&gt;
	 typedef unsigned int (*t_performOperation)(struct am_restore_device *rdev,&lt;br /&gt;
	 CFDictionaryRef op) __attribute__ ((regparm(2)));&lt;br /&gt;
	 t_performOperation _performOperation = (t_performOperation)0x3c39fa4b;&lt;br /&gt;
	 */ &lt;br /&gt;
	&lt;br /&gt;
	/* ----------------------------------------------------------------------------&lt;br /&gt;
	 *   Less-documented private routines&lt;br /&gt;
	 * ------------------------------------------------------------------------- */&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	/*&lt;br /&gt;
	 typedef int (*t_socketForPort)(struct am_restore_device *rdev, unsigned int port)&lt;br /&gt;
	 __attribute__ ((regparm(2)));&lt;br /&gt;
	 t_socketForPort _socketForPort = (t_socketForPort)(void *)0x3c39f36c;&lt;br /&gt;
	 &lt;br /&gt;
	 typedef void (*t_restored_send_message)(int port, CFDictionaryRef msg);&lt;br /&gt;
	 t_restored_send_message _restored_send_message = (t_restored_send_message)0x3c3a4e40;&lt;br /&gt;
	 &lt;br /&gt;
	 typedef CFDictionaryRef (*t_restored_receive_message)(int port);&lt;br /&gt;
	 t_restored_receive_message _restored_receive_message = (t_restored_receive_message)0x3c3a4d40;&lt;br /&gt;
	 &lt;br /&gt;
	 typedef unsigned int (*t_sendControlPacket)(struct am_recovery_device *rdev, unsigned&lt;br /&gt;
	 int msg1, unsigned int msg2, unsigned int unknown0, unsigned int *unknown1,&lt;br /&gt;
	 unsigned char *unknown2) __attribute__ ((regparm(3)));&lt;br /&gt;
	 t_sendControlPacket _sendControlPacket = (t_sendControlPacket)0x3c3a3da3;;&lt;br /&gt;
	 &lt;br /&gt;
	 typedef unsigned int (*t_sendCommandToDevice)(struct am_recovery_device *rdev,&lt;br /&gt;
	 CFStringRef cmd) __attribute__ ((regparm(2)));&lt;br /&gt;
	 t_sendCommandToDevice _sendCommandToDevice = (t_sendCommandToDevice)0x3c3a3e3b;&lt;br /&gt;
	 &lt;br /&gt;
	 typedef unsigned int (*t_AMRUSBInterfaceReadPipe)(unsigned int readwrite_pipe, unsigned&lt;br /&gt;
	 int read_pipe, unsigned char *data, unsigned int *len);&lt;br /&gt;
	 t_AMRUSBInterfaceReadPipe _AMRUSBInterfaceReadPipe = (t_AMRUSBInterfaceReadPipe)0x3c3a27e8;&lt;br /&gt;
	 &lt;br /&gt;
	 typedef unsigned int (*t_AMRUSBInterfaceWritePipe)(unsigned int readwrite_pipe, unsigned&lt;br /&gt;
	 int write_pipe, void *data, unsigned int len);&lt;br /&gt;
	 t_AMRUSBInterfaceWritePipe _AMRUSBInterfaceWritePipe = (t_AMRUSBInterfaceWritePipe)0x3c3a27cb;&lt;br /&gt;
	 */&lt;br /&gt;
	&lt;br /&gt;
	int performOperation(am_restore_device *rdev, CFMutableDictionaryRef message);&lt;br /&gt;
	int socketForPort(am_restore_device *rdev, unsigned int portnum);&lt;br /&gt;
	int sendCommandToDevice(am_recovery_device *rdev, CFStringRef cfs, int block);&lt;br /&gt;
	int sendFileToDevice(am_recovery_device *rdev, CFStringRef filename); &lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
#ifdef __cplusplus&lt;br /&gt;
}&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
/* -*- mode:c; indent-tabs-mode:nil; c-basic-offset:2; tab-width:2; */&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===AFC Connection===&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
===Locking the Device for Sync===&lt;br /&gt;
When iTunes sends a new song to the device, the device shows a &amp;quot;Sync in progress&amp;quot; screen and when complete, the Music app on the device re-reads the iTunesDB file so it picks up the new song.&lt;br /&gt;
&lt;br /&gt;
To get this behaviour, first start the notification service:&lt;br /&gt;
&amp;lt;pre&amp;gt;SOCKET socket;&lt;br /&gt;
AMDeviceStartService(dev, CFSTR(&amp;quot;com.apple.mobile.notification_proxy&amp;quot;), &amp;amp;socket, NULL);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we post a notificaton message to signal that we are going to start a sync:&lt;br /&gt;
&amp;lt;pre&amp;gt;AMDPostNotification(socket, CFSTR(&amp;quot;com.apple.itunes-mobdev.syncWillStart&amp;quot;), NULL);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next we open the itunes lock file:&lt;br /&gt;
&amp;lt;pre&amp;gt;afc_file_ref lockref;&lt;br /&gt;
AFCFileRefOpen(conn, &amp;quot;/com.apple.itunes.lock_sync&amp;quot;, 2, &amp;amp;lockref);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now post a notification to say we are going to lock this file, and try and lock it.&lt;br /&gt;
If the AFCFileRefLock call fails, pause and repeat.&lt;br /&gt;
&amp;lt;pre&amp;gt;AMDPostNotification(socket, CFSTR(&amp;quot;com.apple.itunes-mobdev.syncLockRequest&amp;quot;), NULL);&lt;br /&gt;
mach_error_t error = AFCFileRefLock(conn, lockref);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the file is successfully locked, post another notification, and stop the notification service.&lt;br /&gt;
&amp;lt;pre&amp;gt;AMDPostNotification(socket,CFSTR(&amp;quot;com.apple.itunes-mobdev.syncDidStart&amp;quot;), NULL);&lt;br /&gt;
AMDShutdownNotificationProxy(socket);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now the sync can proceed, so copy your files across and make the changes to the iTunesDB.&lt;br /&gt;
&lt;br /&gt;
To release the lock, start the notification system again, unlock and close the lock file, and send a sync finished notification message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;AFCFileRefUnlock(conn, lockref);&lt;br /&gt;
AFCFileRefClose(conn, lockref);&lt;br /&gt;
AMDeviceStartService(dev, CFSTR(&amp;quot;com.apple.mobile.notification_proxy&amp;quot;), &amp;amp;socket, NULL);&lt;br /&gt;
AMDPostNotification(socket, &amp;amp;CFSTR(&amp;quot;com.apple.itunes-mobdev.syncDidFinish&amp;quot;), NULL);&lt;br /&gt;
AMDShutdownNotificationProxy(socket);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To handle &amp;quot;Slide to Cancel&amp;quot; and terminate sync when user slides cancel switch, use AMDObserveNotification to subscribe notifications about “com.apple.itunes-client.syncCancelRequest”. Then start listening for notifications (AMDListenForNotifications) until you get “AMDNotificationFaceplant”.&lt;br /&gt;
When notification got, you should unlock and close lock file handle (don’t sure if you need to post “syncDidFinish” to proxy, seems it doesn’t matter) and terminate sync gracefully.&lt;br /&gt;
The same notification is also got when you unplug your device, so you should always be ready for errors.&lt;br /&gt;
&lt;br /&gt;
NOTE: You may find that starting the notification_proxy service once and once only at the start of your app and using the same socket in calls to AMDPostNotification works better. iTunes opens and closes the notification_proxy regularly, but it appears to be a bit flakey when you open/close it all the time.&lt;br /&gt;
&lt;br /&gt;
===Private Functions===&lt;br /&gt;
&lt;br /&gt;
====How to find address of privates functions in iTunesMobileDevice.dll or MobileDevice.framework====&lt;br /&gt;
&lt;br /&gt;
In order to obtain the address of a usable private function in MobileDevice, you will have to be able to understand x86-64 assembly to reverse engineer it. A private function will not have its name exported in the mach-o symbol table, so in a debugger, like GDB, it will show up as part of another function. However, you will know that it is a separate function as a new stack frame is set up.&lt;br /&gt;
&lt;br /&gt;
====Private Function Address List====&lt;br /&gt;
&lt;br /&gt;
=====OSX.6 - iTunes 9.0.2(25)=====&lt;br /&gt;
&amp;lt;pre&amp;gt;unsigned int sendCommandToiBoot(struct am_recovery_device *rdev, CFStringRef command, int u);&amp;lt;/pre&amp;gt;&lt;br /&gt;
Address is obtainable by adding 868(0x364) to the address of AMRecoveryDeviceGetProductType(), a public symbol that you can obtain via nlist() or dlsym(). &lt;br /&gt;
Address: 0x1000245ea&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
1. rdev - the device you wish to send the command to.&lt;br /&gt;
2. a CFStringRef of the command to send.&lt;br /&gt;
3. an integer, whose use is currently unknown, but should be set to 0 to work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;unsigned int sendFileToiDevice(struct am_recovery_device *rdev, CFStringRef filename);&amp;lt;/pre&amp;gt;&lt;br /&gt;
Address is obtainable by adding 1763(0x6e3) to the address of AMRecoveryDeviceGetProductType(), a public symbol that you can obtain via nlist() or dlsym().&lt;br /&gt;
Address: 0x100024969&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
1. rdev - the device you wish to send the file to.&lt;br /&gt;
2. a CFStringRef of the path to the file to send.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====OSX.6 - iTunes 9.0.3(15)=====&lt;br /&gt;
&amp;lt;pre&amp;gt;unsigned int sendCommandToiBoot(struct am_recovery_device *rdev, CFStringRef command, int u);&amp;lt;/pre&amp;gt;&lt;br /&gt;
Addresss: AMRecoveryDeviceGetProductType() + 0x37f(895); full offset: 0x2a0ed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;unsigned int sendFileToiDevice(struct am_recovery_device *rdev, CFStringRef filename);&amp;lt;/pre&amp;gt;&lt;br /&gt;
Address: AMRecoveryDeviceGetProductType()+0x6f3(1790); full offset: 0x2a46c&lt;br /&gt;
&lt;br /&gt;
===Libraries Implementations===&lt;br /&gt;
&lt;br /&gt;
* [http://gojohnnyboi.com/source/afcinstall.cpp afcinstall (command line, os x file install via afc)]&lt;br /&gt;
* [http://code.google.com/p/iphuc/ iPhuc (Command line utility)]&lt;br /&gt;
* [http://code.google.com/p/iphucwin32/ iPhuc Win32 (Command line utility)]&lt;br /&gt;
* [http://code.google.com/p/manzana/ manzana (.Net Library)]&lt;br /&gt;
* [http://code.google.com/p/independence/source/browse/trunk/libPhoneInteraction/ libPhoneInteraction (C Library)]&lt;/div&gt;</summary>
		<author><name>DarkMalloc</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=MobileDevice_Library&amp;diff=6438</id>
		<title>MobileDevice Library</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=MobileDevice_Library&amp;diff=6438"/>
		<updated>2010-05-27T18:51:59Z</updated>

		<summary type="html">&lt;p&gt;DarkMalloc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;MobileDevice Library is used by [[iTunes]] to transfer data between iPhone and computer over the USB connection.&lt;br /&gt;
&lt;br /&gt;
===PC Windows : iTunesMobileDevice.dll===&lt;br /&gt;
&lt;br /&gt;
* Location : Location is stored in '''iTunesMobileDeviceDLL''' registry value under '''HKLM\SOFTWARE\Apple Inc.\Apple Mobile Device Support\Shared''' key. Usually - C:\Program Files\Common Files\Apple\Mobile Device Support\bin\iTunesMobileDevice.dll.&lt;br /&gt;
&lt;br /&gt;
* Supporting CoreFoundation.dll (used for CFStringRef, CFPropertyListRef management) is located in the same dir (when using iTunes prior 9.0). &lt;br /&gt;
&lt;br /&gt;
* For iTunes 9.0 location of CoreFoundation.dll is stored in '''InstallDir''' registry value under '''HKLM\SOFTWARE\Apple Inc.\Apple Application Support''' key, usually C:\Program Files\Common Files\Apple\Apple Application Support\. CoreFoundation.dll from Mobile Device Support\bin should not be used.&lt;br /&gt;
&lt;br /&gt;
===Mac OSX : MobileDevice.framework===&lt;br /&gt;
&lt;br /&gt;
* Location : /System/Library/PrivateFrameworks/MobileDevice.framework&lt;br /&gt;
* Export command : &amp;quot;nm /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===MobileDevice Header (mobiledevice.h)===&lt;br /&gt;
&lt;br /&gt;
Reverse engineered C header for MobileDevice Library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#ifndef MOBILEDEVICE_H&lt;br /&gt;
#define MOBILEDEVICE_H&lt;br /&gt;
&lt;br /&gt;
#define CF_BUILDING_CF_AS_LIB&lt;br /&gt;
#include &amp;lt;CoreFoundation/CoreFoundation.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
//typedef unsigned int unsigned int;&lt;br /&gt;
&lt;br /&gt;
/* Error codes */&lt;br /&gt;
#define MDERR_APPLE_MOBILE  (err_system(0x3a))&lt;br /&gt;
#define MDERR_IPHONE        (err_sub(0))&lt;br /&gt;
&lt;br /&gt;
/* Apple Mobile (AM*) errors */&lt;br /&gt;
#define MDERR_OK                ERR_SUCCESS&lt;br /&gt;
#define MDERR_SYSCALL           (ERR_MOBILE_DEVICE | 0x01)&lt;br /&gt;
#define MDERR_OUT_OF_MEMORY     (ERR_MOBILE_DEVICE | 0x03)&lt;br /&gt;
#define MDERR_QUERY_FAILED      (ERR_MOBILE_DEVICE | 0x04) &lt;br /&gt;
#define MDERR_INVALID_ARGUMENT  (ERR_MOBILE_DEVICE | 0x0b)&lt;br /&gt;
#define MDERR_DICT_NOT_LOADED   (ERR_MOBILE_DEVICE | 0x25)&lt;br /&gt;
&lt;br /&gt;
/* Messages passed to device notification callbacks: passed as part of&lt;br /&gt;
 * am_device_notification_callback_info. */&lt;br /&gt;
#define ADNCI_MSG_CONNECTED     1&lt;br /&gt;
#define ADNCI_MSG_DISCONNECTED  2&lt;br /&gt;
#define ADNCI_MSG_UNKNOWN       3&lt;br /&gt;
&lt;br /&gt;
typedef struct am_recovery_device am_recovery_device;&lt;br /&gt;
&lt;br /&gt;
struct am_device_notification_callback_info {&lt;br /&gt;
    struct am_device *dev;  /* 0    device */ &lt;br /&gt;
    unsigned int msg;       /* 4    one of ADNCI_MSG_* */&lt;br /&gt;
} __attribute__ ((packed));&lt;br /&gt;
&lt;br /&gt;
/* The type of the device notification callback function. */&lt;br /&gt;
typedef void(*am_device_notification_callback)(struct&lt;br /&gt;
											   am_device_notification_callback_info *);&lt;br /&gt;
&lt;br /&gt;
/* The type of the device restore notification callback functions.&lt;br /&gt;
 * TODO: change to correct type. */&lt;br /&gt;
typedef void (*am_restore_device_notification_callback)(am_recovery_device *);&lt;br /&gt;
&lt;br /&gt;
/* This is a CoreFoundation object of class AMRecoveryModeDevice. */&lt;br /&gt;
struct am_recovery_device {&lt;br /&gt;
    unsigned char unknown0[8];                          /* 0 */&lt;br /&gt;
    am_restore_device_notification_callback callback;   /* 8 */&lt;br /&gt;
    void *user_info;                                    /* 12 */&lt;br /&gt;
    unsigned char unknown1[12];                         /* 16 */&lt;br /&gt;
    unsigned int readwrite_pipe;                        /* 28 */&lt;br /&gt;
    unsigned char read_pipe;                            /* 32 */&lt;br /&gt;
    unsigned char write_ctrl_pipe;                      /* 33 */&lt;br /&gt;
    unsigned char read_unknown_pipe;                    /* 34 */&lt;br /&gt;
    unsigned char write_file_pipe;                      /* 35 */&lt;br /&gt;
    unsigned char write_input_pipe;                     /* 36 */&lt;br /&gt;
} __attribute__ ((packed));&lt;br /&gt;
&lt;br /&gt;
struct afc_connection {&lt;br /&gt;
	unsigned int handle;            /* 0 */&lt;br /&gt;
	unsigned int unknown0;          /* 4 */&lt;br /&gt;
	unsigned char unknown1;         /* 8 */&lt;br /&gt;
	unsigned char padding[3];       /* 9 */&lt;br /&gt;
	unsigned int unknown2;          /* 12 */&lt;br /&gt;
	unsigned int unknown3;          /* 16 */&lt;br /&gt;
	unsigned int unknown4;          /* 20 */&lt;br /&gt;
	unsigned int fs_block_size;     /* 24 */&lt;br /&gt;
	unsigned int sock_block_size;   /* 28: always 0x3c */&lt;br /&gt;
	unsigned int io_timeout;        /* 32: from AFCConnectionOpen, usu. 0 */&lt;br /&gt;
	void *afc_lock;                 /* 36 */&lt;br /&gt;
	unsigned int context;           /* 40 */&lt;br /&gt;
} __attribute__ ((packed));&lt;br /&gt;
&lt;br /&gt;
/* A CoreFoundation object of class AMRestoreModeDevice. */&lt;br /&gt;
struct am_restore_device {&lt;br /&gt;
    unsigned char unknown[32];&lt;br /&gt;
    int port;&lt;br /&gt;
} __attribute__ ((packed));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/* The type of the _AMDDeviceAttached function.&lt;br /&gt;
 * TODO: change to correct type. */&lt;br /&gt;
typedef void *amd_device_attached_callback;&lt;br /&gt;
&lt;br /&gt;
struct am_device {&lt;br /&gt;
	unsigned char unknown0[16]; /* 0 - zero */&lt;br /&gt;
	unsigned int device_id;     /* 16 */&lt;br /&gt;
	unsigned int product_id;    /* 20 - set to AMD_IPHONE_PRODUCT_ID */&lt;br /&gt;
	char *serial;               /* 24 - set to UDID, Unique Device Identifier */&lt;br /&gt;
	unsigned int unknown1;      /* 28 */&lt;br /&gt;
	unsigned int unknown2;      /* 32 - reference counter, increased by AMDeviceRetain, decreased by AMDeviceRelease*/&lt;br /&gt;
	unsigned int lockdown_conn; /* 36 */&lt;br /&gt;
	unsigned char unknown3[8];  /* 40 */&lt;br /&gt;
	unsigned int unknown4;      /* 48 - used to store CriticalSection Handle*/&lt;br /&gt;
	unsigned char unknown5[24];  /* 52 */&lt;br /&gt;
} __attribute__ ((packed));&lt;br /&gt;
&lt;br /&gt;
struct am_device_notification {&lt;br /&gt;
    unsigned int unknown0;                      /* 0 */&lt;br /&gt;
    unsigned int unknown1;                      /* 4 */&lt;br /&gt;
    unsigned int unknown2;                      /* 8 */&lt;br /&gt;
    am_device_notification_callback callback;   /* 12 */ &lt;br /&gt;
    unsigned int unknown3;                      /* 16 */&lt;br /&gt;
} __attribute__ ((packed));&lt;br /&gt;
&lt;br /&gt;
unsigned int AMDeviceNotificationSubscribe(am_device_notification_callback&lt;br /&gt;
										   callback, unsigned int unused0, unsigned int unused1, unsigned int&lt;br /&gt;
										   dn_unknown3, struct am_device_notification **notification);&lt;br /&gt;
&lt;br /&gt;
unsigned int AMRestoreRegisterForDeviceNotifications(&lt;br /&gt;
													 am_restore_device_notification_callback dfu_connect_callback,&lt;br /&gt;
													 am_restore_device_notification_callback recovery_connect_callback,&lt;br /&gt;
													 am_restore_device_notification_callback dfu_disconnect_callback,&lt;br /&gt;
													 am_restore_device_notification_callback recovery_disconnect_callback,&lt;br /&gt;
													 unsigned int unknown0,&lt;br /&gt;
													 void *user_info);&lt;br /&gt;
&lt;br /&gt;
CFMutableDictionaryRef AMRestoreCreateDefaultOptions(CFAllocatorRef allocator);&lt;br /&gt;
&lt;br /&gt;
unsigned int AMRestoreEnableFileLogging(char *path);&lt;br /&gt;
unsigned int AMDeviceEnterRecovery(struct am_device *device);&lt;br /&gt;
&lt;br /&gt;
unsigned int AMDeviceRetain(struct am_device *device);&lt;br /&gt;
CFStringRef AMDeviceCopyValue(struct am_device *device, CFStringRef domain, CFStringRef cfstring);&lt;br /&gt;
&lt;br /&gt;
unsigned int AMDeviceStartService(struct am_device *device, CFStringRef service_name, void **handle, int *socket_fd);&lt;br /&gt;
&lt;br /&gt;
unsigned int AMDPostNotification(int socket, CFStringRef  notification, CFStringRef userinfo);&lt;br /&gt;
unsigned int AMDeviceConnect(struct am_device *device);&lt;br /&gt;
&lt;br /&gt;
unsigned int AMDShutdownNotificationProxy(int socket);&lt;br /&gt;
&lt;br /&gt;
unsigned int AMDeviceIsPaired(struct am_device *device);&lt;br /&gt;
unsigned int AMDevicePair(struct am_device *device);&lt;br /&gt;
unsigned int AMDeviceValidatePairing(struct am_device *device);&lt;br /&gt;
unsigned int AMDeviceStartSession(struct am_device *device);&lt;br /&gt;
&lt;br /&gt;
unsigned int AMRestorePerformDFURestore(struct am_recovery_device *rdev, CFDictionaryRef opts, void *callback, void *user_info);&lt;br /&gt;
&lt;br /&gt;
int sendCommandToDevice(am_recovery_device *rdev, CFStringRef cfs, int block);&lt;br /&gt;
int sendFileToDevice(am_recovery_device *rdev, CFStringRef filename);&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===AFC Connection===&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
===Locking the Device for Sync===&lt;br /&gt;
When iTunes sends a new song to the device, the device shows a &amp;quot;Sync in progress&amp;quot; screen and when complete, the Music app on the device re-reads the iTunesDB file so it picks up the new song.&lt;br /&gt;
&lt;br /&gt;
To get this behaviour, first start the notification service:&lt;br /&gt;
&amp;lt;pre&amp;gt;SOCKET socket;&lt;br /&gt;
AMDeviceStartService(dev, CFSTR(&amp;quot;com.apple.mobile.notification_proxy&amp;quot;), &amp;amp;socket, NULL);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we post a notificaton message to signal that we are going to start a sync:&lt;br /&gt;
&amp;lt;pre&amp;gt;AMDPostNotification(socket, CFSTR(&amp;quot;com.apple.itunes-mobdev.syncWillStart&amp;quot;), NULL);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next we open the itunes lock file:&lt;br /&gt;
&amp;lt;pre&amp;gt;afc_file_ref lockref;&lt;br /&gt;
AFCFileRefOpen(conn, &amp;quot;/com.apple.itunes.lock_sync&amp;quot;, 2, &amp;amp;lockref);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now post a notification to say we are going to lock this file, and try and lock it.&lt;br /&gt;
If the AFCFileRefLock call fails, pause and repeat.&lt;br /&gt;
&amp;lt;pre&amp;gt;AMDPostNotification(socket, CFSTR(&amp;quot;com.apple.itunes-mobdev.syncLockRequest&amp;quot;), NULL);&lt;br /&gt;
mach_error_t error = AFCFileRefLock(conn, lockref);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the file is successfully locked, post another notification, and stop the notification service.&lt;br /&gt;
&amp;lt;pre&amp;gt;AMDPostNotification(socket,CFSTR(&amp;quot;com.apple.itunes-mobdev.syncDidStart&amp;quot;), NULL);&lt;br /&gt;
AMDShutdownNotificationProxy(socket);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now the sync can proceed, so copy your files across and make the changes to the iTunesDB.&lt;br /&gt;
&lt;br /&gt;
To release the lock, start the notification system again, unlock and close the lock file, and send a sync finished notification message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;AFCFileRefUnlock(conn, lockref);&lt;br /&gt;
AFCFileRefClose(conn, lockref);&lt;br /&gt;
AMDeviceStartService(dev, CFSTR(&amp;quot;com.apple.mobile.notification_proxy&amp;quot;), &amp;amp;socket, NULL);&lt;br /&gt;
AMDPostNotification(socket, &amp;amp;CFSTR(&amp;quot;com.apple.itunes-mobdev.syncDidFinish&amp;quot;), NULL);&lt;br /&gt;
AMDShutdownNotificationProxy(socket);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To handle &amp;quot;Slide to Cancel&amp;quot; and terminate sync when user slides cancel switch, use AMDObserveNotification to subscribe notifications about “com.apple.itunes-client.syncCancelRequest”. Then start listening for notifications (AMDListenForNotifications) until you get “AMDNotificationFaceplant”.&lt;br /&gt;
When notification got, you should unlock and close lock file handle (don’t sure if you need to post “syncDidFinish” to proxy, seems it doesn’t matter) and terminate sync gracefully.&lt;br /&gt;
The same notification is also got when you unplug your device, so you should always be ready for errors.&lt;br /&gt;
&lt;br /&gt;
NOTE: You may find that starting the notification_proxy service once and once only at the start of your app and using the same socket in calls to AMDPostNotification works better. iTunes opens and closes the notification_proxy regularly, but it appears to be a bit flakey when you open/close it all the time.&lt;br /&gt;
&lt;br /&gt;
===Private Functions===&lt;br /&gt;
&lt;br /&gt;
====How to find address of privates functions in iTunesMobileDevice.dll or MobileDevice.framework====&lt;br /&gt;
&lt;br /&gt;
In order to obtain the address of a usable private function in MobileDevice, you will have to be able to understand x86-64 assembly to reverse engineer it. A private function will not have its name exported in the mach-o symbol table, so in a debugger, like GDB, it will show up as part of another function. However, you will know that it is a separate function as a new stack frame is set up.&lt;br /&gt;
&lt;br /&gt;
====Private Function Address List====&lt;br /&gt;
&lt;br /&gt;
=====OSX.6 - iTunes 9.0.2(25)=====&lt;br /&gt;
&amp;lt;pre&amp;gt;unsigned int sendCommandToiBoot(struct am_recovery_device *rdev, CFStringRef command, int u);&amp;lt;/pre&amp;gt;&lt;br /&gt;
Address is obtainable by adding 868(0x364) to the address of AMRecoveryDeviceGetProductType(), a public symbol that you can obtain via nlist() or dlsym(). &lt;br /&gt;
Address: 0x1000245ea&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
1. rdev - the device you wish to send the command to.&lt;br /&gt;
2. a CFStringRef of the command to send.&lt;br /&gt;
3. an integer, whose use is currently unknown, but should be set to 0 to work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;unsigned int sendFileToiDevice(struct am_recovery_device *rdev, CFStringRef filename);&amp;lt;/pre&amp;gt;&lt;br /&gt;
Address is obtainable by adding 1763(0x6e3) to the address of AMRecoveryDeviceGetProductType(), a public symbol that you can obtain via nlist() or dlsym().&lt;br /&gt;
Address: 0x100024969&lt;br /&gt;
&lt;br /&gt;
Parameters&lt;br /&gt;
1. rdev - the device you wish to send the file to.&lt;br /&gt;
2. a CFStringRef of the path to the file to send.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====OSX.6 - iTunes 9.0.3(15)=====&lt;br /&gt;
&amp;lt;pre&amp;gt;unsigned int sendCommandToiBoot(struct am_recovery_device *rdev, CFStringRef command, int u);&amp;lt;/pre&amp;gt;&lt;br /&gt;
Addresss: AMRecoveryDeviceGetProductType() + 0x37f(895); full offset: 0x2a0ed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;unsigned int sendFileToiDevice(struct am_recovery_device *rdev, CFStringRef filename);&amp;lt;/pre&amp;gt;&lt;br /&gt;
Address: AMRecoveryDeviceGetProductType()+0x6f3(1790); full offset: 0x2a46c&lt;br /&gt;
&lt;br /&gt;
===Libraries Implementations===&lt;br /&gt;
&lt;br /&gt;
* [http://gojohnnyboi.com/source/afcinstall.cpp afcinstall (command line, os x file install via afc)]&lt;br /&gt;
* [http://code.google.com/p/iphuc/ iPhuc (Command line utility)]&lt;br /&gt;
* [http://code.google.com/p/iphucwin32/ iPhuc Win32 (Command line utility)]&lt;br /&gt;
* [http://code.google.com/p/manzana/ manzana (.Net Library)]&lt;br /&gt;
* [http://code.google.com/p/independence/source/browse/trunk/libPhoneInteraction/ libPhoneInteraction (C Library)]&lt;/div&gt;</summary>
		<author><name>DarkMalloc</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=S5L8922&amp;diff=5917</id>
		<title>S5L8922</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=S5L8922&amp;diff=5917"/>
		<updated>2010-03-26T16:44:06Z</updated>

		<summary type="html">&lt;p&gt;DarkMalloc: Added load address.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the processor used in the [[N18ap|iPod Touch 3G]].&lt;br /&gt;
&lt;br /&gt;
== Exploits ==&lt;br /&gt;
=== [[iBoot]] / [[Kernel]] ===&lt;br /&gt;
* [[usb_control_msg(0x21, 2) Exploit]] - 3.1.2 and below.&lt;br /&gt;
&lt;br /&gt;
==Information==&lt;br /&gt;
&lt;br /&gt;
The load address is at 0x41000000 (same as the S5l8920).&lt;br /&gt;
&lt;br /&gt;
=== [[S5L8922 (Bootrom)|Bootrom]] ===&lt;br /&gt;
&lt;br /&gt;
== Boot Chain ==&lt;br /&gt;
[[S5L8922 (Bootrom)|Bootrom]]-&amp;gt;[[LLB]]-&amp;gt;[[iBoot]]-&amp;gt;[[Kernel]]-&amp;gt;[[System|System Software]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[S5L8922 (Bootrom)]]&lt;br /&gt;
* [[S5L8922 (Hardware)]]&lt;/div&gt;</summary>
		<author><name>DarkMalloc</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=Usb_control_msg(0x21,_2)_Exploit&amp;diff=5836</id>
		<title>Usb control msg(0x21, 2) Exploit</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=Usb_control_msg(0x21,_2)_Exploit&amp;diff=5836"/>
		<updated>2010-02-23T19:22:40Z</updated>

		<summary type="html">&lt;p&gt;DarkMalloc: /* Exploitation */ Added a bit more detail&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:usb_control_msg(0x21, 2) Exploit}}&lt;br /&gt;
== Credit (Alphabetical) ==&lt;br /&gt;
* '''vulnerability''': pod2g and westbaer, also discovered independently by gray, also discovered independently by [[geohot]]&lt;br /&gt;
* '''exploitation''': ius, chronic, pod2g, and posixninja&lt;br /&gt;
* '''payload ([[greenpois0n]])''': chronic and posixninja&lt;br /&gt;
&lt;br /&gt;
== Vulnerability ==&lt;br /&gt;
'''pod2g''' and '''westbaer''' discovered, via some reversing + fuzzing, you could overwrite the content of 0x0 thanks to Apple not checking the contents of a register they should have, shown in the disassm below. Now, the reason that this is useful is because the MMU maps whatever is running ([[LLB]], [[iBoot]], etc.) to 0x0 so that if an exception vector is triggered, it would jump to the one designed to be used with what is running, versus jumping to what is normally located at 0x0, the [[S5L8920 (Bootrom)|bootrom]].&lt;br /&gt;
&lt;br /&gt;
All you need to do is send the following (assuming you're using libusb 0.1.x)...&lt;br /&gt;
 usb_control_msg(iDev, 0x21, 2, 0, 0, 0, 0, 1000);&lt;br /&gt;
And thanks to our vulnerability, it will do this:&lt;br /&gt;
 memcpy(0, LOAD_ADDR, 0x2000);&lt;br /&gt;
&lt;br /&gt;
As you can see, we have full control over the first 0x2000 bytes of iBoot.&lt;br /&gt;
&lt;br /&gt;
=== Disassm ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// R5: a pointer to a buffer is here if requesttype==0xA1.&lt;br /&gt;
//     however, if requesttype==0x21, R5 is undefined.&lt;br /&gt;
&lt;br /&gt;
SRAM:22009ED2                 code_1                                  ; CODE XREF: handle_file_io_control_req+62�j&lt;br /&gt;
SRAM:22009ED2 014 36 49                       LDR     R1, =usb_file_loadaddr&lt;br /&gt;
SRAM:22009ED4 014 36 4B                       LDR     R3, =usb_file_offset&lt;br /&gt;
SRAM:22009ED6 014 28 68                       LDR     R0, [R5]&lt;br /&gt;
SRAM:22009ED8 014 09 68                       LDR     R1, [R1]&lt;br /&gt;
SRAM:22009EDA 014 1B 68                       LDR     R3, [R3]&lt;br /&gt;
SRAM:22009EDC 014 22 1C                       ADDS    R2, R4, #0&lt;br /&gt;
SRAM:22009EDE 014 C9 18                       ADDS    R1, R1, R3&lt;br /&gt;
SRAM:22009EE0 014 07 F0 94 EF                 BLX     memcpy&lt;br /&gt;
SRAM:22009EE4 014 00 2E                       CMP     R6, #0&lt;br /&gt;
SRAM:22009EE6 014 53 D0                       BEQ     return&lt;br /&gt;
SRAM:22009EE8 014 01 23                       MOVS    R3, #1&lt;br /&gt;
SRAM:22009EEA 014 33 60                       STR     R3, [R6]&lt;br /&gt;
SRAM:22009EEC 014 50 E0                       B       return&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exploitation ==&lt;br /&gt;
So, how do you actually run code with this? Well, '''chronic''' suggested that since the irq vector was in constant use, we try that, so we were able to simply replace the address of the irq vector handler (0x00000038) in the 0x2000 [[iBoot]] chunk that we send with 0x41002000, and then just tack our payload to the end of that chunk. Of course, since we are hijacking the irq exception, you must disable interrupts first. Here is the basic procedure:&lt;br /&gt;
* Call enter_critical_task(); disabling interrupts, so that your code can reliably execute.&lt;br /&gt;
* Restore 0x38 (irq handler) with the original irq vector address&lt;br /&gt;
* '''DO WHAT YOU WANT AT THIS POINT, YOU MAY NOT USE INTERRUPTS'''.&lt;br /&gt;
* Call exit_critical_task(); re-enabling interrupts.&lt;br /&gt;
* Call the irq handler so that the interrupt request that you hijacked can execute.&lt;br /&gt;
&lt;br /&gt;
=== Roadblocks ===&lt;br /&gt;
* If what you send is not 0x2000 bytes, the remainder is filled in with zeroes, which is bad.&lt;br /&gt;
* Due to the above rule, you need the first 0x2000 of a decrypted iBoot by the time your payload is done running.&lt;br /&gt;
* You must disable interrupts to reliably execute your payload. Due to this, this will rule out the possibility of reading the 0x2000 iBoot chunk needed from NOR, since nor_read(); requires interrupts.&lt;br /&gt;
&lt;br /&gt;
One way to get around the need of sending the 0x2000 [[iBoot]] chunk is to hook the image_load(); function in the LLB which is sitting intact in memory. This was successfully done in [[blackra1n]]. &lt;br /&gt;
&lt;br /&gt;
The [[PwnageTool]] method requires an [[IPSW]] to be input in order to create a custom firmware anyway, so the 0x2000 chunk is not an issue. It can just be copied from the [[iBoot]] in the [[IPSW]].&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
[[blackra1n]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Exploits]]&lt;/div&gt;</summary>
		<author><name>DarkMalloc</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=The_iPhone_Wiki:Current_events&amp;diff=4829</id>
		<title>The iPhone Wiki:Current events</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=The_iPhone_Wiki:Current_events&amp;diff=4829"/>
		<updated>2009-09-14T10:45:42Z</updated>

		<summary type="html">&lt;p&gt;DarkMalloc: /* Complete */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Primary Goals ==&lt;br /&gt;
* [[X-Gold 608 Unlock|Break Chain of Trust (X-Gold)]]&lt;br /&gt;
&lt;br /&gt;
==  Secondary ==&lt;br /&gt;
* Get [[iPhoneLinux]] running on [[iPod touch 2G]]&lt;br /&gt;
* Get kernel extensions working on 2.x&lt;br /&gt;
* Get kernel extensions working on 3.x&lt;br /&gt;
&lt;br /&gt;
== Complete ==&lt;br /&gt;
* [[Jailbreak iPhone2,1]]&lt;/div&gt;</summary>
		<author><name>DarkMalloc</name></author>
		
	</entry>
	<entry>
		<id>https://www.theiphonewiki.com/w/index.php?title=The_iPhone_Wiki:Current_events&amp;diff=4828</id>
		<title>The iPhone Wiki:Current events</title>
		<link rel="alternate" type="text/html" href="https://www.theiphonewiki.com/w/index.php?title=The_iPhone_Wiki:Current_events&amp;diff=4828"/>
		<updated>2009-09-14T10:45:32Z</updated>

		<summary type="html">&lt;p&gt;DarkMalloc: /* Primary Goals */  Changed Jailbreak iPhone 2,1 to Completed&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Primary Goals ==&lt;br /&gt;
* [[X-Gold 608 Unlock|Break Chain of Trust (X-Gold)]]&lt;br /&gt;
&lt;br /&gt;
==  Secondary ==&lt;br /&gt;
* Get [[iPhoneLinux]] running on [[iPod touch 2G]]&lt;br /&gt;
* Get kernel extensions working on 2.x&lt;br /&gt;
* Get kernel extensions working on 3.x&lt;br /&gt;
&lt;br /&gt;
== Complete ==&lt;/div&gt;</summary>
		<author><name>DarkMalloc</name></author>
		
	</entry>
</feed>