diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-01-31 10:41:03 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-01-31 10:41:03 +0000 |
commit | d76ff8424ecaa8a42939adf2975a6429870902f1 (patch) | |
tree | 4582c399214656b801fcb79ebd32069be36dec13 /src/exit/gnunet-helper-exit-windows.c | |
parent | 19b889a241c7bebbaefefd6744a4f8029004a219 (diff) | |
download | gnunet-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/exit/gnunet-helper-exit-windows.c')
-rw-r--r-- | src/exit/gnunet-helper-exit-windows.c | 60 |
1 files changed, 40 insertions, 20 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 | */ |
223 | WINBASEAPI HANDLE WINAPI ReOpenFile (HANDLE, DWORD, DWORD, DWORD); | 216 | WINBASEAPI HANDLE WINAPI ReOpenFile (HANDLE, DWORD, DWORD, DWORD); |
224 | 217 | ||
218 | /** | ||
219 | * IsWow64Process definition for our is_win64, as this is a kernel function | ||
220 | */ | ||
221 | typedef 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 | */ | ||
228 | BOOL | ||
229 | is_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 | /** |