Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyman123abc committed Dec 13, 2017
1 parent b5af5dd commit a9427e7
Show file tree
Hide file tree
Showing 21 changed files with 3,173 additions and 2 deletions.
28 changes: 26 additions & 2 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,32 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:dspatch_gui"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
Title="DSPatch-GUI" Height="351" Width="536" Background="#FFF4F4F4">
<Grid>

<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ToolBar VerticalAlignment="Top" Grid.ColumnSpan="2" Height="28">
<Menu>
<MenuItem x:Name="bar_Credits" Header="Credits" Click="bar_Credits_Click" Background="#FFF0F0F0"></MenuItem>
<MenuItem x:Name="bar_Quit" Header="Quit" Click="bar_Quit_Click"></MenuItem>
</Menu>
</ToolBar>
<TextBox x:Name="downloadStationTextBox" Margin="10,60,10,0" TextWrapping="Wrap" VerticalAlignment="Top"/>
<Label x:Name="label" Content="DS Download Station Volume 1" HorizontalAlignment="Center" Margin="0,33,0,0" VerticalAlignment="Top"/>
<Button x:Name="downloadStationROMOpen" Content="Open File" HorizontalAlignment="Center" Margin="0,100,0,0" VerticalAlignment="Top" Width="75" Click="downloadStationROMOpen_Click"/>
<Label x:Name="verifiedROM" Content="" HorizontalAlignment="Center" Margin="0,129,0,0" VerticalAlignment="Top" Background="{x:Null}" Foreground="#FF2D9139"/>
<Label x:Name="label1" Content="Output File" HorizontalAlignment="Center" Margin="0,23,0,0" Grid.Row="1" VerticalAlignment="Top"/>
<TextBox x:Name="outputTextBox" Margin="10,49,10,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top"/>
<Button x:Name="saveButton" Content="Save File" HorizontalAlignment="Center" Margin="0,89,0,0" Grid.Row="1" VerticalAlignment="Top" Width="76" Click="saveButton_Click"/>
<Button x:Name="createButton" Content="Create ROM" HorizontalAlignment="Center" Margin="222,130,221,0" Grid.Row="1" VerticalAlignment="Top" Grid.ColumnSpan="2" Width="75" Click="createButton_Click"/>
<Label x:Name="label2" Content="ROMs to Add" Grid.Column="1" HorizontalAlignment="Center" Margin="0,33,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.497,0.407"/>
<ListBox x:Name="romListBox" Grid.Column="1" HorizontalAlignment="Center" Height="167" Margin="54,60,54,0" VerticalAlignment="Top" Width="151" Grid.RowSpan="2"/>
<Button x:Name="addROMButton" Content="Add ROM" Grid.Column="1" HorizontalAlignment="Center" Margin="0,89,0,0" Grid.Row="1" VerticalAlignment="Top" Width="74" Click="addROMButton_Click"/>
</Grid>
</Window>
121 changes: 121 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Win32;
using System.Security.Cryptography;
using System.IO;
using dspatch;
using dspatch.Nitro;


namespace dspatch_gui
{
Expand All @@ -24,5 +30,120 @@ public MainWindow()
{
InitializeComponent();
}

static byte[] dsHash = //Hash of the DS Download Station ROM
{
0xF1, 0x8B, 0x55, 0xF3, 0xE1, 0x25, 0x9C, 0x03, 0xE1, 0x0D, 0x0E, 0xCB,
0x54, 0x96, 0x93, 0xB4, 0x29, 0x05, 0xCE, 0xB5
};

private Boolean checkHash(string rom)
{
if (rom == "")
{
return false;
}
byte[] dsdata = File.ReadAllBytes(rom);
byte[] sha1 = SHA1.Create().ComputeHash(dsdata);
for (int i = 0; i < 20; i++)
{
if (sha1[i] != dsHash[i])
{
return false;
}
}
return true;
}

private Boolean createROM()
{
// Make sure everything is filled out properly
if (checkHash(downloadStationTextBox.Text) == false)
{
MessageBox.Show("You aren't using the correct DS Download Station ROM!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
}
if (outputTextBox.Text == "")
{
MessageBox.Show("You did not assign a location for the patched ROM to be saved to!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
}
if (romListBox.HasItems == false)
{
MessageBox.Show("You did not add any ROMs to include in the patched DS Download Station!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
}
byte[] dsdata = File.ReadAllBytes(downloadStationTextBox.Text);
DownloadStationPatcher p = new DownloadStationPatcher(new NDS(dsdata));
foreach(var r in romListBox.Items)
p.AddRom(new NDS(File.ReadAllBytes(r.ToString())));
byte[] finalResult = p.ProduceRom().Write();
File.Create(outputTextBox.Text).Close();
File.WriteAllBytes(outputTextBox.Text, finalResult);
return true;
}

private void bar_Credits_Click(object sender, RoutedEventArgs e)
{
Window1 credits = new Window1();
credits.Show();
}

private void downloadStationROMOpen_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "All Usable Files (*.nds;*.srl)|*.nds;*.srl|All Files (*.*)|*.*";
if (open.ShowDialog() == true)
{
downloadStationTextBox.Text = open.FileName;
}

// Green: #FF33B439
// Red: #FFAE0000
if (checkHash(open.FileName) == false && downloadStationTextBox.Text != "")
{
verifiedROM.Foreground = new SolidColorBrush(Color.FromRgb(0xB3, 0x00, 0x00));
verifiedROM.Content = "Bad ROM!";
}
else if (checkHash(open.FileName) == true)
{
verifiedROM.Foreground = new SolidColorBrush(Color.FromRgb(0x2D, 0x91, 0x39));
verifiedROM.Content = "Good ROM!";
}
}

private void bar_Quit_Click(object sender, RoutedEventArgs e)
{
this.Close();
}

private void saveButton_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog save = new SaveFileDialog();
save.Filter = "NDS ROM (*.nds)|*.nds|All Files (*.*)|*.*";

if (save.ShowDialog() == true)
{
outputTextBox.Text = save.FileName;
}
}

private void addROMButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "All Usable Files (*.nds;*.srl)|*.nds;*.srl";
if (open.ShowDialog() == true)
{
romListBox.Items.Add(open.FileName);
}
}

private void createButton_Click(object sender, RoutedEventArgs e)
{
if (createROM() == true)
{
MessageBox.Show("Patched ROM successfully saved to " + outputTextBox.Text + "!", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}
}
15 changes: 15 additions & 0 deletions Window1.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Window x:Class="dspatch_gui.Window1"
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:dspatch_gui"
mc:Ignorable="d"
Title="Credits" Height="200" Width="360" Background="#FFF4F4F4" ResizeMode="NoResize">
<Grid>
<Label x:Name="label" Content="DS Download Station Patcher by Gericom" HorizontalAlignment="Center" Margin="0,10,0,0" VerticalAlignment="Top" Width="229" Height="26"/>
<Label x:Name="label1" Content="Exploit by Gericom, shutterbug2000, and Apache Thunder" HorizontalAlignment="Center" Margin="0,43,0,0" VerticalAlignment="Top" Width="316" Height="26"/>
<Label x:Name="label2" Content="DSPatch-GUI by bennyman123abc" HorizontalAlignment="Center" Margin="0,79,0,0" VerticalAlignment="Top" Width="192" Height="26"/>
<Button x:Name="button" Content="Close" HorizontalAlignment="Center" Margin="0,123,0,0" VerticalAlignment="Top" Width="75" Height="20" Click="button_Click"/>
</Grid>
</Window>
32 changes: 32 additions & 0 deletions Window1.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace dspatch_gui
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}

private void button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}
62 changes: 62 additions & 0 deletions dspatch-gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -33,9 +34,51 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
Expand All @@ -54,6 +97,21 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="dspatch\DownloadStationPatcher.cs" />
<Compile Include="dspatch\DS\DemoMenu.cs" />
<Compile Include="dspatch\IO\EndianBinaryReader.cs" />
<Compile Include="dspatch\IO\EndianBinaryWriter.cs" />
<Compile Include="dspatch\IO\IOUtil.cs" />
<Compile Include="dspatch\IO\SFSDirectory.cs" />
<Compile Include="dspatch\IO\SFSFile.cs" />
<Compile Include="dspatch\Nitro\ARM9.cs" />
<Compile Include="dspatch\Nitro\CRC16.cs" />
<Compile Include="dspatch\Nitro\CRT0.cs" />
<Compile Include="dspatch\Nitro\NDS.cs" />
<Compile Include="dspatch\Nitro\NitroFS.cs" />
<Compile Include="Window1.xaml.cs">
<DependentUpon>Window1.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand All @@ -66,6 +124,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Window1.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
Expand Down
12 changes: 12 additions & 0 deletions dspatch-gui.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{745ECCE4-5F65-4155-8BEE-7C388A5C4954}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{745ECCE4-5F65-4155-8BEE-7C388A5C4954}.Debug|Any CPU.Build.0 = Debug|Any CPU
{745ECCE4-5F65-4155-8BEE-7C388A5C4954}.Debug|x64.ActiveCfg = Debug|x64
{745ECCE4-5F65-4155-8BEE-7C388A5C4954}.Debug|x64.Build.0 = Debug|x64
{745ECCE4-5F65-4155-8BEE-7C388A5C4954}.Debug|x86.ActiveCfg = Debug|x86
{745ECCE4-5F65-4155-8BEE-7C388A5C4954}.Debug|x86.Build.0 = Debug|x86
{745ECCE4-5F65-4155-8BEE-7C388A5C4954}.Release|Any CPU.ActiveCfg = Release|Any CPU
{745ECCE4-5F65-4155-8BEE-7C388A5C4954}.Release|Any CPU.Build.0 = Release|Any CPU
{745ECCE4-5F65-4155-8BEE-7C388A5C4954}.Release|x64.ActiveCfg = Release|x64
{745ECCE4-5F65-4155-8BEE-7C388A5C4954}.Release|x64.Build.0 = Release|x64
{745ECCE4-5F65-4155-8BEE-7C388A5C4954}.Release|x86.ActiveCfg = Release|x86
{745ECCE4-5F65-4155-8BEE-7C388A5C4954}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions dspatch/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

0 comments on commit a9427e7

Please sign in to comment.