1

I should hook UIResponder of every app, including SpringBoard and any others. In the hooking, I will write something to the specified file. If I set the path to /var/mobile/Library/MyApp, recommended by Cydia, I found that only the SpringBoard and MyApp could write successfully.

So is there a place every app can write and read?

Nate
  • 31,017
  • 13
  • 83
  • 207
Suge
  • 2,808
  • 3
  • 48
  • 79
  • 1
    on a jailbreaked one I think everyone can write almost everywhere –  Jul 23 '13 at 10:42
  • 1
    refer this http://stackoverflow.com/questions/16026920/why-sandbox-in-ios-6-1-1-still-exists-for-app-even-after-i-have-jailbreak – Maulik Jul 23 '13 at 11:26
  • @matheszabi, no, that's not actually true. See Maulik's link, or my answer below. – Nate Jul 24 '13 at 21:16

2 Answers2

2

I admit that I'm not 100% sure on this one, but my guess would be no, there is not a path that every app can writes files to on a jailbroken iPhone.

Certainly, jailbreak apps (installed in /Applications/) on a jailbroken phone can write to locations that can be shared between those jailbreak apps. But, as I understand your question, you would like to inject code into normal, App Store apps, so that those apps can also read and write to the shared location. That part I don't think is possible, because jailbreaking does not completely disable the sandbox for 3rd-party apps installed normally, under /var/mobile/Applications/.

Now, there might be a workaround. There are some shared folders that are accessible to all apps for certain purposes. For example, any app can write images to the saved photos album. What you could try is to take the content of the file you want to write, and encode it as fake image data, in a UIImage (e.g. with [UIImage imageWithData:]). You'd probably need to add a valid image header to the data. Then, you save the file to the photos album, using something like

writeImageToSavedPhotosAlbum:orientation:completionBlock:.

Another app could then find the fake photo by enumerating the saved photos album, and then converting the asset back to image representation to pull the real data back out.

However, this seems quite complicated, and possibly wouldn't work (I haven't tried it). Perhaps you could tell us why you want this shared file. Maybe there's a better way to share the data, without using a globally-accessible file?

Community
  • 1
  • 1
Nate
  • 31,017
  • 13
  • 83
  • 207
  • @ Nate, very appreciate for your help and doing so much.I hook the normal apps to to capture the events and send them out to a file for doing something. But it looks like no way to do that, I've tried hooking and inserting in to apps with the CFMessagePort function to send message, but not success so far. Now I'am reflecting the top design, which maybe is wrong at the beginning.Anyway, I benefit so much from you, and thank you so much. – Suge Jul 24 '13 at 14:51
2

Notifications can help you with this. Every app will send interprocess notifications about the events. You could start a daemon that will listen for this notifications and save them in a file. Or you could listen for them in SpringBoard as he can write, for example, to /var/mobile/Media. Depends on what you want to do with this file. Check out my answer here How to create a global environment variable that can be accessed by SpringBoard or other applications in the jailbroken iPhone?

Community
  • 1
  • 1
creker
  • 9,400
  • 1
  • 30
  • 47