subversion/libsvn_subr/opt.c subversion/libsvn_subr/sysinfo.c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable
In which cases would it help to detect system library versions? Security updates usually don't update this number (as that breaks on a multiple branch approach) and they are only serviced as part of system updates (and if not there is no way to install a specific version for testing). This will only provide pages of unneeded information in error reports when we have an accurate os version. (win64 +-doubles the number of dlls loaded per process and on win8 many system dlls are split up in smaller components) The exact version of things like openssl are much more interesting and you don't get these this way.(Reason: not a numeric version scheme and not a separate library if linked stayically) Bert Huijben (Cell phone) From: [email protected] Sent: 9-8-2012 10:28 To: [email protected] Subject: svn commit: r1371087 - in /subversion/trunk: build.conf subversion/libsvn_subr/opt.c subversion/libsvn_subr/sysinfo.c Author: brane Date: Thu Aug 9 08:27:53 2012 New Revision: 1371087 URL: http://svn.apache.org/viewvc?rev=3D1371087&view=3Drev Log: Display list of loaded DLLs with "svn --version --verbose" on Windows. * subversion/libsvn_subr/opt.c (svn_opt__print_version_info): Update output for loaded module list. * subversion/libsvn_subr/sysinfo.c [WIN32]: Import psapi.h Import apr_file_info.h. (win32_shared_libs, enum_loaded_modules, FNENUMPROCESSMODULES): New. (svn_sysinfo__loaded_libs) [WIN32]: Call win32_shared_libs. Modified: subversion/trunk/build.conf subversion/trunk/subversion/libsvn_subr/opt.c subversion/trunk/subversion/libsvn_subr/sysinfo.c Modified: subversion/trunk/build.conf URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=3D1371087= &r1=3D1371086&r2=3D1371087&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- subversion/trunk/build.conf (original) +++ subversion/trunk/build.conf Thu Aug 9 08:27:53 2012 @@ -296,7 +296,8 @@ type =3D lib install =3D fsmod-lib path =3D subversion/libsvn_subr libs =3D aprutil apriconv apr xml zlib apr_memcache sqlite magic -msvc-libs =3D kernel32.lib advapi32.lib shfolder.lib ole32.lib crypt32.lib= version.lib +msvc-libs =3D kernel32.lib advapi32.lib shfolder.lib ole32.lib + crypt32.lib version.lib psapi.lib msvc-export =3D=20 svn_auth.h svn_base64.h svn_cache_config.h svn_checksum.h svn_cmdl= ine.h svn_compat.h svn_config.h svn_ctype.h svn_dirent_uri.h svn_dso.h= =20 Modified: subversion/trunk/subversion/libsvn_subr/opt.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/o= pt.c?rev=3D1371087&r1=3D1371086&r2=3D1371087&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- subversion/trunk/subversion/libsvn_subr/opt.c (original) +++ subversion/trunk/subversion/libsvn_subr/opt.c Thu Aug 9 08:27:53 2012 @@ -1146,9 +1146,9 @@ svn_opt__print_version_info(const char * =20 if (dlibs) { - SVN_ERR(svn_cmdline_fputs(_("\nLoaded shared libraries:\n"), + SVN_ERR(svn_cmdline_fputs(_("* loaded shared libraries:\n"), stdout, pool)); - SVN_ERR(svn_cmdline_printf(pool, "\n%s\n", dlibs)); + SVN_ERR(svn_cmdline_fputs(dlibs, stdout, pool)); } } =20 Modified: subversion/trunk/subversion/libsvn_subr/sysinfo.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/s= ysinfo.c?rev=3D1371087&r1=3D1371086&r2=3D1371087&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- subversion/trunk/subversion/libsvn_subr/sysinfo.c (original) +++ subversion/trunk/subversion/libsvn_subr/sysinfo.c Thu Aug 9 08:27:53 2= 012 @@ -25,7 +25,9 @@ =0C #ifdef WIN32 #define WIN32_LEAN_AND_MEAN +#define PSAPI_VERSION 1 #include <windows.h> +#include <psapi.h> #endif =20 #define APR_WANT_STRFUNC @@ -33,6 +35,7 @@ =20 #include <apr_lib.h> #include <apr_pools.h> +#include <apr_file_info.h> =20 #include "svn_ctype.h" #include "svn_error.h" @@ -52,6 +55,7 @@ static const char* canonical_host_from_u #ifdef WIN32 static const char * win32_canonical_host(apr_pool_t *pool); static const char * win32_release_name(apr_pool_t *pool); +static const char * win32_shared_libs(apr_pool_t *pool); #endif /* WIN32 */ =20 =20 @@ -82,7 +86,11 @@ svn_sysinfo__release_name(apr_pool_t *po const char * svn_sysinfo__loaded_libs(apr_pool_t *pool) { +#ifdef WIN32 + return win32_shared_libs(pool); +#else return NULL; +#endif } =20 =0C @@ -140,6 +148,7 @@ canonical_host_from_uname(apr_pool_t *po =0C #ifdef WIN32 typedef DWORD (WINAPI *FNGETNATIVESYSTEMINFO)(LPSYSTEM_INFO); +typedef BOOL (WINAPI *FNENUMPROCESSMODULES) (HANDLE, HMODULE, DWORD, LPDWO= RD); =20 /* Get sysstem and version info, and try to tell the difference between the native system type and the runtime environment of the @@ -349,4 +358,61 @@ win32_release_name(apr_pool_t *pool) (unsigned int)osinfo.dwMinorVersion, (unsigned int)osinfo.dwBuildNumber); } + + +/* Get a list of handles of shared libs loaded by the current + process. Returns a NULL-terminated array alocated from POOL. */ +static HMODULE * +enum_loaded_modules(apr_pool_t *pool) +{ + HANDLE current =3D GetCurrentProcess(); + HMODULE dummy[1]; + HMODULE *handles; + DWORD size; + + if (!EnumProcessModules(current, dummy, sizeof(dummy), &size)) + return NULL; + + handles =3D apr_palloc(pool, size + sizeof *handles); + if (!EnumProcessModules(current, handles, size, &size)) + return NULL; + handles[size / sizeof *handles] =3D NULL; + return handles; +} + + +/* List the shared libraries loaded by the current process. */ +const char * +win32_shared_libs(apr_pool_t *pool) +{ + wchar_t buffer[MAX_PATH + 1]; + HMODULE *handles =3D enum_loaded_modules(pool); + char *libinfo =3D ""; + HMODULE *module; + + for (module =3D handles; module && *module; ++module) + { + const char *filename; + if (GetModuleFileNameW(*module, buffer, MAX_PATH)) + { + buffer[MAX_PATH] =3D 0; + filename =3D wcs_to_utf8(buffer, pool); + if (filename) + { + char *truename; + if (0 =3D=3D apr_filepath_merge(&truename, "", filename, + APR_FILEPATH_NATIVE + | APR_FILEPATH_TRUENAME, + pool)) + filename =3D truename; + libinfo =3D apr_pstrcat(pool, libinfo, " - ", + filename, "\n", NULL); + } + } + } + + if (*libinfo) + return libinfo; + return NULL; +} #endif /* WIN32 */
