summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-04 01:17:37 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-04 01:17:37 +0000
commit1e67c2be4d77333ab9f303c8d9fa5eb58ebc6c90 (patch)
tree80434934d6420f40ea3372dc1c148123c55f6a32 /base
parentcf50836f5fff555ab9b8d2e961029a31514ea239 (diff)
downloadchromium_src-1e67c2be4d77333ab9f303c8d9fa5eb58ebc6c90.zip
chromium_src-1e67c2be4d77333ab9f303c8d9fa5eb58ebc6c90.tar.gz
chromium_src-1e67c2be4d77333ab9f303c8d9fa5eb58ebc6c90.tar.bz2
Create a "GetWOW64Status()" utility function and make the rest of the codebase call it.
BUG=none TEST=none Review URL: http://codereview.chromium.org/6610029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76854 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/win/windows_version.cc20
-rw-r--r--base/win/windows_version.h21
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