From efd24133be983234ca9dd1c11979a979d7327ef2 Mon Sep 17 00:00:00 2001 From: C Linus Hicks <45015546+linush100@users.noreply.github.com> Date: Sat, 19 Sep 2020 00:33:22 +0200 Subject: [PATCH] BuildUtil: fix an issue encountered with Visual Studio 2008 on Windows XP - When building on Windows XP using Visual Studio 2008, I encountered the following issue. - I did a fresh install of Windows XP SP3 32-bit, then applied updates including .NET 3.5. Next I installed MS Visual Studio 2008, then updated with sp1. All of this according to the documentation in your readme for building on Windows. - In file src/BuildUtils/VpnBuilder.cs, there are two "if" statements testing the same thing, which is to determine if it is a 32-bit or 64-bit machine/compiler. But the then and else clauses are reversed, so clearly, one of them is wrong. The result I saw is that the SDK path being used to run RC.exe is left as the NULL string and so it fails to run the RC.exe program. - This happens early in the build process, building the build utils. The two "if" statements are used to set paths for the Visual Studio VC and SDK directories. Depending on the integer pointer size, it uses different paths in the registry. - When I looked in the registry on my Windows XP machine, there is no key HKLM\SOFTWARE\Wow6432Node, I have only seen that on 64-bit machines. - For the fix, I consolidated the two "if" statements into one, the existing statement on line 380 would only set a value for Paths.VisualStudioVCDir (which got set correctly). Now I moved the code for also setting Paths.MicrosoftSDKDir, while reversing the values from the incorrectly coded "if" statement. - I can understand that under certain circumstances, this issue would not be encountered, but should be easily reproducible when installing a clean system. --- src/BuildUtil/VpnBuilder.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/BuildUtil/VpnBuilder.cs b/src/BuildUtil/VpnBuilder.cs index f235bcc9..f93d5ce2 100644 --- a/src/BuildUtil/VpnBuilder.cs +++ b/src/BuildUtil/VpnBuilder.cs @@ -269,14 +269,17 @@ namespace BuildUtil } // Get the VC++ directory + // Get Microsoft SDK 6.0a directory // Visual Studio 2008 if (IntPtr.Size == 4) { Paths.VisualStudioVCDir = IO.RemoteLastEnMark(Reg.ReadStr(RegRoot.LocalMachine, @"SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VC", "ProductDir")); + Paths.MicrosoftSDKDir = IO.RemoteLastEnMark(Reg.ReadStr(RegRoot.LocalMachine, @"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A", "InstallationFolder")); } else { Paths.VisualStudioVCDir = IO.RemoteLastEnMark(Reg.ReadStr(RegRoot.LocalMachine, @"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VC", "ProductDir")); + Paths.MicrosoftSDKDir = IO.RemoteLastEnMark(Reg.ReadStr(RegRoot.LocalMachine, @"SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v6.0A", "InstallationFolder")); } if (Str.IsEmptyStr(Paths.VisualStudioVCDir)) { @@ -296,16 +299,6 @@ namespace BuildUtil bool x86_dir = false; - // Get Microsoft SDK 6.0a directory - if (IntPtr.Size == 4) - { - Paths.MicrosoftSDKDir = IO.RemoteLastEnMark(Reg.ReadStr(RegRoot.LocalMachine, @"SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v6.0A", "InstallationFolder")); - } - else - { - Paths.MicrosoftSDKDir = IO.RemoteLastEnMark(Reg.ReadStr(RegRoot.LocalMachine, @"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A", "InstallationFolder")); - } - // Get makecat.exe file name Paths.MakeCatFilename = Path.Combine(Paths.MicrosoftSDKDir, @"bin\" + (x86_dir ? @"x86\" : "") + "makecat.exe");