kernel32: Retrieve the system info from ntdll on startup.

This commit is contained in:
Alexandre Julliard 2013-01-08 22:02:21 +01:00
parent 58176bba10
commit 62f22dd4e3
4 changed files with 19 additions and 23 deletions

View File

@ -39,9 +39,10 @@
#include "winnt.h" #include "winnt.h"
#include "winternl.h" #include "winternl.h"
#include "psapi.h" #include "psapi.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "ddk/wdm.h" #include "ddk/wdm.h"
#include "wine/unicode.h"
#include "kernel_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(reg); WINE_DEFAULT_DEBUG_CHANNEL(reg);
@ -104,13 +105,11 @@ VOID WINAPI GetSystemInfo(
LPSYSTEM_INFO si /* [out] Destination for system information, may not be NULL */) LPSYSTEM_INFO si /* [out] Destination for system information, may not be NULL */)
{ {
NTSTATUS nts; NTSTATUS nts;
SYSTEM_BASIC_INFORMATION sbi;
SYSTEM_CPU_INFORMATION sci; SYSTEM_CPU_INFORMATION sci;
TRACE("si=0x%p\n", si); TRACE("si=0x%p\n", si);
if ((nts = NtQuerySystemInformation( SystemBasicInformation, &sbi, sizeof(sbi), NULL )) != STATUS_SUCCESS || if ((nts = NtQuerySystemInformation( SystemCpuInformation, &sci, sizeof(sci), NULL )) != STATUS_SUCCESS)
(nts = NtQuerySystemInformation( SystemCpuInformation, &sci, sizeof(sci), NULL )) != STATUS_SUCCESS)
{ {
SetLastError(RtlNtStatusToDosError(nts)); SetLastError(RtlNtStatusToDosError(nts));
return; return;
@ -118,11 +117,11 @@ VOID WINAPI GetSystemInfo(
si->u.s.wProcessorArchitecture = sci.Architecture; si->u.s.wProcessorArchitecture = sci.Architecture;
si->u.s.wReserved = 0; si->u.s.wReserved = 0;
si->dwPageSize = sbi.PageSize; si->dwPageSize = system_info.PageSize;
si->lpMinimumApplicationAddress = sbi.LowestUserAddress; si->lpMinimumApplicationAddress = system_info.LowestUserAddress;
si->lpMaximumApplicationAddress = sbi.HighestUserAddress; si->lpMaximumApplicationAddress = system_info.HighestUserAddress;
si->dwActiveProcessorMask = sbi.ActiveProcessorsAffinityMask; si->dwActiveProcessorMask = system_info.ActiveProcessorsAffinityMask;
si->dwNumberOfProcessors = sbi.NumberOfProcessors; si->dwNumberOfProcessors = system_info.NumberOfProcessors;
switch (sci.Architecture) switch (sci.Architecture)
{ {
@ -162,7 +161,7 @@ VOID WINAPI GetSystemInfo(
FIXME("Unknown processor architecture %x\n", sci.Architecture); FIXME("Unknown processor architecture %x\n", sci.Architecture);
si->dwProcessorType = 0; si->dwProcessorType = 0;
} }
si->dwAllocationGranularity = sbi.AllocationGranularity; si->dwAllocationGranularity = system_info.AllocationGranularity;
si->wProcessorLevel = sci.Level; si->wProcessorLevel = sci.Level;
si->wProcessorRevision = sci.Revision; si->wProcessorRevision = sci.Revision;
} }

View File

@ -53,6 +53,7 @@ static inline obj_handle_t console_handle_unmap(HANDLE h)
#define KERNEL32_CONSOLE_SHELL ((HANDLE)2) #define KERNEL32_CONSOLE_SHELL ((HANDLE)2)
extern HMODULE kernel32_handle DECLSPEC_HIDDEN; extern HMODULE kernel32_handle DECLSPEC_HIDDEN;
extern SYSTEM_BASIC_INFORMATION system_info DECLSPEC_HIDDEN;
extern const WCHAR *DIR_Windows DECLSPEC_HIDDEN; extern const WCHAR *DIR_Windows DECLSPEC_HIDDEN;
extern const WCHAR *DIR_System DECLSPEC_HIDDEN; extern const WCHAR *DIR_System DECLSPEC_HIDDEN;

View File

@ -87,6 +87,7 @@ static BOOL is_wow64;
static const int is_win64 = (sizeof(void *) > sizeof(int)); static const int is_win64 = (sizeof(void *) > sizeof(int));
HMODULE kernel32_handle = 0; HMODULE kernel32_handle = 0;
SYSTEM_BASIC_INFORMATION system_info = { 0 };
const WCHAR *DIR_Windows = NULL; const WCHAR *DIR_Windows = NULL;
const WCHAR *DIR_System = NULL; const WCHAR *DIR_System = NULL;
@ -1146,6 +1147,7 @@ void CDECL __wine_kernel_init(void)
setbuf(stderr,NULL); setbuf(stderr,NULL);
kernel32_handle = GetModuleHandleW(kernel32W); kernel32_handle = GetModuleHandleW(kernel32W);
IsWow64Process( GetCurrentProcess(), &is_wow64 ); IsWow64Process( GetCurrentProcess(), &is_wow64 );
NtQuerySystemInformation( SystemBasicInformation, &system_info, sizeof(system_info), NULL );
LOCALE_Init(); LOCALE_Init();

View File

@ -48,8 +48,6 @@
WINE_DECLARE_DEBUG_CHANNEL(seh); WINE_DECLARE_DEBUG_CHANNEL(seh);
WINE_DECLARE_DEBUG_CHANNEL(file); WINE_DECLARE_DEBUG_CHANNEL(file);
static unsigned int page_size;
/*********************************************************************** /***********************************************************************
* VirtualAlloc (KERNEL32.@) * VirtualAlloc (KERNEL32.@)
@ -648,19 +646,17 @@ BOOL WINAPI IsBadReadPtr( LPCVOID ptr, UINT size )
{ {
if (!size) return FALSE; /* handle 0 size case w/o reference */ if (!size) return FALSE; /* handle 0 size case w/o reference */
if (!ptr) return TRUE; if (!ptr) return TRUE;
if (!page_size) page_size = getpagesize();
__TRY __TRY
{ {
volatile const char *p = ptr; volatile const char *p = ptr;
char dummy __attribute__((unused)); char dummy __attribute__((unused));
UINT count = size; UINT count = size;
while (count > page_size) while (count > system_info.PageSize)
{ {
dummy = *p; dummy = *p;
p += page_size; p += system_info.PageSize;
count -= page_size; count -= system_info.PageSize;
} }
dummy = p[0]; dummy = p[0];
dummy = p[count - 1]; dummy = p[count - 1];
@ -692,18 +688,16 @@ BOOL WINAPI IsBadWritePtr( LPVOID ptr, UINT size )
{ {
if (!size) return FALSE; /* handle 0 size case w/o reference */ if (!size) return FALSE; /* handle 0 size case w/o reference */
if (!ptr) return TRUE; if (!ptr) return TRUE;
if (!page_size) page_size = getpagesize();
__TRY __TRY
{ {
volatile char *p = ptr; volatile char *p = ptr;
UINT count = size; UINT count = size;
while (count > page_size) while (count > system_info.PageSize)
{ {
*p |= 0; *p |= 0;
p += page_size; p += system_info.PageSize;
count -= page_size; count -= system_info.PageSize;
} }
p[0] |= 0; p[0] |= 0;
p[count - 1] |= 0; p[count - 1] |= 0;