From d3d8347a607ea77bf43dff03c7d4674cf86f56df Mon Sep 17 00:00:00 2001
From: kawaiizenbo <48113593+kawaiizenbo@users.noreply.github.com>
Date: Wed, 22 Jan 2025 11:29:49 -0700
Subject: [PATCH] Initial commit
---
.gitattributes | 2 +
.gitignore | 398 +++++++++++++++++++
AFCExplorer.sln | 25 ++
AFCExplorer/AFCExplorer.csproj | 120 ++++++
AFCExplorer/AFCFileType.cs | 21 +
AFCExplorer/App.config | 6 +
AFCExplorer/App.xaml | 9 +
AFCExplorer/App.xaml.cs | 17 +
AFCExplorer/GenericSingleInputWindow.xaml | 15 +
AFCExplorer/GenericSingleInputWindow.xaml.cs | 38 ++
AFCExplorer/MainWindow.xaml | 38 ++
AFCExplorer/MainWindow.xaml.cs | 363 +++++++++++++++++
AFCExplorer/Properties/AssemblyInfo.cs | 52 +++
AFCExplorer/Properties/Resources.Designer.cs | 63 +++
AFCExplorer/Properties/Resources.resx | 117 ++++++
AFCExplorer/Properties/Settings.Designer.cs | 26 ++
AFCExplorer/Properties/Settings.settings | 7 +
AFCExplorer/packages.config | 4 +
LICENSE | 21 +
README.md | 2 +
20 files changed, 1344 insertions(+)
create mode 100644 .gitattributes
create mode 100644 .gitignore
create mode 100644 AFCExplorer.sln
create mode 100644 AFCExplorer/AFCExplorer.csproj
create mode 100644 AFCExplorer/AFCFileType.cs
create mode 100644 AFCExplorer/App.config
create mode 100644 AFCExplorer/App.xaml
create mode 100644 AFCExplorer/App.xaml.cs
create mode 100644 AFCExplorer/GenericSingleInputWindow.xaml
create mode 100644 AFCExplorer/GenericSingleInputWindow.xaml.cs
create mode 100644 AFCExplorer/MainWindow.xaml
create mode 100644 AFCExplorer/MainWindow.xaml.cs
create mode 100644 AFCExplorer/Properties/AssemblyInfo.cs
create mode 100644 AFCExplorer/Properties/Resources.Designer.cs
create mode 100644 AFCExplorer/Properties/Resources.resx
create mode 100644 AFCExplorer/Properties/Settings.Designer.cs
create mode 100644 AFCExplorer/Properties/Settings.settings
create mode 100644 AFCExplorer/packages.config
create mode 100644 LICENSE
create mode 100644 README.md
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..dfe0770
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# Auto detect text files and perform LF normalization
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8a30d25
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,398 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
diff --git a/AFCExplorer.sln b/AFCExplorer.sln
new file mode 100644
index 0000000..2b213c0
--- /dev/null
+++ b/AFCExplorer.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.11.35327.3
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AFCExplorer", "AFCExplorer\AFCExplorer.csproj", "{BE979188-8383-470B-BA69-202D36152DA7}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {BE979188-8383-470B-BA69-202D36152DA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BE979188-8383-470B-BA69-202D36152DA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BE979188-8383-470B-BA69-202D36152DA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BE979188-8383-470B-BA69-202D36152DA7}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {0248E34F-F941-4DCE-9A63-6EA3F459DFBA}
+ EndGlobalSection
+EndGlobal
diff --git a/AFCExplorer/AFCExplorer.csproj b/AFCExplorer/AFCExplorer.csproj
new file mode 100644
index 0000000..11faa62
--- /dev/null
+++ b/AFCExplorer/AFCExplorer.csproj
@@ -0,0 +1,120 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {BE979188-8383-470B-BA69-202D36152DA7}
+ WinExe
+ AFCExplorer
+ AFCExplorer
+ v4.7.2
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+
+
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\packages\iMobileDevice-net.1.3.17\lib\net45\iMobileDevice-net.dll
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+ App.xaml
+ Code
+
+
+ GenericSingleInputWindow.xaml
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
\ No newline at end of file
diff --git a/AFCExplorer/AFCFileType.cs b/AFCExplorer/AFCFileType.cs
new file mode 100644
index 0000000..d8aba0a
--- /dev/null
+++ b/AFCExplorer/AFCFileType.cs
@@ -0,0 +1,21 @@
+using System;
+
+namespace AFCExplorer
+{
+ public class AFCFileType
+ {
+ public string Name { get; set; }
+ public string Type { get; set; }
+ public string Modified { get; set; }
+ public string Size { get; set; }
+
+ public AFCFileType(string name, string type, string modified, string size)
+ {
+ Name = name;
+ Type = type;
+ Modified = modified;
+ Size = size;
+ if (Type == "Directory") Size = "";
+ }
+ }
+}
diff --git a/AFCExplorer/App.config b/AFCExplorer/App.config
new file mode 100644
index 0000000..ecdcf8a
--- /dev/null
+++ b/AFCExplorer/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/AFCExplorer/App.xaml b/AFCExplorer/App.xaml
new file mode 100644
index 0000000..8d15efb
--- /dev/null
+++ b/AFCExplorer/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/AFCExplorer/App.xaml.cs b/AFCExplorer/App.xaml.cs
new file mode 100644
index 0000000..f9f7ad7
--- /dev/null
+++ b/AFCExplorer/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace AFCExplorer
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/AFCExplorer/GenericSingleInputWindow.xaml b/AFCExplorer/GenericSingleInputWindow.xaml
new file mode 100644
index 0000000..df98005
--- /dev/null
+++ b/AFCExplorer/GenericSingleInputWindow.xaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
diff --git a/AFCExplorer/GenericSingleInputWindow.xaml.cs b/AFCExplorer/GenericSingleInputWindow.xaml.cs
new file mode 100644
index 0000000..018eba7
--- /dev/null
+++ b/AFCExplorer/GenericSingleInputWindow.xaml.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Forms;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace AFCExplorer
+{
+ public partial class GenericSingleInputWindow : Window
+ {
+ public DialogResult result;
+ public GenericSingleInputWindow()
+ {
+ InitializeComponent();
+ }
+
+ private void OKButton_Click(object sender, RoutedEventArgs e)
+ {
+ result = System.Windows.Forms.DialogResult.OK;
+ Close();
+ }
+
+ private void CancelButton_Click(object sender, RoutedEventArgs e)
+ {
+ result = System.Windows.Forms.DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/AFCExplorer/MainWindow.xaml b/AFCExplorer/MainWindow.xaml
new file mode 100644
index 0000000..dafbedb
--- /dev/null
+++ b/AFCExplorer/MainWindow.xaml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AFCExplorer/MainWindow.xaml.cs b/AFCExplorer/MainWindow.xaml.cs
new file mode 100644
index 0000000..d75ae51
--- /dev/null
+++ b/AFCExplorer/MainWindow.xaml.cs
@@ -0,0 +1,363 @@
+using iMobileDevice;
+using iMobileDevice.Afc;
+using iMobileDevice.iDevice;
+using iMobileDevice.Lockdown;
+using iMobileDevice.Plist;
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Timers;
+using System.Windows;
+using System.Windows.Input;
+
+namespace AFCExplorer
+{
+ public partial class MainWindow : Window
+ {
+ private readonly IiDeviceApi idevice = LibiMobileDevice.Instance.iDevice;
+ private readonly ILockdownApi lockdown = LibiMobileDevice.Instance.Lockdown;
+ public static IAfcApi afc = LibiMobileDevice.Instance.Afc;
+
+ private iDeviceHandle deviceHandle;
+ private LockdownClientHandle lockdownHandle;
+ public static LockdownServiceDescriptorHandle lockdownServiceHandle;
+ public static AfcClientHandle afcHandle;
+
+ private string deviceType;
+ private string deviceName;
+ private string deviceVersion;
+ private string deviceUDID = "";
+ private bool gotDeviceInfo;
+
+ private readonly Timer deviceDetectorTimer;
+
+ string path = "/";
+ bool afc2 = false;
+
+ public MainWindow()
+ {
+ InitializeComponent();
+ NativeLibraries.Load();
+ deviceDetectorTimer = new Timer
+ {
+ Interval = 1000
+ };
+ deviceDetectorTimer.Elapsed += Event_deviceDetectorTimer_Tick;
+ }
+
+ private void ReadDirectory()
+ {
+ try
+ {
+ if (!path.EndsWith("/")) throw new Exception();
+ afc.afc_read_directory(afcHandle, path, out ReadOnlyCollection tempFilesList).ThrowOnError();
+ List afcDirectory = new List();
+ foreach (string fn in tempFilesList)
+ {
+ if (fn == "." || fn == "..") continue;
+ afc.afc_get_file_info(afcHandle, path + fn, out ReadOnlyCollection fileInfo).ThrowOnError();
+ string readableSize = FormatBytes(ulong.Parse(fileInfo[1]));
+ string readableType = fileInfo[7] == "S_IFDIR" ? "Directory" : "File";
+ int unixSeconds = (int)(((long.Parse(fileInfo[9]) / 1000) / 1000) / 1000);
+ string readableTime = DateTimeOffset.FromUnixTimeSeconds(unixSeconds).DateTime.ToString();
+ afcDirectory.Add(new AFCFileType(fn, readableType, readableTime, readableSize));
+ }
+ DirectoryItems.ItemsSource = afcDirectory;
+ PathTextBox.Text = path;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ path = "/";
+ if (afc2) path = "/private/var/mobile/Media/";
+ ReadDirectory();
+ }
+ }
+
+ private void ChangeTransportControlState(bool enabled)
+ {
+ RefreshButton.IsEnabled = enabled;
+ HomeButton.IsEnabled = enabled;
+ PathTextBox.IsEnabled = enabled;
+ GoButton.IsEnabled = enabled;
+ DownloadFileButton.IsEnabled = enabled;
+ UploadFileButton.IsEnabled = enabled;
+ MakeDirectoryButton.IsEnabled = enabled;
+ DeleteButton.IsEnabled = enabled;
+ ConnectAFC2Button.IsEnabled = enabled;
+ GoUpButton.IsEnabled = enabled;
+ if (!enabled) DirectoryItems.ItemsSource = null;
+ }
+
+ private void Event_window_Loaded(object sender, RoutedEventArgs e)
+ {
+ ChangeTransportControlState(false);
+ deviceDetectorTimer.Start();
+ }
+
+ private void Event_deviceDetectorTimer_Tick(object sender, EventArgs e)
+ {
+ int count = 0;
+ if (idevice.idevice_get_device_list(out ReadOnlyCollection udids, ref count) == iDeviceError.NoDevice || count == 0)
+ {
+ // found nothing
+ deviceUDID = "";
+
+ Dispatcher.Invoke(
+ System.Windows.Threading.DispatcherPriority.Normal,
+ new Action(
+ delegate ()
+ {
+ window.Title = "AFCExplorer (No Device)";
+ }));
+
+ if (gotDeviceInfo)
+ {
+ // device was connected and now it isnt, let user know
+ Dispatcher.Invoke(
+ System.Windows.Threading.DispatcherPriority.Normal,
+ new Action(
+ delegate ()
+ {
+ ChangeTransportControlState(false);
+ StatusLabel.Content = "Device disconnected.";
+ ConnectAFC2Button.Content = "Enable AFC2";
+ PathTextBox.Text = "/";
+ }));
+ gotDeviceInfo = false;
+ afc2 = false;
+ path = "/";
+ }
+ }
+ else
+ {
+ if (!gotDeviceInfo)
+ {
+ try
+ {
+ Dispatcher.Invoke(
+ System.Windows.Threading.DispatcherPriority.Normal,
+ new Action(
+ delegate ()
+ {
+ StatusLabel.Content = "Found device, attempting to connect.";
+ }));
+ idevice.idevice_new(out deviceHandle, udids[0]).ThrowOnError();
+ lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "AFCExplorer").ThrowOnError();
+
+ // make afc connection
+ lockdown.lockdownd_start_service(lockdownHandle, "com.apple.afc", out lockdownServiceHandle);
+ lockdownHandle.Api.Afc.afc_client_new(deviceHandle, lockdownServiceHandle, out afcHandle);
+
+ // get device info
+ lockdown.lockdownd_get_device_name(lockdownHandle, out deviceName).ThrowOnError();
+ lockdown.lockdownd_get_value(lockdownHandle, null, "ProductVersion", out PlistHandle temp).ThrowOnError();
+ temp.Api.Plist.plist_get_string_val(temp, out deviceVersion);
+ lockdown.lockdownd_get_value(lockdownHandle, null, "ProductType", out temp).ThrowOnError();
+ temp.Api.Plist.plist_get_string_val(temp, out deviceType);
+
+ temp.Dispose();
+
+ deviceUDID = udids[0];
+
+ Dispatcher.Invoke(
+ System.Windows.Threading.DispatcherPriority.Normal,
+ new Action(
+ delegate ()
+ {
+ window.Title = $"AFCExplorer ({deviceName}, {deviceType}, iOS {deviceVersion})";
+ StatusLabel.Content = "Connected to device.";
+ PathTextBox.Text = path;
+ ChangeTransportControlState(true);
+ ReadDirectory();
+ }));
+ gotDeviceInfo = true;
+ }
+ catch (Exception ex)
+ {
+ // fucked it up in some way
+ MessageBox.Show(ex.Message);
+ deviceUDID = "";
+ Dispatcher.Invoke(
+ System.Windows.Threading.DispatcherPriority.Normal,
+ new Action(
+ delegate ()
+ {
+ window.Title = "AFCExplorer (No Device)";
+ StatusLabel.Content = "Failed to connect to device.";
+ ChangeTransportControlState(false);
+ }));
+
+ gotDeviceInfo = false; // never should matter but just in case
+ }
+ }
+ }
+ }
+
+ private void GoButton_Click(object sender, RoutedEventArgs e)
+ {
+ path = PathTextBox.Text;
+ ReadDirectory();
+ }
+
+ private void HomeButton_Click(object sender, RoutedEventArgs e)
+ {
+ // these go to the same place
+ path = "/";
+ if (afc2) path = "/private/var/mobile/Media/";
+ ReadDirectory();
+ }
+
+ private void RefreshButton_Click(object sender, RoutedEventArgs e)
+ {
+ ReadDirectory();
+ }
+
+ private void ConnectAFC2Button_Click(object sender, RoutedEventArgs e)
+ {
+ // disable afc2 if already enabled
+ if (afc2)
+ {
+ lockdown.lockdownd_start_service(lockdownHandle, "com.apple.afc", out lockdownServiceHandle).ThrowOnError();
+ lockdownHandle.Api.Afc.afc_client_new(deviceHandle, lockdownServiceHandle, out afcHandle).ThrowOnError();
+ afc2 = false;
+ ConnectAFC2Button.Content = "Enable AFC2";
+ path = "/";
+ ReadDirectory();
+ }
+ else
+ {
+ try
+ {
+ lockdown.lockdownd_start_service(lockdownHandle, "com.apple.afc2", out lockdownServiceHandle).ThrowOnError();
+ lockdownHandle.Api.Afc.afc_client_new(deviceHandle, lockdownServiceHandle, out afcHandle).ThrowOnError();
+ afc2 = true;
+ ConnectAFC2Button.Content = "Disable AFC2";
+ path = "/private/var/mobile/Media/";
+ ReadDirectory();
+ }
+ catch (Exception)
+ {
+ MessageBox.Show("AFC2 Connection failed!\nBe sure your device is jailbroken and has the Apple File Conduit 2 tweak installed.");
+ afc2 = false;
+ }
+ }
+ }
+
+ private void MakeDirectoryButton_Click(object sender, RoutedEventArgs e)
+ {
+ GenericSingleInputWindow inputDialog = new GenericSingleInputWindow();
+ inputDialog.Title = "Name of directory.";
+ inputDialog.TextBox.Text = "New Folder";
+ inputDialog.ShowDialog();
+ if (inputDialog.result == System.Windows.Forms.DialogResult.Cancel) return;
+ afc.afc_make_directory(afcHandle, path + inputDialog.TextBox.Text);
+ ReadDirectory();
+ }
+
+ private void UploadFileButton_Click(object sender, RoutedEventArgs e)
+ {
+ var openAfcUploadFile = new Microsoft.Win32.OpenFileDialog();
+
+ openAfcUploadFile.ShowDialog();
+
+ if (openAfcUploadFile.FileName == "") return;
+
+ string afcUploadFilePath = openAfcUploadFile.FileName;
+
+ string afcUploadFileName = afcUploadFilePath.Split('\\').Last();
+
+ ulong handle = 0UL;
+ afc.afc_file_open(afcHandle, path + "/" + afcUploadFileName, AfcFileMode.FopenRw, ref handle);
+ byte[] array = File.ReadAllBytes(afcUploadFilePath);
+ uint bytesWritten = 0U;
+ afc.afc_file_write(afcHandle, handle, array, (uint)array.Length, ref bytesWritten);
+ afc.afc_file_close(afcHandle, handle);
+ ReadDirectory();
+ }
+
+ private void DownloadFileButton_Click(object sender, RoutedEventArgs e)
+ {
+ var saveAfcFile = new Microsoft.Win32.SaveFileDialog
+ {
+ FileName = ((AFCFileType)DirectoryItems.SelectedItem).Name
+ };
+
+ saveAfcFile.ShowDialog();
+
+ string afcSaveFilePath = saveAfcFile.FileName;
+ string afcFilePath = path + ((AFCFileType)DirectoryItems.SelectedItem).Name;
+ afc.afc_get_file_info(afcHandle, afcFilePath, out ReadOnlyCollection infoListr);
+ List infoList = new List(infoListr.ToArray());
+ long fileSize = Convert.ToInt64(infoList[infoList.FindIndex(x => x == "st_size") + 1]);
+
+ ulong fileHandle = 0;
+ afc.afc_file_open(afcHandle, afcFilePath, AfcFileMode.FopenRdonly, ref fileHandle);
+
+ FileStream fileStream = File.Create(afcSaveFilePath);
+ const int bufferSize = 4194304;
+ for (int i = 0; i < fileSize / bufferSize + 1; i++)
+ {
+ uint bytesRead = 0;
+
+ long remainder = fileSize - i * bufferSize;
+ int currBufferSize = remainder >= bufferSize ? bufferSize : (int)remainder;
+ byte[] currBuffer = new byte[currBufferSize];
+
+ if (afc.afc_file_read(afcHandle, fileHandle, currBuffer, Convert.ToUInt32(currBufferSize), ref bytesRead)
+ != AfcError.Success)
+ {
+ afc.afc_file_close(afcHandle, fileHandle);
+ }
+
+ fileStream.Write(currBuffer, 0, currBufferSize);
+ }
+
+ fileStream.Close();
+ }
+
+ private void DeleteButton_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ afc.afc_remove_path(afcHandle, path + $"/{DirectoryItems.SelectedItem}").ThrowOnError();
+ ReadDirectory();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Failed to delete item.");
+ }
+ }
+
+ private void DirectoryItems_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+ {
+ if (DirectoryItems.SelectedItem == null) return;
+ if (((AFCFileType)DirectoryItems.SelectedItem).Type == "File") return;
+ path += $"{((AFCFileType)DirectoryItems.SelectedItem).Name}/";
+ ReadDirectory();
+ }
+
+ private void GoUpButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (path == "/") return;
+ path = path.Replace('/' + path.TrimEnd('/').Split('/').Last(), "");
+ ReadDirectory();
+ }
+
+ public static string FormatBytes(ulong bytes)
+ {
+ string[] Suffix = { "B", "KB", "MB", "GB", "TB" };
+ int i;
+ double dblSByte = bytes;
+ for (i = 0; i < Suffix.Length && bytes >= 1000; i++, bytes /= 1000)
+ {
+ dblSByte = bytes / 1000.0;
+ }
+
+ return string.Format("{0:0.##} {1}", dblSByte, Suffix[i]);
+ }
+ }
+}
diff --git a/AFCExplorer/Properties/AssemblyInfo.cs b/AFCExplorer/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..d489a59
--- /dev/null
+++ b/AFCExplorer/Properties/AssemblyInfo.cs
@@ -0,0 +1,52 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AFCExplorer")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AFCExplorer")]
+[assembly: AssemblyCopyright("Copyright © 2025")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/AFCExplorer/Properties/Resources.Designer.cs b/AFCExplorer/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..819157e
--- /dev/null
+++ b/AFCExplorer/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace AFCExplorer.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AFCExplorer.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/AFCExplorer/Properties/Resources.resx b/AFCExplorer/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/AFCExplorer/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/AFCExplorer/Properties/Settings.Designer.cs b/AFCExplorer/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..d68db21
--- /dev/null
+++ b/AFCExplorer/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace AFCExplorer.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/AFCExplorer/Properties/Settings.settings b/AFCExplorer/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/AFCExplorer/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AFCExplorer/packages.config b/AFCExplorer/packages.config
new file mode 100644
index 0000000..81b623b
--- /dev/null
+++ b/AFCExplorer/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..c66f398
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 kawaiizenbo
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..da8b2d6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# AFCExplorer
+ AFC File Browser for iOS Devices