Initial commit

This commit is contained in:
kawaiizenbo 2025-01-22 11:29:49 -07:00
commit d3d8347a60
20 changed files with 1344 additions and 0 deletions

2
.gitattributes vendored Normal file
View file

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

398
.gitignore vendored Normal file
View file

@ -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

25
AFCExplorer.sln Normal file
View file

@ -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

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BE979188-8383-470B-BA69-202D36152DA7}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>AFCExplorer</RootNamespace>
<AssemblyName>AFCExplorer</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="iMobileDevice-net, Version=1.3.0.0, Culture=neutral, PublicKeyToken=040ae19651fac98a, processorArchitecture=MSIL">
<HintPath>..\packages\iMobileDevice-net.1.3.17\lib\net45\iMobileDevice-net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="GenericSingleInputWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="AFCFileType.cs" />
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="GenericSingleInputWindow.xaml.cs">
<DependentUpon>GenericSingleInputWindow.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\iMobileDevice-net.1.3.17\build\net45\iMobileDevice-net.targets" Condition="Exists('..\packages\iMobileDevice-net.1.3.17\build\net45\iMobileDevice-net.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\iMobileDevice-net.1.3.17\build\net45\iMobileDevice-net.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\iMobileDevice-net.1.3.17\build\net45\iMobileDevice-net.targets'))" />
</Target>
</Project>

View file

@ -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 = "";
}
}
}

6
AFCExplorer/App.config Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>

9
AFCExplorer/App.xaml Normal file
View file

@ -0,0 +1,9 @@
<Application x:Class="AFCExplorer.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:AFCExplorer"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

17
AFCExplorer/App.xaml.cs Normal file
View file

@ -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
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View file

@ -0,0 +1,15 @@
<Window x:Class="AFCExplorer.GenericSingleInputWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AFCExplorer"
mc:Ignorable="d"
Title="GenericSingleInputWindow" Height="105" Width="250" ResizeMode="NoResize">
<Grid>
<TextBox x:Name="TextBox" Margin="10,10,10,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Grid.ColumnSpan="2"/>
<Button x:Name="OKButton" Content="OK" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Height="20" Width="50" Grid.Column="1" Click="OKButton_Click"/>
<Button x:Name="CancelButton" Content="Cancel" HorizontalAlignment="Right" Margin="0,0,65,10" VerticalAlignment="Bottom" Width="50" Height="20" Grid.Column="1" Click="CancelButton_Click"/>
</Grid>
</Window>

View file

@ -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();
}
}
}

View file

@ -0,0 +1,38 @@
<Window x:Name="window" x:Class="AFCExplorer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AFCExplorer"
mc:Ignorable="d"
Title="AFCExplorer (loading...)" Height="600" Width="800" Loaded="Event_window_Loaded">
<Grid>
<Button x:Name="RefreshButton" Content="Refresh" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="50" Height="25" Click="RefreshButton_Click"/>
<Button x:Name="HomeButton" Content="Home" HorizontalAlignment="Left" Margin="65,10,0,0" VerticalAlignment="Top" Width="50" Height="25" Click="HomeButton_Click"/>
<Button x:Name="GoUpButton" Content="Go Up" HorizontalAlignment="Left" Margin="120,10,0,0" VerticalAlignment="Top" Width="50" Height="25" Click="GoUpButton_Click"/>
<TextBox x:Name="PathTextBox" Margin="175,10,40,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="25" FontSize="16"/>
<Button x:Name="GoButton" Content="Go" HorizontalAlignment="Right" Margin="0,10,10,0" VerticalAlignment="Top" Width="25" Height="25" Click="GoButton_Click"/>
<Grid VerticalAlignment="Bottom" Height="24">
<Grid.Background>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.MenuBarColorKey}}"/>
</Grid.Background>
<Label x:Name="StatusLabel" Content="Waiting for device..." FontSize="11" />
</Grid>
<ListView x:Name="DirectoryItems" d:ItemsSource="{d:SampleData ItemCount=5}" Margin="10,70,10,29" MouseDoubleClick="DirectoryItems_MouseDoubleClick">
<ListView.View>
<GridView>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Header="Date Modified" DisplayMemberBinding="{Binding Modified}"/>
<GridViewColumn Header="Type" DisplayMemberBinding="{Binding Type}"/>
<GridViewColumn Header="Size" DisplayMemberBinding="{Binding Size}"/>
</GridView>
</ListView.View>
</ListView>
<Button x:Name="UploadFileButton" Content="Upload File" HorizontalAlignment="Left" Margin="10,40,0,0" VerticalAlignment="Top" Width="100" Height="25" Click="UploadFileButton_Click"/>
<Button x:Name="DownloadFileButton" Content="Download File" HorizontalAlignment="Left" Margin="115,40,0,0" VerticalAlignment="Top" Width="100" Height="25" Click="DownloadFileButton_Click"/>
<Button x:Name="DeleteButton" Content="Delete Selected" HorizontalAlignment="Left" Margin="220,40,0,0" VerticalAlignment="Top" Width="100" Height="25" Click="DeleteButton_Click"/>
<Button x:Name="MakeDirectoryButton" Content="Make Directory" HorizontalAlignment="Left" Margin="325,40,0,0" VerticalAlignment="Top" Width="100" Height="25" Click="MakeDirectoryButton_Click"/>
<Button x:Name="ConnectAFC2Button" Content="Enable AFC2" HorizontalAlignment="Right" Margin="0,40,10,0" VerticalAlignment="Top" Width="100" Height="25" Click="ConnectAFC2Button_Click"/>
</Grid>
</Window>

View file

@ -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<string> tempFilesList).ThrowOnError();
List<AFCFileType> afcDirectory = new List<AFCFileType>();
foreach (string fn in tempFilesList)
{
if (fn == "." || fn == "..") continue;
afc.afc_get_file_info(afcHandle, path + fn, out ReadOnlyCollection<string> 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<string> 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<string> infoListr);
List<string> infoList = new List<string>(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]);
}
}
}

View file

@ -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
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> 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")]

View file

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AFCExplorer.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// 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() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[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;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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;
}
}
}
}

View file

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="iMobileDevice-net" version="1.3.17" targetFramework="net45" />
</packages>

21
LICENSE Normal file
View file

@ -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.

2
README.md Normal file
View file

@ -0,0 +1,2 @@
# AFCExplorer
AFC File Browser for iOS Devices