Initial check-in for install support. Install working yet needs some cosmetic changes & a freeze fix...

This commit is contained in:
imruon 2010-01-09 22:50:06 +00:00
parent adeb60b1e6
commit 7720f29928
10 changed files with 373 additions and 5 deletions

View File

@ -1,10 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C# Express 2008
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomizeMii", "CustomizeMii\CustomizeMii.csproj", "{46B7F0BC-101B-4167-95AD-4C5D78AA0A20}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ForwardMii-Plugin", "ForwardMii-Plugin\ForwardMii-Plugin.csproj", "{20CB2CA7-6767-4758-97FA-97395F47CD6B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Helpers", "Helpers\Helpers.csproj", "{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester", "Tester\Tester.csproj", "{C020DE3A-F72B-47AD-A451-17B7586E4D21}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -19,6 +23,14 @@ Global
{20CB2CA7-6767-4758-97FA-97395F47CD6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20CB2CA7-6767-4758-97FA-97395F47CD6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20CB2CA7-6767-4758-97FA-97395F47CD6B}.Release|Any CPU.Build.0 = Release|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Release|Any CPU.Build.0 = Release|Any CPU
{C020DE3A-F72B-47AD-A451-17B7586E4D21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C020DE3A-F72B-47AD-A451-17B7586E4D21}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C020DE3A-F72B-47AD-A451-17B7586E4D21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C020DE3A-F72B-47AD-A451-17B7586E4D21}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -49,10 +49,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ForwardMii, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ForwardMii-Plugin\bin\Release\ForwardMii.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
@ -180,6 +176,12 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ForwardMii-Plugin\ForwardMii-Plugin.csproj">
<Project>{20CB2CA7-6767-4758-97FA-97395F47CD6B}</Project>
<Name>ForwardMii-Plugin</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -2208,6 +2208,7 @@ namespace CustomizeMii
// a new window (wiiload - window or whatever) ?!
// If it finishes successfully, the variable >> sendWadReady << will turn into 1,
// if it errors, it will turn into -1, as long as it's running it is 0.
}
catch (Exception ex)
{

53
Helpers/Helpers.csproj Normal file
View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Helpers</RootNamespace>
<AssemblyName>Helpers</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="InstallerHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\CrapInstaller.dol.z" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.IO.Compression;
using System.Security.Cryptography;
namespace Helpers
{
public class InstallerHelper
{
public static MemoryStream CreateInstaller(string wadFile, byte iosToUse)
{
const int injectionPosition = 0x85338;
//1. Open the stub installer from resources
MemoryStream compressedStubInstallerStream = LoadCompressedStubInstaller("CrapInstaller.dol.z");
compressedStubInstallerStream.Seek(0, SeekOrigin.Begin);
//2. Decompress compressed installer
MemoryStream uncompressedStubInstallerStream = new MemoryStream();
using (GZipStream gzipStream = new GZipStream(compressedStubInstallerStream, CompressionMode.Decompress))
{
byte[] decompressedBuff = new byte[1024];
while (true)
{
int length = gzipStream.Read(decompressedBuff, 0, 1024);
if (length == 0) break;
uncompressedStubInstallerStream.Write(decompressedBuff, 0, length);
}
}
//3. Take SHA of the wad and store it in the stub installer along with the size of the wad
byte[] wadFileBytes = File.ReadAllBytes(wadFile);
uint wadLength = (uint) wadFileBytes.Length;
byte[] shaHash;
using (SHA1 shaGen = SHA1.Create())
{
shaHash = shaGen.ComputeHash(wadFileBytes);
}
//4. Inject the data into the installer
//Write out the wad size
uncompressedStubInstallerStream.Seek(injectionPosition, SeekOrigin.Begin);
uncompressedStubInstallerStream.WriteByte((byte)((wadLength >> 24) & 0xff));
uncompressedStubInstallerStream.WriteByte((byte)((wadLength >> 16) & 0xff));
uncompressedStubInstallerStream.WriteByte((byte)((wadLength >> 8) & 0xff));
uncompressedStubInstallerStream.WriteByte((byte)(wadLength & 0xff));
//Write out the SHA1 value (Against corruption of the file on the network, this value will be checked by the installer)
uncompressedStubInstallerStream.Write(shaHash, 0, 20);
//Write out the ios to be used...
uncompressedStubInstallerStream.WriteByte(iosToUse);
//pad it with three zeroes (to align it into 32-bit)
uncompressedStubInstallerStream.WriteByte(0); uncompressedStubInstallerStream.WriteByte(0); uncompressedStubInstallerStream.WriteByte(0);
//Write out to be installed wad file's contents...
uncompressedStubInstallerStream.Write(wadFileBytes, 0, (int)wadLength);
return uncompressedStubInstallerStream;
}
private static MemoryStream LoadCompressedStubInstaller(string installerResourceName)
{
using (BinaryReader resLoader = new BinaryReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Helpers.Resources." + installerResourceName)))
{
MemoryStream ms = new MemoryStream();
byte[] temp = resLoader.ReadBytes((int)resLoader.BaseStream.Length);
ms.Write(temp, 0, temp.Length);
return ms;
}
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 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("Helpers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Irduco")]
[assembly: AssemblyProduct("Helpers")]
[assembly: AssemblyCopyright("Copyright © Irduco 2010")]
[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)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("032fe41d-4954-44ea-a8f3-e51de3546361")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Binary file not shown.

88
Tester/Program.cs Normal file
View File

@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Text;
using Helpers;
using System.IO;
using System.IO.Compression;
namespace Tester
{
class Program
{
static void Main(string[] args)
{
string command = args[0];
if (command == "CSTUB")
{
Console.Out.WriteLine("Stub Compression>>");
CompressStub(args[1], args[2]);
}
else if (command == "DSTUB")
{
Console.Out.WriteLine("Stub Decompression>>");
DecompressStub(args[1], args[2]);
}
else if (command == "LOADC")
{
Console.Out.WriteLine("Installer creation>>");
CreateInstaller(args[1], args[2]);
}
}
static void CompressStub(string installerDol, string zippedResourceFileName)
{
using (FileStream fs = new FileStream(installerDol, FileMode.Open))
{
using (FileStream fsOut = new FileStream(zippedResourceFileName, FileMode.Create))
{
using (GZipStream gzip = new GZipStream(fsOut, CompressionMode.Compress))
{
// Copy the source file into the compression stream.
byte[] buffer = new byte[4096];
int numRead;
while ((numRead = fs.Read(buffer, 0, buffer.Length)) != 0)
{
gzip.Write(buffer, 0, numRead);
}
}
}
}
}
public static void DecompressStub(string compressedInstallerDol, string decompressedInstallerDol)
{
// Get the stream of the source file.
using (FileStream inFile = new FileStream(compressedInstallerDol, FileMode.Open))
{
//Create the decompressed file.
using (FileStream outFile = File.Create(decompressedInstallerDol))
{
using (GZipStream Decompress = new GZipStream(inFile,CompressionMode.Decompress))
{
//Copy the decompression stream into the output file.
byte[] buffer = new byte[4096];
int numRead;
while ((numRead = Decompress.Read(buffer, 0, buffer.Length)) != 0)
{
outFile.Write(buffer, 0, numRead);
}
}
}
}
}
static void CreateInstaller(string inWadFilename, string outDolFileName)
{
using (MemoryStream ms = InstallerHelper.CreateInstaller(inWadFilename, 249))
{
using (FileStream fs = new FileStream(outDolFileName, FileMode.Create))
{
ms.WriteTo(fs);
fs.Close();
}
}
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 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("Tester")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Irduco")]
[assembly: AssemblyProduct("Tester")]
[assembly: AssemblyCopyright("Copyright © Irduco 2010")]
[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)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("891f8670-dc92-4f81-b010-62634af8b756")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

56
Tester/Tester.csproj Normal file
View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C020DE3A-F72B-47AD-A451-17B7586E4D21}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Tester</RootNamespace>
<AssemblyName>Tester</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Helpers\Helpers.csproj">
<Project>{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}</Project>
<Name>Helpers</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>