Add files via upload

This commit is contained in:
Useful Stuffs
2024-02-11 12:51:01 +01:00
committed by GitHub
commit eac708fbdc
96 changed files with 28373 additions and 0 deletions

39
LegacyUpdate/Compat.cpp Normal file
View File

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

6
LegacyUpdate/Compat.h Normal file
View File

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

18
LegacyUpdate/CplTasks.xml Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

17
LegacyUpdate/Makefile Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

26
LegacyUpdate/Resource.h Normal file
View File

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

177
LegacyUpdate/Utils.cpp Normal file
View File

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

15
LegacyUpdate/Utils.h Normal file
View File

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

17
LegacyUpdate/build.cmd Normal file
View File

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

38
LegacyUpdate/dlldata.c Normal file
View File

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

18
LegacyUpdate/dlldatax.c Normal file
View File

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

11
LegacyUpdate/dlldatax.h Normal file
View File

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

108
LegacyUpdate/dllmain.cpp Normal file
View File

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

10
LegacyUpdate/dllmain.h Normal file
View File

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

BIN
LegacyUpdate/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

5
LegacyUpdate/stdafx.cpp Normal file
View File

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

28
LegacyUpdate/stdafx.h Normal file
View File

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

11
LegacyUpdate/targetver.h Normal file
View File

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