Add files via upload

This commit is contained in:
Useful Stuffs 2024-02-11 12:51:01 +01:00 committed by GitHub
commit eac708fbdc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
96 changed files with 28373 additions and 0 deletions

202
LICENSE.md Normal file
View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

37
LegacyUpdate.sln Normal file
View File

@ -0,0 +1,37 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LegacyUpdate", "LegacyUpdate\LegacyUpdate.vcxproj", "{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug-VC08|Win32 = Debug-VC08|Win32
Debug-VC08|x64 = Debug-VC08|x64
Debug-VC17|Win32 = Debug-VC17|Win32
Debug-VC17|x64 = Debug-VC17|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}.Debug-VC08|Win32.ActiveCfg = Debug-VC08|Win32
{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}.Debug-VC08|Win32.Build.0 = Debug-VC08|Win32
{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}.Debug-VC08|x64.ActiveCfg = Debug-VC17|x64
{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}.Debug-VC08|x64.Build.0 = Debug-VC17|x64
{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}.Debug-VC17|Win32.ActiveCfg = Debug-VC17|Win32
{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}.Debug-VC17|Win32.Build.0 = Debug-VC17|Win32
{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}.Debug-VC17|x64.ActiveCfg = Debug-VC17|x64
{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}.Debug-VC17|x64.Build.0 = Debug-VC17|x64
{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}.Release|Win32.ActiveCfg = Release|Win32
{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}.Release|Win32.Build.0 = Release|Win32
{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}.Release|x64.ActiveCfg = Release|x64
{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E11EF986-8512-4F69-B67C-C40CCB81052A}
EndGlobalSection
EndGlobal

39
LegacyUpdate/Compat.cpp Normal file
View File

@ -0,0 +1,39 @@
#include "stdafx.h"
#include <comdef.h>
#include "Utils.h"
typedef BOOL (WINAPI *_Wow64DisableWow64FsRedirection)(PVOID *OldValue);
typedef BOOL (WINAPI *_Wow64RevertWow64FsRedirection)(PVOID OldValue);
typedef BOOL (WINAPI *_GetProductInfo)(DWORD, DWORD, DWORD, DWORD, PDWORD);
// XP+
_Wow64DisableWow64FsRedirection $Wow64DisableWow64FsRedirection = (_Wow64DisableWow64FsRedirection)GetProcAddress(GetModuleHandle(L"kernel32.dll"), "Wow64DisableWow64FsRedirection");
_Wow64RevertWow64FsRedirection $Wow64RevertWow64FsRedirection = (_Wow64RevertWow64FsRedirection)GetProcAddress(GetModuleHandle(L"kernel32.dll"), "Wow64RevertWow64FsRedirection");
// Vista+
_GetProductInfo $GetProductInfo = (_GetProductInfo)GetProcAddress(GetModuleHandle(L"kernel32.dll"), "GetProductInfo");
BOOL GetVistaProductInfo(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dwSpMajorVersion, DWORD dwSpMinorVersion, PDWORD pdwReturnedProductType) {
if ($GetProductInfo) {
return $GetProductInfo(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion, pdwReturnedProductType);
} else {
*pdwReturnedProductType = PRODUCT_UNDEFINED;
return FALSE;
}
}
BOOL DisableWow64FsRedirection(PVOID *OldValue) {
if ($Wow64DisableWow64FsRedirection) {
return $Wow64DisableWow64FsRedirection(OldValue);
} else {
return TRUE;
}
}
BOOL RevertWow64FsRedirection(PVOID OldValue) {
if ($Wow64RevertWow64FsRedirection) {
return $Wow64RevertWow64FsRedirection(OldValue);
} else {
return TRUE;
}
}

6
LegacyUpdate/Compat.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
BOOL GetVistaProductInfo(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dwSpMajorVersion, DWORD dwSpMinorVersion, PDWORD pdwReturnedProductType);
BOOL DisableWow64FsRedirection(PVOID *OldValue);
BOOL RevertWow64FsRedirection(PVOID OldValue);

18
LegacyUpdate/CplTasks.xml Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<applications xmlns="http://schemas.microsoft.com/windows/cpltasks/v1" xmlns:sh="http://schemas.microsoft.com/windows/tasks/v1">
<application id="{FFBE8D44-E9CF-4DD8-9FD6-976802C94D9C}">
<sh:task id="{9943E8C8-748D-47CE-AE10-9FA4A80ED28B}" needsElevation="true">
<sh:name>@&quot;%ProgramFiles%\Legacy Update\LegacyUpdate.dll&quot;,-3</sh:name>
<sh:keywords>legacy update;legacyupdate;update;windows;microsoft;driver;security;software;</sh:keywords>
<sh:command>%windir%\system32\rundll32.exe &quot;%ProgramFiles%\Legacy Update\LegacyUpdate.dll&quot;,LaunchUpdateSite</sh:command>
</sh:task>
<category id="5">
<sh:task idref="{9943E8C8-748D-47CE-AE10-9FA4A80ED28B}" />
</category>
<category id="10">
<sh:task idref="{9943E8C8-748D-47CE-AE10-9FA4A80ED28B}" />
</category>
</application>
</applications>

View File

@ -0,0 +1,74 @@
// ElevationHelper.cpp : Implementation of CElevationHelper
#include "stdafx.h"
#include "ElevationHelper.h"
#include "Utils.h"
#include <strsafe.h>
const BSTR permittedProgIDs[] = {
L"Microsoft.Update.",
NULL
};
const int permittedProgIDsMax = 1;
BOOL ProgIDIsPermitted(PWSTR progID) {
if (progID == NULL) {
return FALSE;
}
for (int i = 0; i < permittedProgIDsMax; i++) {
if (wcsncmp(progID, permittedProgIDs[i], wcslen(permittedProgIDs[i])) == 0) {
return TRUE;
}
}
return FALSE;
}
STDMETHODIMP CoCreateInstanceAsAdmin(HWND hwnd, __in REFCLSID rclsid, __in REFIID riid, __deref_out void **ppv) {
WCHAR clsidString[45];
StringFromGUID2(rclsid, clsidString, ARRAYSIZE(clsidString));
WCHAR monikerName[75];
HRESULT hr = StringCchPrintf(monikerName, ARRAYSIZE(monikerName), L"Elevation:Administrator!new:%s", clsidString);
if (!SUCCEEDED(hr)) {
return hr;
}
BIND_OPTS3 bindOpts;
memset(&bindOpts, 0, sizeof(bindOpts));
bindOpts.cbStruct = sizeof(bindOpts);
bindOpts.hwnd = hwnd;
bindOpts.dwClassContext = CLSCTX_LOCAL_SERVER;
return CoGetObject(monikerName, &bindOpts, riid, ppv);
}
HRESULT CElevationHelper::CreateObject(BSTR progID, IDispatch **retval) {
if (progID == NULL) {
return E_INVALIDARG;
}
HRESULT hr = S_OK;
CComPtr<IDispatch> object;
if (!ProgIDIsPermitted(progID)) {
hr = E_ACCESSDENIED;
goto end;
}
CLSID clsid;
hr = CLSIDFromProgID(progID, &clsid);
if (!SUCCEEDED(hr)) {
goto end;
}
hr = object.CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER);
if (!SUCCEEDED(hr)) {
goto end;
}
*retval = object.Detach();
end:
if (!SUCCEEDED(hr)) {
TRACE("CreateObject(%ls) failed: %ls\n", progID, GetMessageForHresult(hr));
}
return hr;
}

View File

@ -0,0 +1,44 @@
#pragma once
// ElevationHelper.h : Declaration of the CElevationHelper class.
#include <atlctl.h>
#include "resource.h"
#include "LegacyUpdate_i.h"
BOOL ProgIDIsPermitted(PWSTR progID);
STDMETHODIMP CoCreateInstanceAsAdmin(HWND hwnd, __in REFCLSID rclsid, __in REFIID riid, __deref_out void **ppv);
// CElevationHelper
class ATL_NO_VTABLE CElevationHelper :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CElevationHelper, &CLSID_ElevationHelper>,
public ISupportErrorInfo,
public IDispatchImpl<IElevationHelper, &IID_IElevationHelper, &LIBID_LegacyUpdateLib, /*wMajor =*/ 1, /*wMinor =*/ 0> {
public:
CElevationHelper() {}
DECLARE_REGISTRY_RESOURCEID(IDR_ELEVATIONHELPER)
BEGIN_COM_MAP(CElevationHelper)
COM_INTERFACE_ENTRY(IElevationHelper)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid) {
return IsEqualGUID(riid, IID_IElevationHelper) ? S_OK : S_FALSE;
}
// IElevationHelper
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct() { return S_OK; }
void FinalRelease() {}
STDMETHODIMP CreateObject(BSTR progID, IDispatch **retval);
};
OBJECT_ENTRY_AUTO(__uuidof(ElevationHelper), CElevationHelper)

View File

@ -0,0 +1,32 @@
HKCR
{
LegacyUpdate.ElevationHelper.1 = s 'Legacy Update Elevation Helper'
{
CLSID = s '{84F517AD-6438-478F-BEA8-F0B808DC257F}'
}
LegacyUpdate.ElevationHelper = s 'Legacy Update Elevation Helper'
{
CurVer = s 'LegacyUpdate.ElevationHelper.1'
}
NoRemove CLSID
{
ForceRemove {84F517AD-6438-478F-BEA8-F0B808DC257F} = s 'Legacy Update Elevation Helper'
{
ProgID = s 'LegacyUpdate.ElevationHelper.1'
VersionIndependentProgID = s 'LegacyUpdate.ElevationHelper'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
val AppID = s '%APPID%'
val LocalizedString = s '@%MODULE%,-2'
TypeLib = s '{05D22F33-C7C3-4C90-BDD9-CEDC86EA8FBE}'
Version = s '1.0'
Elevation
{
val Enabled = d '1'
val IconReference = s '@%MODULE%,-201'
}
}
}
}

View File

@ -0,0 +1,174 @@
#include "stdafx.h"
#include <comdef.h>
#include <ShellAPI.h>
#include <ShlObj.h>
#include <ExDisp.h>
#include <strsafe.h>
#include "Utils.h"
#include "LegacyUpdate_i.h"
#include "dllmain.h"
const LPCSTR UpdateSiteHostname = "legacyupdate.net";
const LPWSTR UpdateSiteURLHttp = L"http://legacyupdate.net/windowsupdate/v6/";
const LPWSTR UpdateSiteURLHttps = L"https://legacyupdate.net/windowsupdate/v6/";
const LPWSTR UpdateSiteFirstRunFlag = L"?firstrun=true";
static BOOL CanUseSSLConnection() {
// Get the Windows Update website URL set by Legacy Update setup
LPWSTR data;
DWORD size;
HRESULT hr = GetRegistryString(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate", L"URL", NULL, &data, &size);
if (!SUCCEEDED(hr)) {
goto end;
}
// Return based on the URL value
if (StrCmpW(data, UpdateSiteURLHttps) == 0) {
return TRUE;
} else if (StrCmpW(data, UpdateSiteURLHttp) == 0) {
return FALSE;
}
end:
// Fallback: Use SSL only on Vista and up
OSVERSIONINFOEX *versionInfo = GetVersionInfo();
return versionInfo->dwMajorVersion > 5;
}
// Function signature required by Rundll32.exe.
void CALLBACK LaunchUpdateSite(HWND hwnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow) {
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
CComPtr<IWebBrowser2> browser;
CComVariant url;
CComVariant flags(0);
CComVariant nullVariant;
if (!SUCCEEDED(hr)) {
goto end;
}
// If running on 2k/XP, make sure we're elevated. If not, show Run As prompt.
if (GetVersionInfo()->dwMajorVersion < 6 && !IsUserAnAdmin()) {
LPWSTR filename;
DWORD filenameSize;
GetOwnFileName(&filename, &filenameSize);
WCHAR args[MAX_PATH + 20];
StringCchPrintfW(args, filenameSize + 20, L"\"%ls\",LaunchUpdateSite", filename);
// Ignore C4311 and C4302, which is for typecasts. It is due to ShellExec and should be safe to bypass.
#pragma warning(disable: 4311 4302)
int execResult = (int)ShellExecute(NULL, L"runas", L"rundll32.exe", args, NULL, SW_SHOWDEFAULT);
#pragma warning(default: 4311 4302)
// Access denied happens when the user clicks No/Cancel.
if (execResult <= 32 && execResult != SE_ERR_ACCESSDENIED) {
hr = E_FAIL;
}
goto end;
}
// Spawn an IE window via the COM interface. This ensures the page opens in IE (ShellExecute uses
// default browser), and avoids hardcoding a path to iexplore.exe. Also conveniently allows testing
// on Windows 11 (iexplore.exe redirects to Edge, but COM still works). Same strategy as used by
// Wupdmgr.exe and Muweb.dll,LaunchMUSite.
hr = browser.CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER);
if (hr == REGDB_E_CLASSNOTREG) {
// Handle case where the user has uninstalled Internet Explorer using Programs and Features.
OSVERSIONINFOEX *versionInfo = GetVersionInfo();
// Windows 8+: Directly prompt to reinstall IE using Fondue.exe.
SYSTEM_INFO systemInfo;
GetSystemInfo(&systemInfo);
LPWSTR archSuffix = systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ? L"amd64" : L"x86";
WCHAR fondueArgs[256];
StringCchPrintfW(fondueArgs, 256, L"/enable-feature:Internet-Explorer-Optional-%ls", archSuffix);
#pragma warning(disable: 4311 4302)
int execResult = (int)ShellExecute(NULL, L"open", L"fondue.exe", fondueArgs, NULL, SW_SHOWDEFAULT);
#pragma warning(default: 4311 4302)
if (execResult <= 32) {
// Tell the user what they need to do, then open the Optional Features dialog.
WCHAR message[4096];
LoadString(g_hInstance, IDS_IENOTINSTALLED, message, ARRAYSIZE(message));
MessageBox(hwnd, message, L"Legacy Update", MB_OK | MB_ICONEXCLAMATION);
ShellExecute(NULL, L"open", L"OptionalFeatures.exe", NULL, NULL, SW_SHOWDEFAULT);
}
hr = S_OK;
goto end;
} else if (!SUCCEEDED(hr)) {
goto end;
}
// Can we connect with https? WinInet will throw an error if not.
LPWSTR siteURL = CanUseSSLConnection() ? UpdateSiteURLHttps : UpdateSiteURLHttp;
// Is this a first run launch? Append first run flag if so.
if (strcmp(lpszCmdLine, "firstrun") == 0) {
WCHAR newSiteURL[256];
StringCchPrintfW(newSiteURL, 256, L"%s%s", siteURL, UpdateSiteFirstRunFlag);
siteURL = newSiteURL;
}
url = siteURL;
hr = browser->Navigate2(&url, &flags, &nullVariant, &nullVariant, &nullVariant);
if (!SUCCEEDED(hr)) {
goto end;
}
HWND ieHwnd;
hr = browser->get_HWND((SHANDLE_PTR *)&ieHwnd);
if (!SUCCEEDED(hr)) {
goto end;
}
// Are we on a small display? If so, resize and maximise the window.
HMONITOR monitor = MonitorFromWindow(ieHwnd, MONITOR_DEFAULTTONEAREST);
MONITORINFO monitorInfo;
monitorInfo.cbSize = sizeof(MONITORINFO);
if (GetMonitorInfo(monitor, &monitorInfo) > 0) {
LONG workWidth = monitorInfo.rcWork.right - monitorInfo.rcWork.left;
LONG workHeight = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top;
LONG width, height;
browser->get_Width(&width);
browser->get_Height(&height);
if (width < 800) {
width = min(800, workWidth);
browser->put_Width(width);
}
if (height < 600) {
height = min(600, workHeight);
browser->put_Height(height);
}
LONG left, top;
browser->get_Left(&left);
browser->get_Top(&top);
if (left + width > workWidth) {
browser->put_Left(0);
}
if (top + height > workHeight) {
browser->put_Top(0);
}
if (workWidth <= 1152) {
ShowWindow(ieHwnd, SW_MAXIMIZE);
}
}
browser->put_Visible(TRUE);
// Focus the window, since it seems to not always get focus as it should.
SetForegroundWindow(ieHwnd);
end:
if (!SUCCEEDED(hr)) {
MessageBox(NULL, GetMessageForHresult(hr), L"Legacy Update", MB_OK | MB_ICONEXCLAMATION);
}
browser = NULL;
CoUninitialize();
}

View File

@ -0,0 +1,3 @@
#pragma once
void CALLBACK LaunchUpdateSite(HWND hwnd, HINSTANCE hinstance, LPSTR lpszCmdLine, int nCmdShow);

View File

@ -0,0 +1,8 @@
; LegacyUpdate.def : Declares the module parameters.
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
LaunchUpdateSite PRIVATE

View File

@ -0,0 +1,123 @@
// LegacyUpdate.idl : IDL source for LegacyUpdate
//
// This file will be processed by the MIDL tool to
// produce the type library (LegacyUpdate.tlb) and marshalling code.
#include <olectl.h>
#include <idispids.h>
import "oaidl.idl";
import "ocidl.idl";
typedef enum {
e_majorVer = 0,
e_minorVer = 1,
e_buildNumber = 2,
e_platform = 3,
e_SPMajor = 4,
e_SPMinor = 5,
e_productSuite = 6,
e_productType = 7,
e_systemMetric = 8,
e_SPVersionString = 9,
e_controlVersionString = 10,
e_VistaProductType = 11,
e_productName = 12,
e_displayVersion = 13,
e_maxOSVersionFieldValue = 13
} OSVersionField;
typedef enum {
e_nonAdmin = 0,
e_admin = 2,
e_elevated = 3
} UserType;
[
object,
uuid(C33085BB-C3E1-4D27-A214-AF01953DF5E5),
dual,
nonextensible,
helpstring("ILegacyUpdateCtrl Interface"),
pointer_default(unique)
]
interface ILegacyUpdateCtrl : IDispatch {
[id(1)] HRESULT CheckControl([out, retval] VARIANT_BOOL *retval);
[id(2)] HRESULT MessageForHresult(LONG inHresult, [out, retval] BSTR *retval);
[id(3)] HRESULT GetOSVersionInfo(OSVersionField osField, LONG systemMetric, [out, retval] VARIANT *retval);
[id(14)] HRESULT RequestElevation(void);
[id(4)] HRESULT CreateObject(BSTR progID, [out, retval] IDispatch **retval);
[id(5)] HRESULT GetUserType([out, retval] UserType *retval);
[id(8)] HRESULT RebootIfRequired(void);
[id(9)] HRESULT ViewWindowsUpdateLog(void);
[id(13)] HRESULT OpenWindowsUpdateSettings(void);
[id(6), propget] HRESULT IsRebootRequired([out, retval] VARIANT_BOOL *retval);
[id(7), propget] HRESULT IsWindowsUpdateDisabled([out, retval] VARIANT_BOOL *retval);
[id(10), propget] HRESULT IsUsingWsusServer([out, retval] VARIANT_BOOL *retval);
[id(11), propget] HRESULT WsusServerUrl([out, retval] BSTR *retval);
[id(12), propget] HRESULT WsusStatusServerUrl([out, retval] BSTR *retval);
};
[
object,
uuid(4524BFBF-70BD-4EAC-AD33-6BADA4FB0638),
dual,
nonextensible,
pointer_default(unique)
]
interface IProgressBarControl : IDispatch
{
[id(1), propget] HRESULT Value([out, retval] SHORT *retval);
[id(1), propput] HRESULT Value([in] SHORT newVal);
};
[
object,
uuid(3236E684-0E4B-4780-9F31-F1983F5AB78D),
dual,
nonextensible,
pointer_default(unique),
oleautomation
]
interface IElevationHelper : IDispatch
{
[id(1)] HRESULT CreateObject(BSTR progID, [out, retval] IDispatch **retval);
};
[
uuid(05D22F33-C7C3-4C90-BDD9-CEDC86EA8FBE),
version(1.0),
helpstring("Legacy Update Control")
]
library LegacyUpdateLib {
importlib(STDOLE_TLB);
[
uuid(AD28E0DF-5F5A-40B5-9432-85EFD97D1F9F),
control,
helpstring("LegacyUpdateCtrl Class")
]
coclass LegacyUpdateCtrl {
[default] interface ILegacyUpdateCtrl;
};
[
uuid(7B875A2F-2DFB-4D38-91F5-5C0BFB74C377),
control,
helpstring("ProgressBarControl Class")
]
coclass ProgressBarControl
{
[default] interface IProgressBarControl;
};
[
uuid(84F517AD-6438-478F-BEA8-F0B808DC257F),
helpstring("ElevationHelper Class")
]
coclass ElevationHelper
{
[default] interface IElevationHelper;
};
};

View File

@ -0,0 +1,153 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(65001)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#ifndef APSTUDIO_INVOKED\r\n"
"#include ""targetver.h""\r\n"
"#endif\r\n"
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"1 TYPELIB ""LegacyUpdate.tlb""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,9,0,0
PRODUCTVERSION 1,9,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Hashbang Productions"
VALUE "FileDescription", "Legacy Update"
VALUE "FileVersion", "1.9.0.0"
VALUE "InternalName", "LegacyUpdate.dll"
VALUE "LegalCopyright", "© Hashbang Productions. All rights reserved."
VALUE "OriginalFilename", "LegacyUpdate.dll"
VALUE "ProductName", "Legacy Update"
VALUE "ProductVersion", "1.9.0.0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "icon.ico"
/////////////////////////////////////////////////////////////////////////////
//
// REGISTRY
//
IDR_LEGACYUPDATEOCX REGISTRY "LegacyUpdate.rgs"
IDR_LEGACYUPDATECTRL REGISTRY "LegacyUpdateCtrl.rgs"
IDR_PROGRESSBARCONTROL REGISTRY "ProgressBarControl.rgs"
IDR_ELEVATIONHELPER REGISTRY "ElevationHelper.rgs"
/////////////////////////////////////////////////////////////////////////////
//
// XML
//
IDR_CPLTASKS XML "CplTasks.xml"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_LEGACYUPDATEOCX "Legacy Update Control"
IDS_LEGACYUPDATE "Legacy Update"
IDS_CHECKFORUPDATES "Check for updates"
IDS_CHECKFORUPDATES_ALT "Check for software and driver updates via Legacy Update."
IDS_IENOTINSTALLED "Internet Explorer is not installed. Use Optional Features in Control Panel to install it before using Legacy Update."
END
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
1 TYPELIB "LegacyUpdate.tlb"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,14 @@
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'Legacy Update Control'
{
val DllSurrogate = s ''
}
'LegacyUpdate.dll'
{
val AppID = s '%APPID%'
}
}
}

View File

@ -0,0 +1,493 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug-VC08|x64">
<Configuration>Debug-VC08</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug-VC17|Win32">
<Configuration>Debug-VC17</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug-VC08|Win32">
<Configuration>Debug-VC08</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug-VC17|x64">
<Configuration>Debug-VC17</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{95F3E1A1-5DDA-4C4D-B52B-981D46E6C98B}</ProjectGuid>
<RootNamespace>LegacyUpdate</RootNamespace>
<Keyword>AtlProj</Keyword>
<WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v90</PlatformToolset>
<UseOfAtl>Dynamic</UseOfAtl>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v90</PlatformToolset>
<UseOfAtl>Dynamic</UseOfAtl>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v90</PlatformToolset>
<UseOfAtl>Static</UseOfAtl>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<UseOfAtl>Static</UseOfAtl>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">
<LinkIncremental>true</LinkIncremental>
<TargetExt>.dll</TargetExt>
<IncludePath>$(SolutionDir)\shared;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">
<LinkIncremental>true</LinkIncremental>
<TargetExt>.dll</TargetExt>
<IncludePath>$(SolutionDir)\shared;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">
<LinkIncremental>true</LinkIncremental>
<TargetExt>.dll</TargetExt>
<IncludePath>$(SolutionDir)\shared;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">
<LinkIncremental>true</LinkIncremental>
<TargetExt>.dll</TargetExt>
<IncludePath>$(SolutionDir)\shared;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetExt>.dll</TargetExt>
<IncludePath>$(SolutionDir)\shared;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetExt>.dll</TargetExt>
<IncludePath>$(SolutionDir)\shared;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;_MERGE_PROXYSTUB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<CompileAs />
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>.\LegacyUpdate.def</ModuleDefinitionFile>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
</Link>
<Midl>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>false</MkTypLibCompatible>
<TargetEnvironment>Win32</TargetEnvironment>
<GenerateStublessProxies>true</GenerateStublessProxies>
<TypeLibraryName>$(IntDir)LegacyUpdate.tlb</TypeLibraryName>
<HeaderFileName>LegacyUpdate_i.h</HeaderFileName>
<DllDataFileName>
</DllDataFileName>
<InterfaceIdentifierFileName>LegacyUpdate_i.c</InterfaceIdentifierFileName>
<ProxyFileName>LegacyUpdate_p.c</ProxyFileName>
<ValidateAllParameters>true</ValidateAllParameters>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>cmd /c start "" taskkill /im iexplore.exe</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;_MERGE_PROXYSTUB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<CompileAs />
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>.\LegacyUpdate.def</ModuleDefinitionFile>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
</Link>
<Midl>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>false</MkTypLibCompatible>
<GenerateStublessProxies>true</GenerateStublessProxies>
<TypeLibraryName>$(IntDir)LegacyUpdate.tlb</TypeLibraryName>
<HeaderFileName>LegacyUpdate_i.h</HeaderFileName>
<DllDataFileName>
</DllDataFileName>
<InterfaceIdentifierFileName>LegacyUpdate_i.c</InterfaceIdentifierFileName>
<ProxyFileName>LegacyUpdate_p.c</ProxyFileName>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>cmd /c start "" taskkill /im iexplore.exe</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;_MERGE_PROXYSTUB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<CompileAs />
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>.\LegacyUpdate.def</ModuleDefinitionFile>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
</Link>
<Midl>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>false</MkTypLibCompatible>
<TargetEnvironment>Win32</TargetEnvironment>
<GenerateStublessProxies>true</GenerateStublessProxies>
<TypeLibraryName>$(IntDir)LegacyUpdate.tlb</TypeLibraryName>
<HeaderFileName>LegacyUpdate_i.h</HeaderFileName>
<DllDataFileName>
</DllDataFileName>
<InterfaceIdentifierFileName>LegacyUpdate_i.c</InterfaceIdentifierFileName>
<ProxyFileName>LegacyUpdate_p.c</ProxyFileName>
<ValidateAllParameters>true</ValidateAllParameters>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>cmd /c start "" taskkill /im iexplore.exe</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;_MERGE_PROXYSTUB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<CompileAs />
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>.\LegacyUpdate.def</ModuleDefinitionFile>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
</Link>
<Midl>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>false</MkTypLibCompatible>
<GenerateStublessProxies>true</GenerateStublessProxies>
<TypeLibraryName>$(IntDir)LegacyUpdate.tlb</TypeLibraryName>
<HeaderFileName>LegacyUpdate_i.h</HeaderFileName>
<DllDataFileName>
</DllDataFileName>
<InterfaceIdentifierFileName>LegacyUpdate_i.c</InterfaceIdentifierFileName>
<ProxyFileName>LegacyUpdate_p.c</ProxyFileName>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>cmd /c start "" taskkill /im iexplore.exe</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;_MERGE_PROXYSTUB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<CompileAs />
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>.\LegacyUpdate.def</ModuleDefinitionFile>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
<AdditionalDependencies>
</AdditionalDependencies>
</Link>
<Midl>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>false</MkTypLibCompatible>
<TargetEnvironment>Win32</TargetEnvironment>
<GenerateStublessProxies>true</GenerateStublessProxies>
<TypeLibraryName>$(IntDir)LegacyUpdate.tlb</TypeLibraryName>
<HeaderFileName>LegacyUpdate_i.h</HeaderFileName>
<DllDataFileName>
</DllDataFileName>
<InterfaceIdentifierFileName>LegacyUpdate_i.c</InterfaceIdentifierFileName>
<ProxyFileName>LegacyUpdate_p.c</ProxyFileName>
<ValidateAllParameters>true</ValidateAllParameters>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PreBuildEvent>
<Command>cmd /c start "" taskkill /im iexplore.exe</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;_MERGE_PROXYSTUB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<CompileAs />
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>.\LegacyUpdate.def</ModuleDefinitionFile>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
<AdditionalDependencies>
</AdditionalDependencies>
</Link>
<Midl>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>false</MkTypLibCompatible>
<GenerateStublessProxies>true</GenerateStublessProxies>
<TypeLibraryName>$(IntDir)LegacyUpdate.tlb</TypeLibraryName>
<HeaderFileName>LegacyUpdate_i.h</HeaderFileName>
<DllDataFileName>
</DllDataFileName>
<InterfaceIdentifierFileName>LegacyUpdate_i.c</InterfaceIdentifierFileName>
<ProxyFileName>LegacyUpdate_p.c</ProxyFileName>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="CplTasks.xml" />
<None Include="ElevationHelper.rgs" />
<None Include="icon.ico" />
<None Include="LegacyUpdate.def" />
<None Include="LegacyUpdate.rgs" />
<None Include="LegacyUpdateCtrl.rgs" />
<None Include="ProgressBarControl.html">
<DeploymentContent>true</DeploymentContent>
</None>
<None Include="ProgressBarControl.rgs" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\shared\VersionInfo.cpp" />
<ClCompile Include="..\shared\WMI.cpp" />
<ClCompile Include="ElevationHelper.cpp" />
<ClCompile Include="LaunchUpdateSite.cpp" />
<ClCompile Include="LegacyUpdateCtrl.cpp" />
<ClCompile Include="Compat.cpp" />
<ClCompile Include="ProgressBarControl.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Utils.cpp" />
<ClCompile Include="dlldatax.c">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
</ClCompile>
<ClCompile Include="LegacyUpdate_i.c">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\shared\VersionInfo.h" />
<ClInclude Include="..\shared\WMI.h" />
<ClInclude Include="Compat.h" />
<ClInclude Include="ElevationHelper.h" />
<ClInclude Include="LaunchUpdateSite.h" />
<ClInclude Include="LegacyUpdateCtrl.h" />
<ClInclude Include="ProgressBarControl.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="Utils.h" />
<ClInclude Include="dlldatax.h" />
<ClInclude Include="dllmain.h" />
<ClInclude Include="LegacyUpdate_i.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="LegacyUpdate.rc" />
</ItemGroup>
<ItemGroup>
<Midl Include="LegacyUpdate.idl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties RESOURCE_FILE="LegacyUpdate.rc" />
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Shared">
<UniqueIdentifier>{7f88225c-35ff-498e-a402-49bc456952b5}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="LegacyUpdate.def">
<Filter>Source Files</Filter>
</None>
<None Include="icon.ico">
<Filter>Resource Files</Filter>
</None>
<None Include="LegacyUpdate.rgs">
<Filter>Resource Files</Filter>
</None>
<None Include="LegacyUpdateCtrl.rgs">
<Filter>Resource Files</Filter>
</None>
<None Include="ProgressBarControl.rgs">
<Filter>Resource Files</Filter>
</None>
<None Include="ProgressBarControl.html" />
<None Include="CplTasks.xml">
<Filter>Resource Files</Filter>
</None>
<None Include="ElevationHelper.rgs">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LegacyUpdateCtrl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LaunchUpdateSite.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Compat.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dlldatax.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LegacyUpdate_i.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ProgressBarControl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ElevationHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\shared\VersionInfo.cpp">
<Filter>Shared</Filter>
</ClCompile>
<ClCompile Include="..\shared\WMI.cpp">
<Filter>Shared</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="LegacyUpdateCtrl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="LaunchUpdateSite.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Compat.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="dlldatax.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="dllmain.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="LegacyUpdate_i.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ProgressBarControl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ElevationHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\shared\WMI.h">
<Filter>Shared</Filter>
</ClInclude>
<ClInclude Include="..\shared\VersionInfo.h">
<Filter>Shared</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="LegacyUpdate.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Midl Include="LegacyUpdate.idl">
<Filter>Source Files</Filter>
</Midl>
</ItemGroup>
</Project>

View File

@ -0,0 +1,435 @@
// LegacyUpdateCtrl.cpp : Implementation of the CLegacyUpdateCtrl ActiveX Control class.
#include "stdafx.h"
#include "LegacyUpdateCtrl.h"
#include "Utils.h"
#include "Compat.h"
#include "ElevationHelper.h"
#include <atlbase.h>
#include <atlcom.h>
#include <ShellAPI.h>
#include <ShlObj.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
const BSTR permittedHosts[] = {
L"legacyupdate.net",
L"test.legacyupdate.net",
NULL
};
const int permittedHostsMax = 2;
// CLegacyUpdateCtrl message handlers
IHTMLDocument2 *CLegacyUpdateCtrl::GetHTMLDocument() {
CComPtr<IOleClientSite> clientSite;
HRESULT hr = GetClientSite(&clientSite);
if (!SUCCEEDED(hr) || clientSite == NULL) {
TRACE("GetDocument() failed: %ls\n", GetMessageForHresult(hr));
return NULL;
}
CComPtr<IOleContainer> container;
hr = clientSite->GetContainer(&container);
if (!SUCCEEDED(hr) || container == NULL) {
TRACE("GetDocument() failed: %ls\n", GetMessageForHresult(hr));
return NULL;
}
CComPtr<IHTMLDocument2> document;
hr = container->QueryInterface(IID_IHTMLDocument2, (void**)&document);
if (!SUCCEEDED(hr) || document == NULL) {
TRACE("GetDocument() failed: %ls\n", GetMessageForHresult(hr));
return NULL;
}
return document.Detach();
}
HWND CLegacyUpdateCtrl::GetIEWindowHWND() {
CComPtr<IOleWindow> oleWindow;
HRESULT hr = QueryInterface(IID_IOleWindow, (void**)&oleWindow);
if (!SUCCEEDED(hr) || !oleWindow) {
goto end;
}
HWND hwnd;
hr = oleWindow->GetWindow(&hwnd);
if (!SUCCEEDED(hr)) {
goto end;
}
return hwnd;
end:
if (!SUCCEEDED(hr)) {
TRACE("GetIEWindowHWND() failed: %ls\n", GetMessageForHresult(hr));
}
return 0;
}
BOOL CLegacyUpdateCtrl::IsPermitted(void) {
CComPtr<IHTMLDocument2> document = GetHTMLDocument();
if (document == NULL) {
#ifdef _DEBUG
// Allow debugging outside of IE (e.g. via PowerShell)
TRACE("GetHTMLDocument() failed - allowing anyway due to debug build\n");
return TRUE;
#else
return FALSE;
#endif
}
CComPtr<IHTMLLocation> location;
CComBSTR host;
HRESULT hr = document->get_location(&location);
if (!SUCCEEDED(hr) || location == NULL) {
goto end;
}
hr = location->get_host(&host);
if (!SUCCEEDED(hr)) {
goto end;
}
for (int i = 0; i < permittedHostsMax; i++) {
if (wcscmp(host, permittedHosts[i]) == 0) {
return TRUE;
}
}
end:
if (!SUCCEEDED(hr)) {
TRACE("IsPermitted() failed: %ls\n", GetMessageForHresult(hr));
}
return FALSE;
}
#define DoIsPermittedCheck() \
if (!IsPermitted()) { \
return E_ACCESSDENIED; \
}
STDMETHODIMP CLegacyUpdateCtrl::CheckControl(VARIANT_BOOL *retval) {
DoIsPermittedCheck();
// Just return true so the site can confirm the control is working.
*retval = TRUE;
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::MessageForHresult(LONG inHresult, BSTR *retval) {
DoIsPermittedCheck();
*retval = GetMessageForHresult(inHresult);
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::GetOSVersionInfo(OSVersionField osField, LONG systemMetric, VARIANT *retval) {
DoIsPermittedCheck();
VariantInit(retval);
retval->vt = VT_I4;
OSVERSIONINFOEX *versionInfo = GetVersionInfo();
switch (osField) {
case e_majorVer:
retval->lVal = versionInfo->dwMajorVersion;
break;
case e_minorVer:
retval->lVal = versionInfo->dwMinorVersion;
break;
case e_buildNumber:
retval->lVal = versionInfo->dwBuildNumber;
break;
case e_platform:
retval->lVal = versionInfo->dwPlatformId;
break;
case e_SPMajor:
retval->lVal = versionInfo->wServicePackMajor;
break;
case e_SPMinor:
retval->lVal = versionInfo->wServicePackMinor;
break;
case e_productSuite:
retval->lVal = versionInfo->wSuiteMask;
break;
case e_productType:
retval->lVal = versionInfo->wProductType;
break;
case e_systemMetric:
retval->lVal = GetSystemMetrics(systemMetric);
break;
case e_SPVersionString: {
LPWSTR data;
DWORD size;
HRESULT hr = GetRegistryString(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", L"BuildLab", NULL, &data, &size);
if (SUCCEEDED(hr)) {
retval->vt = VT_BSTR;
retval->bstrVal = SysAllocStringLen(data, size - 1);
} else {
// BuildLab doesn't exist on Windows 2000.
retval->vt = VT_BSTR;
retval->bstrVal = SysAllocString(versionInfo->szCSDVersion);
}
break;
}
case e_controlVersionString: {
LPWSTR data;
DWORD size;
HRESULT hr = GetOwnVersion(&data, &size);
if (!SUCCEEDED(hr)) {
return hr;
}
retval->vt = VT_BSTR;
retval->bstrVal = SysAllocStringLen(data, size - 1);
break;
}
case e_VistaProductType: {
DWORD productType;
GetVistaProductInfo(versionInfo->dwMajorVersion, versionInfo->dwMinorVersion, versionInfo->wServicePackMajor, versionInfo->wServicePackMinor, &productType);
retval->vt = VT_UI4;
retval->ulVal = productType;
break;
}
case e_productName: {
HRESULT hr = GetOSProductName(retval);
if (!SUCCEEDED(hr)) {
LPWSTR data;
DWORD size;
hr = GetRegistryString(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", L"ProductName", NULL, &data, &size);
if (SUCCEEDED(hr)) {
retval->vt = VT_BSTR;
retval->bstrVal = SysAllocStringLen(data, size - 1);
} else {
VariantClear(retval);
}
}
break;
}
case e_displayVersion: {
LPWSTR data;
DWORD size;
HRESULT hr = GetRegistryString(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", L"DisplayVersion", NULL, &data, &size);
if (SUCCEEDED(hr)) {
retval->vt = VT_BSTR;
retval->bstrVal = SysAllocStringLen(data, size - 1);
} else {
VariantClear(retval);
}
break;
}
}
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::RequestElevation() {
DoIsPermittedCheck();
if (m_elevatedHelper != NULL || GetVersionInfo()->dwMajorVersion < 6) {
return S_OK;
}
// https://learn.microsoft.com/en-us/windows/win32/com/the-com-elevation-moniker
HRESULT hr = CoCreateInstanceAsAdmin(GetIEWindowHWND(), CLSID_ElevationHelper, IID_IElevationHelper, (void**)&m_elevatedHelper);
if (!SUCCEEDED(hr)) {
TRACE("RequestElevation() failed: %ls\n", GetMessageForHresult(hr));
}
return hr;
}
STDMETHODIMP CLegacyUpdateCtrl::CreateObject(BSTR progID, IDispatch **retval) {
DoIsPermittedCheck();
HRESULT hr = S_OK;
CComPtr<IElevationHelper> elevatedHelper;
if (progID == NULL) {
hr = E_INVALIDARG;
goto end;
}
if (!ProgIDIsPermitted(progID)) {
hr = E_ACCESSDENIED;
goto end;
}
elevatedHelper = m_elevatedHelper ? m_elevatedHelper : m_nonElevatedHelper;
if (elevatedHelper == NULL) {
// Use the helper directly, without elevation. It's the responsibility of the caller to ensure it
// is already running as admin on 2k/XP, or that it has requested elevation on Vista+.
m_nonElevatedHelper.CoCreateInstance(CLSID_ElevationHelper, NULL, CLSCTX_INPROC_SERVER);
if (!SUCCEEDED(hr)) {
goto end;
}
elevatedHelper = m_nonElevatedHelper;
}
return elevatedHelper->CreateObject(progID, retval);
end:
if (!SUCCEEDED(hr)) {
TRACE("CreateObject(%ls) failed: %ls\n", progID, GetMessageForHresult(hr));
}
return hr;
}
STDMETHODIMP CLegacyUpdateCtrl::GetUserType(UserType *retval) {
DoIsPermittedCheck();
if (IsUserAnAdmin()) {
// Entire process is elevated.
*retval = e_admin;
} else if (m_elevatedHelper != NULL) {
// Our control has successfully received elevation.
*retval = e_elevated;
} else {
// The control has no admin rights (although it may not have requested them yet).
*retval = e_nonAdmin;
}
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::get_IsRebootRequired(VARIANT_BOOL *retval) {
DoIsPermittedCheck();
HKEY subkey;
HRESULT hr = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update\\RebootRequired", 0, KEY_READ, &subkey);
*retval = subkey != NULL;
if (subkey != NULL) {
RegCloseKey(subkey);
}
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::get_IsWindowsUpdateDisabled(VARIANT_BOOL *retval) {
DoIsPermittedCheck();
DWORD noWU;
HRESULT hr = GetRegistryDword(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", L"NoWindowsUpdate", NULL, &noWU);
if (SUCCEEDED(hr) && noWU == 1) {
*retval = TRUE;
return S_OK;
}
DWORD disableWUAccess;
hr = GetRegistryDword(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\WindowsUpdate", L"DisableWindowsUpdateAccess", NULL, &disableWUAccess);
if (SUCCEEDED(hr) && disableWUAccess == 1) {
*retval = TRUE;
return S_OK;
}
*retval = FALSE;
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::RebootIfRequired(void) {
DoIsPermittedCheck();
VARIANT_BOOL isRebootRequired;
if (SUCCEEDED(get_IsRebootRequired(&isRebootRequired)) && isRebootRequired) {
Reboot();
}
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::ViewWindowsUpdateLog(void) {
DoIsPermittedCheck();
WCHAR windir[MAX_PATH];
HRESULT hr = SHGetFolderPath(0, CSIDL_WINDOWS, NULL, 0, windir);
if (!SUCCEEDED(hr)) {
TRACE(L"SHGetFolderPath() failed: %ls\n", GetMessageForHresult(hr));
return hr;
}
// Try Windows Server 2003 Resource Kit (or MSYS/Cygwin/etc) tail.exe, falling back to directly
// opening the file (most likely in Notepad).
// Ignore C4311 and C4302, which is for typecasts. It is due to ShellExec and should be safe to bypass.
#pragma warning(disable: 4311 4302)
if ((int)ShellExecute(NULL, L"open", L"tail.exe", L"-f WindowsUpdate.log", windir, SW_SHOWDEFAULT) > 32) {
return S_OK;
}
ShellExecute(NULL, L"open", L"WindowsUpdate.log", NULL, windir, SW_SHOWDEFAULT);
#pragma warning(default: 4311 4302)
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::OpenWindowsUpdateSettings(void) {
DoIsPermittedCheck();
// Some issues arise from the working directory being SysWOW64 rather than System32. Notably,
// Windows Vista - 8.1 don't have wuauclt.exe in SysWOW64. Disable WOW64 redirection temporarily
// to work around this.
PVOID oldValue;
BOOL isRedirected = DisableWow64FsRedirection(&oldValue);
WCHAR systemDir[MAX_PATH];
HRESULT hr = SHGetFolderPath(0, CSIDL_SYSTEM, NULL, 0, systemDir);
if (!SUCCEEDED(hr)) {
TRACE(L"SHGetFolderPath() failed: %ls\n", GetMessageForHresult(hr));
return hr;
}
DWORD majorVersion = GetVersionInfo()->dwMajorVersion;
if (majorVersion >= 10) {
// Windows 10+: Open Settings app
ShellExecute(NULL, NULL, L"ms-settings:windowsupdate-options", NULL, systemDir, SW_SHOWDEFAULT);
} else if (majorVersion >= 6) {
// Windows Vista, 7, 8: Open Windows Update control panel
ShellExecute(NULL, NULL, L"wuauclt.exe", L"/ShowOptions", systemDir, SW_SHOWDEFAULT);
} else {
// Windows 2000, XP: Open Automatic Updates control panel
ShellExecute(NULL, NULL, L"wuaucpl.cpl", NULL, systemDir, SW_SHOWDEFAULT);
}
// Revert WOW64 redirection if we changed it.
if (isRedirected) {
RevertWow64FsRedirection(oldValue);
}
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::get_IsUsingWsusServer(VARIANT_BOOL *retval) {
DoIsPermittedCheck();
DWORD useWUServer;
HRESULT hr = GetRegistryDword(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Policies\\Microsoft\\Windows\\WindowsUpdate\\AU", L"UseWUServer", NULL, &useWUServer);
*retval = SUCCEEDED(hr) && useWUServer == 1;
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::get_WsusServerUrl(BSTR *retval) {
DoIsPermittedCheck();
LPWSTR data;
DWORD size;
HRESULT hr = GetRegistryString(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Policies\\Microsoft\\Windows\\WindowsUpdate", L"WUServer", NULL, &data, &size);
*retval = SUCCEEDED(hr) ? SysAllocStringLen(data, size - 1) : NULL;
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::get_WsusStatusServerUrl(BSTR *retval) {
DoIsPermittedCheck();
LPWSTR data;
DWORD size;
HRESULT hr = GetRegistryString(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Policies\\Microsoft\\Windows\\WindowsUpdate", L"WUStatusServer", NULL, &data, &size);
*retval = SUCCEEDED(hr) ? SysAllocStringLen(data, size - 1) : NULL;
return S_OK;
}

View File

@ -0,0 +1,114 @@
#pragma once
// LegacyUpdateCtrl.h : Declaration of the CLegacyUpdateCtrl ActiveX Control class.
// CLegacyUpdateCtrl : See LegacyUpdateCtrl.cpp for implementation.
#include <atlctl.h>
#include <MsHTML.h>
#include "resource.h"
#include "LegacyUpdate_i.h"
// CLegacyUpdateCtrl
class ATL_NO_VTABLE CLegacyUpdateCtrl :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<ILegacyUpdateCtrl, &IID_ILegacyUpdateCtrl, &LIBID_LegacyUpdateLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
public IPersistStreamInitImpl<CLegacyUpdateCtrl>,
public IOleControlImpl<CLegacyUpdateCtrl>,
public IOleObjectImpl<CLegacyUpdateCtrl>,
public IOleInPlaceActiveObjectImpl<CLegacyUpdateCtrl>,
public IViewObjectExImpl<CLegacyUpdateCtrl>,
public IOleInPlaceObjectWindowlessImpl<CLegacyUpdateCtrl>,
public ISupportErrorInfo,
public IObjectWithSiteImpl<CLegacyUpdateCtrl>,
public IPersistStorageImpl<CLegacyUpdateCtrl>,
public IQuickActivateImpl<CLegacyUpdateCtrl>,
public IProvideClassInfo2Impl<&CLSID_LegacyUpdateCtrl, NULL, &LIBID_LegacyUpdateLib>,
public CComCoClass<CLegacyUpdateCtrl, &CLSID_LegacyUpdateCtrl>,
public CComControl<CLegacyUpdateCtrl> {
private:
CComPtr<IElevationHelper> m_elevatedHelper;
CComPtr<IElevationHelper> m_nonElevatedHelper;
public:
CLegacyUpdateCtrl() {
m_bWindowOnly = TRUE;
}
DECLARE_OLEMISC_STATUS(
OLEMISC_INVISIBLEATRUNTIME |
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST |
OLEMISC_INSIDEOUT |
OLEMISC_CANTLINKINSIDE |
OLEMISC_RECOMPOSEONRESIZE
)
DECLARE_REGISTRY_RESOURCEID(IDR_LEGACYUPDATECTRL)
BEGIN_COM_MAP(CLegacyUpdateCtrl)
COM_INTERFACE_ENTRY(ILegacyUpdateCtrl)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IViewObjectEx)
COM_INTERFACE_ENTRY(IViewObject2)
COM_INTERFACE_ENTRY(IViewObject)
COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceObject)
COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
COM_INTERFACE_ENTRY(IOleControl)
COM_INTERFACE_ENTRY(IOleObject)
COM_INTERFACE_ENTRY(IPersistStreamInit)
COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IQuickActivate)
COM_INTERFACE_ENTRY(IPersistStorage)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
END_COM_MAP()
BEGIN_PROP_MAP(CLegacyUpdateCtrl)
END_PROP_MAP()
BEGIN_MSG_MAP(CLegacyUpdateCtrl)
CHAIN_MSG_MAP(CComControl<CLegacyUpdateCtrl>)
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP()
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid) {
return IsEqualGUID(riid, IID_ILegacyUpdateCtrl) ? S_OK : S_FALSE;
}
// IViewObjectEx
DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
// ILegacyUpdateCtrl
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct() { return S_OK; }
void FinalRelease() {}
private:
IHTMLDocument2 *GetHTMLDocument();
HWND GetIEWindowHWND();
BOOL IsPermitted();
public:
STDMETHODIMP CheckControl(VARIANT_BOOL *retval);
STDMETHODIMP MessageForHresult(LONG inHresult, BSTR *retval);
STDMETHODIMP GetOSVersionInfo(OSVersionField osField, LONG systemMetric, VARIANT *retval);
STDMETHODIMP RequestElevation();
STDMETHODIMP CreateObject(BSTR progID, IDispatch **retval);
STDMETHODIMP GetUserType(UserType *retval);
STDMETHODIMP get_IsRebootRequired(VARIANT_BOOL *retval);
STDMETHODIMP get_IsWindowsUpdateDisabled(VARIANT_BOOL *retval);
STDMETHODIMP RebootIfRequired(void);
STDMETHODIMP ViewWindowsUpdateLog(void);
STDMETHODIMP OpenWindowsUpdateSettings(void);
STDMETHODIMP get_IsUsingWsusServer(VARIANT_BOOL *retval);
STDMETHODIMP get_WsusServerUrl(BSTR *retval);
STDMETHODIMP get_WsusStatusServerUrl(BSTR *retval);
};
OBJECT_ENTRY_AUTO(__uuidof(LegacyUpdateCtrl), CLegacyUpdateCtrl)

View File

@ -0,0 +1,37 @@
HKCR
{
LegacyUpdate.Control.1 = s 'LegacyUpdateCtrl Class'
{
CLSID = s '{AD28E0DF-5F5A-40B5-9432-85EFD97D1F9F}'
}
LegacyUpdate.Control = s 'LegacyUpdateCtrl Class'
{
CurVer = s 'LegacyUpdate.Control.1'
}
NoRemove CLSID
{
ForceRemove {AD28E0DF-5F5A-40B5-9432-85EFD97D1F9F} = s 'Legacy Update Control'
{
ProgID = s 'LegacyUpdate.Control.1'
VersionIndependentProgID = s 'LegacyUpdate.Control'
ForceRemove 'Programmable'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
val AppID = s '%APPID%'
ForceRemove 'Control'
'MiscStatus' = s '0'
{
'1' = s '%OLEMISC%'
}
'TypeLib' = s '{05D22F33-C7C3-4C90-BDD9-CEDC86EA8FBE}'
'Version' = s '1.0'
'Implemented Categories'
{
'{7DD95801-9882-11CF-9FA9-00AA006C42C4}'
'{7DD95802-9882-11CF-9FA9-00AA006C42C4}'
}
}
}
}

17
LegacyUpdate/Makefile Normal file
View File

@ -0,0 +1,17 @@
ifeq ($(CI),1)
MSBUILDFLAGS += /p:PlatformToolset=v141_xp
endif
all:
cmd.exe /c build.cmd $(MSBUILDFLAGS)
ifeq ($(SIGN),1)
../build/sign.sh \
../Release/LegacyUpdate.dll \
../x64/Release/LegacyUpdate.dll
endif
clean:
@# Not needed, build.cmd cleans before it builds
.PHONY: all clean

View File

@ -0,0 +1,65 @@
// ProgressBarControl.cpp : Implementation of CProgressBarControl
#include "stdafx.h"
#include "ProgressBarControl.h"
#include <CommCtrl.h>
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#ifndef PBS_MARQUEE
#define PBS_MARQUEE 0x08
#endif
#ifndef PBM_SETMARQUEE
#define PBM_SETMARQUEE (WM_USER + 10)
#endif
LRESULT CProgressBarControl::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) {
RECT rc;
GetWindowRect(&rc);
rc.right -= rc.left;
rc.bottom -= rc.top;
rc.left = 0;
rc.top = 0;
m_ctl.Create(m_hWnd, rc, PROGRESS_CLASS, WS_CHILD | WS_VISIBLE, WS_EX_CLIENTEDGE);
put_Value(-1);
return 0;
}
STDMETHODIMP CProgressBarControl::SetObjectRects(LPCRECT prcPos, LPCRECT prcClip) {
IOleInPlaceObjectWindowlessImpl<CProgressBarControl>::SetObjectRects(prcPos, prcClip);
::SetWindowPos(m_ctl.m_hWnd, NULL, 0, 0,
prcPos->right - prcPos->left,
prcPos->bottom - prcPos->top,
SWP_NOZORDER | SWP_NOACTIVATE);
return S_OK;
}
STDMETHODIMP CProgressBarControl::get_Value(SHORT *pValue) {
if (m_ctl.GetWindowLongPtr(GWL_STYLE) & PBS_MARQUEE) {
// Marquee - no value
*pValue = -1;
} else {
// Normal - return PBM_GETPOS
*pValue = (SHORT)m_ctl.SendMessage(PBM_GETPOS, 0, 0);
}
return S_OK;
}
STDMETHODIMP CProgressBarControl::put_Value(SHORT value) {
if (value == -1) {
// Marquee style
m_ctl.SetWindowLongPtr(GWL_STYLE, m_ctl.GetWindowLongPtr(GWL_STYLE) | PBS_MARQUEE);
m_ctl.SendMessage(PBM_SETMARQUEE, TRUE, 100);
} else {
// Normal style
SHORT oldValue;
get_Value(&oldValue);
if (oldValue == -1) {
m_ctl.SetWindowLongPtr(GWL_STYLE, m_ctl.GetWindowLongPtr(GWL_STYLE) & ~PBS_MARQUEE);
m_ctl.SendMessage(PBM_SETRANGE, 0, MAKELPARAM(0, 100));
}
m_ctl.SendMessage(PBM_SETPOS, value, 0);
}
return S_OK;
}

View File

@ -0,0 +1,77 @@
#pragma once
// ProgressBarControl.h : Declaration of the CProgressBarControl class.
#include <atlctl.h>
#include "resource.h"
#include "LegacyUpdate_i.h"
// CProgressBarControl
class ATL_NO_VTABLE CProgressBarControl :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<IProgressBarControl, &IID_IProgressBarControl, &LIBID_LegacyUpdateLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
public IOleControlImpl<CProgressBarControl>,
public IOleObjectImpl<CProgressBarControl>,
public IOleInPlaceActiveObjectImpl<CProgressBarControl>,
public IViewObjectExImpl<CProgressBarControl>,
public IOleInPlaceObjectWindowlessImpl<CProgressBarControl>,
public CComCoClass<CProgressBarControl, &CLSID_ProgressBarControl>,
public CComControl<CProgressBarControl>
{
public:
CContainedWindow m_ctl;
CProgressBarControl() : m_ctl(L"msctls_progress32", this, 1) {
m_bWindowOnly = TRUE;
}
DECLARE_OLEMISC_STATUS(
OLEMISC_RECOMPOSEONRESIZE |
OLEMISC_CANTLINKINSIDE |
OLEMISC_INSIDEOUT |
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST
)
DECLARE_REGISTRY_RESOURCEID(IDR_PROGRESSBARCONTROL)
BEGIN_COM_MAP(CProgressBarControl)
COM_INTERFACE_ENTRY(IProgressBarControl)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IViewObjectEx)
COM_INTERFACE_ENTRY(IViewObject2)
COM_INTERFACE_ENTRY(IViewObject)
COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceObject)
COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
COM_INTERFACE_ENTRY(IOleControl)
COM_INTERFACE_ENTRY(IOleObject)
END_COM_MAP()
BEGIN_PROP_MAP(CProgressBarControl)
END_PROP_MAP()
BEGIN_MSG_MAP(CProgressBarControl)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
CHAIN_MSG_MAP(CComControl<CProgressBarControl>)
ALT_MSG_MAP(1)
END_MSG_MAP()
// IViewObjectEx
DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
// IProgressBarControl
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct() { return S_OK; }
void FinalRelease() {}
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
STDMETHODIMP SetObjectRects(LPCRECT prcPos, LPCRECT prcClip);
STDMETHODIMP get_Value(SHORT *pValue);
STDMETHODIMP put_Value(SHORT value);
};
OBJECT_ENTRY_AUTO(__uuidof(ProgressBarControl), CProgressBarControl)

View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<title>ATL test page for object ProgressBarControl</title>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="MSThemeCompatible" content="yes">
</head>
<body>
<div style="border: 1px solid;">
<object id="ProgressBarControl" classid="CLSID:7b875a2f-2dfb-4d38-91f5-5c0bfb74c377" width="208" height="14"></object>
</div>
<div id="Value">-1</div>
<button onclick="marquee()">Marquee</button>
<button onclick="normal()">Normal</button>
<button onclick="zero()">Zero</button>
<script>
var timer = -1;
function marquee() {
if (timer !== -1) {
clearInterval(timer);
}
ProgressBarControl.Value = -1;
Value.innerText = "-1";
}
function normal() {
if (timer !== -1) {
clearInterval(timer);
}
timer = setInterval(function() {
var value = ProgressBarControl.Value;
Value.innerText = value;
ProgressBarControl.Value = value === 100 ? 0 : value + 1;
}, 100);
}
function zero() {
ProgressBarControl.Value = 0;
}
</script>
</body>
</html>

View File

@ -0,0 +1,34 @@
HKCR
{
LegacyUpdate.ProgressBar.1 = s 'ProgressBarControl Class'
{
CLSID = s '{7B875A2F-2DFB-4D38-91F5-5C0BFB74C377}'
}
LegacyUpdate.ProgressBar = s 'ProgressBarControl Class'
{
CurVer = s 'LegacyUpdate.ProgressBar.1'
}
NoRemove CLSID
{
ForceRemove {7B875A2F-2DFB-4D38-91F5-5C0BFB74C377} = s 'Legacy Update Progress Bar Control'
{
ForceRemove Programmable
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
ForceRemove Control
MiscStatus = s '0'
{
'1' = s '%OLEMISC%'
}
TypeLib = s '{05D22F33-C7C3-4C90-BDD9-CEDC86EA8FBE}'
Version = s '1.0'
'Implemented Categories'
{
'{7DD95801-9882-11CF-9FA9-00AA006C42C4}'
'{7DD95802-9882-11CF-9FA9-00AA006C42C4}'
}
}
}
}

26
LegacyUpdate/Resource.h Normal file
View File

@ -0,0 +1,26 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by LegacyUpdate.rc
//
#define IDS_LEGACYUPDATEOCX 1
#define IDS_LEGACYUPDATE 2
#define IDS_CHECKFORUPDATES 3
#define IDS_CHECKFORUPDATES_ALT 4
#define IDS_IENOTINSTALLED 5
#define IDR_LEGACYUPDATEOCX 101
#define IDR_LEGACYUPDATECTRL 102
#define IDR_PROGRESSBARCONTROL 103
#define IDR_ELEVATIONHELPER 104
#define IDI_ICON1 201
#define IDR_CPLTASKS 202
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 204
#define _APS_NEXT_COMMAND_VALUE 32768
#define _APS_NEXT_CONTROL_VALUE 201
#define _APS_NEXT_SYMED_VALUE 105
#endif
#endif

177
LegacyUpdate/Utils.cpp Normal file
View File

@ -0,0 +1,177 @@
#include "stdafx.h"
#include <comdef.h>
#include <atlstr.h>
#include "WMI.h"
#pragma comment(lib, "version.lib")
#pragma comment(lib, "advapi32.lib")
// Defined as being Vista+, older versions ignore the flag.
#ifndef EWX_RESTARTAPPS
#define EWX_RESTARTAPPS 0x00000040
#endif
extern "C" IMAGE_DOS_HEADER __ImageBase;
#define OwnModule ((HMODULE)&__ImageBase)
static BOOL _loadedProductName = FALSE;
static CComVariant _productName;
static BOOL _loadedOwnVersion = FALSE;
static LPWSTR _version;
static UINT _versionSize;
void GetOwnFileName(LPWSTR *filename, LPDWORD size) {
*filename = (LPWSTR)malloc(MAX_PATH);
*size = GetModuleFileName(OwnModule, *filename, MAX_PATH);
}
HRESULT GetOwnVersion(LPWSTR *version, LPDWORD size) {
if (!_loadedOwnVersion) {
LPWSTR filename;
DWORD filenameSize;
GetOwnFileName(&filename, &filenameSize);
DWORD verHandle;
DWORD verInfoSize = GetFileVersionInfoSize(filename, &verHandle);
if (verInfoSize == 0) {
return AtlHresultFromLastError();
}
LPVOID verInfo = new BYTE[verInfoSize];
if (!GetFileVersionInfo(filename, verHandle, verInfoSize, verInfo)) {
return AtlHresultFromLastError();
}
if (!VerQueryValue(verInfo, L"\\StringFileInfo\\040904B0\\ProductVersion", (LPVOID *)&_version, &_versionSize)) {
return AtlHresultFromLastError();
}
}
*version = _version;
*size = _versionSize;
return _version == NULL ? E_FAIL : NOERROR;
}
HRESULT GetRegistryString(HKEY key, LPCWSTR subkeyPath, LPCWSTR valueName, LPDWORD type, LPWSTR *data, LPDWORD size) {
HKEY subkey;
HRESULT hr = HRESULT_FROM_WIN32(RegOpenKeyEx(key, subkeyPath, 0, KEY_READ, &subkey));
if (!SUCCEEDED(hr)) {
goto end;
}
if (data != NULL && size != NULL) {
DWORD length = 512 * sizeof(WCHAR);
LPWSTR buffer = (LPWSTR)malloc(length);
LSTATUS status;
do {
status = RegQueryValueEx(subkey, valueName, NULL, type, (BYTE *)buffer, &length);
if (status == ERROR_MORE_DATA) {
length += 256 * sizeof(WCHAR);
buffer = (LPWSTR)realloc(buffer, length);
} else if (status != ERROR_SUCCESS) {
hr = HRESULT_FROM_WIN32(status);
goto end;
}
} while (status == ERROR_MORE_DATA);
*data = buffer;
*size = length / sizeof(WCHAR);
}
end:
if (subkey != NULL) {
RegCloseKey(subkey);
}
if (!SUCCEEDED(hr)) {
if (data != NULL) {
*data = NULL;
}
if (size != NULL) {
*size = 0;
}
}
return hr;
}
HRESULT GetRegistryDword(HKEY key, LPCWSTR subkeyPath, LPCWSTR valueName, LPDWORD type, LPDWORD data) {
HKEY subkey;
HRESULT hr = HRESULT_FROM_WIN32(RegOpenKeyEx(key, subkeyPath, 0, KEY_READ, &subkey));
if (!SUCCEEDED(hr)) {
goto end;
}
if (data != NULL) {
DWORD length = sizeof(DWORD);
hr = HRESULT_FROM_WIN32(RegQueryValueEx(subkey, valueName, NULL, type, (LPBYTE)data, &length));
if (!SUCCEEDED(hr)) {
goto end;
}
}
end:
if (subkey != NULL) {
RegCloseKey(subkey);
}
return hr;
}
LPWSTR GetMessageForHresult(HRESULT hr) {
_com_error *error = new _com_error(hr);
CString message = error->ErrorMessage();
BSTR outMessage = message.AllocSysString();
return outMessage;
}
HRESULT GetOSProductName(VARIANT *pProductName) {
if (_loadedProductName) {
VariantCopy(pProductName, &_productName);
return S_OK;
}
VariantInit(&_productName);
_loadedProductName = true;
return QueryWMIProperty(L"SELECT Caption FROM Win32_OperatingSystem", L"Caption", &_productName);
}
HRESULT Reboot() {
HRESULT hr = E_FAIL;
// Make sure we have permission to shut down.
HANDLE token;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) {
LUID shutdownLuid;
if (LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &shutdownLuid) != 0) {
// Ask the system nicely to give us shutdown privilege.
TOKEN_PRIVILEGES privileges;
privileges.PrivilegeCount = 1;
privileges.Privileges[0].Luid = shutdownLuid;
privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(token, FALSE, &privileges, 0, NULL, NULL)) {
hr = AtlHresultFromLastError();
TRACE("AdjustTokenPrivileges() failed: %ls\n", GetMessageForHresult(hr));
}
}
} else {
hr = AtlHresultFromLastError();
TRACE("OpenProcessToken() failed: %ls\n", GetMessageForHresult(hr));
}
// Reboot with reason "Operating System: Security fix (Unplanned)"
if (!InitiateSystemShutdownEx(NULL, NULL, 0, FALSE, TRUE, SHTDN_REASON_MAJOR_OPERATINGSYSTEM | SHTDN_REASON_MINOR_SECURITYFIX)) {
hr = AtlHresultFromLastError();
TRACE("InitiateSystemShutdownExW() failed: %ls\n", GetMessageForHresult(hr));
// Try ExitWindowsEx instead
// Win2k: Use ExitWindowsEx, which is only guaranteed to work for the current logged in user
if (!ExitWindowsEx(EWX_REBOOT | EWX_RESTARTAPPS | EWX_FORCEIFHUNG, SHTDN_REASON_MAJOR_OPERATINGSYSTEM | SHTDN_REASON_MINOR_SECURITYFIX)) {
hr = AtlHresultFromLastError();
TRACE("ExitWindowsEx() failed: %ls\n", GetMessageForHresult(hr));
}
} else {
hr = S_OK;
}
return hr;
}

15
LegacyUpdate/Utils.h Normal file
View File

@ -0,0 +1,15 @@
#pragma once
OSVERSIONINFOEX *GetVersionInfo();
void GetOwnFileName(LPWSTR *filename, LPDWORD size);
HRESULT GetOwnVersion(LPWSTR *version, LPDWORD size);
HRESULT GetRegistryString(HKEY key, LPCWSTR subkeyPath, LPCWSTR valueName, LPDWORD type, LPWSTR *data, LPDWORD size);
HRESULT GetRegistryDword(HKEY key, LPCWSTR subkeyPath, LPCWSTR valueName, LPDWORD type, LPDWORD data);
LPWSTR GetMessageForHresult(HRESULT hresult);
HRESULT GetOSProductName(VARIANT* pProductName);
HRESULT Reboot();

17
LegacyUpdate/build.cmd Normal file
View File

@ -0,0 +1,17 @@
@echo off
setlocal enabledelayedexpansion
cd %~dp0\..
:: Clean
call build\getvc.cmd x86
msbuild LegacyUpdate.sln /v:quiet /m /p:Configuration=Release /p:Platform=Win32 /t:clean
if "%errorlevel%" neq "0" exit /b %errorlevel%
msbuild LegacyUpdate.sln /v:quiet /m /p:Configuration=Release /p:Platform=x64 /t:clean
if "%errorlevel%" neq "0" exit /b %errorlevel%
:: Build DLL
msbuild LegacyUpdate.sln /v:minimal /m /p:Configuration=Release /p:Platform=Win32 %*
if "%errorlevel%" neq "0" exit /b %errorlevel%
call build\getvc.cmd x64
msbuild LegacyUpdate.sln /v:minimal /m /p:Configuration=Release /p:Platform=x64 %*
if "%errorlevel%" neq "0" exit /b %errorlevel%

38
LegacyUpdate/dlldata.c Normal file
View File

@ -0,0 +1,38 @@
/*********************************************************
DllData file -- generated by MIDL compiler
DO NOT ALTER THIS FILE
This file is regenerated by MIDL on every IDL file compile.
To completely reconstruct this file, delete it and rerun MIDL
on all the IDL files in this DLL, specifying this file for the
/dlldata command line option
*********************************************************/
#define PROXY_DELEGATION
#include <rpcproxy.h>
#ifdef __cplusplus
extern "C" {
#endif
EXTERN_PROXY_FILE( LegacyUpdate )
PROXYFILE_LIST_START
/* Start of list */
REFERENCE_PROXY_FILE( LegacyUpdate ),
/* End of list */
PROXYFILE_LIST_END
DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )
#ifdef __cplusplus
} /*extern "C" */
#endif
/* end of generated dlldata file */

18
LegacyUpdate/dlldatax.c Normal file
View File

@ -0,0 +1,18 @@
// wrapper for dlldata.c
#ifdef _MERGE_PROXYSTUB // merge proxy stub DLL
#define REGISTER_PROXY_DLL //DllRegisterServer, etc.
#define _WIN32_WINNT 0x0500 //for WinNT 4.0 or Win95 with DCOM
#define USE_STUBLESS_PROXY //defined only with MIDL switch /Oicf
#pragma comment(lib, "rpcns4.lib")
#pragma comment(lib, "rpcrt4.lib")
#define ENTRY_PREFIX Prx
#include "dlldata.c"
#include "LegacyUpdate_p.c"
#endif //_MERGE_PROXYSTUB

11
LegacyUpdate/dlldatax.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
#ifdef _MERGE_PROXYSTUB
extern "C" {
BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved);
STDAPI PrxDllCanUnloadNow(void);
STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv);
STDAPI PrxDllRegisterServer(void);
STDAPI PrxDllUnregisterServer(void);
}
#endif

108
LegacyUpdate/dllmain.cpp Normal file
View File

@ -0,0 +1,108 @@
// dllmain.cpp : Implementation of DLL Exports.
#include "stdafx.h"
#include "resource.h"
#include "LegacyUpdate_i.h"
#include "dllmain.h"
#include "dlldatax.h"
CLegacyUpdateModule _AtlModule;
HINSTANCE g_hInstance;
// DLL Entry Point
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) {
#ifdef _MERGE_PROXYSTUB
if (!PrxDllMain(hInstance, dwReason, lpReserved))
return FALSE;
#endif
switch (dwReason) {
case DLL_PROCESS_ATTACH:
g_hInstance = hInstance;
break;
case DLL_PROCESS_DETACH:
g_hInstance = NULL;
break;
}
return _AtlModule.DllMain(dwReason, lpReserved);
}
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void) {
#ifdef _MERGE_PROXYSTUB
HRESULT hr = PrxDllCanUnloadNow();
if (hr != S_OK) {
return hr;
}
#endif
return _AtlModule.DllCanUnloadNow();
}
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
#ifdef _MERGE_PROXYSTUB
if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK) {
return S_OK;
}
#endif
return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
}
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void) {
// registers object, typelib and all interfaces in typelib
HRESULT hr = _AtlModule.DllRegisterServer();
#ifdef _MERGE_PROXYSTUB
if (FAILED(hr)) {
return hr;
}
hr = PrxDllRegisterServer();
#endif
return hr;
}
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void) {
HRESULT hr = _AtlModule.DllUnregisterServer();
#ifdef _MERGE_PROXYSTUB
if (FAILED(hr)) {
return hr;
}
hr = PrxDllRegisterServer();
if (FAILED(hr)) {
return hr;
}
hr = PrxDllUnregisterServer();
#endif
return hr;
}
// DllInstall - Adds/Removes entries to the system registry per user per machine.
STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine) {
HRESULT hr = E_FAIL;
static const wchar_t szUserSwitch[] = L"user";
if (pszCmdLine != NULL) {
if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0) {
AtlSetPerUserRegistration(true);
}
}
if (bInstall) {
hr = DllRegisterServer();
if (FAILED(hr)) {
DllUnregisterServer();
}
} else {
hr = DllUnregisterServer();
}
return hr;
}

10
LegacyUpdate/dllmain.h Normal file
View File

@ -0,0 +1,10 @@
// dllmain.h : Declaration of module class.
class CLegacyUpdateModule : public CAtlDllModuleT<CLegacyUpdateModule> {
public:
DECLARE_LIBID(LIBID_LegacyUpdateLib)
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_LEGACYUPDATEOCX, "{D0A82CD0-B6F0-4101-83ED-DA47D0D04830}")
};
extern class CLegacyUpdateModule _AtlModule;
extern HINSTANCE g_hInstance;

BIN
LegacyUpdate/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

5
LegacyUpdate/stdafx.cpp Normal file
View File

@ -0,0 +1,5 @@
// stdafx.cpp : source file that includes just the standard includes
// LegacyUpdate.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

28
LegacyUpdate/stdafx.h Normal file
View File

@ -0,0 +1,28 @@
#pragma once
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#ifndef STRICT
#define STRICT
#endif
#include "targetver.h"
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#define ISOLATION_AWARE_ENABLED 1 // Enable comctl 6.0 (visual styles)
#include "resource.h"
#include <atltrace.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlctl.h>
using namespace ATL;
#define TRACE ATLTRACE

11
LegacyUpdate/targetver.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
#if _MSC_VER > 1599
// VC17: Windows XP
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#else
// VC08: Windows 2000 RTM
#define WINVER 0x0500
#define _WIN32_WINNT 0x0500
#endif

17
Makefile Normal file
View File

@ -0,0 +1,17 @@
export SIGN ?= 0
SUBPROJECTS = LegacyUpdate nsisplugin setup
all:
set -e; \
for i in $(SUBPROJECTS); do \
$(MAKE) -C $$i; \
done
clean:
set -e; \
for i in $(SUBPROJECTS); do \
$(MAKE) -C $$i clean; \
done
.PHONY: all clean

77
README.md Normal file
View File

@ -0,0 +1,77 @@
# [<img src="https://legacyupdate.net/socialbanner.png" alt="Legacy Update">](http://legacyupdate.net/)
[![wakatime](https://wakatime.com/badge/github/kirb/LegacyUpdate.svg)](https://wakatime.com/badge/github/kirb/LegacyUpdate)
[![Build](https://github.com/kirb/LegacyUpdate/actions/workflows/build.yml/badge.svg)](https://github.com/kirb/LegacyUpdate/actions/workflows/build.yml)
Since Windows XP was discontinued in 2014, followed by Windows 7 in 2020, Microsofts support for their earlier OSes has significantly dwindled. As XP and earlier dont officially support modern security improvements, such as the SHA256 hash algorithm required by modern SSL and Authenticode certificates [as of 2019](https://support.microsoft.com/en-us/topic/2019-sha-2-code-signing-support-requirement-for-windows-and-wsus-64d1c82d-31ee-c273-3930-69a4cde8e64f), much of the internet has become inaccessible to these devices. Adding insult to injury, Microsoft [actively removed](https://techcommunity.microsoft.com/t5/windows-it-pro-blog/sha-1-windows-content-to-be-retired-august-3-2020/ba-p/1544373) many downloads for XP and earlier versions in 2020. In effect, working with these OSes is now incredibly difficult.
To address this, [**Legacy Update**](https://legacyupdate.net/) hosts a patched instance of the Windows Update website. This works because the original Windows Update website simply accesses an ActiveX control that connects to the Windows Update service running on your computer.
> *If this website helped you to update your old PCs, please consider [leaving a tip](https://github.com/sponsors/kirb) to help me pay for the server costs. Thank you!*
## Download
Download the latest version from the [Releases](https://github.com/kirb/LegacyUpdate/releases) page of this repo, or from [**legacyupdate.net**](https://legacyupdate.net/).
You can also download the [latest nightly build](https://nightly.link/kirb/LegacyUpdate/workflows/build/main/artifact.zip), based on the current development work. Nightly builds are not guaranteed to be stable, and unlike release builds, require at least Windows 2000 SP4 or Windows XP SP2. You may also need to accept extra SmartScreen and other security warnings since these executables are unique to each build. If youre not sure what to download, you probably want the [stable release](https://legacyupdate.net/).
## The ActiveX Control
This repo hosts an ActiveX control used as a replica of the original one developed by Microsoft for the official Windows Update website. The original version of Legacy Update required using a proxy autoconfiguration file (.pac) and some additional configuration of IE security settings to intercept requests to the **update.microsoft.com** site, because the Microsoft Wuweb.dll control validates that it is being used on the official update.microsoft.com domain. With the custom Legacy Update ActiveX control, proxying is no longer required, because we have full control over the validation logic. This also allows adding additional convenient features not possible with JavaScript alone.
### Building
The project can be built on Windows 10/11 with [WSL 2](https://aka.ms/wslinstall) installed. Youll ideally want to also set up an XP VM for testing.
You will need to install:
* [Visual Studio](https://visualstudio.microsoft.com/vs/) - select the following individual components:
* Desktop development with C++
* C++ Windows XP Support for VS 2017 (v141) tools
* C++ ATL for v141 build tools (x86 & x64)
* [Visual Studio 2008](https://my.visualstudio.com/Downloads?q=Visual%20Studio%20Express%202008%20with%20Service%20Pack%201&pgroup=) for compiling a build that works on XP RTM and 2000 SP4 - not required if you only want to build for XP SP2 and later
* [NSIS](https://nsis.sourceforge.io/)
In the WSL environment, run the following command to install build dependencies. This command is for Ubuntu - if you use a different distro, you will need to find and install the equivalent packages from your package manager.
```bash
sudo apt install make nsis nsis-pluginapi mingw-w64-i686-dev
```
You will also need to extract a copy of updroots.exe from [this update](http://download.windowsupdate.com/d/msdownload/update/software/secu/2015/03/rvkroots_3f2ce4676450c06f109b5b4e68bec252873ccc21.exe). You can do this manually using 7-Zip, placing the exe at `setup/updroots.exe`, or run the following in WSL:
```bash
sudo apt install cabextract
curl -L http://download.windowsupdate.com/d/msdownload/update/software/secu/2015/03/rvkroots_3f2ce4676450c06f109b5b4e68bec252873ccc21.exe -o /tmp/rvkroots.exe
cabextract -d setup -F updroots.exe /tmp/rvkroots.exe
rm /tmp/rvkroots.exe
```
When opening the solution for the first time, Visual Studio will ask if you want to retarget it against the latest Windows SDK. Select No Upgrade.
### Testing
For debugging, if running on XP with IE8, install [Utilu IE Collection](https://www.utilu.com/iecollection/). IE6/IE7 is much more useful for debugging the native code, because of its simplistic single-process model. Visual Studio is able to launch it and directly attach to the process the code is running in.
To configure the debugger:
1. Right click LegacyUpdate in the Solution Explorer &rarr; Properties
2. In the Debugging tab, set the Command field to:
* For system IE install: `$(ProgramW6432)\Internet Explorer\iexplore.exe`
* For Utilu IE6 RTM: `$(ProgramW6432)\Utilu IE Collection\IE600\iexplore.exe`
* For Utilu IE6 SP2: `$(ProgramW6432)\Utilu IE Collection\IE600XPSP2\iexplore.exe`
* For Utilu IE7: `$(ProgramW6432)\Utilu IE Collection\IE700\iexplore.exe`
3. Set the Command Arguments field to `http://legacyupdate.net/windowsupdate/v6/`, or any other URL you want to use for debugging
4. If running on XP, in the Debugger tab, set Register Output to Yes.
If running on Vista or later, this will throw a permission denied error due to UAC. Youll need to manually register the control using `regsvr32 LegacyUpdate.dll` in an administrator command prompt.
## Website source code
I havent yet open sourced the website. This is because the vast majority of it is Microsoft code - just with a handful of patches Ive made to remove Microsoft trademark branding, switch it to the Legacy Update ActiveX control, and make some slight bug fixes/improvements. It doesnt feel appropriate to put an open source license on something I dont own. However, if you would like to review it, you can right click &rarr; View Source on the website and take a poke around, mainly in the JavaScript files. You might find [DebugBar](https://www.debugbar.com/download.php) and [CompanionJS](https://www.my-debugbar.com/wiki/CompanionJS/HomePage) (requires Visual Studio or standalone [Microsoft Script Debugger](https://web.archive.org/web/20131113042519/http://download.microsoft.com/download/7/7/d/77d8df05-6fbc-4718-a319-be14317a6811/scd10en.exe)) useful.
Ive tinkered with writing a [ground-up replacement](https://twitter.com/hbkirb/status/1584537446716350466) of the Microsoft-developed Windows Update website, which Ill open source when I feel its ready for public use (there are currently a number of bugs and missing features).
## Disclaimer
The existence of this project shouldnt be taken as an endorsement to continue using unsupported OSes. You should stick to a supported OS such as Windows 10 or 11 (or, try Linux?!). However, this service exists anyway in recognition that using these OSes is sometimes necessary to run legacy hardware/software, or just interesting to play around with.
This project is not affiliated with or endorsed by Microsoft. This software is provided “as is”, without warranty of any kind. We dont believe anything should go wrong, but please ensure you have backups of any important data anyway.
## License
Licensed under the Apache License, version 2.0. Refer to [LICENSE.md](https://github.com/kirb/LegacyUpdate/blob/main/LICENSE.md).
The repository includes a compiled copy of my fork of [NSxfer](https://github.com/kirb/nsis-nsxfer), licensed under the [zlib/libpng license](https://github.com/kirb/nsis-nsxfer/blob/master/LICENSE).

21
build.cmd Normal file
View File

@ -0,0 +1,21 @@
@echo off
setlocal enabledelayedexpansion
cd %~dp0
set ProgramFiles32=%ProgramFiles%
if "%ProgramFiles(x86)%" neq "" set ProgramFiles32=%ProgramFiles(x86)%
path %ProgramFiles32%\NSIS\Bin;%path%
:: Make sure we have MakeNSIS
if not exist "%ProgramFiles32%\NSIS\Bin\makensis.exe" (
echo NSIS not found. Refer to README.md. >&2
exit /b 1
)
:: Build project
call LegacyUpdate\build.cmd
:: Build NSIS
makensis setup\setup.nsi
if "%errorlevel%" neq "0" exit /b %errorlevel%

23
build/getvc.cmd Normal file
View File

@ -0,0 +1,23 @@
@REM @echo off
setlocal enabledelayedexpansion
set ProgramFiles32=%ProgramFiles%
if "%ProgramFiles(x86)%" neq "" set ProgramFiles32=%ProgramFiles(x86)%
:: Find Visual Studio installation
if exist "%ProgramFiles32%\Microsoft Visual Studio\Installer\vswhere.exe" (
:: Get modern Visual Studio install path
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles32%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath`) do set VSPath=%%i
set "vcvarsall=!VSPath!\VC\Auxiliary\Build\vcvarsall.bat"
if "%errorlevel%" neq "0" exit /b %errorlevel%
) else if exist "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" (
:: Visual Studio 2010
set "vcvarsall=%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat"
if "%errorlevel%" neq "0" exit /b %errorlevel%
) else (
echo Visual Studio not found. Refer to README.md. >&2
exit /b 1
)
endlocal & set "vcvarsall=%vcvarsall%"
call "%vcvarsall%" %* >nul

10
build/sign.cmd Normal file
View File

@ -0,0 +1,10 @@
@echo off
setlocal enabledelayedexpansion
:: Find Visual Studio installation
call %~dp0getvc.cmd x64
:: Sign
signtool sign /n "Hashbang Productions" /tr http://time.certum.pl/ /fd SHA1 /td SHA256 /v %*
signtool sign /n "Hashbang Productions" /tr http://time.certum.pl/ /fd SHA256 /td SHA256 /as /v %*
if "%errorlevel%" neq "0" exit /b %errorlevel%

9
build/sign.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
args=("$(wslpath -w "$(dirname "$0")/sign.cmd")")
for arg in "$@"; do
case "$arg" in
*/*) args+=("$(wslpath -w "$arg")") ;;
*) args+=("$arg") ;;
esac
done
exec cmd.exe /c "${args[@]}"

959
include/atlcomcli.h Normal file
View File

@ -0,0 +1,959 @@
/*
* ReactOS ATL
*
* Copyright 2009 Andrew Hill <ash77@reactos.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#include "atlcore.h"
#ifdef _MSC_VER
// It is common to use this in ATL constructors. They only store this for later use, so the usage is safe.
#pragma warning(disable:4355)
#endif
#ifndef _ATL_PACKING
#define _ATL_PACKING 8
#endif
#ifndef _ATL_FREE_THREADED
#ifndef _ATL_APARTMENT_THREADED
#ifndef _ATL_SINGLE_THREADED
#define _ATL_FREE_THREADED
#endif
#endif
#endif
#ifndef ATLTRY
#define ATLTRY(x) x;
#endif
#ifdef _ATL_DISABLE_NO_VTABLE
#define ATL_NO_VTABLE
#else
#define ATL_NO_VTABLE __declspec(novtable)
#endif
namespace ATL
{
inline HRESULT AtlHresultFromLastError() throw()
{
DWORD dwError = ::GetLastError();
return HRESULT_FROM_WIN32(dwError);
}
template <class T>
class _NoAddRefReleaseOnCComPtr : public T
{
private:
virtual ULONG STDMETHODCALLTYPE AddRef() = 0;
virtual ULONG STDMETHODCALLTYPE Release() = 0;
};
// Begin code borrowed from Microsoft <atlcomcli.h>
//CComPtrBase provides the basis for all other smart pointers
//The other smartpointers add their own constructors and operators
template <class T>
class CComPtrBase
{
protected:
CComPtrBase() throw()
{
p = NULL;
}
CComPtrBase(_Inout_opt_ T* lp) throw()
{
p = lp;
if (p != NULL)
p->AddRef();
}
void Swap(CComPtrBase& other)
{
T* pTemp = p;
p = other.p;
other.p = pTemp;
}
public:
typedef T _PtrClass;
~CComPtrBase() throw()
{
if (p)
p->Release();
}
operator T*() const throw()
{
return p;
}
T& operator*() const
{
ATLENSURE(p!=NULL);
return *p;
}
//The assert on operator& usually indicates a bug. If this is really
//what is needed, however, take the address of the p member explicitly.
T** operator&() throw()
{
ATLASSERT(p==NULL);
return &p;
}
_NoAddRefReleaseOnCComPtr<T>* operator->() const throw()
{
ATLASSERT(p!=NULL);
return (_NoAddRefReleaseOnCComPtr<T>*)p;
}
bool operator!() const throw()
{
return (p == NULL);
}
bool operator<(_In_opt_ T* pT) const throw()
{
return p < pT;
}
bool operator!=(_In_opt_ T* pT) const
{
return !operator==(pT);
}
bool operator==(_In_opt_ T* pT) const throw()
{
return p == pT;
}
// Release the interface and set to NULL
void Release() throw()
{
T* pTemp = p;
if (pTemp)
{
p = NULL;
pTemp->Release();
}
}
// Compare two objects for equivalence
inline bool IsEqualObject(_Inout_opt_ IUnknown* pOther) throw();
// Attach to an existing interface (does not AddRef)
void Attach(_In_opt_ T* p2) throw()
{
if (p)
{
ULONG ref = p->Release();
(ref);
// Attaching to the same object only works if duplicate references are being coalesced. Otherwise
// re-attaching will cause the pointer to be released and may cause a crash on a subsequent dereference.
ATLASSERT(ref != 0 || p2 != p);
}
p = p2;
}
// Detach the interface (does not Release)
T* Detach() throw()
{
T* pt = p;
p = NULL;
return pt;
}
_Check_return_ HRESULT CopyTo(_COM_Outptr_result_maybenull_ T** ppT) throw()
{
ATLASSERT(ppT != NULL);
if (ppT == NULL)
return E_POINTER;
*ppT = p;
if (p)
p->AddRef();
return S_OK;
}
_Check_return_ HRESULT SetSite(_Inout_opt_ IUnknown* punkParent) throw()
{
return AtlSetChildSite(p, punkParent);
}
_Check_return_ HRESULT Advise(
_Inout_ IUnknown* pUnk,
_In_ const IID& iid,
_Out_ LPDWORD pdw) throw()
{
return AtlAdvise(p, pUnk, iid, pdw);
}
_Check_return_ HRESULT CoCreateInstance(
_In_ REFCLSID rclsid,
_Inout_opt_ LPUNKNOWN pUnkOuter = NULL,
_In_ DWORD dwClsContext = CLSCTX_ALL) throw()
{
ATLASSERT(p == NULL);
return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
}
#ifdef _ATL_USE_WINAPI_FAMILY_DESKTOP_APP
_Check_return_ HRESULT CoCreateInstance(
_In_z_ LPCOLESTR szProgID,
_Inout_opt_ LPUNKNOWN pUnkOuter = NULL,
_In_ DWORD dwClsContext = CLSCTX_ALL) throw()
{
CLSID clsid;
HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
ATLASSERT(p == NULL);
if (SUCCEEDED(hr))
hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p);
return hr;
}
#endif // _ATL_USE_WINAPI_FAMILY_DESKTOP_APP
template <class Q>
_Check_return_ HRESULT QueryInterface(_Outptr_ Q** pp) const throw()
{
ATLASSERT(pp != NULL);
return p->QueryInterface(__uuidof(Q), (void**)pp);
}
T* p;
};
// End code borrowed from Microsoft <atlcomcli.h>
template<class T>
class CComPtr :
public CComPtrBase<T>
{
public:
T *p;
public:
CComPtr()
{
p = NULL;
}
CComPtr(T *lp)
{
p = lp;
if (p != NULL)
p->AddRef();
}
CComPtr(const CComPtr<T> &lp)
{
p = lp.p;
if (p != NULL)
p->AddRef();
}
~CComPtr()
{
if (p != NULL)
p->Release();
}
T *operator = (T *lp)
{
T* pOld = p;
p = lp;
if (p != NULL)
p->AddRef();
if (pOld != NULL)
pOld->Release();
return *this;
}
T *operator = (const CComPtr<T> &lp)
{
T* pOld = p;
p = lp.p;
if (p != NULL)
p->AddRef();
if (pOld != NULL)
pOld->Release();
return *this;
}
// We cannot enable this until gcc starts supporting __uuidof
// See CORE-12710
#if 0
template <typename Q>
T* operator=(const CComPtr<Q>& lp)
{
T* pOld = p;
if (!lp.p || FAILED(lp.p->QueryInterface(__uuidof(T), (void**)(IUnknown**)&p)))
p = NULL;
if (pOld != NULL)
pOld->Release();
return *this;
}
#endif
void Release()
{
if (p != NULL)
{
p->Release();
p = NULL;
}
}
void Attach(T *lp)
{
if (p != NULL)
p->Release();
p = lp;
}
T *Detach()
{
T *saveP;
saveP = p;
p = NULL;
return saveP;
}
T **operator & ()
{
ATLASSERT(p == NULL);
return &p;
}
operator T * ()
{
return p;
}
_NoAddRefReleaseOnCComPtr<T> *operator -> () const
{
ATLASSERT(p != NULL);
return (_NoAddRefReleaseOnCComPtr<T> *)p;
}
};
// Begin code borrowed from Microsoft <atlcomcli.h>
//specialization for IDispatch
template <>
class CComPtr<IDispatch> :
public CComPtrBase<IDispatch>
{
public:
CComPtr() throw()
{
}
CComPtr(_Inout_opt_ IDispatch* lp) throw() :
CComPtrBase<IDispatch>(lp)
{
}
CComPtr(_Inout_ const CComPtr<IDispatch>& lp) throw() :
CComPtrBase<IDispatch>(lp.p)
{
}
IDispatch* operator=(_Inout_opt_ IDispatch* lp) throw()
{
if(*this!=lp)
{
CComPtr(lp).Swap(*this);
}
return *this;
}
IDispatch* operator=(_Inout_ const CComPtr<IDispatch>& lp) throw()
{
if(*this!=lp)
{
CComPtr(lp).Swap(*this);
}
return *this;
}
CComPtr(_Inout_ CComPtr<IDispatch>&& lp) throw() :
CComPtrBase<IDispatch>()
{
this->p = lp.p;
lp.p = NULL;
}
IDispatch* operator=(_Inout_ CComPtr<IDispatch>&& lp) throw()
{
CComPtr(static_cast<CComPtr&&>(lp)).Swap(*this);
return *this;
}
_Check_return_ HRESULT GetPropertyByName(
_In_z_ LPCOLESTR lpsz,
_Out_ VARIANT* pVar) throw()
{
ATLASSERT(this->p);
ATLASSERT(pVar);
DISPID dwDispID;
HRESULT hr = GetIDOfName(lpsz, &dwDispID);
if (SUCCEEDED(hr))
hr = GetProperty(dwDispID, pVar);
return hr;
}
_Check_return_ HRESULT GetProperty(
_In_ DISPID dwDispID,
_Out_ VARIANT* pVar) throw()
{
return GetProperty(this->p, dwDispID, pVar);
}
_Check_return_ HRESULT PutPropertyByName(
_In_z_ LPCOLESTR lpsz,
_In_ VARIANT* pVar) throw()
{
ATLASSERT(this->p);
ATLASSERT(pVar);
DISPID dwDispID;
HRESULT hr = GetIDOfName(lpsz, &dwDispID);
if (SUCCEEDED(hr))
hr = PutProperty(dwDispID, pVar);
return hr;
}
_Check_return_ HRESULT PutProperty(
_In_ DISPID dwDispID,
_In_ VARIANT* pVar) throw()
{
return PutProperty(this->p, dwDispID, pVar);
}
_Check_return_ HRESULT GetIDOfName(
_In_z_ LPCOLESTR lpsz,
_Out_ DISPID* pdispid) throw()
{
return this->p->GetIDsOfNames(IID_NULL, const_cast<LPOLESTR*>(&lpsz), 1, LOCALE_USER_DEFAULT, pdispid);
}
// Invoke a method by DISPID with no parameters
_Check_return_ HRESULT Invoke0(
_In_ DISPID dispid,
_Out_opt_ VARIANT* pvarRet = NULL) throw()
{
DISPPARAMS dispparams = { NULL, NULL, 0, 0};
return this->p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL);
}
// Invoke a method by name with no parameters
_Check_return_ HRESULT Invoke0(
_In_z_ LPCOLESTR lpszName,
_Out_opt_ VARIANT* pvarRet = NULL) throw()
{
HRESULT hr;
DISPID dispid;
hr = GetIDOfName(lpszName, &dispid);
if (SUCCEEDED(hr))
hr = Invoke0(dispid, pvarRet);
return hr;
}
// Invoke a method by DISPID with a single parameter
_Check_return_ HRESULT Invoke1(
_In_ DISPID dispid,
_In_ VARIANT* pvarParam1,
_Out_opt_ VARIANT* pvarRet = NULL) throw()
{
DISPPARAMS dispparams = { pvarParam1, NULL, 1, 0};
return this->p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL);
}
// Invoke a method by name with a single parameter
_Check_return_ HRESULT Invoke1(
_In_z_ LPCOLESTR lpszName,
_In_ VARIANT* pvarParam1,
_Out_opt_ VARIANT* pvarRet = NULL) throw()
{
DISPID dispid;
HRESULT hr = GetIDOfName(lpszName, &dispid);
if (SUCCEEDED(hr))
hr = Invoke1(dispid, pvarParam1, pvarRet);
return hr;
}
// Invoke a method by DISPID with two parameters
_Check_return_ HRESULT Invoke2(
_In_ DISPID dispid,
_In_ VARIANT* pvarParam1,
_In_ VARIANT* pvarParam2,
_Out_opt_ VARIANT* pvarRet = NULL) throw();
// Invoke a method by name with two parameters
_Check_return_ HRESULT Invoke2(
_In_z_ LPCOLESTR lpszName,
_In_ VARIANT* pvarParam1,
_In_ VARIANT* pvarParam2,
_Out_opt_ VARIANT* pvarRet = NULL) throw()
{
DISPID dispid;
HRESULT hr = GetIDOfName(lpszName, &dispid);
if (SUCCEEDED(hr))
hr = Invoke2(dispid, pvarParam1, pvarParam2, pvarRet);
return hr;
}
// Invoke a method by DISPID with N parameters
_Check_return_ HRESULT InvokeN(
_In_ DISPID dispid,
_In_ VARIANT* pvarParams,
_In_ int nParams,
_Out_opt_ VARIANT* pvarRet = NULL) throw()
{
DISPPARAMS dispparams = {pvarParams, NULL, (unsigned int)nParams, 0};
return this->p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL);
}
// Invoke a method by name with Nparameters
_Check_return_ HRESULT InvokeN(
_In_z_ LPCOLESTR lpszName,
_In_ VARIANT* pvarParams,
_In_ int nParams,
_Out_opt_ VARIANT* pvarRet = NULL) throw()
{
HRESULT hr;
DISPID dispid;
hr = GetIDOfName(lpszName, &dispid);
if (SUCCEEDED(hr))
hr = InvokeN(dispid, pvarParams, nParams, pvarRet);
return hr;
}
_Check_return_ static HRESULT PutProperty(
_In_ IDispatch* pDispatch,
_In_ DISPID dwDispID,
_In_ VARIANT* pVar) throw()
{
ATLASSERT(pDispatch);
ATLASSERT(pVar != NULL);
if (pVar == NULL)
return E_POINTER;
if (pDispatch == NULL)
return E_INVALIDARG;
DISPPARAMS dispparams = {NULL, NULL, 1, 1};
dispparams.rgvarg = pVar;
DISPID dispidPut = DISPID_PROPERTYPUT;
dispparams.rgdispidNamedArgs = &dispidPut;
if (pVar->vt == VT_UNKNOWN || pVar->vt == VT_DISPATCH ||
(pVar->vt & VT_ARRAY) || (pVar->vt & VT_BYREF))
{
HRESULT hr = pDispatch->Invoke(dwDispID, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUTREF,
&dispparams, NULL, NULL, NULL);
if (SUCCEEDED(hr))
return hr;
}
return pDispatch->Invoke(dwDispID, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
&dispparams, NULL, NULL, NULL);
}
_Check_return_ static HRESULT GetProperty(
_In_ IDispatch* pDispatch,
_In_ DISPID dwDispID,
_Out_ VARIANT* pVar) throw()
{
ATLASSERT(pDispatch);
ATLASSERT(pVar != NULL);
if (pVar == NULL)
return E_POINTER;
if (pDispatch == NULL)
return E_INVALIDARG;
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
return pDispatch->Invoke(dwDispID, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
&dispparamsNoArgs, pVar, NULL, NULL);
}
};
// End code borrowed from Microsoft <atlcomcli.h>
//CComQIIDPtr<I_ID(Itype)> is the gcc compatible version of CComQIPtr<Itype>
#define I_ID(Itype) Itype,&IID_##Itype
template <class T, const IID* piid>
class CComQIIDPtr :
public CComPtr<T>
{
public:
// Let's tell GCC how to find a symbol.
using CComPtr<T>::p;
CComQIIDPtr()
{
}
CComQIIDPtr(_Inout_opt_ T* lp) :
CComPtr<T>(lp)
{
}
CComQIIDPtr(_Inout_ const CComQIIDPtr<T,piid>& lp):
CComPtr<T>(lp.p)
{
}
CComQIIDPtr(_Inout_opt_ IUnknown* lp)
{
if (lp != NULL)
{
if (FAILED(lp->QueryInterface(*piid, (void**)(IUnknown**)&p)))
p = NULL;
}
}
T *operator = (T *lp)
{
T* pOld = p;
p = lp;
if (p != NULL)
p->AddRef();
if (pOld != NULL)
pOld->Release();
return *this;
}
T *operator = (const CComQIIDPtr<T,piid> &lp)
{
T* pOld = p;
p = lp.p;
if (p != NULL)
p->AddRef();
if (pOld != NULL)
pOld->Release();
return *this;
}
T * operator=(IUnknown* lp)
{
T* pOld = p;
if (!lp || FAILED(lp->QueryInterface(*piid, (void**)(IUnknown**)&p)))
p = NULL;
if (pOld != NULL)
pOld->Release();
return *this;
}
};
class CComBSTR
{
public:
BSTR m_str;
public:
CComBSTR() :
m_str(NULL)
{
}
CComBSTR(LPCOLESTR pSrc)
{
if (pSrc == NULL)
m_str = NULL;
else
m_str = ::SysAllocString(pSrc);
}
CComBSTR(int length)
{
if (length == 0)
m_str = NULL;
else
m_str = ::SysAllocStringLen(NULL, length);
}
CComBSTR(int length, LPCOLESTR pSrc)
{
if (length == 0)
m_str = NULL;
else
m_str = ::SysAllocStringLen(pSrc, length);
}
CComBSTR(PCSTR pSrc)
{
if (pSrc)
{
int len = MultiByteToWideChar(CP_THREAD_ACP, 0, pSrc, -1, NULL, 0);
m_str = ::SysAllocStringLen(NULL, len - 1);
if (m_str)
{
int res = MultiByteToWideChar(CP_THREAD_ACP, 0, pSrc, -1, m_str, len);
ATLASSERT(res == len);
if (res != len)
{
::SysFreeString(m_str);
m_str = NULL;
}
}
}
else
{
m_str = NULL;
}
}
CComBSTR(const CComBSTR &other)
{
m_str = other.Copy();
}
CComBSTR(REFGUID guid)
{
OLECHAR szGuid[40];
::StringFromGUID2(guid, szGuid, 40);
m_str = ::SysAllocString(szGuid);
}
~CComBSTR()
{
::SysFreeString(m_str);
m_str = NULL;
}
operator BSTR () const
{
return m_str;
}
BSTR *operator & ()
{
return &m_str;
}
CComBSTR &operator = (const CComBSTR &other)
{
::SysFreeString(m_str);
m_str = other.Copy();
return *this;
}
void Attach(BSTR bstr)
{
::SysFreeString(m_str);
m_str = bstr;
}
BSTR Detach()
{
BSTR str = m_str;
m_str = NULL;
return str;
}
BSTR Copy() const
{
if (!m_str)
return NULL;
return ::SysAllocStringLen(m_str, ::SysStringLen(m_str));
}
HRESULT CopyTo(BSTR *other) const
{
if (!other)
return E_POINTER;
*other = Copy();
return S_OK;
}
bool LoadString(HMODULE module, DWORD uID)
{
::SysFreeString(m_str);
m_str = NULL;
const wchar_t *ptr = NULL;
int len = ::LoadStringW(module, uID, (PWSTR)&ptr, 0);
if (len)
m_str = ::SysAllocStringLen(ptr, len);
return m_str != NULL;
}
unsigned int Length() const
{
return ::SysStringLen(m_str);
}
unsigned int ByteLength() const
{
return ::SysStringByteLen(m_str);
}
};
class CComVariant : public tagVARIANT
{
public:
CComVariant()
{
::VariantInit(this);
}
CComVariant(const CComVariant& other)
{
V_VT(this) = VT_EMPTY;
Copy(&other);
}
~CComVariant()
{
Clear();
}
CComVariant(LPCOLESTR lpStr)
{
V_VT(this) = VT_BSTR;
V_BSTR(this) = ::SysAllocString(lpStr);
}
CComVariant(LPCSTR lpStr)
{
V_VT(this) = VT_BSTR;
CComBSTR str(lpStr);
V_BSTR(this) = str.Detach();
}
CComVariant(bool value)
{
V_VT(this) = VT_BOOL;
V_BOOL(this) = value ? VARIANT_TRUE : VARIANT_FALSE;
}
CComVariant(char value)
{
V_VT(this) = VT_I1;
V_I1(this) = value;
}
CComVariant(BYTE value)
{
V_VT(this) = VT_UI1;
V_UI1(this) = value;
}
CComVariant(short value)
{
V_VT(this) = VT_I2;
V_I2(this) = value;
}
CComVariant(unsigned short value)
{
V_VT(this) = VT_UI2;
V_UI2(this) = value;
}
CComVariant(int value, VARENUM type = VT_I4)
{
if (type == VT_I4 || type == VT_INT)
{
V_VT(this) = type;
V_I4(this) = value;
}
else
{
V_VT(this) = VT_ERROR;
V_ERROR(this) = E_INVALIDARG;
}
}
CComVariant(unsigned int value, VARENUM type = VT_UI4)
{
if (type == VT_UI4 || type == VT_UINT)
{
V_VT(this) = type;
V_UI4(this) = value;
}
else
{
V_VT(this) = VT_ERROR;
V_ERROR(this) = E_INVALIDARG;
}
}
CComVariant(long value, VARENUM type = VT_I4)
{
if (type == VT_I4 || type == VT_ERROR)
{
V_VT(this) = type;
V_I4(this) = value;
}
else
{
V_VT(this) = VT_ERROR;
V_ERROR(this) = E_INVALIDARG;
}
}
CComVariant(unsigned long value)
{
V_VT(this) = VT_UI4;
V_UI4(this) = value;
}
CComVariant(float value)
{
V_VT(this) = VT_R4;
V_R4(this) = value;
}
CComVariant(double value, VARENUM type = VT_R8)
{
if (type == VT_R8 || type == VT_DATE)
{
V_VT(this) = type;
V_R8(this) = value;
}
else
{
V_VT(this) = VT_ERROR;
V_ERROR(this) = E_INVALIDARG;
}
}
CComVariant(const LONGLONG& value)
{
V_VT(this) = VT_I8;
V_I8(this) = value;
}
CComVariant(const ULONGLONG& value)
{
V_VT(this) = VT_UI8;
V_UI8(this) = value;
}
CComVariant(const CY& value)
{
V_VT(this) = VT_CY;
V_I8(this) = value.int64;
}
HRESULT Clear()
{
return ::VariantClear(this);
}
HRESULT Copy(_In_ const VARIANT* src)
{
return ::VariantCopy(this, const_cast<VARIANT*>(src));
}
HRESULT ChangeType(_In_ VARTYPE newType, _In_opt_ const LPVARIANT src = NULL)
{
const LPVARIANT lpSrc = src ? src : this;
return ::VariantChangeType(this, lpSrc, 0, newType);
}
};
}; // namespace ATL
#ifndef _ATL_NO_AUTOMATIC_NAMESPACE
using namespace ATL;
#endif //!_ATL_NO_AUTOMATIC_NAMESPACE

310
include/atlcore.h Normal file
View File

@ -0,0 +1,310 @@
/*
* ReactOS ATL
*
* Copyright 2009 Andrew Hill <ash77@reactos.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#include <malloc.h>
#ifdef __REACTOS__
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <winnls.h>
#else
#include <windows.h>
#endif
#include <ole2.h>
#include <olectl.h>
#include <crtdbg.h>
#ifndef ATLASSERT
#define ATLASSERT(expr) _ASSERTE(expr)
#endif // ATLASSERT
namespace ATL
{
class CComCriticalSection
{
public:
CRITICAL_SECTION m_sec;
public:
CComCriticalSection()
{
memset(&m_sec, 0, sizeof(CRITICAL_SECTION));
}
virtual ~CComCriticalSection()
{
}
HRESULT Lock()
{
EnterCriticalSection(&m_sec);
return S_OK;
}
HRESULT Unlock()
{
LeaveCriticalSection(&m_sec);
return S_OK;
}
HRESULT Init()
{
InitializeCriticalSection(&m_sec);
return S_OK;
}
HRESULT Term()
{
DeleteCriticalSection(&m_sec);
return S_OK;
}
};
class CComFakeCriticalSection
{
public:
HRESULT Lock()
{
return S_OK;
}
HRESULT Unlock()
{
return S_OK;
}
HRESULT Init()
{
return S_OK;
}
HRESULT Term()
{
return S_OK;
}
};
class CComAutoCriticalSection : public CComCriticalSection
{
public:
CComAutoCriticalSection()
{
HRESULT hResult __MINGW_ATTRIB_UNUSED;
hResult = CComCriticalSection::Init();
ATLASSERT(SUCCEEDED(hResult));
}
~CComAutoCriticalSection()
{
CComCriticalSection::Term();
}
};
class CComSafeDeleteCriticalSection : public CComCriticalSection
{
private:
bool m_bInitialized;
public:
CComSafeDeleteCriticalSection()
{
m_bInitialized = false;
}
~CComSafeDeleteCriticalSection()
{
Term();
}
HRESULT Lock()
{
ATLASSERT(m_bInitialized);
return CComCriticalSection::Lock();
}
HRESULT Init()
{
HRESULT hResult;
ATLASSERT(!m_bInitialized);
hResult = CComCriticalSection::Init();
if (SUCCEEDED(hResult))
m_bInitialized = true;
return hResult;
}
HRESULT Term()
{
if (!m_bInitialized)
return S_OK;
m_bInitialized = false;
return CComCriticalSection::Term();
}
};
class CComAutoDeleteCriticalSection : public CComSafeDeleteCriticalSection
{
private:
// CComAutoDeleteCriticalSection::Term should never be called
HRESULT Term();
};
struct _ATL_BASE_MODULE70
{
UINT cbSize;
HINSTANCE m_hInst;
HINSTANCE m_hInstResource;
bool m_bNT5orWin98;
DWORD dwAtlBuildVer;
GUID *pguidVer;
CRITICAL_SECTION m_csResource;
#ifdef NOTYET
CSimpleArray<HINSTANCE> m_rgResourceInstance;
#endif
};
typedef _ATL_BASE_MODULE70 _ATL_BASE_MODULE;
class CAtlBaseModule : public _ATL_BASE_MODULE
{
public :
static bool m_bInitFailed;
public:
CAtlBaseModule()
{
cbSize = sizeof(_ATL_BASE_MODULE);
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)this, &m_hInst);
m_hInstResource = m_hInst;
}
HINSTANCE GetModuleInstance()
{
return m_hInst;
}
HINSTANCE GetResourceInstance()
{
return m_hInstResource;
}
HINSTANCE SetResourceInstance(HINSTANCE hInst)
{
return static_cast< HINSTANCE >(InterlockedExchangePointer((void**)&m_hInstResource, hInst));
}
HINSTANCE GetHInstanceAt(int i);
};
__declspec(selectany) CAtlBaseModule _AtlBaseModule;
__declspec(selectany) bool CAtlBaseModule::m_bInitFailed = false;
///
// String Resource helper functions
//
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4200)
#endif
struct ATLSTRINGRESOURCEIMAGE
{
WORD nLength;
WCHAR achString[];
};
#ifdef _MSC_VER
#pragma warning(pop)
#endif
inline const ATLSTRINGRESOURCEIMAGE* _AtlGetStringResourceImage(
_In_ HINSTANCE hInstance,
_In_ HRSRC hResource,
_In_ UINT id)
{
const ATLSTRINGRESOURCEIMAGE* pImage;
const ATLSTRINGRESOURCEIMAGE* pImageEnd;
ULONG nResourceSize;
HGLOBAL hGlobal;
UINT iIndex;
hGlobal = ::LoadResource(hInstance, hResource);
if (hGlobal == NULL) return NULL;
pImage = (const ATLSTRINGRESOURCEIMAGE*)::LockResource(hGlobal);
if (pImage == NULL) return NULL;
nResourceSize = ::SizeofResource(hInstance, hResource);
pImageEnd = (const ATLSTRINGRESOURCEIMAGE*)(LPBYTE(pImage) + nResourceSize);
iIndex = id & 0x000f;
while ((iIndex > 0) && (pImage < pImageEnd))
{
pImage = (const ATLSTRINGRESOURCEIMAGE*)(LPBYTE(pImage) + (sizeof(ATLSTRINGRESOURCEIMAGE) + (pImage->nLength * sizeof(WCHAR))));
iIndex--;
}
if (pImage >= pImageEnd) return NULL;
if (pImage->nLength == 0) return NULL;
return pImage;
}
inline const ATLSTRINGRESOURCEIMAGE* AtlGetStringResourceImage(
_In_ HINSTANCE hInstance,
_In_ UINT id) throw()
{
HRSRC hResource;
hResource = ::FindResourceW(hInstance, MAKEINTRESOURCEW((((id >> 4) + 1) & static_cast<WORD>(~0))), (LPWSTR)RT_STRING);
if (hResource == NULL) return NULL;
return _AtlGetStringResourceImage(hInstance, hResource, id);
}
inline const ATLSTRINGRESOURCEIMAGE* AtlGetStringResourceImage(
_In_ HINSTANCE hInstance,
_In_ UINT id,
_In_ WORD wLanguage)
{
HRSRC hResource;
hResource = ::FindResourceExW(hInstance, (LPWSTR)RT_STRING, MAKEINTRESOURCEW((((id >> 4) + 1) & static_cast<WORD>(~0))), wLanguage);
if (hResource == NULL) return NULL;
return _AtlGetStringResourceImage(hInstance, hResource, id);
}
inline HINSTANCE AtlFindStringResourceInstance(
UINT nID,
WORD wLanguage = 0)
{
const ATLSTRINGRESOURCEIMAGE* strRes = NULL;
HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0);
for (int i = 1; hInst != NULL && strRes == NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++))
{
strRes = AtlGetStringResourceImage(hInst, nID, wLanguage);
if (strRes != NULL) return hInst;
}
return NULL;
}
}; // namespace ATL

85
include/nsis/api.h Normal file
View File

@ -0,0 +1,85 @@
/*
* apih
*
* This file is a part of NSIS.
*
* Copyright (C) 1999-2023 Nullsoft and Contributors
*
* Licensed under the zlib/libpng license (the "License");
* you may not use this file except in compliance with the License.
*
* Licence details can be found in the file COPYING.
*
* This software is provided 'as-is', without any express or implied
* warranty.
*/
#ifndef _NSIS_EXEHEAD_API_H_
#define _NSIS_EXEHEAD_API_H_
// Starting with NSIS 2.42, you can check the version of the plugin API in exec_flags->plugin_api_version
// The format is 0xXXXXYYYY where X is the major version and Y is the minor version (MAKELONG(y,x))
// When doing version checks, always remember to use >=, ex: if (pX->exec_flags->plugin_api_version >= NSISPIAPIVER_1_0) {}
#define NSISPIAPIVER_1_0 0x00010000
#define NSISPIAPIVER_CURR NSISPIAPIVER_1_0
// NSIS Plug-In Callback Messages
enum NSPIM
{
NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup
NSPIM_GUIUNLOAD, // Called after .onGUIEnd
};
// Prototype for callbacks registered with extra_parameters->RegisterPluginCallback()
// Return NULL for unknown messages
// Should always be __cdecl for future expansion possibilities
typedef UINT_PTR (*NSISPLUGINCALLBACK)(enum NSPIM);
// extra_parameters data structure containing other interesting stuff
// besides the stack, variables and HWND passed on to plug-ins.
typedef struct
{
int autoclose; // SetAutoClose
int all_user_var; // SetShellVarContext: User context = 0, Machine context = 1
int exec_error; // IfErrors/ClearErrors/SetErrors
int abort; // IfAbort
int exec_reboot; // IfRebootFlag/SetRebootFlag (NSIS_SUPPORT_REBOOT)
int reboot_called; // NSIS_SUPPORT_REBOOT
int XXX_cur_insttype; // Deprecated
int plugin_api_version; // Plug-in ABI. See NSISPIAPIVER_CURR (Note: used to be XXX_insttype_changed)
int silent; // IfSilent/SetSilent (NSIS_CONFIG_SILENT_SUPPORT)
int instdir_error; // GetInstDirError
int rtl; // IfRtlLanguage: 1 if $LANGUAGE is a RTL language
int errlvl; // SetErrorLevel
int alter_reg_view; // SetRegView: Default View = 0, Alternative View = (sizeof(void*) > 4 ? KEY_WOW64_32KEY : KEY_WOW64_64KEY)
int status_update; // SetDetailsPrint
} exec_flags_t;
#ifndef NSISCALL
# define NSISCALL __stdcall
#endif
#if !defined(_WIN32) && !defined(LPTSTR)
# define LPTSTR TCHAR*
#endif
typedef struct {
exec_flags_t *exec_flags;
int (NSISCALL *ExecuteCodeSegment)(int, HWND);
void (NSISCALL *validate_filename)(LPTSTR);
int (NSISCALL *RegisterPluginCallback)(HMODULE, NSISPLUGINCALLBACK); // returns 0 on success, 1 if already registered and < 0 on errors
} extra_parameters;
// Definitions for page showing plug-ins
// See Ui.c to understand better how they're used
// sent to the outer window to tell it to go to the next inner window
#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8)
// custom pages should send this message to let NSIS know they're ready
#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd)
// sent as wParam with WM_NOTIFY_OUTER_NEXT when user cancels - heed its warning
#define NOTIFY_BYE_BYE 'x'
#endif /* _NSIS_EXEHEAD_API_H_ */

229
include/nsis/nsis_tchar.h Normal file
View File

@ -0,0 +1,229 @@
/*
* nsis_tchar.h
*
* This file is a part of NSIS.
*
* Copyright (C) 1999-2023 Nullsoft and Contributors
*
* This software is provided 'as-is', without any express or implied
* warranty.
*
* For Unicode support by Jim Park -- 08/30/2007
*/
// Jim Park: Only those we use are listed here.
#pragma once
#ifdef _UNICODE
#ifndef _T
#define __T(x) L ## x
#define _T(x) __T(x)
#define _TEXT(x) __T(x)
#endif
#ifndef _TCHAR_DEFINED
#define _TCHAR_DEFINED
#if !defined(_NATIVE_WCHAR_T_DEFINED) && !defined(_WCHAR_T_DEFINED)
typedef unsigned short TCHAR;
#else
typedef wchar_t TCHAR;
#endif
#endif
// program
#define _tenviron _wenviron
#define __targv __wargv
// printfs
#define _ftprintf fwprintf
#define _sntprintf _snwprintf
#if (defined(_MSC_VER) && (_MSC_VER<=1310||_MSC_FULL_VER<=140040310)) || defined(__MINGW32__)
# define _stprintf swprintf
#else
# define _stprintf _swprintf
#endif
#define _tprintf wprintf
#define _vftprintf vfwprintf
#define _vsntprintf _vsnwprintf
#if defined(_MSC_VER) && (_MSC_VER<=1310)
# define _vstprintf vswprintf
#else
# define _vstprintf _vswprintf
#endif
// scanfs
#define _tscanf wscanf
#define _stscanf swscanf
// string manipulations
#define _tcscat wcscat
#define _tcschr wcschr
#define _tcsclen wcslen
#define _tcscpy wcscpy
#define _tcsdup _wcsdup
#define _tcslen wcslen
#define _tcsnccpy wcsncpy
#define _tcsncpy wcsncpy
#define _tcsrchr wcsrchr
#define _tcsstr wcsstr
#define _tcstok wcstok
// string comparisons
#define _tcscmp wcscmp
#define _tcsicmp _wcsicmp
#define _tcsncicmp _wcsnicmp
#define _tcsncmp wcsncmp
#define _tcsnicmp _wcsnicmp
// upper / lower
#define _tcslwr _wcslwr
#define _tcsupr _wcsupr
#define _totlower towlower
#define _totupper towupper
// conversions to numbers
#define _tcstoi64 _wcstoi64
#define _tcstol wcstol
#define _tcstoul wcstoul
#define _tstof _wtof
#define _tstoi _wtoi
#define _tstoi64 _wtoi64
#define _ttoi _wtoi
#define _ttoi64 _wtoi64
#define _ttol _wtol
// conversion from numbers to strings
#define _itot _itow
#define _ltot _ltow
#define _i64tot _i64tow
#define _ui64tot _ui64tow
// file manipulations
#define _tfopen _wfopen
#define _topen _wopen
#define _tremove _wremove
#define _tunlink _wunlink
// reading and writing to i/o
#define _fgettc fgetwc
#define _fgetts fgetws
#define _fputts fputws
#define _gettchar getwchar
// directory
#define _tchdir _wchdir
// environment
#define _tgetenv _wgetenv
#define _tsystem _wsystem
// time
#define _tcsftime wcsftime
#else // ANSI
#ifndef _T
#define _T(x) x
#define _TEXT(x) x
#endif
#ifndef _TCHAR_DEFINED
#define _TCHAR_DEFINED
typedef char TCHAR;
#endif
// program
#define _tenviron environ
#define __targv __argv
// printfs
#define _ftprintf fprintf
#define _sntprintf _snprintf
#define _stprintf sprintf
#define _tprintf printf
#define _vftprintf vfprintf
#define _vsntprintf _vsnprintf
#define _vstprintf vsprintf
// scanfs
#define _tscanf scanf
#define _stscanf sscanf
// string manipulations
#define _tcscat strcat
#define _tcschr strchr
#define _tcsclen strlen
#define _tcscnlen strnlen
#define _tcscpy strcpy
#define _tcsdup _strdup
#define _tcslen strlen
#define _tcsnccpy strncpy
#define _tcsrchr strrchr
#define _tcsstr strstr
#define _tcstok strtok
// string comparisons
#define _tcscmp strcmp
#define _tcsicmp _stricmp
#define _tcsncmp strncmp
#define _tcsncicmp _strnicmp
#define _tcsnicmp _strnicmp
// upper / lower
#define _tcslwr _strlwr
#define _tcsupr _strupr
#define _totupper toupper
#define _totlower tolower
// conversions to numbers
#define _tcstol strtol
#define _tcstoul strtoul
#define _tstof atof
#define _tstoi atoi
#define _tstoi64 _atoi64
#define _tstoi64 _atoi64
#define _ttoi atoi
#define _ttoi64 _atoi64
#define _ttol atol
// conversion from numbers to strings
#define _i64tot _i64toa
#define _itot _itoa
#define _ltot _ltoa
#define _ui64tot _ui64toa
// file manipulations
#define _tfopen fopen
#define _topen _open
#define _tremove remove
#define _tunlink _unlink
// reading and writing to i/o
#define _fgettc fgetc
#define _fgetts fgets
#define _fputts fputs
#define _gettchar getchar
// directory
#define _tchdir _chdir
// environment
#define _tgetenv getenv
#define _tsystem system
// time
#define _tcsftime strftime
#endif
// is functions (the same in Unicode / ANSI)
#define _istgraph isgraph
#define _istascii __isascii
#define __TFILE__ _T(__FILE__)
#define __TDATE__ _T(__DATE__)
#define __TTIME__ _T(__TIME__)

305
include/nsis/pluginapi.c Normal file
View File

@ -0,0 +1,305 @@
#include <windows.h>
#include "pluginapi.h"
#ifndef COUNTOF
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#endif
// minimal tchar.h emulation
#ifndef _T
# define _T TEXT
#endif
#if !defined(TCHAR) && !defined(_TCHAR_DEFINED)
# ifdef UNICODE
# define TCHAR WCHAR
# else
# define TCHAR char
# endif
#endif
#define isvalidnsisvarindex(varnum) ( ((unsigned int)(varnum)) < (__INST_LAST) )
unsigned int g_stringsize;
stack_t **g_stacktop;
LPTSTR g_variables;
// utility functions (not required but often useful)
int NSISCALL popstring(LPTSTR str)
{
stack_t *th;
if (!g_stacktop || !*g_stacktop) return 1;
th=(*g_stacktop);
if (str) lstrcpy(str,th->text);
*g_stacktop = th->next;
GlobalFree((HGLOBAL)th);
return 0;
}
int NSISCALL popstringn(LPTSTR str, int maxlen)
{
stack_t *th;
if (!g_stacktop || !*g_stacktop) return 1;
th=(*g_stacktop);
if (str) lstrcpyn(str,th->text,maxlen?maxlen:g_stringsize);
*g_stacktop = th->next;
GlobalFree((HGLOBAL)th);
return 0;
}
void NSISCALL pushstring(LPCTSTR str)
{
stack_t *th;
if (!g_stacktop) return;
th=(stack_t*)GlobalAlloc(GPTR,(sizeof(stack_t)+(g_stringsize)*sizeof(*str)));
lstrcpyn(th->text,str,g_stringsize);
th->next=*g_stacktop;
*g_stacktop=th;
}
LPTSTR NSISCALL getuservariable(const int varnum)
{
if (!isvalidnsisvarindex(varnum)) return NULL;
return g_variables+varnum*g_stringsize;
}
void NSISCALL setuservariable(const int varnum, LPCTSTR var)
{
if (var && isvalidnsisvarindex(varnum))
lstrcpy(g_variables + varnum*g_stringsize, var);
}
#ifdef UNICODE
int NSISCALL PopStringA(LPSTR ansiStr)
{
LPWSTR wideStr = (LPWSTR) GlobalAlloc(GPTR, g_stringsize*sizeof(WCHAR));
int rval = popstring(wideStr);
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
GlobalFree((HGLOBAL)wideStr);
return rval;
}
int NSISCALL PopStringNA(LPSTR ansiStr, int maxlen)
{
int realLen = maxlen ? maxlen : g_stringsize;
LPWSTR wideStr = (LPWSTR) GlobalAlloc(GPTR, realLen*sizeof(WCHAR));
int rval = popstringn(wideStr, realLen);
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, realLen, NULL, NULL);
GlobalFree((HGLOBAL)wideStr);
return rval;
}
void NSISCALL PushStringA(LPCSTR ansiStr)
{
LPWSTR wideStr = (LPWSTR) GlobalAlloc(GPTR, g_stringsize*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
pushstring(wideStr);
GlobalFree((HGLOBAL)wideStr);
return;
}
void NSISCALL GetUserVariableW(const int varnum, LPWSTR wideStr)
{
lstrcpyW(wideStr, getuservariable(varnum));
}
void NSISCALL GetUserVariableA(const int varnum, LPSTR ansiStr)
{
LPWSTR wideStr = getuservariable(varnum);
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
}
void NSISCALL SetUserVariableA(const int varnum, LPCSTR ansiStr)
{
if (ansiStr && isvalidnsisvarindex(varnum))
{
LPWSTR wideStr = g_variables + varnum * g_stringsize;
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
}
}
#else
// ANSI defs
int NSISCALL PopStringW(LPWSTR wideStr)
{
LPSTR ansiStr = (LPSTR) GlobalAlloc(GPTR, g_stringsize);
int rval = popstring(ansiStr);
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
GlobalFree((HGLOBAL)ansiStr);
return rval;
}
int NSISCALL PopStringNW(LPWSTR wideStr, int maxlen)
{
int realLen = maxlen ? maxlen : g_stringsize;
LPSTR ansiStr = (LPSTR) GlobalAlloc(GPTR, realLen);
int rval = popstringn(ansiStr, realLen);
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, realLen);
GlobalFree((HGLOBAL)ansiStr);
return rval;
}
void NSISCALL PushStringW(LPWSTR wideStr)
{
LPSTR ansiStr = (LPSTR) GlobalAlloc(GPTR, g_stringsize);
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
pushstring(ansiStr);
GlobalFree((HGLOBAL)ansiStr);
}
void NSISCALL GetUserVariableW(const int varnum, LPWSTR wideStr)
{
LPSTR ansiStr = getuservariable(varnum);
MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, wideStr, g_stringsize);
}
void NSISCALL GetUserVariableA(const int varnum, LPSTR ansiStr)
{
lstrcpyA(ansiStr, getuservariable(varnum));
}
void NSISCALL SetUserVariableW(const int varnum, LPCWSTR wideStr)
{
if (wideStr && isvalidnsisvarindex(varnum))
{
LPSTR ansiStr = g_variables + varnum * g_stringsize;
WideCharToMultiByte(CP_ACP, 0, wideStr, -1, ansiStr, g_stringsize, NULL, NULL);
}
}
#endif
// playing with integers
INT_PTR NSISCALL nsishelper_str_to_ptr(LPCTSTR s)
{
INT_PTR v=0;
if (*s == _T('0') && (s[1] == _T('x') || s[1] == _T('X')))
{
s++;
for (;;)
{
int c=*(++s);
if (c >= _T('0') && c <= _T('9')) c-=_T('0');
else if (c >= _T('a') && c <= _T('f')) c-=_T('a')-10;
else if (c >= _T('A') && c <= _T('F')) c-=_T('A')-10;
else break;
v<<=4;
v+=c;
}
}
else if (*s == _T('0') && s[1] <= _T('7') && s[1] >= _T('0'))
{
for (;;)
{
int c=*(++s);
if (c >= _T('0') && c <= _T('7')) c-=_T('0');
else break;
v<<=3;
v+=c;
}
}
else
{
int sign=0;
if (*s == _T('-')) sign++; else s--;
for (;;)
{
int c=*(++s) - _T('0');
if (c < 0 || c > 9) break;
v*=10;
v+=c;
}
if (sign) v = -v;
}
return v;
}
unsigned int NSISCALL myatou(LPCTSTR s)
{
unsigned int v=0;
for (;;)
{
unsigned int c=*s++;
if (c >= _T('0') && c <= _T('9')) c-=_T('0');
else break;
v*=10;
v+=c;
}
return v;
}
int NSISCALL myatoi_or(LPCTSTR s)
{
int v=0;
if (*s == _T('0') && (s[1] == _T('x') || s[1] == _T('X')))
{
s++;
for (;;)
{
int c=*(++s);
if (c >= _T('0') && c <= _T('9')) c-=_T('0');
else if (c >= _T('a') && c <= _T('f')) c-=_T('a')-10;
else if (c >= _T('A') && c <= _T('F')) c-=_T('A')-10;
else break;
v<<=4;
v+=c;
}
}
else if (*s == _T('0') && s[1] <= _T('7') && s[1] >= _T('0'))
{
for (;;)
{
int c=*(++s);
if (c >= _T('0') && c <= _T('7')) c-=_T('0');
else break;
v<<=3;
v+=c;
}
}
else
{
int sign=0;
if (*s == _T('-')) sign++; else s--;
for (;;)
{
int c=*(++s) - _T('0');
if (c < 0 || c > 9) break;
v*=10;
v+=c;
}
if (sign) v = -v;
}
// Support for simple ORed expressions
if (*s == _T('|'))
{
v |= myatoi_or(s+1);
}
return v;
}
INT_PTR NSISCALL popintptr()
{
TCHAR buf[128];
if (popstringn(buf,COUNTOF(buf)))
return 0;
return nsishelper_str_to_ptr(buf);
}
int NSISCALL popint_or()
{
TCHAR buf[128];
if (popstringn(buf,COUNTOF(buf)))
return 0;
return myatoi_or(buf);
}
void NSISCALL pushintptr(INT_PTR value)
{
TCHAR buffer[30];
wsprintf(buffer, sizeof(void*) > 4 ? _T("%Id") : _T("%d"), value);
pushstring(buffer);
}

108
include/nsis/pluginapi.h Normal file
View File

@ -0,0 +1,108 @@
#ifndef ___NSIS_PLUGIN__H___
#define ___NSIS_PLUGIN__H___
#ifdef __cplusplus
extern "C" {
#endif
#include "api.h"
#include "nsis_tchar.h" // BUGBUG: Why cannot our plugins use the compilers tchar.h?
#ifndef NSISCALL
# define NSISCALL WINAPI
#endif
#define EXDLL_INIT() { \
g_stringsize=string_size; \
g_stacktop=stacktop; \
g_variables=variables; }
typedef struct _stack_t {
struct _stack_t *next;
#ifdef UNICODE
WCHAR text[1]; // this should be the length of g_stringsize when allocating
#else
char text[1];
#endif
} stack_t;
enum
{
INST_0, // $0
INST_1, // $1
INST_2, // $2
INST_3, // $3
INST_4, // $4
INST_5, // $5
INST_6, // $6
INST_7, // $7
INST_8, // $8
INST_9, // $9
INST_R0, // $R0
INST_R1, // $R1
INST_R2, // $R2
INST_R3, // $R3
INST_R4, // $R4
INST_R5, // $R5
INST_R6, // $R6
INST_R7, // $R7
INST_R8, // $R8
INST_R9, // $R9
INST_CMDLINE, // $CMDLINE
INST_INSTDIR, // $INSTDIR
INST_OUTDIR, // $OUTDIR
INST_EXEDIR, // $EXEDIR
INST_LANG, // $LANGUAGE
__INST_LAST
};
extern unsigned int g_stringsize;
extern stack_t **g_stacktop;
extern LPTSTR g_variables;
void NSISCALL pushstring(LPCTSTR str);
void NSISCALL pushintptr(INT_PTR value);
#define pushint(v) pushintptr((INT_PTR)(v))
int NSISCALL popstring(LPTSTR str); // 0 on success, 1 on empty stack
int NSISCALL popstringn(LPTSTR str, int maxlen); // with length limit, pass 0 for g_stringsize
INT_PTR NSISCALL popintptr();
#define popint() ( (int) popintptr() )
int NSISCALL popint_or(); // with support for or'ing (2|4|8)
INT_PTR NSISCALL nsishelper_str_to_ptr(LPCTSTR s);
#define myatoi(s) ( (int) nsishelper_str_to_ptr(s) ) // converts a string to an integer
unsigned int NSISCALL myatou(LPCTSTR s); // converts a string to an unsigned integer, decimal only
int NSISCALL myatoi_or(LPCTSTR s); // with support for or'ing (2|4|8)
LPTSTR NSISCALL getuservariable(const int varnum);
void NSISCALL setuservariable(const int varnum, LPCTSTR var);
#ifdef UNICODE
#define PopStringW(x) popstring(x)
#define PushStringW(x) pushstring(x)
#define SetUserVariableW(x,y) setuservariable(x,y)
int NSISCALL PopStringA(LPSTR ansiStr);
void NSISCALL PushStringA(LPCSTR ansiStr);
void NSISCALL GetUserVariableW(const int varnum, LPWSTR wideStr);
void NSISCALL GetUserVariableA(const int varnum, LPSTR ansiStr);
void NSISCALL SetUserVariableA(const int varnum, LPCSTR ansiStr);
#else
// ANSI defs
#define PopStringA(x) popstring(x)
#define PushStringA(x) pushstring(x)
#define SetUserVariableA(x,y) setuservariable(x,y)
int NSISCALL PopStringW(LPWSTR wideStr);
void NSISCALL PushStringW(LPWSTR wideStr);
void NSISCALL GetUserVariableW(const int varnum, LPWSTR wideStr);
void NSISCALL GetUserVariableA(const int varnum, LPSTR ansiStr);
void NSISCALL SetUserVariableW(const int varnum, LPCWSTR wideStr);
#endif
#ifdef __cplusplus
}
#endif
#endif//!___NSIS_PLUGIN__H___

17341
include/wuapi.h Normal file

File diff suppressed because it is too large Load Diff

2581
include/wuerror.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
#define CINTERFACE
#define COBJMACROS
#include <windows.h>
#include <nsis/pluginapi.h>
#include <wuapi.h>
#include "main.h"
static const GUID our_CLSID_UpdateServiceManager = { 0xf8d253d9, 0x89a4, 0x4daa, { 0x87, 0xb6, 0x11, 0x68, 0x36, 0x9f, 0x0b, 0x21 } };
static const GUID our_IID_IUpdateServiceManager2 = { 0x0bb8531d, 0x7e8d, 0x424f, { 0x98, 0x6c, 0xa0, 0xb8, 0xf6, 0x0a, 0x3e, 0x7b } };
static const LPWSTR MicrosoftUpdateServiceID = L"7971f918-a847-4430-9279-4a52d1efe18d";
EXTERN_C __declspec(dllexport)
void __cdecl EnableMicrosoftUpdate(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) {
EXDLL_INIT();
g_hwndParent = hwndParent;
IUpdateServiceManager2 *serviceManager;
IUpdateServiceRegistration *registration;
HRESULT hr = CoCreateInstance(our_CLSID_UpdateServiceManager, NULL, CLSCTX_INPROC_SERVER, our_IID_IUpdateServiceManager2, (void **)&serviceManager);
if (!SUCCEEDED(hr)) {
goto end;
}
hr = IUpdateServiceManager2_AddService2(serviceManager, SysAllocString(MicrosoftUpdateServiceID), asfAllowPendingRegistration | asfAllowOnlineRegistration | asfRegisterServiceWithAU, SysAllocString(L""), &registration);
if (!SUCCEEDED(hr)) {
goto end;
}
end:
if (registration != NULL) {
IUpdateServiceManager2_Release(registration);
}
if (serviceManager != NULL) {
IUpdateServiceManager2_Release(serviceManager);
}
pushint(hr);
}

View File

@ -0,0 +1,45 @@
#include <windows.h>
#include <nsis/pluginapi.h>
#include <psapi.h>
#include "main.h"
EXTERN_C __declspec(dllexport)
void __cdecl IsProcessRunning(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) {
EXDLL_INIT();
g_hwndParent = hwndParent;
LPTSTR process = (LPTSTR)malloc(string_size * sizeof(TCHAR));
popstring(process);
CharLowerBuffW(process, wcslen(process));
// Yes, eat all of our SHRTs!
DWORD pids[SHRT_MAX];
DWORD bytesReturned;
if (!EnumProcesses(pids, sizeof(pids), &bytesReturned)) {
pushstring(L"0");
return;
}
DWORD count = bytesReturned / sizeof(DWORD);
for (DWORD i = 0; i < count; ++i) {
HANDLE handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_VM_READ, FALSE, pids[i]);
if (handle) {
WCHAR path[MAX_PATH];
if (GetProcessImageFileName(handle, path, ARRAYSIZE(path))) {
LPWSTR basename = wcsrchr(path, L'\\');
if (basename != NULL) {
basename += 1;
CharLowerBuffW(basename, wcslen(basename));
if (_wcsicmp(process, basename) == 0) {
pushstring(L"1");
CloseHandle(handle);
return;
}
}
}
CloseHandle(handle);
}
}
pushstring(L"0");
}

110
nsisplugin/Makefile Normal file
View File

@ -0,0 +1,110 @@
FILES = \
$(wildcard *.c) \
../include/nsis/pluginapi.c \
../Shared/HResult.c \
../Shared/WUErrors.c
RCFILES = resource.rc
BIN = obj/LegacyUpdateNSIS.dll
DEF = $(patsubst %.dll,%.def,$(BIN))
STATIC = $(patsubst %.dll,%.a,$(BIN))
OBJ = $(foreach file,$(FILES),obj/$(notdir $(basename $(file)).o))
RES = $(foreach file,$(RCFILES),obj/$(notdir $(basename $(file)).res))
PREFIX = i686-w64-mingw32-
CC = $(PREFIX)g++
RC = $(PREFIX)windres
override DEBUG := $(or $(DEBUG),1)
CFLAGS = \
-std=c++11 \
-march=i486 \
-mdll \
-municode \
-DUNICODE \
-D_UNICODE \
$(if $(filter 1,$(DEBUG)),-D_DEBUG -g,-DNDEBUG -Os) \
-D__USE_MINGW_ANSI_STDIO=0 \
-D_USRDLL \
-s \
-fPIE \
-ffunction-sections \
-fdata-sections \
-fno-unwind-tables \
-fno-asynchronous-unwind-tables \
-fno-exceptions \
-fno-rtti \
-flto \
-Wno-write-strings \
-I../include \
-I../shared \
-include stdafx.h
LDFLAGS = \
-nodefaultlibs \
-nostartfiles \
-nostdlib \
-Wl,--gc-sections \
-Wl,--no-seh \
-Wl,--nxcompat \
-Wl,--enable-auto-image-base \
-Wl,--enable-stdcall-fixup \
-Wl,--output-def,$(DEF) \
-Wl,--out-implib,$(STATIC) \
-Wl,--strip-all \
-Wl,-e_DllMain \
-lmsvcrt \
-lgcc \
-lpsapi \
-lkernel32 \
-luser32 \
-lole32 \
-loleaut32
RCFLAGS = \
-F pe-i386 \
-O coff
all: before-all $(BIN) after-all
before-all:
mkdir -p obj
after-all:
ifeq ($(SIGN),1)
../build/sign.sh $(BIN)
endif
cp $(BIN) ../setup/x86-unicode/
$(BIN): $(OBJ) $(RES)
$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@
obj/%.o: %.c
$(CC) $< $(CFLAGS) -c -o $@
obj/%.o: %.cpp
$(CC) $< $(CFLAGS) -c -o $@
obj/%.o: ../shared/%.c
$(CC) $< $(CFLAGS) -c -o $@
obj/%.o: ../shared/%.cpp
$(CC) $< $(CFLAGS) -c -o $@
obj/%.o: ../include/nsis/%.c
$(CC) $< $(CFLAGS) -c -o $@
obj/%.res: %.rc
$(RC) $< $(RCFLAGS) -o $@
clean:
rm -rf obj
test:
$(MAKE) DEBUG=$(DEBUG)
cd ../setup && makensis test.nsi
cd ../setup && explorer.exe test.exe
.PHONY: all before-all after-all clean test

View File

@ -0,0 +1,14 @@
#include <windows.h>
#include <nsis/pluginapi.h>
#include "../shared/HResult.h"
EXTERN_C __declspec(dllexport)
void __cdecl MessageForHresult(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) {
EXDLL_INIT();
g_hwndParent = hwndParent;
HRESULT hr = popint();
LPWSTR message = GetMessageForHresult(hr);
pushstring(message);
LocalFree(message);
}

View File

@ -0,0 +1,109 @@
// Based on https://nsis.sourceforge.io/TaskbarProgress_plug-in - zlib licensed
// Cleaned up and refactored into C by Legacy Update
#define CINTERFACE
#define COBJMACROS
#include <windows.h>
#include <nsis/pluginapi.h>
#include <commctrl.h>
#include <objbase.h>
#include <shobjidl.h>
#include "main.h"
static const GUID our_CLSID_ITaskbarList = { 0x56fdf344, 0xfd6d, 0x11d0, { 0x95, 0x8a, 0x00, 0x60, 0x97, 0xc9, 0xa0, 0x90 } };
static const GUID our_IID_ITaskbarList3 = { 0xea1afb91, 0x9e28, 0x4b86, { 0x90, 0xe9, 0x9e, 0x9f, 0x8a, 0x5e, 0xef, 0xaf } };
ITaskbarList3 *g_taskbarList;
UINT g_totalRange;
WNDPROC g_origWndProc;
LRESULT ProgressBarWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
if (g_origWndProc == NULL) {
return 0;
}
switch (uMsg) {
case PBM_SETRANGE:
g_totalRange = LOWORD(lParam) + HIWORD(lParam);
break;
case PBM_SETRANGE32:
g_totalRange = wParam + lParam;
break;
case PBM_SETPOS:
if (g_taskbarList != NULL) {
ITaskbarList3_SetProgressValue(g_taskbarList, g_hwndParent, wParam, g_totalRange);
}
break;
case WM_DESTROY:
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)g_origWndProc);
if (g_taskbarList != NULL) {
ITaskbarList3_SetProgressState(g_taskbarList, g_hwndParent, TBPF_NOPROGRESS);
ITaskbarList3_Release(g_taskbarList);
g_taskbarList = NULL;
}
g_origWndProc = NULL;
break;
}
return CallWindowProc(g_origWndProc, hwnd, uMsg, wParam, lParam);
}
UINT_PTR NSISPluginCallback(enum NSPIM event) {
// Does nothing, but keeping a callback registered prevents NSIS from unloading the plugin
return 0;
}
EXTERN_C __declspec(dllexport)
void __cdecl InitTaskbarProgress(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) {
EXDLL_INIT();
g_hwndParent = hwndParent;
extra->RegisterPluginCallback(g_hInstance, NSISPluginCallback);
if (g_taskbarList != NULL && g_origWndProc != NULL) {
// Already initialised
return;
}
HWND innerWindow = FindWindowEx(g_hwndParent, NULL, L"#32770", NULL);
HWND progressBar = FindWindowEx(innerWindow, NULL, L"msctls_progress32", NULL);
PBRANGE range;
HRESULT hr;
if (progressBar == NULL) {
goto fail;
}
hr = CoCreateInstance(our_CLSID_ITaskbarList, NULL, CLSCTX_INPROC_SERVER, our_IID_ITaskbarList3, (void**)&g_taskbarList);
if (!SUCCEEDED(hr)) {
goto fail;
}
hr = ITaskbarList3_HrInit(g_taskbarList);
if (!SUCCEEDED(hr)) {
goto fail;
}
// Get the initial progress bar range
SendMessage(progressBar, PBM_GETRANGE, 0, (LPARAM)&range);
g_totalRange = range.iLow + range.iHigh;
// Add our own window procedure so we can respond to progress bar updates
g_origWndProc = (WNDPROC)SetWindowLongPtr(progressBar, GWLP_WNDPROC, (LONG_PTR)ProgressBarWndProc);
if (g_origWndProc == NULL) {
goto fail;
}
return;
fail:
if (g_taskbarList != NULL) {
ITaskbarList3_Release(g_taskbarList);
g_taskbarList = NULL;
}
g_origWndProc = NULL;
}

10
nsisplugin/main.c Normal file
View File

@ -0,0 +1,10 @@
#include <windows.h>
#include <nsis/pluginapi.h>
HMODULE g_hInstance;
HWND g_hwndParent;
EXTERN_C BOOL WINAPI DllMain(HMODULE hInstance, UINT iReason, LPVOID lpReserved) {
g_hInstance = hInstance;
return TRUE;
}

4
nsisplugin/main.h Normal file
View File

@ -0,0 +1,4 @@
#include <windows.h>
EXTERN_C HMODULE g_hInstance;
EXTERN_C HWND g_hwndParent;

0
nsisplugin/resource.h Normal file
View File

53
nsisplugin/resource.rc Normal file
View File

@ -0,0 +1,53 @@
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
#include <windows.h>
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(65001)
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,9,0,0
PRODUCTVERSION 1,9,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Hashbang Productions"
VALUE "FileDescription", "Legacy Update Setup Helper"
VALUE "FileVersion", "1.9.0.0"
VALUE "InternalName", "LegacyUpdateNSIS.dll"
VALUE "LegalCopyright", "© Hashbang Productions. All rights reserved."
VALUE "OriginalFilename", "LegacyUpdateNSIS.dll"
VALUE "ProductName", "Legacy Update"
VALUE "ProductVersion", "1.9.0.0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

16
nsisplugin/stdafx.h Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#ifndef STRICT
#define STRICT
#endif
#define WINVER 0x0500
#define _WIN32_WINNT 0x0500
#define ISOLATION_AWARE_ENABLED 1 // Enable comctl 6.0 (visual styles)
#include "resource.h"
#include <windows.h>
EXTERN_C HWND g_hwndParent;

BIN
setup/7z.exe Normal file

Binary file not shown.

4
setup/7zip.nsh Normal file
View File

@ -0,0 +1,4 @@
Function Install7Zip
File 7z.exe
!insertmacro Install "7-Zip" "7z.exe" "/S"
FunctionEnd

9
setup/ActiveX.inf Normal file
View File

@ -0,0 +1,9 @@
[Version]
Signature="$CHICAGO$"
AdvancedINF=2.0
[Setup Hooks]
setup=setup
[setup]
run="%EXTRACT_DIR%\setup.exe"

86
setup/AeroWizard.nsh Normal file
View File

@ -0,0 +1,86 @@
!macro SetFont font parent control
GetDlgItem $0 ${parent} ${control}
SendMessage $0 ${WM_SETFONT} ${font} 0
!macroend
!macro SetControlColor parent control color
GetDlgItem $0 ${parent} ${control}
SetCtlColors $0 ${color} SYSCLR:WINDOW
!macroend
!macro SetBackground parent control
!insertmacro SetControlColor ${parent} ${control} SYSCLR:WINDOWTEXT
!macroend
Var /GLOBAL ChildHwnd
!macro -AeroWizardOnShow
; Get the child window where the wizard page is
FindWindow $ChildHwnd "#32770" "" $HWNDPARENT
; Set font
${If} ${AtLeastWinVista}
; Aero wizard style
${If} ${AtLeastWin11}
; Semi-Fluent style
CreateFont $3 "Segoe UI Variable Display Semibold" 14 600
!insertmacro SetControlColor $HWNDPARENT 1037 SYSCLR:WINDOWTEXT
${Else}
CreateFont $3 "Segoe UI" 12 400
!insertmacro SetControlColor $HWNDPARENT 1037 0x003399
${EndIf}
CreateFont $2 "Segoe UI" 8 400
!insertmacro SetFont $3 $HWNDPARENT 1037
!insertmacro SetFont $2 $HWNDPARENT 1
!insertmacro SetFont $2 $HWNDPARENT 2
!insertmacro SetFont $2 $HWNDPARENT 3
!insertmacro SetFont $2 $HWNDPARENT 1028
!insertmacro SetFont $2 $ChildHwnd 1000
!insertmacro SetFont $2 $ChildHwnd 1004
!insertmacro SetFont $2 $ChildHwnd 1006
!insertmacro SetFont $2 $ChildHwnd 1016
!insertmacro SetFont $2 $ChildHwnd 1022
!insertmacro SetFont $2 $ChildHwnd 1023
!insertmacro SetFont $2 $ChildHwnd 1029
!insertmacro SetFont $2 $ChildHwnd 1027
!insertmacro SetFont $2 $ChildHwnd 1032
!insertmacro SetFont $2 $ChildHwnd 1043
${Else}
; Wizard97 style
${If} ${FileExists} "$FONTS\framd.ttf"
CreateFont $2 "Franklin Gothic Medium" 13 400
!insertmacro SetFont $2 $HWNDPARENT 1037
!insertmacro SetControlColor $HWNDPARENT 1037 0x003399
${Else}
CreateFont $2 "Verdana" 12 800
!insertmacro SetFont $2 $HWNDPARENT 1037
!insertmacro SetControlColor $HWNDPARENT 1037 SYSCLR:WINDOWTEXT
${EndIf}
${EndIf}
; Set white background
SetCtlColors $HWNDPARENT SYSCLR:WINDOWTEXT SYSCLR:WINDOW
SetCtlColors $ChildHwnd SYSCLR:WINDOWTEXT SYSCLR:WINDOW
!insertmacro SetBackground $ChildHwnd 1020
!insertmacro SetBackground $ChildHwnd 1028
!insertmacro SetBackground $ChildHwnd 1006
!insertmacro SetBackground $ChildHwnd 1022
!insertmacro SetBackground $ChildHwnd 1023
!insertmacro SetBackground $ChildHwnd 1027
!insertmacro SetBackground $ChildHwnd 1029
!insertmacro SetBackground $ChildHwnd 1032
!insertmacro SetBackground $ChildHwnd 1043
; Activate taskbar progress bar plugin
${If} ${AtLeastWin7}
LegacyUpdateNSIS::InitTaskbarProgress
${EndIf}
!macroend
Function AeroWizardOnShow
!insertmacro -AeroWizardOnShow
FunctionEnd
Function un.AeroWizardOnShow
!insertmacro -AeroWizardOnShow
FunctionEnd

258
setup/Common.nsh Normal file
View File

@ -0,0 +1,258 @@
!addplugindir /x86-unicode x86-unicode
SetPluginUnload alwaysoff
!if ${SIGN} == 1
!finalize '../build/sign.sh "%1"'
!uninstfinalize '../build/sign.sh "%1"'
!endif
!define IsNativeIA64 '${IsNativeMachineArchitecture} ${IMAGE_FILE_MACHINE_IA64}'
Function GetArch
Var /GLOBAL Arch
${If} $Arch == ""
${If} ${IsNativeIA32}
StrCpy $Arch "x86"
${ElseIf} ${IsNativeAMD64}
StrCpy $Arch "x64"
${ElseIf} ${IsNativeIA64}
StrCpy $Arch "ia64"
${Else}
StrCpy $Arch ""
${EndIf}
${EndIf}
Push $Arch
FunctionEnd
!macro _HasFlag _a _b _t _f
!insertmacro _LOGICLIB_TEMP
${GetParameters} $_LOGICLIB_TEMP
ClearErrors
${GetOptions} $_LOGICLIB_TEMP `${_b}` $_LOGICLIB_TEMP
IfErrors `${_f}` `${_t}`
!macroend
!define IsActiveXInstall `"" HasFlag "/activex"`
!define IsHelp `"" HasFlag "/?"`
!macro DetailPrint text
SetDetailsPrint both
DetailPrint "${text}"
SetDetailsPrint listonly
!macroend
Var /GLOBAL Download.ID
!macro DownloadRequest url local extra
NSxfer::Request \
/TIMEOUTCONNECT 60000 \
/TIMEOUTRECONNECT 60000 \
/OPTCONNECTTIMEOUT 60000 \
/OPTRECEIVETIMEOUT 60000 \
/OPTSENDTIMEOUT 60000 \
/URL "${url}" \
/LOCAL "${local}" \
/INTERNETFLAGS ${INTERNET_FLAG_RELOAD}|${INTERNET_FLAG_NO_CACHE_WRITE}|${INTERNET_FLAG_KEEP_CONNECTION}|${INTERNET_FLAG_NO_COOKIES}|${INTERNET_FLAG_NO_UI} \
/SECURITYFLAGS ${SECURITY_FLAG_STRENGTH_STRONG} \
${extra} \
/END
Pop $Download.ID
!macroend
Function DownloadWaitSilent
NSxfer::Wait /ID $Download.ID /MODE SILENT /END
NSxfer::Query /ID $Download.ID /ERRORCODE /ERRORTEXT /END
FunctionEnd
Function DownloadWait
NSxfer::Wait /ID $Download.ID /MODE PAGE \
/STATUSTEXT \
"{TIMEREMAINING} left - {RECVSIZE} of {FILESIZE} ({SPEED})" \
"{TIMEREMAINING} left - {TOTALRECVSIZE} of {TOTALFILESIZE} ({SPEED})" \
/ABORT "Legacy Update" "Cancelling will terminate Legacy Update setup." \
/END
NSxfer::Query /ID $Download.ID /ERRORCODE /ERRORTEXT /END
FunctionEnd
!macro -Download name url filename verbose
!insertmacro DetailPrint "Downloading ${name}..."
!insertmacro DownloadRequest "${url}" "${filename}" ""
${If} ${verbose} == 1
Call DownloadWait
${Else}
Call DownloadWaitSilent
${EndIf}
Pop $1
Pop $0
${If} $0 != "OK"
${If} $1 != ${ERROR_INTERNET_OPERATION_CANCELLED}
MessageBox MB_USERICON "${name} failed to download.$\r$\n$\r$\n$0 ($1)" /SD IDOK
${EndIf}
Delete /REBOOTOK "${filename}"
SetErrorLevel 1
Abort
${EndIf}
!macroend
!macro Download name url filename verbose
${If} ${FileExists} "$EXEDIR\${filename}"
${If} $OUTDIR != "$EXEDIR"
SetOutPath "$EXEDIR"
${EndIf}
StrCpy $0 "$EXEDIR\${filename}"
${Else}
${If} $OUTDIR != "$RunOnceDir"
SetOutPath "$RunOnceDir"
${EndIf}
${IfNot} ${FileExists} "$RunOnceDir\${filename}"
!insertmacro -Download '${name}' '${url}' '$RunOnceDir\${filename}' ${verbose}
${EndIf}
StrCpy $0 "$RunOnceDir\${filename}"
${EndIf}
!macroend
Var /GLOBAL Exec.Command
Var /GLOBAL Exec.Name
Var /GLOBAL Exec.IsWusa
Function ExecWithErrorHandling
Push $0
ExecWait '$Exec.Command' $0
${If} $0 == ${ERROR_SUCCESS_REBOOT_REQUIRED}
SetRebootFlag true
${ElseIf} $0 == ${ERROR_INSTALL_USEREXIT}
SetErrorLevel ${ERROR_INSTALL_USEREXIT}
Abort
${ElseIf} $Exec.IsWusa == 1
${AndIf} $0 == 1
; wusa exits with 1 if the patch is already installed. Treat this as success.
DetailPrint "Installation skipped - already installed"
${ElseIf} $Exec.IsWusa == 1
${AndIf} $0 == ${WU_S_ALREADY_INSTALLED}
DetailPrint "Installation skipped - already installed"
${ElseIf} $Exec.IsWusa == 1
${AndIf} $0 == ${WU_E_NOT_APPLICABLE}
DetailPrint "Installation skipped - not applicable"
${ElseIf} $0 != 0
LegacyUpdateNSIS::MessageForHresult $0
Pop $1
MessageBox MB_USERICON "$Exec.Name failed to install.$\r$\n$\r$\n$1 ($0)" /SD IDOK
SetErrorLevel $0
Abort
${EndIf}
Pop $0
FunctionEnd
!macro ExecWithErrorHandling name command iswusa
StrCpy $Exec.Command '${command}'
StrCpy $Exec.Name '${name}'
StrCpy $Exec.IsWusa '${iswusa}'
Call ExecWithErrorHandling
!macroend
!macro Install name filename args
!insertmacro DetailPrint "Installing ${name}..."
!insertmacro ExecWithErrorHandling '${name}' '"$0" ${args}' 0
!macroend
!macro InstallSP name filename
; SPInstall.exe /norestart seems to be broken. We let it do a delayed restart, then cancel it.
!insertmacro DetailPrint "Extracting ${name}..."
!insertmacro ExecWithErrorHandling '${name}' '"$0" /X:"$PLUGINSDIR\${filename}"' 0
!insertmacro DetailPrint "Installing ${name}..."
!insertmacro ExecWithErrorHandling '${name}' '"$PLUGINSDIR\${filename}\spinstall.exe" /unattend /nodialog /warnrestart:600' 0
; If we successfully abort a shutdown, we'll get exit code 0, so we know a reboot is required.
ExecWait "$WINDIR\system32\shutdown.exe /a" $0
${If} $0 == 0
SetRebootFlag true
${EndIf}
!macroend
!macro DownloadMSU kbid name url
!insertmacro Download '${name} (${kbid})' '${url}' '${kbid}.msu' 1
!macroend
!macro InstallMSU kbid name
; Stop AU service before running wusa so it doesn't try checking for updates online first (which
; may never complete before we install our patches).
!insertmacro DetailPrint "Installing ${name} (${kbid})..."
SetDetailsPrint none
ExecShellWait "" "$WINDIR\system32\net.exe" "stop wuauserv" SW_HIDE
SetDetailsPrint listonly
!insertmacro ExecWithErrorHandling '${name} (${kbid})' '$WINDIR\system32\wusa.exe /quiet /norestart "$0"' 1
!macroend
!macro EnsureAdminRights
${IfNot} ${AtLeastWin2000}
MessageBox MB_USERICON "Legacy Update requires at least Windows 2000." /SD IDOK
SetErrorLevel ${ERROR_OLD_WIN_VERSION}
Quit
${EndIf}
System::Call '${IsUserAnAdmin}() .r0'
${If} $0 == 0
MessageBox MB_USERICON "Log on as an administrator to install Legacy Update." /SD IDOK
SetErrorLevel ${ERROR_ELEVATION_REQUIRED}
Quit
${EndIf}
!macroend
!macro InhibitSleep state
${If} ${state} == 1
System::Call '${SetThreadExecutionState}(${ES_CONTINUOUS}|${ES_SYSTEM_REQUIRED})'
${Else}
System::Call '${SetThreadExecutionState}(${ES_CONTINUOUS})'
${EndIf}
!macroend
!macro TryWithRetry command error
ClearErrors
${command}
IfErrors 0 +3
MessageBox MB_RETRYCANCEL|MB_USERICON \
'${error}$\r$\n$\r$\nIf Internet Explorer is open, close it and click Retry.' \
/SD IDCANCEL \
IDRETRY -3
Abort
!macroend
!macro TryFile file oname
!insertmacro TryWithRetry `File "/ONAME=${oname}" "${file}"` 'Unable to write to "${oname}".'
!macroend
!macro TryDelete file
!insertmacro TryWithRetry `Delete "${file}"` 'Unable to delete "${file}".'
!macroend
!macro TryRename src dest
!insertmacro TryWithRetry `Rename "${src}" "${dest}"` 'Unable to write to "${dest}".'
!macroend
!macro RegisterDLL un arch file
${If} "${un}" == "Un"
StrCpy $0 "/u"
${Else}
StrCpy $0 ""
${EndIf}
${If} "${arch}" == "x64"
${DisableX64FSRedirection}
${EndIf}
ClearErrors
ExecWait '"$WINDIR\system32\regsvr32.exe" /s $0 "${file}"'
${If} ${Errors}
; Do it again non-silently so the user can see the error.
ExecWait '"$WINDIR\system32\regsvr32.exe" $0 "${file}"'
${If} "${arch}" == "x64"
${EnableX64FSRedirection}
${EndIf}
Abort
${EndIf}
${If} "${arch}" == "x64"
${EnableX64FSRedirection}
${EndIf}
!macroend

51
setup/Constants.nsh Normal file
View File

@ -0,0 +1,51 @@
; Product
!define NAME "WUIsBack"
!define DOMAIN "legacyupdate.net"
; Version
!getdllversion "..\Release\LegacyUpdate.dll" DLLVersion_
!define LONGVERSION "${DLLVersion_1}.${DLLVersion_2}.${DLLVersion_3}.${DLLVersion_4}"
!define VERSION "${DLLVersion_1}.${DLLVersion_2}.${DLLVersion_3}"
!if ${DLLVersion_3} == 0
!define /redef VERSION "${DLLVersion_1}.${DLLVersion_2}"
!endif
; Main URLs
!define WEBSITE "http://legacyupdate.net/"
!define UPDATE_URL "http://legacyupdate.net/windowsupdate/v6/"
!define UPDATE_URL_HTTPS "https://legacyupdate.net/windowsupdate/v6/"
!define WSUS_SERVER "http://fritzbox3272.controlliamo.com/WUIsBack/v6"
!define WSUS_SERVER_HTTPS "https://fritzbox3272.controlliamo.com/WUIsBack/v6"
!define TRUSTEDR "http://download.windowsupdate.com/msdownload/update/v3/static/trustedr/en"
!define WIN81UPGRADE_URL "https://go.microsoft.com/fwlink/?LinkId=798437"
; Control Panel entry
!define CPL_GUID "{FFBE8D44-E9CF-4DD8-9FD6-976802C94D9C}"
!define CPL_APPNAME "LegacyUpdate"
; RunOnce
!define RUNONCE_USERNAME "LegacyUpdateTemp"
!define RUNONCE_PASSWORD "Legacy_Update0"
; Registry keys
!define REGPATH_LEGACYUPDATE_SETUP "Software\Hashbang Productions\Legacy Update\Setup"
!define REGPATH_UNINSTSUBKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
!define REGPATH_WUPOLICY "Software\Policies\Microsoft\Windows\WindowsUpdate"
!define REGPATH_WUAUPOLICY "${REGPATH_WUPOLICY}\AU"
!define REGPATH_WU "Software\Microsoft\Windows\CurrentVersion\WindowsUpdate"
!define REGPATH_WU_SERVICES "${REGPATH_WU}\Services"
!define REGPATH_INETSETTINGS "Software\Microsoft\Windows\CurrentVersion\Internet Settings"
!define REGPATH_ZONEDOMAINS "${REGPATH_INETSETTINGS}\ZoneMap\Domains"
!define REGPATH_ZONEESCDOMAINS "${REGPATH_INETSETTINGS}\ZoneMap\EscDomains"
!define REGPATH_CPLNAMESPACE "Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\NameSpace\${CPL_GUID}"
!define REGPATH_CPLCLSID "CLSID\${CPL_GUID}"
!define REGPATH_WINLOGON "Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
!define REGPATH_POSREADY "System\WPA\PosReady"
!define REGPATH_SCHANNEL_PROTOCOLS "System\CurrentControlSet\Control\SecurityProviders\SChannel\Protocols"
!define REGPATH_DOTNET_V2 "Software\Microsoft\.NETFramework\v2.0.50727"
!define REGPATH_DOTNET_V4 "Software\Microsoft\.NETFramework\v4.0.30319"
!define REGPATH_RUNONCE "Software\Microsoft\Windows\CurrentVersion\RunOnce"
!define REGPATH_PACKAGEINDEX "Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\PackageIndex"
!define REGPATH_SERVICING_SHA2 "Software\Microsoft\Windows\CurrentVersion\Servicing\Codesigning\SHA2"
!define REGPATH_COMPONENT_THEMES "Software\Microsoft\Active Setup\Installed Components\{2C7339CF-2B09-4501-B3F3-F3508C9228ED}"

122
setup/Download2KXP.nsh Normal file
View File

@ -0,0 +1,122 @@
Function GetUpdateLanguage
Var /GLOBAL UpdateLanguage
${If} $UpdateLanguage == ""
ReadRegStr $UpdateLanguage HKLM "Hardware\Description\System" "Identifier"
${If} $UpdateLanguage == "NEC PC-98"
StrCpy $UpdateLanguage "NEC98"
${Else}
ReadRegStr $UpdateLanguage HKLM "System\CurrentControlSet\Control\Nls\Language" "InstallLanguage"
ReadINIStr $UpdateLanguage $PLUGINSDIR\Patches.ini Language $UpdateLanguage
${EndIf}
${EndIf}
Push $UpdateLanguage
FunctionEnd
!macro NeedsSPHandler name os sp
Function Needs${name}
${If} ${Is${os}}
${AndIf} ${AtMostServicePack} ${sp}
Push 1
${Else}
Push 0
${EndIf}
FunctionEnd
!macroend
!macro NeedsFileVersionHandler name file version
Function Needs${name}
${GetFileVersion} "$SYSDIR\${file}" $0
${VersionCompare} $0 ${version} $1
${If} $1 == 2 ; Less than
Push 1
${Else}
Push 0
${EndIf}
FunctionEnd
!macroend
Var /GLOBAL Patch.Key
Var /GLOBAL Patch.File
Var /GLOBAL Patch.Title
Function -PatchHandler
Call GetUpdateLanguage
Call GetArch
Pop $1
Pop $0
ClearErrors
ReadINIStr $0 $PLUGINSDIR\Patches.ini "$Patch.Key" $0-$1
${If} ${Errors}
; Language neutral
ClearErrors
ReadINIStr $0 $PLUGINSDIR\Patches.ini "$Patch.Key" $1
${If} ${Errors}
MessageBox MB_USERICON "$Patch.Title could not be installed.$\r$\n$\r$\nThe installed Windows language and/or architecture is not supported." /SD IDOK
SetErrorLevel 1
Abort
${EndIf}
${EndIf}
!insertmacro Download "$Patch.Title" "$0" "$Patch.File" 1
FunctionEnd
!macro PatchHandler kbid title params
Function Download${kbid}
Call Needs${kbid}
Pop $0
${If} $0 == 1
StrCpy $Patch.Key "${kbid}"
StrCpy $Patch.File "${kbid}.exe"
StrCpy $Patch.Title "${title}"
Call -PatchHandler
${EndIf}
FunctionEnd
Function Install${kbid}
Call Needs${kbid}
Pop $0
${If} $0 == 1
Call Download${kbid}
!insertmacro Install "${title}" "${kbid}.exe" "${params}"
${EndIf}
FunctionEnd
!macroend
!insertmacro NeedsSPHandler "W2KSP4" "Win2000" 2
!insertmacro NeedsSPHandler "XPSP2" "WinXP2002" 0
!insertmacro NeedsSPHandler "XPSP3" "WinXP2002" 2
!insertmacro NeedsSPHandler "XPESP3" "WinXP2002" 2
!insertmacro NeedsSPHandler "2003SP2" "WinXP2003" 1
!insertmacro NeedsFileVersionHandler "KB835732" "kernel32.dll" "5.00.2195.6897"
!insertmacro NeedsFileVersionHandler "IE6" "mshtml.dll" "6.0.2600.0"
!insertmacro PatchHandler "W2KSP4" "Windows 2000 Service Pack 4" "-u -z"
!insertmacro PatchHandler "KB835732" "Windows 2000 KB835732 Update" "/passive /norestart"
!insertmacro PatchHandler "XPSP2" "Windows XP Service Pack 2" "/passive /norestart"
!insertmacro PatchHandler "XPSP3" "Windows XP Service Pack 3" "/passive /norestart"
!insertmacro PatchHandler "2003SP2" "Windows XP x64 Edition/Server 2003 Service Pack 2" "/passive /norestart"
!insertmacro PatchHandler "XPESP3" "Windows XP Embedded Service Pack 3" "/passive /norestart"
Function DownloadIE6
Call NeedsIE6
Pop $0
${If} $0 == 1
StrCpy $Patch.Key "W2KIE6"
StrCpy $Patch.File "ie6sp1.cab"
StrCpy $Patch.Title "Internet Explorer 6 SP1"
Call -PatchHandler
${EndIf}
FunctionEnd
Function InstallIE6
Call NeedsIE6
Pop $0
${If} $0 == 1
Call DownloadIE6
!insertmacro DetailPrint "Extracting Internet Explorer 6 SP1..."
ExecShellWait "" "$WINDIR\system32\expand.exe" '"$OUTDIR\ie6sp1.cab" -F:ie6setup.exe "$PLUGINSDIR"' SW_HIDE
ExecShellWait "" "$WINDIR\system32\expand.exe" '"$OUTDIR\ie6sp1.cab" -F:iebatch.txt "$PLUGINSDIR"' SW_HIDE
!insertmacro DetailPrint "Installing Internet Explorer 6 SP1..."
!insertmacro ExecWithErrorHandling 'Internet Explorer 6 SP1' '"$PLUGINSDIR\ie6setup.exe" /q' 0
${EndIf}
FunctionEnd

46
setup/Download8.nsh Normal file
View File

@ -0,0 +1,46 @@
; Windows 8 Servicing Stack
!insertmacro MSUHandler "KB4598297" "2021-01 Servicing Stack Update for Windows Server 2012" "Package_for_KB4598297"
; Windows 8.1 Servicing Stack
!insertmacro MSUHandler "KB3021910" "2015-04 Servicing Stack Update for Windows 8.1" "Package_for_KB3021910"
; Windows 8.1 Update 1
!insertmacro MSUHandler "KB2919355" "Windows 8.1 Update 1" "Package_for_KB2919355"
!insertmacro MSUHandler "KB2932046" "Windows 8.1 Update 1" "Package_for_KB2932046"
!insertmacro MSUHandler "KB2959977" "Windows 8.1 Update 1" "Package_for_KB2959977"
!insertmacro MSUHandler "KB2937592" "Windows 8.1 Update 1" "Package_for_KB2937592"
!insertmacro MSUHandler "KB2934018" "Windows 8.1 Update 1" "Package_for_KB2934018"
Function NeedsWin81Update1
Call NeedsKB2919355
Call NeedsKB2932046
Call NeedsKB2937592
Call NeedsKB2934018
Pop $0
Pop $1
Pop $2
Pop $3
Pop $4
${If} $0 == 1
${OrIf} $1 == 1
${OrIf} $2 == 1
${OrIf} $3 == 1
Push 1
${Else}
Push 0
${EndIf}
FunctionEnd
; Weird prerequisite to Update 1 that fixes the main KB2919355 update failing to install
Function DownloadClearCompressionFlag
Call GetArch
Pop $0
ReadINIStr $0 $PLUGINSDIR\Patches.ini ClearCompressionFlag $0
!insertmacro Download "Windows 8.1 Update 1 Preparation Tool" "$0" "ClearCompressionFlag.exe" 1
FunctionEnd
Function InstallClearCompressionFlag
Call DownloadClearCompressionFlag
!insertmacro Install "Windows 8.1 Update 1 Preparation Tool" "ClearCompressionFlag.exe" ""
FunctionEnd

145
setup/DownloadVista7.nsh Normal file
View File

@ -0,0 +1,145 @@
Function GetComponentArch
Var /GLOBAL ComponentArch
${If} $ComponentArch == ""
${If} ${IsNativeIA32}
StrCpy $ComponentArch "x86"
${ElseIf} ${IsNativeAMD64}
StrCpy $ComponentArch "amd64"
${ElseIf} ${IsNativeIA64}
StrCpy $ComponentArch "ia64"
${Else}
StrCpy $ComponentArch ""
${EndIf}
${EndIf}
Push $ComponentArch
FunctionEnd
!macro SPHandler kbid title os sp
!insertmacro NeedsSPHandler "${kbid}" "${os}" "${sp}"
Function Download${kbid}
Call Needs${kbid}
Pop $0
${If} $0 == 1
Call GetArch
Pop $0
ReadINIStr $0 $PLUGINSDIR\Patches.ini "${kbid}" $0
!insertmacro Download "${title}" "$0" "${kbid}.exe" 1
${EndIf}
FunctionEnd
Function Install${kbid}
Call Needs${kbid}
Pop $0
${If} $0 == 1
Call Download${kbid}
!insertmacro InstallSP "${title}" "${kbid}.exe"
${EndIf}
FunctionEnd
!macroend
!macro MSUHandler kbid title packagename
Function Needs${kbid}
Call GetComponentArch
Pop $0
ClearErrors
EnumRegKey $1 HKLM "${REGPATH_PACKAGEINDEX}\${packagename}~31bf3856ad364e35~$0~~0.0.0.0" 0
${If} ${Errors}
Push 1
${Else}
Push 0
${EndIf}
FunctionEnd
Function Download${kbid}
Call Needs${kbid}
Pop $0
${If} $0 == 1
Call GetArch
Pop $0
ReadINIStr $1 $PLUGINSDIR\Patches.ini "${kbid}" $0
!insertmacro DownloadMSU "${kbid}" "${title}" "$1"
${EndIf}
FunctionEnd
Function Install${kbid}
Call Needs${kbid}
Pop $0
${If} $0 == 1
Call Download${kbid}
!insertmacro InstallMSU "${kbid}" "${title}"
${EndIf}
FunctionEnd
!macroend
; Service Packs
!insertmacro SPHandler "VistaSP1" "Windows Vista Service Pack 1" "WinVista" 0
!insertmacro SPHandler "VistaSP2" "Windows Vista Service Pack 2" "WinVista" 1
!insertmacro SPHandler "Win7SP1" "Windows 7 Service Pack 1" "Win7" 0
; Windows Vista post-SP2 update combination that fixes WU indefinitely checking for updates
!insertmacro MSUHandler "KB3205638" "Security Update for Windows Vista" "Package_for_KB3205638"
!insertmacro MSUHandler "KB4012583" "Security Update for Windows Vista" "Package_for_KB4012583"
!insertmacro MSUHandler "KB4015195" "Security Update for Windows Vista" "Package_for_KB4015195"
!insertmacro MSUHandler "KB4015380" "Security Update for Windows Vista" "Package_for_KB4015380"
; Vista IE9
!insertmacro MSUHandler "KB971512" "Update for Windows Vista" "Package_for_KB971512"
!insertmacro MSUHandler "KB2117917" "Platform Update Supplement for Windows Vista" "Package_for_KB2117917"
!insertmacro NeedsFileVersionHandler "IE9" "mshtml.dll" "9.0.8112.16421"
!insertmacro PatchHandler "IE9" "Internet Explorer 9 for Windows Vista" "/passive /norestart /update-no /closeprograms"
; Windows Vista Servicing Stack Update
!insertmacro MSUHandler "KB4493730" "2019-04 Servicing Stack Update for Windows Server 2008" "Package_1_for_KB4493730"
; Windows 7 Servicing Stack Update
!insertmacro MSUHandler "KB3138612" "2016-03 Servicing Stack Update for Windows 7" "Package_for_KB3138612"
!insertmacro MSUHandler "KB4474419" "SHA-2 Code Signing Support Update for Windows 7" "Package_for_KB4474419"
!insertmacro MSUHandler "KB4490628" "2019-03 Servicing Stack Update for Windows 7" "Package_for_KB3138612"
; Windows Home Server 2011 Update Rollup 4
!insertmacro MSUHandler "KB2757011" "Windows Home Server 2011 Update Rollup 4" "Package_for_KB2757011"
Function NeedsVistaPostSP2
Call NeedsKB3205638
Call NeedsKB4012583
Call NeedsKB4015195
Call NeedsKB4015380
Call NeedsKB4493730
Pop $0
Pop $1
Pop $2
Pop $3
Pop $4
${If} $0 == 1
${OrIf} $1 == 1
${OrIf} $2 == 1
${OrIf} $3 == 1
${OrIf} $4 == 1
Push 1
${Else}
Push 0
${EndIf}
FunctionEnd
Function NeedsWin7SHA2
ReadRegDWORD $0 HKLM "${REGPATH_SERVICING_SHA2}" "SHA2-Codesigning-Support"
${If} $0 == 1
Push 0
${Else}
Call NeedsKB3138612
Call NeedsKB4474419
Call NeedsKB4490628
Pop $0
Pop $1
Pop $2
${If} $0 == 1
${OrIf} $1 == 1
${OrIf} $2 == 1
Push 1
${Else}
Push 0
${EndIf}
${EndIf}
FunctionEnd

47
setup/DownloadWUA.nsh Normal file
View File

@ -0,0 +1,47 @@
Function DetermineWUAVersion
; Hardcoded special case for XP Home/Embedded SP3, because the WUA 7.6.7600.256 setup SFX is
; seriously broken on it, potentially causing an unbootable Windows install due to it entering an
; infinite loop of creating folders in the root of C:.
${If} ${IsWinXP2002}
${AndIf} ${AtLeastServicePack} 3
${AndIf} ${IsHomeEdition}
${OrIf} ${IsEmbedded}
StrCpy $1 "5.1.3-home"
${Else}
GetWinVer $1 Major
GetWinVer $2 Minor
GetWinVer $3 ServicePack
StrCpy $1 "$1.$2.$3"
${EndIf}
StrCpy $0 ""
ClearErrors
ReadINIStr $2 $PLUGINSDIR\Patches.ini WUA $1
${If} ${Errors}
Return
${EndIf}
${GetFileVersion} "$SYSDIR\wuapi.dll" $1
${VersionCompare} $1 $2 $3
${If} $3 == 2
Call GetArch
Pop $0
ReadINIStr $0 $PLUGINSDIR\Patches.ini WUA $2-$0
${EndIf}
FunctionEnd
Function DownloadWUA
Call DetermineWUAVersion
${If} $0 != ""
!insertmacro Download "Windows Update Agent" "$0" "WindowsUpdateAgent.exe" 1
${EndIf}
FunctionEnd
Function InstallWUA
Call DetermineWUAVersion
${If} $0 != ""
Call DownloadWUA
!insertmacro Install "Windows Update Agent" "WindowsUpdateAgent.exe" "/quiet /norestart"
${EndIf}
FunctionEnd

346
setup/Patches.ini Normal file
View File

@ -0,0 +1,346 @@
[Language]
0401=ARA
0403=CAT
0404=CHT
0804=CHS
0405=CSY
0406=DAN
0407=DEU
0408=ELL
0409=ENU
0c0a=ESN
0425=ETI
040b=FIN
040c=FRA
040d=HEB
040e=HUN
0410=ITA
0411=JPN
0412=KOR
0427=LTH
0426=LVI
0413=NLD
0414=NOR
0415=PLK
0416=PTB
0816=PTG
0418=ROM
0419=RUS
041a=HRV
041b=SKY
041d=SVE
041e=THA
041f=TRK
0424=SLV
042a=VIT
042d=EUQ
0c04=CHH
; Windows 2000
[W2KSP4]
ARA-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_ar_d2a46163d29f14829f230729e2c0821.exe
CHH-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_hk_89b5425007c388c1c146756557915ab.exe
CHS-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_cn_a6d8fab4fe598cf1d5c3cf257b11fc8.exe
CHT-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_tw_baf16f1aaae8be095127f4a46dded69.exe
CSY-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_cs_d055279f80e684debdac3f4a230ab2c.exe
DAN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_da_e9afc8657e31b34730ea2cda85ece36.exe
DEU-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_de_00d4912b4703c77c46cf53a8a8f2027.exe
ELL-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_el_55eeec8b3b303e61cb0ddab4d943cd1.exe
ENU-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_en_7f12d2da3d7c5b6a62ec4fde9a4b1e6.exe
ESN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_es_51bae94c83adcf9f0ad3155bcf3ddfc.exe
FIN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_fi_794e2bba5a5286287dccf7943055e46.exe
FRA-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_fr_4556797dfc88fdd4be13d638bcfb655.exe
HEB-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_he_b8e8519d7ae067f49ce742b59e8bcce.exe
HUN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_hu_1de3d254582472c714af315c85bf2b3.exe
ITA-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_it_6395c3848397fa6cf05e0c3d1923205.exe
JPN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_ja_beb10c6f96ac4bb93f6e192b419a50f.exe
KOR-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_ko_8bd7a0eedfaf1fb30439abdad43c347.exe
NLD-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_nl_07596ad911493b966a18b6626e4a1c4.exe
NOR-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_no_64602c5f513d7244dd5790c6a11577e.exe
PLK-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_pl_5248f4f8262d599079f5ee246cafc28.exe
PTB-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_br_a90a49821bf9b5e37810e4c453a5128.exe
PTG-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_pt_cdf5d5ecd163862ff6f641b0a4d4168.exe
RUS-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_ru_980742b1376cf5614a9e10705952dcd.exe
SVE-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_sv_c46814adb550c5184297a290acd9d25.exe
TRK-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_tr_3d5c002a300e271049b18acdc569d83.exe
NEC98-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/w2ksp4_ja_7cf59dd6babe7afcf1d7489b40941a8.exe
[KB835732]
ARA-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-ara_caf56d0f9606b68387a228f7aae57d5.exe
CHH-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-cht_c3991c4bde0e9996c3d0727cd3fdbc1.exe
CHS-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-chs_779d1b67c993ed5edaeeb6706f37a0d.exe
CHT-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-cht_c3991c4bde0e9996c3d0727cd3fdbc1.exe
CSY-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-csy_c4f86e2d69be35ba780c4f930b43e63.exe
DAN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-dan_3a6d22e0daccb7fe2d77ccda8624283.exe
DEU-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-deu_62210b6322e8370917f00fb0eb40bf1.exe
ELL-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-ell_5f2073b1f1cad898c61bea003084320.exe
ENU-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-enu_7b7d1dffd9347af2c166bfcecc4782c.exe
ESN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-esn_d62fd2652c870e4a06766638a4b119b.exe
FIN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-fin_08a377df67f697ce14d53d1d9f8dab1.exe
FRA-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-fra_85fb76a002b43ad7f8bf236a4469ad4.exe
HEB-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-heb_4c1f72024873e31a37fad21b9194dfc.exe
HUN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-hun_538b15f6b13aba4549248313cfa4c7c.exe
ITA-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-ita_10e1ca8aec2249cca79a2dd6f7d05ff.exe
JPN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-jpn_2602d9d56b3995923611494ea90f535.exe
KOR-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-kor_852d1690cd8c36ecf681a454fac484a.exe
NLD-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-nld_742d6aadbbe08ca67b755e0abaaeb8c.exe
NOR-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-nor_99fac6bc7b291e7bc6d7655ea8da446.exe
PLK-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-plk_27a55ddbb55db37b9e15e9975b3f106.exe
PTB-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-ptb_f7d297c52fd7ef6006d3b2798a10025.exe
PTG-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-ptg_67c7095f1db29bb1b4ecb3d253fdde7.exe
RUS-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-rus_0d1eca332ca7543d4cf80846eee3a80.exe
SVE-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-sve_087a446929bed6a79649a7c5a418220.exe
TRK-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-x86-trk_8dc398f69b7c8c59466511aa21eb67c.exe
NEC98-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windows2000-kb835732-nec98-jpn_8fb43a1fa0f40115cae8f3ea72d52bc.exe
[W2KIE6]
ARA-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-ara_b1720a72becd05142cb4ccbb23205c76b51d29e2.cab
CHH-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-cht_1899bffb8ebf36c0a58686f04cc1d721c419792d.cab
CHS-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-chs_6d93ab8525d3b6f775faf692caaa4c8267c8a22b.cab
CHT-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-cht_1899bffb8ebf36c0a58686f04cc1d721c419792d.cab
CSY-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-csy_2789a030bba2128fc90e0475e2530c300ed5defc.cab
DAN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-dan_0c178b2634a97a4879c172797b21a59e567d18e6.cab
DEU-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-deu_2a13ac14e403ad4a1c6877fe478067e81ac20da8.cab
ELL-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-ell_15a4e43c8922f658eddd5d57d23c11e0fa55dce9.cab
ENU-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-enu_91192253c8d3cf7beff22e68ae1fdff9638bf546.cab
ESN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-esn_a9c53ad93bae78becf2b06f6d317ef7ef66a2abe.cab
FIN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-fin_1a369fcc86e803128144e17246e16d0a27a8c35b.cab
FRA-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-fra_0bc4219b3119a127503cd93863cfedfb1e37bd55.cab
HEB-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-heb_70518dd1d09d702975b8e44a22c88e139f168975.cab
HUN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-hun_1eeed3e7b3e6bd311c17c0d97f67ec12df8b4b85.cab
ITA-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-ita_2c6ab20b41114e53646ebb56ff6d269fd86fba36.cab
JPN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-jpn_b1e1e8b9dbbf440d8964ec375348674502ef0728.cab
KOR-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-kor_f61474b056ae37c5e9670978c6d3b24f4800d7f5.cab
NLD-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-nld_3fd676fe34f93471f4db9a0a1f3ef5c3ed8e5f43.cab
NOR-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-nor_72a81d06462c5a66f9531f4f226b13463698dd24.cab
PLK-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-plk_14889750985a9d29490886c2e901ef3bc69c4ff5.cab
PTB-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-ptb_448df44aea5d853e4954d48411b1953569df23c2.cab
PTG-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-ptg_5892593c72f702ba6c7d88b47c2bd7c5707081fd.cab
RUS-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-rus_842c289d0887bbe2e4edea1ff3763addc8d77db5.cab
SVE-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-sve_db8dcfef073f2df327fc3706d9a141b6124cfed0.cab
TRK-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-trk_64479241feb2f783f851b16791d5d1c684d94a66.cab
NEC98-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/ie6sp1-wucab-jpn_b1e1e8b9dbbf440d8964ec375348674502ef0728.cab
; Windows XP 2002
[XPSP2]
ARA-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_a001b2b27b0f748ab89bd28fa45359f28f95ffb6.exe
CHH-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_546c11a0a5a41e90ae5f021f234d9abad5a0a25a.exe
CHS-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_554ee954bae0f65e88b706cf9b9fd733c02fa397.exe
CHT-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_66d8ba2cbf90737010a45e2b5969c9a779ab1d35.exe
CSY-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_767f81c9d0154bfa21d19a49e0b27ede9f93190a.exe
DAN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_e60a2b567fda2ab2cf4629700cf65cd3f4d46b0d.exe
DEU-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_ac8d3101744ff56f74a4de941dc04a7e567c8ba7.exe
ELL-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_fd86a331f91bc16185e88e6706db859cb27264d1.exe
ENU-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_33a8fef60d48ae1f2c4feea27111af5ceca3c4f6.exe
ESN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_8e7e8de62676d994a7412df190fcdce848f25cf0.exe
FIN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_2feacc1ad5a703d508e9aee4c2fca1e0b9ca9962.exe
FRA-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_da94a031147ebd6f8d02eadb7972801843a533bb.exe
HEB-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_76096ed9f2218ac7a14472cbf435f380ffc1c2f6.exe
HUN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_bd03a3d2a28de2de9e58da3e5dec888ffae25aca.exe
ITA-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_1334fdd285666bfd821eef8590914f188b1bcc0c.exe
JPN-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_d36c0a7046f2dbe29dfff33b6dbb6bb4574bbd7d.exe
KOR-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_4a6b32f007fe94a2a8b4542fc6778582ef4245e3.exe
NLD-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_64551a535981fbcd9c2bac3f91df30c6b3610725.exe
NOR-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_ace2994463597f9cb7cb059e1dca2a87c12bf278.exe
PLK-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_8aefc12abade033f2f093786646206fbb70cbb5d.exe
PTB-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_bcbc1bbb2c493dd0a942d13695b18da0400188f8.exe
PTG-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_db1f7c486f0eda249d77ae91c858a162cefb769b.exe
RUS-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_72946fbe955201f2387430963d4372cda7cac392.exe
SVE-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_3ff578d759e77df91effefe34a42030b8ada1c24.exe
TRK-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/xpsp2_68cfeb8fda746b900f9c3ce313d7348c812fd30d.exe
[XPSP3]
ARA-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/04/windowsxp-kb936929-sp3-x86-ara_4e82a87cea3b9643fd57b39393a88061614cdae6.exe
CHH-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-chh_2663fb610f29e65a10be176740ea6757ca1f22d5.exe
CHS-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-chs_d7067e86abd4257454200d0c398d71c4ce6cd33e.exe
CHT-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-cht_8a0625e10b8c6cb88d9d1952f1a189fbd761b744.exe
CSY-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-csy_7af606916b887dba9dd38ae282505ce2c2b81b08.exe
DAN-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-dan_37e03a7d43ad65bc4b71f3947c76bd2fc0fe44d6.exe
DEU-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-deu_f2dcd2211384a78df215c696a7fd1a7949dc794b.exe
ELL-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-ell_cec2ed1c3097e44e62dcb1f2a473a64a58e031fe.exe
ENU-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/04/windowsxp-kb936929-sp3-x86-enu_c81472f7eeea2eca421e116cd4c03e2300ebfde4.exe
ESN-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-esn_e305becfc6fd5a8199368ceffc496397247ac60f.exe
FIN-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-fin_5654c021a03bfb10543a2c673bdfc42a853e347a.exe
FRA-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-fra_414b61bbc86e09579d8447baa23eb1b867f9ca93.exe
HEB-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-heb_eb8fc9ff0890279346661dde065c14b5c696e423.exe
HUN-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-hun_77b70fe421baeebb115c2f378b8a1fc274db9867.exe
ITA-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-ita_2162c1d419d1e462a7dc34294528b2daf593302c.exe
JPN-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-jpn_e0fc34cfa52d270b3c79a68af8fa358244f7419e.exe
KOR-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-kor_8ca7e862bfc2742ad9c4c58df0b0cd5ad4b700ae.exe
NLD-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-nld_b2576b4d1972583a3b776fdf963b914341d34058.exe
NOR-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-nor_67c9167275a2c3e3884a38c2ad7387556ad4713a.exe
PLK-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-plk_7cbe718131e9c71b322f1149e86bedba351ba11c.exe
PTB-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-ptb_02900ef11f5a982a93de5f927997ce92d5a81a86.exe
PTG-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-ptg_bc5189c05e93cd0e5742712d84f0b5f5ffcbb7e4.exe
RUS-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-rus_850cda9f57033a17d046a56d422547ea80dcaf61.exe
SVE-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-sve_13c5ecca22e12224934a1faa1190ee34db3995ae.exe
TRK-x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windowsxp-kb936929-sp3-x86-trk_5aaf60501636af08c97ef1c18f1315f4ed6fbcdf.exe
[XPESP3]
; Only seems to be available in English.
x86=http://web.archive.org/web/20140813085714/http://download.microsoft.com/download/3/a/e/3aea3d4e-159d-4078-a5b4-5b1e4f5a4db4/WindowsXP-KB958255-ENU.exe
; Windows XP 2003
[2003SP2]
CHH-x86=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windowsserver2003-kb914961-sp2-x86-chh_2de4fb187533e226cd615bcda30b9a8a2836e197.exe
CHS-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-chs_c3e7772c6ad063bac3cb6ca05ea6e1b39c5bb35d.exe
CHT-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-cht_65a62b8ef051bf93d0ccd78900fe8d6709d37a92.exe
CSY-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-csy_fa0c18ba0a265001778e9d2691086742fc4efeb6.exe
DEU-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-deu_f9a055504e882bb06ce2c7e83319000d905f7917.exe
ENU-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-enu_51e1759a1fda6cd588660324abaed59dd3bbe86b.exe
ESN-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-esn_38d7fba08bdebdaf567ae626042e860bf525306e.exe
FRA-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-fra_51f76d9ebb01806f905199f83a16715e8026c095.exe
HUN-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-hun_0ac4aaf8685d74132da6256439ed5f74337cb7f5.exe
ITA-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-ita_75aa7220b0e226330a723cd27cb0f8b56e9b5f22.exe
JPN-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-jpn_af70b74d70df32c530352b75e42ce772e9bb68d2.exe
KOR-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-kor_65bcd5be738a08046f0714a108a5fa334ef08fd0.exe
NLD-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-nld_12014e84ae5c8a41cd918a6e2c97586bdee030f7.exe
PLK-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-plk_213469cc7ac58cfa82215f1e5ca6753675061b57.exe
PTB-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-ptb_73a2c9a9a28f1203aba9f1852c64247467494652.exe
PTG-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-ptg_d8b921ee4bb0e0d2831f249e99c64264ae9098db.exe
RUS-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-rus_b53c66c6cec98327d1a25b77a252dc82d984f959.exe
SVE-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-sve_fba6d5c90dc7c15ae750c98cf407a0f148bbfee5.exe
TRK-x86=http://download.windowsupdate.com/msdownload/update/software/dflt/2008/02/windowsserver2003-kb914961-sp2-x86-trk_428236b66433ce6b08c9d7a6aa6c523874a340ae.exe
ENU-x64=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windowsserver2003.windowsxp-kb914961-sp2-x64-enu_7f8e909c52d23ac8b5dbfd73f1f12d3ee0fe794c.exe
JPN-x64=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windowsserver2003.windowsxp-kb914961-sp2-x64-jpn_c725a8c4e03803b12a9ac8820e964dbc377a80dc.exe
DEU-ia64=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windowsserver2003-kb914961-sp2-ia64-deu_f6857c1bb8fc03798541a78cdc1f5bb98b456333.exe
ENU-ia64=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windowsserver2003-kb914961-sp2-ia64-enu_8856af0aa0f198a8aad2de2c1ca68240d1d49bf3.exe
FRA-ia64=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windowsserver2003-kb914961-sp2-ia64-fra_0289b81fe7ed5c1c36f87232f87b25cdb21d331d.exe
JPN-ia64=http://download.windowsupdate.com/msdownload/update/v3-19990518/cabpool/windowsserver2003-kb914961-sp2-ia64-jpn_3216b1978fd418181ecbf77eef67398edb97a106.exe
; Windows Update Agent standalone installer
[WUA]
; Pay no attention to the version numbers in the urls, they're all over the place. The keys have the
; actual versions of dlls that gets installed.
7.2.6001.788-x86=http://download.windowsupdate.com/windowsupdate/redist/standalone/7.2.6001.788/WindowsUpdateAgent30-x86.exe
7.2.6001.788-x64=http://download.windowsupdate.com/windowsupdate/redist/standalone/7.2.6001.788/WindowsUpdateAgent30-x64.exe
7.2.6001.788-ia64=http://download.windowsupdate.com/windowsupdate/redist/standalone/7.2.6001.788/WindowsUpdateAgent30-ia64.exe
7.6.7600.243-x86=http://download.windowsupdate.com/windowsupdate/redist/standalone/7.4.7600.243/WindowsUpdateAgent30-x86.exe
7.6.7600.256-x86=http://download.windowsupdate.com/windowsupdate/redist/standalone/7.6.7600.320/WindowsUpdateAgent-7.6-x86.exe
7.6.7600.256-x64=http://download.windowsupdate.com/windowsupdate/redist/standalone/7.6.7600.320/WindowsUpdateAgent-7.6-x64.exe
7.6.7600.256-ia64=http://download.windowsupdate.com/windowsupdate/redist/standalone/7.6.7600.320/WindowsUpdateAgent-7.6-ia64.exe
; Win2k
5.0.0=7.2.6001.788
5.0.1=7.2.6001.788
5.0.2=7.2.6001.788
5.0.3=7.2.6001.788
5.0.4=7.2.6001.788
; XP
5.1.0=7.2.6001.788
5.1.1=7.2.6001.788
5.1.2=7.2.6001.788
5.1.3=7.6.7600.256
5.1.3-home=7.6.7600.243
; Server 03/XP x64
5.2.0=7.2.6001.788
5.2.1=7.2.6001.788
5.2.2=7.6.7600.256
; Vista/Server 08
6.0.2=7.6.7600.256
; Vista/Server 08
[VistaSP1]
x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windows6.0-kb936330-x86_b8a3fa8f819269e37d8acde799e7a9aea3dd4529.exe
x64=http://download.windowsupdate.com/msdownload/update/software/svpk/2008/04/windows6.0-kb936330-x64_12eed6cf0a842ce2a609c622b843afc289a8f4b9.exe
; No ia64 release for Vista SP1
[VistaSP2]
x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2009/06/windows6.0-kb948465-x86_55f17352b4398ecb4f0cc20e3737631420ca1609.exe
x64=http://download.windowsupdate.com/msdownload/update/software/svpk/2009/06/windows6.0-kb948465-x64_2eedca0bfa5ae8d1b0acf2117ddc4f15ac5183c9.exe
ia64=http://download.windowsupdate.com/msdownload/update/software/svpk/2009/06/windows6.0-kb948465-ia64_1a6cd9ade213bcc056cba3b810e86f0c09c16b51.exe
[KB3205638]
x86=http://download.windowsupdate.com/d/msdownload/update/software/secu/2016/11/windows6.0-kb3205638-x86_e2211e9a6523061972decd158980301fc4c32a47.msu
x64=http://download.windowsupdate.com/d/msdownload/update/software/secu/2016/11/windows6.0-kb3205638-x64_a52aaa009ee56ca941e21a6009c00bc4c88cbb7c.msu
ia64=http://download.windowsupdate.com/d/msdownload/update/software/secu/2016/11/windows6.0-kb3205638-ia64_d6bd55663080885c712c3afb9021c7336d0be83a.msu
[KB4012583]
x86=http://download.windowsupdate.com/c/msdownload/update/software/secu/2017/02/windows6.0-kb4012583-x86_1887cb5393b62cbd2dbb6a6ff6b136e809a2fbd0.msu
x64=http://download.windowsupdate.com/c/msdownload/update/software/secu/2017/02/windows6.0-kb4012583-x64_f63c9a85aa877d86c886e432560fdcfad53b752d.msu
ia64=http://download.windowsupdate.com/c/msdownload/update/software/secu/2017/02/windows6.0-kb4012583-ia64_ab1ab96d3a3d7fbd1bf5d1cee53bf0be958c6329.msu
[KB4015195]
x86=http://download.windowsupdate.com/d/msdownload/update/software/secu/2017/03/windows6.0-kb4015195-x86_eb045e0144266b20b615f29fa581c4001ebb7852.msu
x64=http://download.windowsupdate.com/d/msdownload/update/software/secu/2017/03/windows6.0-kb4015195-x64_2e310724d86b6a43c5ae8ec659685dd6cfb28ba4.msu
ia64=http://download.windowsupdate.com/d/msdownload/update/software/secu/2017/03/windows6.0-kb4015195-ia64_0ae8f7c2ab5cf24123f6e279469674d823d20129.msu
[KB4015380]
x86=http://download.windowsupdate.com/d/msdownload/update/software/secu/2017/03/windows6.0-kb4015380-x86_3f3548db24cf61d6f47d2365c298d739e6cb069a.msu
x64=http://download.windowsupdate.com/c/msdownload/update/software/secu/2017/03/windows6.0-kb4015380-x64_959aedbe0403d160be89f4dac057e2a0cd0c6d40.msu
ia64=http://download.windowsupdate.com/c/msdownload/update/software/secu/2017/03/windows6.0-kb4015380-ia64_2a825e5f1aca191bb5f627b494838660180da2d6.msu
[KB4493730]
x86=http://download.windowsupdate.com/d/msdownload/update/software/secu/2019/04/windows6.0-kb4493730-x86_ab4368f19db796680ff445a7769886c4cdc009a0.msu
x64=http://download.windowsupdate.com/d/msdownload/update/software/secu/2019/04/windows6.0-kb4493730-x64_5cb91f4e9000383f061b80f88feffdf228c2443c.msu
ia64=http://download.windowsupdate.com/d/msdownload/update/software/secu/2019/04/windows6.0-kb4493730-ia64_024e5a390f7eace6d2e9dcaa91f09976e4d147db.msu
; IE9 for Vista
[KB971512]
x86=http://download.windowsupdate.com/msdownload/update/software/updt/2009/10/windows6.0-kb971512-x86_370c3e41e1c161ddce29676e9273e4b8bb7ba3eb.msu
x64=http://download.windowsupdate.com/msdownload/update/software/updt/2009/10/windows6.0-kb971512-x64_0b329b985437c6c572529e5fd0042b9d54aeaa0c.msu
[KB2117917]
x86=http://download.windowsupdate.com/msdownload/update/software/updt/2011/02/windows6.0-kb2117917-x86_370435d9efa6643c44d6506666b1960d56cf673a.msu
x64=http://download.windowsupdate.com/msdownload/update/software/updt/2011/02/windows6.0-kb2117917-x64_655a21758801e9648702791d7bf30f81b58884b3.msu
[IE9]
x86=http://download.windowsupdate.com/msdownload/update/software/uprl/2011/05/wu-ie9-windowsvista-x86_90e3e90e964c2769a008cbf924eefdc42413dd52.exe
x64=http://download.windowsupdate.com/msdownload/update/software/uprl/2011/03/wu-ie9-windowsvista-x64_f599c02e7e1ea8a4e1029f0e49418a8be8416367.exe
; 7/Server 08 R2
[Win7SP1]
x86=http://download.windowsupdate.com/msdownload/update/software/svpk/2011/02/windows6.1-kb976932-x86_c3516bc5c9e69fee6d9ac4f981f5b95977a8a2fa.exe
x64=http://download.windowsupdate.com/msdownload/update/software/svpk/2011/02/windows6.1-kb976932-x64_74865ef2562006e51d7f9333b4a8d45b7a749dab.exe
[KB3138612]
x86=http://download.windowsupdate.com/d/msdownload/update/software/updt/2016/02/windows6.1-kb3138612-x86_6e90531daffc13bc4e92ecea890e501e807c621f.msu
x64=http://download.windowsupdate.com/d/msdownload/update/software/updt/2016/02/windows6.1-kb3138612-x64_f7b1de8ea7cf8faf57b0138c4068d2e899e2b266.msu
ia64=http://download.windowsupdate.com/d/msdownload/update/software/updt/2016/02/windows6.1-kb3138612-ia64_4edd5410fb137382d77f468a14118fa6d1c03655.msu
[KB4474419]
x86=http://download.windowsupdate.com/c/msdownload/update/software/secu/2019/09/windows6.1-kb4474419-v3-x86_0f687d50402790f340087c576886501b3223bec6.msu
x64=http://download.windowsupdate.com/c/msdownload/update/software/secu/2019/09/windows6.1-kb4474419-v3-x64_b5614c6cea5cb4e198717789633dca16308ef79c.msu
ia64=http://download.windowsupdate.com/c/msdownload/update/software/secu/2019/09/windows6.1-kb4474419-v3-ia64_1436a990f64876332857baaafa7aeb9eadcb4fa4.msu
[KB4490628]
x86=http://download.windowsupdate.com/c/msdownload/update/software/secu/2019/03/windows6.1-kb4490628-x86_3cdb3df55b9cd7ef7fcb24fc4e237ea287ad0992.msu
x64=http://download.windowsupdate.com/c/msdownload/update/software/secu/2019/03/windows6.1-kb4490628-x64_d3de52d6987f7c8bdc2c015dca69eac96047c76e.msu
ia64=http://download.windowsupdate.com/d/msdownload/update/software/secu/2019/03/windows6.1-kb4490628-ia64_4736acd98e0a4e02f29fcdef63feacc5ac7b702b.msu
; Windows Home Server 2011
[KB2757011]
x64=http://download.windowsupdate.com/msdownload/update/software/uprl/2012/12/windows6.1-kb2757011-x64_4140355ab0b06df89668ec51432a820dff9af356.msu
; 8/Server 2012
[KB4598297]
x86=http://download.windowsupdate.com/d/msdownload/update/software/secu/2021/01/windows8-rt-kb4598297-x86_a517ea587c91af5f803b0973d40166c3e076fe5c.msu
x64=http://download.windowsupdate.com/d/msdownload/update/software/secu/2021/01/windows8-rt-kb4598297-x64_60f5c45d1216ee6ff1ab88ca03b037ac519ad0da.msu
; 8.1/Server 2012 R2
[KB3021910]
x86=http://download.windowsupdate.com/c/msdownload/update/software/updt/2015/04/windows8.1-kb3021910-x86_7e70173bec00c3d4fe3b0b8cba17b095b4ed2d20.msu
x64=http://download.windowsupdate.com/c/msdownload/update/software/updt/2015/04/windows8.1-kb3021910-x64_e291c0c339586e79c36ebfc0211678df91656c3d.msu
[ClearCompressionFlag]
x86=http://download.windowsupdate.com/c/msdownload/update/software/secu/2014/04/clearcompressionflag_220edca17ae47089fc4da060915e0df568eac4ff.exe
x64=http://download.windowsupdate.com/d/msdownload/update/software/secu/2014/04/clearcompressionflag_3104315db9d84f6a2a56b9621e89ea66a8c27604.exe
[KB2919355]
x86=http://download.windowsupdate.com/c/msdownload/update/software/crup/2014/02/windows8.1-kb2919355-x86_de9df31e42fe034c9a763328326e5852c2b4963d.msu
x64=http://download.windowsupdate.com/d/msdownload/update/software/crup/2014/02/windows8.1-kb2919355-x64_e6f4da4d33564419065a7370865faacf9b40ff72.msu
[KB2932046]
x86=http://download.windowsupdate.com/c/msdownload/update/software/crup/2014/02/windows8.1-kb2932046-x86_bfd8ca4c683ccec26355afc1f2e677f3809cb3d6.msu
x64=http://download.windowsupdate.com/d/msdownload/update/software/crup/2014/02/windows8.1-kb2932046-x64_6aee5fda6e2a6729d1fbae6eac08693acd70d985.msu
[KB2959977]
x86=http://download.windowsupdate.com/d/msdownload/update/software/secu/2014/04/windows8.1-kb2959977-x86_5ccf761a356bb143b68887f99883d8c24946d2c2.msu
x64=http://download.windowsupdate.com/c/msdownload/update/software/secu/2014/04/windows8.1-kb2959977-x64_574ba2d60baa13645b764f55069b74b2de866975.msu
[KB2937592]
x86=http://download.windowsupdate.com/d/msdownload/update/software/crup/2014/02/windows8.1-kb2937592-x86_96a3416d480bd2b54803df26b8e76cd1d0008d43.msu
x64=http://download.windowsupdate.com/c/msdownload/update/software/crup/2014/02/windows8.1-kb2937592-x64_4abc0a39c9e500c0fbe9c41282169c92315cafc2.msu
[KB2934018]
x86=http://download.windowsupdate.com/d/msdownload/update/software/secu/2014/04/windows8.1-kb2934018-x86_8fb05387836b77abbf1755185ae743c9da417e9a.msu
x64=http://download.windowsupdate.com/c/msdownload/update/software/secu/2014/04/windows8.1-kb2934018-x64_234a5fc4955f81541f5bfc0d447e4fc4934efc38.msu

166
setup/RunOnce.nsh Normal file
View File

@ -0,0 +1,166 @@
!define IsRunOnce `"" HasFlag "/runonce"`
!define IsPostInstall `"" HasFlag "/postinstall"`
!define NoRestart `"" HasFlag "/norestart"`
!macro -PromptReboot
SetErrorLevel ${ERROR_SUCCESS_REBOOT_REQUIRED}
${If} ${NoRestart}
; Prompt for reboot
${IfNot} ${Silent}
System::Call '${RestartDialog}($HWNDPARENT, \
"Windows will be restarted to complete installation of prerequisite components. Setup will resume after the restart.", \
${EWX_REBOOT})'
${EndIf}
${Else}
; Reboot immediately
Reboot
${EndIf}
!macroend
!macro -RegisterRunOnce flags
WriteRegStr HKLM "${REGPATH_RUNONCE}" "Legacy Update" '"$RunOnceDir\LegacyUpdateSetup.exe" ${flags}'
!macroend
Function RegisterRunOnce
!insertmacro -RegisterRunOnce "/runonce"
FunctionEnd
Function un.RegisterRunOnce
; Unused, just needs to exist to make the compiler happy
FunctionEnd
Function RegisterRunOncePostInstall
!insertmacro -RegisterRunOnce "/postinstall"
FunctionEnd
!macro -WriteRegStrWithBackup root key name value
; Backup the key if it exists
ClearErrors
ReadRegStr $0 ${root} "${key}" "${name}"
${IfNot} ${Errors}
WriteRegStr ${root} "${key}" "LegacyUpdate_${name}" $0
${EndIf}
WriteRegStr ${root} "${key}" "${name}" "${value}"
!macroend
!macro -RestoreRegStr root key name
; Restore the key if it exists
ClearErrors
ReadRegStr $0 ${root} "${key}" "LegacyUpdate_${name}"
${If} ${Errors}
DeleteRegValue ${root} "${key}" "${name}"
${Else}
WriteRegStr ${root} "${key}" "${name}" $0
DeleteRegValue ${root} "${key}" "LegacyUpdate_${name}"
${EndIf}
!macroend
!macro -RebootIfRequired un
${If} ${RebootFlag}
${IfNot} ${IsRunOnce}
${AndIfNot} ${NoRestart}
!insertmacro DetailPrint "Preparing to restart..."
; Get the localised name of the Administrators group from its SID
System::Call '*(&i1 0, &i4 0, &i1 5) i .r0'
; S-1-5-32-544
System::Call '${AllocateAndInitializeSid}(r0, 2, ${SECURITY_BUILTIN_DOMAIN_RID}, ${DOMAIN_ALIAS_RID_ADMINS}, 0, 0, 0, 0, 0, 0, .r1)'
System::Free $0
System::Call '${LookupAccountSid}(0, r1, .r0, ${NSIS_MAX_STRLEN}, .r2, ${NSIS_MAX_STRLEN}, 0)'
System::Call '${FreeSid}(r1)'
; Create the admin user
ExecShellWait "" "$WINDIR\system32\net.exe" "user /add ${RUNONCE_USERNAME} ${RUNONCE_PASSWORD}" SW_HIDE
ExecShellWait "" "$WINDIR\system32\net.exe" 'localgroup /add "$0" ${RUNONCE_USERNAME}' SW_HIDE
!insertmacro -WriteRegStrWithBackup HKLM "${REGPATH_WINLOGON}" "AutoAdminLogon" "1"
!insertmacro -WriteRegStrWithBackup HKLM "${REGPATH_WINLOGON}" "DefaultDomainName" "."
!insertmacro -WriteRegStrWithBackup HKLM "${REGPATH_WINLOGON}" "DefaultUserName" "${RUNONCE_USERNAME}"
!insertmacro -WriteRegStrWithBackup HKLM "${REGPATH_WINLOGON}" "DefaultPassword" "${RUNONCE_PASSWORD}"
; Copy to runonce path to ensure installer is accessible by the temp user
CreateDirectory "$RunOnceDir"
CopyFiles /SILENT "$EXEPATH" "$RunOnceDir\LegacyUpdateSetup.exe"
; Remove mark of the web to prevent "Open File - Security Warning" dialog
System::Call '${DeleteFile}("$RunOnceDir\LegacyUpdateSetup.exe:Zone.Identifier")'
${EndIf}
Call ${un}RegisterRunOnce
!insertmacro -PromptReboot
Quit
${EndIf}
!macroend
Function RebootIfRequired
${MementoSectionSave}
!insertmacro -RebootIfRequired ""
FunctionEnd
Function un.RebootIfRequired
!insertmacro -RebootIfRequired "un."
FunctionEnd
Function OnRunOnceLogon
; Trick winlogon into thinking the shell has started, so it doesn't appear to be stuck at
; "Welcome" (XP) or "Preparing your desktop..." (Vista+)
; https://social.msdn.microsoft.com/Forums/WINDOWS/en-US/ca253e22-1ef8-4582-8710-9cd9c89b15c3
${If} ${AtLeastWinVista}
StrCpy $0 "ShellDesktopSwitchEvent"
${Else}
StrCpy $0 "msgina: ShellReadyEvent"
${EndIf}
System::Call '${OpenEvent}(${EVENT_MODIFY_STATE}, 0, "$0") .r0'
${If} $0 != 0
System::Call '${SetEvent}(r0)'
System::Call '${CloseHandle}(r0)'
${EndIf}
; Handle Safe Mode case. RunOnce can still be processed in Safe Mode in some edge cases. If that
; happens, just silently register runonce again and quit.
${If} ${IsSafeMode}
Call RegisterRunOnce
Quit
${EndIf}
; Allow the themes component to be registered if necessary. This sets the theme to Aero Basic
; rather than Classic in Vista/7.
ClearErrors
ReadRegStr $0 HKLM "${REGPATH_COMPONENT_THEMES}" "StubPath"
${IfNot} ${Errors}
ExecShellWait "" "$WINDIR\system32\cmd.exe" "/c $0" SW_HIDE
${EndIf}
FunctionEnd
Function CleanUpRunOnce
; Restore autologon keys
!insertmacro -RestoreRegStr HKLM "${REGPATH_WINLOGON}" "AutoAdminLogon"
!insertmacro -RestoreRegStr HKLM "${REGPATH_WINLOGON}" "DefaultDomainName"
!insertmacro -RestoreRegStr HKLM "${REGPATH_WINLOGON}" "DefaultUserName"
!insertmacro -RestoreRegStr HKLM "${REGPATH_WINLOGON}" "DefaultPassword"
; Delete the temp user
ExecShellWait "" "$WINDIR\system32\net.exe" "user /delete ${RUNONCE_USERNAME}" SW_HIDE
${If} ${IsRunOnce}
; Clean up temporary setup exe if we created it (likely on next reboot)
${If} ${FileExists} "$RunOnceDir"
RMDir /r /REBOOTOK "$RunOnceDir"
${EndIf}
; Be really really sure this is the right user before we nuke their profile and log out
System::Call '${GetUserName}(.r0, ${NSIS_MAX_STRLEN}) .r1'
${If} $0 == "${RUNONCE_USERNAME}"
; Register postinstall runonce for the next admin user logon, and log out of the temporary user
${IfNot} ${Abort}
Call RegisterRunOncePostInstall
${EndIf}
RMDir /r /REBOOTOK "$PROFILE"
System::Call "${ExitWindowsEx}(${EWX_FORCE}, 0) .r0"
${EndIf}
${EndIf}
FunctionEnd

82
setup/UpdateRoots.nsh Normal file
View File

@ -0,0 +1,82 @@
!macro -SetSecureProtocolsBitmask
; If the value isn't yet set, ReadRegDword will return 0. This means TLSv1.1 and v1.2 will be the
; only enabled protocols. This is intentional behavior, because SSLv2 and SSLv3 are not secure,
; and TLSv1.0 is deprecated. The user can manually enable them in Internet Settings if needed.
; On XP, we'll also enable TLSv1.0, given TLSv1.1 and v1.2 are only offered through an optional
; POSReady 2009 update.
${If} $0 == 0
${AndIf} ${AtMostWinXP2003}
IntOp $0 $0 | ${WINHTTP_FLAG_SECURE_PROTOCOL_TLS1}
${EndIf}
IntOp $0 $0 | ${WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1}
IntOp $0 $0 | ${WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2}
!macroend
Function _ConfigureCrypto
; Enable SChannel TLSv1.1 and v1.2
WriteRegDword HKLM "${REGPATH_SCHANNEL_PROTOCOLS}\TLS 1.1\Client" "Enabled" 1
WriteRegDword HKLM "${REGPATH_SCHANNEL_PROTOCOLS}\TLS 1.1\Client" "DisabledByDefault" 0
WriteRegDword HKLM "${REGPATH_SCHANNEL_PROTOCOLS}\TLS 1.1\Server" "Enabled" 1
WriteRegDword HKLM "${REGPATH_SCHANNEL_PROTOCOLS}\TLS 1.1\Server" "DisabledByDefault" 0
WriteRegDword HKLM "${REGPATH_SCHANNEL_PROTOCOLS}\TLS 1.2\Client" "Enabled" 1
WriteRegDword HKLM "${REGPATH_SCHANNEL_PROTOCOLS}\TLS 1.2\Client" "DisabledByDefault" 0
WriteRegDword HKLM "${REGPATH_SCHANNEL_PROTOCOLS}\TLS 1.2\Server" "Enabled" 1
WriteRegDword HKLM "${REGPATH_SCHANNEL_PROTOCOLS}\TLS 1.2\Server" "DisabledByDefault" 0
; Enable IE TLSv1.1 and v1.2
ReadRegDword $0 HKLM "${REGPATH_INETSETTINGS}" "SecureProtocols"
!insertmacro -SetSecureProtocolsBitmask
WriteRegDword HKLM "${REGPATH_INETSETTINGS}" "SecureProtocols" $0
ReadRegDword $0 HKCU "${REGPATH_INETSETTINGS}" "SecureProtocols"
!insertmacro -SetSecureProtocolsBitmask
WriteRegDword HKCU "${REGPATH_INETSETTINGS}" "SecureProtocols" $0
; Enable WinHTTP TLSv1.1 and v1.2
ReadRegDword $0 HKLM "${REGPATH_INETSETTINGS}\WinHttp" "DefaultSecureProtocols"
!insertmacro -SetSecureProtocolsBitmask
WriteRegDword HKLM "${REGPATH_INETSETTINGS}\WinHttp" "DefaultSecureProtocols" $0
ReadRegDword $0 HKCU "${REGPATH_INETSETTINGS}\WinHttp" "DefaultSecureProtocols"
!insertmacro -SetSecureProtocolsBitmask
WriteRegDword HKCU "${REGPATH_INETSETTINGS}\WinHttp" "DefaultSecureProtocols" $0
; Enable .NET inheriting SChannel protocol config
; .NET 3 uses the same registry keys as .NET 2.
WriteRegDword HKLM "${REGPATH_DOTNET_V2}" "SystemDefaultTlsVersions" 1
WriteRegDword HKLM "${REGPATH_DOTNET_V4}" "SystemDefaultTlsVersions" 1
FunctionEnd
Function ConfigureCrypto
Call _ConfigureCrypto
; Repeat in the WOW64 registry if needed
${If} ${RunningX64}
SetRegView 32
Call _ConfigureCrypto
SetRegView 64
${EndIf}
FunctionEnd
!macro _DownloadSST name
!insertmacro Download "Certificate Trust List" "${TRUSTEDR}/${name}.sst" "${name}.sst" 0
!macroend
Function DownloadRoots
!insertmacro DetailPrint "Downloading Certificate Trust List..."
!insertmacro _DownloadSST "authroots"
!insertmacro _DownloadSST "delroots"
!insertmacro _DownloadSST "roots"
!insertmacro _DownloadSST "updroots"
!insertmacro _DownloadSST "disallowedcert"
FunctionEnd
Function UpdateRoots
File "updroots.exe"
!insertmacro DetailPrint "Installing Certificate Trust List..."
!insertmacro ExecWithErrorHandling "Certificate Trust List" '"$OUTDIR\updroots.exe" authroots.sst' 0
!insertmacro ExecWithErrorHandling "Certificate Trust List" '"$OUTDIR\updroots.exe" updroots.sst' 0
!insertmacro ExecWithErrorHandling "Certificate Trust List" '"$OUTDIR\updroots.exe" -l roots.sst' 0
!insertmacro ExecWithErrorHandling "Certificate Trust List" '"$OUTDIR\updroots.exe" -d delroots.sst' 0
!insertmacro ExecWithErrorHandling "Certificate Trust List" '"$OUTDIR\updroots.exe" -l -u disallowedcert.sst' 0
FunctionEnd

69
setup/Win32.nsh Normal file
View File

@ -0,0 +1,69 @@
; advapi32
!define SECURITY_BUILTIN_DOMAIN_RID 0x00000020
!define DOMAIN_ALIAS_RID_ADMINS 0x00000220
!define AllocateAndInitializeSid 'advapi32::AllocateAndInitializeSid(i, i, i, i, i, i, i, i, i, i, *i) i'
!define LookupAccountSid 'advapi32::LookupAccountSid(i, i, t, *i, t, *i, *i) i'
!define FreeSid 'advapi32::FreeSid(i)'
!define GetUserName 'advapi32::GetUserName(t, *i) i'
; kernel32
!define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
!define ES_CONTINUOUS 0x80000000
!define ES_SYSTEM_REQUIRED 0x00000001
!define GetVersionEx 'kernel32::GetVersionEx(pr) i'
!define GetLogicalProcessorInformationEx 'kernel32::GetLogicalProcessorInformationEx(i, *i, *i) i'
!define SetThreadExecutionState 'kernel32::SetThreadExecutionState(i) i'
!define OpenEvent 'kernel32::OpenEvent(i, i, t) i'
!define SetEvent 'kernel32::SetEvent(i) i'
!define CloseHandle 'kernel32::CloseHandle(i) i'
!define DeleteFile 'kernel32::DeleteFile(t) i'
; netapi32
!define NetApiBufferFree 'netapi32::NetApiBufferFree(i) i'
!define NetUserGetInfo 'netapi32::NetUserGetInfo(t, t, i, *i) i'
!define NetUserAdd 'netapi32::NetUserAdd(t, i, t, i, *i) i'
!define NetLocalGroupAddMembers 'netapi32::NetLocalGroupAddMembers(t, t, i, *i, i) i'
; ole32
!define CoCreateInstance 'ole32::CoCreateInstance(g, p, i, g, *p) i'
!define CoTaskMemFree 'ole32::CoTaskMemFree(p)'
; oleaut32
!define SysAllocString 'oleaut32::SysAllocString(t) p'
!define SysFreeString 'oleaut32::SysFreeString(p)'
; shell32
!define IsUserAnAdmin 'shell32::IsUserAnAdmin() i'
!define RestartDialog 'shell32::RestartDialog(p, t, i) i'
; user32
!define EWX_REBOOT 0x02
!define EWX_FORCE 0x04
!define ExitWindowsEx 'user32::ExitWindowsEx(i, i) i'
!define GetSystemMetrics 'user32::GetSystemMetrics(i) i'
; winhttp
!define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 0x00000080
!define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 0x00000200
!define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 0x00000800
!define ERROR_INTERNET_OPERATION_CANCELLED 12017
; wininet
!define INTERNET_FLAG_RELOAD 0x80000000
!define INTERNET_FLAG_NO_CACHE_WRITE 0x04000000
!define INTERNET_FLAG_KEEP_CONNECTION 0x00400000
!define INTERNET_FLAG_NO_COOKIES 0x00080000
!define INTERNET_FLAG_NO_UI 0x00000200
!define SECURITY_FLAG_STRENGTH_STRONG 0x20000000
; wuapi
!define WU_S_ALREADY_INSTALLED 2359302 ; 0x00240006
!define WU_E_NOT_APPLICABLE -2145124329 ; 0x80240017
!define WU_MU_SERVICE_ID "7971f918-a847-4430-9279-4a52d1efe18d"

173
setup/WinVer.nsh Normal file
View File

@ -0,0 +1,173 @@
; NSIS WinVer.nsh rewritten to work more like what I expect.
!include LogicLib.nsh
!include Util.nsh
; Defines
!define OSVERSIONINFOW_SIZE 276
!define OSVERSIONINFOEXW_SIZE 284
!define WINVER_2000 0x0500 ; 5.0.2195
!define WINVER_XP 0x0501 ; 5.1.2600
!define WINVER_XP2002 0x0501 ; 5.1.2600
!define WINVER_XP2003 0x0502 ; 5.2.3790
!define WINVER_VISTA 0x0600 ; 6.0.6000
!define WINVER_7 0x0601 ; 6.1.7600
!define WINVER_8 0x0602 ; 6.2.9200
!define WINVER_8.1 0x0603 ; 6.3.9600
!define WINVER_10 0x0A00 ; 10.0.10240
!define WINVER_SERVER_2000 ${WINVER_2000}
!define WINVER_SERVER_2003 ${WINVER_XP2003}
!define WINVER_SERVER_2003R2 ${WINVER_XP2003}
!define WINVER_SERVER_2008 ${WINVER_VISTA}
!define WINVER_SERVER_2008R2 ${WINVER_7}
!define WINVER_SERVER_2012 ${WINVER_8}
!define WINVER_SERVER_2012R2 ${WINVER_8.1}
!define WINVER_SERVER_2016 ${WINVER_10}
!define WINVER_BUILD_11 22000
!define /ifndef VER_NT_WORKSTATION 1
!define VER_SUITE_BACKOFFICE 0x00000004 ; Microsoft BackOffice
!define VER_SUITE_BLADE 0x00000400 ; Windows Server 2003, Web Edition
!define VER_SUITE_COMPUTE_SERVER 0x00004000 ; Windows Server 2003, Compute Cluster Edition
!define VER_SUITE_DATACENTER 0x00000080 ; Windows Server Datacenter
!define VER_SUITE_ENTERPRISE 0x00000002 ; Windows Server Enterprise
!define VER_SUITE_EMBEDDEDNT 0x00000040 ; Windows Embedded
!define VER_SUITE_PERSONAL 0x00000200 ; Windows Home Edition
!define VER_SUITE_SINGLEUSERTS 0x00000100 ; Single-user Remote Desktop
!define VER_SUITE_SMALLBUSINESS 0x00000001 ; Small Business Server
!define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020 ; Small Business Server (restrictive client license)
!define VER_SUITE_STORAGE_SERVER 0x00002000 ; Windows Storage Server 2003
!define VER_SUITE_TERMINAL 0x00000010 ; Terminal Services (always true)
!define VER_SUITE_WH_SERVER 0x00008000 ; Windows Home Server
!define VER_SUITE_MULTIUSERTS 0x00020000 ; Multi-user Remote Desktop
!define SM_CLEANBOOT 67
; Init
!macro __WinVer_Init
!ifndef __WINVER_VARS_DECLARED
!define __WINVER_VARS_DECLARED
Var /GLOBAL __WINVEROS
Var /GLOBAL __WINVERBUILD
Var /GLOBAL __WINVERSP
Var /GLOBAL __WINVERPROD
Var /GLOBAL __WINVERSUITE
!endif
StrCmp $__WINVEROS "" _winver_noveryet
Return
_winver_noveryet:
GetWinVer $__WINVEROS NTDDIMajMin
GetWinVer $__WINVERBUILD Build
GetWinVer $__WINVERSP ServicePack
GetWinVer $__WINVERPROD Product
Push $0
Push $1
System::Alloc ${OSVERSIONINFOEXW_SIZE}
Pop $0
System::Call '*$0(i ${OSVERSIONINFOEXW_SIZE})'
System::Call '${GetVersionEx}(.r0)'
System::Call '*$0(i, i, i, i, i, &t128, h, h, h .r1, b, b)'
System::Free $0
StrCpy $__WINVERSUITE $1
Pop $1
Pop $0
!macroend
; Tests
!macro __WinVer_TestOS op num _t _f
${CallArtificialFunction} __WinVer_Init
!insertmacro _${op} $__WINVEROS ${num} `${_t}` `${_f}`
!macroend
!macro __WinVer_TestBuild op num _t _f
${CallArtificialFunction} __WinVer_Init
!insertmacro _${op} $__WINVERBUILD ${num} `${_t}` `${_f}`
!macroend
!macro __WinVer_TestSP op num _t _f
${CallArtificialFunction} __WinVer_Init
!insertmacro _${op} $__WINVERSP ${num} `${_t}` `${_f}`
!macroend
!macro __WinVer_TestProduct op num _t _f
${CallArtificialFunction} __WinVer_Init
!insertmacro _${op} $__WINVERPROD ${num} `${_t}` `${_f}`
!macroend
!macro __WinVer_TestSuite _a num _t _f
!insertmacro _LOGICLIB_TEMP
${CallArtificialFunction} __WinVer_Init
IntOp $_LOGICLIB_TEMP $__WINVERSUITE & ${num}
!insertmacro _= $_LOGICLIB_TEMP ${num} `${_t}` `${_f}`
!macroend
!macro __WinVer_TestSystemMetric op metric _t _f
!insertmacro _LOGICLIB_TEMP
${CallArtificialFunction} __WinVer_Init
System::Call '${GetSystemMetrics}(${metric}) .s'
Pop $_LOGICLIB_TEMP
!insertmacro _${op} $_LOGICLIB_TEMP 0 `${_t}` `${_f}`
!macroend
; Defines
!define IsClientOS `= _WinVer_TestProduct ${VER_NT_WORKSTATION}`
!define IsServerOS `!= _WinVer_TestProduct ${VER_NT_WORKSTATION}`
!define IsHomeEdition `"" _WinVer_TestSuite ${VER_SUITE_PERSONAL}`
!define IsEmbedded `"" _WinVer_TestSuite ${VER_SUITE_EMBEDDEDNT}`
!define IsHomeServer `"" _WinVer_TestSuite ${VER_SUITE_WH_SERVER}`
!define IsSafeMode `!= _WinVer_TestSystemMetric ${SM_CLEANBOOT}`
!define IsServicePack `= _WinVer_TestSP`
!define AtLeastServicePack `>= _WinVer_TestSP`
!define AtMostServicePack `<= _WinVer_TestSP`
!macro __WinVer_DefineClient os
!define IsWin${os} `= _WinVer_TestOS ${WINVER_${os}}`
!define AtLeastWin${os} `>= _WinVer_TestOS ${WINVER_${os}}`
!define AtMostWin${os} `<= _WinVer_TestOS ${WINVER_${os}}`
!macroend
!macro __WinVer_DefineServer os
!define IsWin${os} `= _WinVer_TestOS ${WINVER_SERVER_${os}}`
!define AtLeastWin${os} `>= _WinVer_TestOS ${WINVER_SERVER_${os}}`
!define AtMostWin${os} `<= _WinVer_TestOS ${WINVER_SERVER_${os}}`
!macroend
!macro __WinVer_DefineBuild os
!define IsWin${os} `= _WinVer_TestBuild ${WINVER_BUILD_${os}}`
!define AtLeastWin${os} `>= _WinVer_TestBuild ${WINVER_BUILD_${os}}`
!define AtMostWin${os} `<= _WinVer_TestBuild ${WINVER_BUILD_${os}}`
!macroend
!insertmacro __WinVer_DefineClient 2000
!insertmacro __WinVer_DefineClient XP2002
!insertmacro __WinVer_DefineClient XP2003
!insertmacro __WinVer_DefineClient Vista
!insertmacro __WinVer_DefineClient 7
!insertmacro __WinVer_DefineClient 8
!insertmacro __WinVer_DefineClient 8.1
!insertmacro __WinVer_DefineClient 10
!insertmacro __WinVer_DefineServer 2003
!insertmacro __WinVer_DefineServer 2003R2
!insertmacro __WinVer_DefineServer 2008
!insertmacro __WinVer_DefineServer 2008R2
!insertmacro __WinVer_DefineServer 2012
!insertmacro __WinVer_DefineServer 2012R2
!insertmacro __WinVer_DefineServer 2016
!insertmacro __WinVer_DefineBuild 11

View File

@ -0,0 +1,20 @@
.Set CabinetNameTemplate=lucontrl.cab
.Set CompressionType=MSZIP
.Set CompressionLevel=7
.Set InfFileName=lucontrl_layout.inf
.Set MaxDiskSize=CDROM
.Set ReservePerCabinetSize=6144
.Set InfCabinetLineFormat=*cab#*=Application Source Media,*cabfile*,0
.Set Compress=on
.Set CompressionMemory=21
.Set DiskDirectoryTemplate=
.Set Cabinet=ON
.Set MaxCabinetSize=999999999
.Set InfDiskHeader=
.Set InfDiskLineFormat=
.Set InfCabinetHeader=[SourceDisksNames]
.Set InfFileHeader=
.Set InfFileHeader1=[SourceDisksFiles]
.Set InfFileLineFormat=*file*=*cab#*,,*size*,*csum*
setup.inf
setup.exe

9
setup/codebase/setup.inf Normal file
View File

@ -0,0 +1,9 @@
[Version]
Signature="$CHICAGO$"
AdvancedINF=2.0
[Setup Hooks]
setup=setup
[setup]
run="%EXTRACT_DIR%\setup.exe" /activex

1
setup/codebase/test.html Normal file
View File

@ -0,0 +1 @@
<object classid="CLSID:AD28E0DF-5F5A-40B5-9432-85EFD97D1F9F" codebase="/lucontrl.cab#version=1,9,0,0" viewastext></object>

89
setup/ie6setupstub.nsi Normal file
View File

@ -0,0 +1,89 @@
; Stub file used to replace the ie6setup_w2k.exe file that was previously hosted by Legacy Update.
; This was a full copy of IE6 SP1, but only for English installations of Windows 2000.
; This is expected to ONLY be run by Legacy Update 1.5 and earlier. It should not be used directly.
!define MUI_UI "modern_aerowizard.exe"
!define MUI_UI_HEADERIMAGE "modern_aerowizard.exe"
!define MUI_CUSTOMFUNCTION_GUIINIT OnShow
!include Constants.nsh
Name "${NAME}"
Caption "${NAME} - Internet Explorer 6 Downloader"
BrandingText "${NAME} ${VERSION} - ${DOMAIN}"
OutFile "ie6setupstub-${VERSION}.exe"
Unicode True
RequestExecutionLevel Admin
AutoCloseWindow true
VIAddVersionKey /LANG=1033 "ProductName" "${NAME} - Internet Explorer 6 Downloader"
VIAddVersionKey /LANG=1033 "ProductVersion" "${LONGVERSION}"
VIAddVersionKey /LANG=1033 "CompanyName" "Hashbang Productions"
VIAddVersionKey /LANG=1033 "LegalCopyright" "© Hashbang Productions. All rights reserved."
VIAddVersionKey /LANG=1033 "FileDescription" "${NAME} - Internet Explorer 6 Downloader"
VIAddVersionKey /LANG=1033 "FileVersion" "${LONGVERSION}"
VIProductVersion ${LONGVERSION}
VIFileVersion ${LONGVERSION}
!define MUI_ICON "..\icon.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "setupbanner.bmp"
!include FileFunc.nsh
!include LogicLib.nsh
!include MUI2.nsh
!include Win\WinNT.nsh
!include WinCore.nsh
!include WinVer.nsh
!include WordFunc.nsh
!include x64.nsh
!include Common.nsh
!include AeroWizard.nsh
!include Download2KXP.nsh
!insertmacro GetParameters
!insertmacro GetOptions
!define MUI_PAGE_HEADER_TEXT "Performing Actions"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW OnShow
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Function OnShow
Call AeroWizardOnShow
FunctionEnd
Section "Internet Explorer 6.0 Service Pack 1" IE6SP1
SectionIn Ro
Call DownloadIE6
Call InstallIE6
SectionEnd
Function .onInit
SetShellVarContext All
!insertmacro EnsureAdminRights
SetDetailsPrint listonly
${IfNot} ${IsWin2000}
MessageBox MB_USERICON "This tool is intended only for use on Windows 2000." /SD IDOK
Quit
${EndIf}
Call NeedsIE6
Pop $0
${If} $0 == 0
MessageBox MB_USERICON "Internet Explorer 6 Service Pack 1 is already installed." /SD IDOK
Quit
${EndIf}
SetOutPath $PLUGINSDIR
File Patches.ini
SetErrorLevel ${ERROR_SUCCESS_REBOOT_REQUIRED}
FunctionEnd

BIN
setup/modern_aerowizard.exe Normal file

Binary file not shown.

944
setup/setup.nsi Normal file
View File

@ -0,0 +1,944 @@
!include Constants.nsh
Name "${NAME}"
Caption "${NAME}"
BrandingText "${NAME} ${VERSION} - ${DOMAIN}"
OutFile "WUIsBack-latest.exe"
InstallDir "$PROGRAMFILES\${NAME}"
InstallDirRegKey HKLM "${REGPATH_LEGACYUPDATE_SETUP}" "InstallDir"
Unicode true
RequestExecutionLevel admin
AutoCloseWindow true
ManifestSupportedOS all
ManifestDPIAware true
AllowSkipFiles off
SetCompressor /SOLID lzma
VIAddVersionKey /LANG=1033 "ProductName" "${NAME}"
VIAddVersionKey /LANG=1033 "ProductVersion" "${LONGVERSION}"
VIAddVersionKey /LANG=1033 "CompanyName" "Hashbang Productions and Vichingo455"
VIAddVersionKey /LANG=1033 "LegalCopyright" "${U+00A9} Hashbang Productions and Vichingo455. All rights reserved."
VIAddVersionKey /LANG=1033 "FileDescription" "${NAME}"
VIAddVersionKey /LANG=1033 "FileVersion" "${LONGVERSION}"
VIProductVersion ${LONGVERSION}
VIFileVersion ${LONGVERSION}
!define MUI_UI "modern_aerowizard.exe"
!define MUI_UI_HEADERIMAGE "modern_aerowizard.exe"
!define MUI_CUSTOMFUNCTION_GUIINIT OnShow
!define MUI_CUSTOMFUNCTION_UNGUIINIT un.OnShow
!define MUI_CUSTOMFUNCTION_ABORT CleanUp
!define MUI_ICON "..\LegacyUpdate\icon.ico"
!define MUI_UNICON "..\LegacyUpdate\icon.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "setupbanner.bmp"
!define MUI_HEADERIMAGE_UNBITMAP "setupbanner.bmp"
!define MUI_TEXT_ABORT_TITLE "Installation Failed"
!define MEMENTO_REGISTRY_ROOT HKLM
!define MEMENTO_REGISTRY_KEY "${REGPATH_LEGACYUPDATE_SETUP}"
Var /GLOBAL InstallDir
Var /GLOBAL RunOnceDir
!include FileFunc.nsh
!include Integration.nsh
!include LogicLib.nsh
!include Memento.nsh
!include MUI2.nsh
!include Sections.nsh
!include Win\COM.nsh
!include Win\WinError.nsh
!include Win\WinNT.nsh
!include WinCore.nsh
!include WinMessages.nsh
!include WinVer.nsh
!include WordFunc.nsh
!include x64.nsh
!include Win32.nsh
!include Common.nsh
!include AeroWizard.nsh
!include Download2KXP.nsh
!include DownloadVista7.nsh
!include Download8.nsh
!include DownloadWUA.nsh
!include RunOnce.nsh
!include UpdateRoots.nsh
!include 7zip.nsh
!insertmacro GetParameters
!insertmacro GetOptions
!define MUI_PAGE_HEADER_TEXT "Welcome to WUIsBack"
!define MUI_COMPONENTSPAGE_TEXT_TOP "Select what you would like WUIsBack to do. An internet connection is required to download additional components from Microsoft. Your computer will restart automatically if needed. Close all other programs before continuing."
!define MUI_PAGE_CUSTOMFUNCTION_PRE ComponentsPageCheck
!define MUI_PAGE_CUSTOMFUNCTION_SHOW OnShow
!define MUI_PAGE_FUNCTION_GUIINIT OnShow
!define MUI_CUSTOMFUNCTION_ONMOUSEOVERSECTION OnMouseOverSection
!insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_HEADER_TEXT "Performing Actions"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW OnShow
!insertmacro MUI_PAGE_INSTFILES
!define MUI_PAGE_HEADER_TEXT "Uninstall WUIsBack"
!define MUI_UNCONFIRMPAGE_TEXT_TOP "WUIsBack will be uninstalled. Your Windows Update configuration will be reset to directly use Microsoft servers."
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.OnShow
!insertmacro MUI_UNPAGE_CONFIRM
!define MUI_PAGE_HEADER_TEXT "Performing Actions"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.OnShow
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!macro RestartWUAUService
!insertmacro DetailPrint "Restarting Windows Update service..."
SetDetailsPrint none
ExecShellWait "" "$WINDIR\system32\net.exe" "stop wuauserv" SW_HIDE
SetDetailsPrint listonly
!macroend
Function OnShow
Call AeroWizardOnShow
FunctionEnd
Function un.OnShow
Call un.AeroWizardOnShow
FunctionEnd
Section -BeforeInstall
!insertmacro InhibitSleep 1
SectionEnd
Section -PreDownload
${IfNot} ${IsRunOnce}
${AndIfNot} ${IsPostInstall}
Call PreDownload
${EndIf}
SectionEnd
Section - PREREQS_START
SectionEnd
; Win2k prerequisities
Section "Windows 2000 Service Pack 4" W2KSP4
SectionIn Ro
Call InstallW2KSP4
Call InstallKB835732
Call RebootIfRequired
SectionEnd
Section "Internet Explorer 6.0 Service Pack 1" IE6SP1
SectionIn Ro
Call InstallIE6
Call RebootIfRequired
SectionEnd
Section "7-Zip File Manager" 7ZIP
Call Install7Zip
SectionEnd
; XP 2002 prerequisities
${MementoSection} "Windows XP Service Pack 3" XPSP3
Call InstallXPSP2
Call RebootIfRequired
Call InstallXPSP3
Call RebootIfRequired
${MementoSectionEnd}
${MementoSection} "Windows XP Embedded Service Pack 3" XPESP3
Call InstallXPESP3
Call RebootIfRequired
${MementoSectionEnd}
; XP 2003 prerequisities
${MementoSection} "Windows XP/Server 2003 Service Pack 2" 2003SP2
Call Install2003SP2
Call RebootIfRequired
${MementoSectionEnd}
; Vista prerequisities
Section "Windows Vista Service Pack 2" VISTASP2
SectionIn Ro
Call InstallVistaSP1
Call RebootIfRequired
Call InstallVistaSP2
Call RebootIfRequired
SectionEnd
Section "Windows Servicing Stack update" VISTASSU
SectionIn Ro
Call InstallKB3205638
Call InstallKB4012583
Call InstallKB4015195
Call InstallKB4015380
Call InstallKB4493730
Call RebootIfRequired
SectionEnd
${MementoSection} "Internet Explorer 9" VISTAIE9
Call InstallKB971512
Call InstallKB2117917
Call RebootIfRequired
Call InstallIE9
Call RebootIfRequired
${MementoSectionEnd}
; 7 prerequisities
Section "Windows 7 Service Pack 1" WIN7SP1
SectionIn Ro
Call InstallWin7SP1
Call RebootIfRequired
SectionEnd
Section "Windows Servicing Stack update" WIN7SSU
SectionIn Ro
Call InstallKB3138612
Call InstallKB4474419
Call InstallKB4490628
Call RebootIfRequired
SectionEnd
; Windows Home Server 2011 (Server 2008 R2) prerequisites
Section "Windows Home Server Update Rollup 4" WHS2011U4
SectionIn Ro
Call InstallKB2757011
Call RebootIfRequired
SectionEnd
; 8 prerequisities
Section "Windows Servicing Stack update" WIN8SSU
SectionIn Ro
Call InstallKB4598297
Call RebootIfRequired
SectionEnd
Section "Windows 8.1" WIN81UPGRADE
; No-op; we'll launch the support site in post-install.
SectionEnd
; 8.1 prerequisities
Section "Windows 8.1 Update 1" WIN81UPDATE1
SectionIn Ro
Call InstallKB3021910
Call InstallClearCompressionFlag
Call InstallKB2919355
Call InstallKB2932046
Call InstallKB2959977
Call InstallKB2937592
Call InstallKB2934018
Call RebootIfRequired
SectionEnd
Section "Windows Servicing Stack update" WIN81SSU
SectionIn Ro
Call InstallKB3021910
Call RebootIfRequired
SectionEnd
; Shared prerequisites
Section "Windows Update Agent update" WUA
SectionIn Ro
Call InstallWUA
SectionEnd
${MementoUnselectedSection} "Enable Windows Embedded 2009 updates" WES09
WriteRegDword HKLM "${REGPATH_POSREADY}" "Installed" 1
${MementoSectionEnd}
${MementoSection} "Update root certificates store" ROOTCERTS
Call ConfigureCrypto
${IfNot} ${IsPostInstall}
Call UpdateRoots
${EndIf}
${MementoSectionEnd}
${MementoSection} "Enable Microsoft Update" WIN7MU
LegacyUpdateNSIS::EnableMicrosoftUpdate
Pop $0
${If} $0 != 0
LegacyUpdateNSIS::MessageForHresult $0
Pop $0
MessageBox MB_USERICON "Failed to enable Microsoft Update.$\r$\n$\r$\n$0" /SD IDOK
${EndIf}
!insertmacro RestartWUAUService
${MementoSectionEnd}
${MementoSection} "Activate Windows" ACTIVATE
; No-op; we'll launch the activation wizard in post-install.
${MementoSectionEnd}
Section - PREREQS_END
SectionEnd
; Main installation
${MementoSection} "WUIsBack" LEGACYUPDATE
SetOutPath $InstallDir
WriteUninstaller "$OUTDIR\Uninstall.exe"
; Add uninstall entry
WriteRegStr HKLM "${REGPATH_UNINSTSUBKEY}" "DisplayName" "${NAME}"
WriteRegStr HKLM "${REGPATH_UNINSTSUBKEY}" "DisplayIcon" '"$OUTDIR\LegacyUpdate.dll",-201'
WriteRegStr HKLM "${REGPATH_UNINSTSUBKEY}" "DisplayVersion" "${VERSION}"
WriteRegStr HKLM "${REGPATH_UNINSTSUBKEY}" "Publisher" "${NAME}"
WriteRegStr HKLM "${REGPATH_UNINSTSUBKEY}" "URLInfoAbout" "${WEBSITE}"
WriteRegStr HKLM "${REGPATH_UNINSTSUBKEY}" "UninstallString" '"$OUTDIR\Uninstall.exe"'
WriteRegStr HKLM "${REGPATH_UNINSTSUBKEY}" "QuietUninstallString" '"$OUTDIR\Uninstall.exe" /S'
WriteRegDword HKLM "${REGPATH_UNINSTSUBKEY}" "NoModify" 1
WriteRegDword HKLM "${REGPATH_UNINSTSUBKEY}" "NoRepair" 1
; Add Control Panel entry
; Category 5: XP Performance and Maintenance, Vista System and Maintenance, 7+ System and Security
; Category 10: XP SP2 Security Center, Vista Security, 7+ System and Security
WriteRegStr HKCR "${REGPATH_CPLCLSID}" "" "${NAME}"
WriteRegStr HKCR "${REGPATH_CPLCLSID}" "LocalizedString" '@"$OUTDIR\LegacyUpdate.dll",-2'
WriteRegStr HKCR "${REGPATH_CPLCLSID}" "InfoTip" '@"$OUTDIR\LegacyUpdate.dll",-4'
WriteRegStr HKCR "${REGPATH_CPLCLSID}\DefaultIcon" "" '"$OUTDIR\LegacyUpdate.dll",-201'
WriteRegStr HKCR "${REGPATH_CPLCLSID}\Shell\Open\Command" "" 'rundll32.exe "$OUTDIR\LegacyUpdate.dll",LaunchUpdateSite'
WriteRegDword HKCR "${REGPATH_CPLCLSID}\ShellFolder" "Attributes" 0
WriteRegDword HKCR "${REGPATH_CPLCLSID}" "{305CA226-D286-468e-B848-2B2E8E697B74} 2" 5
WriteRegStr HKCR "${REGPATH_CPLCLSID}" "System.ApplicationName" "${CPL_APPNAME}"
WriteRegStr HKCR "${REGPATH_CPLCLSID}" "System.ControlPanelCategory" "5,10"
WriteRegStr HKCR "${REGPATH_CPLCLSID}" "System.Software.TasksFileUrl" "$OUTDIR\LegacyUpdate.dll,-202"
WriteRegStr HKLM "${REGPATH_CPLNAMESPACE}" "" "${NAME}"
; Install DLL, with detection for it being in use by IE
; NOTE: Here we specifically check for amd64, because the DLL is amd64.
; We still install to native Program Files on IA64, but with x86 binaries.
SetOverwrite try
!insertmacro TryFile "..\Release\LegacyUpdate.dll" "$OUTDIR\LegacyUpdate.dll"
${If} ${IsNativeAMD64}
${If} ${FileExists} "$OUTDIR\LegacyUpdate32.dll"
!insertmacro TryDelete "$OUTDIR\LegacyUpdate32.dll"
${EndIf}
!insertmacro TryRename "$OUTDIR\LegacyUpdate.dll" "$OUTDIR\LegacyUpdate32.dll"
!insertmacro TryFile "..\x64\Release\LegacyUpdate.dll" "$OUTDIR\LegacyUpdate.dll"
${EndIf}
SetOverwrite on
; Register DLL
${If} ${IsNativeAMD64}
!insertmacro RegisterDLL "" x64 "$OUTDIR\LegacyUpdate.dll"
!insertmacro RegisterDLL "" x86 "$OUTDIR\LegacyUpdate32.dll"
${Else}
!insertmacro RegisterDLL "" x86 "$OUTDIR\LegacyUpdate.dll"
${EndIf}
; Create shortcut
CreateShortcut "$COMMONSTARTMENU\${NAME}.lnk" \
"$SYSDIR\rundll32.exe" '"$OUTDIR\LegacyUpdate.dll",LaunchUpdateSite' \
"$OUTDIR\LegacyUpdate.dll" 0 \
SW_SHOWNORMAL "" \
'@"$OUTDIR\LegacyUpdate.dll",-4'
; Hide WU shortcuts
; TODO: How can we consistently find the shortcuts for non-English installs?
${If} ${AtMostWinXP2003}
${If} ${FileExists} "$COMMONSTARTMENU\Windows Update.lnk"
CreateDirectory "$OUTDIR\Backup"
Rename "$COMMONSTARTMENU\Windows Update.lnk" "$OUTDIR\Backup\Windows Update.lnk"
${EndIf}
${If} ${FileExists} "$COMMONSTARTMENU\Microsoft Update.lnk"
CreateDirectory "$OUTDIR\Backup"
Rename "$COMMONSTARTMENU\Microsoft Update.lnk" "$OUTDIR\Backup\Microsoft Update.lnk"
${EndIf}
${EndIf}
; Add to trusted sites
WriteRegDword HKCU "${REGPATH_ZONEDOMAINS}\${DOMAIN}" "http" 2
WriteRegDword HKCU "${REGPATH_ZONEDOMAINS}\${DOMAIN}" "https" 2
WriteRegDword HKCU "${REGPATH_ZONEESCDOMAINS}\${DOMAIN}" "http" 2
WriteRegDword HKCU "${REGPATH_ZONEESCDOMAINS}\${DOMAIN}" "https" 2
; Delete LegacyUpdate.dll in System32 from 1.0 installer
${If} ${FileExists} $WINDIR\System32\LegacyUpdate.dll
Delete $WINDIR\System32\LegacyUpdate.dll
${EndIf}
; Delete LegacyUpdate.inf from 1.0 installer
${If} ${FileExists} $WINDIR\inf\LegacyUpdate.inf
Delete $WINDIR\inf\LegacyUpdate.inf
${EndIf}
; If 32-bit Legacy Update exists, move it to 64-bit Program Files
${If} ${RunningX64}
${AndIf} ${FileExists} "$PROGRAMFILES32\Legacy Update\Backup"
CreateDirectory "$PROGRAMFILES64\Legacy Update"
Rename "$PROGRAMFILES32\Legacy Update\Backup" "$PROGRAMFILES64\Legacy Update\Backup"
RMDir /r "$PROGRAMFILES32\Legacy Update"
${EndIf}
; Set WSUS server
; Check if Schannel is going to work with modern TLS
!insertmacro DetailPrint "Checking SSL connectivity..."
!insertmacro DownloadRequest "${WSUS_SERVER_HTTPS}/ClientWebService/ping.bin" NONE \
`/TIMEOUTCONNECT 0 /TIMEOUTRECONNECT 0`
Pop $0
Call DownloadWaitSilent
Pop $0
Pop $0
${If} $0 == "OK"
; HTTPS will work
WriteRegStr HKLM "${REGPATH_WUPOLICY}" "WUServer" "${WSUS_SERVER_HTTPS}"
WriteRegStr HKLM "${REGPATH_WUPOLICY}" "WUStatusServer" "${WSUS_SERVER_HTTPS}"
WriteRegStr HKLM "${REGPATH_WU}" "URL" "${UPDATE_URL_HTTPS}"
${Else}
; Probably not supported; use HTTP
WriteRegStr HKLM "${REGPATH_WUPOLICY}" "WUServer" "${WSUS_SERVER}"
WriteRegStr HKLM "${REGPATH_WUPOLICY}" "WUStatusServer" "${WSUS_SERVER}"
WriteRegStr HKLM "${REGPATH_WU}" "URL" "${UPDATE_URL}"
${EndIf}
WriteRegDword HKLM "${REGPATH_WUAUPOLICY}" "UseWUServer" 1
; Restart service
!insertmacro RestartWUAUService
${MementoSectionEnd}
${MementoSection} "Allow OS Upgrade" ALLOWOSUPGRADE
WriteRegDword HKLM "${REGPATH_WUPOLICY}\OSUpgrade" "AllowOSUpgrade" 1
!insertmacro RestartWUAUService
${MementoSectionEnd}
${MementoSectionDone}
Section -Uninstall
SetOutPath $InstallDir
; Delete shortcut
${UnpinShortcut} "$COMMONSTARTMENU\${NAME}.lnk"
Delete "$COMMONSTARTMENU\${NAME}.lnk"
; Delete Control Panel entry
DeleteRegKey HKLM "${REGPATH_CPLNAMESPACE}"
DeleteRegKey HKCR "${REGPATH_CPLCLSID}"
; Restore shortcuts
${If} ${FileExists} "$OUTDIR\Backup\Windows Update.lnk"
Rename "$OUTDIR\Backup\Windows Update.lnk" "$COMMONSTARTMENU\Windows Update.lnk"
${EndIf}
${If} ${FileExists} "$OUTDIR\Backup\Microsoft Update.lnk"
Rename "$OUTDIR\Backup\Microsoft Update.lnk" "$COMMONSTARTMENU\Microsoft Update.lnk"
${EndIf}
; Unregister DLLS
${If} ${IsNativeAMD64}
!insertmacro RegisterDLL Un x64 "$OUTDIR\LegacyUpdate.dll"
!insertmacro RegisterDLL Un x86 "$OUTDIR\LegacyUpdate32.dll"
${Else}
!insertmacro RegisterDLL Un x86 "$OUTDIR\LegacyUpdate.dll"
${EndIf}
; Delete DLLs
SetOverwrite try
!insertmacro TryDelete "$OUTDIR\LegacyUpdate.dll"
!insertmacro TryDelete "$OUTDIR\LegacyUpdate32.dll"
SetOverwrite on
; Clear WSUS server
${If} ${AtMostWinVista}
DeleteRegValue HKLM "${REGPATH_WUPOLICY}" "WUServer"
DeleteRegValue HKLM "${REGPATH_WUPOLICY}" "WUStatusServer"
DeleteRegValue HKLM "${REGPATH_WUAUPOLICY}" "UseWUStatusServer"
DeleteRegValue HKLM "${REGPATH_WU}" "URL"
${EndIf}
; Remove from trusted sites
DeleteRegKey HKCU "${REGPATH_ZONEDOMAINS}\${DOMAIN}"
DeleteRegKey HKCU "${REGPATH_ZONEESCDOMAINS}\${DOMAIN}"
; Restart service
!insertmacro RestartWUAUService
; Delete folders
RMDir /r "$OUTDIR"
RMDir /r /REBOOTOK "$RunOnceDir"
; Delete uninstall entry
DeleteRegKey HKLM "${REGPATH_UNINSTSUBKEY}"
SectionEnd
!define DESCRIPTION_REBOOTS "Your computer will restart automatically to complete installation."
!define DESCRIPTION_SUPEULA "By installing, you are agreeing to the Supplemental End User License Agreement for this update."
!define DESCRIPTION_MSLT "By installing, you are agreeing to the Microsoft Software License Terms for this update."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${W2KSP4} "Updates Windows 2000 to Service Pack 4, as required to install the Windows Update Agent.$\r$\n${DESCRIPTION_REBOOTS} ${DESCRIPTION_SUPEULA}"
!insertmacro MUI_DESCRIPTION_TEXT ${IE6SP1} "Updates Internet Explorer to 6.0 SP1, as required for Legacy Update.$\r$\n${DESCRIPTION_REBOOTS} ${DESCRIPTION_SUPEULA}"
!insertmacro MUI_DESCRIPTION_TEXT ${XPSP3} "Updates Windows XP to Service Pack 3. Required if you would like to activate Windows online. ${DESCRIPTION_REBOOTS} ${DESCRIPTION_SUPEULA}"
!insertmacro MUI_DESCRIPTION_TEXT ${XPESP3} "Updates Windows XP Embedded to Service Pack 3. Required if you would like to activate Windows online. ${DESCRIPTION_REBOOTS} ${DESCRIPTION_SUPEULA}"
!insertmacro MUI_DESCRIPTION_TEXT ${WES09} "Configures Windows to appear as Windows Embedded POSReady 2009 to Windows Update, enabling access to Windows XP security updates released between 2014 and 2019. Please note that Microsoft officially advises against doing this."
!insertmacro MUI_DESCRIPTION_TEXT ${2003SP2} "Updates Windows XP x64 Edition or Windows Server 2003 to Service Pack 2. Required if you would like to activate Windows online. ${DESCRIPTION_REBOOTS} ${DESCRIPTION_SUPEULA}"
!insertmacro MUI_DESCRIPTION_TEXT ${VISTASP2} "Updates Windows Vista or Windows Server 2008 to Service Pack 2, as required to install the Windows Update Agent. ${DESCRIPTION_REBOOTS} ${DESCRIPTION_MSLT}"
!insertmacro MUI_DESCRIPTION_TEXT ${VISTASSU} "Updates Windows Vista or Windows Server 2008 with additional updates required to resolve issues with the Windows Update Agent.$\r$\n${DESCRIPTION_REBOOTS}"
!insertmacro MUI_DESCRIPTION_TEXT ${VISTAIE9} "Updates Internet Explorer to 9.0.$\r$\n${DESCRIPTION_REBOOTS} ${DESCRIPTION_MSLT}"
!insertmacro MUI_DESCRIPTION_TEXT ${WIN7SP1} "Updates Windows 7 or Windows Server 2008 R2 to Service Pack 1, as required to install the Windows Update Agent. ${DESCRIPTION_REBOOTS} ${DESCRIPTION_MSLT}"
!insertmacro MUI_DESCRIPTION_TEXT ${WIN7SSU} "Updates Windows 7 or Windows Server 2008 R2 with additional updates required to resolve issues with the Windows Update Agent.$\r$\n${DESCRIPTION_REBOOTS}"
!insertmacro MUI_DESCRIPTION_TEXT ${WIN8SSU} "Updates Windows 8 or Windows Server 2012 with additional updates required to resolve issues with the Windows Update Agent.$\r$\n${DESCRIPTION_REBOOTS}"
!insertmacro MUI_DESCRIPTION_TEXT ${WIN81UPGRADE} "Windows 8 can be updated to Windows 8.1. This process involves a manual download. After Legacy Update setup completes, a Microsoft website will be opened with more information."
!insertmacro MUI_DESCRIPTION_TEXT ${WIN81UPDATE1} "Updates Windows 8.1 to Update 1, as required to resolve issues with the Windows Update Agent. Also required to upgrade to Windows 10.$\r$\n${DESCRIPTION_REBOOTS}"
!insertmacro MUI_DESCRIPTION_TEXT ${WIN81SSU} "Updates Windows 8.1 or Windows Server 2012 R2 with additional updates required to resolve issues with the Windows Update Agent.$\r$\n${DESCRIPTION_REBOOTS}"
!insertmacro MUI_DESCRIPTION_TEXT ${WHS2011U4} "Updates Windows Home Server 2011 to Update Rollup 4 to resolve issues with the Windows Update Agent. Also fixes data corruption problems.$\r$\n${DESCRIPTION_REBOOTS}"
!insertmacro MUI_DESCRIPTION_TEXT ${WUA} "Updates the Windows Update Agent to the latest version, as required for Legacy Update."
!insertmacro MUI_DESCRIPTION_TEXT ${ROOTCERTS} "Updates the root certificate store to the latest from Microsoft, and enables additional modern security features. Root certificates are used to verify the security of encrypted (https) connections. This fixes connection issues with some websites."
!insertmacro MUI_DESCRIPTION_TEXT ${WIN7MU} "Configures Windows to install updates for Microsoft Office and other Microsoft software."
!insertmacro MUI_DESCRIPTION_TEXT ${ACTIVATE} "Your copy of Windows is not activated. If you update the root certificates store, Windows Product Activation can be completed over the internet. Legacy Update can start the activation wizard after installation so you can activate your copy of Windows."
!insertmacro MUI_DESCRIPTION_TEXT ${ALLOWOSUPGRADE} "Forces Windows Update to deliver the Windows 10/11 upgrade."
!insertmacro MUI_DESCRIPTION_TEXT ${7ZIP} "Installs 7-Zip on Windows 2000 to open zip files.$\r$\n${DESCRIPTION_SUPEULA}"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Function OnMouseOverSection
${If} $0 == ${LEGACYUPDATE}
${If} ${AtMostWinXP2003}
StrCpy $0 "Installs WUIsBack, enabling access to the full Windows Update interface via the legacyupdate.net website. Windows Update will be configured to use the WUIsBack WSUS server."
${ElseIf} ${AtMostWin8.1}
StrCpy $0 "Installs WUIsBack, enabling access to the full Windows Update interface via the legacyupdate.net website, and Windows Update Control Panel. Windows Update will be configured to use the WUIsBack WSUS server."
${Else}
StrCpy $0 "Installs WUIsBack, enabling access to the full Windows Update interface via the legacyupdate.net website, and Windows Update Settings page. Windows Update will be configured to use the WUIsBack WSUS server."
${EndIf}
SendMessage $mui.ComponentsPage.DescriptionText ${WM_SETTEXT} 0 "STR:"
EnableWindow $mui.ComponentsPage.DescriptionText 1
SendMessage $mui.ComponentsPage.DescriptionText ${WM_SETTEXT} 0 "STR:$0"
${EndIf}
FunctionEnd
!macro Init
SetShellVarContext All
${If} ${RunningX64}
SetRegView 64
StrCpy $InstallDir "$PROGRAMFILES64\${NAME}"
${Else}
StrCpy $InstallDir "$PROGRAMFILES32\${NAME}"
${EndIf}
StrCpy $RunOnceDir "$COMMONPROGRAMDATA\Legacy Update"
!insertmacro EnsureAdminRights
SetDetailsPrint listonly
!macroend
Function .onInit
${If} ${IsHelp}
MessageBox MB_USERICON \
"Usage: setup.exe [/S] [/norestart]$\r$\n\
$\r$\n\
/S$\tExecutes WUIsBack setup silently.$\r$\n\
/norestart$\tDisables automatic restart during installation.$\r$\n\
$\r$\n\
If no flags are passed, WUIsBack will launch its full user interface.$\r$\n\
For more information on these flags, visit legacyupdate.net."
Quit
${EndIf}
!insertmacro Init
${If} ${IsRunOnce}
${OrIf} ${IsPostInstall}
Call OnRunOnceLogon
${EndIf}
SetOutPath $PLUGINSDIR
File Patches.ini
SetOutPath $RunOnceDir
${MementoSectionRestore}
${If} ${IsWin2000}
!insertmacro RemoveSection ${ALLOWOSUPGRADE}
; Determine whether Win2k prereqs need to be installed
Call NeedsW2KSP4
Call NeedsKB835732
Pop $0
Pop $1
${If} $0 == 0
${AndIf} $1 == 0
!insertmacro RemoveSection ${W2KSP4}
${EndIf}
; Check if system needs Internet Explorer 6
Call NeedsIE6
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${IE6SP1}
${EndIf}
; Check if 7-Zip is installed
${If} ${FileExists} "$PROGRAMFILES\7-Zip\7zFM.exe"
!insertmacro RemoveSection ${7ZIP}
${EndIf}
${Else}
!insertmacro RemoveSection ${W2KSP4}
!insertmacro RemoveSection ${IE6SP1}
!insertmacro RemoveSection ${7ZIP}
${EndIf}
${If} ${IsWinXP2002}
!insertmacro RemoveSection ${ALLOWOSUPGRADE}
${If} ${IsEmbedded}
; Determine whether XP Embedded prereqs need to be installed
; Windows XP Embedded (version 2001), including FLP and WEPOS, has a different service pack
!insertmacro RemoveSection ${XPSP3}
Call NeedsXPESP3
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${XPESP3}
${EndIf}
${EndIf}
${IfNot} ${IsEmbedded}
; Determine whether XP prereqs need to be installed
!insertmacro RemoveSection ${XPESP3}
Call NeedsXPSP3
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${XPSP3}
${EndIf}
${EndIf}
ReadRegDword $0 HKLM "${REGPATH_POSREADY}" "Installed"
${If} $0 == 1
!insertmacro RemoveSection ${WES09}
${EndIf}
${Else}
!insertmacro RemoveSection ${XPSP3}
!insertmacro RemoveSection ${XPESP3}
!insertmacro RemoveSection ${WES09}
${EndIf}
${If} ${IsWinXP2003}
!insertmacro RemoveSection ${ALLOWOSUPGRADE}
; Determine whether 2003 prereqs need to be installed
Call Needs2003SP2
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${2003SP2}
${EndIf}
${Else}
!insertmacro RemoveSection ${2003SP2}
${EndIf}
${If} ${IsWinVista}
!insertmacro RemoveSection ${ALLOWOSUPGRADE}
; Determine whether Vista prereqs need to be installed
Call NeedsVistaSP2
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${VISTASP2}
${EndIf}
Call NeedsVistaPostSP2
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${VISTASSU}
${EndIf}
Call NeedsIE9
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${VISTAIE9}
${EndIf}
${Else}
!insertmacro RemoveSection ${VISTASP2}
!insertmacro RemoveSection ${VISTASSU}
!insertmacro RemoveSection ${VISTAIE9}
${EndIf}
${If} ${IsWin7}
; Determine whether 7 prereqs need to be installed
Call NeedsWin7SP1
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${WIN7SP1}
${EndIf}
${If} ${IsHomeServer}
Call NeedsKB2757011
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${WHS2011U4}
${EndIf}
${Else}
!insertmacro RemoveSection ${WHS2011U4}
${EndIf}
Call NeedsWin7SHA2
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${WIN7SSU}
${EndIf}
ClearErrors
EnumRegKey $0 HKLM "${REGPATH_WU_SERVICES}\${WU_MU_SERVICE_ID}" 0
${IfNot} ${Errors}
!insertmacro RemoveSection ${WIN7MU}
${EndIf}
${Else}
!insertmacro RemoveSection ${WIN7SP1}
!insertmacro RemoveSection ${WHS2011U4}
!insertmacro RemoveSection ${WIN7SSU}
!insertmacro RemoveSection ${WIN7MU}
${EndIf}
${If} ${IsWin8}
; Determine whether 8 prereqs need to be installed
${IfNot} ${IsWin8}
!insertmacro RemoveSection ${WIN81UPGRADE}
${EndIf}
Call NeedsKB4598297
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${WIN8SSU}
${EndIf}
${Else}
!insertmacro RemoveSection ${WIN81UPGRADE}
!insertmacro RemoveSection ${WIN8SSU}
${EndIf}
${If} ${IsWin8.1}
; Determine whether 8.1 prereqs need to be installed
Call NeedsWin81Update1
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${WIN81UPDATE1}
${EndIf}
Call NeedsKB3021910
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${WIN81SSU}
${EndIf}
${Else}
!insertmacro RemoveSection ${WIN81UPDATE1}
!insertmacro RemoveSection ${WIN81SSU}
${EndIf}
Call DetermineWUAVersion
${If} $0 == ""
!insertmacro RemoveSection ${WUA}
${EndIf}
${If} ${IsWinXP2002}
${OrIf} ${IsWinXP2003}
; Check if the OS needs activation
LegacyUpdateNSIS::IsProcessRunning "wpabaln.exe"
Pop $0
${If} $0 == 0
!insertmacro RemoveSection ${ACTIVATE}
${EndIf}
${Else}
!insertmacro RemoveSection ${ACTIVATE}
${EndIf}
; Try not to be too intrusive on Windows 10 and newer, which are (for now) fine
${If} ${AtLeastWin10}
!insertmacro RemoveSection ${ALLOWOSUPGRADE}
!insertmacro RemoveSection ${ROOTCERTS}
${EndIf}
FunctionEnd
Function ComponentsPageCheck
; Skip the page if we're being launched via RunOnce
${If} ${IsRunOnce}
${OrIf} ${IsPostInstall}
Abort
${EndIf}
; Skip if installer was invoked by IE, and all prerequisites are installed
${If} ${IsActiveXInstall}
${AndIf} ${SectionIsSelected} ${LEGACYUPDATE}
StrCpy $1 0
${For} $0 ${PREREQS_START} ${PREREQS_END}
${If} ${SectionIsSelected} $0
${AndIf} $0 != ${PREREQS_START}
${AndIf} $0 != ${PREREQS_END}
${AndIf} $0 != ${LEGACYUPDATE}
${AndIf} $0 != ${ROOTCERTS}
StrCpy $1 1
${Break}
${EndIf}
${Next}
${If} $1 == 0
Abort
${EndIf}
${EndIf}
FunctionEnd
Function PreDownload
; Win2k
${If} ${IsWin2000}
Call DownloadW2KSP4
Call DownloadKB835732
Call DownloadIE6
${EndIf}
; XP 2002
${If} ${IsWinXP2002}
${AndIf} ${SectionIsSelected} ${XPSP3}
Call DownloadXPSP2
Call DownloadXPSP3
${EndIf}
${If} ${IsWinXP2002}
${AndIf} ${SectionIsSelected} ${XPESP3}
Call DownloadXPESP3
${EndIf}
; XP 2003
${If} ${IsWinXP2003}
${AndIf} ${SectionIsSelected} ${2003SP2}
Call Download2003SP2
${EndIf}
; Vista
${If} ${IsWinVista}
Call DownloadVistaSP1
Call DownloadVistaSP2
Call DownloadKB3205638
Call DownloadKB4012583
Call DownloadKB4015195
Call DownloadKB4015380
Call DownloadKB4493730
${If} ${SectionIsSelected} ${VISTAIE9}
Call DownloadKB971512
Call DownloadKB2117917
Call DownloadIE9
${EndIf}
${EndIf}
; 7
${If} ${IsWin7}
${If} ${IsHomeServer}
Call DownloadKB2757011
${Else}
Call DownloadWin7SP1
${EndIf}
Call DownloadKB3138612
Call DownloadKB4474419
Call DownloadKB4490628
${EndIf}
; 8
${If} ${IsWin8}
Call DownloadKB4598297
${EndIf}
; 8.1
${If} ${IsWin8.1}
Call DownloadKB3021910
Call DownloadClearCompressionFlag
Call DownloadKB2919355
Call DownloadKB2932046
Call DownloadKB2959977
Call DownloadKB2937592
Call DownloadKB2934018
Call DownloadKB3021910
${EndIf}
; General
Call DownloadWUA
${If} ${AtMostWin8.1}
${AndIf} ${SectionIsSelected} ${ROOTCERTS}
Call DownloadRoots
${EndIf}
FunctionEnd
Function PostInstall
; Handle first run flag if needed
${If} ${FileExists} "$InstallDir\LegacyUpdate.dll"
ReadRegDword $0 HKLM "${REGPATH_LEGACYUPDATE_SETUP}" "ActiveXInstalled"
${If} ${Errors}
StrCpy $0 "firstrun"
${Else}
StrCpy $0 ""
${EndIf}
WriteRegDword HKLM "${REGPATH_LEGACYUPDATE_SETUP}" "ActiveXInstalled" 1
${EndIf}
${IfNot} ${Silent}
${AndIfNot} ${IsRunOnce}
${IfNot} ${IsActiveXInstall}
${AndIf} ${SectionIsSelected} ${LEGACYUPDATE}
Exec '$SYSDIR\rundll32.exe "$InstallDir\LegacyUpdate.dll",LaunchUpdateSite $0'
${ElseIf} ${AtLeastWinVista}
Exec '$SYSDIR\wuauclt.exe /ShowWUAutoScan'
${EndIf}
; Launch XP activation wizard if requested by the user
${If} ${SectionIsSelected} ${ACTIVATE}
ExecShell "" "$WINDIR\system32\oobe\msoobe.exe" "/a"
${EndIf}
; Launch Windows 8.1 upgrade site if requested by the user
${If} ${SectionIsSelected} ${WIN81UPGRADE}
ExecShell "" "${WIN81UPGRADE_URL}"
${EndIf}
${EndIf}
FunctionEnd
Function CleanUp
Call CleanUpRunOnce
!insertmacro InhibitSleep 0
${If} ${IsPostInstall}
${OrIfNot} ${RebootFlag}
RMDir /r /REBOOTOK "$RunOnceDir"
${EndIf}
FunctionEnd
Function .onInstSuccess
${MementoSectionSave}
; Reboot now if we need to. Nothing further in this function will be run if we do need to reboot.
Call RebootIfRequired
; If we're done, launch the update site
Call PostInstall
Call CleanUp
FunctionEnd
Function .onInstFailed
Call CleanUp
FunctionEnd
Function .onSelChange
${If} ${SectionIsSelected} ${WES09}
; Check for SSE2.
System::Call 'kernel32::IsProcessorFeaturePresent(i ${PF_XMMI64_INSTRUCTIONS_AVAILABLE}) i .r0'
${If} $0 == 0
MessageBox MB_USERICON "Your processor does not support the Streaming SIMD Extensions 2 (SSE2) instruction set, which is required to install Windows Embedded 2009 updates released after May 2018. Processors that initially implemented SSE2 instructions include the Intel Pentium 4, Pentium M, and AMD Athlon 64.$\r$\n$\r$\nTo protect your Windows installation from becoming corrupted by incompatible updates, this option will be disabled." /SD IDOK
!insertmacro UnselectSection ${WES09}
${EndIf}
${EndIf}
FunctionEnd
Function un.onInit
!insertmacro Init
FunctionEnd
Function un.onUninstSuccess
!insertmacro DetailPrint "Done"
Call un.RebootIfRequired
${IfNot} ${RebootFlag}
Quit
${EndIf}
FunctionEnd

BIN
setup/setupbanner.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

BIN
setup/updroots.exe Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

20
shared/HResult.c Normal file
View File

@ -0,0 +1,20 @@
#include <windows.h>
#include "WUErrors.h"
EXTERN_C LPWSTR GetMessageForHresult(HRESULT hr) {
LPWSTR message;
for (int i = 0; WUErrorMessages[i].hr != 0; i++) {
if (WUErrorMessages[i].hr == hr) {
message = (LPWSTR)LocalAlloc(LPTR, 4096 * sizeof(WCHAR));
lstrcpy(message, WUErrorMessages[i].message);
return message;
}
}
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&message, 0, NULL) == 0) {
message = (LPWSTR)LocalAlloc(LPTR, 1024 * sizeof(WCHAR));
wsprintf(message, L"Error 0x%08x", hr);
}
return message;
}

5
shared/HResult.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include <windows.h>
EXTERN_C LPWSTR GetMessageForHresult(HRESULT hr);

25
shared/VersionInfo.cpp Normal file
View File

@ -0,0 +1,25 @@
#include "stdafx.h"
#include "VersionInfo.h"
static BOOL _loadedVersionInfo = FALSE;
static OSVERSIONINFOEX _versionInfo;
OSVERSIONINFOEX *GetVersionInfo() {
if (!_loadedVersionInfo) {
_loadedVersionInfo = true;
ZeroMemory(&_versionInfo, sizeof(OSVERSIONINFOEX));
_versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx((LPOSVERSIONINFO)&_versionInfo);
}
return &_versionInfo;
}
BOOL IsOSVersionOrLater(DWORD major, DWORD minor) {
OSVERSIONINFOEX *versionInfo = GetVersionInfo();
return versionInfo->dwMajorVersion > major || (versionInfo->dwMajorVersion == major && versionInfo->dwMinorVersion >= minor);
}
BOOL IsOSVersionOrEarlier(DWORD major, DWORD minor) {
OSVERSIONINFOEX *versionInfo = GetVersionInfo();
return versionInfo->dwMajorVersion < major || (versionInfo->dwMajorVersion == major && versionInfo->dwMinorVersion <= minor);
}

6
shared/VersionInfo.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <windows.h>
OSVERSIONINFOEX *GetVersionInfo();
BOOL IsOSVersionOrLater(DWORD major, DWORD minor);
BOOL IsOSVersionOrEarlier(DWORD major, DWORD minor);

45
shared/WMI.cpp Normal file
View File

@ -0,0 +1,45 @@
#include "stdafx.h"
#include "WMI.h"
#include <atlcomcli.h>
#include <wbemcli.h>
#pragma comment(lib, "wbemuuid.lib")
HRESULT QueryWMIProperty(BSTR query, BSTR property, VARIANT *value) {
CComPtr<IWbemLocator> locator;
HRESULT hr = CoCreateInstance(CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (void **)&locator);
if (!SUCCEEDED(hr)) {
return hr;
}
CComPtr<IWbemServices> services;
hr = locator->ConnectServer(_bstr_t(L"ROOT\\CIMV2"), NULL, NULL, NULL, 0, NULL, NULL, &services);
if (!SUCCEEDED(hr)) {
return hr;
}
hr = CoSetProxyBlanket(services, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
if (!SUCCEEDED(hr)) {
return hr;
}
CComPtr<IEnumWbemClassObject> enumerator;
hr = services->ExecQuery(L"WQL", query, WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &enumerator);
if (!SUCCEEDED(hr)) {
return hr;
}
CComPtr<IWbemClassObject> object;
ULONG uReturn = 0;
hr = enumerator->Next(WBEM_INFINITE, 1, &object, &uReturn);
if (!SUCCEEDED(hr)) {
return hr;
}
hr = object->Get(property, 0, value, NULL, NULL);
if (!SUCCEEDED(hr)) {
return hr;
}
return S_OK;
}

6
shared/WMI.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <windows.h>
#include <stdio.h>
#include <comdef.h>
HRESULT QueryWMIProperty(BSTR query, BSTR property, VARIANT *value);

266
shared/WUErrors.c Normal file
View File

@ -0,0 +1,266 @@
#include "stdafx.h"
#include "WUErrors.h"
#include <wuerror.h>
// TODO: There needs to be a better way to do this other than hardcoding all these English strings...
HResultMessage WUErrorMessages[] = {
{ WU_S_SERVICE_STOP, L"Windows Update Agent was stopped successfully." },
{ WU_S_SELFUPDATE, L"Windows Update Agent updated itself." },
{ WU_S_UPDATE_ERROR, L"Operation completed successfully but there were errors applying the updates.." },
{ WU_S_MARKED_FOR_DISCONNECT, L"A callback was marked to be disconnected later because the request to disconnect the operation came while a callback was executing." },
{ WU_S_REBOOT_REQUIRED, L"The system must be restarted to complete installation of the update." },
{ WU_S_ALREADY_INSTALLED, L"The update to be installed is already installed on the system." },
{ WU_S_ALREADY_UNINSTALLED, L"The update to be removed is not installed on the system." },
{ WU_S_ALREADY_DOWNLOADED, L"The update to be downloaded has already been downloaded." },
{ WU_E_NO_SERVICE, L"Windows Update Agent was unable to provide the service." },
{ WU_E_MAX_CAPACITY_REACHED, L"The maximum capacity of the service was exceeded." },
{ WU_E_UNKNOWN_ID, L"An ID cannot be found." },
{ WU_E_NOT_INITIALIZED, L"The object could not be initialized." },
{ WU_E_RANGEOVERLAP, L"The update handler requested a byte range overlapping a previously requested range." },
{ WU_E_TOOMANYRANGES, L"The requested number of byte ranges exceeds the maximum number (2^31 - 1)." },
{ WU_E_INVALIDINDEX, L"The index to a collection was invalid." },
{ WU_E_ITEMNOTFOUND, L"The key for the item queried could not be found." },
{ WU_E_OPERATIONINPROGRESS, L"Another conflicting operation was in progress. Some operations such as installation cannot be performed twice simultaneously." },
{ WU_E_COULDNOTCANCEL, L"Cancellation of the operation was not allowed." },
{ WU_E_CALL_CANCELLED, L"Operation was cancelled." },
{ WU_E_NOOP, L"No operation was required." },
{ WU_E_XML_MISSINGDATA, L"Windows Update Agent could not find required information in the update's XML data." },
{ WU_E_XML_INVALID, L"Windows Update Agent found invalid information in the update's XML data." },
{ WU_E_CYCLE_DETECTED, L"Circular update relationships were detected in the metadata." },
{ WU_E_TOO_DEEP_RELATION, L"Update relationships too deep to evaluate were evaluated." },
{ WU_E_INVALID_RELATIONSHIP, L"An invalid update relationship was detected." },
{ WU_E_REG_VALUE_INVALID, L"An invalid registry value was read." },
{ WU_E_DUPLICATE_ITEM, L"Operation tried to add a duplicate item to a list." },
{ WU_E_INSTALL_NOT_ALLOWED, L"Operation tried to install while another installation was in progress or the system was pending a mandatory restart." },
{ WU_E_NOT_APPLICABLE, L"Operation was not performed because there are no applicable updates." },
{ WU_E_NO_USERTOKEN, L"Operation failed because a required user token is missing." },
{ WU_E_EXCLUSIVE_INSTALL_CONFLICT, L"An exclusive update cannot be installed with other updates at the same time." },
{ WU_E_POLICY_NOT_SET, L"A policy value was not set." },
{ WU_E_SELFUPDATE_IN_PROGRESS, L"The operation could not be performed because the Windows Update Agent is self-updating." },
{ WU_E_INVALID_UPDATE, L"An update contains invalid metadata." },
{ WU_E_SERVICE_STOP, L"Operation did not complete because the service or system was being shut down." },
{ WU_E_NO_CONNECTION, L"Operation did not complete because the network connection was unavailable." },
{ WU_E_NO_INTERACTIVE_USER, L"Operation did not complete because there is no logged-on interactive user." },
{ WU_E_TIME_OUT, L"Operation did not complete because it timed out." },
{ WU_E_ALL_UPDATES_FAILED, L"Operation failed for all the updates." },
{ WU_E_EULAS_DECLINED, L"The license terms for all updates were declined." },
{ WU_E_NO_UPDATE, L"There are no updates." },
{ WU_E_USER_ACCESS_DISABLED, L"Group Policy settings prevented access to Windows Update." },
{ WU_E_INVALID_UPDATE_TYPE, L"The type of update is invalid." },
{ WU_E_URL_TOO_LONG, L"The URL exceeded the maximum length." },
{ WU_E_UNINSTALL_NOT_ALLOWED, L"The update could not be uninstalled because the request did not originate from a WSUS server." },
{ WU_E_INVALID_PRODUCT_LICENSE, L"Search may have missed some updates before there is an unlicensed application on the system." },
{ WU_E_MISSING_HANDLER, L"A component required to detect applicable updates was missing." },
{ WU_E_LEGACYSERVER, L"An operation did not complete because it requires a newer version of server." },
{ WU_E_BIN_SOURCE_ABSENT, L"A delta-compressed update could not be installed because it required the source." },
{ WU_E_SOURCE_ABSENT, L"A full-file update could not be installed because it required the source." },
{ WU_E_WU_DISABLED, L"Access to an unmanaged server is not allowed." },
{ WU_E_CALL_CANCELLED_BY_POLICY, L"Operation did not complete because the DisableWindowsUpdateAccess policy was set." },
{ WU_E_INVALID_PROXY_SERVER, L"The format of the proxy list was invalid." },
{ WU_E_INVALID_FILE, L"The file is in the wrong format." },
{ WU_E_INVALID_CRITERIA, L"The search criteria string was invalid." },
{ WU_E_EULA_UNAVAILABLE, L"License terms could not be downloaded." },
{ WU_E_DOWNLOAD_FAILED, L"Update failed to download." },
{ WU_E_UPDATE_NOT_PROCESSED, L"The update was not processed." },
{ WU_E_INVALID_OPERATION, L"The object's current state did not allow the operation." },
{ WU_E_NOT_SUPPORTED, L"The functionality for the operation is not supported." },
{ WU_E_WINHTTP_INVALID_FILE, L"The downloaded file has an unexpected content type." },
{ WU_E_TOO_MANY_RESYNC, L"Agent is asked by server to resync too many times." },
{ WU_E_NO_SERVER_CORE_SUPPORT, L"WUA API method does not run on Server Core installation." },
{ WU_E_SYSPREP_IN_PROGRESS, L"Service is not available while sysprep is running." },
{ WU_E_UNKNOWN_SERVICE, L"The update service is no longer registered with AU." },
{ WU_E_UNEXPECTED, L"An operation failed due to reasons not covered by another error code." },
{ WU_E_MSI_WRONG_VERSION, L"Search may have missed some updates because the Windows Installer is less than version 3.1." },
{ WU_E_MSI_NOT_CONFIGURED, L"Search may have missed some updates because the Windows Installer is not configured." },
{ WU_E_MSP_DISABLED, L"Search may have missed some updates because policy has disabled Windows Installer patching." },
{ WU_E_MSI_WRONG_APP_CONTEXT, L"An update could not be applied because the application is installed per-user." },
{ WU_E_MSP_UNEXPECTED, L"Search may have missed some updates because there was a failure of the Windows Installer." },
{ WU_E_UH_REMOTEUNAVAILABLE, L"A request for a remote update handler could not be completed because no remote process is available." },
{ WU_E_UH_LOCALONLY, L"A request for a remote update handler could not be completed because the handler is local only." },
{ WU_E_UH_UNKNOWNHANDLER, L"A request for an update handler could not be completed because the handler could not be recognized." },
{ WU_E_UH_REMOTEALREADYACTIVE, L"A remote update handler could not be created because one already exists." },
{ WU_E_UH_DOESNOTSUPPORTACTION, L"A request for the handler to install (uninstall) an update could not be completed because the update does not support install (uninstall)." },
{ WU_E_UH_WRONGHANDLER, L"An operation did not complete because the wrong handler was specified." },
{ WU_E_UH_INVALIDMETADATA, L"A handler operation could not be completed because the update contains invalid metadata." },
{ WU_E_UH_INSTALLERHUNG, L"An operation could not be completed because the installer exceeded the time limit." },
{ WU_E_UH_OPERATIONCANCELLED, L"An operation being done by the update handler was cancelled." },
{ WU_E_UH_BADHANDLERXML, L"An operation could not be completed because the handler-specific metadata is invalid." },
{ WU_E_UH_CANREQUIREINPUT, L"A request to the handler to install an update could not be completed because the update requires user input." },
{ WU_E_UH_INSTALLERFAILURE, L"The installer failed to install (uninstall) one or more updates." },
{ WU_E_UH_FALLBACKTOSELFCONTAINED, L"The update handler should download self-contained content rather than delta-compressed content for the update." },
{ WU_E_UH_NEEDANOTHERDOWNLOAD, L"The update handler did not install the update because it needs to be downloaded again." },
{ WU_E_UH_NOTIFYFAILURE, L"The update handler failed to send notification of the status of the install (uninstall) operation." },
{ WU_E_UH_INCONSISTENT_FILE_NAMES, L"The file names contained in the update metadata and in the update package are inconsistent." },
{ WU_E_UH_FALLBACKERROR, L"The update handler failed to fall back to the self-contained content." },
{ WU_E_UH_TOOMANYDOWNLOADREQUESTS, L"The update handler has exceeded the maximum number of download requests." },
{ WU_E_UH_UNEXPECTEDCBSRESPONSE, L"The update handler has received an unexpected response from CBS." },
{ WU_E_UH_BADCBSPACKAGEID, L"The update metadata contains an invalid CBS package identifier." },
{ WU_E_UH_POSTREBOOTSTILLPENDING, L"The post-reboot operation for the update is still in progress." },
{ WU_E_UH_POSTREBOOTRESULTUNKNOWN, L"The result of the post-reboot operation for the update could not be determined." },
{ WU_E_UH_POSTREBOOTUNEXPECTEDSTATE, L"The state of the update after its post-reboot operation has completed is unexpected." },
{ WU_E_UH_NEW_SERVICING_STACK_REQUIRED, L"The operating system servicing stack must be updated before this update is downloaded or installed." },
{ WU_E_UH_UNEXPECTED, L"An update handler error not covered by another WU_E_UH_* code." },
{ WU_E_INSTALLATION_RESULTS_UNKNOWN_VERSION, L"The results of download and installation could not be read from the registry due to an unrecognized data format version." },
{ WU_E_INSTALLATION_RESULTS_INVALID_DATA, L"The results of download and installation could not be read from the registry due to an invalid data format." },
{ WU_E_INSTALLATION_RESULTS_NOT_FOUND, L"The results of download and installation are not available; the operation may have failed to start." },
{ WU_E_TRAYICON_FAILURE, L"A failure occurred when trying to create an icon in the taskbar notification area." },
{ WU_E_NON_UI_MODE, L"Unable to show UI when in non-UI mode; WU client UI modules may not be installed." },
{ WU_E_WUCLTUI_UNSUPPORTED_VERSION, L"Unsupported version of WU client UI exported functions." },
{ WU_E_AUCLIENT_UNEXPECTED, L"There was a user interface error not covered by another WU_E_AUCLIENT_* error code." },
{ WU_E_PT_SOAPCLIENT_BASE, L"WU_E_PT_SOAPCLIENT_* error codes map to the SOAPCLIENT_ERROR enum of the ATL Server Library." },
{ WU_E_PT_SOAPCLIENT_INITIALIZE, L"SOAPCLIENT_INITIALIZE_ERROR - initialization of the SOAP client failed, possibly because of an MSXML installation failure." },
{ WU_E_PT_SOAPCLIENT_OUTOFMEMORY, L"SOAPCLIENT_OUTOFMEMORY - SOAP client failed because it ran out of memory." },
{ WU_E_PT_SOAPCLIENT_GENERATE, L"SOAPCLIENT_GENERATE_ERROR - SOAP client failed to generate the request." },
{ WU_E_PT_SOAPCLIENT_CONNECT, L"SOAPCLIENT_CONNECT_ERROR - SOAP client failed to connect to the server." },
{ WU_E_PT_SOAPCLIENT_SEND, L"SOAPCLIENT_SEND_ERROR - SOAP client failed to send a message for reasons of WU_E_WINHTTP_* error codes." },
{ WU_E_PT_SOAPCLIENT_SERVER, L"SOAPCLIENT_SERVER_ERROR - SOAP client failed because there was a server error." },
{ WU_E_PT_SOAPCLIENT_SOAPFAULT, L"SOAPCLIENT_SOAPFAULT - SOAP client failed because there was a SOAP fault for reasons of WU_E_PT_SOAP_* error codes." },
{ WU_E_PT_SOAPCLIENT_PARSEFAULT, L"SOAPCLIENT_PARSEFAULT_ERROR - SOAP client failed to parse a SOAP fault." },
{ WU_E_PT_SOAPCLIENT_READ, L"SOAPCLIENT_READ_ERROR - SOAP client failed while reading the response from the server." },
{ WU_E_PT_SOAPCLIENT_PARSE, L"SOAPCLIENT_PARSE_ERROR - SOAP client failed to parse the response from the server." },
{ WU_E_PT_SOAP_VERSION, L"SOAP_E_VERSION_MISMATCH - SOAP client found an unrecognizable namespace for the SOAP envelope." },
{ WU_E_PT_SOAP_MUST_UNDERSTAND, L"SOAP_E_MUST_UNDERSTAND - SOAP client was unable to understand a header." },
{ WU_E_PT_SOAP_CLIENT, L"SOAP_E_CLIENT - SOAP client found the message was malformed; fix before resending." },
{ WU_E_PT_SOAP_SERVER, L"SOAP_E_SERVER - The SOAP message could not be processed due to a server error; resend later." },
{ WU_E_PT_WMI_ERROR, L"There was an unspecified Windows Management Instrumentation (WMI) error." },
{ WU_E_PT_EXCEEDED_MAX_SERVER_TRIPS, L"The number of round trips to the server exceeded the maximum limit." },
{ WU_E_PT_SUS_SERVER_NOT_SET, L"WUServer policy value is missing in the registry." },
{ WU_E_PT_DOUBLE_INITIALIZATION, L"Initialization failed because the object was already initialized." },
{ WU_E_PT_INVALID_COMPUTER_NAME, L"The computer name could not be determined." },
{ WU_E_PT_REFRESH_CACHE_REQUIRED, L"The reply from the server indicates that the server was changed or the cookie was invalid; refresh the state of the internal cache and retry." },
{ WU_E_PT_HTTP_STATUS_BAD_REQUEST, L"HTTP 400 - the server could not process the request due to invalid syntax." },
{ WU_E_PT_HTTP_STATUS_DENIED, L"HTTP 401 - the requested resource requires user authentication." },
{ WU_E_PT_HTTP_STATUS_FORBIDDEN, L"HTTP 403 - server understood the request, but declined to fulfill it." },
{ WU_E_PT_HTTP_STATUS_NOT_FOUND, L"HTTP 404 - the server cannot find the requested URI (Uniform Resource Identifier)." },
{ WU_E_PT_HTTP_STATUS_BAD_METHOD, L"HTTP 405 - the HTTP method is not allowed." },
{ WU_E_PT_HTTP_STATUS_PROXY_AUTH_REQ, L"HTTP 407 - proxy authentication is required." },
{ WU_E_PT_HTTP_STATUS_REQUEST_TIMEOUT, L"HTTP 408 - the server timed out waiting for the request." },
{ WU_E_PT_HTTP_STATUS_CONFLICT, L"HTTP 409 - the request was not completed due to a conflict with the current state of the resource." },
{ WU_E_PT_HTTP_STATUS_GONE, L"HTTP 410 - requested resource is no longer available at the server." },
{ WU_E_PT_HTTP_STATUS_SERVER_ERROR, L"HTTP 500 - an error internal to the server prevented fulfilling the request." },
{ WU_E_PT_HTTP_STATUS_NOT_SUPPORTED, L"HTTP 501 - server does not support the functionality required to fulfill the request." },
{ WU_E_PT_HTTP_STATUS_BAD_GATEWAY, L"HTTP 502 - the server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request." },
{ WU_E_PT_HTTP_STATUS_SERVICE_UNAVAIL, L"HTTP 503 - the service is temporarily overloaded." },
{ WU_E_PT_HTTP_STATUS_GATEWAY_TIMEOUT, L"HTTP 504 - the request was timed out waiting for a gateway." },
{ WU_E_PT_HTTP_STATUS_VERSION_NOT_SUP, L"HTTP 505 - the server does not support the HTTP protocol version used for the request." },
{ WU_E_PT_FILE_LOCATIONS_CHANGED, L"Operation failed due to a changed file location; refresh internal state and resend." },
{ WU_E_PT_REGISTRATION_NOT_SUPPORTED, L"Operation failed because Windows Update Agent does not support registration with a non-WSUS server." },
{ WU_E_PT_NO_AUTH_PLUGINS_REQUESTED, L"The server returned an empty authentication information list." },
{ WU_E_PT_NO_AUTH_COOKIES_CREATED, L"Windows Update Agent was unable to create any valid authentication cookies." },
{ WU_E_PT_INVALID_CONFIG_PROP, L"A configuration property value was wrong." },
{ WU_E_PT_CONFIG_PROP_MISSING, L"A configuration property value was missing." },
{ WU_E_PT_HTTP_STATUS_NOT_MAPPED, L"The HTTP request could not be completed and the reason did not correspond to any of the WU_E_PT_HTTP_* error codes." },
{ WU_E_PT_WINHTTP_NAME_NOT_RESOLVED, L"ERROR_WINHTTP_NAME_NOT_RESOLVED - the proxy server or target server name cannot be resolved." },
{ WU_E_PT_ECP_SUCCEEDED_WITH_ERRORS, L"External cab file processing completed with some errors. (Confirm that download.windowsupdate.com and www.download.windowsupdate.com aren't being blocked by a firewall.)" },
{ WU_E_PT_ECP_INIT_FAILED, L"The external cab processor initialization did not complete." },
{ WU_E_PT_ECP_INVALID_FILE_FORMAT, L"The format of a metadata file was invalid." },
{ WU_E_PT_ECP_INVALID_METADATA, L"External cab processor found invalid metadata." },
{ WU_E_PT_ECP_FAILURE_TO_EXTRACT_DIGEST, L"The file digest could not be extracted from an external cab file." },
{ WU_E_PT_ECP_FAILURE_TO_DECOMPRESS_CAB_FILE, L"An external cab file could not be decompressed." },
{ WU_E_PT_ECP_FILE_LOCATION_ERROR, L"External cab processor was unable to get file locations." },
{ WU_E_PT_UNEXPECTED, L"A communication error not covered by another WU_E_PT_* error code" },
{ WU_E_REDIRECTOR_LOAD_XML, L"The redirector XML document could not be loaded into the DOM class." },
{ WU_E_REDIRECTOR_S_FALSE, L"The redirector XML document is missing some required information." },
{ WU_E_REDIRECTOR_ID_SMALLER, L"The redirector ID in the downloaded redirector cab is less than in the cached cab." },
{ WU_E_PT_SAME_REDIR_ID, L"Windows Update Agent failed to download a redirector cabinet file with a new redirector ID value from the server during the recovery." },
{ WU_E_PT_NO_MANAGED_RECOVER, L"A redirector recovery action did not complete because the server is managed." },
{ WU_E_REDIRECTOR_UNEXPECTED, L"The redirector failed for reasons not covered by another WU_E_REDIRECTOR_* error code." },
{ WU_E_DM_URLNOTAVAILABLE, L"A download manager operation could not be completed because the requested file does not have a URL." },
{ WU_E_DM_INCORRECTFILEHASH, L"A download manager operation could not be completed because the file digest was not recognized." },
{ WU_E_DM_UNKNOWNALGORITHM, L"A download manager operation could not be completed because the file metadata requested an unrecognized hash algorithm." },
{ WU_E_DM_NEEDDOWNLOADREQUEST, L"An operation could not be completed because a download request is required from the download handler." },
{ WU_E_DM_NONETWORK, L"A download manager operation could not be completed because the network connection was unavailable." },
{ WU_E_DM_WRONGBITSVERSION, L"A download manager operation could not be completed because the version of Background Intelligent Transfer Service (BITS) is incompatible." },
{ WU_E_DM_NOTDOWNLOADED, L"The update has not been downloaded." },
{ WU_E_DM_FAILTOCONNECTTOBITS, L"A download manager operation failed because the download manager was unable to connect the Background Intelligent Transfer Service (BITS)." },
{ WU_E_DM_BITSTRANSFERERROR, L"A download manager operation failed because there was an unspecified Background Intelligent Transfer Service (BITS) transfer error." },
{ WU_E_DM_DOWNLOADLOCATIONCHANGED, L"A download must be restarted because the location of the source of the download has changed." },
{ WU_E_DM_CONTENTCHANGED, L"A download must be restarted because the update content changed in a new revision." },
{ WU_E_DM_UNEXPECTED, L"There was a download manager error not covered by another WU_E_DM_* error code." },
{ WU_E_OL_INVALID_SCANFILE, L"An operation could not be completed because the scan package was invalid." },
{ WU_E_OL_NEWCLIENT_REQUIRED, L"An operation could not be completed because the scan package requires a greater version of the Windows Update Agent." },
{ WU_E_OL_UNEXPECTED, L"Search using the scan package failed." },
{ WU_E_REPORTER_EVENTCACHECORRUPT, L"The event cache file was defective." },
{ WU_E_REPORTER_EVENTNAMESPACEPARSEFAILED, L"The XML in the event namespace descriptor could not be parsed." },
{ WU_E_INVALID_EVENT, L"The XML in the event namespace descriptor could not be parsed." },
{ WU_E_SERVER_BUSY, L"The server rejected an event because the server was too busy." },
{ WU_E_REPORTER_UNEXPECTED, L"There was a reporter error not covered by another error code." },
{ WU_E_DS_SHUTDOWN, L"An operation failed because Windows Update Agent is shutting down." },
{ WU_E_DS_INUSE, L"An operation failed because the data store was in use." },
{ WU_E_DS_INVALID, L"The current and expected states of the data store do not match." },
{ WU_E_DS_TABLEMISSING, L"The data store is missing a table." },
{ WU_E_DS_TABLEINCORRECT, L"The data store contains a table with unexpected columns." },
{ WU_E_DS_INVALIDTABLENAME, L"A table could not be opened because the table is not in the data store." },
{ WU_E_DS_BADVERSION, L"The current and expected versions of the data store do not match." },
{ WU_E_DS_NODATA, L"The information requested is not in the data store." },
{ WU_E_DS_MISSINGDATA, L"The data store is missing required information or has a NULL in a table column that requires a non-null value." },
{ WU_E_DS_MISSINGREF, L"The data store is missing required information or has a reference to missing license terms, file, localized property or linked row." },
{ WU_E_DS_UNKNOWNHANDLER, L"The update was not processed because its update handler could not be recognized." },
{ WU_E_DS_CANTDELETE, L"The update was not deleted because it is still referenced by one or more services." },
{ WU_E_DS_LOCKTIMEOUTEXPIRED, L"The data store section could not be locked within the allotted time." },
{ WU_E_DS_NOCATEGORIES, L"The category was not added because it contains no parent categories and is not a top-level category itself." },
{ WU_E_DS_ROWEXISTS, L"The row was not added because an existing row has the same primary key." },
{ WU_E_DS_STOREFILELOCKED, L"The data store could not be initialized because it was locked by another process." },
{ WU_E_DS_CANNOTREGISTER, L"The data store is not allowed to be registered with COM in the current process." },
{ WU_E_DS_UNABLETOSTART, L"Could not create a data store object in another process." },
{ WU_E_DS_DUPLICATEUPDATEID, L"The server sent the same update to the client with two different revision IDs." },
{ WU_E_DS_UNKNOWNSERVICE, L"An operation did not complete because the service is not in the data store." },
{ WU_E_DS_SERVICEEXPIRED, L"An operation did not complete because the registration of the service has expired." },
{ WU_E_DS_DECLINENOTALLOWED, L"A request to hide an update was declined because it is a mandatory update or because it was deployed with a deadline." },
{ WU_E_DS_TABLESESSIONMISMATCH, L"A table was not closed because it is not associated with the session." },
{ WU_E_DS_SESSIONLOCKMISMATCH, L"A table was not closed because it is not associated with the session." },
{ WU_E_DS_NEEDWINDOWSSERVICE, L"A request to remove the Windows Update service or to unregister it with Automatic Updates was declined because it is a built-in service and/or Automatic Updates cannot fall back to another service." },
{ WU_E_DS_INVALIDOPERATION, L"A request was declined because the operation is not allowed." },
{ WU_E_DS_SCHEMAMISMATCH, L"The schema of the current data store and the schema of a table in a backup XML document do not match." },
{ WU_E_DS_RESETREQUIRED, L"The data store requires a session reset; release the session and retry with a new session." },
{ WU_E_DS_IMPERSONATED, L"A data store operation did not complete because it was requested with an impersonated identity." },
{ WU_E_DS_UNEXPECTED, L"A data store error not covered by another WU_E_DS_* code." },
{ WU_E_INVENTORY_PARSEFAILED, L"Parsing of the rule file failed." },
{ WU_E_INVENTORY_GET_INVENTORY_TYPE_FAILED, L"Failed to get the requested inventory type from the server." },
{ WU_E_INVENTORY_RESULT_UPLOAD_FAILED, L"Failed to upload inventory result to the server." },
{ WU_E_INVENTORY_UNEXPECTED, L"There was an inventory error not covered by another error code." },
{ WU_E_INVENTORY_WMI_ERROR, L"A WMI error occurred when enumerating the instances for a particular class." },
{ WU_E_AU_NOSERVICE, L"Automatic Updates was unable to service incoming requests." },
{ WU_E_AU_NONLEGACYSERVER, L"The old version of the Automatic Updates client has stopped because the WSUS server has been upgraded." },
{ WU_E_AU_LEGACYCLIENTDISABLED, L"The old version of the Automatic Updates client was disabled." },
{ WU_E_AU_PAUSED, L"Automatic Updates was unable to process incoming requests because it was paused." },
{ WU_E_AU_NO_REGISTERED_SERVICE, L"No unmanaged service is registered with AU." },
{ WU_E_AU_UNEXPECTED, L"An Automatic Updates error not covered by another WU_E_AU * code." },
{ WU_E_DRV_PRUNED, L"A driver was skipped." },
{ WU_E_DRV_NOPROP_OR_LEGACY, L"A property for the driver could not be found. It may not conform with required specifications." },
{ WU_E_DRV_REG_MISMATCH, L"The registry type read for the driver does not match the expected type." },
{ WU_E_DRV_NO_METADATA, L"The driver update is missing metadata." },
{ WU_E_DRV_MISSING_ATTRIBUTE, L"The driver update is missing a required attribute." },
{ WU_E_DRV_SYNC_FAILED, L"Driver synchronization failed." },
{ WU_E_DRV_NO_PRINTER_CONTENT, L"Information required for the synchronization of applicable printers is missing." },
{ WU_E_DRV_UNEXPECTED, L"A driver error not covered by another WU_E_DRV_* code." },
{ WU_E_SETUP_INVALID_INFDATA, L"Windows Update Agent could not be updated because an INF file contains invalid information." },
{ WU_E_SETUP_INVALID_IDENTDATA, L"Windows Update Agent could not be updated because the wuident.cab file contains invalid information." },
{ WU_E_SETUP_ALREADY_INITIALIZED, L"Windows Update Agent could not be updated because of an internal error that caused setup initialization to be performed twice." },
{ WU_E_SETUP_NOT_INITIALIZED, L"Windows Update Agent could not be updated because setup initialization never completed successfully." },
{ WU_E_SETUP_SOURCE_VERSION_MISMATCH, L"Windows Update Agent could not be updated because the versions specified in the INF do not match the actual source file versions." },
{ WU_E_SETUP_TARGET_VERSION_GREATER, L"Windows Update Agent could not be updated because a WUA file on the target system is newer than the corresponding source file." },
{ WU_E_SETUP_REGISTRATION_FAILED, L"Windows Update Agent could not be updated because regsvr32.exe returned an error." },
{ WU_E_SELFUPDATE_SKIP_ON_FAILURE, L"An update to the Windows Update Agent was skipped because previous attempts to update have failed." },
{ WU_E_SETUP_SKIP_UPDATE, L"An update to the Windows Update Agent was skipped due to a directive in the wuident.cab file." },
{ WU_E_SETUP_UNSUPPORTED_CONFIGURATION, L"Windows Update Agent could not be updated because the current system configuration is not supported." },
{ WU_E_SETUP_BLOCKED_CONFIGURATION, L"Windows Update Agent could not be updated because the system is configured to block the update." },
{ WU_E_SETUP_REBOOT_TO_FIX, L"Windows Update Agent could not be updated because a restart of the system is required." },
{ WU_E_SETUP_ALREADYRUNNING, L"Windows Update Agent setup is already running." },
{ WU_E_SETUP_REBOOTREQUIRED, L"Windows Update Agent setup package requires a reboot to complete installation." },
{ WU_E_SETUP_HANDLER_EXEC_FAILURE, L"Windows Update Agent could not be updated because the setup handler failed during execution." },
{ WU_E_SETUP_INVALID_REGISTRY_DATA, L"Windows Update Agent could not be updated because the registry contains invalid information." },
{ WU_E_SELFUPDATE_REQUIRED, L"Windows Update Agent must be updated before search can continue." },
{ WU_E_SELFUPDATE_REQUIRED_ADMIN, L"Windows Update Agent must be updated before search can continue. An administrator is required to perform the operation." },
{ WU_E_SETUP_WRONG_SERVER_VERSION, L"Windows Update Agent could not be updated because the server does not contain update information for this version." },
{ WU_E_SETUP_UNEXPECTED, L"Windows Update Agent could not be updated because of an error not covered by another WU_E_SETUP_* error code." },
{ WU_E_EE_UNKNOWN_EXPRESSION, L"An expression evaluator operation could not be completed because an expression was unrecognized." },
{ WU_E_EE_INVALID_EXPRESSION, L"An expression evaluator operation could not be completed because an expression was invalid." },
{ WU_E_EE_MISSING_METADATA, L"An expression evaluator operation could not be completed because an expression contains an incorrect number of metadata nodes." },
{ WU_E_EE_INVALID_VERSION, L"An expression evaluator operation could not be completed because the version of the serialized expression data is invalid." },
{ WU_E_EE_NOT_INITIALIZED, L"The expression evaluator could not be initialized." },
{ WU_E_EE_INVALID_ATTRIBUTEDATA, L"An expression evaluator operation could not be completed because there was an invalid attribute." },
{ WU_E_EE_CLUSTER_ERROR, L"An expression evaluator operation could not be completed because the cluster state of the computer could not be determined." },
{ WU_E_EE_UNEXPECTED, L"There was an expression evaluator error not covered by another WU_E_EE_* error code." },
NULL
};

9
shared/WUErrors.h Normal file
View File

@ -0,0 +1,9 @@
#pragma once
#include <windows.h>
struct HResultMessage {
HRESULT hr;
const LPWSTR message;
};
EXTERN_C HResultMessage WUErrorMessages[];

0
shared/stdafx.h Normal file
View File