Implemented loading compatibility settings (custom version information) for applications

svn path=/trunk/; revision=5719
This commit is contained in:
Thomas Bluemel 2003-08-21 12:51:01 +00:00
parent cbbd90f4f1
commit 45e8d98b48
2 changed files with 174 additions and 1 deletions

View file

@ -9,4 +9,30 @@ HKCU,"Control Panel\Appearance",,0x00000012
HKCU,"Environment",,0x00000012
; application compatibility settings for Windows 95
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WIN95","MajorVersion",0x00010001,0x00000004
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WIN95","MinorVersion",0x00010001,0x0000000A
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WIN95","BuildNumber",0x00010001,0x000003B6
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WIN95","PlatformId",0x00010001,0x00000001
; application compatibility settings for Windows 98/ME
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WIN98","MajorVersion",0x00010001,0x00000004
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WIN98","MinorVersion",0x00010001,0x00000000
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WIN98","BuildNumber",0x00010001,0x000008AE
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WIN98","PlatformId",0x00010001,0x00000001
; application compatibility settings for Windows NT 4 Service Pack 5
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\NT4SP5","MajorVersion",0x00010001,0x00000004
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\NT4SP5","MinorVersion",0x00010001,0x00000000
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\NT4SP5","BuildNumber",0x00010001,0x00000565
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\NT4SP5","PlatformId",0x00010001,0x00000002
; application compatibility settings for Windows 2000
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WIN2000","MajorVersion",0x00010001,0x00000005
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WIN2000","MinorVersion",0x00010001,0x00000000
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WIN2000","BuildNumber",0x00010001,0x00000893
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WIN2000","PlatformId",0x00010001,0x00000002
; application compatibility settings for Windows XP
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WINXP","MajorVersion",0x00010001,0x00000005
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WINXP","MinorVersion",0x00010001,0x00000001
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WINXP","BuildNumber",0x00010001,0x00000A28
HKCU,"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\WINXP","PlatformId",0x00010001,0x00000002
; EOF

View file

@ -1,4 +1,4 @@
/* $Id: startup.c,v 1.53 2003/08/15 10:17:09 hbirr Exp $
/* $Id: startup.c,v 1.54 2003/08/21 12:49:23 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -38,6 +38,150 @@ static RTL_BITMAP TlsBitMap;
ULONG NtGlobalFlag = 0;
#define VALUE_BUFFER_SIZE 256
BOOL FASTCALL
ReadCompatibilitySetting(HANDLE Key, LPWSTR Value, PKEY_VALUE_PARTIAL_INFORMATION ValueInfo, DWORD *Buffer)
{
UNICODE_STRING ValueName;
NTSTATUS Status;
ULONG Length;
RtlInitUnicodeString(&ValueName, Value);
Status = NtQueryValueKey(Key,
&ValueName,
KeyValuePartialInformation,
ValueInfo,
VALUE_BUFFER_SIZE,
&Length);
if (!NT_SUCCESS(Status) || (ValueInfo->Type != REG_DWORD))
{
RtlFreeUnicodeString(&ValueName);
return FALSE;
}
RtlCopyMemory(Buffer, &ValueInfo->Data[0], sizeof(DWORD));
RtlFreeUnicodeString(&ValueName);
return TRUE;
}
BOOL FASTCALL
LoadCompatibilitySettings(PPEB Peb)
{
NTSTATUS Status;
HANDLE UserKey = NULL;
HANDLE KeyHandle;
HANDLE SubKeyHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
UNICODE_STRING ValueName;
UCHAR ValueBuffer[VALUE_BUFFER_SIZE];
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
ULONG Length;
DWORD MajorVersion, MinorVersion, BuildNumber, PlatformId,
SPMajorVersion, SPMinorVersion= 0;
if(Peb->ProcessParameters &&
(Peb->ProcessParameters->ImagePathName.Length > 0))
{
Status = RtlOpenCurrentUser(KEY_READ,
&UserKey);
if (!NT_SUCCESS(Status))
{
return FALSE;
}
RtlInitUnicodeStringFromLiteral(&KeyName,
L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
UserKey,
NULL);
Status = NtOpenKey(&KeyHandle,
KEY_QUERY_VALUE,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
if (UserKey) NtClose(UserKey);
return FALSE;
}
/* query version name for application */
ValueInfo = (PKEY_VALUE_PARTIAL_INFORMATION)ValueBuffer;
Status = NtQueryValueKey(KeyHandle,
&Peb->ProcessParameters->ImagePathName,
KeyValuePartialInformation,
ValueBuffer,
VALUE_BUFFER_SIZE,
&Length);
if (!NT_SUCCESS(Status) || (ValueInfo->Type != REG_SZ))
{
NtClose(KeyHandle);
if (UserKey) NtClose(UserKey);
return FALSE;
}
ValueName.Length = ValueInfo->DataLength;
ValueName.MaximumLength = ValueInfo->DataLength;
ValueName.Buffer = (PWSTR)ValueInfo->Data;
/* load version info */
InitializeObjectAttributes(&ObjectAttributes,
&ValueName,
OBJ_CASE_INSENSITIVE,
KeyHandle,
NULL);
Status = NtOpenKey(&SubKeyHandle,
KEY_QUERY_VALUE,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
NtClose(KeyHandle);
if (UserKey) NtClose(UserKey);
return FALSE;
}
DPRINT("Loading version information for: %wZ\n", &ValueName);
/* read settings from registry */
if(!ReadCompatibilitySetting(SubKeyHandle, L"MajorVersion", ValueInfo, &MajorVersion))
goto finish;
if(!ReadCompatibilitySetting(SubKeyHandle, L"MinorVersion", ValueInfo, &MinorVersion))
goto finish;
if(!ReadCompatibilitySetting(SubKeyHandle, L"BuildNumber", ValueInfo, &BuildNumber))
goto finish;
if(!ReadCompatibilitySetting(SubKeyHandle, L"PlatformId", ValueInfo, &PlatformId))
goto finish;
/* now assign the settings */
Peb->OSMajorVersion = (ULONG)MajorVersion;
Peb->OSMinorVersion = (ULONG)MinorVersion;
Peb->OSBuildNumber = (USHORT)BuildNumber;
Peb->OSPlatformId = (ULONG)PlatformId;
/* optional service pack version numbers */
if(ReadCompatibilitySetting(SubKeyHandle, L"SPMajorVersion", ValueInfo, &SPMajorVersion))
Peb->SPMajorVersion = (UCHAR)SPMajorVersion;
if(ReadCompatibilitySetting(SubKeyHandle, L"SPMinorVersion", ValueInfo, &SPMinorVersion))
Peb->SPMinorVersion = (UCHAR)SPMinorVersion;
finish:
/* we're finished */
NtClose(SubKeyHandle);
NtClose(KeyHandle);
if (UserKey) NtClose(UserKey);
return TRUE;
}
return FALSE;
}
/* FUNCTIONS *****************************************************************/
@ -173,6 +317,9 @@ __true_LdrInitializeThunk (ULONG Unknown1,
InitializeListHead(&Peb->Ldr->InMemoryOrderModuleList);
InitializeListHead(&Peb->Ldr->InInitializationOrderModuleList);
/* Load compatibility settings */
LoadCompatibilitySettings(Peb);
/* build full ntdll path */
wcscpy (FullNtDllPath, SharedUserData->NtSystemRoot);
wcscat (FullNtDllPath, L"\\system32\\ntdll.dll");