2024-09-06 06:10:19 -04:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
#include "MsgBox.h"
|
2024-09-17 05:19:57 -04:00
|
|
|
#include "RegisterServer.h"
|
2024-10-23 10:50:42 -04:00
|
|
|
#include "Startup.h"
|
2024-09-06 06:10:19 -04:00
|
|
|
|
|
|
|
HINSTANCE g_hInstance;
|
|
|
|
|
2024-09-14 13:10:26 -04:00
|
|
|
extern void LaunchUpdateSite(int argc, LPWSTR *argv, int nCmdShow);
|
2024-12-11 01:17:29 -05:00
|
|
|
extern void LaunchOptions(int nCmdShow);
|
2024-09-06 06:10:19 -04:00
|
|
|
extern void RunOnce();
|
|
|
|
|
2024-12-11 01:17:29 -05:00
|
|
|
typedef enum Action {
|
|
|
|
ActionLaunch,
|
|
|
|
ActionOptions,
|
|
|
|
ActionRunOnce,
|
|
|
|
ActionRegServer,
|
|
|
|
ActionUnregServer
|
|
|
|
} Action;
|
|
|
|
|
|
|
|
static const LPWSTR actions[] = {
|
|
|
|
L"/launch",
|
|
|
|
L"/options",
|
|
|
|
L"/runonce",
|
|
|
|
L"/regserver",
|
|
|
|
L"/unregserver",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2024-09-11 04:28:57 -04:00
|
|
|
EXTERN_C __declspec(dllexport)
|
|
|
|
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) {
|
2024-09-06 06:10:19 -04:00
|
|
|
g_hInstance = hInstance;
|
2024-10-23 10:50:42 -04:00
|
|
|
Startup();
|
2024-09-06 06:10:19 -04:00
|
|
|
|
|
|
|
int argc;
|
2024-09-14 13:10:26 -04:00
|
|
|
LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
2024-09-06 06:10:19 -04:00
|
|
|
|
2024-12-11 01:17:29 -05:00
|
|
|
LPWSTR actionFlag = L"/launch";
|
2024-09-06 06:10:19 -04:00
|
|
|
if (argc > 1) {
|
2024-12-11 01:17:29 -05:00
|
|
|
actionFlag = argv[1];
|
2024-09-06 06:10:19 -04:00
|
|
|
}
|
|
|
|
|
2024-09-14 13:10:26 -04:00
|
|
|
// All remaining args past the action
|
|
|
|
LPWSTR *flags = {0};
|
|
|
|
int flagsCount = 0;
|
|
|
|
if (argc > 2) {
|
|
|
|
flags = &argv[2];
|
|
|
|
flagsCount = argc - 2;
|
|
|
|
}
|
|
|
|
|
2024-12-11 01:17:29 -05:00
|
|
|
Action action = -1;
|
|
|
|
|
|
|
|
for (int i = 0; actions[i] != NULL; i++) {
|
|
|
|
if (wcscmp(actionFlag, actions[i]) == 0) {
|
|
|
|
action = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case ActionLaunch:
|
2024-09-14 13:10:26 -04:00
|
|
|
LaunchUpdateSite(flagsCount, flags, nCmdShow);
|
2024-12-11 01:17:29 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ActionOptions:
|
|
|
|
LaunchOptions(nCmdShow);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ActionRunOnce:
|
2024-09-06 06:10:19 -04:00
|
|
|
RunOnce();
|
2024-12-11 01:17:29 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ActionRegServer:
|
|
|
|
case ActionUnregServer: {
|
|
|
|
BOOL state = action == ActionRegServer;
|
2024-09-29 04:52:20 -04:00
|
|
|
HWND hwnd = flagsCount > 0 ? (HWND)(intptr_t)wcstol(flags[0], NULL, 10) : 0;
|
2024-09-28 13:27:48 -04:00
|
|
|
RegisterServer(hwnd, state, FALSE);
|
2024-12-11 01:17:29 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
2024-09-17 05:19:57 -04:00
|
|
|
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"
|
2024-12-11 01:17:29 -05:00
|
|
|
L"/options\n"
|
|
|
|
L" Open the Windows Update Options control panel\n"
|
|
|
|
L"\n"
|
2024-09-17 05:19:57 -04:00
|
|
|
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);
|
2024-09-14 13:10:26 -04:00
|
|
|
PostQuitMessage(1);
|
2024-12-11 01:17:29 -05:00
|
|
|
break;
|
|
|
|
}
|
2024-09-14 13:10:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MSG msg;
|
|
|
|
while (GetMessage(&msg, NULL, 0, 0) == 1) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
|
|
|
|
switch (msg.message) {
|
|
|
|
case WM_QUIT:
|
|
|
|
case WM_DESTROY:
|
|
|
|
break;
|
|
|
|
}
|
2024-09-06 06:10:19 -04:00
|
|
|
}
|
|
|
|
|
2024-09-14 13:10:26 -04:00
|
|
|
ExitProcess(msg.wParam);
|
|
|
|
return msg.wParam;
|
2024-09-06 06:10:19 -04:00
|
|
|
}
|