diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/win/windows_version.cc | 20 | ||||
-rw-r--r-- | base/win/windows_version.h | 21 |
2 files changed, 39 insertions, 2 deletions
diff --git a/base/win/windows_version.cc b/base/win/windows_version.cc index a80688c..9abf1d2 100644 --- a/base/win/windows_version.cc +++ b/base/win/windows_version.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -68,5 +68,23 @@ void GetServicePackLevel(int* major, int* minor) { *minor = service_pack_minor; } +WOW64Status GetWOW64Status() { + static WOW64Status wow64_status = + GetWOW64StatusForProcess(GetCurrentProcess()); + return wow64_status; +} + +WOW64Status GetWOW64StatusForProcess(HANDLE process_handle) { + typedef BOOL (WINAPI* IsWow64ProcessFunc)(HANDLE, PBOOL); + IsWow64ProcessFunc is_wow64_process = reinterpret_cast<IsWow64ProcessFunc>( + GetProcAddress(GetModuleHandle(L"kernel32.dll"), "IsWow64Process")); + if (!is_wow64_process) + return WOW64_DISABLED; + BOOL is_wow64 = FALSE; + if (!(*is_wow64_process)(process_handle, &is_wow64)) + return WOW64_UNKNOWN; + return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED; +} + } // namespace win } // namespace base diff --git a/base/win/windows_version.h b/base/win/windows_version.h index 7e281a6..0cfb2c7 100644 --- a/base/win/windows_version.h +++ b/base/win/windows_version.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,6 +6,8 @@ #define BASE_WIN_WINDOWS_VERSION_H_ #pragma once +typedef void* HANDLE; + namespace base { namespace win { @@ -28,6 +30,23 @@ Version GetVersion(); // Returns the major and minor version of the service pack installed. void GetServicePackLevel(int* major, int* minor); +enum WOW64Status { + WOW64_DISABLED, + WOW64_ENABLED, + WOW64_UNKNOWN, +}; + +// Returns whether this process is running under WOW64 (the wrapper that allows +// 32-bit processes to run on 64-bit versions of Windows). This will return +// WOW64_DISABLED for both "32-bit Chrome on 32-bit Windows" and "64-bit Chrome +// on 64-bit Windows". WOW64_UNKNOWN means "an error occurred", e.g. the +// process does not have sufficient access rights to determine this. +WOW64Status GetWOW64Status(); + +// Like GetWOW64Status(), but for the supplied handle instead of the current +// process. +WOW64Status GetWOW64StatusForProcess(HANDLE process_handle); + } // namespace win } // namespace base |