From e484a699502403b50ba173d3531c0a9c1a1605aa Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 21 Mar 2017 11:09:28 -0500 Subject: [PATCH] put RemoveMOTW back in the EXE assemblies. They can't load MOTW'd dlls which contain RemoveMOTW. We still need the RemoveMOTW code in a shared place for externalcores. --- BizHawk.Client.EmuHawk/Program.cs | 12 ++++++++++-- BizHawk.Client.MultiHawk/Program.cs | 4 ++-- BizHawk.Common/Win32Hacks.cs | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/BizHawk.Client.EmuHawk/Program.cs b/BizHawk.Client.EmuHawk/Program.cs index c6a916a5a8..0df0d3788d 100644 --- a/BizHawk.Client.EmuHawk/Program.cs +++ b/BizHawk.Client.EmuHawk/Program.cs @@ -320,6 +320,14 @@ namespace BizHawk.Client.EmuHawk [DllImport("kernel32.dll", SetLastError = true)] static extern uint SetDllDirectory(string lpPathName); + [DllImport("kernel32.dll", EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] + static extern bool DeleteFileW([MarshalAs(UnmanagedType.LPWStr)]string lpFileName); + + public static void RemoveMOTW(string path) + { + DeleteFileW(path + ":Zone.Identifier"); + } + static void WhackAllMOTW(string dllDir) { var todo = new Queue(new[] { new DirectoryInfo(dllDir) }); @@ -328,9 +336,9 @@ namespace BizHawk.Client.EmuHawk var di = todo.Dequeue(); foreach (var disub in di.GetDirectories()) todo.Enqueue(disub); foreach (var fi in di.GetFiles("*.dll")) - Win32Hacks.RemoveMOTW(fi.FullName); + RemoveMOTW(fi.FullName); foreach (var fi in di.GetFiles("*.exe")) - Win32Hacks.RemoveMOTW(fi.FullName); + RemoveMOTW(fi.FullName); } } diff --git a/BizHawk.Client.MultiHawk/Program.cs b/BizHawk.Client.MultiHawk/Program.cs index 69c5891ce1..7f026ec757 100644 --- a/BizHawk.Client.MultiHawk/Program.cs +++ b/BizHawk.Client.MultiHawk/Program.cs @@ -166,9 +166,9 @@ namespace BizHawk.Client.MultiHawk var di = todo.Dequeue(); foreach (var disub in di.GetDirectories()) todo.Enqueue(disub); foreach (var fi in di.GetFiles("*.dll")) - Win32Hacks.RemoveMOTW(fi.FullName); + RemoveMOTW(fi.FullName); foreach (var fi in di.GetFiles("*.exe")) - Win32Hacks.RemoveMOTW(fi.FullName); + RemoveMOTW(fi.FullName); } } diff --git a/BizHawk.Common/Win32Hacks.cs b/BizHawk.Common/Win32Hacks.cs index dd4f5cbd30..419b7f722b 100644 --- a/BizHawk.Common/Win32Hacks.cs +++ b/BizHawk.Common/Win32Hacks.cs @@ -445,6 +445,8 @@ namespace BizHawk.Common [DllImport("kernel32.dll", EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] static extern bool DeleteFileW([MarshalAs(UnmanagedType.LPWStr)]string lpFileName); + //warning: youll have to copy this into the main assembly for your exes in order to run it when booting. + //I only put this for use here by external cores public static void RemoveMOTW(string path) { DeleteFileW(path + ":Zone.Identifier");