|
1 |
| -#ifdef _WIN32 |
2 |
| -#include "Declarations.h" |
3 |
| -#include "Constants.h" |
4 |
| -#include "FileHelper.h" |
5 |
| -#include "Printing.h" |
6 |
| -#include "SocketHelper.h" |
7 |
| -#include "CommonFunctions.h" |
8 |
| - |
9 |
| -#include <map> |
10 |
| -#include <sstream> |
11 |
| -extern int __result; |
12 |
| - |
13 |
| -std::string get_signature_base64(std::string image_signature_path) |
14 |
| -{ |
15 |
| - FileInfo signature_file_info = get_file_info(image_signature_path, true); |
16 |
| - return base64_encode(&signature_file_info.contents[0], signature_file_info.size); |
17 |
| -} |
18 |
| - |
19 |
| -bool mount_image(std::string& device_identifier, std::string& image_path, std::string& method_id) |
20 |
| -{ |
21 |
| - PRINT_ERROR_AND_RETURN_VALUE_IF_FAILED_RESULT(!exists(image_path), "Could not find developer disk image", device_identifier, method_id, false); |
22 |
| - std::string image_signature_path = image_path + ".signature"; |
23 |
| - PRINT_ERROR_AND_RETURN_VALUE_IF_FAILED_RESULT(!exists(image_signature_path), "Could not find developer disk image signature", device_identifier, method_id, false); |
24 |
| - |
25 |
| - HANDLE mountFd = start_secure_service(device_identifier, kMobileImageMounter, method_id); |
26 |
| - if (!mountFd) |
27 |
| - { |
28 |
| - return false; |
29 |
| - } |
30 |
| - |
31 |
| - FileInfo image_file_info = get_file_info(image_path, false); |
32 |
| - std::string signature_base64 = get_signature_base64(image_signature_path); |
33 |
| - |
34 |
| - std::stringstream xml_command; |
35 |
| - int bytes_sent; |
36 |
| - std::map<std::string, boost::any> dict; |
37 |
| - xml_command << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
38 |
| - "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" |
39 |
| - "<plist version=\"1.0\">" |
40 |
| - "<dict>" |
41 |
| - "<key>Command</key>" |
42 |
| - "<string>ReceiveBytes</string>" |
43 |
| - "<key>ImageSize</key>" |
44 |
| - "<integer>" + std::to_string(image_file_info.size) + "</integer>" |
45 |
| - "<key>ImageType</key>" |
46 |
| - "<string>Developer</string>" |
47 |
| - "<key>ImageSignature</key>" |
48 |
| - "<data>" + signature_base64 + "</data>" |
49 |
| - "</dict>" |
50 |
| - "</plist>"; |
51 |
| - |
52 |
| - bytes_sent = send_message(xml_command.str().c_str(), (SOCKET)mountFd); |
53 |
| - dict = receive_message((SOCKET)mountFd); |
54 |
| - PRINT_ERROR_AND_RETURN_VALUE_IF_FAILED_RESULT(dict.count(kErrorKey), boost::any_cast<std::string>(dict[kErrorKey]).c_str(), device_identifier, method_id, false); |
55 |
| - if (boost::any_cast<std::string>(dict[kStatusKey]) == "ReceiveBytesAck") |
56 |
| - { |
57 |
| - image_file_info = get_file_info(image_path, true); |
58 |
| - bytes_sent = send((SOCKET)mountFd, &image_file_info.contents[0], image_file_info.size, 0); |
59 |
| - dict = receive_message((SOCKET)mountFd); |
60 |
| - xml_command.str(""); |
61 |
| - xml_command << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
62 |
| - "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" |
63 |
| - "<plist version=\"1.0\">" |
64 |
| - "<dict>" |
65 |
| - "<key>Command</key>" |
66 |
| - "<string>MountImage</string>" |
67 |
| - "<key>ImageType</key>" |
68 |
| - "<string>Developer</string>" |
69 |
| - "<key>ImageSignature</key>" |
70 |
| - "<data>" + signature_base64 + "</data>" |
71 |
| - "<key>ImagePath</key>" |
72 |
| - "<string>/var/mobile/Media/PublicStaging/staging.dimage</string>" |
73 |
| - "</dict>" |
74 |
| - "</plist>"; |
75 |
| - bytes_sent = send_message(xml_command.str().c_str(), (SOCKET)mountFd); |
76 |
| - dict = receive_message((SOCKET)mountFd); |
77 |
| - PRINT_ERROR_AND_RETURN_VALUE_IF_FAILED_RESULT(dict.count(kErrorKey), boost::any_cast<std::string>(dict[kErrorKey]).c_str(), device_identifier, method_id, false); |
78 |
| - return dict.count(kStatusKey) && has_complete_status(dict); |
79 |
| - } |
80 |
| - else |
81 |
| - { |
82 |
| - print_error("Could not transfer disk image", device_identifier, method_id, kUnexpectedError); |
83 |
| - return false; |
84 |
| - } |
85 |
| -} |
86 |
| - |
87 |
| -#endif // _WIN32 |
| 1 | +//#ifdef _WIN32 |
| 2 | +//#include "Declarations.h" |
| 3 | +//#include "Constants.h" |
| 4 | +//#include "FileHelper.h" |
| 5 | +//#include "Printing.h" |
| 6 | +//#include "SocketHelper.h" |
| 7 | +//#include "CommonFunctions.h" |
| 8 | +// |
| 9 | +//#include <map> |
| 10 | +//#include <sstream> |
| 11 | +//extern int __result; |
| 12 | +// |
| 13 | +//std::string get_signature_base64(std::string image_signature_path) |
| 14 | +//{ |
| 15 | +// FileInfo signature_file_info = get_file_info(image_signature_path, true); |
| 16 | +// return base64_encode(&signature_file_info.contents[0], signature_file_info.size); |
| 17 | +//} |
| 18 | +// |
| 19 | +//bool mount_image(std::string& device_identifier, std::string& image_path, std::string& method_id) |
| 20 | +//{ |
| 21 | +// PRINT_ERROR_AND_RETURN_VALUE_IF_FAILED_RESULT(!exists(image_path), "Could not find developer disk image", device_identifier, method_id, false); |
| 22 | +// std::string image_signature_path = image_path + ".signature"; |
| 23 | +// PRINT_ERROR_AND_RETURN_VALUE_IF_FAILED_RESULT(!exists(image_signature_path), "Could not find developer disk image signature", device_identifier, method_id, false); |
| 24 | +// |
| 25 | +// ServiceInfo serviceInfo = start_secure_service(device_identifier, kMobileImageMounter, method_id); |
| 26 | +// if (!serviceInfo.socket) |
| 27 | +// { |
| 28 | +// return false; |
| 29 | +// } |
| 30 | +// |
| 31 | +// FileInfo image_file_info = get_file_info(image_path, false); |
| 32 | +// std::string signature_base64 = get_signature_base64(image_signature_path); |
| 33 | +// |
| 34 | +// std::stringstream xml_command; |
| 35 | +// int bytes_sent; |
| 36 | +// std::map<std::string, boost::any> dict; |
| 37 | +// xml_command << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
| 38 | +// "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" |
| 39 | +// "<plist version=\"1.0\">" |
| 40 | +// "<dict>" |
| 41 | +// "<key>Command</key>" |
| 42 | +// "<string>ReceiveBytes</string>" |
| 43 | +// "<key>ImageSize</key>" |
| 44 | +// "<integer>" + std::to_string(image_file_info.size) + "</integer>" |
| 45 | +// "<key>ImageType</key>" |
| 46 | +// "<string>Developer</string>" |
| 47 | +// "<key>ImageSignature</key>" |
| 48 | +// "<data>" + signature_base64 + "</data>" |
| 49 | +// "</dict>" |
| 50 | +// "</plist>"; |
| 51 | +// |
| 52 | +// bytes_sent = send_message(xml_command.str().c_str(), (SOCKET)mountFd); |
| 53 | +// dict = receive_message((SOCKET)mountFd); |
| 54 | +// PRINT_ERROR_AND_RETURN_VALUE_IF_FAILED_RESULT(dict.count(kErrorKey), boost::any_cast<std::string>(dict[kErrorKey]).c_str(), device_identifier, method_id, false); |
| 55 | +// if (boost::any_cast<std::string>(dict[kStatusKey]) == "ReceiveBytesAck") |
| 56 | +// { |
| 57 | +// image_file_info = get_file_info(image_path, true); |
| 58 | +// bytes_sent = send((SOCKET)mountFd, &image_file_info.contents[0], image_file_info.size, 0); |
| 59 | +// dict = receive_message((SOCKET)mountFd); |
| 60 | +// xml_command.str(""); |
| 61 | +// xml_command << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
| 62 | +// "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" |
| 63 | +// "<plist version=\"1.0\">" |
| 64 | +// "<dict>" |
| 65 | +// "<key>Command</key>" |
| 66 | +// "<string>MountImage</string>" |
| 67 | +// "<key>ImageType</key>" |
| 68 | +// "<string>Developer</string>" |
| 69 | +// "<key>ImageSignature</key>" |
| 70 | +// "<data>" + signature_base64 + "</data>" |
| 71 | +// "<key>ImagePath</key>" |
| 72 | +// "<string>/var/mobile/Media/PublicStaging/staging.dimage</string>" |
| 73 | +// "</dict>" |
| 74 | +// "</plist>"; |
| 75 | +// bytes_sent = send_message(xml_command.str().c_str(), (SOCKET)mountFd); |
| 76 | +// dict = receive_message((SOCKET)mountFd); |
| 77 | +// PRINT_ERROR_AND_RETURN_VALUE_IF_FAILED_RESULT(dict.count(kErrorKey), boost::any_cast<std::string>(dict[kErrorKey]).c_str(), device_identifier, method_id, false); |
| 78 | +// return dict.count(kStatusKey) && has_complete_status(dict); |
| 79 | +// } |
| 80 | +// else |
| 81 | +// { |
| 82 | +// print_error("Could not transfer disk image", device_identifier, method_id, kUnexpectedError); |
| 83 | +// return false; |
| 84 | +// } |
| 85 | +//} |
| 86 | +// |
| 87 | +//#endif // _WIN32 |
0 commit comments