mspaintmsi / superUser

A simple and lightweight utility for starting any process with TrustedInstaller privileges.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why the msvcrt{32,64}.lib binary?

tanzislam opened this issue · comments

Just curious, what does this definition and the bundled msvcrt64.lib accomplish? (Was wondering if it could be made to use the definition included in MSVC.)

The libraries bundled with Visual Studio are meant to (dynamically) link with the newest Visual C++ Redistributables, which is not needed in our case and introduces incompatibility problems. The lib files in the project have been generated from the default system "msvcrt.dll" available and mostly unchanged from Windows XP which means that there is no need to link against heavy redistributables (MSVCP140 dll - ~626 KB, compare that to the current release size of superUser) thus increasing portability and drastically decreasing the size. (If we were to statically link MSVCP140 to not have to redistribute it, the resulting file would weigh hundreds of kilobytes which is just silly)

That definition is required to use older definitions for the standard library stdin, stdout and stderr file descriptors that the regular msvcrt needs.
(Basically, VS switches from __iob_func to __acrt_iob_func when you specify you don't want any standard libraries, but it still uses UCRT headers which are not compatible with the "normal" msvcrt because they do not have the "legacy" definitions. We also need to specify no inlining for stdio, which is done through a preprocessor directive to keep Visual Studio from referencing UCRT anywhere at all)

If this ever becomes an actual compatibility problem (as Microsoft has been actively trying to convince people for a couple of years) I'll have no other choice than to link it statically with the C run-time, but there is nearly zero chance that it will happen anytime soon, unless Microsoft wants to, among others, kill off every program compiled with the MinGW toolchain.

Understood, thanks. I managed to build it in Debug configuration with the libraries bundled with my MSVC installation, so this isn't a problem for people who want to build it themselves for their own use.