Example #1
0
        public static AFCError CollectData(iDevice device, string savePath)
        {
            //CollectionForm.logWriter.WriteLine("[INFO] Starting AFC client.");
            IntPtr   afcClient;
            AFCError returnCode = afc_client_start_service(device.Handle, out afcClient, "iOSLibDataCollector");

            if (returnCode != AFCError.AFC_E_SUCCESS || afcClient == IntPtr.Zero)
            {
                //CollectionForm.logWriter.WriteLine("[ERROR] Couldn't start AFC client. AFC error " + (int)returnCode + ": " + returnCode + ".");
                return(returnCode);
            }
            //CollectionForm.logWriter.WriteLine("[INFO] AFC client has been successfully started.");

            int    fileNumber = 0;
            string iOSVersion = device.iOSVersion.Replace(".", "_");
            string fileName;

            do
            {
                fileName = iOSVersion + (fileNumber != 0 ? " (" + fileNumber + ")" : "");
                fileNumber++;
            } while (File.Exists(savePath + @"\" + fileName + ".sqlite") ||
                     File.Exists(savePath + @"\" + fileName + ".sqlite-shm") ||
                     File.Exists(savePath + @"\" + fileName + ".sqlite-wal") ||
                     File.Exists(savePath + @"\" + fileName + ".txt"));
            savePath += @"\" + fileName;

            StreamWriter treeWriter = new StreamWriter(savePath + ".txt");

            //CollectionForm.logWriter.WriteLine("[INFO] Saving directory tree.");
            photoDatabasePath = "";
            string lastDirectory;

            if ((returnCode = saveDirectoryTree(afcClient, "/", treeWriter, out lastDirectory)) != AFCError.AFC_E_SUCCESS)
            {
                //CollectionForm.logWriter.WriteLine("[ERROR] Couldn't save directory tree. An error occurred while reading \"" + lastDirectory
                //+ "\". AFC error " + (int)returnCode + ": " + returnCode + ".");
            }
            //CollectionForm.logWriter.WriteLine("[INFO] Directory saving has been finished.");

            if (photoDatabasePath != "")
            {
                //CollectionForm.logWriter.WriteLine("[INFO] Photos database file is located at " + photoDatabasePath + ".");
            }

            else
            {
                //CollectionForm.logWriter.WriteLine("[ERROR] Couldn't find photo database file.");
            }

            treeWriter.WriteLine("\n\r" + photoDatabasePath);
            treeWriter.Close();

            //CollectionForm.logWriter.WriteLine("[INFO] Saving photos database.");
            returnCode = savePhotosDatabase(afcClient, savePath + ".sqlite");

            afc_client_free(afcClient);
            return(returnCode);
        }
Example #2
0
        public static AFCError CollectData(iDevice device, string savePath)
        {
            //CollectionForm.logWriter.WriteLine("[INFO] Starting AFC client.");
            IntPtr afcClient;
            AFCError returnCode = afc_client_start_service(device.Handle, out afcClient, "iOSLibDataCollector");
            if (returnCode != AFCError.AFC_E_SUCCESS || afcClient == IntPtr.Zero)
            {
                //CollectionForm.logWriter.WriteLine("[ERROR] Couldn't start AFC client. AFC error " + (int)returnCode + ": " + returnCode + ".");
                return returnCode;
            }
            //CollectionForm.logWriter.WriteLine("[INFO] AFC client has been successfully started.");

            int fileNumber = 0;
            string iOSVersion = device.iOSVersion.Replace(".", "_");
            string fileName;
            do
            {
                fileName = iOSVersion + (fileNumber != 0 ? " (" + fileNumber + ")" : "");
                fileNumber++;
            } while (File.Exists(savePath + @"\" + fileName + ".sqlite")
                || File.Exists(savePath + @"\" + fileName + ".sqlite-shm")
                || File.Exists(savePath + @"\" + fileName + ".sqlite-wal")
                || File.Exists(savePath + @"\" + fileName + ".txt"));
            savePath += @"\" + fileName;

            StreamWriter treeWriter = new StreamWriter(savePath + ".txt");

            //CollectionForm.logWriter.WriteLine("[INFO] Saving directory tree.");
            photoDatabasePath = "";
            string lastDirectory;
            if ((returnCode = saveDirectoryTree(afcClient, "/", treeWriter, out lastDirectory)) != AFCError.AFC_E_SUCCESS)
            {
                //CollectionForm.logWriter.WriteLine("[ERROR] Couldn't save directory tree. An error occurred while reading \"" + lastDirectory
                    //+ "\". AFC error " + (int)returnCode + ": " + returnCode + ".");
            }
            //CollectionForm.logWriter.WriteLine("[INFO] Directory saving has been finished.");

            if (photoDatabasePath != "")
            {
                //CollectionForm.logWriter.WriteLine("[INFO] Photos database file is located at " + photoDatabasePath + ".");
            }

            else
            {
                //CollectionForm.logWriter.WriteLine("[ERROR] Couldn't find photo database file.");
            }

            treeWriter.WriteLine("\n\r" + photoDatabasePath);
            treeWriter.Close();

            //CollectionForm.logWriter.WriteLine("[INFO] Saving photos database.");
            returnCode = savePhotosDatabase(afcClient, savePath + ".sqlite");

            afc_client_free(afcClient);
            return returnCode;
        }