diff --git a/UIX/UIX.csproj b/UIX/UIX.csproj index 0585627..6d87e5b 100644 --- a/UIX/UIX.csproj +++ b/UIX/UIX.csproj @@ -47,6 +47,26 @@ + + true + bin\x64\Debug\ + DEBUG;TRACE + true + full + x64 + 7.3 + prompt + + + bin\x64\Release\ + TRACE + true + true + pdbonly + x64 + 7.3 + prompt + diff --git a/UIX/UIXSign/Program.cs b/UIX/UIXSign/Program.cs index 8180d8e..a0e46d6 100644 --- a/UIX/UIXSign/Program.cs +++ b/UIX/UIXSign/Program.cs @@ -1,4 +1,9 @@ using dnlib.DotNet; +using dnlib.DotNet.Pdb; +using dnlib.DotNet.Writer; +using dnlib.IO; +using dnlib.PE; +using System; using System.IO; namespace UIXSign @@ -8,17 +13,54 @@ namespace UIXSign static void Main(string[] args) { string dll = args[0]; + string outputName = args.Length >= 2 ? args[1] : "UIX_signed.dll"; string outputDir = Path.GetDirectoryName(dll); - string dllCopy = Path.Combine(outputDir, "UIX_signed.dll"); + string dllCopy = Path.Combine(outputDir, outputName); File.Copy(dll, dllCopy, true); + Console.WriteLine("Created working copy"); - var module = ModuleDefMD.Load(dllCopy); + // Load DLL + using var module = ModuleDefMD.Load(dllCopy); var asm = module.Assembly; - asm.PublicKey = new PublicKey("00240000048000009400000006020000002400005253413100040000010001001dc70401884cdfad2010ce192e1f08a30fb034cf504759943eec3359d4ed09af3ce1616dbb124e479617ec73e4162903766e7a5e7bf1984bb318040118fe0f69dfb8b6e5c7c47a0e1bc9a8984b22f7221cc235986c09c74cab38ea3562c18adb8e3a95b73faf1ed71d7c309058b86d951af2165eb215b47de335e360a6a25da7"); - asm.Write(dll); + var writeOptions = new ModuleWriterOptions(module); + Console.WriteLine("Loaded copy"); - module.Dispose(); + if (module.Metadata.PEImage.ImageDebugDirectories.Count > 0) + Console.WriteLine(module.Metadata.PEImage.ImageDebugDirectories[0]); + Console.WriteLine("Original public key: " + asm.PublicKey.ToString()); + + // 'Sign' the library so it can be loaded by unmodified Zune executables + asm.PublicKey = new PublicKey("00240000048000009400000006020000002400005253413100040000010001001dc70401884cdfad2010ce192e1f08a30fb034cf504759943eec3359d4ed09af3ce1616dbb124e479617ec73e4162903766e7a5e7bf1984bb318040118fe0f69dfb8b6e5c7c47a0e1bc9a8984b22f7221cc235986c09c74cab38ea3562c18adb8e3a95b73faf1ed71d7c309058b86d951af2165eb215b47de335e360a6a25da7"); + module.IsStrongNameSigned = true; + Console.WriteLine("Signed assembly"); + + if (module.Metadata.PEImage.ImageDebugDirectories.Count > 0) + Console.WriteLine(module.Metadata.PEImage.ImageDebugDirectories[0]); + + // Set up PDB to enable debugging + if (module.Metadata.PEImage.ImageDebugDirectories.Count <= 0) + module.CreatePdbState(PdbFileKind.WindowsPDB); + using FileStream pdbFile = File.OpenRead(Path.ChangeExtension(dll, "pdb")); + writeOptions.WritePdb = true; + writeOptions.PdbOptions = PdbWriterOptions.PdbChecksum; + writeOptions.PdbFileName = Path.GetFileName(pdbFile.Name); + writeOptions.PdbFileNameInDebugDirectory = Path.GetFileName(pdbFile.Name); + //writeOptions.PdbFileNameInDebugDirectory = Path.ChangeExtension(Path.GetFileName(dll), ".dn2.pdb"); + //module.CreatePdbState(PdbFileKind.EmbeddedPortablePDB); + //var pdbBytes = File.ReadAllBytes(Path.ChangeExtension(dll, "pdb")); + //var pdbStream = DataStreamFactory.Create(pdbBytes); + //var pdbReader = ByteArrayDataReaderFactory.CreateReader(pdbBytes); + //module.Metadata.PEImage.ImageDebugDirectories.Add(new ImageDebugDirectory(ref pdbReader, true)); + Console.WriteLine("Loaded PDB"); + + if (module.Metadata.PEImage.ImageDebugDirectories.Count > 0) + Console.WriteLine(module.Metadata.PEImage.ImageDebugDirectories[0]); + + // Replace the raw build with the modded DLL + module.Write(dll, writeOptions); File.Delete(dllCopy); + Console.WriteLine("DLL modded:"); + Console.WriteLine(dll); } } } diff --git a/UIX/UIXSign/UIXSign.csproj b/UIX/UIXSign/UIXSign.csproj index e2aefaf..705bc24 100644 --- a/UIX/UIXSign/UIXSign.csproj +++ b/UIX/UIXSign/UIXSign.csproj @@ -12,6 +12,7 @@ 512 true true + latest AnyCPU @@ -32,9 +33,29 @@ prompt 4 + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + latest + prompt + true + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + latest + prompt + true + - - ..\packages\dnlib.3.3.2\lib\net45\dnlib.dll + + ..\..\packages\dnlib.3.3.4\lib\net45\dnlib.dll diff --git a/UIX/UIXSign/packages.config b/UIX/UIXSign/packages.config index 35854da..de4e104 100644 --- a/UIX/UIXSign/packages.config +++ b/UIX/UIXSign/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/UIXControls/UIXControls.csproj b/UIXControls/UIXControls.csproj index d682f41..9cfeb42 100644 --- a/UIXControls/UIXControls.csproj +++ b/UIXControls/UIXControls.csproj @@ -36,6 +36,24 @@ prompt 4 + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + diff --git a/ZuneShell.csproj b/ZuneShell.csproj index f52e80e..0d5531a 100644 --- a/ZuneShell.csproj +++ b/ZuneShell.csproj @@ -37,6 +37,26 @@ 4 true + + true + bin\x64\Debug\ + DEBUG;TRACE + true + full + x64 + 7.3 + prompt + + + bin\x64\Release\ + TRACE + true + true + pdbonly + x64 + 7.3 + prompt + diff --git a/ZuneShell.sln b/ZuneShell.sln index 5f99e37..3548885 100644 --- a/ZuneShell.sln +++ b/ZuneShell.sln @@ -13,25 +13,43 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {E93CFFA3-1EEB-4E71-9E83-7377C1422119}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E93CFFA3-1EEB-4E71-9E83-7377C1422119}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E93CFFA3-1EEB-4E71-9E83-7377C1422119}.Debug|x64.ActiveCfg = Debug|x64 + {E93CFFA3-1EEB-4E71-9E83-7377C1422119}.Debug|x64.Build.0 = Debug|x64 {E93CFFA3-1EEB-4E71-9E83-7377C1422119}.Release|Any CPU.ActiveCfg = Release|Any CPU {E93CFFA3-1EEB-4E71-9E83-7377C1422119}.Release|Any CPU.Build.0 = Release|Any CPU + {E93CFFA3-1EEB-4E71-9E83-7377C1422119}.Release|x64.ActiveCfg = Release|x64 + {E93CFFA3-1EEB-4E71-9E83-7377C1422119}.Release|x64.Build.0 = Release|x64 {5681A1BD-B3EC-450B-BF6E-38187204B6BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5681A1BD-B3EC-450B-BF6E-38187204B6BE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5681A1BD-B3EC-450B-BF6E-38187204B6BE}.Debug|x64.ActiveCfg = Debug|x64 + {5681A1BD-B3EC-450B-BF6E-38187204B6BE}.Debug|x64.Build.0 = Debug|x64 {5681A1BD-B3EC-450B-BF6E-38187204B6BE}.Release|Any CPU.ActiveCfg = Release|Any CPU {5681A1BD-B3EC-450B-BF6E-38187204B6BE}.Release|Any CPU.Build.0 = Release|Any CPU + {5681A1BD-B3EC-450B-BF6E-38187204B6BE}.Release|x64.ActiveCfg = Release|x64 + {5681A1BD-B3EC-450B-BF6E-38187204B6BE}.Release|x64.Build.0 = Release|x64 {56AE007D-B441-4294-8582-D5C63CC1C206}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {56AE007D-B441-4294-8582-D5C63CC1C206}.Debug|Any CPU.Build.0 = Debug|Any CPU + {56AE007D-B441-4294-8582-D5C63CC1C206}.Debug|x64.ActiveCfg = Debug|x64 + {56AE007D-B441-4294-8582-D5C63CC1C206}.Debug|x64.Build.0 = Debug|x64 {56AE007D-B441-4294-8582-D5C63CC1C206}.Release|Any CPU.ActiveCfg = Release|Any CPU {56AE007D-B441-4294-8582-D5C63CC1C206}.Release|Any CPU.Build.0 = Release|Any CPU + {56AE007D-B441-4294-8582-D5C63CC1C206}.Release|x64.ActiveCfg = Release|x64 + {56AE007D-B441-4294-8582-D5C63CC1C206}.Release|x64.Build.0 = Release|x64 {F0323473-F9B6-4875-93B2-DF657C3F7197}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F0323473-F9B6-4875-93B2-DF657C3F7197}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F0323473-F9B6-4875-93B2-DF657C3F7197}.Debug|x64.ActiveCfg = Debug|x64 + {F0323473-F9B6-4875-93B2-DF657C3F7197}.Debug|x64.Build.0 = Debug|x64 {F0323473-F9B6-4875-93B2-DF657C3F7197}.Release|Any CPU.ActiveCfg = Release|Any CPU {F0323473-F9B6-4875-93B2-DF657C3F7197}.Release|Any CPU.Build.0 = Release|Any CPU + {F0323473-F9B6-4875-93B2-DF657C3F7197}.Release|x64.ActiveCfg = Release|x64 + {F0323473-F9B6-4875-93B2-DF657C3F7197}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE