Giter Club home page Giter Club logo

sdmmobiledevice's Introduction

SDMMobileDevice

Table of Contents


What is this?

SDMMobileDevice is a framework that enables access to communicating with iOS devices. This framework serves as a public and documented way to interact with iOS devices and the services that exist on iOS devices.

SDMMobileDevice is a framework that can be used interchangeably with Apple's private framework MobileDevice.framework


What can this project do for me?

This framework gives access to a number of technologies that have previously been "off limits" to developers. Due to being a private and undocumented API, MobileDevice.framework has not been something that can be safely interacted with. This framework provides access to:

  1. Detecting attached iOS devices
  2. Querying iOS devices for software and hardware configurations
  3. Communication with device services
  4. Sandbox access to applications installed on iOS devices
  5. Installation of applications onto iOS devices
  6. File transfers

How do I use this?

SDMMobileDevice is an OS X framework and can be used in two ways:

  1. Bundled Framework
  2. Source Code

Special Note: Entitlements

Bundled Framework

You are already almost done!

  1. Add SDMMobileDevice.framework as a linked library
  2. Add a new build phase that copies "SDMMobileDevice.framework" to the "Frameworks" directory of your app.
  3. Add "@loader_path/../Frameworks" to "Runtime Search Paths"
  4. Add #include <SDMMobileDevice/SDMMobileDevice.h> to your source code

Source Code

If you wish you use this as source code, it will require the following libraries:

  • CoreFoundation.framework
  • libcrypto.dylib
  • libssl.dylib
  • IOKit.framework

If you have trouble locating any of these, please look at the "-Framework" xcode project file to get the paths for these libraries.

Entitlements (where applicable)

See this file


FAQ

Q. Why do I get so many warnings when compiling?

A. The warnings are from the openssl and libcrypto calls that Apple has deprecated starting in 10.7, I am looking to replace these with CommonCrypto or bundling openssl and libcrypto so these errors don't happen.

Q. When is the Cocoa version coming?

A. Soon! I am working to provide a few more core features and keeping the whole thing compatible with MobileDevice and keeping it as a completely C library. The Cocoa wrapper for this will come as soon as I have finished the AFC implementation and have working wireless communication.

Q. How do I use this with MobileDevice.framework

A. For the most part SDMMobileDevice is cross-compatible with MobileDevice's function calls and object types. Function calls with matching names (remove the "SDMMD" prefix and underscores), will have matching parameters and types to what MobileDevice uses. Majority of the object types are reconstructed to match in internal layout.

Q. How can I contribute?

A. See the wiki for details on submitting pull requests.

Help

I have created a IRC room on freenode to serve as general discussion and research.

Server: irc.freenode.net

Room: #sdmmobiledevice

Quicklink: webchat

sdmmobiledevice's People

Contributors

gwynne avatar heardrwt avatar jeremyagost avatar ryu2 avatar samdmarshall avatar srna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdmmobiledevice's Issues

openssl/ssl.h not found

Hi
FYI in the next major release of OS X 10.11 (El Capitan) Apple stops shipping openssl.
So #include <openssl/ssl.h> in SDMMD_Connection_Internal.h will fail when using the 10.11 SDK

Make framework constants for USBMuxListener notifications

USBMuxListener sends the following notifications:

SDMMD_USBMuxListenerDeviceAttachedNotification
SDMMD_USBMuxListenerDeviceAttachedNotificationFinished
SDMMD_USBMuxListenerDeviceDetachedNotification
SDMMD_USBMuxListenerDeviceDetachedNotificationFinished
SDMMD_USBMuxListenerStoppedListenerNotification

Configurable usbmuxd socket descriptor

USBMuxListener is currently hardcoded to connect to the socket at /var/run/usbmuxd. This path should be exposed to configuration somehow, either in a configuration header or optionally at runtime.

Wrong endian-ness conversion?

In SDMMD_AppleFileConduit.c, there are several places where htole64() is used. This doesn't seem correct because on OS X it will evaluate to just a uint64_t cast. Since on Mac the host byte order is already little endian ('le64'). If the goal is to transform device big-endian into host little-endian, the correct function to use is be64toh(). That's big-endian to host.

MobileDeviceAccess.m read_dir function has a bug

static BOOL read_dir( AFCDirectoryAccess *self, afc_connection afc, NSString *path, NSMutableArray *files )

line:871
should be:
[here addObject:[NSString stringWithFormat:@"%@/%@",path,[NSString stringWithCString:d encoding:NSUTF8StringEncoding]]];

Or some unicode words can't be read correctly.

Listener fails to retrieve any iOS devices after awhile

So I have a small program that grabs iOS device information as they are plugged in. After awhile it fails to listen for any devices and could only be brought back if I restart the app. Now there are several case that I have troubleshooted this.

In debug or release build, If the program is ran and debugged by Xcode, it works perfectly; never disconnects. If the program is ran by itself in either build config, the SDMMobileDevice instance/controller seems to fail to listen for iOS device connections.

SDMMD_USBMuxAttachedCallback or SDMMD_USBMuxDeviceListCallback are never called after it fails to listen for device connections. I do know that devices are being registered as iTunes can sync to it and com.apple.usbmuxd sends a _SendAttachNotification Device as posted in the console.

I am not sure if this framework is designed to work for long sessions or if there was a way to restart the SDMMD_USBMuxListener.

32bit compatibility

Seems that MobileDevice has a slightly different implementation on 32bit from 64bit, currently it only supports 64bit. Currently 32bit compatibility with MobileDevice.framework is not going to be supported.

SDMMD_AMDeviceCopyValue on non existing key crashes on swift

I'm getting an EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP) crash when trying to use SDMMD_AMDeviceCopyValue with a key on a device which does not support the key (like phone number on iPod)
Running the code in objective-c will cause a console log but no crash while using the code below in swift will cause the crash.

var result1: sdmmd_return_t = SDMMD_AMDeviceConnect(deviceRef)
var result2 = SDMMD_AMDeviceStartSession(deviceRef)

var key = CFStringCreateWithCString(kCFAllocatorDefault, kPhoneNumber, 0)
var pn = SDMMD_AMDeviceCopyValue(deviceRef, kGlobalDomain, key)
print(pn.takeUnretainedValue())

var result3 = SDMMD_AMDeviceStopSession(device)
var result4 = SDMMD_AMDeviceDisconnect(device)

Call in obj-c
NSLog(@"%@",(NSString*)CFBridgingRelease(SDMMD_AMDeviceCopyValue(device, NULL, CFSTR(kPhoneNumber))));

Calling 'SDMMD_TranslateConnectionToSocket' with incomplete return type 'SocketConnection' (aka 'struct SocketConnection_Internal')

Hi,

I am using this code in my project.

sdmmd_return_t result = kAMDInvalidArgumentError;
CFDictionaryRef dict = NULL;
SDMMD_AMConnectionRef conn = SDMMD_AMDServiceConnectionCreate(0, NULL, dict);
result1 = SDMMD_AMDeviceSecureStartService(device, CFSTR(AMSVC_SYSLOG_RELAY), NULL, &conn);
if (SDM_MD_CallSuccessful(result))
{
NSLog(@"success12");
CFMutableDictionaryRef optionDict = SDMMD_create_dict();
CFDictionarySetValue(optionDict, CFSTR("Request"), CFSTR("GasGauge"));

    result = SDMMD_ServiceSendMessage(SDMMD_TranslateConnectionToSocket(conn), optionsDict, kCFPropertyListXMLFormat_v1_0);
    CFMutableDictionaryRef response;
    result = SDMMD_ServiceReceiveMessage(SDMMD_TranslateConnectionToSocket(conn), (CFPropertyListRef *)&response);
    if (SDM_MD_CallSuccessful(result))
    {
        PrintCFType(response);
    }
}

But it is warning on this line
“SDMMD_AMConnectionRef conn = SDMMD_AMDServiceConnectionCreate(0, NULL, dict);”
Warning:

  1. Implicit declaration of function 'SDMMD_AMDServiceConnectionCreate' is invalid in C99
  2. Incompatible integer to pointer conversion initializing 'SDMMD_AMConnectionRef' (aka 'struct am_connection *') with an expression of type 'int'

And Error on this line:
“result = SDMMD_ServiceSendMessage(SDMMD_TranslateConnectionToSocket(conn), optionsDict, kCFPropertyListXMLFormat_v1_0);”
Error;

  1. Calling 'SDMMD_TranslateConnectionToSocket' with incomplete return type 'SocketConnection' (aka 'struct SocketConnection_Internal')

I tried to solve this but not get to success
Please help to fix it.

Thanks

Wireless

There is currently a bug in interacting over wireless as the UDID isn't being pulled from the device so it can validate pairing.

sdmmd_return_t SDMMD_ServiceSend(SocketConnection, CFDataRef): Incomplete length

When i try to take backup then it show this error in SDMMD_ServiceSendMessage function.

Please see code:
-(void)getMobileBackup
{
sdmmd_return_t result1 = kAMDInvalidArgumentError;
CFDictionaryRef dict = NULL;
SDMMD_AMConnectionRef conn = NULL;
conn = SDMMD_AMDServiceConnectionCreate(0, NULL, dict);
result1 = SDMMD_AMDeviceStartService(device, CFSTR(AMSVC_BACKUP2), NULL, &conn);

if (SDM_MD_CallSuccessful(result1))
{
    CFMutableDictionaryRef responset = NULL;
    
    
    /*
     Open connection
     
     recieve from device
     
     <CFArray>=[
     <CFStringRef>={DLMessageVersionExchange}
     <CFNumberRef>=(kCFNumberSInt64Type){300} // major version
     <CFNumberRef>=(kCFNumberSInt64Type){0} // minor version
     ]
     
     respond with sending
     
     <CFArray>=[
     <CFStringRef>={DLMessageProcessMessage}
     <CFDictionary>={
     ]
     SupportedProtocolVersions: <CFArray>=[
     <CFNumberRef>=(kCFNumberFloat64Type){2.100000}
     MessageName: <CFStringRef>={Hello}
     }
     ]
     
     
     if successful, now receive
     
     <CFArray>=[
     <CFStringRef>={DLMessageDeviceReady}
     ]
     
     
     
     it seems that for doing a restore, you need to parse the mbdb
     
     
     
     // for files that are not on the host system
     Received:
     <CFArray>=[
     <CFStringRef>={DLMessageDownloadFiles}
     <CFArray>=[
     <CFStringRef>={435f770a03b4ff48d7540f3d85851f845e6e14ac/Info.plist}
     ]
     <CFDictionary>={
     }
     <CFNumberRef>=(kCFNumberFloat64Type){0.000000}
     <CFNumberRef>=(kCFNumberSInt64Type){0}
     ]
     
     
     If file doesn't exist...
     
     Send: (length + 0x06)
     0000 0001 06
     
     Send: (four zeros raw)
     0000 0000
     
     Send Message:
     <CFArray>=[
     <CFStringRef>={DLMessageStatusResponse}
     <CFNumberRef>=(kCFNumberSInt64Type){-13}	// magic error number :P
     <CFStringRef>={Multi status}
     <CFDictionary>={
     <CFStringRef>={435f770a03b4ff48d7540f3d85851f845e6e14ac/Info.plist}: <CFDictionary>={
     <CFStringRef>={DLFileErrorString}: <CFStringRef>=Invalid object referenced in backup image	// this is just an example
     <CFStringRef>={DLFileErrorCode}: <CFNumberRef>=(kCFNumberSInt64Type){-6}	// this is the error code I've seen for file not found
     }
     }
     ]
     */


    
    
    
    CFMutableArrayRef arrVesrions = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
    Float64 code_value1 = 2.0;
    CFNumberRef code1 = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloat64Type, &code_value1);
    CFArrayAppendValue(arrVesrions, code1);
    
    Float64 code_value2 = 2.1;
    CFNumberRef code2 = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloat64Type, &code_value2);
    CFArrayAppendValue(arrVesrions, code2);
    
    CFMutableDictionaryRef dictVersion = SDMMD_create_dict();
    CFDictionarySetValue(dictVersion, CFSTR("SupportedProtocolVersions"), arrVesrions);
    CFDictionarySetValue(dictVersion, CFSTR("MessageName"), CFSTR("Hello"));
    
    CFMutableArrayRef status_response = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
    CFArrayAppendValue(status_response, CFSTR("DLMessageProcessMessage"));
    CFArrayAppendValue(status_response, dictVersion);

    
    result1 = SDMMD_ServiceSendMessage(SDMMD_TranslateConnectionToSocket(conn), status_response, kCFPropertyListXMLFormat_v1_0);
    if (SDM_MD_CallSuccessful(result1))
    {
        result1 = SDMMD_ServiceReceiveMessage(SDMMD_TranslateConnectionToSocket(conn), (CFPropertyListRef *)&responset);
        
    }
    if (SDM_MD_CallSuccessful(result1))
    {
        NSMutableDictionary *dictResponse = (__bridge NSMutableDictionary *)(responset);
        NSLog(@"dictResponse=%@",dictResponse);
        
        
        CFMutableArrayRef arrDeviceReady = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
        CFArrayAppendValue(arrDeviceReady, CFSTR("DLMessageVersionExchange"));
        CFArrayAppendValue(arrDeviceReady, CFSTR("DLVersionsOk"));
        uint32_t code_value3 = 300;
        CFNumberRef code3 = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &code_value3);
        CFArrayAppendValue(arrDeviceReady, code3);

        
        **result1 = SDMMD_ServiceSendMessage(SDMMD_TranslateConnectionToSocket(conn), arrDeviceReady, kCFPropertyListXMLFormat_v1_0);**

        if (SDM_MD_CallSuccessful(result1))
        {
            result1 = SDMMD_ServiceReceiveMessage(SDMMD_TranslateConnectionToSocket(conn), (CFPropertyListRef *)&responset);
            
        }
        if (SDM_MD_CallSuccessful(result1))
        {
            NSMutableDictionary *dictResponse = (__bridge NSMutableDictionary *)(responset);
            NSLog(@"dictResponse=%@",dictResponse);

        }
    }
}

}

I am facing problem in this line:
" result1 = SDMMD_ServiceSendMessage(SDMMD_TranslateConnectionToSocket(conn), arrDeviceReady, kCFPropertyListXMLFormat_v1_0);
"
Please suggest any solution.

SwiftTest Crash on Xcode 7

I'm trying to run the swift example (Xcode 7), and after doing some minor changes to convert to Swift 2 syntax

import SDMMobileDevice

InitializeSDMMobileDevice();

func getDeviceAtIndex(array: NSArray, index: Int) -> SDMMD_AMDeviceRef {
    let device = array.objectAtIndex(index);
    return device as! SDMMD_AMDeviceRef;
}

var deviceList = SDMMD_AMDCreateDeviceList().takeRetainedValue();

var device = getDeviceAtIndex(deviceList, index: 0);

var result1: sdmmd_return_t = SDMMD_AMDeviceConnect(device);
print(result1);
var result2 = SDMMD_AMDeviceStartSession(device);
print(result2)
var domain = CFStringCreateWithCString(kCFAllocatorDefault, "NULL", 0);
var key = CFStringCreateWithCString(kCFAllocatorDefault, "UniqueDeviceID", 0);
var udid = SDMMD_AMDeviceCopyValue(device, domain, key);
//PrintCFType(udid);
var result3 = SDMMD_AMDeviceStopSession(device);
print(result3);
var result4 = SDMMD_AMDeviceDisconnect(device);
print(result4);
//SDMMD_AMDServiceConnectionGetDevice

I get a crash on return device as! SDMMD_AMDeviceRef; everytime. Because it cannot convert from AnyObject to COOpaquePointer (SDMMD_AMDeviceRef).

Do you know a possible solution?

Crashes when device detached

While reading data from the iPhone, if the device is detached the application crashes immediately.

Is there not any exception or crash handling? How to prevent it? Application shouldn't crash but give error instead. There seems to be problem with it.

Missing Files

I am trying to build the .framework but all the files in the core folder in the .xcodeproj are missing?
screen shot 2016-03-15 at 11 35 45 am

Publish on brew

Is there any interest in having the command line utilities published to Brew?

.app using the framework will crash on systems without Xcode

The sample code https://github.com/mountsi/sample1 works fine.
However, when creating an .app from this code this .app will only run on OS X with installed Xcode.
Running this .app on an OS X without Xcode installed will cause a crash. (tried in VMware and also on a MacBook directly)

I'm not really sure why this is happening or if I forgot something important but I can replicate this issue any time.
After installing Xcode on OS X the .app is working fine instantly.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.CoreFoundation 0x00007fff8570c7a6 CFGetTypeID + 54
1 com.samdmarshall.SDMMobileDevice 0x0000000109d821d7 SDMMD__CopyEscrowBag + 151
2 com.samdmarshall.SDMMobileDevice 0x0000000109d839ab SDMMD_AMDeviceStartSession + 619
3 com.test.bugtest 0x0000000109d69861 0x109d67000 + 10337
4 com.apple.Foundation 0x00007fff8b47f784 NSFireTimer + 96
5 com.apple.CoreFoundation 0x00007fff857953e4 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION
+ 20
6 com.apple.CoreFoundation 0x00007fff85794f1f __CFRunLoopDoTimer + 1151
7 com.apple.CoreFoundation 0x00007fff858065aa __CFRunLoopDoTimers + 298
8 com.apple.CoreFoundation 0x00007fff857506a5 __CFRunLoopRun + 1525
9 com.apple.CoreFoundation 0x00007fff8574fe75 CFRunLoopRunSpecific + 309
10 com.apple.HIToolbox 0x00007fff8d367a0d RunCurrentEventLoopInMode + 226
11 com.apple.HIToolbox 0x00007fff8d3677b7 ReceiveNextEventCommon + 479
12 com.apple.HIToolbox 0x00007fff8d3675bc _BlockUntilNextEventMatchingListInModeWithFilter + 65
13 com.apple.AppKit 0x00007fff886ee24e _DPSNextEvent + 1434
14 com.apple.AppKit 0x00007fff886ed89b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
15 com.apple.AppKit 0x00007fff886e199c -[NSApplication run] + 553
16 com.apple.AppKit 0x00007fff886cc783 NSApplicationMain + 940
17 libdyld.dylib 0x00007fff85ffd5fd start + 1

Backup from Device

Atleast please help on it. i am very near to take backup from device to my mac system.
i have reached on last stage to take backup.

i got from device in response as you described in SDMMD_MobileBackup2.h file

(
DLMessageDownloadFiles,
(
"efb2701063497003269535183f353b293f7a501a/Status.plist"
),
{
},
0,
0
)

and then i am passing parameters BackupPath and “efb2701063497003269535183f353b293f7a501a/Status.plist” below function

SDMMD_MB2SendFile(conn, (__bridge CFStringRef)(strBackupPath), (__bridge CFDataRef)(data));

In SDMMD_MB2SendFile contains two function:

  1. SDMMD_MB2SendFileStream
  2. SDMMD_MB2SendEndStream

SDMMD_MB2SendFileStream is working fine but SDMMD_MB2SendEndStream is not working fine.

so i am unable to write this file (efb2701063497003269535183f353b293f7a501a/Status.plist) on my backup folder path
(/Users/admin/Library/Application Support/MobileSync/Backup/efb2701063497003269535183f353b293f7a501a)

Please help any Idea :)

Is posible to support send fake location via "com.apple.dt.simulatelocation" service

I used Xcode to "Simulate Location" and found it throws the log

com.apple.xpc.launchd[1] (lockdown.6282088763277.com.apple.dt.simulatelocation) <Warning>: com.apple.dt.simulatelocation: This daemon is not allowed to execute. Running anyway.

I also custom iOSConsole to attach into this service and see it throws the same message
However I don't know what's next. Could you support this feature?

I know that is undocument but could you guide me how to debug the protocol of existing services as debugserver, afc, etc.

iosdeploy lldb support seems incomplete

When I do iosdeploy -d <udid> -a <path to my .app file>

it installs OK and I can launch manually from my device, but then I get this when it spawns lldb:

  (lldb) target create "/tmp/sdmmd-lldb-prep"
error: '/tmp/sdmmd-lldb-prep' doesn't contain any 'host' platform architectures: x86_64h, x86_64, i386

(lldb)

Looking at /tmp/sdmmd-lldb-prep and iosdeploy/main.c it looks like a lot of the variables aren't expanded, and lldb prep commands missing. Is this something you're actively working on now. If not, happy to do this and submit a PR. Thanks!

Get safari cache.

I think this is not right place to ask question. but i have no idea where user do put questions.

How to get safari cache using this project or is this possible for using this project.
If any idea or code.

I got DeviceName, UDID, batteryCharging.

Thanks.

Mavericks

Some new changes to the usbmuxd protocol on mavericks seem to be making the listener crash for me, these should be 100% backwards compatible, will have to test this going back to 10.6

<openssl/opensslconf.h> is not found

I am using Xcode 7.3.1 with OS X El Capitan 10.11.6.
When i build this then i found "<openssl/opensslconf.h> is not found"

Plz help me to fix it.
Thanks

MobileDevice Type Translation

At present, SDMTranslation.h has a whole mess of #defines to translate the SDMMD types into MobileDevice types. We should look at using typedefs for all the type specifiers instead of #defines. Xcode's code completion and other preprocessing features resolve the #defines, which personally I find annoying. Typedefs are processed by the compiler in a similar way to #defines so theres no possibility of symbol duplication issues.

Increasing memory crash issue

Memory is not being freed properly while reading files from iPhone. It goes up to 2gb for reading 2gb of data, means no memory is being freed at all while reading. And when memory keeps increasing, it crashes.

I'm using static library, maybe that can be the problem? Should I use framework or dylib instead? Can't really understand the problem. Kindly suggest a solution.

#include path in internal headers is inconsistent

In various *Internal.h headers I see

#include <SDMMobileDevice/CFRuntime.h>

and

#include "CFRuntime.h"

and also

#if IS_FRAMEWORK
#include <SDMMobileDevice/CFRuntime.h>
#else
#include "CFRuntime.h"
#endif

This is causing issues when I'm integrating this into a bigger project with its own build scripts. Should we unify them? I suggest the second variant, since #include <...> should really be reserved for system libraries (per most C style guides).

AMDeviceStartService returns useless AMConnectionRef after device has auto shut off

Expected Behavior:

  • AMDeviceStartService returns result other than kAMDSuccess if service cannot be negotiated due to the device have auto-shut-off after the lockdown session was established
  • or
  • AMDeviceStartService returns kAMDSuccess with AMConnectionRef that can be used to receive data

Actual Behavior:

  • AMDeviceStartService returns kAMDSuccess with non-null AMConnectionRef but SDMMD_ServiceReceive calls with that connection time out

Repro steps:

  1. Attach to awake connected device
  2. Start lockdown session with AMDeviceStartSession
  3. Wait until device auto shuts off
  4. Attempt to start service with AMDeviceStartService
  5. Get the socket struct by calling SDMMD_TranslateConnectionToSocket() on the AMConnectionRef returned
  6. Call SDMMD_ServiceReceive. Function returns kAMDSuccess but data parameter is not set, indicating timeout.

Memory Leaks

I seem to be getting memory leaks whenever a call is made to fetch values. The culprits seem to be libcrypto and SDMMD_ServiceReceiveMessage. I have attached a full trace file as well.

screen shot 2016-03-16 at 11 14 51 am

Here is the Swift script I used

import Foundation
import SDMMobileDevice

InitializeSDMMobileDevice()

while true {
    var deviceList = SDMMD_AMDCreateDeviceList().takeRetainedValue()

    for iosDev in deviceList as NSArray {
        let device = unsafeBitCast(iosDev, SDMMD_AMDeviceRef.self)

        var result1: sdmmd_return_t = SDMMD_AMDeviceConnect(device)
        var result2 = SDMMD_AMDeviceStartSession(device)

        var key = CFStringCreateWithCString(kCFAllocatorDefault, kDeviceName, 0)
        var name = SDMMD_AMDeviceCopyValue(device, nil, key)
        print(name.takeUnretainedValue())

        var result3 = SDMMD_AMDeviceStopSession(device)
        var result4 = SDMMD_AMDeviceDisconnect(device)
    }

    sleep(5)
}

iOS.trace.zip

ABI compliance broken

Seems that apple has changed some of the internal device object structure, need to look into how it is formatted now.

AMSVC_FILE_RELAY (com.apple.mobile.file_relay)

I read about this service and I am using this service for IOS 8.3 and OSX 10.10. then it is showing me in response:
{
Error = PermissionDenied;
Goodbye = 1;
}

Could you please tell me how to fix it.

I think this is not a StackOverFlow type question. i think it related to functionality and implementation type issue.

Please suggest.

How to start or use com.apple.atc services

Hi sr,
Sr i want use this service for sync of data from pc to iphone.For this i find on some website that in iOS 6 or above com.apple.atc is used for sync of song from pc to iOS device.Please Could you tell me how can i use this service or any small sample of code for start this service.Your help will be very greatfull to me

Device stops responding after auto-off but AMDeviceIsValid still returns true

Expected Behavior:

  • Can copy values from device lockdown service if session is active before auto-off

Actual Behavior:

  • AMDeviceCopyValue returns NULL after auto-off

Repro steps:

  1. Attach to awake connected device
  2. Start lockdown session with AMDeviceStartSession
  3. Copy value with AMDeviceCopyValue, valid value is returned
  4. Wait until device auto shuts off
  5. Copy value with AMDeviceCopyValue, NULL value is returned

sdmmd_return_t SDMMD_ServiceSend(SocketConnection, CFDataRef): Incomplete length

I am calling function SDMMD_MB2SendFileStream but getting issue.


When passing file_path and SDMMD_AMConnectionRef connnection then get result suceess. when passing data_chunk[1] and SDMMD_AMConnectionRef connnection then get result success. but when pass zero_chunk data and SDMMD_AMConnectionRef connnection then get below error “sdmmd_return_t SDMMD_ServiceSend(SocketConnection, CFDataRef): Incomplete length”. 



sdmmd_return_t SDMMD_MB2SendFileStream(SDMMD_AMConnectionRef conn, CFStringRef path, CFDataRef file) 

{ 
 

sdmmd_return_t result = kAMDSuccess; 

 
CFDataRef file_path = CFStringCreateExternalRepresentation(kCFAllocatorDefault, path, kCFStringEncodingUTF8, 0); 
 
result = SDMMD_ServiceSend(SDMMD_TranslateConnectionToSocket(conn), file_path); 
 CFSafeRelease(file_path); 

CheckErrorAndReturn(result); 

 

char data_chunk[1] = {0x0C}; 
 
CFMutableDataRef data_separator = CFDataCreateMutable(kCFAllocatorDefault, 0); 
 
CFDataAppendBytes(data_separator, (const UInt8 *)data_chunk, sizeof(uint8_t)); 
 CFDataAppendBytes(data_separator, CFDataGetBytePtr(file), CFDataGetLength(file)); 
 
result = SDMMD_ServiceSend(SDMMD_TranslateConnectionToSocket(conn), data_separator); 
 CFSafeRelease(data_separator); 
 
CheckErrorAndReturn(result); 

 

char zero_chunk[1] = {0}; 
 
CFDataRef data_end = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)zero_chunk, sizeof(uint8_t)); 
 
result = SDMMD_ServiceSend(SDMMD_TranslateConnectionToSocket(conn), data_end); 
 CFSafeRelease(data_end); 
 
CheckErrorAndReturn(result); 
 
ExitLabelAndReturn(result);

 
}

Error codes

Replace hex error codes with the enum versions instead.

dyld: Library not loaded: build/libSDMMobileDevice.dylib

env:

 Host : Mac OS X 10.12.4 (16E195)
 Xcode : 8.3.1 (8E1000a)
 Git : git version 2.11.0 (Apple Git-81)

commit 995b926
build framework with: make framework
output:

libCore.a
libSDMMobileDevice.dylib
libcrypto.a
libssl.a

add 4 files to xcode Mac OS project, build and run.
debug console output this,and app did not run.

dyld: Library not loaded: build/libSDMMobileDevice.dylib

Higher privileges required on 10.12 for StartService

Hi.
It seems that in latest 10.12 higher privileges are required to run StartService.

SDMMD__CreateDataFromFileContents: Could not lstat.
SDMMD__CreateDictFromFileContents: Could not read from file.
SDMMD__CreateDataFromFileContents: Could not lstat.
SDMMD__CreateDictFromFileContents: Could not read from file.

Running with sudo works fine

EXC_BAD_ACCESS in SDMMD_Service.c

I'm experiencing some random crashes when using the SDMMobileDevice framework.
(EXC_BAD_ACCESS in SDMMD_Service.c SDMMD__ServiceReceiveBytesSSL)
I'm not able to replicate this but experiencing this regularly.

screenshot

Copy Files into Application Sandbox

Sorry if this is the wrong place for this, but I was wondering if there is any documentation or examples about how to transfer files into an app's sandbox. I think that should be possible based on #4 and #6 in the "What can this project do for me" section. I'm able to access my device, get a list of apps installed, find the app I'm looking for and get its container path, but I'm not sure where to go from there. Hopefully if someone can point me in the right direction I can add another demo method to the demo project.

Also, when I try to build the Anthem project I get the following error:

"error: -fobjc-arc is not supported on platforms using the legacy runtime

Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1"

and since Anthem won't build I cant build the SDM_MD_Demo

EDIT: sorry, just got anthem to build by switching "Build Active Architecture Only" to "Yes" in the build settings.

Header Documentation

header documentation will be completed as each section nears completion of code.

SDMMD__AddNewAMDError isn't really functional

As of the current implementation, it always returns -1. In the one place it is used, SDMMD_Error.c:185 you pass "SDMMD_ErrorsCreatedAtRuntime+1" as the argument. I presume you mean to use "SDMMD_ErrorsCreatedAtRuntime++" as that global variable isn't incremented anywhere else.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.