aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
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/vpn
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/vpn')
-rw-r--r--src/vpn/gnunet-helper-vpn-windows.c57
1 files changed, 49 insertions, 8 deletions
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 /**