Browse Source

Moved from a Python script to a small C# program to support Mono.Cecil

pull/1/head
DaNike 6 years ago
parent
commit
aab06cf3ea
9 changed files with 231 additions and 71 deletions
  1. +32
    -0
      BSIPA.sln
  2. +6
    -0
      CollectDependencies/App.config
  3. +66
    -0
      CollectDependencies/CollectDependencies.csproj
  4. +82
    -0
      CollectDependencies/Program.cs
  5. +36
    -0
      CollectDependencies/Properties/AssemblyInfo.cs
  6. +4
    -0
      CollectDependencies/packages.config
  7. +4
    -4
      IPA/IPA.csproj
  8. +1
    -1
      IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache
  9. +0
    -66
      Refs/grabo.py

+ 32
- 0
BSIPA.sln View File

@ -19,6 +19,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IPA.Injector", "IPA.Injecto
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proxy", "Doorstop\Proxy\Proxy.vcxproj", "{88609E16-731F-46C9-8139-6B1A7A83240D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{C79C2C3A-A7FC-40D6-A5CC-9752A661AFA9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CollectDependencies", "CollectDependencies\CollectDependencies.csproj", "{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -173,10 +177,38 @@ Global
{88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x64.Build.0 = Verbose_Release|x64
{88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x86.ActiveCfg = Verbose|Win32
{88609E16-731F-46C9-8139-6B1A7A83240D}.Verbose|x86.Build.0 = Verbose|Win32
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Debug|x64.ActiveCfg = Debug|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Debug|x64.Build.0 = Debug|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Debug|x86.ActiveCfg = Debug|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Debug|x86.Build.0 = Debug|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Release|Any CPU.Build.0 = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Release|x64.ActiveCfg = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Release|x64.Build.0 = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Release|x86.ActiveCfg = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Release|x86.Build.0 = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Verbose_Release|Any CPU.ActiveCfg = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Verbose_Release|Any CPU.Build.0 = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Verbose_Release|x64.ActiveCfg = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Verbose_Release|x64.Build.0 = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Verbose_Release|x86.ActiveCfg = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Verbose_Release|x86.Build.0 = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Verbose|Any CPU.ActiveCfg = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Verbose|Any CPU.Build.0 = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Verbose|x64.ActiveCfg = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Verbose|x64.Build.0 = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Verbose|x86.ActiveCfg = Release|Any CPU
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}.Verbose|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F08C3C7A-3221-432E-BAB8-32BCE58408C8} = {C79C2C3A-A7FC-40D6-A5CC-9752A661AFA9}
{5F33B310-DC8D-4C0D-877E-BAC3908DE10F} = {C79C2C3A-A7FC-40D6-A5CC-9752A661AFA9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C7380FAB-02D6-4A2A-B428-B4BFCFE3A054}
EndGlobalSection


+ 6
- 0
CollectDependencies/App.config 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>

+ 66
- 0
CollectDependencies/CollectDependencies.csproj View File

@ -0,0 +1,66 @@
<?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>{5F33B310-DC8D-4C0D-877E-BAC3908DE10F}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>CollectDependencies</RootNamespace>
<AssemblyName>CollectDependencies</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</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="Mono.Cecil, Version=0.10.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb, Version=0.10.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb, Version=0.10.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks, Version=0.10.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

+ 82
- 0
CollectDependencies/Program.cs View File

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CollectDependencies
{
class Program
{
static void Main(string[] args)
{
string depsfile = File.ReadAllText(args[0]);
string fdir = Path.GetDirectoryName(args[0]);
List<string> files = new List<string>();
{ // Create files from stuff in depsfile
Stack<string> fstack = new Stack<string>();
void Push(string val)
{
string pre = "";
if (fstack.Count > 0)
pre = fstack.First();
fstack.Push(pre + val);
}
string Pop() => fstack.Pop();
string Replace(string val)
{
var v2 = Pop();
Push(val);
return v2;
}
foreach (var line in depsfile.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
{
var parts = line.Split('"');
var path = parts.Last();
var level = parts.Length - 1;
if (path.StartsWith("::"))
{ // pseudo-command
parts = path.Split(' ');
var command = parts[0].Substring(2);
parts = parts.Skip(1).ToArray();
var arglist = string.Join(" ", parts);
if (command == "from")
{ // an "import" type command
path = File.ReadAllText(Path.Combine(fdir, arglist));
}
else if (command == "prompt")
{
Console.Write(arglist);
path = Console.ReadLine();
}
else
{
path = "";
Console.Error.WriteLine($"Invalid command {command}");
}
}
if (level > fstack.Count - 1)
Push(path);
else if (level == fstack.Count - 1)
files.Add(Replace(path));
else if (level < fstack.Count - 1)
{
files.Add(Pop());
while (level < fstack.Count)
Pop();
Push(path);
}
}
files.Add(Pop());
}
}
}
}

+ 36
- 0
CollectDependencies/Properties/AssemblyInfo.cs 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("CollectDependencies")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CollectDependencies")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[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("5f33b310-dc8d-4c0d-877e-bac3908de10f")]
// 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")]

+ 4
- 0
CollectDependencies/packages.config View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Mono.Cecil" version="0.10.1" targetFramework="net472" />
</packages>

+ 4
- 4
IPA/IPA.csproj View File

@ -94,16 +94,16 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Doorstop\Proxy\Proxy.vcxproj">
<Project>{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}</Project>
<Project>{88609E16-731F-46C9-8139-6B1A7A83240D}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<Private>False</Private>
<Name>Doorstop</Name>
<Name>proxy</Name>
</ProjectReference>
<ProjectReference Include="..\IPA.Injector\IPA.Injector.csproj">
<Project>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Project>
<Project>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<Private>False</Private>
<Name>IPA.Injector</Name>
<Name>IPA.Injector</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>


+ 1
- 1
IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache View File

@ -1 +1 @@
1d38dd5b9139545c6bc300c735ca121563a74d20
de1a0105accb49be9027a1a26ea711a5ac5f69fd

+ 0
- 66
Refs/grabo.py View File

@ -1,66 +0,0 @@
import os
import shutil
def toFileList(text):
lines = text.splitlines()
files = []
stack = []
def push(val):
pre = ''
if len(stack) > 0:
pre = stack[-1]
stack.append(pre + val)
def pop():
return stack.pop()
def replace(val):
val2 = pop()
push(val)
return val2
for line in lines:
spl = line.split('"');
spath = spl[-1]
semis = len(spl[:-1])
if spath.startswith('::'):
spl = spath.split(' ')
cmd = spl[0][2:]
if cmd == 'from': # basically just import
content = ''
with open(' '.join(spl[1:]),'r') as f:
content = f.read()
spath = content
elif cmd == 'prompt':
spath = input(' '.join(spl[1:]))
else:
spath = ''
print("No such command", cmd)
if semis > (len(stack)-1):
push(spath)
elif semis == (len(stack)-1):
files.append(replace(spath))
elif semis < (len(stack)-1):
files.append(pop())
while semis < (len(stack)):
pop()
push(spath)
files.append(pop())
return files
if __name__ == '__main__':
file = ''
with open("refs.txt","r") as f:
file = f.read()
refs = toFileList(file)
tgtDir = "target/"
shutil.rmtree(tgtDir, ignore_errors=True)
if not os.path.exists(tgtDir):
os.makedirs(tgtDir)
for filename in refs:
if (os.path.isfile(filename)):
print("Copying",filename)
shutil.copy(filename, tgtDir)

Loading…
Cancel
Save