From ffecfdce295bf15b0feeae56356b0840aaa938cd Mon Sep 17 00:00:00 2001 From: DaNike Date: Wed, 10 Oct 2018 08:18:12 -0500 Subject: [PATCH] Moved from a Python script to a small C# program to support Mono.Cecil --- BSIPA.sln | 32 ++++++++ CollectDependencies/App.config | 6 ++ .../CollectDependencies.csproj | 66 +++++++++++++++ CollectDependencies/Program.cs | 82 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 36 ++++++++ CollectDependencies/packages.config | 4 + IPA/IPA.csproj | 8 +- .../Debug/IPA.csproj.CoreCompileInputs.cache | 2 +- Refs/grabo.py | 66 --------------- 9 files changed, 231 insertions(+), 71 deletions(-) create mode 100644 CollectDependencies/App.config create mode 100644 CollectDependencies/CollectDependencies.csproj create mode 100644 CollectDependencies/Program.cs create mode 100644 CollectDependencies/Properties/AssemblyInfo.cs create mode 100644 CollectDependencies/packages.config delete mode 100644 Refs/grabo.py diff --git a/BSIPA.sln b/BSIPA.sln index 411979ba..b8a9a7b4 100644 --- a/BSIPA.sln +++ b/BSIPA.sln @@ -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 diff --git a/CollectDependencies/App.config b/CollectDependencies/App.config new file mode 100644 index 00000000..56efbc7b --- /dev/null +++ b/CollectDependencies/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CollectDependencies/CollectDependencies.csproj b/CollectDependencies/CollectDependencies.csproj new file mode 100644 index 00000000..c15270ac --- /dev/null +++ b/CollectDependencies/CollectDependencies.csproj @@ -0,0 +1,66 @@ + + + + + Debug + AnyCPU + {5F33B310-DC8D-4C0D-877E-BAC3908DE10F} + Exe + CollectDependencies + CollectDependencies + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.dll + + + ..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Mdb.dll + + + ..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Pdb.dll + + + ..\packages\Mono.Cecil.0.10.1\lib\net40\Mono.Cecil.Rocks.dll + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CollectDependencies/Program.cs b/CollectDependencies/Program.cs new file mode 100644 index 00000000..306d05a8 --- /dev/null +++ b/CollectDependencies/Program.cs @@ -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 files = new List(); + { // Create files from stuff in depsfile + Stack fstack = new Stack(); + + 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()); + } + + } + } +} diff --git a/CollectDependencies/Properties/AssemblyInfo.cs b/CollectDependencies/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..d806ff21 --- /dev/null +++ b/CollectDependencies/Properties/AssemblyInfo.cs @@ -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")] diff --git a/CollectDependencies/packages.config b/CollectDependencies/packages.config new file mode 100644 index 00000000..353fb5d7 --- /dev/null +++ b/CollectDependencies/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/IPA/IPA.csproj b/IPA/IPA.csproj index 6a49b5a7..90d9cabf 100644 --- a/IPA/IPA.csproj +++ b/IPA/IPA.csproj @@ -94,16 +94,16 @@ - {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} + {88609E16-731F-46C9-8139-6B1A7A83240D} false False - Doorstop + proxy - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} false False - IPA.Injector + IPA.Injector diff --git a/IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache b/IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache index 7a5f217b..ac134d2c 100644 --- a/IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache +++ b/IPA/obj/Debug/IPA.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -1d38dd5b9139545c6bc300c735ca121563a74d20 +de1a0105accb49be9027a1a26ea711a5ac5f69fd diff --git a/Refs/grabo.py b/Refs/grabo.py deleted file mode 100644 index 6e3d0536..00000000 --- a/Refs/grabo.py +++ /dev/null @@ -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) \ No newline at end of file