diff --git a/Build/BizHawk.Build.Tool.exe b/Build/BizHawk.Build.Tool.exe
index 2bf586054b..b8a093b1bc 100644
Binary files a/Build/BizHawk.Build.Tool.exe and b/Build/BizHawk.Build.Tool.exe differ
diff --git a/Build/BizHawk.Build.Tool/BizHawk.Build.Tool.csproj b/Build/BizHawk.Build.Tool/BizHawk.Build.Tool.csproj
index 8c7ef94d06..226d9220fc 100644
--- a/Build/BizHawk.Build.Tool/BizHawk.Build.Tool.csproj
+++ b/Build/BizHawk.Build.Tool/BizHawk.Build.Tool.csproj
@@ -36,10 +36,14 @@
AnyCPU
..\
+ false
+ false
AnyCPU
..\
+ false
+ false
diff --git a/Build/BizHawk.Build.Tool/Tool.cs b/Build/BizHawk.Build.Tool/Tool.cs
index 8a8c7894ab..1218d0c7ce 100644
--- a/Build/BizHawk.Build.Tool/Tool.cs
+++ b/Build/BizHawk.Build.Tool/Tool.cs
@@ -16,6 +16,7 @@ namespace BizHawk.Build.Tool
{
case "SVN_REV": SVN_REV(true,cmdArgs); break;
case "GIT_REV": SVN_REV(false,cmdArgs); break;
+ case "NXCOMPAT": NXCOMPAT(cmdArgs); break;
}
}
@@ -66,6 +67,44 @@ namespace BizHawk.Build.Tool
File.WriteAllText(path, content);
}
+ //sets NXCOMPAT bit in PE header
+ static void NXCOMPAT(string[] args)
+ {
+ string target = null, strValue = "0";
+ int idx = 0;
+ while (idx < args.Length)
+ {
+ string a = args[idx++];
+ string au = a.ToUpperInvariant();
+ if (au == "--TARGET")
+ target = args[idx++];
+ if (au == "--VALUE")
+ strValue = args[idx++];
+ }
+ if (target == null)
+ {
+ Console.WriteLine("NXCOMPAT: No target EXE specified");
+ return;
+ }
+
+ //we're going to skip around through the file and edit only the minimum required bytes (to speed things up by avoiding loading and rewriting the entire exe)
+ using(var fs = new FileStream(target,FileMode.Open,FileAccess.ReadWrite,FileShare.Read))
+ {
+ var br = new BinaryReader(fs);
+ fs.Position = 0x3C;
+ fs.Position = br.ReadUInt16(); //move to NT_HEADERS
+ fs.Position += 0x18; //move to OPTIONAL_HEADER
+ fs.Position += 0x46; //move to DllCharacteristics
+ var dllCharacteristics = br.ReadUInt16();
+ dllCharacteristics &= unchecked((ushort)~0x100);
+ if (strValue == "1") dllCharacteristics |= 0x100;
+ fs.Position -= 2; //move back to DllCharacteristics
+ var bw = new BinaryWriter(fs);
+ bw.Write(dllCharacteristics);
+ bw.Flush();
+ }
+ }
+
//gets the working copy version. use this command:
//BizHawk.Build.Tool.exe SCM_REV --wc c:\path\to\wcdir --template c:\path\to\templatefile --out c:\path\to\outputfile.cs
//if the required tools aren't found