Skip to content

Commit c7500c0

Browse files
committed
Initial commit.
1 parent 267258e commit c7500c0

31 files changed

Lines changed: 2200 additions & 0 deletions

IPA.sln

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25123.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IPA", "IPA\IPA.csproj", "{14092533-98BB-40A4-9AFC-27BB75672A70}"
7+
ProjectSection(ProjectDependencies) = postProject
8+
{D1390268-F68B-4A55-B50D-EAD25756C8EF} = {D1390268-F68B-4A55-B50D-EAD25756C8EF}
9+
{D1C61AF5-0D2D-4752-8203-1C6929025F7C} = {D1C61AF5-0D2D-4752-8203-1C6929025F7C}
10+
{E2848BFB-5432-42F4-8AE0-D2EC0CDF2F71} = {E2848BFB-5432-42F4-8AE0-D2EC0CDF2F71}
11+
EndProjectSection
12+
EndProject
13+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher\Launcher.csproj", "{D1390268-F68B-4A55-B50D-EAD25756C8EF}"
14+
EndProject
15+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IllusionPlugin", "IllusionPlugin\IllusionPlugin.csproj", "{E2848BFB-5432-42F4-8AE0-D2EC0CDF2F71}"
16+
EndProject
17+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IllusionInjector", "IllusionInjector\IllusionInjector.csproj", "{D1C61AF5-0D2D-4752-8203-1C6929025F7C}"
18+
EndProject
19+
Global
20+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
21+
Debug|Any CPU = Debug|Any CPU
22+
Release|Any CPU = Release|Any CPU
23+
EndGlobalSection
24+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
25+
{14092533-98BB-40A4-9AFC-27BB75672A70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{14092533-98BB-40A4-9AFC-27BB75672A70}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{14092533-98BB-40A4-9AFC-27BB75672A70}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{14092533-98BB-40A4-9AFC-27BB75672A70}.Release|Any CPU.Build.0 = Release|Any CPU
29+
{D1390268-F68B-4A55-B50D-EAD25756C8EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30+
{D1390268-F68B-4A55-B50D-EAD25756C8EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
31+
{D1390268-F68B-4A55-B50D-EAD25756C8EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
32+
{D1390268-F68B-4A55-B50D-EAD25756C8EF}.Release|Any CPU.Build.0 = Release|Any CPU
33+
{E2848BFB-5432-42F4-8AE0-D2EC0CDF2F71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34+
{E2848BFB-5432-42F4-8AE0-D2EC0CDF2F71}.Debug|Any CPU.Build.0 = Debug|Any CPU
35+
{E2848BFB-5432-42F4-8AE0-D2EC0CDF2F71}.Release|Any CPU.ActiveCfg = Release|Any CPU
36+
{E2848BFB-5432-42F4-8AE0-D2EC0CDF2F71}.Release|Any CPU.Build.0 = Release|Any CPU
37+
{D1C61AF5-0D2D-4752-8203-1C6929025F7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38+
{D1C61AF5-0D2D-4752-8203-1C6929025F7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
39+
{D1C61AF5-0D2D-4752-8203-1C6929025F7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
40+
{D1C61AF5-0D2D-4752-8203-1C6929025F7C}.Release|Any CPU.Build.0 = Release|Any CPU
41+
EndGlobalSection
42+
GlobalSection(SolutionProperties) = preSolution
43+
HideSolutionNode = FALSE
44+
EndGlobalSection
45+
EndGlobal

IPA/IPA.csproj

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{14092533-98BB-40A4-9AFC-27BB75672A70}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>IPA</RootNamespace>
11+
<AssemblyName>IPA</AssemblyName>
12+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>none</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Xml" />
42+
</ItemGroup>
43+
<ItemGroup>
44+
<Compile Include="Program.cs" />
45+
<Compile Include="Properties\AssemblyInfo.cs" />
46+
</ItemGroup>
47+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
48+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
49+
Other similar extension points exist, see Microsoft.Common.targets.
50+
<Target Name="BeforeBuild">
51+
</Target>
52+
<Target Name="AfterBuild">
53+
</Target>
54+
-->
55+
<Target Name="AfterBuild">
56+
<Message Text="Packing..." Importance="normal" />
57+
<ItemGroup>
58+
<LauncherDlls Include="$(SolutionDir)Launcher\$(OutDir)*.dll" />
59+
<Launcher Include="$(SolutionDir)Launcher\$(OutDir)Launcher.exe" />
60+
<Dlls Include="$(SolutionDir)IllusionInjector\$(OutDir)**\*" />
61+
</ItemGroup>
62+
<Copy SourceFiles="@(Dlls)" DestinationFolder="$(OutputPath)IPA\Managed" />
63+
<Copy SourceFiles="@(Launcher)" DestinationFolder="$(OutputPath)IPA" />
64+
<Copy SourceFiles="@(LauncherDlls)" DestinationFolder="$(OutputPath)" />
65+
</Target>
66+
</Project>

IPA/Program.cs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace IPA
8+
{
9+
class Program
10+
{
11+
static void Main(string[] args)
12+
{
13+
if(args.Length < 1 || !args[0].EndsWith(".exe"))
14+
{
15+
Fail("Drag an (executable) file on the exe!");
16+
}
17+
18+
string launcherSrc = Path.Combine("IPA", "Launcher.exe");
19+
string managedFolder = Path.Combine("IPA", "Managed");
20+
21+
// Sanitizing
22+
if (!File.Exists(launcherSrc)) Fail("Couldn't find launcher! Make sure you extracted all contents of the release archive.");
23+
if (!File.Exists(launcherSrc)) Fail("Couldn't find DLLs! Make sure you extracted all contents of the release archive.");
24+
25+
// Copying
26+
try
27+
{
28+
string projectName = Path.GetFileNameWithoutExtension(args[0]);
29+
string launcherPath = Path.Combine(Environment.CurrentDirectory, projectName + "_Patched.exe");
30+
string dataPath = Path.Combine(Path.Combine(Environment.CurrentDirectory, projectName + "_Data"), "Managed");
31+
32+
File.Copy(launcherSrc, launcherPath, true);
33+
CopyAll(new DirectoryInfo(managedFolder), new DirectoryInfo(dataPath));
34+
35+
Console.WriteLine("Successfully copied files!");
36+
} catch(Exception e)
37+
{
38+
Fail("Oops! This should not have happened.\n\n" + e);
39+
}
40+
}
41+
42+
public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
43+
{
44+
Directory.CreateDirectory(target.FullName);
45+
46+
// Copy each file into the new directory.
47+
foreach (FileInfo fi in source.GetFiles())
48+
{
49+
Console.WriteLine(@"Copying {0}\{1}", target.FullName, fi.Name);
50+
fi.CopyTo(Path.Combine(target.FullName, fi.Name), true);
51+
}
52+
53+
// Copy each subdirectory using recursion.
54+
foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
55+
{
56+
DirectoryInfo nextTargetSubDir =
57+
target.CreateSubdirectory(diSourceSubDir.Name);
58+
CopyAll(diSourceSubDir, nextTargetSubDir);
59+
}
60+
}
61+
62+
63+
static void Fail(string message)
64+
{
65+
Console.BackgroundColor = ConsoleColor.Red;
66+
Console.ForegroundColor = ConsoleColor.White;
67+
Console.Write("{0,80}", "");
68+
Console.Write("{0,-80}", " "+message);
69+
Console.Write("{0,80}", "");
70+
71+
Console.ReadLine();
72+
Environment.Exit(1);
73+
}
74+
}
75+
}

IPA/Properties/AssemblyInfo.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("IPA")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("IPA")]
13+
[assembly: AssemblyCopyright("Copyright © 2016")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("14092533-98bb-40a4-9afc-27bb75672a70")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

IllusionInjector/Bootstrapper.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using UnityEngine;
6+
7+
namespace IllusionInjector
8+
{
9+
class Bootstrapper : MonoBehaviour
10+
{
11+
public event Action Destroyed = delegate {};
12+
13+
void OnDestroy()
14+
{
15+
Destroyed();
16+
}
17+
}
18+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
using IllusionPlugin;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
using UnityEngine;
6+
7+
namespace IllusionInjector
8+
{
9+
public class CompositePlugin : IPlugin
10+
{
11+
IEnumerable<IPlugin> plugins;
12+
13+
private delegate void CompositeCall(IPlugin plugin);
14+
15+
public CompositePlugin(IEnumerable<IPlugin> plugins)
16+
{
17+
this.plugins = plugins;
18+
}
19+
20+
public void OnApplicationStart()
21+
{
22+
Invoke(plugin => plugin.OnApplicationStart());
23+
}
24+
25+
public void OnApplicationQuit()
26+
{
27+
Invoke(plugin => plugin.OnApplicationQuit());
28+
}
29+
30+
public void OnLevelWasLoaded(int level)
31+
{
32+
foreach (var plugin in plugins)
33+
{
34+
try
35+
{
36+
plugin.OnLevelWasLoaded(level);
37+
}
38+
catch (Exception ex)
39+
{
40+
Console.WriteLine("{0}: {1}", plugin.Name, ex);
41+
}
42+
}
43+
}
44+
45+
46+
private void Invoke(CompositeCall callback)
47+
{
48+
foreach (var plugin in plugins)
49+
{
50+
try
51+
{
52+
callback(plugin);
53+
}
54+
catch (Exception ex)
55+
{
56+
Console.WriteLine("{0}: {1}", plugin.Name, ex);
57+
}
58+
}
59+
}
60+
61+
62+
63+
public void OnLevelWasInitialized(int level)
64+
{
65+
foreach (var plugin in plugins)
66+
{
67+
try
68+
{
69+
plugin.OnLevelWasInitialized(level);
70+
}
71+
catch (Exception ex)
72+
{
73+
Console.WriteLine("{0}: {1}", plugin.Name, ex);
74+
}
75+
}
76+
}
77+
78+
79+
public void OnUpdate()
80+
{
81+
Invoke(plugin => plugin.OnUpdate());
82+
}
83+
84+
public void OnFixedUpdate()
85+
{
86+
Invoke(plugin => plugin.OnFixedUpdate());
87+
}
88+
89+
90+
public string Name
91+
{
92+
get { throw new NotImplementedException(); }
93+
}
94+
95+
public string Version
96+
{
97+
get { throw new NotImplementedException(); }
98+
}
99+
100+
public void OnLateUpdate()
101+
{
102+
Invoke(plugin =>
103+
{
104+
if (plugin is IEnhancedPlugin)
105+
((IEnhancedPlugin)plugin).OnLateUpdate();
106+
});
107+
}
108+
}
109+
}

0 commit comments

Comments
 (0)