Module: wine Branch: master Commit: 985bd97c2bb0a161f9cae370ae1893f2b0554ffd URL: https://source.winehq.org/git/wine.git/?a=commit;h=985bd97c2bb0a161f9cae370a...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Apr 5 13:05:44 2021 +0200
ntdll: Retrieve Wine version strings through NtQuerySystemInformation().
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/ntdll.spec | 6 +++--- dlls/ntdll/unix/loader.c | 48 ++---------------------------------------------- dlls/ntdll/unix/system.c | 18 ++++++++++++++++++ dlls/ntdll/version.c | 37 +++++++++++++++++++++++++++++++++++++ include/winternl.h | 4 +++- 5 files changed, 63 insertions(+), 50 deletions(-)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index c8622ba21f4..cbb45f50dff 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1623,9 +1623,9 @@ @ cdecl -syscall __wine_locked_recvmsg(long ptr long)
# Version -@ cdecl -syscall wine_get_version() -@ cdecl -syscall wine_get_build_id() -@ cdecl -syscall wine_get_host_version(ptr ptr) +@ cdecl wine_get_version() +@ cdecl wine_get_build_id() +@ cdecl wine_get_host_version(ptr ptr)
# Filesystem @ cdecl -syscall wine_nt_to_unix_file_name(ptr ptr ptr long) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 9c6d58d94ee..c13055a5549 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -51,9 +51,6 @@ #ifdef HAVE_SYS_RESOURCE_H # include <sys/resource.h> #endif -#ifdef HAVE_SYS_UTSNAME_H -#include <sys/utsname.h> -#endif #ifdef HAVE_SYS_WAIT_H #include <sys/wait.h> #endif @@ -335,48 +332,6 @@ static void init_paths( char *argv[] ) }
-/********************************************************************* - * wine_get_version - */ -const char * CDECL wine_get_version(void) -{ - return PACKAGE_VERSION; -} - - -/********************************************************************* - * wine_get_build_id - */ -const char * CDECL wine_get_build_id(void) -{ - extern const char wine_build[]; - return wine_build; -} - - -/********************************************************************* - * wine_get_host_version - */ -void CDECL wine_get_host_version( const char **sysname, const char **release ) -{ -#ifdef HAVE_SYS_UTSNAME_H - static struct utsname buf; - static BOOL init_done; - - if (!init_done) - { - uname( &buf ); - init_done = TRUE; - } - if (sysname) *sysname = buf.sysname; - if (release) *release = buf.release; -#else - if (sysname) *sysname = ""; - if (release) *release = ""; -#endif -} - - static void preloader_exec( char **argv ) { if (use_preloader) @@ -2107,7 +2062,8 @@ static void check_command_line( int argc, char *argv[] ) } if (!strcmp( argv[1], "--version" )) { - printf( "%s\n", wine_get_build_id() ); + extern const char wine_build[]; + printf( "%s\n", wine_build ); exit(0); } } diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index 56f31e4147f..2b316095f4a 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -40,6 +40,9 @@ #ifdef HAVE_SYS_SYSCTL_H # include <sys/sysctl.h> #endif +#ifdef HAVE_SYS_UTSNAME_H +# include <sys/utsname.h> +#endif #ifdef HAVE_MACHINE_CPU_H # include <machine/cpu.h> #endif @@ -2809,6 +2812,21 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class, ret = STATUS_SUCCESS; break;
+ /* Wine extensions */ + + case SystemWineVersionInformation: + { + static const char version[] = PACKAGE_VERSION; + extern const char wine_build[]; + struct utsname buf; + + uname( &buf ); + len = strlen(version) + strlen(wine_build) + strlen(buf.sysname) + strlen(buf.release) + 4; + snprintf( info, size, "%s%c%s%c%s%c%s", version, 0, wine_build, 0, buf.sysname, 0, buf.release ); + if (size < len) ret = STATUS_INFO_LENGTH_MISMATCH; + break; + } + default: FIXME( "(0x%08x,%p,0x%08x,%p) stub\n", class, info, size, ret_size );
diff --git a/dlls/ntdll/version.c b/dlls/ntdll/version.c index 740d8403f5e..cde340cca1d 100644 --- a/dlls/ntdll/version.c +++ b/dlls/ntdll/version.c @@ -207,6 +207,41 @@ static const struct { WCHAR name[12]; WINDOWS_VERSION ver; } version_names[] = /* initialized to null so that we crash if we try to retrieve the version too early at startup */ static const RTL_OSVERSIONINFOEXW *current_version;
+static char wine_version[256]; + +/********************************************************************* + * wine_get_version + */ +const char * CDECL wine_get_version(void) +{ + return wine_version; +} + + +/********************************************************************* + * wine_get_build_id + */ +const char * CDECL wine_get_build_id(void) +{ + const char *p = wine_version; + p += strlen(p) + 1; /* skip version */ + return p; +} + + +/********************************************************************* + * wine_get_host_version + */ +void CDECL wine_get_host_version( const char **sysname, const char **release ) +{ + const char *p = wine_version; + p += strlen(p) + 1; /* skip version */ + p += strlen(p) + 1; /* skip build id */ + if (sysname) *sysname = p; + p += strlen(p) + 1; + if (release) *release = p; +} +
/********************************************************************** * get_nt_registry_version @@ -430,6 +465,8 @@ void version_init(void) const WCHAR *p, *appname = NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer; WCHAR appversion[MAX_PATH+20];
+ NtQuerySystemInformation( SystemWineVersionInformation, wine_version, sizeof(wine_version), NULL ); + current_version = &VersionData[WIN7];
RtlOpenCurrentUser( KEY_ALL_ACCESS, &root ); diff --git a/include/winternl.h b/include/winternl.h index 9e6bde25569..298ebbc2d36 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -1693,7 +1693,9 @@ typedef enum _SYSTEM_INFORMATION_CLASS { SystemDifRemovePluginVerificationOnDriver = 220, SystemShadowStackInformation = 221, SystemBuildVersionInformation = 222, - SystemInformationClassMax +#ifdef __WINESRC__ + SystemWineVersionInformation = 1000, +#endif } SYSTEM_INFORMATION_CLASS, *PSYSTEM_INFORMATION_CLASS;
typedef enum _THREADINFOCLASS {