Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make portable ZIP more portable by bundling MSVC DLLs #11497

Open
yan12125 opened this issue Nov 26, 2024 · 5 comments
Open

Make portable ZIP more portable by bundling MSVC DLLs #11497

yan12125 opened this issue Nov 26, 2024 · 5 comments

Comments

@yan12125
Copy link
Contributor

Summary

As shown in #10925, out-dated MSVC redistributable packages prevent KeePassXC from being started. In some cases, installing newer MSVC redist is not an option. How about bundling necessary DLLs in portable ZIP archives, so that KeePassXC can work out-of-box (almost) everywhere?

Examples

I believe bundling individual DLLs in portable ZIP is allowed by the license. Such an approach is mentioned on https://learn.microsoft.com/en-us/cpp/windows/redistributing-visual-cpp-files?view=msvc-170 (not recommended, though):

It's also possible to directly install the Redistributable DLLs in the application local folder. The application local folder is the folder that contains your executable application file. For servicing reasons, we don't recommend you use this installation location.

Technically, relevant DLLs can be copied from Visual Studio as per https://learn.microsoft.com/en-us/cpp/windows/determining-which-dlls-to-redistribute?view=msvc-170:

The individual Redistributable DLLs are also included in your installation of Visual Studio. By default, they're installed in the Visual the %VCToolsRedistDir%[architecture]\Microsoft.[toolset].[library] folders, where [architecture] represents the target architecture, [toolset] represents the toolset version, and [library] represents the library.

It seems 4 files are needed: MSVCP140.dll, MSVCP140_1.dll, VCRUNTIME140.dll, VCRUNTIME140_1.dll

ldd output for KeePassXC.exe
PS C:\> ldd.exe 'C:\Program Files\KeePassXC\KeePassXC.exe' | sort.exe | grep -v /KeePassXC/
        ADVAPI32.dll => /c/Windows/System32/ADVAPI32.dll (0x7ff99e6d0000)
        bcrypt.dll => /c/Windows/System32/bcrypt.dll (0x7ff99d830000)
        cfgmgr32.dll => /c/Windows/System32/cfgmgr32.dll (0x7ff99db10000)
        combase.dll => /c/Windows/System32/combase.dll (0x7ff99e7a0000)
        CRYPT32.dll => /c/Windows/System32/CRYPT32.dll (0x7ff99d1e0000)
        CRYPTBASE.DLL => /c/Windows/SYSTEM32/CRYPTBASE.DLL (0x7ff99cab0000)
        d3d11.dll => /c/Windows/SYSTEM32/d3d11.dll (0x7ff998110000)
        DEVOBJ.dll => /c/Windows/SYSTEM32/DEVOBJ.dll (0x7ff99cea0000)
        DNSAPI.dll => /c/Windows/SYSTEM32/DNSAPI.dll (0x7ff99c5c0000)
        dwmapi.dll => /c/Windows/SYSTEM32/dwmapi.dll (0x7ff99aea0000)
        dxgi.dll => /c/Windows/SYSTEM32/dxgi.dll (0x7ff99ba70000)
        GDI32.dll => /c/Windows/System32/GDI32.dll (0x7ff99f390000)
        gdi32full.dll => /c/Windows/System32/gdi32full.dll (0x7ff99d340000)
        HID.DLL => /c/Windows/SYSTEM32/HID.DLL (0x7ff99ba30000)
        IPHLPAPI.DLL => /c/Windows/SYSTEM32/IPHLPAPI.DLL (0x7ff99c580000)
        KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ff99e580000)
        KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ff99d460000)
        MPR.dll => /c/Windows/SYSTEM32/MPR.dll (0x7ff98ca40000)
        msvcp_win.dll => /c/Windows/System32/msvcp_win.dll (0x7ff99d790000)
        MSVCP140.dll => /c/Windows/SYSTEM32/MSVCP140.dll (0x7ff996ba0000)
        MSVCP140_1.dll => /c/Windows/SYSTEM32/MSVCP140_1.dll (0x7ff9993a0000)
        msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ff99db60000)
        NETAPI32.dll => /c/Windows/SYSTEM32/NETAPI32.dll (0x7ff98d040000)
        NETUTILS.DLL => /c/Windows/SYSTEM32/NETUTILS.DLL (0x7ff99c6e0000)
        ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ff99fb30000)
        ntmarta.dll => /c/Windows/SYSTEM32/ntmarta.dll (0x7ff99c410000)
        ole32.dll => /c/Windows/System32/ole32.dll (0x7ff99f600000)
        OLEAUT32.dll => /c/Windows/System32/OLEAUT32.dll (0x7ff99ed20000)
        RPCRT4.dll => /c/Windows/System32/RPCRT4.dll (0x7ff99f790000)
        sechost.dll => /c/Windows/System32/sechost.dll (0x7ff99f560000)
        SETUPAPI.dll => /c/Windows/System32/SETUPAPI.dll (0x7ff99ee70000)
        shcore.dll => /c/Windows/System32/shcore.dll (0x7ff99f2e0000)
        SHELL32.dll => /c/Windows/System32/SHELL32.dll (0x7ff99dc60000)
        SRVCLI.DLL => /c/Windows/SYSTEM32/SRVCLI.DLL (0x7ff9929e0000)
        ucrtbase.dll => /c/Windows/System32/ucrtbase.dll (0x7ff99d910000)
        USER32.dll => /c/Windows/System32/USER32.dll (0x7ff99f3c0000)
        USERENV.dll => /c/Windows/SYSTEM32/USERENV.dll (0x7ff99d090000)
        UxTheme.dll => /c/Windows/SYSTEM32/UxTheme.dll (0x7ff99ab90000)
        VCRUNTIME140.dll => /c/Windows/SYSTEM32/VCRUNTIME140.dll (0x7ff99a100000)
        VCRUNTIME140_1.dll => /c/Windows/SYSTEM32/VCRUNTIME140_1.dll (0x7ff99a2f0000)
        VERSION.dll => /c/Windows/SYSTEM32/VERSION.dll (0x7ff98dce0000)
        win32u.dll => /c/Windows/System32/win32u.dll (0x7ff99d760000)
        WINMM.dll => /c/Windows/SYSTEM32/WINMM.dll (0x7ff98b1c0000)
        WinSCard.dll => /c/Windows/SYSTEM32/WinSCard.dll (0x7ff98dfc0000)
        WS2_32.dll => /c/Windows/System32/WS2_32.dll (0x7ff99edf0000)
        WTSAPI32.dll => /c/Windows/SYSTEM32/WTSAPI32.dll (0x7ff99a380000)

Context

I'd like to use KeePassXC on computers where I don't have admin rights.

@droidmonkey
Copy link
Member

droidmonkey commented Nov 26, 2024

Many more than that are needed, unfortunately. The WinRT dlls are also required. I believe those are loaded at runtime which is why they don't appear in the ldd report.

@yan12125
Copy link
Contributor Author

If WinRT DLLs are loaded at runtime, I guess they are not needed until relevant functionality (Windows Hello?) is used. If so, bundling those 4 files can be a good start.

I have been using portable ZIP + those 4 DLLs (copied manually from another PC) for several weeks. Basic functionalities are fine - entry operations, autotype, browser integration. I cannot setup Windows Hello on that machine for testing, though.

@droidmonkey
Copy link
Member

droidmonkey commented Nov 26, 2024

No, they are loaded at startup. You can see what dependencies are actually attached/loaded by using a tool like Process Explorer. https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer

@droidmonkey
Copy link
Member

Also, if you are using the legacywindows portable then WinRT is not a part of that build.

@yan12125
Copy link
Contributor Author

Yeah, I see CryptoWinRT.dll in procexp. Looks like it's a built-in DLL in Windows, as install.wim in Windows 10 ISO contains that file, so maybe it's not needed to bundle them.

On the other hand, MSVCP140.dll, MSVCP140_1.dll, VCRUNTIME140.dll, VCRUNTIME140_1.dll do not appear in Windows 10 ISO. I didn't find them on a freshly-installed Windows 10 VM, either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants