mirror of
https://github.com/reactos/reactos.git
synced 2024-11-02 12:53:33 +00:00
1. made the PEB structure match xp's layout
2. fixed GetVersionEx() svn path=/trunk/; revision=13639
This commit is contained in:
parent
c8ad5d3ade
commit
5239de8ad5
|
@ -105,8 +105,8 @@ typedef struct _PEB
|
||||||
UCHAR InheritedAddressSpace; /* 00h */
|
UCHAR InheritedAddressSpace; /* 00h */
|
||||||
UCHAR ReadImageFileExecOptions; /* 01h */
|
UCHAR ReadImageFileExecOptions; /* 01h */
|
||||||
UCHAR BeingDebugged; /* 02h */
|
UCHAR BeingDebugged; /* 02h */
|
||||||
UCHAR Spare; /* 03h */
|
BOOLEAN SpareBool; /* 03h */
|
||||||
PVOID Mutant; /* 04h */
|
HANDLE Mutant; /* 04h */
|
||||||
PVOID ImageBaseAddress; /* 08h */
|
PVOID ImageBaseAddress; /* 08h */
|
||||||
PPEB_LDR_DATA Ldr; /* 0Ch */
|
PPEB_LDR_DATA Ldr; /* 0Ch */
|
||||||
PRTL_USER_PROCESS_PARAMETERS ProcessParameters; /* 10h */
|
PRTL_USER_PROCESS_PARAMETERS ProcessParameters; /* 10h */
|
||||||
|
@ -131,7 +131,6 @@ typedef struct _PEB
|
||||||
PVOID UnicodeCaseTableData; /* 60h */
|
PVOID UnicodeCaseTableData; /* 60h */
|
||||||
ULONG NumberOfProcessors; /* 64h */
|
ULONG NumberOfProcessors; /* 64h */
|
||||||
ULONG NtGlobalFlag; /* 68h */
|
ULONG NtGlobalFlag; /* 68h */
|
||||||
UCHAR Spare2[0x4]; /* 6Ch */
|
|
||||||
LARGE_INTEGER CriticalSectionTimeout; /* 70h */
|
LARGE_INTEGER CriticalSectionTimeout; /* 70h */
|
||||||
ULONG HeapSegmentReserve; /* 78h */
|
ULONG HeapSegmentReserve; /* 78h */
|
||||||
ULONG HeapSegmentCommit; /* 7Ch */
|
ULONG HeapSegmentCommit; /* 7Ch */
|
||||||
|
@ -139,7 +138,7 @@ typedef struct _PEB
|
||||||
ULONG HeapDeCommitFreeBlockThreshold; /* 84h */
|
ULONG HeapDeCommitFreeBlockThreshold; /* 84h */
|
||||||
ULONG NumberOfHeaps; /* 88h */
|
ULONG NumberOfHeaps; /* 88h */
|
||||||
ULONG MaximumNumberOfHeaps; /* 8Ch */
|
ULONG MaximumNumberOfHeaps; /* 8Ch */
|
||||||
PVOID** ProcessHeaps; /* 90h */
|
PVOID* ProcessHeaps; /* 90h */
|
||||||
PVOID GdiSharedHandleTable; /* 94h */
|
PVOID GdiSharedHandleTable; /* 94h */
|
||||||
PVOID ProcessStarterHelper; /* 98h */
|
PVOID ProcessStarterHelper; /* 98h */
|
||||||
PVOID GdiDCAttributeList; /* 9Ch */
|
PVOID GdiDCAttributeList; /* 9Ch */
|
||||||
|
@ -147,13 +146,19 @@ typedef struct _PEB
|
||||||
ULONG OSMajorVersion; /* A4h */
|
ULONG OSMajorVersion; /* A4h */
|
||||||
ULONG OSMinorVersion; /* A8h */
|
ULONG OSMinorVersion; /* A8h */
|
||||||
USHORT OSBuildNumber; /* ACh */
|
USHORT OSBuildNumber; /* ACh */
|
||||||
UCHAR SPMajorVersion; /* AEh */
|
USHORT OSCSDVersion; /* AEh */
|
||||||
UCHAR SPMinorVersion; /* AFh */
|
|
||||||
ULONG OSPlatformId; /* B0h */
|
ULONG OSPlatformId; /* B0h */
|
||||||
ULONG ImageSubSystem; /* B4h */
|
ULONG ImageSubSystem; /* B4h */
|
||||||
ULONG ImageSubSystemMajorVersion; /* B8h */
|
ULONG ImageSubSystemMajorVersion; /* B8h */
|
||||||
ULONG ImageSubSystemMinorVersion; /* C0h */
|
ULONG ImageSubSystemMinorVersion; /* BCh */
|
||||||
|
ULONG ImageProcessAffinityMask; /* C0h */
|
||||||
ULONG GdiHandleBuffer[0x22]; /* C4h */
|
ULONG GdiHandleBuffer[0x22]; /* C4h */
|
||||||
|
PVOID PostProcessInitRoutine; /* 14Ch */
|
||||||
|
PVOID *TlsExpansionBitmap; /* 150h */
|
||||||
|
ULONG TlsExpansionBitmapBits[0x20]; /* 154h */
|
||||||
|
ULONG SessionId; /* 1D4h */
|
||||||
|
PVOID AppCompatInfo; /* 1D8h */
|
||||||
|
UNICODE_STRING CSDVersion; /* 1DCh */
|
||||||
} PEB;
|
} PEB;
|
||||||
|
|
||||||
#ifndef __USE_W32API
|
#ifndef __USE_W32API
|
||||||
|
|
|
@ -253,69 +253,46 @@ GetVersionExW(
|
||||||
LPOSVERSIONINFOW lpVersionInformation
|
LPOSVERSIONINFOW lpVersionInformation
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
PPEB pPeb = NtCurrentPeb();
|
NTSTATUS Status;
|
||||||
WCHAR *RosVersion;
|
|
||||||
|
|
||||||
/* TODO: move this into RtlGetVersion */
|
if(lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW) &&
|
||||||
switch(lpVersionInformation->dwOSVersionInfoSize)
|
lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW))
|
||||||
{
|
{
|
||||||
case sizeof(OSVERSIONINFOEXW):
|
/* for some reason win sets ERROR_INSUFFICIENT_BUFFER even if it is large
|
||||||
{
|
enough but doesn't match the exact sizes supported, ERROR_INVALID_PARAMETER
|
||||||
LPOSVERSIONINFOEXW lpVersionInformationEx =
|
would've been much more appropriate... */
|
||||||
(LPOSVERSIONINFOEXW)lpVersionInformation;
|
|
||||||
|
|
||||||
lpVersionInformationEx->wServicePackMajor = pPeb->SPMajorVersion;
|
|
||||||
lpVersionInformationEx->wServicePackMinor = pPeb->SPMinorVersion;
|
|
||||||
/* TODO: read from the KUSER_SHARED_DATA */
|
|
||||||
lpVersionInformationEx->wSuiteMask = 0;
|
|
||||||
/* TODO: call RtlGetNtProductType */
|
|
||||||
lpVersionInformationEx->wProductType = 0;
|
|
||||||
/* ??? */
|
|
||||||
lpVersionInformationEx->wReserved = 0;
|
|
||||||
/* fall through */
|
|
||||||
}
|
|
||||||
|
|
||||||
case sizeof(OSVERSIONINFOW):
|
|
||||||
{
|
|
||||||
lpVersionInformation->dwMajorVersion = pPeb->OSMajorVersion;
|
|
||||||
lpVersionInformation->dwMinorVersion = pPeb->OSMinorVersion;
|
|
||||||
lpVersionInformation->dwBuildNumber = pPeb->OSBuildNumber;
|
|
||||||
lpVersionInformation->dwPlatformId = pPeb->OSPlatformId;
|
|
||||||
|
|
||||||
/* First the Windows compatible string */
|
|
||||||
_snwprintf(lpVersionInformation->szCSDVersion,
|
|
||||||
sizeof(lpVersionInformation->szCSDVersion) / sizeof(WCHAR),
|
|
||||||
L"Service Pack %u", pPeb->SPMajorVersion);
|
|
||||||
/* Add the Reactos-specific string */
|
|
||||||
RosVersion = lpVersionInformation->szCSDVersion + wcslen(lpVersionInformation->szCSDVersion) + 1;
|
|
||||||
wcsncpy
|
|
||||||
(
|
|
||||||
RosVersion,
|
|
||||||
L"ReactOS " KERNEL_VERSION_STR L" (Build " KERNEL_VERSION_BUILD_STR L")",
|
|
||||||
sizeof(lpVersionInformation->szCSDVersion) / sizeof(WCHAR) -
|
|
||||||
((RosVersion - lpVersionInformation->szCSDVersion) + 1)
|
|
||||||
);
|
|
||||||
|
|
||||||
/* null-terminate, just in case */
|
|
||||||
lpVersionInformation->szCSDVersion
|
|
||||||
[
|
|
||||||
sizeof(lpVersionInformation->szCSDVersion) / sizeof(WCHAR) - 1
|
|
||||||
] = 0;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
/* unknown version information revision */
|
|
||||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = RtlGetVersion((PRTL_OSVERSIONINFOW)lpVersionInformation);
|
||||||
|
if(NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
int ln, maxlen;
|
||||||
|
|
||||||
|
/* append a reactos specific string to the szCSDVersion string */
|
||||||
|
|
||||||
|
/* FIXME - we shouldn't do this when there is a (ros-specific) compatibility
|
||||||
|
flag set so we don't screw applications that might depend on a
|
||||||
|
certain string */
|
||||||
|
|
||||||
|
ln = wcslen(lpVersionInformation->szCSDVersion);
|
||||||
|
maxlen = (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0]) - 1);
|
||||||
|
if(maxlen > ln)
|
||||||
|
{
|
||||||
|
PWCHAR szVer = lpVersionInformation->szCSDVersion + ln;
|
||||||
|
RtlZeroMemory(szVer, (maxlen - ln + 1) * sizeof(WCHAR));
|
||||||
|
wcsncpy(szVer,
|
||||||
|
L" ReactOS " KERNEL_VERSION_STR L" (Build " KERNEL_VERSION_BUILD_STR L")",
|
||||||
|
maxlen - ln);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
|
@ -326,111 +303,61 @@ GetVersionExA(
|
||||||
LPOSVERSIONINFOA lpVersionInformation
|
LPOSVERSIONINFOA lpVersionInformation
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
NTSTATUS nErrCode;
|
OSVERSIONINFOEXW viw;
|
||||||
OSVERSIONINFOEXW oviVerInfo;
|
|
||||||
LPOSVERSIONINFOEXA lpVersionInformationEx;
|
|
||||||
|
|
||||||
/* UNICODE_STRING descriptor of the Unicode version string */
|
RtlZeroMemory(&viw, sizeof(viw));
|
||||||
UNICODE_STRING wstrVerStr =
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
gives extra work to RtlUnicodeStringToAnsiString, but spares us an
|
|
||||||
RtlInitUnicodeString round
|
|
||||||
*/
|
|
||||||
0,
|
|
||||||
sizeof(((LPOSVERSIONINFOW)NULL)->szCSDVersion),
|
|
||||||
oviVerInfo.szCSDVersion
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ANSI_STRING descriptor of the ANSI version string buffer */
|
|
||||||
ANSI_STRING strVerStr =
|
|
||||||
{
|
|
||||||
0,
|
|
||||||
sizeof(((LPOSVERSIONINFOA)NULL)->szCSDVersion),
|
|
||||||
lpVersionInformation->szCSDVersion
|
|
||||||
};
|
|
||||||
|
|
||||||
switch(lpVersionInformation->dwOSVersionInfoSize)
|
switch(lpVersionInformation->dwOSVersionInfoSize)
|
||||||
{
|
{
|
||||||
case sizeof(OSVERSIONINFOEXA):
|
|
||||||
{
|
|
||||||
oviVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case sizeof(OSVERSIONINFOA):
|
case sizeof(OSVERSIONINFOA):
|
||||||
{
|
viw.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
|
||||||
oviVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
|
break;
|
||||||
|
|
||||||
|
case sizeof(OSVERSIONINFOEXA):
|
||||||
|
viw.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
/* for some reason win sets ERROR_INSUFFICIENT_BUFFER even if it is large
|
||||||
/* unknown version information revision */
|
enough but doesn't match the exact sizes supported, ERROR_INVALID_PARAMETER
|
||||||
|
would've been much more appropriate... */
|
||||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(!GetVersionExW((LPOSVERSIONINFOW)&oviVerInfo))
|
if(GetVersionExW((LPOSVERSIONINFOW)&viw))
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* null-terminate, just in case */
|
|
||||||
oviVerInfo.szCSDVersion
|
|
||||||
[
|
|
||||||
sizeof(((LPOSVERSIONINFOW)NULL)->szCSDVersion) /
|
|
||||||
sizeof(((LPOSVERSIONINFOW)NULL)->szCSDVersion[0]) -
|
|
||||||
1
|
|
||||||
] = 0;
|
|
||||||
wstrVerStr.Length = wcslen(wstrVerStr.Buffer) * sizeof(WCHAR);
|
|
||||||
|
|
||||||
/* convert the win version string */
|
|
||||||
nErrCode = RtlUnicodeStringToAnsiString(&strVerStr, &wstrVerStr, FALSE);
|
|
||||||
|
|
||||||
if(!NT_SUCCESS(nErrCode))
|
|
||||||
{
|
{
|
||||||
/* failure */
|
ANSI_STRING CSDVersionA;
|
||||||
SetLastErrorByStatus(nErrCode);
|
UNICODE_STRING CSDVersionW;
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
wstrVerStr.Buffer = oviVerInfo.szCSDVersion + wstrVerStr.Length / sizeof(WCHAR) + 1;
|
/* copy back fields that match both supported structures */
|
||||||
wstrVerStr.MaximumLength = sizeof(oviVerInfo.szCSDVersion) - (wstrVerStr.Length + sizeof(WCHAR));
|
lpVersionInformation->dwMajorVersion = viw.dwMajorVersion;
|
||||||
wstrVerStr.Length = wcslen(wstrVerStr.Buffer) * sizeof(WCHAR);
|
lpVersionInformation->dwMinorVersion = viw.dwMinorVersion;
|
||||||
strVerStr.Buffer = lpVersionInformation->szCSDVersion + strVerStr.Length + 1;
|
lpVersionInformation->dwBuildNumber = viw.dwBuildNumber;
|
||||||
strVerStr.MaximumLength = sizeof(lpVersionInformation->szCSDVersion) - (strVerStr.Length + 1);
|
lpVersionInformation->dwPlatformId = viw.dwPlatformId;
|
||||||
strVerStr.Length = 0;
|
|
||||||
|
|
||||||
/* convert the ReactOS version string */
|
RtlInitUnicodeString(&CSDVersionW, viw.szCSDVersion);
|
||||||
nErrCode = RtlUnicodeStringToAnsiString(&strVerStr, &wstrVerStr, FALSE);
|
|
||||||
|
|
||||||
if(!NT_SUCCESS(nErrCode))
|
CSDVersionA.Length = 0;
|
||||||
|
CSDVersionA.MaximumLength = sizeof(lpVersionInformation->szCSDVersion);
|
||||||
|
CSDVersionA.Buffer = lpVersionInformation->szCSDVersion;
|
||||||
|
|
||||||
|
RtlUnicodeStringToAnsiString(&CSDVersionA, &CSDVersionW, FALSE);
|
||||||
|
|
||||||
|
/* copy back the extended fields */
|
||||||
|
if(viw.dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
|
||||||
{
|
{
|
||||||
/* failure */
|
((LPOSVERSIONINFOEXA)lpVersionInformation)->wServicePackMajor = viw.wServicePackMajor;
|
||||||
SetLastErrorByStatus(nErrCode);
|
((LPOSVERSIONINFOEXA)lpVersionInformation)->wServicePackMinor = viw.wServicePackMinor;
|
||||||
return FALSE;
|
((LPOSVERSIONINFOEXA)lpVersionInformation)->wSuiteMask = viw.wSuiteMask;
|
||||||
|
((LPOSVERSIONINFOEXA)lpVersionInformation)->wProductType = viw.wProductType;
|
||||||
|
((LPOSVERSIONINFOEXA)lpVersionInformation)->wReserved = viw.wReserved;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy the fields */
|
|
||||||
lpVersionInformation->dwMajorVersion = oviVerInfo.dwMajorVersion;
|
|
||||||
lpVersionInformation->dwMinorVersion = oviVerInfo.dwMinorVersion;
|
|
||||||
lpVersionInformation->dwBuildNumber = oviVerInfo.dwBuildNumber;
|
|
||||||
lpVersionInformation->dwPlatformId = oviVerInfo.dwPlatformId;
|
|
||||||
|
|
||||||
if(lpVersionInformation->dwOSVersionInfoSize < sizeof(OSVERSIONINFOEXA))
|
|
||||||
/* success */
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* copy the extended fields */
|
return FALSE;
|
||||||
lpVersionInformationEx = (LPOSVERSIONINFOEXA)lpVersionInformation;
|
|
||||||
lpVersionInformationEx->wServicePackMajor = oviVerInfo.wServicePackMajor;
|
|
||||||
lpVersionInformationEx->wServicePackMinor = oviVerInfo.wServicePackMinor;
|
|
||||||
lpVersionInformationEx->wSuiteMask = oviVerInfo.wSuiteMask;
|
|
||||||
lpVersionInformationEx->wProductType = oviVerInfo.wProductType;
|
|
||||||
lpVersionInformationEx->wReserved = oviVerInfo.wReserved;
|
|
||||||
|
|
||||||
/* success */
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -207,10 +207,9 @@ LoadCompatibilitySettings(PPEB Peb)
|
||||||
Peb->OSPlatformId = (ULONG)PlatformId;
|
Peb->OSPlatformId = (ULONG)PlatformId;
|
||||||
|
|
||||||
/* optional service pack version numbers */
|
/* optional service pack version numbers */
|
||||||
if(ReadCompatibilitySetting(SubKeyHandle, L"SPMajorVersion", ValueInfo, &SPMajorVersion))
|
if(ReadCompatibilitySetting(SubKeyHandle, L"SPMajorVersion", ValueInfo, &SPMajorVersion) &&
|
||||||
Peb->SPMajorVersion = (UCHAR)SPMajorVersion;
|
ReadCompatibilitySetting(SubKeyHandle, L"SPMinorVersion", ValueInfo, &SPMinorVersion))
|
||||||
if(ReadCompatibilitySetting(SubKeyHandle, L"SPMinorVersion", ValueInfo, &SPMinorVersion))
|
Peb->OSCSDVersion = ((SPMajorVersion & 0xFF) << 8) | (SPMinorVersion & 0xFF);
|
||||||
Peb->SPMinorVersion = (UCHAR)SPMinorVersion;
|
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
/* we're finished */
|
/* we're finished */
|
||||||
|
|
|
@ -569,7 +569,7 @@ PsCreatePeb(HANDLE ProcessHandle,
|
||||||
Peb->OSMinorVersion = 0;
|
Peb->OSMinorVersion = 0;
|
||||||
Peb->OSBuildNumber = 1381;
|
Peb->OSBuildNumber = 1381;
|
||||||
Peb->OSPlatformId = 2; //VER_PLATFORM_WIN32_NT;
|
Peb->OSPlatformId = 2; //VER_PLATFORM_WIN32_NT;
|
||||||
Peb->SPMajorVersion = 6;
|
Peb->OSCSDVersion = 6 << 8;
|
||||||
|
|
||||||
Peb->AnsiCodePageData = (char*)TableBase + NlsAnsiTableOffset;
|
Peb->AnsiCodePageData = (char*)TableBase + NlsAnsiTableOffset;
|
||||||
Peb->OemCodePageData = (char*)TableBase + NlsOemTableOffset;
|
Peb->OemCodePageData = (char*)TableBase + NlsOemTableOffset;
|
||||||
|
|
Loading…
Reference in a new issue