summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2016-09-02 18:37:51 +0100
committerFrediano Ziglio <fziglio@redhat.com>2017-02-01 15:15:34 +0000
commitfeb787c9b5054b071d62f17bd914c32c3483ed9e (patch)
tree6ea8ca2180d4b190243690a61c4ff1fced9256d2
parent3bb052cc5d96cb51d5a81f6797a18bcf316c0794 (diff)
Add os_is_64bit utility function
Allow to know if the system is 64 bit or not. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r--src/spice-util-priv.h3
-rw-r--r--src/spice-util.c42
2 files changed, 45 insertions, 0 deletions
diff --git a/src/spice-util-priv.h b/src/spice-util-priv.h
index 38b0deb..790cc06 100644
--- a/src/spice-util-priv.h
+++ b/src/spice-util-priv.h
@@ -32,6 +32,9 @@ gchar* spice_unix2dos(const gchar *str, gssize len);
gchar* spice_dos2unix(const gchar *str, gssize len);
void spice_mono_edge_highlight(unsigned width, unsigned hight,
const guint8 *and, const guint8 *xor, guint8 *dest);
+#ifdef G_OS_WIN32
+G_GNUC_INTERNAL gboolean os_is_64bit(void);
+#endif
G_END_DECLS
diff --git a/src/spice-util.c b/src/spice-util.c
index 86377b6..7f66d51 100644
--- a/src/spice-util.c
+++ b/src/spice-util.c
@@ -23,6 +23,9 @@
#include <string.h>
#include <glib.h>
#include <glib-object.h>
+#ifdef G_OS_WIN32
+#include <windows.h>
+#endif
#include <spice/macros.h>
#include "spice-util-priv.h"
#include "spice-util.h"
@@ -477,3 +480,42 @@ void spice_mono_edge_highlight(unsigned width, unsigned height,
xor += bpl;
}
}
+
+#ifdef G_OS_WIN32
+/*
+ * Check if current process is running in Wow64 mode
+ * (32 bit on a 64 system)
+ */
+#ifndef _WIN64
+static BOOL is_wow64(void)
+{
+ BOOL bIsWow64 = FALSE;
+
+ typedef BOOL WINAPI IsWow64Process_t(HANDLE, PBOOL);
+ IsWow64Process_t *pIsWow64Process =
+ (IsWow64Process_t *) GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
+
+ if (pIsWow64Process)
+ pIsWow64Process(GetCurrentProcess(), &bIsWow64);
+
+ return bIsWow64;
+}
+#else
+static inline BOOL is_wow64(void)
+{
+ return FALSE;
+}
+#endif
+
+/*
+ * Check if OS is 64 bit
+ */
+gboolean os_is_64bit(void)
+{
+#ifdef _WIN64
+ return TRUE;
+#else
+ return is_wow64() != FALSE;
+#endif
+}
+#endif