From b611b79b36515bf5d0d51f29e8ce986729da46c7 Mon Sep 17 00:00:00 2001 From: Emanuele Aliberti Date: Sat, 10 Feb 2001 22:01:50 +0000 Subject: [PATCH] KERNEL32.GetProcessVersion partial implementation. KERNEL32.GetSystemInfo about finished. svn path=/trunk/; revision=1612 --- reactos/lib/kernel32/misc/stubs.c | 13 +------- reactos/lib/kernel32/misc/sysinfo.c | 50 ++++++++++++++++++++++------- reactos/lib/kernel32/process/proc.c | 34 +++++++++++++++++++- 3 files changed, 72 insertions(+), 25 deletions(-) diff --git a/reactos/lib/kernel32/misc/stubs.c b/reactos/lib/kernel32/misc/stubs.c index 4b2b79a45ff..6b250254acd 100644 --- a/reactos/lib/kernel32/misc/stubs.c +++ b/reactos/lib/kernel32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.23 2001/01/20 12:19:57 ekohl Exp $ +/* $Id: stubs.c,v 1.24 2001/02/10 22:01:50 ea Exp $ * * KERNEL32.DLL stubs (unimplemented functions) * Remove from this file, if you implement them. @@ -1764,17 +1764,6 @@ GetProcessShutdownParameters ( } -DWORD -STDCALL -GetProcessVersion ( - DWORD Unknown0 - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - WINBOOL STDCALL GetProcessWorkingSetSize ( diff --git a/reactos/lib/kernel32/misc/sysinfo.c b/reactos/lib/kernel32/misc/sysinfo.c index 755abca3807..6bcb0ee8640 100644 --- a/reactos/lib/kernel32/misc/sysinfo.c +++ b/reactos/lib/kernel32/misc/sysinfo.c @@ -1,4 +1,4 @@ -/* $Id: sysinfo.c,v 1.2 2000/11/04 13:52:12 ekohl Exp $ +/* $Id: sysinfo.c,v 1.3 2001/02/10 22:01:50 ea Exp $ * * reactos/lib/kernel32/misc/sysinfo.c * @@ -8,6 +8,9 @@ #include #include +#define WIN32_LEAN_AND_MEAN +#include + #define PV_NT351 0x00030033 @@ -61,34 +64,57 @@ GetSystemInfo ( Si->dwActiveProcessorMask = Sbi.ActiveProcessorsAffinityMask; Si->dwNumberOfProcessors = Sbi.NumberOfProcessors; /* - * Compatibility: + * Compatibility (no longer relevant): * PROCESSOR_INTEL_386 386 * PROCESSOR_INTEL_486 486 * PROCESSOR_INTEL_PENTIUM 586 * PROCESSOR_MIPS_R4000 4000 * PROCESSOR_ALPHA_21064 21064 */ -#if 0 switch (Spi.ProcessorArchitecture) { - case : -#endif - Si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; -#if 0 + case PROCESSOR_ARCHITECTURE_INTEL: + switch (Spi.ProcessorLevel) + { + case 3: + Si->dwProcessorType = PROCESSOR_INTEL_386; + break; + case 4: + Si->dwProcessorType = PROCESSOR_INTEL_486; + break; + case 5: + Si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; + break; + default: + /* FIXME: P2, P3, P4...? */ + Si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; + } break; + + case PROCESSOR_ARCHITECTURE_MIPS: + Si->dwProcessorType = PROCESSOR_MIPS_R4000; + break; + + case PROCESSOR_ARCHITECTURE_ALPHA: + Si->dwProcessorType = PROCESSOR_ALPHA_21064; + break; + + case PROCESSOR_ARCHITECTURE_PPC: + Si->dwProcessorType = -1; /* FIXME: what value? */ + break; + } -#endif + /* Once hardcoded to 64kb */ Si->dwAllocationGranularity = Sbi.AllocationGranularity; + /* */ + Si->wProcessorLevel = Spi.ProcessorLevel; Si->wProcessorRevision = Spi.ProcessorRevision; /* * Get the version of Windows on which * the process expects to run. */ -#if 0 ProcessVersion = GetProcessVersion (0); /* current process */ -#endif - - /* In NT 3.1, these fields were always zero. */ + /* In NT 3.1 and 3.5 these fields were always zero. */ if (PV_NT351 > ProcessVersion) { Si->wProcessorLevel = 0; diff --git a/reactos/lib/kernel32/process/proc.c b/reactos/lib/kernel32/process/proc.c index 8833760f696..e5d0271a23c 100644 --- a/reactos/lib/kernel32/process/proc.c +++ b/reactos/lib/kernel32/process/proc.c @@ -1,4 +1,4 @@ -/* $Id: proc.c,v 1.37 2001/02/06 00:11:18 dwelch Exp $ +/* $Id: proc.c,v 1.38 2001/02/10 22:01:50 ea Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -629,4 +629,36 @@ SetPriorityClass ( } +DWORD +STDCALL +GetProcessVersion ( + DWORD ProcessId + ) +{ + DWORD Version = 0; + PIMAGE_NT_HEADERS NtHeader = NULL; + PVOID BaseAddress = NULL; + + /* Caller's */ + if (0 == ProcessId) + { + BaseAddress = (PVOID) NtCurrentPeb()->ImageBaseAddress; + NtHeader = RtlImageNtHeader (BaseAddress); + if (NULL != NtHeader) + { + Version = + (NtHeader->OptionalHeader.MajorOperatingSystemVersion << 16) + | (NtHeader->OptionalHeader.MinorOperatingSystemVersion); + } + } + else /* other process */ + { + /* FIXME: open the other process */ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + } + return (Version); +} + + + /* EOF */