/Framework/MobileDevice/SDMMDService/SDMMD_Service.h

https://github.com/jiawei001/SDMMobileDevice · C Header · 277 lines · 192 code · 28 blank · 57 comment · 0 complexity · 18be8ae3880643494b9979a33dba1a25 MD5 · raw file

  1. /*
  2. * SDMMD_Service.h
  3. * SDMMobileDevice
  4. *
  5. * Copyright (c) 2014, Sam Marshall
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
  9. * following conditions are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  12. *
  13. * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
  14. * in the documentation and/or other materials provided with the distribution.
  15. *
  16. * 3. Neither the name of Sam Marshall nor the names of its contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  21. * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *
  26. */
  27. #ifndef _SDM_MD_SERVICE_H_
  28. #define _SDM_MD_SERVICE_H_
  29. #include <CoreFoundation/CoreFoundation.h>
  30. #include "SDMMD_Error.h"
  31. #include "SDMMD_Connection.h"
  32. typedef struct SocketConnection {
  33. bool isSSL;
  34. union {
  35. SSL *ssl;
  36. uint32_t conn;
  37. } socket;
  38. } SocketConnection;
  39. #pragma mark -
  40. #pragma mark Service List
  41. #pragma mark -
  42. #define AMSVC_AFC "com.apple.afc"
  43. #define AMSVC_AFC2 "com.apple.afc2" // hi
  44. #define AMSVC_BACKUP "com.apple.mobilebackup"
  45. #define AMSVC_BACKUP2 "com.apple.mobilebackup2"
  46. #define AMSVC_CRASH_REPORT_COPY "com.apple.crashreportcopy" // nope
  47. #define AMSVC_CRASH_REPORT_COPY_MOB "com.apple.crashreportcopymobile"
  48. #define AMSVC_CRASH_REPORT_COPY_MV "com.apple.crashreportmover"
  49. #define AMSVC_PURPLE_TEST "com.apple.purpletestr" // expects
  50. #define AMSVC_SYNC "com.apple.mobilesync"
  51. #define AMSVC_SCREENSHOT "com.apple.screenshotr"
  52. #define AMSVC_MIS_AGENT "com.apple.misagent"
  53. #define AMSVC_SPRINGBOARD_SERVICES "com.apple.springboardservices"
  54. #define AMSVC_ATC "com.apple.atc" // expects
  55. #define AMSVC_PACKETCAPTURE "com.apple.pcapd"
  56. #define AMSVC_WEB_INSPECTOR "com.apple.webinspector"
  57. #define AMSVC_RASD "com.apple.rasd" // expects
  58. #define AMSVC_THERMAL_MONITOR "com.apple.thermalmonitor.thermtgraphrelay" // expects
  59. #define AMSVC_AIT_AITD "com.apple.ait.aitd" // accessibility response
  60. #define AMSVC_HPD_MOBILE "com.apple.hpd.mobile" // expects
  61. #define AMSVC_SYSLOG_RELAY "com.apple.syslog_relay"
  62. #define AMSVC_FILE_RELAY "com.apple.mobile.file_relay"
  63. #define AMSVC_INTEGRITY_RELAY "com.apple.mobile.integrity_relay"
  64. #define AMSVC_DIAG_RELAY "com.apple.mobile.diagnostics_relay"
  65. #define AMSVC_MOBILE_DEBUG "com.apple.mobile.debug"
  66. #define AMSVC_SYSTEM_PROFILER "com.apple.mobile.system_profiler" // invalid
  67. #define AMSVC_INSTALLATION_PROXY "com.apple.mobile.installation_proxy"
  68. #define AMSVC_FACTORY_PROXY "com.apple.mobile.factory_proxy"
  69. #define AMSVC_NOTIFICATION_PROXY "com.apple.mobile.notification_proxy"
  70. #define AMSVC_HOUSE_ARREST "com.apple.mobile.house_arrest"
  71. #define AMSVC_LOCKDOWN "com.apple.mobile.lockdown" // invalid
  72. #define AMSVC_SOFTWARE_UPDATE "com.apple.mobile.software_update" // invalid
  73. #define AMSVC_DEBUG_IMAGE_MOUNT "com.apple.mobile.debug_image_mount"
  74. #define AMSVC_MOBILE_IMAGE_MOUNT "com.apple.mobile.mobile_image_mounter"
  75. #define AMSVC_MCINSTALL "com.apple.mobile.MCInstall"
  76. #define AMSVC_MDMSERVICE "com.apple.mobile.MDMService"
  77. #define AMSVC_HEARTBEAT "com.apple.mobile.heartbeat" // expects
  78. #define AMSVC_ASSERTATION_AGENT "com.apple.mobile.assertion_agent" // expects
  79. #define AMSVC_IOSDIAG_RELAY "com.apple.iosdiagnostics.relay" // expects
  80. #define AMSVC_DEBUG_SERVER "com.apple.debugserver"
  81. #define AMSVC_DEBUG_SERVER_SECURE "com.apple.debugserver.secure" // used for apple tv?
  82. #define AMSVC_DEBUG_SERVER_APPLIST "com.apple.debugserver.applist"
  83. #define AMSVC_FETCH_SYMBOLS "com.apple.dt.fetchsymbols" // expects
  84. #define AMSVC_SIMULATE_LOCATION "com.apple.dt.simulatelocation"
  85. #define AMSVC_RADIOS_TEST_MOBILE "com.apple.radios.wirelesstester.mobile" // expects
  86. #define AMSVC_RADIOS_TEST_ROOT "com.apple.radios.wirelesstester.root" // expects
  87. struct SDM_MD_Service_Identifiers {
  88. char *identifier;
  89. char *shorthand;
  90. };
  91. enum SDM_MD_Service_Enum {
  92. SDM_MD_Service_AFC,
  93. SDM_MD_Service_AFC2,
  94. SDM_MD_Service_BACKUP,
  95. SDM_MD_Service_BACKUP2,
  96. SDM_MD_Service_CRASH_REPORT_COPY,
  97. SDM_MD_Service_CRASH_REPORT_COPY_MOB,
  98. SDM_MD_Service_CRASH_REPORT_COPY_MV,
  99. SDM_MD_Service_PURPLE_TEST,
  100. SDM_MD_Service_SYNC,
  101. SDM_MD_Service_SCREENSHOT,
  102. SDM_MD_Service_MIS_AGENT,
  103. SDM_MD_Service_SPRINGBOARD_SERVICES,
  104. SDM_MD_Service_ATC,
  105. SDM_MD_Service_PACKETCAPTURE,
  106. SDM_MD_Service_WEB_INSPECTOR,
  107. SDM_MD_Service_RASD,
  108. SDM_MD_Service_THERMAL_MONITOR,
  109. SDM_MD_Service_AIT_AITD,
  110. SDM_MD_Service_HPD_MOBILE,
  111. SDM_MD_Service_SYSLOG_RELAY,
  112. SDM_MD_Service_FILE_RELAY,
  113. SDM_MD_Service_INTEGRITY_RELAY,
  114. SDM_MD_Service_DIAG_RELAY,
  115. SDM_MD_Service_MOBILE_DEBUG,
  116. SDM_MD_Service_SYSTEM_PROFILER,
  117. SDM_MD_Service_INSTALLATION_PROXY,
  118. SDM_MD_Service_FACTORY_PROXY,
  119. SDM_MD_Service_NOTIFICATION_PROXY,
  120. SDM_MD_Service_HOUSE_ARREST,
  121. SDM_MD_Service_LOCKDOWN,
  122. SDM_MD_Service_SOFTWARE_UPDATE,
  123. SDM_MD_Service_DEBUG_IMAGE_MOUNT,
  124. SDM_MD_Service_MOBILE_IMAGE_MOUNT,
  125. SDM_MD_Service_MCINSTALL,
  126. SDM_MD_Service_MDMSERVICE,
  127. SDM_MD_Service_HEARTBEAT,
  128. SDM_MD_Service_ASSERTATION_AGENT,
  129. SDM_MD_Service_IOSDIAG_RELAY,
  130. SDM_MD_Service_DEBUG_SERVER,
  131. SDM_MD_Service_DEBUG_SERVER_SECURE,
  132. SDM_MD_Service_DEBUG_SERVER_APPLIST,
  133. SDM_MD_Service_FETCH_SYMBOLS,
  134. SDM_MD_Service_SIMULATE_LOCATION,
  135. SDM_MD_Service_RADIOS_TEST_MOBILE,
  136. SDM_MD_Service_RADIOS_TEST_ROOT,
  137. SDM_MD_Service_Count
  138. };
  139. ATR_UNUSED static struct SDM_MD_Service_Identifiers SDMMDServiceIdentifiers[SDM_MD_Service_Count] = {
  140. {AMSVC_AFC, "afc"},
  141. {AMSVC_AFC2, "afc2"},
  142. {AMSVC_BACKUP, "backup"},
  143. {AMSVC_BACKUP2, "backup2"},
  144. {AMSVC_CRASH_REPORT_COPY, "crashr"},
  145. {AMSVC_CRASH_REPORT_COPY_MOB, "mcrashr"},
  146. {AMSVC_CRASH_REPORT_COPY_MV, "crashrmove"},
  147. {AMSVC_PURPLE_TEST, "purple"},
  148. {AMSVC_SYNC, "sync"},
  149. {AMSVC_SCREENSHOT, "screenshot"},
  150. {AMSVC_MIS_AGENT, "misagent"},
  151. {AMSVC_SPRINGBOARD_SERVICES, "sb"},
  152. {AMSVC_ATC, "atc"},
  153. {AMSVC_PACKETCAPTURE, "pcap"},
  154. {AMSVC_WEB_INSPECTOR, "web"},
  155. {AMSVC_RASD, "rasd"},
  156. {AMSVC_THERMAL_MONITOR, "thermal"},
  157. {AMSVC_AIT_AITD, "ait"},
  158. {AMSVC_HPD_MOBILE, "hpd"},
  159. {AMSVC_SYSLOG_RELAY, "syslog"},
  160. {AMSVC_FILE_RELAY, "file"},
  161. {AMSVC_INTEGRITY_RELAY, "integ"},
  162. {AMSVC_DIAG_RELAY, "diag"},
  163. {AMSVC_MOBILE_DEBUG, "mobdebug"},
  164. {AMSVC_SYSTEM_PROFILER, "sysprof"},
  165. {AMSVC_INSTALLATION_PROXY, "install"},
  166. {AMSVC_FACTORY_PROXY, "factory"},
  167. {AMSVC_NOTIFICATION_PROXY, "notif"},
  168. {AMSVC_HOUSE_ARREST, "house"},
  169. {AMSVC_LOCKDOWN, "lockdown"},
  170. {AMSVC_SOFTWARE_UPDATE, "update"},
  171. {AMSVC_DEBUG_IMAGE_MOUNT, "dimage"},
  172. {AMSVC_MOBILE_IMAGE_MOUNT, "mimage"},
  173. {AMSVC_MCINSTALL, "mcinstall"},
  174. {AMSVC_MDMSERVICE, "mdm"},
  175. {AMSVC_HEARTBEAT, "heartbeat"},
  176. {AMSVC_ASSERTATION_AGENT, "assert"},
  177. {AMSVC_IOSDIAG_RELAY, "iosdiag"},
  178. {AMSVC_DEBUG_SERVER, "debug"},
  179. {AMSVC_DEBUG_SERVER_SECURE, "debugsec"},
  180. {AMSVC_DEBUG_SERVER_APPLIST, "debugapp"},
  181. {AMSVC_FETCH_SYMBOLS, "fetchsym"},
  182. {AMSVC_SIMULATE_LOCATION, "simloc"},
  183. {AMSVC_RADIOS_TEST_MOBILE, "mradiotest"},
  184. {AMSVC_RADIOS_TEST_ROOT, "rradiotest"},
  185. };
  186. #pragma mark -
  187. #pragma mark Springboard Service Access
  188. #pragma mark -
  189. #define kCommand "command"
  190. #pragma mark *Commands
  191. #define kCommandGetIconState "getIconState"
  192. #define kCommandSetIconState "setIconState"
  193. #define kCommandGetIconPNGData "getIconPNGData"
  194. #define kCommandGetHomeScreenWallpaperPNGData "getHomeScreenWallpaperPNGData"
  195. #define kCommandGetInterfaceOrientation "getInterfaceOrientation"
  196. #pragma mark *FormatVersion
  197. #define kFormatVersion "formatVersion" // use "2" as the key
  198. #pragma mark *Item Properties
  199. #define kPropertyIconState "iconState"
  200. #define kPropertyPNGData "pngData"
  201. #define kPropertyBundleID "bundleId"
  202. #define kPropertyInterfaceOrientation "interfaceOrientation"
  203. #define kListType "listType"
  204. #define kDisplayName "displayName"
  205. #define kIconLists "iconLists"
  206. /*
  207. Results (Array) [
  208. [0] Dock (Array) [
  209. [0] App (Dictionary) {
  210. displayIdentifier (String)
  211. displayName (String)
  212. iconModDate (String)
  213. bundleVersion (String)
  214. bundleIdentifier (String)
  215. }
  216. ]
  217. [1] Page 1 (Array)
  218. [0] Page 1 (Array) [
  219. (see page format above)
  220. ]
  221. ...
  222. [n] Folder (Dictionary) {
  223. displayName (String)
  224. iconLists (Array) [
  225. [0] Page 1 (Array) [
  226. (see page format above)
  227. ]
  228. ]
  229. listType (String)
  230. }
  231. [2] Page 2 (Array) [
  232. (see page format above)
  233. ]
  234. [3] ...
  235. ]
  236. */
  237. #pragma mark -
  238. #pragma mark Service Command Functions
  239. #pragma mark -
  240. sdmmd_return_t SDMMD_DirectServiceSend(SocketConnection handle, CFDataRef data);
  241. sdmmd_return_t SDMMD_DirectServiceReceive(SocketConnection handle, CFDataRef *data);
  242. sdmmd_return_t SDMMD_ServiceSend(SocketConnection handle, CFDataRef data);
  243. sdmmd_return_t SDMMD_ServiceReceive(SocketConnection handle, CFDataRef *data);
  244. sdmmd_return_t SDMMD_ServiceSendMessage(SocketConnection handle, CFPropertyListRef data, CFPropertyListFormat format);
  245. sdmmd_return_t SDMMD_ServiceReceiveMessage(SocketConnection handle, CFPropertyListRef *data);
  246. sdmmd_return_t SDMMD_ServiceSendStream(SocketConnection handle, CFPropertyListRef data, CFPropertyListFormat format);
  247. sdmmd_return_t SDMMD_ServiceReceiveStream(SocketConnection handle, CFPropertyListRef *data);
  248. SocketConnection SDMMD_TranslateConnectionToSocket(SDMMD_AMConnectionRef connection);
  249. #endif