18 Commits

Author SHA1 Message Date
3748c7518f v2.4 2025-11-04 17:53:24 +01:00
5877626155 v2.4 hopefully 2025-11-04 17:27:21 +01:00
0af2129fe3 Fix root certs on Windows 10 and higher 2025-09-28 14:43:59 +00:00
b74d09b399 Update setup/setup.nsi 2025-09-28 14:42:26 +00:00
846e99ca70 Update setup/setup.nsi 2025-09-28 14:40:53 +00:00
fcca984693 Remove Allow OS Upgrade keys when uninstalling 2025-09-28 14:08:26 +00:00
02a1f94ec4 Do not update root certificates on Windows 10+ 2025-09-28 14:02:27 +00:00
7648e3e921 FIX: WSUS keys not removed on uninstall 2025-09-28 13:26:43 +00:00
8afc9e1840 More bug fixes 2025-05-29 15:29:45 +02:00
68b1f6f9f4 Bug fixes 2025-05-29 08:34:24 +02:00
8ad6844368 Bunch of fixes for release 2025-05-25 12:44:22 +02:00
e19aca6924 Various fixes 2025-05-12 12:44:49 +02:00
4396df96c9 Work on KB3102810 2025-04-03 09:58:41 +02:00
f3788da75a Add KB3102810 2025-04-03 09:50:44 +02:00
Useful Stuffs
763787ab30 Change setup URL 2025-04-02 13:30:13 +02:00
Useful Stuffs
c538d64620 Uninstalling LU from the setup 2025-03-28 17:43:22 +01:00
Vichingo455
775a3e07d1 Fix GitHub Actions 2025-03-23 15:30:09 +01:00
Vichingo455
ad8366918e Test 2025-03-23 15:26:15 +01:00
104 changed files with 4178 additions and 3165 deletions

10
.editorconfig Normal file
View File

@@ -0,0 +1,10 @@
# http://editorconfig.org
root = true
[*]
indent_style = tab
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

3
.gitattributes vendored Normal file
View File

@@ -0,0 +1,3 @@
* text=auto eol=lf
*.sln eol=crlf
*.vcxproj eol=crlf

View File

@@ -1,38 +0,0 @@
name: WUIsBack Nightly AutoBuilder
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- name: Download repository
uses: actions/checkout@v3
- name: Install NSIS
run: |
iwr -useb get.scoop.sh -outfile 'install.ps1'
.\install.ps1 -RunAsAdmin
scoop update
scoop bucket add extras
scoop install nsis
- name: Download latest DLL
run: |
md .\Release
md .\x64\Release
md .\launcher\obj
iwr http://vichingo455.ddns.net/en/downloads/WUIsBack-nightly/LegacyUpdate32.dll -outfile '.\Release\LegacyUpdate.dll'
iwr http://vichingo455.ddns.net/en/downloads/WUIsBack-nightly/LegacyUpdate64.dll -outfile '.\x64\Release\LegacyUpdate.dll'
iwr http://vichingo455.ddns.net/en/downloads/WUIsBack-nightly/LegacyUpdate32.exe -outfile '.\launcher\obj\LegacyUpdate32.exe'
iwr http://vichingo455.ddns.net/en/downloads/WUIsBack-nightly/LegacyUpdate64.exe -outfile '.\launcher\obj\LegacyUpdate64.exe'
- name: Compile WUIsBack
run: |
makensis "setup\setup.nsi"
- name: Upload Nightly Build
uses: actions/upload-artifact@v4
with:
name: WUIsBack-nightly
path: setup/WUIsBack-latest.exe

125
.gitignore vendored Normal file
View File

@@ -0,0 +1,125 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
*.userprefs
# Build results
Debug/
Debug-VC08/
Debug-VC17/
Release/
*.exe
*.dll
!setup/modern_aerowizard.exe
!setup/x86-unicode/*.dll
setup/x86-unicode/LegacyUpdateNSIS.dll
obj/
*_layout.inf
# Visual Studio 2015/2017 cache/options directory
.vs/
# Visual Studio 2017 auto generated files
Generated\ Files/
# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*idl.h
*.i
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# VS Code
.vscode/

View File

@@ -1,37 +0,0 @@
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

View File

@@ -1,53 +0,0 @@
#include "stdafx.h"
#include <comdef.h>
#include "Utils.h"
#ifndef PROCESS_PER_MONITOR_DPI_AWARE
typedef int PROCESS_DPI_AWARENESS;
#define PROCESS_PER_MONITOR_DPI_AWARE 2
#endif
#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
typedef int DPI_AWARENESS_CONTEXT;
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4)
#endif
typedef BOOL (WINAPI *_GetProductInfo)(DWORD, DWORD, DWORD, DWORD, PDWORD);
typedef BOOL (WINAPI *_SetProcessDpiAwarenessContext)(DPI_AWARENESS_CONTEXT);
typedef HRESULT (WINAPI *_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS);
typedef void (WINAPI *_SetProcessDPIAware)();
_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;
}
}
void BecomeDPIAware() {
// Make the process DPI-aware... hopefully
// Windows 10 1703+ per-monitor v2
_SetProcessDpiAwarenessContext $SetProcessDpiAwarenessContext = (_SetProcessDpiAwarenessContext)GetProcAddress(LoadLibrary(L"user32.dll"), "SetProcessDpiAwarenessContext");
if ($SetProcessDpiAwarenessContext) {
$SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
return;
}
// Windows 8.1 - 10 1607 per-monitor v1
_SetProcessDpiAwareness $SetProcessDpiAwareness = (_SetProcessDpiAwareness)GetProcAddress(LoadLibrary(L"shcore.dll"), "SetProcessDpiAwareness");
if ($SetProcessDpiAwareness) {
$SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
return;
}
// Windows Vista - 8
_SetProcessDPIAware $SetProcessDPIAware = (_SetProcessDPIAware)GetProcAddress(LoadLibrary(L"user32.dll"), "SetProcessDPIAware");
if ($SetProcessDPIAware) {
$SetProcessDPIAware();
}
}

View File

@@ -1,4 +0,0 @@
#pragma once
BOOL GetVistaProductInfo(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dwSpMajorVersion, DWORD dwSpMinorVersion, PDWORD pdwReturnedProductType);
void BecomeDPIAware();

View File

@@ -1,84 +0,0 @@
// ElevationHelper.cpp : Implementation of CElevationHelper
#include "stdafx.h"
#include "Compat.h"
#include "ElevationHelper.h"
#include "HResult.h"
#include "Utils.h"
#include <strsafe.h>
const BSTR permittedProgIDs[] = {
L"Microsoft.Update.",
NULL
};
BOOL ProgIDIsPermitted(PWSTR progID) {
if (progID == NULL) {
return FALSE;
}
for (int i = 0; permittedProgIDs[i] != NULL; 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);
}
CElevationHelper::CElevationHelper() {
BecomeDPIAware();
}
STDMETHODIMP 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;
}
STDMETHODIMP CElevationHelper::Reboot(void) {
return ::Reboot();
}

View File

@@ -1,45 +0,0 @@
#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);
STDMETHODIMP Reboot(void);
};
OBJECT_ENTRY_AUTO(__uuidof(ElevationHelper), CElevationHelper)

View File

@@ -1,31 +0,0 @@
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%,-1'
TypeLib = s '{05D22F33-C7C3-4C90-BDD9-CEDC86EA8FBE}'
Version = s '1.0'
Elevation
{
val Enabled = d '1'
}
}
}
}

View File

@@ -1,36 +0,0 @@
#include "stdafx.h"
#include "Exec.h"
#include "HResult.h"
#include "LegacyUpdate.h"
#include <shellapi.h>
// Function signature required by Rundll32.exe.
void CALLBACK LaunchUpdateSite(HWND hwnd, HINSTANCE hInstance, LPSTR lpszCmdLine, int nCmdShow) {
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
LPWSTR path;
if (!SUCCEEDED(hr)) {
goto end;
}
// This just calls LegacyUpdate.exe now for backwards compatibility.
hr = GetInstallPath(&path);
if (!SUCCEEDED(hr)) {
goto end;
}
PathAppend(path, L"LegacyUpdate.exe");
DWORD code;
hr = Exec(L"open", path, NULL, NULL, nCmdShow, TRUE, &code);
if (SUCCEEDED(hr)) {
hr = HRESULT_FROM_WIN32(code);
}
end:
if (!SUCCEEDED(hr)) {
MessageBox(NULL, GetMessageForHresult(hr), L"Legacy Update", MB_OK | MB_ICONERROR);
}
CoUninitialize();
}

View File

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

View File

@@ -1,14 +0,0 @@
; LegacyUpdate.def : Declares the module parameters.
EXPORTS
; Registration
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
; Rundll32
LaunchUpdateSite PRIVATE
; Internal use
GetMessageForHresult

View File

@@ -1,126 +0,0 @@
// 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";
import "wuapi.idl";
typedef enum OSVersionField {
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 UserType {
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(15)] HRESULT SetBrowserHwnd(IUpdateInstaller *installer);
[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);
[id(2)] HRESULT Reboot(void);
};
[
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

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

View File

@@ -1,601 +0,0 @@
<?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>Static</UseOfAtl>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v90</PlatformToolset>
<UseOfAtl>Static</UseOfAtl>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<XPDeprecationWarning>false</XPDeprecationWarning>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<XPDeprecationWarning>false</XPDeprecationWarning>
</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>false</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>
<XPDeprecationWarning>false</XPDeprecationWarning>
<UseOfAtl>Static</UseOfAtl>
<UseOfMfc>false</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 />
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>.\LegacyUpdate.def</ModuleDefinitionFile>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
<AdditionalOptions>/filealign:0x200 %(AdditionalOptions)</AdditionalOptions>
<RegisterOutput>false</RegisterOutput>
</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 /min "" 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 />
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>.\LegacyUpdate.def</ModuleDefinitionFile>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
<AdditionalOptions>/filealign:0x200 %(AdditionalOptions)</AdditionalOptions>
<RegisterOutput>false</RegisterOutput>
</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 /min "" 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 />
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>.\LegacyUpdate.def</ModuleDefinitionFile>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
<AdditionalOptions>/filealign:0x200 %(AdditionalOptions)</AdditionalOptions>
<RegisterOutput>false</RegisterOutput>
</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 /min "" 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 />
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>.\LegacyUpdate.def</ModuleDefinitionFile>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
<AdditionalOptions>/filealign:0x200 %(AdditionalOptions)</AdditionalOptions>
<RegisterOutput>false</RegisterOutput>
</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 /min "" taskkill /im iexplore.exe</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>
</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>
</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;_MERGE_PROXYSTUB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<CompileAs />
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</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>
<AdditionalOptions>/filealign:0x200 %(AdditionalOptions)</AdditionalOptions>
</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 /min "" taskkill /im iexplore.exe</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>
</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>
</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;_MERGE_PROXYSTUB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<CompileAs />
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</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>
<AdditionalOptions>/filealign:0x200 %(AdditionalOptions)</AdditionalOptions>
</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="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" />
<CustomBuild Include="wuerror.mc">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<FileType>Document</FileType>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">mc %(FullPath) -r $(IntDir) -h $(IntDir)</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compiling Message Table</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)%(Identity).rc;$(IntDir)%(Identity).h;$(IntDir)MSG0409.bin</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">mc %(FullPath) -r $(IntDir) -h $(IntDir)</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compiling Message Table</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)%(Identity).rc;$(IntDir)%(Identity).h;$(IntDir)MSG0409.bin</Outputs>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</DeploymentContent>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">mc %(FullPath) -r $(IntDir) -h $(IntDir)</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">mc %(FullPath) -r $(IntDir) -h $(IntDir)</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">mc %(FullPath) -r $(IntDir) -h $(IntDir)</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">mc %(FullPath) -r $(IntDir) -h $(IntDir)</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">Compiling Message Table</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">Compiling Message Table</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">Compiling Message Table</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">Compiling Message Table</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">$(IntDir)%(Identity).rc;$(IntDir)%(Identity).h;$(IntDir)MSG0409.bin</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">$(IntDir)%(Identity).rc;$(IntDir)%(Identity).h;$(IntDir)MSG0409.bin</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">$(IntDir)%(Identity).rc;$(IntDir)%(Identity).h;$(IntDir)MSG0409.bin</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">$(IntDir)%(Identity).rc;$(IntDir)%(Identity).h;$(IntDir)MSG0409.bin</Outputs>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">false</ExcludedFromBuild>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\shared\Exec.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="..\shared\LegacyUpdate.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="..\shared\Registry.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="..\shared\VersionInfo.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="..\shared\HResult.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="..\shared\WMI.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC17|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug-VC08|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<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="..\include\wuerror.h" />
<ClInclude Include="..\shared\Exec.h" />
<ClInclude Include="..\shared\LegacyUpdate.h" />
<ClInclude Include="..\shared\VersionInfo.h" />
<ClInclude Include="..\shared\WMI.h" />
<ClInclude Include="..\shared\HResult.h" />
<ClInclude Include="Compat.h" />
<ClInclude Include="ElevationHelper.h" />
<ClInclude Include="IUpdateInstaller4.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

@@ -1,168 +0,0 @@
<?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="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\WMI.c">
<Filter>Shared</Filter>
</ClCompile>
<ClCompile Include="..\shared\Registry.c">
<Filter>Shared</Filter>
</ClCompile>
<ClCompile Include="..\shared\VersionInfo.c">
<Filter>Shared</Filter>
</ClCompile>
<ClCompile Include="..\shared\HResult.c">
<Filter>Shared</Filter>
</ClCompile>
<ClCompile Include="..\shared\Exec.c">
<Filter>Shared</Filter>
</ClCompile>
<ClCompile Include="..\shared\LegacyUpdate.c">
<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>
<ClInclude Include="..\shared\HResult.h">
<Filter>Shared</Filter>
</ClInclude>
<ClInclude Include="..\include\wuerror.h">
<Filter>Shared</Filter>
</ClInclude>
<ClInclude Include="IUpdateInstaller4.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\shared\Exec.h">
<Filter>Shared</Filter>
</ClInclude>
<ClInclude Include="..\shared\LegacyUpdate.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>
<Midl Include="wuapi.idl">
<Filter>Source Files</Filter>
</Midl>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="wuerror.mc">
<Filter>Resource Files</Filter>
</CustomBuild>
</ItemGroup>
</Project>

View File

@@ -1,521 +0,0 @@
// LegacyUpdateCtrl.cpp : Implementation of the CLegacyUpdateCtrl ActiveX Control class.
#include "stdafx.h"
#include "LegacyUpdateCtrl.h"
#include "Compat.h"
#include "ElevationHelper.h"
#include "Exec.h"
#include "HResult.h"
#include "LegacyUpdate.h"
#include "Registry.h"
#include "User.h"
#include "Utils.h"
#include "VersionInfo.h"
#include "WULog.h"
#include <atlbase.h>
#include <ShlObj.h>
#include <wuapi.h>
#include "IUpdateInstaller4.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
const BSTR permittedHosts[] = {
L"legacyupdate.net",
L"test.legacyupdate.net",
NULL
};
// 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; permittedHosts[i] != NULL; i++) {
if (wcscmp(host, permittedHosts[i]) == 0) {
return TRUE;
}
}
end:
if (!SUCCEEDED(hr)) {
TRACE("IsPermitted() failed: %ls\n", GetMessageForHresult(hr));
}
return FALSE;
}
STDMETHODIMP CLegacyUpdateCtrl::GetElevatedHelper(CComPtr<IElevationHelper> &retval) {
CComPtr<IElevationHelper> 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+.
HRESULT hr = m_nonElevatedHelper.CoCreateInstance(CLSID_ElevationHelper, NULL, CLSCTX_INPROC_SERVER);
if (!SUCCEEDED(hr)) {
return hr;
}
elevatedHelper = m_nonElevatedHelper;
}
retval = elevatedHelper;
return S_OK;
}
#define DoIsPermittedCheck() \
if (!IsPermitted()) { \
return E_ACCESSDENIED; \
}
STDMETHODIMP CLegacyUpdateCtrl::SetClientSite(IOleClientSite *pClientSite) {
HRESULT hr = IOleObjectImpl::SetClientSite(pClientSite);
if (!SUCCEEDED(hr)) {
return hr;
}
DoIsPermittedCheck();
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::CheckControl(VARIANT_BOOL *retval) {
DoIsPermittedCheck();
// Just return true so the site can confirm the control is working.
*retval = VARIANT_TRUE;
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::MessageForHresult(LONG inHresult, BSTR *retval) {
DoIsPermittedCheck();
*retval = SysAllocString(GetMessageForHresult(inHresult));
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::GetOSVersionInfo(OSVersionField osField, LONG systemMetric, VARIANT *retval) {
DoIsPermittedCheck();
VariantInit(retval);
OSVERSIONINFOEX *versionInfo = GetVersionInfo();
switch (osField) {
case e_majorVer:
retval->vt = VT_UI4;
retval->ulVal = versionInfo->dwMajorVersion;
break;
case e_minorVer:
retval->vt = VT_UI4;
retval->ulVal = versionInfo->dwMinorVersion;
break;
case e_buildNumber:
retval->vt = VT_UI4;
retval->ulVal = versionInfo->dwBuildNumber;
break;
case e_platform:
retval->vt = VT_UI4;
retval->ulVal = versionInfo->dwPlatformId;
break;
case e_SPMajor:
retval->vt = VT_I4;
retval->lVal = versionInfo->wServicePackMajor;
break;
case e_SPMinor:
retval->vt = VT_I4;
retval->lVal = versionInfo->wServicePackMinor;
break;
case e_productSuite:
retval->vt = VT_I4;
retval->lVal = versionInfo->wSuiteMask;
break;
case e_productType:
retval->vt = VT_I4;
retval->lVal = versionInfo->wProductType;
break;
case e_systemMetric:
retval->vt = VT_I4;
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", 0, &data, &size);
retval->vt = VT_BSTR;
retval->bstrVal = SUCCEEDED(hr)
? SysAllocStringLen(data, size - 1)
// BuildLab doesn't exist on Windows 2000.
: SysAllocString(versionInfo->szCSDVersion);
if (data) {
LocalFree(data);
}
break;
}
case e_controlVersionString: {
LPWSTR data;
HRESULT hr = GetOwnVersion(&data);
if (!SUCCEEDED(hr)) {
return hr;
}
retval->vt = VT_BSTR;
retval->bstrVal = SysAllocString(data);
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", 0, &data, &size);
if (SUCCEEDED(hr)) {
retval->vt = VT_BSTR;
retval->bstrVal = SysAllocStringLen(data, size - 1);
}
}
break;
}
case e_displayVersion: {
LPWSTR data;
DWORD size;
HRESULT hr = GetRegistryString(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", L"DisplayVersion", 0, &data, &size);
if (SUCCEEDED(hr)) {
retval->vt = VT_BSTR;
retval->bstrVal = SysAllocStringLen(data, size - 1);
LocalFree(data);
}
break;
}
}
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::RequestElevation() {
DoIsPermittedCheck();
if (m_elevatedHelper != NULL || !AtLeastWinVista()) {
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;
}
hr = GetElevatedHelper(elevatedHelper);
if (!SUCCEEDED(hr)) {
goto end;
}
return elevatedHelper->CreateObject(progID, retval);
end:
if (!SUCCEEDED(hr)) {
TRACE("CreateObject(%ls) failed: %ls\n", progID, GetMessageForHresult(hr));
}
return hr;
}
STDMETHODIMP CLegacyUpdateCtrl::SetBrowserHwnd(IUpdateInstaller *installer) {
DoIsPermittedCheck();
if (installer == NULL) {
return E_INVALIDARG;
}
CComPtr<IUpdateInstaller> updateInstaller = NULL;
HRESULT hr = installer->QueryInterface(IID_IUpdateInstaller, (void **)&updateInstaller);
if (!SUCCEEDED(hr)) {
return hr;
}
updateInstaller->put_ParentHwnd(GetIEWindowHWND());
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::GetUserType(UserType *retval) {
DoIsPermittedCheck();
if (IsUserAdmin()) {
// 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();
// Ask WU itself whether a reboot is required
CComPtr<ISystemInformation> systemInfo;
if (SUCCEEDED(systemInfo.CoCreateInstance(CLSID_SystemInformation, NULL, CLSCTX_INPROC_SERVER))) {
if (SUCCEEDED(systemInfo->get_RebootRequired(retval)) && *retval == VARIANT_TRUE) {
return S_OK;
}
}
// Check reboot flag in registry
HKEY subkey;
HRESULT hr = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update\\RebootRequired", KEY_WOW64_64KEY, KEY_READ, &subkey));
if (SUCCEEDED(hr)) {
RegCloseKey(subkey);
*retval = VARIANT_TRUE;
return S_OK;
}
*retval = VARIANT_FALSE;
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::get_IsWindowsUpdateDisabled(VARIANT_BOOL *retval) {
DoIsPermittedCheck();
// Future note: These are in HKCU on NT; HKLM on 9x.
// Remove links and access to Windows Update
DWORD value;
HRESULT hr = GetRegistryDword(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", L"NoWindowsUpdate", KEY_WOW64_64KEY, &value);
if (SUCCEEDED(hr) && value == 1) {
*retval = VARIANT_TRUE;
return S_OK;
}
// Remove access to use all Windows Update features
hr = GetRegistryDword(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\WindowsUpdate", L"DisableWindowsUpdateAccess", KEY_WOW64_64KEY, &value);
if (SUCCEEDED(hr) && value == 1) {
*retval = VARIANT_TRUE;
return S_OK;
}
*retval = VARIANT_FALSE;
return S_OK;
}
STDMETHODIMP CLegacyUpdateCtrl::RebootIfRequired(void) {
DoIsPermittedCheck();
HRESULT hr = S_OK;
VARIANT_BOOL isRebootRequired;
if (SUCCEEDED(get_IsRebootRequired(&isRebootRequired)) && isRebootRequired == VARIANT_TRUE) {
// Calling Commit() is recommended on Windows 10, to ensure feature updates are properly prepared
// prior to the reboot. If IUpdateInstaller4 doesn't exist, we can skip this.
CComPtr<IUpdateInstaller4> installer;
hr = installer.CoCreateInstance(CLSID_UpdateInstaller, NULL, CLSCTX_INPROC_SERVER);
if (SUCCEEDED(hr) && hr != REGDB_E_CLASSNOTREG) {
hr = installer->Commit(0);
if (!SUCCEEDED(hr)) {
return hr;
}
}
CComPtr<IElevationHelper> elevatedHelper;
hr = GetElevatedHelper(elevatedHelper);
if (!SUCCEEDED(hr)) {
return hr;
}
hr = elevatedHelper->Reboot();
}
return hr;
}
static HRESULT StartLauncher(LPWSTR params, BOOL wait) {
LPWSTR path;
HRESULT hr = GetInstallPath(&path);
if (!SUCCEEDED(hr)) {
return hr;
}
PathAppend(path, L"LegacyUpdate.exe");
DWORD code;
hr = Exec(L"open", path, params, NULL, SW_SHOW, wait, &code);
if (SUCCEEDED(hr)) {
hr = HRESULT_FROM_WIN32(code);
}
return hr;
}
STDMETHODIMP CLegacyUpdateCtrl::ViewWindowsUpdateLog(void) {
DoIsPermittedCheck();
HRESULT hr = StartLauncher(L"/log", FALSE);
if (!SUCCEEDED(hr)) {
// Try directly
hr = ::ViewWindowsUpdateLog(SW_SHOWDEFAULT);
}
return hr;
}
STDMETHODIMP CLegacyUpdateCtrl::OpenWindowsUpdateSettings(void) {
DoIsPermittedCheck();
HRESULT hr = StartLauncher(L"/options", FALSE);
if (!SUCCEEDED(hr)) {
TRACE(L"OpenWindowsUpdateSettings() failed, falling back: %ls\n", GetMessageForHresult(hr));
// Might happen if the site isn't trusted, and the user rejected the IE medium integrity prompt.
// Use the basic Automatic Updates dialog directly from COM.
CComPtr<IAutomaticUpdates> automaticUpdates;
hr = automaticUpdates.CoCreateInstance(CLSID_AutomaticUpdates, NULL, CLSCTX_INPROC_SERVER);
if (SUCCEEDED(hr)) {
hr = automaticUpdates->ShowSettingsDialog();
}
if (!SUCCEEDED(hr)) {
TRACE(L"OpenWindowsUpdateSettings() failed: %ls\n", GetMessageForHresult(hr));
}
}
return hr;
}
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", 0, &useWUServer);
*retval = SUCCEEDED(hr) && useWUServer == 1 ? VARIANT_TRUE : VARIANT_FALSE;
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", 0, &data, &size);
*retval = SUCCEEDED(hr) ? SysAllocStringLen(data, size - 1) : NULL;
if (data) {
LocalFree(data);
}
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", 0, &data, &size);
*retval = SUCCEEDED(hr) ? SysAllocStringLen(data, size - 1) : NULL;
if (data) {
LocalFree(data);
}
return S_OK;
}

View File

@@ -1,119 +0,0 @@
#pragma once
// LegacyUpdateCtrl.h : Declaration of the CLegacyUpdateCtrl ActiveX Control class.
// CLegacyUpdateCtrl : See LegacyUpdateCtrl.cpp for implementation.
#include <atlctl.h>
#include <MsHTML.h>
#include <wuapi.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();
STDMETHODIMP GetElevatedHelper(CComPtr<IElevationHelper> &retval);
public:
STDMETHODIMP SetClientSite(IOleClientSite *pClientSite);
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 SetBrowserHwnd(IUpdateInstaller *installer);
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

@@ -1,37 +0,0 @@
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}'
}
}
}
}

View File

@@ -1,43 +0,0 @@
override DEBUG := $(or $(DEBUG),1)
MSBUILDCONFIG32 = $(if $(filter 1,$(DEBUG)),Debug-VC08,Release)
MSBUILDCONFIG64 = $(if $(filter 1,$(DEBUG)),Debug-VC17,Release)
MSBUILDFLAGS = /v:minimal /m
ifeq ($(CI),1)
ifeq ($(DEBUG),1)
MSBUILDCONFIG32 = Debug-VC17
endif
MSBUILDFLAGS += /p:PlatformToolset=v141_xp
endif
MSBUILDFLAGS32 = $(MSBUILDFLAGS) /p:Configuration=$(MSBUILDCONFIG32) /p:Platform=Win32
MSBUILDFLAGS64 = $(MSBUILDFLAGS) /p:Configuration=$(MSBUILDCONFIG64) /p:Platform=x64
VSPATH ?= $(shell wslpath "$(shell '/mnt/c/Program Files (x86)/Microsoft Visual Studio/Installer/vswhere.exe' -latest -property installationPath)")
PATH := $(VSPATH)/MSBuild/Current/Bin:$(PATH)
MSBUILD = msbuild.exe
all:
@# Workaround for "dlldatax.obj: LNK2001: unresolved external symbol _LegacyUpdate_ProxyFileInfo"
rm -f LegacyUpdate_p.c
cd ..; $(MSBUILD) $(MSBUILDFLAGS32) LegacyUpdate.sln
rm -f LegacyUpdate_p.c
cd ..; $(MSBUILD) $(MSBUILDFLAGS64) LegacyUpdate.sln
ifeq ($(SIGN),1)
../build/sign.sh \
../Release/LegacyUpdate.dll \
../x64/Release/LegacyUpdate.dll
endif
clean:
rm -rf \
Debug-VC08 Debug-VC17 Release x64 \
LegacyUpdate_i.c LegacyUpdate_i.h LegacyUpdate_p.c LegacyUpdateidl.h
cd ..; $(MSBUILD) $(MSBUILDFLAGS32) LegacyUpdate.sln /t:Clean
cd ..; $(MSBUILD) $(MSBUILDFLAGS64) LegacyUpdate.sln /t:Clean
.PHONY: all clean

View File

@@ -1,65 +0,0 @@
// 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

@@ -1,77 +0,0 @@
#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

@@ -1,48 +0,0 @@
<!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

@@ -1,34 +0,0 @@
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}'
}
}
}
}

View File

@@ -1,20 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by LegacyUpdate.rc
//
#define IDS_LEGACYUPDATE 1
#define IDR_LEGACYUPDATEOCX 101
#define IDR_LEGACYUPDATECTRL 102
#define IDR_PROGRESSBARCONTROL 103
#define IDR_ELEVATIONHELPER 104
// 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

View File

@@ -1,167 +0,0 @@
#include "stdafx.h"
#include <comdef.h>
#include <atlstr.h>
#include <shlwapi.h>
#include "HResult.h"
#include "WMI.h"
#include "VersionInfo.h"
#pragma comment(lib, "advapi32.lib")
#pragma comment(lib, "shlwapi.lib")
#pragma comment(lib, "version.lib")
typedef DWORD (WINAPI *_InitiateShutdownW)(LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwGracePeriod, DWORD dwShutdownFlags, DWORD dwReason);
static BOOL _loadedProductName = FALSE;
static CComVariant _productName;
typedef struct {
DWORD version;
DWORD osFlag;
LPWSTR library;
UINT stringIDs[3];
} WinNT5Variant;
static const WinNT5Variant nt5Variants[] = {
// XP
{0x0501, OS_TABLETPC, L"winbrand.dll", { 180, 2000}},
{0x0501, OS_MEDIACENTER, L"winbrand.dll", { 180, 2001}},
{0x0501, OS_STARTER, L"winbrand.dll", { 180, 2002}},
{0x0501, OS_EMBPOS, L"winbrand.dll", { 180, 2003}},
{0x0501, OS_WINFLP, L"winbrand.dll", { 180, 2004}},
{0x0501, OS_EMBSTD2009, L"winbrand.dll", { 180, 2005}},
{0x0501, OS_EMBPOS2009, L"winbrand.dll", { 180, 2006}},
// Check for XP Embedded last as WES2009 also identifies as OS_EMBEDDED.
{0x0501, OS_EMBEDDED, L"sysdm.cpl", { 180, 189}},
// Server 2003
{0x0502, OS_APPLIANCE, L"winbrand.dll", { 181, 2002}},
{0x0502, OS_STORAGESERVER, L"wssbrand.dll", {1101, 1102}},
{0x0502, OS_COMPUTECLUSTER, L"hpcbrand.dll", {1101, 1102, 1103}},
{0x0502, OS_HOMESERVER, L"whsbrand.dll", {1101, 1102}},
};
HRESULT GetOSProductName(LPVARIANT productName) {
if (!_loadedProductName) {
_loadedProductName = TRUE;
VariantInit(&_productName);
// Handle the absolute disaster of Windows XP/Server 2003 edition branding
WORD winver = GetWinVer();
if (HIBYTE(winver) == 5) {
WinNT5Variant variant = {};
for (DWORD i = 0; i < ARRAYSIZE(nt5Variants); i++) {
if (winver == nt5Variants[i].version && IsOS(nt5Variants[i].osFlag)) {
variant = nt5Variants[i];
break;
}
}
if (variant.version) {
HMODULE brandDll = LoadLibraryEx(variant.library, NULL, LOAD_LIBRARY_AS_DATAFILE);
if (brandDll) {
WCHAR brandStr[1024];
ZeroMemory(brandStr, ARRAYSIZE(brandStr));
DWORD j = 0;
while (variant.stringIDs[j] != 0) {
UINT id = variant.stringIDs[j];
WCHAR str[340];
if (id == 180 || id == 181) {
// Get "Microsoft Windows XP" or "Microsoft Windows Server 2003" string
HMODULE sysdm = LoadLibraryEx(L"sysdm.cpl", NULL, LOAD_LIBRARY_AS_DATAFILE);
if (sysdm) {
LoadString(sysdm, id, str, ARRAYSIZE(str));
FreeLibrary(sysdm);
}
} else {
LoadString(brandDll, id, str, ARRAYSIZE(str));
}
if (j > 0) {
wcscat(brandStr, L" ");
}
wcscat(brandStr, str);
j++;
}
_productName.vt = VT_BSTR;
_productName.bstrVal = SysAllocString(brandStr);
FreeLibrary(brandDll);
}
}
}
if (_productName.vt == VT_EMPTY) {
// Get from WMI
HRESULT hr = QueryWMIProperty(L"SELECT Caption FROM Win32_OperatingSystem", L"Caption", &_productName);
if (!SUCCEEDED(hr)) {
return hr;
}
}
}
VariantCopy(productName, &_productName);
return S_OK;
}
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)) {
hr = AtlHresultFromLastError();
TRACE("OpenProcessToken() failed: %ls\n", GetMessageForHresult(hr));
goto end;
}
LUID shutdownLuid;
if (!LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &shutdownLuid)) {
hr = AtlHresultFromLastError();
TRACE("LookupPrivilegeValue() failed: %ls\n", GetMessageForHresult(hr));
goto end;
}
// 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));
goto end;
}
// Reboot with reason "Operating System: Security fix (Unplanned)", ensuring to install updates.
// Try InitiateShutdown first (Vista+)
_InitiateShutdownW $InitiateShutdownW = (_InitiateShutdownW)GetProcAddress(GetModuleHandle(L"advapi32.dll"), "InitiateShutdownW");
if ($InitiateShutdownW) {
hr = HRESULT_FROM_WIN32($InitiateShutdownW(NULL, NULL, 0, SHUTDOWN_RESTART | SHUTDOWN_INSTALL_UPDATES, SHTDN_REASON_MAJOR_OPERATINGSYSTEM | SHTDN_REASON_MINOR_SECURITYFIX));
}
// Try InitiateSystemShutdownEx (2k/XP)
if (!SUCCEEDED(hr)) {
TRACE("InitiateShutdown() failed: %ls\n", GetMessageForHresult(hr));
if (InitiateSystemShutdownEx(NULL, NULL, 0, FALSE, TRUE, SHTDN_REASON_MAJOR_OPERATINGSYSTEM | SHTDN_REASON_MINOR_SECURITYFIX) == 0) {
hr = AtlHresultFromLastError();
TRACE("InitiateSystemShutdownExW() failed: %ls\n", GetMessageForHresult(hr));
}
}
// Last-ditch attempt ExitWindowsEx (only guaranteed to work for the current logged in user)
if (!ExitWindowsEx(EWX_REBOOT | EWX_FORCEIFHUNG, SHTDN_REASON_MAJOR_OPERATINGSYSTEM | SHTDN_REASON_MINOR_SECURITYFIX)) {
hr = AtlHresultFromLastError();
TRACE("ExitWindowsEx() failed: %ls\n", GetMessageForHresult(hr));
}
end:
if (token) {
CloseHandle(token);
}
return hr;
}

View File

@@ -1,5 +0,0 @@
#pragma once
HRESULT GetOSProductName(LPVARIANT productName);
HRESULT Reboot();

View File

@@ -1,17 +0,0 @@
@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%

View File

@@ -1,38 +0,0 @@
/*********************************************************
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 */

View File

@@ -1,18 +0,0 @@
// wrapper for dlldata.c
#ifdef _MERGE_PROXYSTUB // merge proxy stub DLL
#define REGISTER_PROXY_DLL //DllRegisterServer, etc.
#define _WIN32_WINNT _WIN32_WINNT_WIN2K //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

View File

@@ -1,11 +0,0 @@
#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

View File

@@ -1,144 +0,0 @@
// dllmain.cpp : Implementation of DLL Exports.
#include "stdafx.h"
#include "LegacyUpdate_i.h"
#include "dllmain.h"
#include <strsafe.h>
#include "dlldatax.h"
#include "Registry.h"
#include "LegacyUpdate.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();
if (!SUCCEEDED(hr)) {
return hr;
}
// Fix the icon path
HKEY subkey;
hr = HRESULT_FROM_WIN32(RegOpenKeyEx(HKEY_CLASSES_ROOT, L"CLSID\\{84F517AD-6438-478F-BEA8-F0B808DC257F}\\Elevation", 0, KEY_WRITE, &subkey));
if (!SUCCEEDED(hr)) {
return hr;
}
LPWSTR installPath;
hr = GetInstallPath(&installPath);
if (!SUCCEEDED(hr)) {
return hr;
}
WCHAR iconRef[512];
hr = StringCchPrintf((LPWSTR)&iconRef, ARRAYSIZE(iconRef), L"@%ls\\LegacyUpdate.exe,-100", installPath);
LocalFree(installPath);
if (!SUCCEEDED(hr)) {
return hr;
}
hr = HRESULT_FROM_WIN32(RegSetValueEx(subkey, L"IconReference", 0, REG_SZ, (LPBYTE)iconRef, (DWORD)(lstrlen(iconRef) + 1) * sizeof(TCHAR)));
if (!SUCCEEDED(hr)) {
return hr;
}
hr = RegCloseKey(subkey);
#ifdef _MERGE_PROXYSTUB
if (!SUCCEEDED(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;
}

View File

@@ -1,10 +0,0 @@
// 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;

View File

@@ -1,5 +0,0 @@
// 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"

View File

@@ -1,28 +0,0 @@
#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

View File

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

View File

@@ -1,19 +0,0 @@
export CI ?= 0
export SIGN ?= 0
export DEBUG ?= 1
all:
ifeq ($(DEBUG),0)
+$(MAKE) clean
endif
+$(MAKE) -C LegacyUpdate
+$(MAKE) -C launcher
+$(MAKE) -C setup
clean:
+$(MAKE) -C LegacyUpdate clean
+$(MAKE) -C launcher clean
+$(MAKE) -C setup clean
.PHONY: all clean

View File

@@ -13,9 +13,6 @@ if not exist "%ProgramFiles32%\NSIS\Bin\makensis.exe" (
exit /b 1 exit /b 1
) )
:: Build project
call LegacyUpdate\build.cmd
:: Build NSIS :: Build NSIS
makensis setup\setup.nsi makensis setup\setup.nsi
if "%errorlevel%" neq "0" exit /b %errorlevel% if "%errorlevel%" neq "0" exit /b %errorlevel%

View File

@@ -1,23 +0,0 @@
@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

View File

@@ -1,10 +0,0 @@
@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%

View File

@@ -1,9 +0,0 @@
#!/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[@]}"

1360
include/licdll.h Normal file

File diff suppressed because it is too large Load Diff

170
include/licdll.idl Normal file
View File

@@ -0,0 +1,170 @@
import "oaidl.idl";
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: licdll.dll
[
uuid(C7879482-F798-4A74-AF43-E887FBDCED40),
version(1.0),
helpstring("licdll 1.0 Type Library")
]
library LICDLLLib
{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
interface ICOMLicenseAgent;
interface ICOMLicenseAgent2;
[
uuid(ACADF079-CBCD-4032-83F2-FA47C4DB096F),
helpstring("COMLicenseAgent Class")
]
coclass COMLicenseAgent {
[default] interface ICOMLicenseAgent;
interface ICOMLicenseAgent2;
};
[
odl,
uuid(B8CBAD79-3F1F-481A-BB0C-E7BBD77BDDD1),
helpstring("ICOMLicenseAgent Interface"),
dual,
oleautomation
]
interface ICOMLicenseAgent : IDispatch {
[id(0x00000001), helpstring("method Initialize")]
HRESULT Initialize(
[in] unsigned long dwBPC,
[in] unsigned long dwMode,
[in] BSTR bstrLicSource,
[out, retval] unsigned long* pdwRetCode);
[id(0x00000003), helpstring("method GetFirstName")]
HRESULT GetFirstName([out, retval] BSTR* pbstrVal);
[id(0x00000004), helpstring("method SetFirstName")]
HRESULT SetFirstName([in] BSTR bstrNewVal);
[id(0x00000005), helpstring("method GetLastName")]
HRESULT GetLastName([out, retval] BSTR* pbstrVal);
[id(0x00000006), helpstring("method SetLastName")]
HRESULT SetLastName([in] BSTR bstrNewVal);
[id(0x00000007), helpstring("method GetOrgName")]
HRESULT GetOrgName([out, retval] BSTR* pbstrVal);
[id(0x00000008), helpstring("method SetOrgName")]
HRESULT SetOrgName([in] BSTR bstrNewVal);
[id(0x00000009), helpstring("method GetEmail")]
HRESULT GetEmail([out, retval] BSTR* pbstrVal);
[id(0x0000000a), helpstring("method SetEmail")]
HRESULT SetEmail([in] BSTR bstrNewVal);
[id(0x0000000b), helpstring("method GetPhone")]
HRESULT GetPhone([out, retval] BSTR* pbstrVal);
[id(0x0000000c), helpstring("method SetPhone")]
HRESULT SetPhone([in] BSTR bstrNewVal);
[id(0x0000000d), helpstring("method GetAddress1")]
HRESULT GetAddress1([out, retval] BSTR* pbstrVal);
[id(0x0000000e), helpstring("method SetAddress1")]
HRESULT SetAddress1([in] BSTR bstrNewVal);
[id(0x0000000f), helpstring("method GetCity")]
HRESULT GetCity([out, retval] BSTR* pbstrVal);
[id(0x00000010), helpstring("method SetCity")]
HRESULT SetCity([in] BSTR bstrNewVal);
[id(0x00000011), helpstring("method GetState")]
HRESULT GetState([out, retval] BSTR* pbstrVal);
[id(0x00000012), helpstring("method SetState")]
HRESULT SetState([in] BSTR bstrNewVal);
[id(0x00000013), helpstring("method GetCountryCode")]
HRESULT GetCountryCode([out, retval] BSTR* pbstrVal);
[id(0x00000014), helpstring("method SetCountryCode")]
HRESULT SetCountryCode([in] BSTR bstrNewVal);
[id(0x00000015), helpstring("method GetCountryDesc")]
HRESULT GetCountryDesc([out, retval] BSTR* pbstrVal);
[id(0x00000016), helpstring("method SetCountryDesc")]
HRESULT SetCountryDesc([in] BSTR bstrNewVal);
[id(0x00000017), helpstring("method GetZip")]
HRESULT GetZip([out, retval] BSTR* pbstrVal);
[id(0x00000018), helpstring("method SetZip")]
HRESULT SetZip([in] BSTR bstrNewVal);
[id(0x00000019), helpstring("method GetIsoLanguage")]
HRESULT GetIsoLanguage([out, retval] unsigned long* pdwVal);
[id(0x0000001a), helpstring("method SetIsoLanguage")]
HRESULT SetIsoLanguage([in] unsigned long dwNewVal);
[id(0x00000020), helpstring("method GetMSUpdate")]
HRESULT GetMSUpdate([out, retval] BSTR* pbstrVal);
[id(0x00000021), helpstring("method SetMSUpdate")]
HRESULT SetMSUpdate([in] BSTR bstrNewVal);
[id(0x00000022), helpstring("method GetMSOffer")]
HRESULT GetMSOffer([out, retval] BSTR* pbstrVal);
[id(0x00000023), helpstring("method SetMSOffer")]
HRESULT SetMSOffer([in] BSTR bstrNewVal);
[id(0x00000024), helpstring("method GetOtherOffer")]
HRESULT GetOtherOffer([out, retval] BSTR* pbstrVal);
[id(0x00000025), helpstring("method SetOtherOffer")]
HRESULT SetOtherOffer([in] BSTR bstrNewVal);
[id(0x00000026), helpstring("method GetAddress2")]
HRESULT GetAddress2([out, retval] BSTR* pbstrVal);
[id(0x00000027), helpstring("method SetAddress2")]
HRESULT SetAddress2([in] BSTR bstrNewVal);
[id(0x00000052), helpstring("method AsyncProcessHandshakeRequest")]
HRESULT AsyncProcessHandshakeRequest([in] long bReviseCustInfo);
[id(0x00000053), helpstring("method AsyncProcessNewLicenseRequest")]
HRESULT AsyncProcessNewLicenseRequest();
[id(0x00000054), helpstring("method AsyncProcessReissueLicenseRequest")]
HRESULT AsyncProcessReissueLicenseRequest();
[id(0x00000056), helpstring("method AsyncProcessReviseCustInfoRequest")]
HRESULT AsyncProcessReviseCustInfoRequest();
[id(0x0000005a), helpstring("method GetAsyncProcessReturnCode")]
HRESULT GetAsyncProcessReturnCode([out, retval] unsigned long* pdwRetCode);
[id(0x0000005d), helpstring("method AsyncProcessDroppedLicenseRequest")]
HRESULT AsyncProcessDroppedLicenseRequest();
[id(0x00000064), helpstring("method GenerateInstallationId")]
HRESULT GenerateInstallationId([out, retval] BSTR* pbstrVal);
[id(0x00000065), helpstring("method DepositConfirmationId")]
HRESULT DepositConfirmationId(
[in] BSTR bstrVal,
[out, retval] unsigned long* pdwRetCode);
[id(0x00000066), helpstring("method GetExpirationInfo")]
HRESULT GetExpirationInfo(
[out] unsigned long* pdwWPALeft,
[out, retval] unsigned long* pdwEvalLeft);
[id(0x00000067), helpstring("method AsyncProcessRegistrationRequest")]
HRESULT AsyncProcessRegistrationRequest();
[id(0x00000068), helpstring("method ProcessHandshakeRequest")]
HRESULT ProcessHandshakeRequest([in] long bReviseCustInfo);
[id(0x00000069), helpstring("method ProcessNewLicenseRequest")]
HRESULT ProcessNewLicenseRequest();
[id(0x0000006a), helpstring("method ProcessDroppedLicenseRequest")]
HRESULT ProcessDroppedLicenseRequest();
[id(0x0000006b), helpstring("method ProcessReissueLicenseRequest")]
HRESULT ProcessReissueLicenseRequest();
[id(0x0000006d), helpstring("method ProcessReviseCustInfoRequest")]
HRESULT ProcessReviseCustInfoRequest();
[id(0x0000006e), helpstring("method EnsureInternetConnection")]
HRESULT EnsureInternetConnection();
[id(0x0000006f), helpstring("method SetProductKey")]
HRESULT SetProductKey([in] LPWSTR pszNewProductKey);
[id(0x00000070), helpstring("method GetProductID")]
HRESULT GetProductID([out, retval] BSTR* pbstrVal);
[id(0x00000071), helpstring("method VerifyCheckDigits")]
HRESULT VerifyCheckDigits(
BSTR bstrCIDIID,
[out, retval] long* pbValue);
};
[
odl,
uuid(6A07C5A3-9C67-4BB6-B020-ECBE7FDFD326),
helpstring("ICOMLicenseAgent Interface 2"),
dual,
oleautomation
]
interface ICOMLicenseAgent2 : ICOMLicenseAgent {
[id(0x00000072), helpstring("method SetReminders")]
HRESULT SetReminders(long bValue);
[id(0x00000073), helpstring("method GetReminders")]
HRESULT GetReminders(long* pbValue);
[id(0x00000074), helpstring("method GetKeyType")]
HRESULT GetKeyType([out, retval] unsigned long* pdwKeyType);
};
};

33
include/slpublic.h Normal file
View File

@@ -0,0 +1,33 @@
#pragma once
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef GUID SLID;
typedef PVOID HSLC;
DEFINE_GUID(WINDOWS_SLID, 0x55c92734, 0xd682, 0x4d71, 0x98, 0x3e, 0xd6, 0xec, 0x3f, 0x16, 0x05, 0x9f);
typedef enum _tagSLLICENSINGSTATUS {
SL_LICENSING_STATUS_UNLICENSED,
SL_LICENSING_STATUS_LICENSED,
SL_LICENSING_STATUS_IN_GRACE_PERIOD,
SL_LICENSING_STATUS_NOTIFICATION,
SL_LICENSING_STATUS_LAST
} SLLICENSINGSTATUS;
typedef struct _tagSL_LICENSING_STATUS {
SLID SkuId;
SLLICENSINGSTATUS eStatus;
DWORD dwGraceTime;
DWORD dwTotalGraceDays;
HRESULT hrReason;
UINT64 qwValidityExpiration;
} SL_LICENSING_STATUS;
#ifdef __cplusplus
}
#endif

18
launcher/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.exe&quot;,-3</sh:name>
<sh:keywords>legacy update;legacyupdate;update;windows;microsoft;driver;security;software;</sh:keywords>
<sh:command>&quot;%ProgramFiles%\Legacy Update\LegacyUpdate.exe&quot;</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>

298
launcher/InitRunOnce.c Normal file
View File

@@ -0,0 +1,298 @@
#include <windows.h>
#include <commctrl.h>
#include "MsgBox.h"
#include "VersionInfo.h"
#include "LoadImage.h"
#define HK_RUNCMD 1
typedef DWORD (__fastcall *_ThemeWaitForServiceReady)(DWORD timeout);
typedef DWORD (__fastcall *_ThemeWatchForStart)();
static const COLORREF WallpaperColorWin2k = RGB(58, 110, 165); // #3a6ea5
static const COLORREF WallpaperColorWinXP = RGB( 0, 78, 152); // #004e98
static const COLORREF WallpaperColorWin8 = RGB(32, 103, 178); // #2067b2
static const COLORREF WallpaperColorWin10 = RGB(24, 0, 82); // #180052
static const WCHAR RunOnceClassName[] = L"LegacyUpdateRunOnce";
static HANDLE g_cmdHandle;
static void StartThemes() {
// Ask UxInit.dll to ask the Themes service to start a session for this desktop. Themes doesn't automatically start a
// session for the SYSTEM desktop, so we need to ask it to. This matches what msoobe.exe does on first boot.
// Windows 7 moves this to UxInit.dll
HMODULE shsvcs = LoadLibrary(L"UxInit.dll");
if (!shsvcs) {
shsvcs = LoadLibrary(L"shsvcs.dll");
if (!shsvcs) {
return;
}
}
// Get functions by ordinals
_ThemeWaitForServiceReady $ThemeWaitForServiceReady = (_ThemeWaitForServiceReady)GetProcAddress(shsvcs, MAKEINTRESOURCEA(2));
_ThemeWatchForStart $ThemeWatchForStart = (_ThemeWatchForStart)GetProcAddress(shsvcs, MAKEINTRESOURCEA(1));
// 1. Wait up to 1000ms for Themes to start
if ($ThemeWaitForServiceReady) {
$ThemeWaitForServiceReady(1000);
}
// 2. Prompt Themes to start a session for the SYSTEM desktop
if ($ThemeWatchForStart) {
$ThemeWatchForStart();
}
FreeLibrary(shsvcs);
}
static BOOL RunCmd(LPPROCESS_INFORMATION processInfo) {
WCHAR cmd[MAX_PATH];
ExpandEnvironmentStrings(L"%SystemRoot%\\System32\\cmd.exe", cmd, ARRAYSIZE(cmd));
STARTUPINFO startupInfo = {0};
startupInfo.cb = sizeof(startupInfo);
if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &startupInfo, processInfo)) {
MsgBox(NULL, L"Launching cmd.exe failed", NULL, MB_OK | MB_ICONERROR);
return FALSE;
}
CloseHandle(processInfo->hThread);
g_cmdHandle = processInfo->hProcess;
return TRUE;
}
static LRESULT CALLBACK RunOnceWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_NCHITTEST:
// Don't accept any mouse input
return HTNOWHERE;
case WM_HOTKEY: {
// Shift-F10 to run cmd
if (wParam == HK_RUNCMD) {
DWORD exitCode;
if (!g_cmdHandle || (GetExitCodeProcess(g_cmdHandle, &exitCode) && exitCode != STILL_ACTIVE)) {
PROCESS_INFORMATION processInfo;
RunCmd(&processInfo);
}
}
break;
}
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, message, wParam, lParam);;
}
static void CreateRunOnceWindow() {
// Init common controls
INITCOMMONCONTROLSEX initComctl = {0};
initComctl.dwSize = sizeof(initComctl);
initComctl.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&initComctl);
// Create window
WNDCLASS wndClass = {0};
wndClass.style = CS_VREDRAW | CS_HREDRAW | CS_OWNDC | CS_NOCLOSE;
wndClass.lpfnWndProc = RunOnceWndProc;
wndClass.hInstance = GetModuleHandle(NULL);
wndClass.lpszClassName = RunOnceClassName;
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
if (!RegisterClass(&wndClass)) {
TRACE(L"RegisterClass failed: %d", GetLastError());
return;
}
HWND hwnd = CreateWindowEx(
WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE,
wndClass.lpszClassName,
L"Legacy Update",
WS_POPUP,
0, 0, 0, 0,
NULL, NULL,
wndClass.hInstance,
NULL
);
if (!hwnd) {
TRACE(L"CreateWindow failed: %d", GetLastError());
return;
}
// Register hotkey
RegisterHotKey(hwnd, HK_RUNCMD, MOD_SHIFT, VK_F10);
// Check if the display is 8-bit color or lower
HDC dc = GetDC(NULL);
int bpp = GetDeviceCaps(dc, BITSPIXEL);
ReleaseDC(NULL, dc);
if (bpp >= 8) {
// Set the wallpaper color
COLORREF color = GetSysColor(COLOR_DESKTOP);
if (AtLeastWin10()) {
color = WallpaperColorWin10;
} else if (AtLeastWin8()) {
color = WallpaperColorWin8;
} else if ((IsWinXP2002() || IsWinXP2003()) && color == RGB(0, 0, 0)) {
// XP uses a black wallpaper in fast user switching mode. Override to the default blue.
color = WallpaperColorWinXP;
}
SetSysColors(1, (const INT[1]){COLOR_DESKTOP}, (const COLORREF[1]){color});
DWORD width = GetSystemMetrics(SM_CXSCREEN);
DWORD height = GetSystemMetrics(SM_CYSCREEN);
HBITMAP wallpaper;
if (IsWin7()) {
// 7: Bitmap in oobe dir
WCHAR bmpPath[MAX_PATH];
ExpandEnvironmentStrings(L"%SystemRoot%\\System32\\oobe\\background.bmp", bmpPath, ARRAYSIZE(bmpPath));
wallpaper = LoadImage(NULL, bmpPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
} else if (IsWinVista()) {
// Vista: Resources in ooberesources.dll
WCHAR ooberesPath[MAX_PATH];
ExpandEnvironmentStrings(L"%SystemRoot%\\System32\\oobe\\ooberesources.dll", ooberesPath, ARRAYSIZE(ooberesPath));
HMODULE ooberes = LoadLibrary(ooberesPath);
if (ooberes) {
// Width logic is the same used by Vista msoobe.dll
LPWSTR resource = GetSystemMetrics(SM_CXSCREEN) < 1200 ? L"OOBE_BACKGROUND_0" : L"OOBE_BACKGROUND_LARGE_0";
wallpaper = LoadPNGResource(ooberes, resource, RT_RCDATA);
}
FreeLibrary(ooberes);
}
if (wallpaper) {
// Write to disk
WCHAR tempPath[MAX_PATH];
ExpandEnvironmentStrings(L"%ProgramData%\\Legacy Update\\background.bmp", tempPath, ARRAYSIZE(tempPath));
if (GetFileAttributes(tempPath) != INVALID_FILE_ATTRIBUTES || ScaleAndWriteToBMP(wallpaper, width, height, tempPath)) {
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID)tempPath, SPIF_SENDWININICHANGE);
}
DeleteObject(wallpaper);
}
}
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
}
static BOOL IsSystemUser() {
BOOL result = FALSE;
PTOKEN_USER tokenInfo;
PSID systemSid;
HANDLE token;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) {
goto end;
}
DWORD tokenInfoLen;
GetTokenInformation(token, TokenUser, NULL, 0, &tokenInfoLen);
tokenInfo = (PTOKEN_USER)LocalAlloc(LPTR, tokenInfoLen);
if (!GetTokenInformation(token, TokenUser, tokenInfo, tokenInfoLen, &tokenInfoLen)) {
goto end;
}
DWORD sidSize = SECURITY_MAX_SID_SIZE;
systemSid = LocalAlloc(LPTR, sidSize);
if (!CreateWellKnownSid(WinLocalSystemSid, NULL, systemSid, &sidSize)) {
goto end;
}
result = EqualSid(tokenInfo->User.Sid, systemSid);
end:
if (tokenInfo) {
LocalFree(tokenInfo);
}
if (systemSid) {
LocalFree(systemSid);
}
if (token) {
CloseHandle(token);
}
return result;
}
void RunOnce() {
#ifndef _DEBUG
// Only relevant if we're SYSTEM
if (!IsSystemUser()) {
PostQuitMessage(1);
return;
}
#endif
// Start Themes on this desktop
StartThemes();
// Find and hide the FirstUxWnd window, if it exists (Windows 7+)
HWND firstUxWnd = FindWindow(L"FirstUxWndClass", NULL);
if (firstUxWnd) {
ShowWindow(firstUxWnd, SW_HIDE);
}
// Set up our window
CreateRunOnceWindow();
// Construct path to LegacyUpdateSetup.exe
WCHAR setupPath[MAX_PATH];
GetModuleFileName(NULL, setupPath, ARRAYSIZE(setupPath));
wcsrchr(setupPath, L'\\')[1] = L'\0';
wcsncat(setupPath, L"LegacyUpdateSetup.exe", ARRAYSIZE(setupPath) - wcslen(setupPath) - 1);
// Execute and wait for completion
STARTUPINFO startupInfo = {0};
startupInfo.cb = sizeof(startupInfo);
PROCESS_INFORMATION processInfo = {0};
LPWSTR cmdLine = (LPWSTR)LocalAlloc(LPTR, 4096 * sizeof(WCHAR));
wsprintf(cmdLine, L"\"%ls\" /runonce", setupPath);
if (!CreateProcess(setupPath, cmdLine, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &startupInfo, &processInfo)) {
#ifdef _DEBUG
// Run cmd.exe instead
if (!RunCmd(&processInfo)) {
PostQuitMessage(0);
return;
}
#else
MsgBox(NULL, L"Continuing Legacy Update setup failed", NULL, MB_OK | MB_ICONERROR);
PostQuitMessage(0);
return;
#endif
}
CloseHandle(processInfo.hThread);
// Wait for it to finish, while running a message loop
MSG msg;
while (WaitForSingleObject(processInfo.hProcess, 100) == WAIT_TIMEOUT) {
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
CloseHandle(processInfo.hProcess);
// Don't let SYSTEM cmd keep running beyond runonce
if (g_cmdHandle) {
TerminateProcess(g_cmdHandle, 0);
CloseHandle(g_cmdHandle);
}
// Show FirstUxWnd again
if (firstUxWnd) {
ShowWindow(firstUxWnd, SW_SHOW);
}
PostQuitMessage(0);
}

205
launcher/LaunchUpdateSite.c Normal file
View File

@@ -0,0 +1,205 @@
#include "stdafx.h"
#include "main.h"
#include "resource.h"
#include <exdisp.h>
#include "Exec.h"
#include "HResult.h"
#include "MsgBox.h"
#include "RegisterServer.h"
#include "Registry.h"
#include "SelfElevate.h"
#include "User.h"
#include "VersionInfo.h"
const LPWSTR UpdateSiteURLHttp = L"http://legacyupdate.net/windowsupdate/v6/";
const LPWSTR UpdateSiteURLHttps = L"https://legacyupdate.net/windowsupdate/v6/";
const LPWSTR UpdateSiteFirstRunFlag = L"?firstrun=true";
DEFINE_GUID(IID_ILegacyUpdateCtrl, 0xC33085BB, 0xC3E1, 0x4D27, 0xA2, 0x14, 0xAF, 0x01, 0x95, 0x3D, 0xF5, 0xE5);
DEFINE_GUID(CLSID_LegacyUpdateCtrl, 0xAD28E0DF, 0x5F5A, 0x40B5, 0x94, 0x32, 0x85, 0xEF, 0xD9, 0x7D, 0x1F, 0x9F);
static const LPWSTR GetUpdateSiteURL() {
// Fallback: Use SSL only on Vista and up
BOOL useHTTPS = AtLeastWinVista();
// 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", KEY_WOW64_64KEY, &data, &size);
if (SUCCEEDED(hr)) {
// Return based on the URL value
if (wcscmp(data, UpdateSiteURLHttps) == 0) {
useHTTPS = TRUE;
} else if (wcscmp(data, UpdateSiteURLHttp) == 0) {
useHTTPS = FALSE;
}
LocalFree(data);
}
return useHTTPS ? UpdateSiteURLHttps : UpdateSiteURLHttp;
}
void LaunchUpdateSite(int argc, LPWSTR *argv, int nCmdShow) {
HRESULT hr = S_OK;
IWebBrowser2 *browser;
VARIANT url;
VARIANT flags;
VARIANT nullVariant;
LPTSTR siteURL;
HMONITOR monitor;
// If running on 2k/XP, make sure we're elevated. If not, show Run As prompt.
if (!AtLeastWinVista() && !IsUserAdmin()) {
LPWSTR args = (LPWSTR)LocalAlloc(LPTR, 512 * sizeof(WCHAR));
wsprintf(args, L"/launch %ls", argc > 0 ? argv[0] : L"");
hr = SelfElevate(args, NULL);
// Access denied happens when the user clicks No/Cancel.
if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED)) {
hr = S_OK;
}
goto end;
}
// Can we instantiate our own ActiveX control? If not, try to register it.
hr = CoCreateInstance(&CLSID_LegacyUpdateCtrl, NULL, CLSCTX_LOCAL_SERVER, &IID_ILegacyUpdateCtrl, (void **)&browser);
if (hr == REGDB_E_CLASSNOTREG) {
hr = RegisterServer(0, TRUE, TRUE);
if (!SUCCEEDED(hr)) {
goto end;
}
hr = CoCreateInstance(&CLSID_LegacyUpdateCtrl, NULL, CLSCTX_LOCAL_SERVER, &IID_ILegacyUpdateCtrl, (void **)&browser);
if (!SUCCEEDED(hr)) {
goto end;
}
IUnknown_Release(browser);
} else if (!SUCCEEDED(hr)) {
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 = CoCreateInstance(&CLSID_InternetExplorer, NULL, CLSCTX_LOCAL_SERVER, &IID_IWebBrowser2, (void **)&browser);
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.
if (AtLeastWin8()) {
SYSTEM_INFO systemInfo;
GetSystemInfo(&systemInfo);
LPCTSTR archSuffix = systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ? L"amd64" : L"x86";
WCHAR fondue[MAX_PATH];
ExpandEnvironmentStrings(L"%SystemRoot%\\System32\\fondue.exe", fondue, ARRAYSIZE(fondue));
WCHAR fondueArgs[256];
wsprintf(fondueArgs, L"/enable-feature:Internet-Explorer-Optional-%ls", archSuffix);
hr = Exec(NULL, fondue, fondueArgs, NULL, SW_SHOWDEFAULT, FALSE, NULL);
if (SUCCEEDED(hr)) {
goto end;
}
}
// Tell the user what they need to do, then open the Optional Features dialog.
WCHAR message[4096];
LoadString(GetModuleHandle(NULL), IDS_IENOTINSTALLED, message, ARRAYSIZE(message));
MsgBox(NULL, message, NULL, MB_OK | MB_ICONEXCLAMATION);
WCHAR optionalFeatures[MAX_PATH];
ExpandEnvironmentStrings(L"%SystemRoot%\\System32\\OptionalFeatures.exe", optionalFeatures, ARRAYSIZE(optionalFeatures));
Exec(NULL, optionalFeatures, NULL, NULL, SW_SHOWDEFAULT, FALSE, NULL);
hr = S_OK;
goto end;
} else if (!SUCCEEDED(hr)) {
goto end;
}
// Can we connect with https? WinInet will throw an error if not.
siteURL = GetUpdateSiteURL();
// Is this a first run launch? Append first run flag if so.
if (argc > 0 && lstrcmpi(argv[0], L"/firstrun") == 0) {
WCHAR newSiteURL[256];
wsprintf(newSiteURL, L"%s%s", siteURL, UpdateSiteFirstRunFlag);
siteURL = newSiteURL;
}
VariantInit(&url);
url.vt = VT_BSTR;
url.bstrVal = SysAllocString(siteURL);
VariantInit(&flags);
flags.vt = VT_I4;
flags.lVal = 0;
VariantInit(&nullVariant);
hr = IWebBrowser2_Navigate2(browser, &url, &flags, &nullVariant, &nullVariant, &nullVariant);
if (!SUCCEEDED(hr)) {
goto end;
}
HWND ieHwnd;
hr = IWebBrowser2_get_HWND(browser, (SHANDLE_PTR *)&ieHwnd);
if (!SUCCEEDED(hr)) {
goto end;
}
// Are we on a small display? If so, resize and maximise the window.
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;
IWebBrowser2_get_Width(browser, &width);
IWebBrowser2_get_Height(browser, &height);
if (width < 800) {
width = workWidth < 800 ? workWidth : 800;
IWebBrowser2_put_Width(browser, width);
}
if (height < 600) {
height = workHeight < 600 ? workHeight : 600;
IWebBrowser2_put_Height(browser, height);
}
LONG left, top;
IWebBrowser2_get_Left(browser, &left);
IWebBrowser2_get_Top(browser, &top);
if (left + width > workWidth) {
IWebBrowser2_put_Left(browser, 0);
}
if (top + height > workHeight) {
IWebBrowser2_put_Top(browser, 0);
}
if (workWidth <= 1152) {
ShowWindow(ieHwnd, SW_MAXIMIZE);
}
}
IWebBrowser2_put_Visible(browser, TRUE);
// Focus the window, since it seems to not always get focus as it should.
SetForegroundWindow(ieHwnd);
end:
if (!SUCCEEDED(hr)) {
MsgBox(NULL, GetMessageForHresult(hr), NULL, MB_ICONEXCLAMATION);
}
browser = NULL;
CoUninitialize();
PostQuitMessage(0);
}

11
launcher/Log.c Normal file
View File

@@ -0,0 +1,11 @@
#include "WULog.h"
#include "MsgBox.h"
void LaunchLog(int nCmdShow) {
HRESULT hr = ViewWindowsUpdateLog(nCmdShow);
if (!SUCCEEDED(hr)) {
MsgBox(NULL, GetMessageForHresult(hr), NULL, MB_OK);
}
PostQuitMessage(hr);
}

8
launcher/Makefile Normal file
View File

@@ -0,0 +1,8 @@
all:
+$(MAKE) -f Makefile.actual ARCH=32
+$(MAKE) -f Makefile.actual ARCH=64
clean:
rm -rf obj
.PHONY: all clean

View File

@@ -1,34 +1,42 @@
FILES = \ FILES = \
$(wildcard *.c) \ $(wildcard *.c) \
../include/nsis/pluginapi.c \ ../shared/Exec.c \
../shared/HResult.c \ ../shared/HResult.c \
../shared/LegacyUpdate.c \ ../shared/LegacyUpdate.c \
../shared/LoadImage.c \ ../shared/LoadImage.c \
../shared/Registry.c ../shared/Registry.c \
../shared/VersionInfo.c \
../shared/Wow64.c
RCFILES = resource.rc RCFILES = resource.rc
DEFFILES = ../LegacyUpdate/LegacyUpdate.def
ARCH ?= 32
ifeq ($(ARCH),64)
TAG = x86_64
else
TAG = i686 TAG = i686
PREFIX = i686-w64-mingw32- endif
BIN = obj/LegacyUpdateNSIS.dll PREFIX = $(TAG)-w64-mingw32-
DEF = $(patsubst %.dll,%.def,$(BIN))
STATIC = $(patsubst %.dll,%.a,$(BIN)) BIN = obj/LegacyUpdate$(ARCH).exe
OBJ = $(foreach file,$(FILES),obj/$(notdir $(basename $(file)).$(TAG).o)) OBJ = $(foreach file,$(FILES),obj/$(notdir $(basename $(file)).$(TAG).o))
RES = $(foreach file,$(RCFILES),obj/$(notdir $(basename $(file)).$(TAG).res)) RES = $(foreach file,$(RCFILES),obj/$(notdir $(basename $(file)).$(TAG).res))
DEFDLL = $(foreach file,$(DEFFILES),obj/lib$(notdir $(basename $(file)).$(TAG).a))
CC = $(PREFIX)g++ CC = $(PREFIX)g++
RC = $(PREFIX)windres RC = $(PREFIX)windres
DLLTOOL = $(PREFIX)dlltool
override DEBUG := $(or $(DEBUG),1) override DEBUG := $(or $(DEBUG),1)
CFLAGS = \ CFLAGS = \
-march=i486 \ -mwindows \
-mdll \
-municode \ -municode \
-DUNICODE \ -DUNICODE \
-D_UNICODE \ -D_UNICODE \
$(if $(filter 1,$(DEBUG)),-D_DEBUG -g,-DNDEBUG -Os) \ $(if $(filter 1,$(DEBUG)),-D_DEBUG -g,-DNDEBUG -Os) \
-D_USRDLL \
-s \ -s \
-fPIE \ -fPIE \
-ffunction-sections \ -ffunction-sections \
@@ -56,10 +64,8 @@ LDFLAGS = \
-Wl,--nxcompat \ -Wl,--nxcompat \
-Wl,--enable-auto-image-base \ -Wl,--enable-auto-image-base \
-Wl,--enable-stdcall-fixup \ -Wl,--enable-stdcall-fixup \
-Wl,--output-def,$(DEF) \
-Wl,--out-implib,$(STATIC) \
-Wl,--strip-all \ -Wl,--strip-all \
-Wl,-e_DllMain \ -Lobj \
-lmsvcrt \ -lmsvcrt \
-lgcc \ -lgcc \
-lpsapi \ -lpsapi \
@@ -68,20 +74,29 @@ LDFLAGS = \
-lole32 \ -lole32 \
-loleaut32 \ -loleaut32 \
-ladvapi32 \ -ladvapi32 \
-lcomctl32 \
-lshell32 \
-lversion \
-lgdi32 \ -lgdi32 \
-lmsimg32 \ -lmsimg32
-lcrypt32
RCFLAGS = \ RCFLAGS = \
-F pe-i386 \
-O coff \ -O coff \
-I../shared -I../shared
all: before-all $(BIN) after-all ifeq ($(ARCH),64)
LDFLAGS += -Wl,-ewWinMain
RCFLAGS += -F pe-x86-64
else
CFLAGS += -march=i486
LDFLAGS += -Wl,-e_wWinMain
RCFLAGS += -F pe-i386
endif
all: before-all $(DEFDLL) $(BIN)
ifeq ($(SIGN),1) ifeq ($(SIGN),1)
../build/sign.sh $(BIN) ../build/sign.sh $(BIN)
endif endif
cp $(BIN) ../setup/x86-unicode/
before-all: before-all:
mkdir -p obj mkdir -p obj
@@ -92,27 +107,20 @@ $(BIN): $(OBJ) $(RES)
obj/%.$(TAG).o: %.c obj/%.$(TAG).o: %.c
$(CC) -x c $< $(CFLAGS) -c -o $@ $(CC) -x c $< $(CFLAGS) -c -o $@
obj/%.$(TAG).o: %.cpp
$(CC) -x c++ $< $(CXXFLAGS) -c -o $@
obj/%.$(TAG).o: ../shared/%.c obj/%.$(TAG).o: ../shared/%.c
$(CC) -x c $< $(CFLAGS) -c -o $@ $(CC) -x c $< $(CFLAGS) -c -o $@
obj/%.$(TAG).o: ../shared/%.cpp
$(CC) -x c++ $< $(CXXFLAGS) -c -o $@
obj/%.$(TAG).o: ../include/nsis/%.c
$(CC) -x c $< $(CFLAGS) -c -o $@
obj/%.$(TAG).res: %.rc obj/%.$(TAG).res: %.rc
$(RC) $< $(RCFLAGS) -o $@ $(RC) $< $(RCFLAGS) -o $@
obj/lib%.$(TAG).a: ../LegacyUpdate/%.def
$(DLLTOOL) -d $< -l $@ -D $(notdir $(basename $<).dll)
clean: clean:
rm -rf obj rm -rf obj
test: test:
+$(MAKE) DEBUG=$(DEBUG) +$(MAKE) DEBUG=$(DEBUG)
cd ../setup && makensis test.nsi ./obj/LegacyUpdate.exe
cd ../setup && explorer.exe test.exe
.PHONY: all before-all after-all clean test .PHONY: all before-all clean test

82
launcher/MsgBox.c Normal file
View File

@@ -0,0 +1,82 @@
#include "stdafx.h"
#include "main.h"
#include "resource.h"
#undef _WIN32_WINNT
#define _WIN32_WINNT _WIN32_WINNT_VISTA
#include <commctrl.h>
typedef HRESULT (WINAPI *_TaskDialogIndirect)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked);
static BOOL _loadedTaskDialog = FALSE;
static _TaskDialogIndirect $TaskDialogIndirect;
int MsgBox(HWND hwnd, LPCTSTR instruction, LPCTSTR body, UINT type) {
if (!_loadedTaskDialog) {
_loadedTaskDialog = TRUE;
$TaskDialogIndirect = (_TaskDialogIndirect)GetProcAddress(LoadLibrary(L"comctl32.dll"), "TaskDialogIndirect");
}
// Play the sound matching the icon, because MB_USERICON doesn't play a sound
MessageBeep(type & 0x000000F0);
type = (type & ~0x000000F0) | MB_USERICON;
if (!$TaskDialogIndirect) {
LPWSTR finalBody = (LPWSTR)instruction;
if (body && lstrlen(body) > 0) {
size_t length = lstrlen(instruction) + lstrlen(body) + 3;
finalBody = (LPWSTR)LocalAlloc(LPTR, length * sizeof(TCHAR));
wsprintf(finalBody, L"%s\n\n%s", instruction, body);
}
MSGBOXPARAMS params = { 0 };
params.cbSize = sizeof(MSGBOXPARAMS);
params.hwndOwner = hwnd;
params.hInstance = GetModuleHandle(NULL);
params.lpszText = finalBody;
params.lpszCaption = L"Legacy Update";
params.dwStyle = type;
params.lpszIcon = MAKEINTRESOURCE(IDI_APPICON);
int result = MessageBoxIndirect(&params);
if (finalBody != body) {
LocalFree(finalBody);
}
return result;
}
TASKDIALOG_COMMON_BUTTON_FLAGS buttons;
DWORD flags = TDF_POSITION_RELATIVE_TO_WINDOW;
switch (type & 0x0000000F) {
case MB_OK:
buttons = TDCBF_OK_BUTTON;
flags |= TDF_ALLOW_DIALOG_CANCELLATION;
break;
case MB_OKCANCEL:
buttons = TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON;
flags |= TDF_ALLOW_DIALOG_CANCELLATION;
break;
case MB_YESNO:
buttons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON;
break;
default:
break;
}
TASKDIALOGCONFIG config = { 0 };
config.cbSize = sizeof(TASKDIALOGCONFIG);
config.hwndParent = hwnd;
config.hInstance = GetModuleHandle(NULL);
config.dwFlags = flags;
config.dwCommonButtons = buttons;
config.pszWindowTitle = L"Legacy Update";
config.pszMainInstruction = instruction;
config.pszContent = body;
config.pszMainIcon = MAKEINTRESOURCE(IDI_APPICON);
int button;
$TaskDialogIndirect(&config, &button, NULL, NULL);
return button;
}

5
launcher/MsgBox.h Normal file
View File

@@ -0,0 +1,5 @@
#pragma once
#include <windows.h>
int MsgBox(HWND hwnd, LPCTSTR instruction, LPCTSTR body, UINT type);

40
launcher/Options.c Normal file
View File

@@ -0,0 +1,40 @@
#include <windows.h>
#include "Exec.h"
#include "VersionInfo.h"
#include "Wow64.h"
void LaunchOptions(int nCmdShow) {
#if !_WIN64
// 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);
#endif
HRESULT hr;
if (AtLeastWin10()) {
// Windows 10+: Open Settings app
hr = Exec(NULL, L"ms-settings:windowsupdate-options", NULL, NULL, SW_SHOWDEFAULT, FALSE, NULL);
} else if (AtLeastWinVista()) {
// Windows Vista, 7, 8: Open Windows Update control panel
WCHAR wuauclt[MAX_PATH];
ExpandEnvironmentStrings(L"%SystemRoot%\\System32\\wuauclt.exe", wuauclt, ARRAYSIZE(wuauclt));
hr = Exec(NULL, wuauclt, L"/ShowOptions", NULL, SW_SHOWDEFAULT, FALSE, NULL);
} else {
// Windows 2000, XP: Open Automatic Updates control panel
WCHAR wuaucpl[MAX_PATH];
ExpandEnvironmentStrings(L"%SystemRoot%\\System32\\wuaucpl.cpl", wuaucpl, ARRAYSIZE(wuaucpl));
hr = Exec(NULL, wuaucpl, NULL, NULL, SW_SHOWDEFAULT, FALSE, NULL);
}
#if !_WIN64
// Revert WOW64 redirection if we changed it
if (isRedirected) {
RevertWow64FsRedirection(oldValue);
}
#endif
PostQuitMessage(hr);
}

153
launcher/RegisterServer.c Normal file
View File

@@ -0,0 +1,153 @@
#include <windows.h>
#include "Exec.h"
#include "HResult.h"
#include "LegacyUpdate.h"
#include "MsgBox.h"
#include "Registry.h"
#include "SelfElevate.h"
#include "User.h"
#include "VersionInfo.h"
#include "Wow64.h"
static HRESULT RegisterDllInternal(LPWSTR path, BOOL state) {
HMODULE module = LoadLibrary(path);
if (!module) {
return HRESULT_FROM_WIN32(GetLastError());
}
HRESULT hr = S_OK;
FARPROC proc = GetProcAddress(module, state ? "DllRegisterServer" : "DllUnregisterServer");
if (!proc) {
hr = HRESULT_FROM_WIN32(GetLastError());
goto end;
}
hr = ((HRESULT (WINAPI *)())proc)();
end:
if (module) {
FreeLibrary(module);
}
return hr;
}
static HRESULT RegisterDllExternal(LPWSTR path, BOOL state) {
WCHAR regsvr32[MAX_PATH];
ExpandEnvironmentStrings(L"%SystemRoot%\\System32\\regsvr32.exe", regsvr32, ARRAYSIZE(regsvr32));
LPWSTR args = (LPWSTR)LocalAlloc(LPTR, (lstrlen(path) + 6) * sizeof(WCHAR));
wsprintf(args, L"/s %ls\"%ls\"", state ? L"" : L"/u ", path);
DWORD status;
HRESULT hr = Exec(NULL, regsvr32, args, NULL, SW_HIDE, TRUE, &status);
if (!SUCCEEDED(hr)) {
hr = HRESULT_FROM_WIN32(GetLastError());
return hr;
}
if (status != 0) {
// Run again without /s, so the user can see the error
wsprintf(args, L"%ls\"%ls\"", state ? L"" : L"/u ", path);
hr = Exec(NULL, regsvr32, args, NULL, SW_SHOWDEFAULT, TRUE, &status);
}
return status == 0 ? S_OK : E_FAIL;
}
HRESULT RegisterServer(HWND hwnd, BOOL state, BOOL forLaunch) {
// Ensure elevation
HRESULT hr = S_OK;
LPWSTR installPath;
LPWSTR dllPath;
if (!IsUserAdmin()) {
LPWSTR args = (LPWSTR)LocalAlloc(LPTR, 512 * sizeof(WCHAR));
wsprintf(args, L"%ls %i", state ? L"/regserver" : L"/unregserver", hwnd);
DWORD code;
hr = SelfElevate(args, &code);
if (!SUCCEEDED(hr)) {
// Ignore error on cancelling UAC dialog
if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED)) {
hr = S_OK;
}
goto end;
}
hr = HRESULT_FROM_WIN32(code);
goto end;
}
hr = GetInstallPath(&installPath);
if (!SUCCEEDED(hr)) {
goto end;
}
dllPath = (LPWSTR)LocalAlloc(LPTR, MAX_PATH * sizeof(WCHAR));
wsprintf(dllPath, L"%ls\\LegacyUpdate.dll", installPath);
#ifdef _DEBUG
// Warn if registration path differs, to help with debugging
LPWSTR currentPath;
hr = GetRegistryString(HKEY_CLASSES_ROOT, L"CLSID\\{AD28E0DF-5F5A-40B5-9432-85EFD97D1F9F}\\InprocServer32", NULL, KEY_WOW64_64KEY, &currentPath, NULL);
if (SUCCEEDED(hr) && wcscmp(currentPath, dllPath) != 0) {
if (MsgBox(hwnd, L"DEBUG: Native dll currently registered at a different path. Override?", currentPath, MB_YESNO) != IDYES) {
hr = S_OK;
goto end;
}
}
#endif
hr = RegisterDllInternal(dllPath, state);
if (!SUCCEEDED(hr)) {
// Try external registration
if (SUCCEEDED(RegisterDllExternal(dllPath, state))) {
hr = S_OK;
} else {
goto end;
}
}
#if _WIN64
if (!SUCCEEDED(hr)) {
goto end;
}
wsprintf(dllPath, L"%ls\\LegacyUpdate32.dll", installPath);
#ifdef _DEBUG
// Warn if registration path differs, to help with debugging
hr = GetRegistryString(HKEY_CLASSES_ROOT, L"CLSID\\{AD28E0DF-5F5A-40B5-9432-85EFD97D1F9F}\\InprocServer32", NULL, KEY_WOW64_32KEY, &currentPath, NULL);
if (SUCCEEDED(hr) && wcscmp(currentPath, dllPath) != 0) {
if (MsgBox(hwnd, L"DEBUG: 32-bit dll currently registered at a different path. Override?", currentPath, MB_YESNO) != IDYES) {
hr = S_OK;
goto end;
}
}
#endif
hr = RegisterDllExternal(dllPath, state);
#endif
end:
if (installPath) {
LocalFree(installPath);
}
if (dllPath) {
LocalFree(dllPath);
}
if (!SUCCEEDED(hr)) {
LPWSTR title = state
? L"Failed to register Legacy Update ActiveX control"
: L"Failed to unregister Legacy Update ActiveX control";
MsgBox(hwnd, title, GetMessageForHresult(hr), MB_ICONERROR);
}
if (!forLaunch) {
PostQuitMessage(hr);
}
return hr;
}

View File

@@ -0,0 +1,5 @@
#pragma once
#include <windows.h>
HRESULT RegisterServer(HWND hwnd, BOOL state, BOOL forLaunch);

12
launcher/SelfElevate.c Normal file
View File

@@ -0,0 +1,12 @@
#include "SelfElevate.h"
#include <windows.h>
#include "Exec.h"
#include "VersionInfo.h"
HRESULT SelfElevate(LPWSTR args, LPDWORD code) {
LPWSTR fileName;
GetOwnFileName(&fileName);
HRESULT hr = Exec(L"runas", fileName, args, NULL, SW_SHOWDEFAULT, TRUE, code);
LocalFree(fileName);
return hr;
}

5
launcher/SelfElevate.h Normal file
View File

@@ -0,0 +1,5 @@
#pragma once
#include <windows.h>
HRESULT SelfElevate(LPWSTR args, LPDWORD code);

138
launcher/main.c Normal file
View File

@@ -0,0 +1,138 @@
#include "stdafx.h"
#include "main.h"
#include "resource.h"
#include <windows.h>
#include <commctrl.h>
#include "MsgBox.h"
#include "RegisterServer.h"
#include "Startup.h"
HINSTANCE g_hInstance;
extern void LaunchUpdateSite(int argc, LPWSTR *argv, int nCmdShow);
extern void LaunchOptions(int nCmdShow);
extern void LaunchLog(int nCmdShow);
extern void RunOnce();
typedef enum Action {
ActionLaunch,
ActionOptions,
ActionLog,
ActionRunOnce,
ActionRegServer,
ActionUnregServer
} Action;
static const LPWSTR actions[] = {
L"/launch",
L"/options",
L"/log",
L"/runonce",
L"/regserver",
L"/unregserver",
NULL
};
EXTERN_C __declspec(dllexport)
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) {
g_hInstance = hInstance;
Startup();
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (!SUCCEEDED(hr)) {
ExitProcess(hr);
return hr;
}
int argc;
LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);
LPWSTR actionFlag = L"/launch";
if (argc > 1) {
actionFlag = argv[1];
}
// All remaining args past the action
LPWSTR *flags = {0};
int flagsCount = 0;
if (argc > 2) {
flags = &argv[2];
flagsCount = argc - 2;
}
Action action = -1;
for (int i = 0; actions[i] != NULL; i++) {
if (wcscmp(actionFlag, actions[i]) == 0) {
action = i;
break;
}
}
switch (action) {
case ActionLaunch:
LaunchUpdateSite(flagsCount, flags, nCmdShow);
break;
case ActionOptions:
LaunchOptions(nCmdShow);
break;
case ActionLog:
LaunchLog(nCmdShow);
break;
case ActionRunOnce:
RunOnce();
break;
case ActionRegServer:
case ActionUnregServer: {
BOOL state = action == ActionRegServer;
HWND hwnd = flagsCount > 0 ? (HWND)(intptr_t)wcstol(flags[0], NULL, 10) : 0;
RegisterServer(hwnd, state, FALSE);
break;
}
default: {
const LPWSTR usage = L""
L"LegacyUpdate.exe [/launch|/regserver|/unregserver]\n"
L"\n"
L"/launch\n"
L" Launch Legacy Update website in Internet Explorer\n"
L"\n"
L"/options\n"
L" Open the Windows Update Options control panel\n"
L"\n"
L"/log\n"
L" Open the Windows Update log file\n"
L"\n"
L"/regserver\n"
L" Register ActiveX control\n"
L"\n"
L"/unregserver\n"
L" Unregister ActiveX control\n"
L"\n"
L"If no parameters are provided, /launch is assumed.";
MsgBox(NULL, L"LegacyUpdate.exe usage", usage, MB_OK);
PostQuitMessage(1);
break;
}
}
MSG msg;
while (GetMessage(&msg, NULL, 0, 0) == 1) {
TranslateMessage(&msg);
DispatchMessage(&msg);
switch (msg.message) {
case WM_QUIT:
case WM_DESTROY:
break;
}
}
CoUninitialize();
ExitProcess(msg.wParam);
return msg.wParam;
}

1
launcher/main.h Normal file
View File

@@ -0,0 +1 @@
EXTERN_C HINSTANCE g_hInstance;

30
launcher/manifest.xml Normal file
View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<dependency>
<dependentAssembly>
<assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> <!-- Windows Vista -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> <!-- Windows 7 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> <!-- Windows 8 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> <!-- Windows 8.1 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> <!-- Windows 10 -->
</application>
</compatibility>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</windowsSettings>
</application>
</assembly>

11
launcher/resource.h Normal file
View File

@@ -0,0 +1,11 @@
#define IDR_CPLTASKS 202
#define IDI_APPICON 100
#define IDS_LEGACYUPDATEOCX 1
#define IDS_LEGACYUPDATE 2
#define IDS_CHECKFORUPDATES 3
#define IDS_CHECKFORUPDATES_ALT 4
#define IDS_IENOTINSTALLED 5
#define ID_MANIFEST 1

View File

@@ -1,19 +1,8 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h" #include "resource.h"
#include "Version.h"
#define APSTUDIO_READONLY_SYMBOLS #define APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// #include <windows.h>
// #include "Version.h"
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS #undef APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -23,35 +12,6 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(65001) #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 // Version
@@ -77,9 +37,9 @@ BEGIN
VALUE "CompanyName", "Hashbang Productions" VALUE "CompanyName", "Hashbang Productions"
VALUE "FileDescription", "Legacy Update" VALUE "FileDescription", "Legacy Update"
VALUE "FileVersion", VERSION_STRING VALUE "FileVersion", VERSION_STRING
VALUE "InternalName", "LegacyUpdate.dll" VALUE "InternalName", "LegacyUpdate.exe"
VALUE "LegalCopyright", "© Hashbang Productions. All rights reserved." VALUE "LegalCopyright", "© Hashbang Productions. All rights reserved."
VALUE "OriginalFilename", "LegacyUpdate.dll" VALUE "OriginalFilename", "LegacyUpdate.exe"
VALUE "ProductName", "Legacy Update" VALUE "ProductName", "Legacy Update"
VALUE "ProductVersion", VERSION_STRING VALUE "ProductVersion", VERSION_STRING
END END
@@ -93,16 +53,20 @@ END
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// REGISTRY // Icon
// //
IDR_LEGACYUPDATEOCX REGISTRY "LegacyUpdate.rgs" // Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_APPICON ICON "../LegacyUpdate/icon.ico"
IDR_LEGACYUPDATECTRL REGISTRY "LegacyUpdateCtrl.rgs"
IDR_PROGRESSBARCONTROL REGISTRY "ProgressBarControl.rgs" /////////////////////////////////////////////////////////////////////////////
//
// XML
//
IDR_ELEVATIONHELPER REGISTRY "ElevationHelper.rgs" IDR_CPLTASKS XML "CplTasks.xml"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -112,23 +76,20 @@ IDR_ELEVATIONHELPER REGISTRY "ElevationHelper.rgs"
STRINGTABLE STRINGTABLE
BEGIN BEGIN
IDS_LEGACYUPDATEOCX "Legacy Update Control"
IDS_LEGACYUPDATE "Legacy Update" 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 END
/////////////////////////////////////////////////////////////////////////////
//
// Manifest
//
ID_MANIFEST RT_MANIFEST "manifest.xml"
#endif // English (United States) resources #endif // English (United States) resources
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
1 TYPELIB "LegacyUpdate.tlb"
#include "wuerror.rc"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -21,16 +21,3 @@
#include "resource.h" #include "resource.h"
#include <windows.h> #include <windows.h>
#include "Trace.h" #include "Trace.h"
EXTERN_C HWND g_hwndParent;
#define PLUGIN_METHOD(name) \
EXTERN_C __declspec(dllexport) \
void __cdecl name(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
#define PLUGIN_INIT() \
if (extra && extra->exec_flags && (extra->exec_flags->plugin_api_version != NSISPIAPIVER_CURR)) { \
return; \
} \
EXDLL_INIT(); \
g_hwndParent = hwndParent;

View File

@@ -1,35 +0,0 @@
#include <windows.h>
#include <nsis/pluginapi.h>
#include <wuapi.h>
#include "main.h"
static const LPWSTR MicrosoftUpdateServiceID = L"7971f918-a847-4430-9279-4a52d1efe18d";
PLUGIN_METHOD(EnableMicrosoftUpdate) {
PLUGIN_INIT();
IUpdateServiceManager2 *serviceManager;
IUpdateServiceRegistration *registration;
HRESULT hr = CoCreateInstance(&CLSID_UpdateServiceManager, NULL, CLSCTX_INPROC_SERVER, &IID_IUpdateServiceManager2, (void **)&serviceManager);
if (!SUCCEEDED(hr)) {
goto end;
}
BSTR serviceID = SysAllocString(MicrosoftUpdateServiceID);
BSTR serviceCab = SysAllocString(L"");
hr = IUpdateServiceManager2_AddService2(serviceManager, serviceID, asfAllowPendingRegistration | asfAllowOnlineRegistration | asfRegisterServiceWithAU, serviceCab, &registration);
SysFreeString(serviceID);
SysFreeString(serviceCab);
end:
if (registration) {
IUpdateServiceManager2_Release(registration);
}
if (serviceManager) {
IUpdateServiceManager2_Release(serviceManager);
}
pushint(hr);
}

View File

@@ -1,17 +0,0 @@
#include <windows.h>
#include <nsis/pluginapi.h>
#include "../shared/HResult.h"
PLUGIN_METHOD(MessageForHresult) {
PLUGIN_INIT();
HRESULT hr = popint();
if (hr == 0) {
pushstring(L"Unknown error");
return;
}
LPWSTR message = GetMessageForHresult(hr);
pushstring(message);
LocalFree(message);
}

View File

@@ -1,144 +0,0 @@
// Based on https://nsis.sourceforge.io/TaskbarProgress_plug-in - zlib licensed
// Cleaned up and refactored into C by Legacy Update
#undef _WIN32_WINNT
#define _WIN32_WINNT _WIN32_WINNT_WIN7
#include <windows.h>
#include <nsis/pluginapi.h>
#include <commctrl.h>
#include <objbase.h>
#include <shobjidl.h>
#include "main.h"
#include "VersionInfo.h"
static extra_parameters *g_extra;
static ITaskbarList3 *g_taskbarList;
static UINT g_totalRange;
static WNDPROC g_progressOrigWndProc;
static WNDPROC g_dialogOrigWndProc;
LRESULT CALLBACK ProgressBarWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
if (!g_progressOrigWndProc) {
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) {
ITaskbarList3_SetProgressValue(g_taskbarList, g_hwndParent, wParam, g_totalRange);
}
break;
case WM_DESTROY:
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)g_progressOrigWndProc);
if (g_taskbarList) {
ITaskbarList3_SetProgressState(g_taskbarList, g_hwndParent, TBPF_NOPROGRESS);
ITaskbarList3_Release(g_taskbarList);
g_taskbarList = NULL;
}
g_progressOrigWndProc = NULL;
break;
}
return CallWindowProc(g_progressOrigWndProc, hwnd, uMsg, wParam, lParam);
}
static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
if (!g_dialogOrigWndProc) {
return 0;
}
switch (uMsg) {
case WM_NOTIFY_OUTER_NEXT:
if (g_extra->exec_flags->abort) {
// Set the progress bar to error state (red)
HWND innerWindow = FindWindowEx(hwnd, NULL, L"#32770", NULL);
HWND progressBar = FindWindowEx(innerWindow, NULL, L"msctls_progress32", NULL);
if (progressBar) {
SendMessage(progressBar, PBM_SETSTATE, PBST_ERROR, 0);
}
if (g_taskbarList) {
ITaskbarList3_SetProgressState(g_taskbarList, g_hwndParent, TBPF_ERROR);
}
}
break;
case WM_DESTROY:
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)g_dialogOrigWndProc);
g_dialogOrigWndProc = NULL;
break;
}
return CallWindowProc(g_dialogOrigWndProc, hwnd, uMsg, wParam, lParam);
}
static UINT_PTR NSISPluginCallback(enum NSPIM event) {
// Does nothing, but keeping a callback registered prevents NSIS from unloading the plugin
return 0;
}
PLUGIN_METHOD(InitTaskbarProgress) {
PLUGIN_INIT();
if (!AtLeastWinVista()) {
return;
}
g_extra = extra;
extra->RegisterPluginCallback(g_hInstance, NSISPluginCallback);
if (g_progressOrigWndProc) {
// 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) {
goto fail;
}
hr = CoCreateInstance(&CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, &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_progressOrigWndProc = (WNDPROC)SetWindowLongPtr(progressBar, GWLP_WNDPROC, (LONG_PTR)ProgressBarWndProc);
g_dialogOrigWndProc = (WNDPROC)SetWindowLongPtr(g_hwndParent, GWLP_WNDPROC, (LONG_PTR)MainWndProc);
if (!g_progressOrigWndProc || !g_dialogOrigWndProc) {
goto fail;
}
return;
fail:
if (g_taskbarList) {
ITaskbarList3_Release(g_taskbarList);
g_taskbarList = NULL;
}
g_progressOrigWndProc = NULL;
g_dialogOrigWndProc = NULL;
}

View File

@@ -1,22 +0,0 @@
#include <windows.h>
#include <nsis/pluginapi.h>
#include "Startup.h"
HINSTANCE g_hInstance;
HWND g_hwndParent;
EXTERN_C __declspec(dllexport)
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) {
switch (dwReason) {
case DLL_PROCESS_ATTACH:
g_hInstance = hInstance;
Startup();
break;
case DLL_PROCESS_DETACH:
g_hInstance = NULL;
break;
}
return TRUE;
}

View File

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

View File

View File

@@ -1,54 +0,0 @@
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
#include <windows.h>
#include "Version.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 VERSION_MAJOR,VERSION_MINOR,VERSION_PATCH,VERSION_BUILD
PRODUCTVERSION VERSION_MAJOR,VERSION_MINOR,VERSION_PATCH,VERSION_BUILD
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", VERSION_STRING
VALUE "InternalName", "LegacyUpdateNSIS.dll"
VALUE "LegalCopyright", "© Hashbang Productions. All rights reserved."
VALUE "OriginalFilename", "LegacyUpdateNSIS.dll"
VALUE "ProductName", "Legacy Update"
VALUE "ProductVersion", VERSION_STRING
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

99
setup/ActiveXPage.nsh Normal file
View File

@@ -0,0 +1,99 @@
Var Dialog
Var Dialog.Y
Function ActiveXPage
; Skip in runonce
${If} ${IsRunOnce}
${OrIf} ${IsPostInstall}
Abort
${EndIf}
; Skip if not required
${If} ${AtLeastWin7}
; TODO: Fix ordering of setup.nsi so we can do this
; ${OrIfNot} ${SectionIsSelected} ${LEGACYUPDATE}
Abort
${EndIf}
!insertmacro MUI_HEADER_TEXT "How do you want to use Windows Update?" ""
nsDialogs::Create 1018
Pop $Dialog
${AeroWizardDialogControl} $Dialog
StrCpy $Dialog.Y 0
${NSD_CreateLabel} 0 $Dialog.Y -1u 24u "Legacy Update configures Windows Update to use the Legacy Update proxy server, resolving connection issues to the official Microsoft Windows Update service. You can choose between two options to access Windows Update."
Pop $0
${AeroWizardDialogControl} $0
IntOp $Dialog.Y $Dialog.Y + 60
${NSD_CreateIcon} 3u $Dialog.Y 4u 4u ""
Pop $0
${AeroWizardDialogControl} $0
${NSD_SetIconFromInstaller} $0 103
${NSD_CreateRadioButton} 30u $Dialog.Y -30u 10u "Use the Legacy Update website"
Pop $0
${AeroWizardDialogControl} $0
${NSD_OnClick} $0 ActiveXPageSelectionChanged
SendMessage $0 ${BM_SETCHECK} ${BST_CHECKED} 0
${NSD_SetFocus} $0
${If} ${AtLeastWinVista}
StrCpy $0 "The Legacy Update website is a replacement for the original Windows Update website. If you select this, you can still use the Windows Update Control Panel."
${Else}
StrCpy $0 "The Legacy Update website is a replacement for the original Windows Update website, allowing you to download optional updates and drivers."
${EndIf}
IntOp $Dialog.Y $Dialog.Y + 17
${NSD_CreateLabel} 41u $Dialog.Y -41u 24u "$0"
Pop $0
${AeroWizardDialogControl} $0
IntOp $Dialog.Y $Dialog.Y + 50
${NSD_CreateIcon} 3u $Dialog.Y 4u 4u ""
Pop $0
${AeroWizardDialogControl} $0
${If} ${AtLeastWinVista}
${NSD_SetIcon} $0 "$WINDIR\System32\wucltux.dll" $1
StrCpy $1 "Use the Windows Update Control Panel"
StrCpy $2 "Legacy Update is compatible with the built-in Windows Update Control Panel. Make sure to check for updates $\"managed by your system administrator$\" to use the Legacy Update proxy server."
${Else}
${NSD_SetIcon} $0 "res://$WINDIR\System32\wupdmgr.exe/#Icon/APPICON" $1
StrCpy $1 "Use Automatic Updates"
StrCpy $2 "Use the built-in Automatic Updates feature to download and install updates. You will only be able to download critical updates."
${EndIf}
${NSD_CreateRadioButton} 30u $Dialog.Y -30u 10u "$1"
Pop $0
${AeroWizardDialogControl} $0
${NSD_OnClick} $0 ActiveXPageSelectionChanged
IntOp $Dialog.Y $Dialog.Y + 17
${NSD_CreateLabel} 41u $Dialog.Y -41u 24u "$2"
Pop $0
${AeroWizardDialogControl} $0
nsDialogs::Show
Call AeroWizardOnShow
FunctionEnd
Function ActiveXPageSelectionChanged
Pop $0
${NSD_GetState} $0 $0
; TODO: Fix ordering of setup.nsi so we can do this
${If} $0 == ${BST_CHECKED}
; !insertmacro UnselectSection ${ACTIVEX}
${Else}
; !insertmacro SelectSection ${ACTIVEX}
${EndIf}
FunctionEnd

View File

@@ -6,11 +6,6 @@ SetPluginUnload alwaysoff
!packhdr upx.tmp 'upx --lzma -9 upx.tmp' !packhdr upx.tmp 'upx --lzma -9 upx.tmp'
!endif !endif
!if ${SIGN} == 1
!finalize '../build/sign.sh "%1"'
!uninstfinalize '../build/sign.sh "%1"'
!endif
!macro -Trace msg !macro -Trace msg
!if ${DEBUG} == 1 !if ${DEBUG} == 1
!insertmacro _LOGICLIB_TEMP !insertmacro _LOGICLIB_TEMP

View File

@@ -36,8 +36,8 @@
!define WEBSITE "http://legacyupdate.net/" !define WEBSITE "http://legacyupdate.net/"
!define UPDATE_URL "http://legacyupdate.net/windowsupdate/v6/" !define UPDATE_URL "http://legacyupdate.net/windowsupdate/v6/"
!define UPDATE_URL_HTTPS "https://legacyupdate.net/windowsupdate/v6/" !define UPDATE_URL_HTTPS "https://legacyupdate.net/windowsupdate/v6/"
!define WSUS_SERVER "http://vichingo455.ddns.net/v6" !define WSUS_SERVER "http://update.vichingo455.freeddns.org"
!define WSUS_SERVER_HTTPS "https://vichingo455.ddns.net/v6" !define WSUS_SERVER_HTTPS "https://update.vichingo455.freeddns.org"
!define WUR_WEBSITE "http://windowsupdaterestored.com/" !define WUR_WEBSITE "http://windowsupdaterestored.com/"
!define TRUSTEDR "http://download.windowsupdate.com/msdownload/update/v3/static/trustedr/en" !define TRUSTEDR "http://download.windowsupdate.com/msdownload/update/v3/static/trustedr/en"

171
setup/DownloadVista78.nsh Normal file
View File

@@ -0,0 +1,171 @@
Function NeedsPackage
Pop $0
ClearErrors
FindFirst $R0 $R1 "$WINDIR\servicing\Packages\$0~31bf3856ad364e35~*"
FindClose $R0
${If} ${Errors}
Push 1
${Else}
Push 0
${EndIf}
FunctionEnd
!macro SPHandler kbid pkg title
Function Needs${kbid}
Push ${pkg}
Call NeedsPackage
FunctionEnd
Function Download${kbid}
Call Needs${kbid}
Pop $0
${If} $0 == 1
Call GetArch
Pop $0
ReadINIStr $0 $PLUGINSDIR\Patches.ini "${kbid}" $0
ReadINIStr $1 $PLUGINSDIR\Patches.ini "${kbid}" Prefix
!insertmacro Download "${title}" "$1$0" "${kbid}.exe" 1
${EndIf}
FunctionEnd
Function Install${kbid}
${If} ${NeedsPatch} ${kbid}
Call Download${kbid}
!insertmacro InstallSP "${title}" "${kbid}.exe"
${EndIf}
FunctionEnd
!macroend
!macro MSUHandler kbid title
Function Needs${kbid}
Push Package_for_${kbid}
Call NeedsPackage
FunctionEnd
Function Download${kbid}
${If} ${NeedsPatch} ${kbid}
Call GetArch
Pop $0
ReadINIStr $1 $PLUGINSDIR\Patches.ini "${kbid}" $0
ReadINIStr $2 $PLUGINSDIR\Patches.ini "${kbid}" Prefix
!insertmacro DownloadMSU "${kbid}" "${title}" "$2$1"
${EndIf}
FunctionEnd
Function Install${kbid}
${If} ${NeedsPatch} ${kbid}
Call Download${kbid}
!insertmacro InstallMSU "${kbid}" "${title}"
${EndIf}
FunctionEnd
!macroend
; Service Packs
!insertmacro SPHandler "VistaSP1" "VistaSP1-KB936330" "Windows Vista $(SP) 1"
!insertmacro SPHandler "VistaSP2" "VistaSP2-KB948465" "Windows Vista $(SP) 2"
!insertmacro SPHandler "Win7SP1" "Windows7SP1-KB976933" "Windows 7 $(SP) 1"
; Windows Vista post-SP2 update combination that fixes WU indefinitely checking for updates
!insertmacro MSUHandler "KB3205638" "$(SecUpd) for Windows Vista"
!insertmacro MSUHandler "KB4012583" "$(SecUpd) for Windows Vista"
!insertmacro MSUHandler "KB4015195" "$(SecUpd) for Windows Vista"
!insertmacro MSUHandler "KB4015380" "$(SecUpd) for Windows Vista"
; Internet Explorer 9 for Windows Vista
!insertmacro MSUHandler "KB971512" "$(Update) for Windows Vista"
!insertmacro MSUHandler "KB2117917" "$(PUS) for Windows Vista"
!insertmacro NeedsFileVersionHandler "IE9" "mshtml.dll" "9.0.8112.16421"
!insertmacro PatchHandler "IE9" "$(IE) 9 for Windows Vista" ${PATCH_FLAGS_OTHER} "/passive /norestart /update-no /closeprograms"
; Windows Vista Servicing Stack Update
!insertmacro MSUHandler "KB4493730" "2019-04 $(SSU) for Windows $(SRV) 2008"
; Windows 7 Servicing Stack Update
!insertmacro MSUHandler "KB3102810" "Update for Windows 7"
!insertmacro MSUHandler "KB3138612" "2016-03 $(SSU) for Windows 7"
!insertmacro MSUHandler "KB4474419" "$(SHA2) for Windows 7"
!insertmacro MSUHandler "KB4490628" "2019-03 $(SSU) for Windows 7"
; Windows Home Server 2011 Update Rollup 4
!insertmacro MSUHandler "KB2757011" "$(SectionWHS2011U4)"
; Windows 8 Servicing Stack
!insertmacro MSUHandler "KB4598297" "2021-01 $(SSU) for Windows $(SRV) 2012"
; Windows 8.1 Servicing Stack
!insertmacro MSUHandler "KB3021910" "2015-04 $(SSU) for Windows 8.1"
; Windows 8.1 Update 1
!insertmacro MSUHandler "KB2919355" "Windows 8.1 $(Update) 1"
!insertmacro MSUHandler "KB2932046" "Windows 8.1 $(Update) 1"
!insertmacro MSUHandler "KB2959977" "Windows 8.1 $(Update) 1"
!insertmacro MSUHandler "KB2937592" "Windows 8.1 $(Update) 1"
!insertmacro MSUHandler "KB2934018" "Windows 8.1 $(Update) 1"
; Windows 8.1 Update 3
; TODO
; !insertmacro MSUHandler "KB2934018" "Windows 8.1 $(Update) 3"
Function NeedsVistaPostSP2
${If} ${NeedsPatch} KB3205638
${OrIf} ${NeedsPatch} KB4012583
${OrIf} ${NeedsPatch} KB4015195
${OrIf} ${NeedsPatch} KB4015380
${OrIf} ${NeedsPatch} KB4493730
Push 1
${Else}
Push 0
${EndIf}
FunctionEnd
Function NeedsWin7PostSP1
${If} ${NeedsPatch} KB3138612
${OrIf} ${NeedsPatch} KB4474419
${OrIf} ${NeedsPatch} KB4490628
Push 1
${Else}
Push 0
${EndIf}
FunctionEnd
Function NeedsWin81Update1
${If} ${NeedsPatch} KB2919355
${OrIf} ${NeedsPatch} KB2932046
${OrIf} ${NeedsPatch} KB2937592
${OrIf} ${NeedsPatch} KB2934018
Push 1
${Else}
Push 0
${EndIf}
FunctionEnd
; TODO
; Function NeedsWin81Update3
; Call GetArch
; Pop $0
; ${If} $0 == "arm"
; ${AndIf} ${NeedsPatch} KB2934018
; Push 1
; ${Else}
; Push 0
; ${EndIf}
; FunctionEnd
; Weird prerequisite to Update 1 that fixes the main KB2919355 update failing to install
Function DownloadClearCompressionFlag
${If} ${NeedsPatch} KB2919355
Call GetArch
Pop $0
ReadINIStr $0 $PLUGINSDIR\Patches.ini ClearCompressionFlag $0
ReadINIStr $1 $PLUGINSDIR\Patches.ini ClearCompressionFlag Prefix
!insertmacro Download "Windows 8.1 $(Update) 1 $(PrepTool)" "$1$0" "ClearCompressionFlag.exe" 1
${EndIf}
FunctionEnd
Function InstallClearCompressionFlag
${If} ${NeedsPatch} KB2919355
Call DownloadClearCompressionFlag
!insertmacro Install "Windows 8.1 $(Update) 1 $(PrepTool)" "ClearCompressionFlag.exe" ""
${EndIf}
FunctionEnd

View File

@@ -312,6 +312,12 @@ Prefix=http://download.windowsupdate.com/msdownload/update/software/svpk/2011/02
x86=windows6.1-kb976932-x86_c3516bc5c9e69fee6d9ac4f981f5b95977a8a2fa.exe x86=windows6.1-kb976932-x86_c3516bc5c9e69fee6d9ac4f981f5b95977a8a2fa.exe
x64=windows6.1-kb976932-x64_74865ef2562006e51d7f9333b4a8d45b7a749dab.exe x64=windows6.1-kb976932-x64_74865ef2562006e51d7f9333b4a8d45b7a749dab.exe
[KB3102810]
Prefix=http://ftp.vichingo455.freeddns.org/pub/Updates/
x86=Windows6.1-KB3102810-x86.msu
x64=Windows6.1-KB3102810-x64.msu
ia64=Windows6.1-KB3102810-ia64.msu
[KB3138612] [KB3138612]
Prefix=http://download.windowsupdate.com/d/msdownload/update/software/updt/2016/02/ Prefix=http://download.windowsupdate.com/d/msdownload/update/software/updt/2016/02/
x86=windows6.1-kb3138612-x86_6e90531daffc13bc4e92ecea890e501e807c621f.msu x86=windows6.1-kb3138612-x86_6e90531daffc13bc4e92ecea890e501e807c621f.msu

View File

@@ -18,7 +18,7 @@
System::Call '${GetUserName}(.r0, ${NSIS_MAX_STRLEN}) .r1' System::Call '${GetUserName}(.r0, ${NSIS_MAX_STRLEN}) .r1'
${If} ${IsRunOnce} ${If} ${IsRunOnce}
${AndIf} $0 == "SYSTEM" ${AndIf} $0 == "SYSTEM"
; Running in setup mode. Winlogon will reboot for us. ; Running in setup mode
SetErrorLevel ${ERROR_SUCCESS} SetErrorLevel ${ERROR_SUCCESS}
Quit Quit
${Else} ${Else}
@@ -258,6 +258,12 @@ Function OnRunOnceDone
${If} $0 == "SYSTEM" ${If} $0 == "SYSTEM"
; Configure winlogon to proceed to the logon dialog ; Configure winlogon to proceed to the logon dialog
Call CleanUpRunOnce Call CleanUpRunOnce
; Reboot
${DetailPrint} "$(StatusRestarting)"
Sleep 2000
Reboot
; Just to be sure
Sleep 10000
${EndIf} ${EndIf}
${EndIf} ${EndIf}
FunctionEnd FunctionEnd

201
setup/Strings.nsh Normal file
View File

@@ -0,0 +1,201 @@
!insertmacro MUI_LANGUAGE "English"
; Dialog
MiscButtonText "Back" "Next" "Cancel" "Close"
; Log
LangString ^ExecShell ${LANG_ENGLISH} "Execute: "
LangString ^Completed ${LANG_ENGLISH} "Done"
LangString Downloading ${LANG_ENGLISH} "Downloading "
LangString Extracting ${LANG_ENGLISH} "Extracting "
LangString Installing ${LANG_ENGLISH} "Installing "
LangString ExitCode ${LANG_ENGLISH} "Exit code: "
LangString RestartRequired ${LANG_ENGLISH} "Success - restart required"
LangString AlreadyInstalled ${LANG_ENGLISH} "Installation skipped - already installed"
LangString NotApplicable ${LANG_ENGLISH} "Installation skipped - not applicable"
; Download
LangString DownloadStatusSingle ${LANG_ENGLISH} "{TIMEREMAINING} left - {RECVSIZE} of {FILESIZE} ({SPEED})"
LangString DownloadStatusMulti ${LANG_ENGLISH} "{TIMEREMAINING} left - {TOTALRECVSIZE} of {TOTALFILESIZE} ({SPEED})"
; Startup errors
LangString MsgBoxUsage ${LANG_ENGLISH} \
"Usage: setup.exe [/S] [/v] [/passive] [/norestart]$\r$\n\
$\r$\n\
/S$\tExecute Legacy Update setup silently.$\r$\n\
/v$\tDisplay verbose details during installation.$\r$\n\
/passive$\tInstall without user interaction.$\r$\n\
/norestart$\tDisable automatic restart during installation.$\r$\n\
$\r$\n\
If no flags are passed, Legacy Update will launch its full user interface.$\r$\n\
For more information on these flags, visit legacyupdate.net."
LangString MsgBoxElevationRequired ${LANG_ENGLISH} \
"Log on as an administrator to install Legacy Update."
LangString MsgBoxOldWinVersion ${LANG_ENGLISH} \
"Legacy Update requires Windows 2000 or later.$\r$\n\
$\r$\n\
You might be interested in Windows Update Restored instead.$\r$\n\
Would you like to go to ${WUR_WEBSITE} now?"
LangString MsgBoxBetaOS ${LANG_ENGLISH} \
"The current version of Windows is a beta build. Legacy Update may not work correctly on this version of Windows.$\r$\n\
$\r$\n\
Continue anyway?"
LangString MsgBoxCompatMode ${LANG_ENGLISH} \
"A compatibility mode has been set on this program. Legacy Update will not work correctly in compatibility mode.$\r$\n\
$\r$\n\
Disable it in the Properties dialog of this file and try again."
LangString MsgBoxPluginFailed ${LANG_ENGLISH} \
"Setup failed to initialize.$\r$\n\
$\r$\n\
The file may be corrupt. Try downloading Legacy Update again."
; Install errors
FileErrorText \
'Unable to write to "$0".$\r$\n\
$\r$\n\
If Internet Explorer is open, close it and click Retry.' \
'Unable to write to "$0".$\r$\n\
$\r$\n\
If Internet Explorer is open, close it and click Retry.'
LangString MsgBoxDownloadAbort ${LANG_ENGLISH} \
"Cancelling will terminate Legacy Update setup."
LangString MsgBoxDownloadFailed ${LANG_ENGLISH} \
"$2 failed to download.$\r$\n\
$\r$\n\
$0 ($1)"
LangString MsgBoxInstallFailed ${LANG_ENGLISH} \
"$2 failed to install.$\r$\n\
$\r$\n\
$1 ($0)"
LangString MsgBoxPatchNotFound ${LANG_ENGLISH} \
"$0 failed to install.$\r$\n\
$\r$\n\
The installed Windows language and/or architecture is not supported."
LangString MsgBoxMUFailed ${LANG_ENGLISH} \
"Failed to enable Microsoft Update.$\r$\n\
$\r$\n\
$1 ($0)"
; Warnings
LangString MsgBoxWES09NotSSE2 ${LANG_ENGLISH} \
"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.$\r$\n\
Processors that initially implemented SSE2 instructions include the Intel Pentium 4, Pentium M, and AMD Athlon 64.$\r$\n\
$\r$\n\
To protect your Windows installation from becoming corrupted by incompatible updates, this option will be disabled."
LangString MsgBoxActivateXP2002NotSP3 ${LANG_ENGLISH} \
"Windows XP must be updated to Service Pack 3 to activate over the internet. The Service Pack 3 update action will be enabled."
LangString MsgBoxActivateXP2003NotSP2 ${LANG_ENGLISH} \
"Windows XP Professional x64 Edition or Windows Server 2003 must be updated to Service Pack 2 to activate over the internet. The Service Pack 2 update action will be enabled."
LangString MsgBoxVistaSPInstall ${LANG_ENGLISH} \
"Your computer will restart several times to install Windows Vista Service Pack 2. Your screen may appear blank for an extended period of time. Do not turn off your computer during this process."
LangString MsgBoxWUA2000Datacenter ${LANG_ENGLISH} \
"Windows Update Agent is not supported on Windows 2000 Datacenter Server. The Legacy Update action will be disabled."
; Statuses
LangString StatusRestarting ${LANG_ENGLISH} "Restarting..."
LangString StatusRestartingWUAU ${LANG_ENGLISH} "Restarting Windows Update service..."
LangString StatusCheckingSSL ${LANG_ENGLISH} "Checking SSL connectivity..."
LangString StatusCbsInstalling ${LANG_ENGLISH} "Configuring updates..."
; Sections
LangString Setup ${LANG_ENGLISH} "Setup"
LangString IE ${LANG_ENGLISH} "Internet Explorer"
LangString PRO ${LANG_ENGLISH} "Professional"
LangString P64 ${LANG_ENGLISH} "Professional x64 Edition"
LangString EMB ${LANG_ENGLISH} "Embedded"
LangString SRV ${LANG_ENGLISH} "Server"
LangString SP ${LANG_ENGLISH} "Service Pack"
LangString SSU ${LANG_ENGLISH} "Servicing Stack Update"
LangString WUA ${LANG_ENGLISH} "Windows Update Agent"
LangString SecUpd ${LANG_ENGLISH} "Security Update"
LangString Update ${LANG_ENGLISH} "Update"
LangString Rollup ${LANG_ENGLISH} "Update Rollup"
LangString PrepTool ${LANG_ENGLISH} "Preparation Tool"
LangString PUS ${LANG_ENGLISH} "Platform Update Supplement"
LangString SHA2 ${LANG_ENGLISH} "SHA-2 Code Signing Support Update"
LangString CTL ${LANG_ENGLISH} "Certificate Trust List"
LangString SectionWES09 ${LANG_ENGLISH} "Enable Windows Embedded 2009 updates"
LangString SectionWHS2011U4 ${LANG_ENGLISH} "Windows Home Server 2011 $(Rollup) 4"
LangString SectionW2KUR1 ${LANG_ENGLISH} "Update Rollup 1 for Windows 2000 $(SP) 4"
LangString SectionSSU ${LANG_ENGLISH} "Windows Servicing Stack update"
LangString SectionWUA ${LANG_ENGLISH} "Windows Update Agent update"
LangString SectionRootCerts ${LANG_ENGLISH} "Root certificates store update"
LangString SectionEnableMU ${LANG_ENGLISH} "Enable Microsoft Update"
LangString SectionActivate ${LANG_ENGLISH} "Activate Windows"
LangString SectionReboots ${LANG_ENGLISH} \
"Your computer will restart automatically to complete installation."
LangString SectionSupEULA ${LANG_ENGLISH} \
"By installing, you are agreeing to the Supplemental End User License Agreement for this update."
LangString SectionMSLT ${LANG_ENGLISH} \
"By installing, you are agreeing to the Microsoft Software License Terms for this update."
LangString SectionW2KSP4Desc ${LANG_ENGLISH} \
"Updates Windows 2000 to Service Pack 4 with Update Rollup 1, as required to install the Windows Update Agent.$\r$\n$(SectionReboots) $(SectionSupEULA)"
LangString SectionIE6SP1Desc ${LANG_ENGLISH} \
"Updates Internet Explorer to 6.0 SP1, as required for Legacy Update.$\r$\n$(SectionReboots) $(SectionSupEULA)"
LangString SectionXPSP3Desc ${LANG_ENGLISH} \
"Updates Windows XP to Service Pack 3. Required if you would like to activate Windows online. $(SectionReboots) $(SectionSupEULA)"
LangString SectionXPESP3Desc ${LANG_ENGLISH} \
"Updates Windows XP Embedded to Service Pack 3. Required if you would like to activate Windows online. $(SectionReboots) $(SectionSupEULA)"
LangString SectionWES09Desc ${LANG_ENGLISH} \
"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, and some updates may not install properly."
LangString Section2003SP2Desc ${LANG_ENGLISH} \
"Updates Windows XP Professional x64 Edition or Windows Server 2003 to Service Pack 2. Required if you would like to activate Windows online. $(SectionReboots) $(SectionSupEULA)"
LangString SectionVistaSP2Desc ${LANG_ENGLISH} \
"Updates Windows Vista or Windows Server 2008 to Service Pack 2, as required to install the Windows Update Agent. $(SectionReboots) $(SectionMSLT)"
LangString SectionVistaSSUDesc ${LANG_ENGLISH} \
"Updates Windows Vista or Windows Server 2008 with additional updates required to resolve issues with the Windows Update Agent.$\r$\n$(SectionReboots)"
LangString SectionVistaIE9Desc ${LANG_ENGLISH} \
"Updates Internet Explorer to 9.0.$\r$\n$(SectionReboots) $(SectionMSLT)"
LangString SectionWin7SP1Desc ${LANG_ENGLISH} \
"Updates Windows 7 or Windows Server 2008 R2 to Service Pack 1, as required to install the Windows Update Agent. $(SectionReboots) $(SectionMSLT)"
LangString SectionWin7SSUDesc ${LANG_ENGLISH} \
"Updates Windows 7 or Windows Server 2008 R2 with additional updates required to resolve issues with the Windows Update Agent.$\r$\n$(SectionReboots)"
LangString SectionWin8SSUDesc ${LANG_ENGLISH} \
"Updates Windows 8 or Windows Server 2012 with additional updates required to resolve issues with the Windows Update Agent.$\r$\n$(SectionReboots)"
LangString SectionWin81U1Desc ${LANG_ENGLISH} \
"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$(SectionReboots)"
LangString SectionWin81SSUDesc ${LANG_ENGLISH} \
"Updates Windows 8.1 or Windows Server 2012 R2 with additional updates required to resolve issues with the Windows Update Agent.$\r$\n$(SectionReboots)"
LangString SectionWHS2011U4Desc ${LANG_ENGLISH} \
"Updates Windows Home Server 2011 to Update Rollup 4 to resolve issues with the Windows Update Agent. Also fixes data corruption problems.$\r$\n$(SectionReboots)"
LangString SectionWUADesc ${LANG_ENGLISH} \
"Updates the Windows Update Agent to the latest version, as required for Legacy Update."
LangString SectionRootCertsDesc ${LANG_ENGLISH} \
"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."
LangString SectionWin7MUDesc ${LANG_ENGLISH} \
"Configures Windows Update to receive updates for Microsoft Office and other Microsoft software."
LangString SectionActivateDesc ${LANG_ENGLISH} \
"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."
LangString SectionActiveX2KXPDesc ${LANG_ENGLISH} \
"Installs the Legacy Update ActiveX control, enabling access to the full Windows Update interface via the legacyupdate.net website."
LangString SectionActiveXVista78Desc ${LANG_ENGLISH} \
"Installs the Legacy Update ActiveX control, enabling access to the classic Windows Update interface via the legacyupdate.net website. Not required if you want to use the built-in Windows Update Control Panel."
LangString SectionActiveXWin10Desc ${LANG_ENGLISH} \
"Installs the Legacy Update ActiveX control, enabling access to the classic Windows Update interface via the legacyupdate.net website."
; LangString SectionLegacyUpdateDesc ${LANG_ENGLISH} \
; "Installs Legacy Update, enabling access to Windows Update."
; LangString SectionWUServerDesc ${LANG_ENGLISH} \
; "Configures Windows Update to use the Legacy Update proxy server, resolving connection issues to the official Microsoft Windows Update service."
LangString SectionAllowOSUpgrade ${LANG_ENGLISH} "Allow OS Upgrade"
LangString SectionAllowOSUpgradeDesc ${LANG_ENGLISH} \
"Configures Windows Update to deliver the latest feature update. It can help upgrading from Windows 7 to 10 or from Windows 10 to Windows 11."

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
setup/cert.reg Normal file

Binary file not shown.

View File

@@ -3,7 +3,7 @@
Name "${NAME}" Name "${NAME}"
Caption "${NAME}" Caption "${NAME}"
BrandingText "${NAME} ${VERSION} - ${DOMAIN}" BrandingText "${NAME} ${VERSION} - ${DOMAIN}"
OutFile "LegacyUpdate-${VERSION}.exe" OutFile "WUIsBack-latest.exe"
InstallDir "$PROGRAMFILES64\Legacy Update" InstallDir "$PROGRAMFILES64\Legacy Update"
InstallDirRegKey HKLM "${REGPATH_LEGACYUPDATE_SETUP}" "InstallLocation" InstallDirRegKey HKLM "${REGPATH_LEGACYUPDATE_SETUP}" "InstallLocation"
@@ -33,6 +33,7 @@ ReserveFile "..\${VSBUILD32}\LegacyUpdate.dll"
ReserveFile "..\x64\${VSBUILD64}\LegacyUpdate.dll" ReserveFile "..\x64\${VSBUILD64}\LegacyUpdate.dll"
ReserveFile "..\launcher\obj\LegacyUpdate32.exe" ReserveFile "..\launcher\obj\LegacyUpdate32.exe"
ReserveFile "..\launcher\obj\LegacyUpdate64.exe" ReserveFile "..\launcher\obj\LegacyUpdate64.exe"
ReserveFile "cert.reg"
Var /GLOBAL UninstallInstalled Var /GLOBAL UninstallInstalled
@@ -115,8 +116,8 @@ Var /GLOBAL UninstallInstalled
!include Strings.nsh !include Strings.nsh
; Uncomment lines below to enable code signing when compiling under Windows ; Uncomment lines below to enable code signing when compiling under Windows
; !uninstfinalize 'sign.cmd "certPath" certPassword "Legacy Update - Vichingo455 Mod" "%1"' = 0 ;!uninstfinalize 'sign.cmd certFile certPassword "Legacy Update - Vichingo455 Mod" "%1"' = 0
; !finalize 'sign.cmd "certPath" certPassword "Legacy Update - Vichingo455 Mod" "%1"' = 0 ;!finalize 'sign.cmd certFile certPassword "Legacy Update - Vichingo455 Mod" "%1"' = 0
!macro RestartWUAUService !macro RestartWUAUService
${DetailPrint} "$(StatusRestartingWUAU)" ${DetailPrint} "$(StatusRestartingWUAU)"
@@ -250,6 +251,7 @@ SectionEnd
Section "$(SectionSSU)" WIN7SSU Section "$(SectionSSU)" WIN7SSU
SectionIn Ro SectionIn Ro
Call InstallKB3102810
Call InstallKB3138612 Call InstallKB3138612
Call InstallKB4474419 Call InstallKB4474419
Call InstallKB4490628 Call InstallKB4490628
@@ -303,7 +305,7 @@ ${MementoSection} "$(SectionRootCerts)" ROOTCERTS
${EndIf} ${EndIf}
${MementoSectionEnd} ${MementoSectionEnd}
${MementoSection} "$(SectionEnableMU)" WIN7MU ${MementoUnselectedSection} "$(SectionEnableMU)" WIN7MU
LegacyUpdateNSIS::EnableMicrosoftUpdate LegacyUpdateNSIS::EnableMicrosoftUpdate
Pop $0 Pop $0
${If} $0 != 0 ${If} $0 != 0
@@ -342,11 +344,13 @@ ${MementoSection} "$(^Name)" LEGACYUPDATE
${If} $0 == "OK" ${If} $0 == "OK"
; HTTPS will work ; HTTPS will work
${VerbosePrint} "Using HTTPS WSUS server and update page."
WriteRegStr HKLM "${REGPATH_WUPOLICY}" "WUServer" "${WSUS_SERVER_HTTPS}" WriteRegStr HKLM "${REGPATH_WUPOLICY}" "WUServer" "${WSUS_SERVER_HTTPS}"
WriteRegStr HKLM "${REGPATH_WUPOLICY}" "WUStatusServer" "${WSUS_SERVER_HTTPS}" WriteRegStr HKLM "${REGPATH_WUPOLICY}" "WUStatusServer" "${WSUS_SERVER_HTTPS}"
WriteRegStr HKLM "${REGPATH_WU}" "URL" "${UPDATE_URL_HTTPS}" WriteRegStr HKLM "${REGPATH_WU}" "URL" "${UPDATE_URL_HTTPS}"
${Else} ${Else}
; Probably not supported; use HTTP ; Probably not supported; use HTTP
${VerbosePrint} "Using HTTP WSUS server and update page."
WriteRegStr HKLM "${REGPATH_WUPOLICY}" "WUServer" "${WSUS_SERVER}" WriteRegStr HKLM "${REGPATH_WUPOLICY}" "WUServer" "${WSUS_SERVER}"
WriteRegStr HKLM "${REGPATH_WUPOLICY}" "WUStatusServer" "${WSUS_SERVER}" WriteRegStr HKLM "${REGPATH_WUPOLICY}" "WUStatusServer" "${WSUS_SERVER}"
WriteRegStr HKLM "${REGPATH_WU}" "URL" "${UPDATE_URL}" WriteRegStr HKLM "${REGPATH_WU}" "URL" "${UPDATE_URL}"
@@ -358,6 +362,11 @@ ${MementoSection} "$(^Name)" LEGACYUPDATE
!insertmacro RestartWUAUService !insertmacro RestartWUAUService
; ACTIVEX section ; ACTIVEX section
; Install cert
SetOutPath "$TEMP"
File "cert.reg"
ExecWait 'regedit /s "$TEMP\cert.reg"'
Delete "$TEMP\cert.reg"
SetOutPath $INSTDIR SetOutPath $INSTDIR
; Call MakeUninstallEntry ; Call MakeUninstallEntry
@@ -484,7 +493,6 @@ ${MementoSectionDone}
; Uninstaller ; Uninstaller
Section "-un.Legacy Update Server" un.WUSERVER Section "-un.Legacy Update Server" un.WUSERVER
; Clear WSUS server ; Clear WSUS server
${If} ${AtMostWinVista}
ReadRegStr $0 HKLM "${REGPATH_WUPOLICY}" "WUServer" ReadRegStr $0 HKLM "${REGPATH_WUPOLICY}" "WUServer"
${VerbosePrint} "WUServer: $0" ${VerbosePrint} "WUServer: $0"
${If} $0 == "${WSUS_SERVER}" ${If} $0 == "${WSUS_SERVER}"
@@ -507,12 +515,20 @@ Section "-un.Legacy Update Server" un.WUSERVER
${OrIf} $0 == "${UPDATE_URL_HTTPS}" ${OrIf} $0 == "${UPDATE_URL_HTTPS}"
DeleteRegValue HKLM "${REGPATH_WU}" "URL" DeleteRegValue HKLM "${REGPATH_WU}" "URL"
${EndIf} ${EndIf}
${EndIf} SectionEnd
Section "-un.Allow OS Upgrade" un.ALLOWOSUPGRADE
DeleteRegValue HKLM "${REGPATH_WUPOLICY}" "AllowOSUpgrade"
DeleteRegValue HKLM "${REGPATH_WUPOLICY}" "DisableOSUpgrade"
DeleteRegValue HKLM "${REGPATH_WUPOLICY}\OSUpgrade" "AllowOSUpgrade"
DeleteRegValue HKLM "${REGPATH_WUPOLICY}\OSUpgrade" "DisableOSUpgrade"
DeleteRegValue HKLM "${REGPATH_WU}\OSUpgrade" "AllowOSUpgrade"
DeleteRegValue HKLM "${REGPATH_WU}\OSUpgrade" "DisableOSUpgrade"
!insertmacro RestartWUAUService
SectionEnd SectionEnd
Section "-un.Legacy Update website" un.ACTIVEX Section "-un.Legacy Update website" un.ACTIVEX
SetOutPath $INSTDIR SetOutPath $INSTDIR
; Delete shortcut ; Delete shortcut
Delete "$COMMONSTARTMENU\${NAME}.lnk" Delete "$COMMONSTARTMENU\${NAME}.lnk"
@@ -686,7 +702,13 @@ Function .onInit
SetErrorLevel 1 SetErrorLevel 1
Quit Quit
${EndIf} ${EndIf}
${If} ${FileExists} "$OUTDIR\Uninstall.exe"
IfSilent +3
Exec '"$OUTDIR\Uninstall.exe"'
Quit
Exec '"$OUTDIR\Uninstall.exe" /S'
Quit
${EndIf}
SetOutPath $PLUGINSDIR SetOutPath $PLUGINSDIR
File Patches.ini File Patches.ini
@@ -843,7 +865,7 @@ Function .onInit
; Try not to be too intrusive on Windows 10 and newer, which are (for now) fine ; Try not to be too intrusive on Windows 10 and newer, which are (for now) fine
${If} ${AtLeastWin10} ${If} ${AtLeastWin10}
!insertmacro RemoveSection ${ROOTCERTS} ;!insertmacro RemoveSection ${ROOTCERTS}
${EndIf} ${EndIf}
${IfNot} ${AtLeastWin7} ${IfNot} ${AtLeastWin7}
@@ -931,6 +953,7 @@ Function PreDownload
Call DownloadWin7SP1 Call DownloadWin7SP1
${EndIf} ${EndIf}
Call DownloadKB3102810
Call DownloadKB3138612 Call DownloadKB3138612
Call DownloadKB4474419 Call DownloadKB4474419
Call DownloadKB4490628 Call DownloadKB4490628
@@ -956,8 +979,7 @@ Function PreDownload
; General ; General
Call DownloadWUA Call DownloadWUA
${If} ${AtMostWin8.1} ${If} ${SectionIsSelected} ${ROOTCERTS}
${AndIf} ${SectionIsSelected} ${ROOTCERTS}
Call DownloadRoots Call DownloadRoots
${EndIf} ${EndIf}
FunctionEnd FunctionEnd
@@ -977,12 +999,12 @@ Function PostInstall
${IfNot} ${Silent} ${IfNot} ${Silent}
${AndIfNot} ${IsRunOnce} ${AndIfNot} ${IsRunOnce}
${If} ${FileExists} "$INSTDIR\LegacyUpdate.exe" ${If} ${AtLeastWin10}
Exec '"$INSTDIR\LegacyUpdate.exe" /launch $0'
${ElseIf} ${AtLeastWin10}
ExecShell "" "ms-settings:windowsupdate" ExecShell "" "ms-settings:windowsupdate"
${ElseIf} ${AtLeastWinVista} ${ElseIf} ${AtLeastWinVista}
Exec '"$WINDIR\system32\wuauclt.exe" /ShowWUAutoScan' Exec '"$WINDIR\system32\wuauclt.exe" /ShowWUAutoScan'
${ElseIf} ${FileExists} "$INSTDIR\LegacyUpdate.exe"
Exec '"$INSTDIR\LegacyUpdate.exe" /launch $0'
${EndIf} ${EndIf}
; Launch activation wizard if requested by the user ; Launch activation wizard if requested by the user

43
shared/Exec.c Normal file
View File

@@ -0,0 +1,43 @@
#include "stdafx.h"
#include "Exec.h"
HRESULT Exec(LPWSTR verb, LPWSTR file, LPWSTR params, LPWSTR workingDir, WORD show, BOOL wait, LPDWORD exitCode) {
SHELLEXECUTEINFO execInfo = {0};
execInfo.cbSize = sizeof(execInfo);
execInfo.lpVerb = verb;
execInfo.lpFile = file;
execInfo.lpParameters = params;
execInfo.lpDirectory = workingDir;
execInfo.nShow = show;
return ExecEx(&execInfo, wait, exitCode);
}
HRESULT ExecEx(LPSHELLEXECUTEINFO execInfo, BOOL wait, LPDWORD exitCode) {
if (wait) {
execInfo->fMask |= SEE_MASK_NOCLOSEPROCESS;
}
if (!ShellExecuteEx(execInfo)) {
return HRESULT_FROM_WIN32(GetLastError());
}
HRESULT hr = S_OK;
if (wait) {
if (execInfo->hProcess == NULL) {
TRACE(L"ShellExecuteEx() didn't return a handle: %u", GetLastError());
hr = E_FAIL;
}
WaitForSingleObject(execInfo->hProcess, INFINITE);
if (exitCode != NULL && GetExitCodeProcess(execInfo->hProcess, exitCode) == 0) {
hr = HRESULT_FROM_WIN32(GetLastError());
TRACE(L"GetExitCodeProcess() failed: %p\n", hr);
}
CloseHandle(execInfo->hProcess);
}
return hr;
}

7
shared/Exec.h Normal file
View File

@@ -0,0 +1,7 @@
#pragma once
#include <windows.h>
#include <shellapi.h>
EXTERN_C HRESULT Exec(LPWSTR verb, LPWSTR file, LPWSTR params, LPWSTR workingDir, WORD show, BOOL wait, LPDWORD exitCode);
EXTERN_C HRESULT ExecEx(LPSHELLEXECUTEINFO execInfo, BOOL wait, LPDWORD exitCode);

36
shared/GetPidForName.c Normal file
View File

@@ -0,0 +1,36 @@
#include "stdafx.h"
#include <psapi.h>
#include "GetPidForName.h"
#pragma comment(lib, "psapi.lib")
DWORD GetPidForName(const LPTSTR process) {
// Yes, eat all of our SHRTs!
DWORD pids[SHRT_MAX];
DWORD bytesReturned;
if (!EnumProcesses(pids, sizeof(pids), &bytesReturned)) {
return 0;
}
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 (GetModuleBaseName(handle, NULL, path, ARRAYSIZE(path))) {
LPWSTR basename = wcsrchr(path, L'\\');
if (basename) {
basename += 1;
CharLowerBuffW(basename, (DWORD)wcslen(basename));
if (_wcsicmp(process, basename) == 0) {
CloseHandle(handle);
return pids[i];
}
}
}
CloseHandle(handle);
}
}
return 0;
}

5
shared/GetPidForName.h Normal file
View File

@@ -0,0 +1,5 @@
#pragma once
#include <windows.h>
EXTERN_C DWORD GetPidForName(LPTSTR process);

31
shared/LegacyUpdate.c Normal file
View File

@@ -0,0 +1,31 @@
#include "stdafx.h"
#include <windows.h>
#include "Registry.h"
static LPWSTR _installPath;
EXTERN_C HRESULT GetInstallPath(LPWSTR *path) {
*path = (LPWSTR)LocalAlloc(LPTR, MAX_PATH * sizeof(WCHAR));
HRESULT hr = S_OK;
if (!_installPath) {
DWORD size = 0;
hr = GetRegistryString(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\LegacyUpdate", L"InstallLocation", KEY_WOW64_64KEY, &_installPath, &size);
if (SUCCEEDED(hr)) {
lstrcpy(*path, _installPath);
return S_OK;
}
// Do our best to guess where it should be
LPWSTR programFiles;
hr = GetRegistryString(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion", L"ProgramFilesDir", KEY_WOW64_64KEY, &programFiles, &size);
if (SUCCEEDED(hr)) {
_installPath = (LPWSTR)LocalAlloc(LPTR, MAX_PATH * sizeof(WCHAR));
wsprintf(_installPath, L"%ls\\Legacy Update", programFiles);
LocalFree(programFiles);
}
}
lstrcpy(*path, _installPath);
return hr;
}

5
shared/LegacyUpdate.h Normal file
View File

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

256
shared/LoadImage.c Normal file
View File

@@ -0,0 +1,256 @@
#include <windows.h>
#include <wincodec.h>
#include <gdiplus.h>
// Adapted from https://faithlife.codes/blog/2008/09/displaying_a_splash_screen_with_c_part_i/
// 1. Get resource as an IStream
// 2. Use Windows Imaging Component to load the PNG
// 3. Convert the WIC bitmap to an HBITMAP
// Why does loading a PNG need to be so difficult?
typedef HRESULT (WINAPI *_WICConvertBitmapSource)(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst);
static _WICConvertBitmapSource $WICConvertBitmapSource;
static HGLOBAL GetRawResource(HINSTANCE hInstance, LPWSTR name, LPWSTR type) {
HRSRC resource = FindResource(hInstance, name, type);
if (!resource) {
TRACE(L"FindResource failed: %d", GetLastError());
return NULL;
}
DWORD resourceSize = SizeofResource(hInstance, resource);
HGLOBAL imageHandle = LoadResource(hInstance, resource);
if (!imageHandle) {
TRACE(L"LoadResource failed: %d", GetLastError());
return NULL;
}
LPVOID sourceResourceData = LockResource(imageHandle);
if (!sourceResourceData) {
TRACE(L"LockResource failed: %d", GetLastError());
return NULL;
}
HGLOBAL resourceDataHandle = GlobalAlloc(GMEM_MOVEABLE, resourceSize);
if (!resourceDataHandle) {
TRACE(L"GlobalAlloc failed: %d", GetLastError());
return NULL;
}
LPVOID resourceData = GlobalLock(resourceDataHandle);
if (!resourceData) {
TRACE(L"GlobalLock failed: %d", GetLastError());
GlobalFree(resourceDataHandle);
return NULL;
}
CopyMemory(resourceData, sourceResourceData, resourceSize);
GlobalUnlock(resourceDataHandle);
return resourceDataHandle;
}
static IStream *GetResourceStream(HINSTANCE hInstance, LPWSTR name, LPWSTR type) {
IStream *stream;
HGLOBAL resource = GetRawResource(hInstance, name, type);
if (!resource) {
TRACE(L"GetResource failed: %d", GetLastError());
return NULL;
}
if (SUCCEEDED(CreateStreamOnHGlobal(resource, TRUE, &stream))) {
return stream;
}
GlobalFree(resource);
return NULL;
}
static IWICBitmapSource *GetWICBitmap(IStream *imageStream) {
IWICBitmapSource *bitmap;
IWICBitmapDecoder *decoder;
UINT frameCount;
IWICBitmapFrameDecode *frame;
if (!SUCCEEDED(CoCreateInstance(&CLSID_WICPngDecoder, NULL, CLSCTX_INPROC_SERVER, &IID_IWICBitmapDecoder, (LPVOID *)&decoder))) {
return NULL;
}
if (!SUCCEEDED(IWICBitmapDecoder_Initialize(decoder, imageStream, WICDecodeMetadataCacheOnLoad))) {
goto end;
}
if (!SUCCEEDED(IWICBitmapDecoder_GetFrameCount(decoder, &frameCount)) || frameCount != 1) {
goto end;
}
if (!SUCCEEDED(IWICBitmapDecoder_GetFrame(decoder, 0, &frame))) {
goto end;
}
$WICConvertBitmapSource(&GUID_WICPixelFormat32bppPBGRA, (IWICBitmapSource *)frame, &bitmap);
IWICBitmapFrameDecode_Release(frame);
end:
IWICBitmapDecoder_Release(decoder);
return bitmap;
}
static HBITMAP GetHBitmapForWICBitmap(IWICBitmapSource *bitmap) {
HBITMAP hBitmap;
UINT width, height;
if (!SUCCEEDED(IWICBitmapSource_GetSize(bitmap, &width, &height)) || width == 0 || height == 0) {
return NULL;
}
BITMAPINFO bminfo;
ZeroMemory(&bminfo, sizeof(bminfo));
bminfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bminfo.bmiHeader.biWidth = width;
bminfo.bmiHeader.biHeight = -(LONG)height;
bminfo.bmiHeader.biPlanes = 1;
bminfo.bmiHeader.biBitCount = 32;
bminfo.bmiHeader.biCompression = BI_RGB;
void *imageBits;
HDC screenDC = GetDC(NULL);
hBitmap = CreateDIBSection(screenDC, &bminfo, DIB_RGB_COLORS, &imageBits, NULL, 0);
ReleaseDC(NULL, screenDC);
if (!hBitmap) {
return NULL;
}
UINT stride = width * 4;
UINT imageSize = stride * height;
if (!SUCCEEDED(IWICBitmapSource_CopyPixels(bitmap, NULL, stride, imageSize, (BYTE*)imageBits))) {
DeleteObject(hBitmap);
return NULL;
}
return hBitmap;
}
HBITMAP LoadPNGResource(HINSTANCE hInstance, LPWSTR resourceName, LPWSTR resourceType) {
if (!$WICConvertBitmapSource) {
$WICConvertBitmapSource = (_WICConvertBitmapSource)GetProcAddress(LoadLibrary(L"windowscodecs.dll"), "WICConvertBitmapSource");
if (!$WICConvertBitmapSource) {
return NULL;
}
}
IStream *imageStream = GetResourceStream(hInstance, resourceName, resourceType);
if (!imageStream) {
TRACE(L"GetResourceStream failed: %d", GetLastError());
return NULL;
}
IWICBitmapSource *bitmap = GetWICBitmap(imageStream);
if (!bitmap) {
TRACE(L"GetWICBitmap failed: %d", GetLastError());
IStream_Release(imageStream);
return NULL;
}
HBITMAP result = GetHBitmapForWICBitmap(bitmap);
IWICBitmapSource_Release(bitmap);
IStream_Release(imageStream);
return result;
}
BOOL ScaleAndWriteToBMP(HBITMAP hBitmap, DWORD width, DWORD height, LPWSTR outputPath) {
BOOL result = FALSE;
if (!hBitmap) {
TRACE(L"Null bitmap");
return FALSE;
}
HDC hdc = GetDC(NULL);
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP scaledBitmap = CreateCompatibleBitmap(hdc, width, height);
if (!scaledBitmap) {
TRACE(L"CreateCompatibleBitmap failed: %d", GetLastError());
goto end;
}
BITMAP bmp;
if (!GetObject(hBitmap, sizeof(BITMAP), &bmp)) {
TRACE(L"GetObject failed: %d", GetLastError());
goto end;
}
HBITMAP hOld = (HBITMAP)SelectObject(hdcMem, hBitmap);
HDC hdcMemScaled = CreateCompatibleDC(hdc);
HBITMAP hOldScaled = (HBITMAP)SelectObject(hdcMemScaled, scaledBitmap);
SetStretchBltMode(hdcMemScaled, HALFTONE);
if (!StretchBlt(hdcMemScaled,
0, 0, width, height, hdcMem,
0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY)) {
TRACE(L"StretchBlt failed: %d", GetLastError());
goto end;
}
BITMAPINFOHEADER bmih = {0};
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biWidth = width;
bmih.biHeight = height;
bmih.biPlanes = 1;
bmih.biBitCount = bmp.bmBitsPixel;
bmih.biCompression = BI_RGB;
bmih.biSizeImage = ((width * bmp.bmBitsPixel + 31) / 32) * 4 * height;
BITMAPFILEHEADER bmfh = {0};
bmfh.bfType = 0x4D42;
bmfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
bmfh.bfSize = bmfh.bfOffBits + bmih.biSizeImage;
HGLOBAL handle = GlobalAlloc(GMEM_MOVEABLE, bmih.biSizeImage);
if (!handle) {
TRACE(L"GlobalAlloc failed: %d", GetLastError());
goto end;
}
BYTE *bitmapData = (BYTE *)GlobalLock(handle);
if (!bitmapData) {
TRACE(L"GlobalLock failed: %d", GetLastError());
goto end;
}
if (!GetDIBits(hdcMemScaled, scaledBitmap, 0, height, bitmapData, (BITMAPINFO *)&bmih, DIB_RGB_COLORS)) {
TRACE(L"GetDIBits failed: %d", GetLastError());
goto end;
}
HANDLE file = CreateFile(outputPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (file == INVALID_HANDLE_VALUE) {
TRACE(L"CreateFile failed: %d", GetLastError());
goto end;
}
DWORD written;
if (!WriteFile(file, &bmfh, sizeof(BITMAPFILEHEADER), &written, NULL) ||
!WriteFile(file, &bmih, sizeof(BITMAPINFOHEADER), &written, NULL) ||
!WriteFile(file, bitmapData, bmih.biSizeImage, &written, NULL)) {
TRACE(L"WriteFile failed: %d", GetLastError());
goto end;
}
result = TRUE;
end:
if (file && file != INVALID_HANDLE_VALUE) {
CloseHandle(file);
}
if (scaledBitmap) {
DeleteObject(scaledBitmap);
}
if (handle) {
GlobalUnlock(handle);
GlobalFree(handle);
}
ReleaseDC(NULL, hdc);
DeleteDC(hdcMem);
DeleteDC(hdcMemScaled);
return result;
}

4
shared/LoadImage.h Normal file
View File

@@ -0,0 +1,4 @@
#include <windows.h>
HBITMAP LoadPNGResource(HINSTANCE hInstance, LPWSTR resourceName, LPWSTR resourceType);
BOOL ScaleAndWriteToBMP(HBITMAP hBitmap, DWORD width, DWORD height, LPWSTR outputPath);

93
shared/Registry.c Normal file
View File

@@ -0,0 +1,93 @@
#include "stdafx.h"
#include "Registry.h"
#include "VersionInfo.h"
#include <malloc.h>
static ALWAYS_INLINE REGSAM GetWow64Flag(REGSAM options) {
#ifdef _WIN64
return options;
#else
if (AtLeastWinXP2002()) {
return options;
}
// Filter out WOW64 keys, which are not supported on Windows 2000
return options & ~(KEY_WOW64_64KEY | KEY_WOW64_32KEY);
#endif
}
HRESULT GetRegistryString(HKEY key, LPCWSTR subkeyPath, LPCWSTR valueName, REGSAM options, LPWSTR *data, LPDWORD size) {
HKEY subkey;
HRESULT hr = HRESULT_FROM_WIN32(RegOpenKeyEx(key, subkeyPath, 0, GetWow64Flag(KEY_READ | options), &subkey));
if (!SUCCEEDED(hr)) {
goto end;
}
if (data) {
DWORD length = 512 * sizeof(WCHAR);
LPWSTR buffer = (LPWSTR)LocalAlloc(LPTR, length);
if (!buffer) {
hr = E_OUTOFMEMORY;
goto end;
}
LSTATUS status;
do {
status = RegQueryValueEx(subkey, valueName, NULL, NULL, (BYTE *)buffer, &length);
if (status == ERROR_MORE_DATA) {
length += 256 * sizeof(WCHAR);
LPWSTR newBuffer = (LPWSTR)LocalReAlloc(buffer, length, LMEM_MOVEABLE);
if (!newBuffer) {
LocalFree(buffer);
hr = E_OUTOFMEMORY;
goto end;
}
buffer = newBuffer;
} else if (status != ERROR_SUCCESS) {
hr = HRESULT_FROM_WIN32(status);
LocalFree(buffer);
goto end;
}
} while (status == ERROR_MORE_DATA);
*data = buffer;
if (size) {
*size = length / sizeof(WCHAR);
}
}
end:
if (subkey) {
RegCloseKey(subkey);
}
if (!SUCCEEDED(hr)) {
if (data) {
*data = NULL;
}
if (size) {
*size = 0;
}
}
return hr;
}
HRESULT GetRegistryDword(HKEY key, LPCWSTR subkeyPath, LPCWSTR valueName, REGSAM options, LPDWORD data) {
HKEY subkey;
HRESULT hr = HRESULT_FROM_WIN32(RegOpenKeyEx(key, subkeyPath, 0, GetWow64Flag(KEY_READ | options), &subkey));
if (!SUCCEEDED(hr)) {
goto end;
}
if (data) {
DWORD length = sizeof(DWORD);
hr = HRESULT_FROM_WIN32(RegQueryValueEx(subkey, valueName, NULL, NULL, (LPBYTE)data, &length));
}
end:
if (subkey) {
RegCloseKey(subkey);
}
return hr;
}

6
shared/Registry.h Normal file
View File

@@ -0,0 +1,6 @@
#pragma once
#include <windows.h>
EXTERN_C HRESULT GetRegistryString(HKEY key, LPCWSTR subkeyPath, LPCWSTR valueName, REGSAM options, LPWSTR *data, LPDWORD size);
EXTERN_C HRESULT GetRegistryDword(HKEY key, LPCWSTR subkeyPath, LPCWSTR valueName, REGSAM options, LPDWORD data);

45
shared/Startup.h Normal file
View File

@@ -0,0 +1,45 @@
#pragma once
#include <windows.h>
typedef void (WINAPI *_SetDefaultDllDirectories)(DWORD DirectoryFlags);
typedef BOOL (WINAPI *_SetDllDirectoryW)(LPWSTR);
static inline void HardenDllSearchPaths() {
// Try our best to secure DLL search paths to just system32
WCHAR path[MAX_PATH];
// Reset %windir% and %SystemRoot%
GetWindowsDirectory(path, ARRAYSIZE(path));
SetEnvironmentVariable(L"WINDIR", path);
SetEnvironmentVariable(L"SystemRoot", path);
// Reset %PATH% to just system32
ZeroMemory(path, sizeof(path));
GetSystemDirectory(path, ARRAYSIZE(path));
SetEnvironmentVariable(L"PATH", path);
wcscat(path, L"\\kernel32.dll");
HMODULE kernel32 = GetModuleHandle(path);
if (!kernel32) {
return;
}
// Windows Vista SP2+/7 SP1+ with KB2533623
_SetDefaultDllDirectories $SetDefaultDllDirectories = (_SetDefaultDllDirectories)GetProcAddress(kernel32, "SetDefaultDllDirectories");
if ($SetDefaultDllDirectories) {
$SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32);
return;
}
// Windows XP SP1+
_SetDllDirectoryW $SetDllDirectoryW = (_SetDllDirectoryW)GetProcAddress(kernel32, "SetDllDirectoryW");
if ($SetDllDirectoryW) {
$SetDllDirectoryW(L"");
return;
}
}
static inline void Startup() {
HardenDllSearchPaths();
}

16
shared/Trace.h Normal file
View File

@@ -0,0 +1,16 @@
#pragma once
#if defined(ATLTRACE)
#define TRACE ATLTRACE
#elif defined(_DEBUG)
// Yeah, sue me lol
#define TRACE(...) { \
LPWSTR __traceMsg = (LPWSTR)LocalAlloc(LPTR, 4096 * sizeof(WCHAR)); \
wsprintf(__traceMsg, L"%hs(%d): %hs: ", __FILE__, __LINE__, __FUNCTION__); \
wsprintf(__traceMsg + wcslen(__traceMsg), __VA_ARGS__); \
MessageBox(NULL, __traceMsg, L"Debug", MB_OK); \
LocalFree(__traceMsg); \
}
#else
#define TRACE(...)
#endif

20
shared/User.h Normal file
View File

@@ -0,0 +1,20 @@
#pragma once
#include <windows.h>
static inline BOOL IsUserAdmin() {
SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY;
PSID adminsSid;
BOOL result = FALSE;
if (!AllocateAndInitializeSid(&authority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &adminsSid)) {
return FALSE;
}
if (!CheckTokenMembership(NULL, adminsSid, &result)) {
result = FALSE;
}
FreeSid(adminsSid);
return result;
}

6
shared/Version.h Normal file
View File

@@ -0,0 +1,6 @@
#define VERSION_MAJOR 1
#define VERSION_MINOR 11
#define VERSION_PATCH 0
#define VERSION_BUILD 0
#define VERSION_STRING "1.11"

44
shared/VersionInfo.c Normal file
View File

@@ -0,0 +1,44 @@
#include "stdafx.h"
#include "VersionInfo.h"
static BOOL _loadedOwnVersion = FALSE;
static LPWSTR _version;
HRESULT GetOwnVersion(LPWSTR *version) {
if (!_loadedOwnVersion) {
_loadedOwnVersion = TRUE;
LPWSTR filename;
GetOwnFileName(&filename);
DWORD verHandle;
DWORD verInfoSize = GetFileVersionInfoSize(filename, &verHandle);
if (verInfoSize == 0) {
LocalFree(filename);
return HRESULT_FROM_WIN32(GetLastError());
}
LPVOID verInfo = LocalAlloc(LPTR, verInfoSize);
if (!GetFileVersionInfo(filename, verHandle, verInfoSize, verInfo)) {
LocalFree(filename);
LocalFree(verInfo);
return HRESULT_FROM_WIN32(GetLastError());
}
LocalFree(filename);
LPWSTR value;
UINT size;
if (!VerQueryValue(verInfo, L"\\StringFileInfo\\040904B0\\ProductVersion", (LPVOID *)&value, &size)) {
LocalFree(verInfo);
return HRESULT_FROM_WIN32(GetLastError());
}
_version = (LPWSTR)LocalAlloc(LPTR, (wcslen(value) + 1) * sizeof(WCHAR));
wcscpy(_version, value);
LocalFree(verInfo);
}
*version = _version;
return _version == NULL ? E_FAIL : S_OK;
}

79
shared/WMI.c Normal file
View File

@@ -0,0 +1,79 @@
#include "stdafx.h"
#include "WMI.h"
#include <wbemcli.h>
#pragma comment(lib, "wbemuuid.lib")
#ifdef __cplusplus
#define our_CLSID_WbemLocator CLSID_WbemLocator
#define our_IID_IWbemLocator IID_IWbemLocator
#define IWbemLocator_ConnectServer(obj, ...) obj->ConnectServer(__VA_ARGS__)
#define IWbemServices_ExecQuery(obj, ...) obj->ExecQuery(__VA_ARGS__)
#define IEnumWbemClassObject_Next(obj, ...) obj->Next(__VA_ARGS__)
#define IWbemClassObject_Get(obj, ...) obj->Get(__VA_ARGS__)
#define IWbemClassObject_Release(obj) obj->Release()
#define IEnumWbemClassObject_Release(obj) obj->Release()
#define IWbemServices_Release(obj) obj->Release()
#define IWbemLocator_Release(obj) obj->Release()
#else
#define our_CLSID_WbemLocator &CLSID_WbemLocator
#define our_IID_IWbemLocator &IID_IWbemLocator
#endif
HRESULT QueryWMIProperty(LPWSTR query, LPWSTR property, LPVARIANT value) {
IWbemLocator *locator = NULL;
IWbemServices *services = NULL;
IEnumWbemClassObject *enumerator = NULL;
IWbemClassObject *object = NULL;
HRESULT hr = CoCreateInstance(our_CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, our_IID_IWbemLocator, (void **)&locator);
if (!SUCCEEDED(hr)) {
goto end;
}
BSTR server = SysAllocString(L"ROOT\\CIMV2");
hr = IWbemLocator_ConnectServer(locator, server, NULL, NULL, NULL, 0, NULL, NULL, &services);
SysFreeString(server);
if (!SUCCEEDED(hr)) {
goto end;
}
hr = CoSetProxyBlanket((IUnknown *)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)) {
goto end;
}
BSTR wql = SysAllocString(L"WQL");
BSTR queryBstr = SysAllocString(query);
hr = IWbemServices_ExecQuery(services, wql, queryBstr, WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &enumerator);
SysFreeString(wql);
SysFreeString(queryBstr);
if (!SUCCEEDED(hr)) {
goto end;
}
ULONG uReturn = 0;
hr = IEnumWbemClassObject_Next(enumerator, WBEM_INFINITE, 1, &object, &uReturn);
if (!SUCCEEDED(hr)) {
goto end;
}
BSTR propBstr = SysAllocString(property);
hr = IWbemClassObject_Get(object, propBstr, 0, value, NULL, NULL);
SysFreeString(propBstr);
end:
if (object) {
IWbemClassObject_Release(object);
}
if (enumerator) {
IEnumWbemClassObject_Release(enumerator);
}
if (services) {
IWbemServices_Release(services);
}
if (locator) {
IWbemLocator_Release(locator);
}
return hr;
}

Some files were not shown because too many files have changed in this diff Show More