Permalink
Browse files

Fixed manifest to disable UAC installer detection heuristics.

This was broken by commit 9776879.  The manifest now has the same
elements as before that commit, but is smaller and doesn't crash XP SP2.
  • Loading branch information...
1 parent 8e90b39 commit 3a3f6b96d230b8f517db8c1b7d5388a1d4fc1689 @Lexikos committed Jan 4, 2015
View
@@ -295,7 +295,11 @@
</CustomBuild>
</ItemGroup>
<ItemGroup>
- <None Include="source\resources\AutoHotkey.exe.manifest" />
+ <CustomBuild Include="source\resources\AutoHotkey.exe.manifest">
+ <Command>cscript.exe //NoLogo "$(SolutionDir)source\scripts\minman.js" "%(FullPath)" "$(SolutionDir)temp\AutoHotkey.exe.manifest"</Command>
+ <Outputs>$(SolutionDir)temp\AutoHotkey.exe.manifest</Outputs>
+ <SubType>Designer</SubType>
+ </CustomBuild>
<None Include="source\resources\icon_filetype.ico" />
<None Include="source\resources\icon_main.ico" />
<None Include="source\resources\icon_pause.ico" />
@@ -197,9 +197,6 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
- <None Include="source\resources\AutoHotkey.exe.manifest">
- <Filter>Resource Files</Filter>
- </None>
<None Include="source\resources\icon_filetype.ico">
<Filter>Resource Files</Filter>
</None>
@@ -237,5 +234,8 @@
<CustomBuild Include="source\libx64call\x64stub.asm">
<Filter>Assembly Files</Filter>
</CustomBuild>
+ <CustomBuild Include="source\resources\AutoHotkey.exe.manifest">
+ <Filter>Resource Files</Filter>
+ </CustomBuild>
</ItemGroup>
</Project>
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:v3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity
version="1.1.00.00"
- processorArchitecture="*"
name="AutoHotkey"
type="win32"
/>
@@ -19,6 +18,19 @@
</dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
+ <!--
+ This section has two important effects:
+ - Prevent the Program Compatibility Assistant from popping up if Windows
+ thinks something went wrong (such as if "setup" exits too quickly).
+ - Allow OS version number checks to work correctly on Windows 8.1.
+
+ If the VC++ manifest tool is enabled, it adds redundant xmlns prefixes and
+ declarations to this node and each of its child nodes. This causes bloat,
+ and having two xmlns attributes on a node causes XP SP2 systems to blue-
+ screen just by running the program once or twice. It can be avoided by
+ using an explicit namespace prefix here, but instead we just avoid the
+ manifest tool entirely and do our own processing to minimize size.
+ -->
<application>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
@@ -30,9 +42,19 @@
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>
-<asmv3:application>
- <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
+<v3:application>
+ <v3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
- </asmv3:windowsSettings>
-</asmv3:application>
+ </v3:windowsSettings>
+</v3:application>
+<v3:trustInfo>
+ <v3:security>
+ <v3:requestedPrivileges>
+ <!-- This prevents UAC from using heuristics to detect the program as an installer.
+ It's normally inserted by the VC++ manifest tool, which is disabled for this
+ project for reasons described above. -->
+ <v3:requestedExecutionLevel level="asInvoker" uiAccess="false" />
+ </v3:requestedPrivileges>
+ </v3:security>
+</v3:trustInfo>
</assembly>
@@ -29,9 +29,9 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// The following #ifdef is disabled because manifest generation is disabled
// in project properties. VC++ 2010 changes the manifest in a way that causes
-// XP SP2 systems to blue-screen.
+// XP SP2 systems to blue-screen. Update: See AutoHotkey.exe.manifest for comments.
//#ifdef EMBED_MANIFEST // VC++ 2005 and later don't require the next line.
-CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "AutoHotkey.exe.manifest"
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "..\\..\\temp\\AutoHotkey.exe.manifest"
//#endif
#ifdef APSTUDIO_INVOKED
@@ -0,0 +1,30 @@
+// This script minimizes the size of AutoHotkey.exe.manifest.
+// Using JS because it doesn't depend on AutoHotkey having already been compiled...
+
+try
+{
+ var args = WScript.Arguments;
+ if (args.length < 2)
+ throw new Error("Too few arguments!");
+ var source = args(0);
+ var dest = args(1);
+
+ var fs = new ActiveXObject("Scripting.FileSystemObject");
+
+ var xml = fs.OpenTextFile(source).ReadAll();
+
+ xml = xml
+ .replace(/<!--[\s\S]*?-->/g, "") // Remove comments
+ .replace(/>\s*</g, "><") // Remove space between elements
+ .replace(/\r?\n\s*/g, " ") // Replace line breaks+indent with one space
+ .replace(/<\?xml.*?\?>/, "") // The VS manifest tool seems to strip this out, so we will too
+
+ fs.CreateTextFile(dest, true).Write(xml);
+
+ //WScript.Echo("Finished processing manifest '"+dest+"'");
+}
+catch (ex)
+{
+ WScript.Echo("Error in minman.js: " + ex.message);
+ WScript.Quit(1);
+}

0 comments on commit 3a3f6b9

Please sign in to comment.