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.

This commit is contained in:
zeromus 2017-03-21 11:09:28 -05:00
parent f1cc6eab36
commit e484a69950
3 changed files with 14 additions and 4 deletions
BizHawk.Client.EmuHawk
BizHawk.Client.MultiHawk
BizHawk.Common

View File

@ -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<DirectoryInfo>(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);
}
}

View File

@ -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);
}
}

View File

@ -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");