// iPodTest.cpp : Defines the entry point for the console application.
//
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#pragma warning(disable:4996)
#include <stdio.h>
#include <tchar.h>
#include <afxwin.h> // MFC core and standard components
#include "MobileDevice.h"
typedef enum { IPOD_STATE_UNCONNECTED = 0, IPOD_STATE_CONNECTED, IPOD_STATE_READY } t_iPodState;
// State variables
volatile t_iPodState iPodState = IPOD_STATE_UNCONNECTED;
volatile struct am_device *iPodDev = NULL;
CFStringRef iPodAFCName;
struct afc_connection *iPodAFC;
struct afc_connection *iPodConnection;
// Dll dynamic loading data
char *piTunesMobileDevicePath = NULL;
HINSTANCE iTunesDll = NULL;
// Dll routines
tf_AMDeviceNotificationSubscribe AMDeviceNotificationSubscribe;
tf_AMDeviceConnect AMDeviceConnect;
tf_AMDeviceDisconnect AMDeviceDisconnect;
tf_AMDeviceIsPaired AMDeviceIsPaired;
tf_AMDeviceValidatePairing AMDeviceValidatePairing;
tf_AMDeviceStartSession AMDeviceStartSession;
tf_AMDeviceStartService AMDeviceStartService;
tf_AMDeviceStopSession AMDeviceStopSession;
tf_AFCConnectionOpen AFCConnectionOpen;
tf_AFCDeviceInfoOpen AFCDeviceInfoOpen;
tf_AFCDirectoryOpen AFCDirectoryOpen;
tf_AFCDirectoryRead AFCDirectoryRead;
tf_AFCDirectoryClose AFCDirectoryClose;
tf_AFCFileInfoOpen AFCFileInfoOpen;
tf_AFCKeyValueRead AFCKeyValueRead;
tf_AFCKeyValueClose AFCKeyValueClose;
tf_AFCFileRefOpen AFCFileRefOpen;
tf_AFCFileRefClose AFCFileRefClose;
tf_AFCFileRefRead AFCFileRefRead;
tf_AFCFileRefWrite AFCFileRefWrite;
tf_AFCRemovePath AFCRemovePath;
tf_AFCDirectoryCreate AFCDirectoryCreate;
tf_AFCRenamePath AFCRenamePath;
tf_AFCGetFileInfo AFCGetFileInfo;
void init()
{
HKEY hSetting = NULL;
DWORD length = 0;
CString path;
int pos;
// Adds iTunesMobileDevice.dll folder to the path, from the registry:
if (::RegCreateKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Apple Inc.\\Apple Mobile Device Support\\Shared"), &hSetting) != ERROR_SUCCESS)
throw "iTunesMobileDevice library not found";
if (::RegQueryValueEx(hSetting, _T("iTunesMobileDeviceDLL"), NULL, NULL, NULL, &length) != ERROR_SUCCESS)
throw "iTunesMobileDevice library not found";
piTunesMobileDevicePath = new char[length+1];
::RegQueryValueEx(hSetting, _T("iTunesMobileDeviceDLL"), NULL, NULL, (LPBYTE)piTunesMobileDevicePath, &length);
// Adds the folder to the current system path:
path.GetEnvironmentVariable("PATH");
path = (path + ";") + piTunesMobileDevicePath;
pos = path.ReverseFind('\\');
if (pos >= 0)
path = path.Left(pos);
SetEnvironmentVariable("PATH", path);
// Loads the DLL routines
iTunesDll = LoadLibrary(piTunesMobileDevicePath);
//iTunesDll = LoadLibrary("C:\\Program Files\\Common Files\\Apple\\Mobile Device Support\\bin\\MobileDevice.dll");
if (iTunesDll) {
AMDeviceNotificationSubscribe = (tf_AMDeviceNotificationSubscribe)GetProcAddress(iTunesDll, "AMDeviceNotificationSubscribe");
AMDeviceConnect = (tf_AMDeviceConnect)GetProcAddress(iTunesDll, "AMDeviceConnect");
AMDeviceDisconnect = (tf_AMDeviceDisconnect)GetProcAddress(iTunesDll, "AMDeviceDisconnect");
AMDeviceIsPaired = (tf_AMDeviceIsPaired)GetProcAddress(iTunesDll, "AMDeviceIsPaired");
AMDeviceValidatePairing = (tf_AMDeviceValidatePairing)GetProcAddress(iTunesDll, "AMDeviceValidatePairing");
AMDeviceStartSession = (tf_AMDeviceStartSession)GetProcAddress(iTunesDll, "AMDeviceStartSession");
AMDeviceStartService = (tf_AMDeviceStartService)GetProcAddress(iTunesDll, "AMDeviceStartService");
AMDeviceStopSession = (tf_AMDeviceStopSession)GetProcAddress(iTunesDll, "AMDeviceStopSession");
AFCConnectionOpen = (tf_AFCConnectionOpen)GetProcAddress(iTunesDll, "AFCConnectionOpen");
AFCDeviceInfoOpen = (tf_AFCDeviceInfoOpen)GetProcAddress(iTunesDll, "AFCDeviceInfoOpen");
AFCDirectoryOpen = (tf_AFCDirectoryOpen)GetProcAddress(iTunesDll, "AFCDirectoryOpen");
AFCDirectoryRead = (tf_AFCDirectoryRead)GetProcAddress(iTunesDll, "AFCDirectoryRead");
AFCDirectoryClose = (tf_AFCDirectoryClose)GetProcAddress(iTunesDll, "AFCDirectoryClose");
AFCFileInfoOpen = (tf_AFCFileInfoOpen)GetProcAddress(iTunesDll, "AFCFileInfoOpen");
AFCKeyValueRead = (tf_AFCKeyValueRead)GetProcAddress(iTunesDll, "AFCKeyValueRead");
AFCKeyValueClose = (tf_AFCKeyValueClose)GetProcAddress(iTunesDll, "AFCKeyValueClose");
AFCFileRefOpen = (tf_AFCFileRefOpen)GetProcAddress(iTunesDll, "AFCFileRefOpen");
AFCFileRefClose = (tf_AFCFileRefClose)GetProcAddress(iTunesDll, "AFCFileRefClose");
AFCFileRefRead = (tf_AFCFileRefRead)GetProcAddress(iTunesDll, "AFCFileRefRead");
AFCFileRefWrite = (tf_AFCFileRefWrite)GetProcAddress(iTunesDll, "AFCFileRefWrite");
AFCRemovePath = (tf_AFCRemovePath)GetProcAddress(iTunesDll, "AFCRemovePath");
AFCDirectoryCreate = (tf_AFCDirectoryCreate)GetProcAddress(iTunesDll, "AFCDirectoryCreate");
AFCRenamePath = (tf_AFCRenamePath)GetProcAddress(iTunesDll, "AFCRenamePath");
AFCGetFileInfo = (tf_AFCGetFileInfo)GetProcAddress(iTunesDll, "AFCGetFileInfo");
} else
throw "iTunesMobileDevice.dll could not be loaded";
}
void notification(struct am_device_notification_callback_info *info)
{
unsigned int msg = info->msg;
// Need more verbosity here.
printf("[NOTIF] %d\n", msg);
switch (msg) {
case ADNCI_MSG_CONNECTED:
if (iPodState == IPOD_STATE_UNCONNECTED) {
iPodDev = info->dev;
iPodState = IPOD_STATE_CONNECTED;
printf("iPod is connected\n");
} else {
// Was in another state before, something bad must have happened
}
break;
case ADNCI_MSG_DISCONNECTED:
if (iPodState == IPOD_STATE_CONNECTED) {
iPodState = IPOD_STATE_UNCONNECTED;
iPodDev = NULL;
iPodAFC = NULL;
iPodConnection = NULL;
printf("iPod is disconnected\n");
}
break;
default:
break;
}
}
void connect()
{
struct am_device_notification *notif;
mach_error_t ret;
int timeout;
struct am_device *pDev;
printf("Trying to connect iPod...\n");
ret = AMDeviceNotificationSubscribe(notification, 0, 0, 0, ¬if);
printf("[RET]AMDeviceNotificationSubscribe() = %d\n", ret);
for (timeout = 0; (timeout < 1000) && (iPodState != IPOD_STATE_CONNECTED); timeout++) {
Sleep(10);
}
if (iPodState != IPOD_STATE_CONNECTED)
throw "Could not find iPod";
pDev = (struct am_device *)iPodDev;
// This part could possibly move to the notification routine:
ret = AMDeviceConnect(pDev);
printf("[RET]AMDeviceConnect() = %d\n", ret);
if (ret) {
// We don't handle the restore mode
throw "Could not connect iPod";
}
ret = AMDeviceIsPaired(pDev);
printf("[RET]AMDeviceIsPaired() = %d\n", ret);
if (!ret)
throw "Could not pair iPod";
ret = AMDeviceValidatePairing(pDev);
printf("[RET]AMDeviceValidatePairing() = %d\n", ret);
if (ret)
throw "Could not validate iPod pairing";
ret = AMDeviceStartSession(pDev);
printf("[RET]AMDeviceStartSession() = %d\n", ret);
if (ret)
throw "Could not start session";
iPodAFCName = AMSVC_AFC2;
ret = AMDeviceStartService(pDev, iPodAFCName, &iPodAFC, NULL);
printf("[RET]AMDeviceStartService() = %d\n", ret);
if (ret) {
// Not jailbroken, tries to connect to the standard name
iPodAFCName = AMSVC_AFC;
ret = AMDeviceStartService(pDev, iPodAFCName, &iPodAFC, NULL);
printf("[RET]AMDeviceStartService() = %d\n", ret);
if (ret)
throw "Could not start AFC service";
}
ret = AFCConnectionOpen(iPodAFC, 0, &iPodConnection);
printf("[RET]AFCConnectionOpen() = %d\n", ret);
if (ret)
throw "Could not start AFC connection";
printf("Ready\n");
iPodState = IPOD_STATE_READY;
}
void close()
{
if (piTunesMobileDevicePath)
delete piTunesMobileDevicePath;
if (iTunesDll)
FreeLibrary(iTunesDll);
if (iPodState == IPOD_STATE_READY) {
/* Doesn't work:
mach_error_t ret;
int timeout;
ret = AMDeviceStopSession((struct am_device *)iPodDev);
printf("[RET]AMDeviceStopSession() = %d\n", ret);
ret = AMDeviceDisconnect((struct am_device *)iPodDev);
printf("[RET]AMDeviceDisconnect() = %d\n", ret);
for (timeout = 0; (timeout < 500) && (iPodState != IPOD_STATE_UNCONNECTED); timeout++) {
Sleep(10);
}
if (iPodState != IPOD_STATE_UNCONNECTED)
throw "Could not disconnect iPod";
*/
}
}
int iPodCmdFileInfo(char *remoteFile)
{
mach_error_t ret;
struct afc_dictionary *pInfo;
char *pKey, *pVal;
unsigned int size = 0;
//ret = AFCGetFileInfo(iPodConnection, remoteFile, &pInfo, &size);
//printf("[RET]AFCGetFileInfo() = %d\n[RES]\tpInfo=%08X size=%08X\n", ret, (int)pInfo, size);
ret = AFCFileInfoOpen(iPodConnection, remoteFile, &pInfo);
printf("[RET]AFCFileInfoOpen() = %d\n", ret);
if (ret) {
printf("%s doesn't exist\n", remoteFile);
return ret;
}
ret = AFCKeyValueRead(pInfo, &pKey, &pVal);
while(pKey || pVal) {
printf("[RES]\t%s = %s\n", (pKey ? pKey : "<empty>"), (pVal ? pVal : "<empty>"));
AFCKeyValueRead(pInfo, &pKey, &pVal);
}
AFCKeyValueClose(pInfo);
return 0;
}
int iPodCmdLs(char *remotePath)
{
struct afc_directory *pDir;
char *pEntry;
mach_error_t ret;
CString filename;
ret = AFCDirectoryOpen(iPodConnection, remotePath, &pDir);
printf("[RET]AFCDirectoryOpen() = %d\n", ret);
if (ret) {
printf("%s doesn't exist\n", remotePath);
return ret;
}
while(1) {
ret = AFCDirectoryRead(iPodConnection, pDir, &pEntry);
if (ret) {
printf("[RET]AFCDirectoryRead() = %d\n", ret);
break;
}
if (!pEntry)
break;
printf("[RES] %s\n", pEntry);
/*
filename = remotePath;
if (filename.Right(1).Compare("/"))
filename += "/";
filename += pEntry;
iPodCmdFileInfo(filename.GetBuffer());
*/
}
ret = AFCDirectoryClose(iPodConnection, pDir);
printf("[RET]AFCDirectoryClose() = %d\n", ret);
return ret;
}
int iPodCmdFileRead(char *remoteFile)
{
mach_error_t ret;
struct afc_dictionary *pInfo;
char *pKey, *pVal;
unsigned int size = 0, total = 0, len;
afc_file_ref handle;
unsigned char buffer[16];
unsigned int i;
// Gets the file size
ret = AFCFileInfoOpen(iPodConnection, remoteFile, &pInfo);
if (ret) {
printf("%s doesn't exist\n", remoteFile);
return ret;
}
ret = AFCKeyValueRead(pInfo, &pKey, &pVal);
while(pKey || pVal) {
printf("\t%s = %s\n", pKey, pVal);
if (pKey == NULL || pVal == NULL)
break;
if (!stricmp(pKey, "st_size")) {
size = atoi(pVal);
break;
}
AFCKeyValueRead(pInfo, &pKey, &pVal);
}
AFCKeyValueClose(pInfo);
if (size == 0) {
printf("%s has a null size\n", remoteFile);
return 1;
}
// Opens the file for reading
ret = AFCFileRefOpen(iPodConnection, remoteFile, AFC_FILEMODE_READ, 0, &handle);
if (ret != MDERR_OK) {
printf("[RET]AFCFileRefOpen() = %d\n", ret);
return ret;
}
// Gets the contents by chunks
while (total < size) {
len = min(size - total, sizeof(buffer));
ret = AFCFileRefRead(iPodConnection, handle, buffer, &len);
if (ret != MDERR_OK) {
printf("[RET]AFCFileRefRead() = %d\n", ret);
break;
}
if (!len)
break;
for (i = 0; i < len; i++)
printf("%02X ", buffer[i]);
printf("%*s| ", (sizeof(buffer)-len)*3+1, " ");
for (i = 0; i < len; i++)
printf("%c", buffer[i] >= 32 ? buffer[i] : ' ');
putchar('\n');
total += len;
}
AFCFileRefClose(iPodConnection, handle);
return 0;
}
void test()
{
char buffer[512];
while(1) {
printf("> ");
gets(buffer);
if (!*buffer)
break;
if (buffer[0] == '?') {
printf("File info on %s:\n", buffer+1);
iPodCmdFileInfo(buffer+1);
} else if (!strncmp(buffer, "r ", 2)) {
printf("Reading file %s:\n", buffer+2);
iPodCmdFileRead(buffer+2);
} else {
printf("Directory contents of %s:\n", buffer);
iPodCmdLs(buffer);
}
}
}
void main(int argc, char *argv[])
{
try {
init();
connect();
test();
close();
}
catch(char *message) {
printf("Error: %s\nAborting.\n", message);
close();
exit(1);
}
}相关推荐
iTunesMobileDevice.dll开发文档API文档
am_device_notification_callback 定义: typedef void(*am_device_notification_callback)(struct am_device_notification_callback_info *); 描述: 回调函数,当设备状态改变时由iTunesMobileDevice.dll回调 参数: am_device_notification_callback_info 返回设备信息 am_restore_device_notification_callback 定义: typedef void (*am_restore_device_notification_callback)(struct am_recovery_device *); 描述: 回调函数,当检测到restore模式设备时由iTunesMobileDevice.dll回调 参数: am_recovery_device返回设备信息 AMDeviceNotificationSubscribe
iTunes.dll文件丢失修复:简单有效的解决方案
卸载iTunes及相关组件:访问控制面板中的“程序和功能”,找到与Apple相关的所有程序如iTunes、Apple Mobile Device、Bonjour等,逐一卸载。当你在使用与iTunes相关的应用程序或服务时遇到“无法找到itunes.dll文件”的错误提示,这通常意味着DLL文件丢失或损坏。清理Apple软件的残留文件:删除C盘下的Apple相关文件夹,例如AppData、Program Files(x86)中的Apple文件夹。使用可靠的注册表清理工具来扫描并修复注册表中的错误。
iphone连接助手源码 C++调用itunes的MobileDevice.dll与电脑建立连接支持新版itunes IOS
ituzi手机助手demo源码只是简单的电脑与手机初步建立连接,获取iphone基本信息,其他功能开发中 使用前请检查itunes是否已安装64位版本,我使用的是iTunes 64位_12.12.2.2 不需要iTunesMobileDevice.dll 本程序开发环境win10 x64 vs2022 使用多字节字符集编译64位 预处理 _CRT_SECURE_NO_WARNINGS 如果提示环境问题,且已安装itunes请检查注册表健值是否存在 HKEY_LOCAL_MACHINE\SOFTWARE\Apple Inc.\Apple Mobile Device Support\InstallDir 通常为C:\Program Files\Common Files\Apple\Mobile Device Support\ 实在不行,可以自己改为直链接dll所在文件夹直接调用dll 2022.4.10
iphone如何删除“不可删除”的描述文件?(桌面快捷方式web clib)
首先下载iPhone配置实用工具,下载地址如下: https://www.onlinedown.net/soft/987607.htm 点击下载,按要求解压,安装。启动时如果出现找不到设备,做以下操作:: 1、进入如下目录 “C:\Program Files (x86)\Common Files\Apple\Mobile Device Support\” 复制Mobile...
iPhone iTunesMobileDevice C++ 接口描述
红色的方法我也不太清楚哈哈,欢迎交流完善。 am_device_notification_callback 定义: typedef void(*am_device_notification_callback)(struct am_device_notification_callback_info *); 描述: 回调函数,当设备状态改变时由iTunesMobi
C#读写iOS应用共享目录下的文件
之前写了一个Windows版的fmm2018球探工具,但每次都需要用助手把手机里的存档复制出来,感觉太胃疼,于是想加入一个功能:球探工具自动检测iPhone连接并自动读取共享目录下的存档,然后复制到Windows下加载。 开始做的时候发现这方面的资料太少了,在百度和Google上面翻了半天才找到些许教程,都不太完整,就知道了是要读取iTunesMobileDevice.dll,然后用它提供的接口...
如何创建回调,得知iPhone设备的接入和拔出信息
要想连接iPhone设备,首先得知道iPhone设备是否插入了电脑 所以就要用到iTunesMobileDevices.dll里面的一个函数 AMDeviceNotificationSubscribe 这个函数有五个参数 第一个是回调程序,用来得到是否接入的信息并做出反馈 二三四都是0,或者null掉 第五个是一个连接设备的句柄,不过这个句柄作用不大 第一个参
iphone的PC端管理软件开源项目
我一直不大相信,国内有人能够单枪匹马的搞iphone的PC端管理软件,完全没接触过这方面的我上网一搜,果然,还是老外走得比较前头,而且非常有正义感,开源的。 通过下面这些开源项目,安装itunes和.netframework2.0,你就可以和越狱的iphone设备进行简单的设备通讯,读取iphone设备上的图片和音乐程序等。这些都是基于itunes的iTunesMobile...
原理解析笔记
http://www.libimobiledevice.org/ iTunesMobileDeviceDLL.dll
通过iTunesMobileDevice服务来获取IPhone信息的demo-易语言
开头说明:此源码并未开发完成,只是个demo。而且写法很随意(我也想搞懂iTunesMobileDevice.dll的调用流程,奈何太繁琐),不喜勿喷! 1 .好像iTunesMobileDevice.dll对 太新太旧的设备读取某些功能存在着有误的问题(Iphone11系列读取颜色会返回空值0/1 ,Iphone5s的CPU架构号也会返回错误),其他没测可自行尝试 2 .整体流程是:1.调用 AMDeviceNotificationSubscribe ,函数用来及时反馈插拔设备消息 2.调用 AMDeviceConnect ,函数用来连接设备( 到此步即可直接去获取一些基础设备信息,上图就是 ) 3.调用 AMDeviceIsPaired ,函数用来判断配对 4.调用 AMDeviceValidatePairing ,函数用来验证配对,此函数也可做为(锁屏/信任)等判断依据 5.调用 AMDeviceStartSession ,函数来创建会话通道,完成此步可做一些文件/高级信息(序列号/硬盘/内存/电池等) 系列操作 注:整体流程的 成功 返回值均在源码中备注, 错误 的返回值过多没做整理,可以到CSDN( 连接在下方 )自行查询错误原因! 3 .源代码共调用了两个模块 精E模块(请自行替换),Ecallback(已开源,一搜就有源码,作者: 星锋工作室-东灿 ) 4 . 源代码或多或少都加了一些注释,功能不多虽然不多, 源代码依赖Itunes( iTunesMobileDevice.dll和CoreFoundation.dll )请自备! 5 .文献: 部分功能调用方法及声明(英文):https://bitbucket.org/tristero/mobiledeviceaccess/src/4bf38336bd6d7f5ffb23c8f331aed9eff5c720c0/MobileDevice.h?at=default#MobileDevice.h-115 部分服务/功能名查询:https://bitbucket.org/tristero/mobiledeviceaccess/src/4e3e281de0c38b7f9f053927d45a756b28134bd3/deviceValueForDomain.md?at=defaultfileviewer=file-view-default 错误返回值含义查询 :https://blog.csdn.net/Cinnazgc/article/details/858609 94
ios命令行调试工具libimobiledevice详解
IOS下面也有类似于android平台adb的工具,可以用来查看手机信息,备份,恢复,手机挂在目录等,本文档介绍了常用的几种方法
itunes_v12.3.5_X64 官方版含有iTunesMobileDevice.dll
官方版本,配合代码使用。 因为含有iTunesMobileDevice.dll,所以提交上传备份使用。
ios助手开发系列(二):第一步,设备连接
上一篇简单介绍了ios助手的调查方向,从这一篇开始,则是讲解ios助手的具体开发了。 废话不多说,ios助手大部分功能的实现都在iTunesMobileDevice.dll里面。这个助手进行的第一步就是要设备连接,只有连接设备之后才能做其他事情。 其中AMDeviceNotificationSubscribe函数,就是负责设备连接这一块的。 函数原型: int AMDevice
iphone实用配置工具_苹果手机配置描述文件移除不了的处理方法
1.首先电脑百度下载 iPhone配置实用工具, 进行安装到电脑2.安装完成后,点击电脑左下角的 开始-所用程序-iPhone 配置实用工具,打开该软件。3. 打开该软件后,连接你的iPhone,此时该软件已经获取到你的iPhone的相关信息,注意iPhone一定要保持解锁不息屏状态。4. 点击左上角的设备,选择你的设备-点击描述配置文件-选择该APP-移除。5. 看到弹出提示框让你确定是否移除,...
总结一下mobile下dll加载不上这几天的尝试的情况。。。
首先给出我的dll #include "stdafx.h" #include "T21Service.h" HINSTANCE g_hInst; BOOL APIENTRY DllMain( HANDLE hModule,
iTunesMobileDevice备忘
1、设备刷机后未激活状态,是可以通过AMDeviceNotificationSubscribe函数注册的回调函数中的am_device参数,来获取设备信息的 2、在dfu & recovery模式,有一批函数可以获取设备硬件信息,比如: typedef unsigned long long (__cdecl *fpAMRecoveryModeDeviceGetECID)(am_...
6948




被折叠的 条评论
为什么被折叠?



