KERNEL32.GetProcessVersion partial implementation.
authorEmanuele Aliberti <ea@iol.it>
Sat, 10 Feb 2001 22:01:50 +0000 (22:01 +0000)
committerEmanuele Aliberti <ea@iol.it>
Sat, 10 Feb 2001 22:01:50 +0000 (22:01 +0000)
KERNEL32.GetSystemInfo about finished.

svn path=/trunk/; revision=1612

reactos/lib/kernel32/misc/stubs.c
reactos/lib/kernel32/misc/sysinfo.c
reactos/lib/kernel32/process/proc.c

index 4b2b79a..6b25025 100644 (file)
@@ -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 (
index 755abca..6bcb0ee 100644 (file)
@@ -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 <kernel32/kernel32.h>
 #include <kernel32/error.h>
 
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
 
 #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;
index 8833760..e5d0271 100644 (file)
@@ -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 */