ntdll: Retrieve Wine version strings through NtQuerySystemInformation().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-04-05 13:05:44 +02:00
parent beff5c56cd
commit 985bd97c2b
5 changed files with 63 additions and 50 deletions

View file

@ -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)

View file

@ -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);
}
}

View file

@ -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 );

View file

@ -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 );

View file

@ -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 {