gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r25959 - in gnunet/src: exit vpn


From: gnunet
Subject: [GNUnet-SVN] r25959 - in gnunet/src: exit vpn
Date: Thu, 31 Jan 2013 11:41:03 +0100

Author: cfuchs
Date: 2013-01-31 11:41:03 +0100 (Thu, 31 Jan 2013)
New Revision: 25959

Modified:
   gnunet/src/exit/gnunet-helper-exit-windows.c
   gnunet/src/vpn/gnunet-helper-vpn-windows.c
Log:
helper-vpn and helper-exit now are 64bit capabled.

added check if we are running on a win32/wow64/win64 host system.



Modified: gnunet/src/exit/gnunet-helper-exit-windows.c
===================================================================
--- gnunet/src/exit/gnunet-helper-exit-windows.c        2013-01-31 10:11:48 UTC 
(rev 25958)
+++ gnunet/src/exit/gnunet-helper-exit-windows.c        2013-01-31 10:41:03 UTC 
(rev 25959)
@@ -18,19 +18,6 @@
      Boston, MA 02111-1307, USA.
  */
 
-/**
- * @file exit/gnunet-helper-exit-windows.c
- * @brief the helper for the exit service in win32 builds. 
- * Opens a virtual network-interface, sends data received on the if to stdout, 
- * sends data received on stdin to the interface
- * @author Christian M. Fuchs
- *
- * The following list of people have reviewed this code and considered
- * it safe since the last modification (if you reviewed it, please
- * have your name added to the list):
- *
- */
-
 #include <stdio.h>
 #include <windows.h>
 #include <setupapi.h>
@@ -60,7 +47,7 @@
 /* FIXME: define with varargs... */
 #define LOG_DEBUG(msg) fprintf (stderr, "%s", msg);
 #else
-#deifne LOG_DEBUG(msg) do {} while (0)
+#define LOG_DEBUG(msg) do {} while (0)
 #endif
 
 
@@ -70,12 +57,18 @@
 #define MAX_SIZE 65536
 
 /**
- * Name or Path+Name of our driver in Unicode.
+ * Name or Path+Name of our win32 driver.
  * The .sys and .cat files HAVE to be in the same location as this file!
  */
 #define INF_FILE "share/gnunet/tapw32/OemWin2k.inf"
 
 /**
+ * Name or Path+Name of our win64 driver.
+ * The .sys and .cat files HAVE to be in the same location as this file!
+ */
+#define INF_FILE64 "share/gnunet/tapw64/OemWin2k.inf"
+
+/**
  * Hardware ID used in the inf-file. 
  * This might change over time, as openvpn advances their driver
  */
@@ -222,8 +215,35 @@
  */
 WINBASEAPI HANDLE WINAPI ReOpenFile (HANDLE, DWORD, DWORD, DWORD);
 
+/**
+ * IsWow64Process definition for our is_win64, as this is a kernel function
+ */
+typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
 
 /**
+ * Determines if the host OS is win32 or win64
+ * 
+ * @return true if 
+ */
+BOOL
+is_win64 ()
+{
+#if defined(_WIN64)
+  //this is a win64 binary, 
+  return TRUE; 
+#elif defined(_WIN32)
+  //this is a 32bit binary, and we need to check if we are running in WOW64
+  BOOL success = FALSE;
+  BOOL on_wow64 = FALSE;
+  LPFN_ISWOW64PROCESS IsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress 
(GetModuleHandle ("kernel32"), "IsWow64Process");
+  
+  if (NULL != IsWow64Process)
+      success = IsWow64Process (GetCurrentProcess (), &on_wow64);
+  
+  return success && on_wow64;
+#endif
+}
+/**
  * Wrapper for executing a shellcommand in windows.
  * 
  * @param command - the command + parameters to execute
@@ -441,12 +461,12 @@
   
   /** 
    * Locate the inf-file, we need to store it somewhere where the system can
-   * find it. A good choice would be CWD/PDW or %WINDIR$\system32\
-   * 
-   * TODO: How about win64 in the future? 
-   *       We need to use a different driver for amd64/i386 !
+   * find it. We need to pick the correct driver for win32/win64.
    */
-  GetFullPathNameA (INF_FILE, MAX_PATH, inf_file_path, &temp_inf_filename);
+  if (is_win64())
+    GetFullPathNameA (INF_FILE64, MAX_PATH, inf_file_path, &temp_inf_filename);
+  else
+    GetFullPathNameA (INF_FILE, MAX_PATH, inf_file_path, &temp_inf_filename);
 
   fprintf (stderr, "INFO: Located our driver's .inf file at %s\n", 
inf_file_path);
   /** 

Modified: gnunet/src/vpn/gnunet-helper-vpn-windows.c
===================================================================
--- gnunet/src/vpn/gnunet-helper-vpn-windows.c  2013-01-31 10:11:48 UTC (rev 
25958)
+++ gnunet/src/vpn/gnunet-helper-vpn-windows.c  2013-01-31 10:41:03 UTC (rev 
25959)
@@ -54,20 +54,34 @@
  * Should we print (interesting|debug) messages that can happen during
  * normal operation?
  */
-//#define DEBUG GNUNET_YES
+#define DEBUG GNUNET_NO
 
+#if DEBUG
+/* FIXME: define with varargs... */
+#define LOG_DEBUG(msg) fprintf (stderr, "%s", msg);
+#else
+#define LOG_DEBUG(msg) do {} while (0)
+#endif
+
+
 /**
  * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
  */
 #define MAX_SIZE 65536
 
 /**
- * Name or Path+Name of our driver in Unicode.
+ * Name or Path+Name of our win32 driver.
  * The .sys and .cat files HAVE to be in the same location as this file!
  */
 #define INF_FILE "share/gnunet/tapw32/OemWin2k.inf"
 
 /**
+ * Name or Path+Name of our win64 driver.
+ * The .sys and .cat files HAVE to be in the same location as this file!
+ */
+#define INF_FILE64 "share/gnunet/tapw64/OemWin2k.inf"
+
+/**
  * Hardware ID used in the inf-file. 
  * This might change over time, as openvpn advances their driver
  */
@@ -214,8 +228,35 @@
  */
 WINBASEAPI HANDLE WINAPI ReOpenFile (HANDLE, DWORD, DWORD, DWORD);
 
+/**
+ * IsWow64Process definition for our is_win64, as this is a kernel function
+ */
+typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
 
 /**
+ * Determines if the host OS is win32 or win64
+ * 
+ * @return true if 
+ */
+BOOL
+is_win64 ()
+{
+#if defined(_WIN64)
+  //this is a win64 binary, 
+  return TRUE; 
+#elif defined(_WIN32)
+  //this is a 32bit binary, and we need to check if we are running in WOW64
+  BOOL success = FALSE;
+  BOOL on_wow64 = FALSE;
+  LPFN_ISWOW64PROCESS IsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress 
(GetModuleHandle ("kernel32"), "IsWow64Process");
+  
+  if (NULL != IsWow64Process)
+      success = IsWow64Process (GetCurrentProcess (), &on_wow64);
+  
+  return success && on_wow64;
+#endif
+}
+/**
  * Wrapper for executing a shellcommand in windows.
  * 
  * @param command - the command + parameters to execute
@@ -232,7 +273,7 @@
        (NULL == (pipe = _popen (command, "rt"))) )
     return EINVAL;
 
-#ifdef DEBUG
+#if DEBUG
   fprintf (stderr, "DEBUG: Command output: \n");
   char output[LINE_LEN];
   while (NULL != fgets (output, sizeof (output), pipe))
@@ -433,12 +474,12 @@
   
   /** 
    * Locate the inf-file, we need to store it somewhere where the system can
-   * find it. A good choice would be CWD/PDW or %WINDIR$\system32\
-   * 
-   * TODO: How about win64 in the future? 
-   *       We need to use a different driver for amd64/i386 !
+   * find it. We need to pick the correct driver for win32/win64.
    */
-  GetFullPathNameA (INF_FILE, MAX_PATH, inf_file_path, &temp_inf_filename);
+  if (is_win64())
+    GetFullPathNameA (INF_FILE64, MAX_PATH, inf_file_path, &temp_inf_filename);
+  else
+    GetFullPathNameA (INF_FILE, MAX_PATH, inf_file_path, &temp_inf_filename);
 
   fprintf (stderr, "INFO: Located our driver's .inf file at %s\n", 
inf_file_path);
   /** 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]