Reduce size of launcher by using WUErrors table from main dll

This commit is contained in:
Adam Demasi 2024-09-07 15:06:06 +09:30
parent 151ee33d82
commit 9934aaf6aa
No known key found for this signature in database
GPG key ID: 5D3B26B3D58C7D91
4 changed files with 30 additions and 17 deletions

View file

@ -1,8 +1,14 @@
; 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,13 +1,12 @@
FILES = \
$(wildcard *.c) \
../shared/GetPidForName.c \
../shared/HResult.c \
../shared/Registry.c \
../shared/WUErrors.c \
../shared/VersionInfo.c
RCFILES = resource.rc
DEFFILES = ../LegacyUpdate/LegacyUpdate.def
ARCH ?= i686
ARCH ?= 32
ifeq ($(ARCH),64)
TAG = x86_64
@ -22,9 +21,11 @@ DEF = $(patsubst %.dll,%.def,$(BIN))
STATIC = $(patsubst %.dll,%.a,$(BIN))
OBJ = $(foreach file,$(FILES),obj/$(notdir $(basename $(file)).$(TAG).o))
RES = $(foreach file,$(RCFILES),obj/$(notdir $(basename $(file)).$(TAG).res))
DEF = $(foreach file,$(DEFFILES),obj/lib$(notdir $(basename $(file)).$(TAG).a))
CC = $(PREFIX)g++
RC = $(PREFIX)windres
DLLTOOL = $(PREFIX)dlltool
override DEBUG := $(or $(DEBUG),1)
@ -63,6 +64,7 @@ LDFLAGS = \
-Wl,--output-def,$(DEF) \
-Wl,--out-implib,$(STATIC) \
-Wl,--strip-all \
-Lobj \
-lmsvcrt \
-lgcc \
-lpsapi \
@ -73,7 +75,8 @@ LDFLAGS = \
-ladvapi32 \
-lcomctl32 \
-lshell32 \
-lversion
-lversion \
-lLegacyUpdate.$(TAG)
RCFLAGS = \
-O coff
@ -87,7 +90,7 @@ else
RCFLAGS += -F pe-i386
endif
all: before-all $(BIN)
all: before-all $(DEF) $(BIN)
ifeq ($(SIGN),1)
../build/sign.sh $(BIN)
endif
@ -116,6 +119,9 @@ obj/%.$(TAG).o: ../include/nsis/%.c
obj/%.$(TAG).res: %.rc
$(RC) $< $(RCFLAGS) -o $@
obj/lib%.$(TAG).a: ../LegacyUpdate/%.def
$(DLLTOOL) -v -d $< -l $@ -D $(notdir $(basename $<).dll)
clean:
rm -rf obj

View file

@ -1,8 +1,9 @@
#include "stdafx.h"
#include <windows.h>
#include "HResult.h"
#include "WUErrors.h"
#include <windows.h>
LPWSTR GetMessageForHresult(HRESULT hr) {
STDAPI_(LPWSTR) GetMessageForHresult(HRESULT hr) {
LPWSTR message;
for (int i = 0; WUErrorMessages[i].hr != 0; i++) {
if (WUErrorMessages[i].hr == hr) {

View file

@ -2,4 +2,4 @@
#include <windows.h>
LPWSTR GetMessageForHresult(HRESULT hr);
STDAPI_(LPWSTR) GetMessageForHresult(HRESULT hr);