aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-01-31 10:41:03 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-01-31 10:41:03 +0000
commitd76ff8424ecaa8a42939adf2975a6429870902f1 (patch)
tree4582c399214656b801fcb79ebd32069be36dec13 /src
parent19b889a241c7bebbaefefd6744a4f8029004a219 (diff)
downloadgnunet-d76ff8424ecaa8a42939adf2975a6429870902f1.tar.gz
gnunet-d76ff8424ecaa8a42939adf2975a6429870902f1.zip
helper-vpn and helper-exit now are 64bit capabled.
added check if we are running on a win32/wow64/win64 host system.
Diffstat (limited to 'src')
-rw-r--r--src/exit/gnunet-helper-exit-windows.c60
-rw-r--r--src/vpn/gnunet-helper-vpn-windows.c57
2 files changed, 89 insertions, 28 deletions
diff --git a/src/exit/gnunet-helper-exit-windows.c b/src/exit/gnunet-helper-exit-windows.c
index adbed1a0c..2b99134cc 100644
--- a/src/exit/gnunet-helper-exit-windows.c
+++ b/src/exit/gnunet-helper-exit-windows.c
@@ -18,19 +18,6 @@
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 */ 19 */
20 20
21/**
22 * @file exit/gnunet-helper-exit-windows.c
23 * @brief the helper for the exit service in win32 builds.
24 * Opens a virtual network-interface, sends data received on the if to stdout,
25 * sends data received on stdin to the interface
26 * @author Christian M. Fuchs
27 *
28 * The following list of people have reviewed this code and considered
29 * it safe since the last modification (if you reviewed it, please
30 * have your name added to the list):
31 *
32 */
33
34#include <stdio.h> 21#include <stdio.h>
35#include <windows.h> 22#include <windows.h>
36#include <setupapi.h> 23#include <setupapi.h>
@@ -60,7 +47,7 @@
60/* FIXME: define with varargs... */ 47/* FIXME: define with varargs... */
61#define LOG_DEBUG(msg) fprintf (stderr, "%s", msg); 48#define LOG_DEBUG(msg) fprintf (stderr, "%s", msg);
62#else 49#else
63#deifne LOG_DEBUG(msg) do {} while (0) 50#define LOG_DEBUG(msg) do {} while (0)
64#endif 51#endif
65 52
66 53
@@ -70,12 +57,18 @@
70#define MAX_SIZE 65536 57#define MAX_SIZE 65536
71 58
72/** 59/**
73 * Name or Path+Name of our driver in Unicode. 60 * Name or Path+Name of our win32 driver.
74 * The .sys and .cat files HAVE to be in the same location as this file! 61 * The .sys and .cat files HAVE to be in the same location as this file!
75 */ 62 */
76#define INF_FILE "share/gnunet/tapw32/OemWin2k.inf" 63#define INF_FILE "share/gnunet/tapw32/OemWin2k.inf"
77 64
78/** 65/**
66 * Name or Path+Name of our win64 driver.
67 * The .sys and .cat files HAVE to be in the same location as this file!
68 */
69#define INF_FILE64 "share/gnunet/tapw64/OemWin2k.inf"
70
71/**
79 * Hardware ID used in the inf-file. 72 * Hardware ID used in the inf-file.
80 * This might change over time, as openvpn advances their driver 73 * This might change over time, as openvpn advances their driver
81 */ 74 */
@@ -222,8 +215,35 @@ struct io_facility
222 */ 215 */
223WINBASEAPI HANDLE WINAPI ReOpenFile (HANDLE, DWORD, DWORD, DWORD); 216WINBASEAPI HANDLE WINAPI ReOpenFile (HANDLE, DWORD, DWORD, DWORD);
224 217
218/**
219 * IsWow64Process definition for our is_win64, as this is a kernel function
220 */
221typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
225 222
226/** 223/**
224 * Determines if the host OS is win32 or win64
225 *
226 * @return true if
227 */
228BOOL
229is_win64 ()
230{
231#if defined(_WIN64)
232 //this is a win64 binary,
233 return TRUE;
234#elif defined(_WIN32)
235 //this is a 32bit binary, and we need to check if we are running in WOW64
236 BOOL success = FALSE;
237 BOOL on_wow64 = FALSE;
238 LPFN_ISWOW64PROCESS IsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress (GetModuleHandle ("kernel32"), "IsWow64Process");
239
240 if (NULL != IsWow64Process)
241 success = IsWow64Process (GetCurrentProcess (), &on_wow64);
242
243 return success && on_wow64;
244#endif
245}
246/**
227 * Wrapper for executing a shellcommand in windows. 247 * Wrapper for executing a shellcommand in windows.
228 * 248 *
229 * @param command - the command + parameters to execute 249 * @param command - the command + parameters to execute
@@ -441,12 +461,12 @@ setup_interface ()
441 461
442 /** 462 /**
443 * Locate the inf-file, we need to store it somewhere where the system can 463 * Locate the inf-file, we need to store it somewhere where the system can
444 * find it. A good choice would be CWD/PDW or %WINDIR$\system32\ 464 * find it. We need to pick the correct driver for win32/win64.
445 *
446 * TODO: How about win64 in the future?
447 * We need to use a different driver for amd64/i386 !
448 */ 465 */
449 GetFullPathNameA (INF_FILE, MAX_PATH, inf_file_path, &temp_inf_filename); 466 if (is_win64())
467 GetFullPathNameA (INF_FILE64, MAX_PATH, inf_file_path, &temp_inf_filename);
468 else
469 GetFullPathNameA (INF_FILE, MAX_PATH, inf_file_path, &temp_inf_filename);
450 470
451 fprintf (stderr, "INFO: Located our driver's .inf file at %s\n", inf_file_path); 471 fprintf (stderr, "INFO: Located our driver's .inf file at %s\n", inf_file_path);
452 /** 472 /**
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c
index f3c61a6e0..dbf5663e4 100644
--- a/src/vpn/gnunet-helper-vpn-windows.c
+++ b/src/vpn/gnunet-helper-vpn-windows.c
@@ -54,7 +54,15 @@
54 * Should we print (interesting|debug) messages that can happen during 54 * Should we print (interesting|debug) messages that can happen during
55 * normal operation? 55 * normal operation?
56 */ 56 */
57//#define DEBUG GNUNET_YES 57#define DEBUG GNUNET_NO
58
59#if DEBUG
60/* FIXME: define with varargs... */
61#define LOG_DEBUG(msg) fprintf (stderr, "%s", msg);
62#else
63#define LOG_DEBUG(msg) do {} while (0)
64#endif
65
58 66
59/** 67/**
60 * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE) 68 * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
@@ -62,12 +70,18 @@
62#define MAX_SIZE 65536 70#define MAX_SIZE 65536
63 71
64/** 72/**
65 * Name or Path+Name of our driver in Unicode. 73 * Name or Path+Name of our win32 driver.
66 * The .sys and .cat files HAVE to be in the same location as this file! 74 * The .sys and .cat files HAVE to be in the same location as this file!
67 */ 75 */
68#define INF_FILE "share/gnunet/tapw32/OemWin2k.inf" 76#define INF_FILE "share/gnunet/tapw32/OemWin2k.inf"
69 77
70/** 78/**
79 * Name or Path+Name of our win64 driver.
80 * The .sys and .cat files HAVE to be in the same location as this file!
81 */
82#define INF_FILE64 "share/gnunet/tapw64/OemWin2k.inf"
83
84/**
71 * Hardware ID used in the inf-file. 85 * Hardware ID used in the inf-file.
72 * This might change over time, as openvpn advances their driver 86 * This might change over time, as openvpn advances their driver
73 */ 87 */
@@ -214,8 +228,35 @@ struct io_facility
214 */ 228 */
215WINBASEAPI HANDLE WINAPI ReOpenFile (HANDLE, DWORD, DWORD, DWORD); 229WINBASEAPI HANDLE WINAPI ReOpenFile (HANDLE, DWORD, DWORD, DWORD);
216 230
231/**
232 * IsWow64Process definition for our is_win64, as this is a kernel function
233 */
234typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
217 235
218/** 236/**
237 * Determines if the host OS is win32 or win64
238 *
239 * @return true if
240 */
241BOOL
242is_win64 ()
243{
244#if defined(_WIN64)
245 //this is a win64 binary,
246 return TRUE;
247#elif defined(_WIN32)
248 //this is a 32bit binary, and we need to check if we are running in WOW64
249 BOOL success = FALSE;
250 BOOL on_wow64 = FALSE;
251 LPFN_ISWOW64PROCESS IsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress (GetModuleHandle ("kernel32"), "IsWow64Process");
252
253 if (NULL != IsWow64Process)
254 success = IsWow64Process (GetCurrentProcess (), &on_wow64);
255
256 return success && on_wow64;
257#endif
258}
259/**
219 * Wrapper for executing a shellcommand in windows. 260 * Wrapper for executing a shellcommand in windows.
220 * 261 *
221 * @param command - the command + parameters to execute 262 * @param command - the command + parameters to execute
@@ -232,7 +273,7 @@ execute_shellcommand (const char *command)
232 (NULL == (pipe = _popen (command, "rt"))) ) 273 (NULL == (pipe = _popen (command, "rt"))) )
233 return EINVAL; 274 return EINVAL;
234 275
235#ifdef DEBUG 276#if DEBUG
236 fprintf (stderr, "DEBUG: Command output: \n"); 277 fprintf (stderr, "DEBUG: Command output: \n");
237 char output[LINE_LEN]; 278 char output[LINE_LEN];
238 while (NULL != fgets (output, sizeof (output), pipe)) 279 while (NULL != fgets (output, sizeof (output), pipe))
@@ -433,12 +474,12 @@ setup_interface ()
433 474
434 /** 475 /**
435 * Locate the inf-file, we need to store it somewhere where the system can 476 * Locate the inf-file, we need to store it somewhere where the system can
436 * find it. A good choice would be CWD/PDW or %WINDIR$\system32\ 477 * find it. We need to pick the correct driver for win32/win64.
437 *
438 * TODO: How about win64 in the future?
439 * We need to use a different driver for amd64/i386 !
440 */ 478 */
441 GetFullPathNameA (INF_FILE, MAX_PATH, inf_file_path, &temp_inf_filename); 479 if (is_win64())
480 GetFullPathNameA (INF_FILE64, MAX_PATH, inf_file_path, &temp_inf_filename);
481 else
482 GetFullPathNameA (INF_FILE, MAX_PATH, inf_file_path, &temp_inf_filename);
442 483
443 fprintf (stderr, "INFO: Located our driver's .inf file at %s\n", inf_file_path); 484 fprintf (stderr, "INFO: Located our driver's .inf file at %s\n", inf_file_path);
444 /** 485 /**