diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-01-15 20:22:54 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-01-15 20:22:54 +0000 |
commit | e1379548b2669fd3d3bf356e9764ea2e13cda1c9 (patch) | |
tree | 010284c4485ee994d83f1d9ef320cd3e003d8688 /src/vpn/gnunet-helper-vpn-windows.c | |
parent | e156f8cceb6186d03b836b14dc308e8ff0bba16e (diff) | |
download | gnunet-e1379548b2669fd3d3bf356e9764ea2e13cda1c9.tar.gz gnunet-e1379548b2669fd3d3bf356e9764ea2e13cda1c9.zip |
added calls for updating the driver in a for device. seems like this is
mandatory when adding a new device node. unfortunately this is pretty
slow...
added new required include+library to link against: newdev.h/dll
Diffstat (limited to 'src/vpn/gnunet-helper-vpn-windows.c')
-rw-r--r-- | src/vpn/gnunet-helper-vpn-windows.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/vpn/gnunet-helper-vpn-windows.c b/src/vpn/gnunet-helper-vpn-windows.c index 2fe039107..dffe92cce 100644 --- a/src/vpn/gnunet-helper-vpn-windows.c +++ b/src/vpn/gnunet-helper-vpn-windows.c | |||
@@ -35,11 +35,11 @@ | |||
35 | #include <windows.h> | 35 | #include <windows.h> |
36 | #include <setupapi.h> | 36 | #include <setupapi.h> |
37 | #include <ddk/cfgmgr32.h> | 37 | #include <ddk/cfgmgr32.h> |
38 | #include <ddk/newdev.h> | ||
38 | #include <Winsock2.h> | 39 | #include <Winsock2.h> |
39 | #include "platform.h" | 40 | #include "platform.h" |
40 | #include "tap-windows.h" | 41 | #include "tap-windows.h" |
41 | 42 | ||
42 | |||
43 | /** | 43 | /** |
44 | * Need 'struct GNUNET_MessageHeader'. | 44 | * Need 'struct GNUNET_MessageHeader'. |
45 | */ | 45 | */ |
@@ -165,7 +165,9 @@ struct io_facility | |||
165 | #define IOSTATE_QUEUED 1 /* overlapped I/O has been queued */ | 165 | #define IOSTATE_QUEUED 1 /* overlapped I/O has been queued */ |
166 | #define IOSTATE_WAITING 3 /* overlapped I/O has finished, but is waiting for it's write-partner */ | 166 | #define IOSTATE_WAITING 3 /* overlapped I/O has finished, but is waiting for it's write-partner */ |
167 | 167 | ||
168 | // ReOpenFile is only available as of XP SP2 and 2003 SP1 | 168 | /** |
169 | * ReOpenFile is only available as of XP SP2 and 2003 SP1 | ||
170 | */ | ||
169 | WINBASEAPI HANDLE WINAPI ReOpenFile (HANDLE, DWORD, DWORD, DWORD); | 171 | WINBASEAPI HANDLE WINAPI ReOpenFile (HANDLE, DWORD, DWORD, DWORD); |
170 | 172 | ||
171 | /** | 173 | /** |
@@ -401,7 +403,7 @@ setup_interface () | |||
401 | class_name, | 403 | class_name, |
402 | &class_guid, | 404 | &class_guid, |
403 | NULL, | 405 | NULL, |
404 | NULL, | 406 | 0, |
405 | DICD_GENERATE_ID, | 407 | DICD_GENERATE_ID, |
406 | &DeviceNode)) | 408 | &DeviceNode)) |
407 | return FALSE; | 409 | return FALSE; |
@@ -411,15 +413,22 @@ setup_interface () | |||
411 | &DeviceNode, | 413 | &DeviceNode, |
412 | SPDRP_HARDWAREID, | 414 | SPDRP_HARDWAREID, |
413 | (LPBYTE) hwidlist, | 415 | (LPBYTE) hwidlist, |
414 | (strlen (hwidlist) + 2) * sizeof (char))) | 416 | (lstrlenA (hwidlist) + 2) * sizeof (char))) |
415 | return FALSE; | 417 | return FALSE; |
416 | 418 | ||
417 | /* Install our new class(=device) into the system */ | 419 | /* Install our new class(=device) into the system */ |
418 | if (!SetupDiCallClassInstaller (DIF_REGISTERDEVICE, | 420 | if (!SetupDiCallClassInstaller (DIF_REGISTERDEVICE, |
419 | DeviceInfo, | 421 | DeviceInfo, |
420 | &DeviceNode)) | 422 | &DeviceNode)) |
421 | return FALSE; | 423 | return FALSE; |
422 | 424 | ||
425 | if(!UpdateDriverForPlugAndPlayDevicesA(NULL, | ||
426 | HARDWARE_ID, // I can haz secondary HWID too? | ||
427 | inf_file_path, | ||
428 | INSTALLFLAG_FORCE | INSTALLFLAG_NONINTERACTIVE, | ||
429 | NULL)) //reboot required? NEVER! | ||
430 | return FALSE; | ||
431 | |||
423 | return TRUE; | 432 | return TRUE; |
424 | } | 433 | } |
425 | 434 | ||
@@ -651,7 +660,7 @@ init_tun () | |||
651 | errno = ENODEV; | 660 | errno = ENODEV; |
652 | return INVALID_HANDLE_VALUE; | 661 | return INVALID_HANDLE_VALUE; |
653 | } | 662 | } |
654 | 663 | ||
655 | /* Open Windows TAP-Windows adapter */ | 664 | /* Open Windows TAP-Windows adapter */ |
656 | snprintf (device_path, sizeof (device_path), "%s%s%s", | 665 | snprintf (device_path, sizeof (device_path), "%s%s%s", |
657 | USERMODEDEVICEDIR, | 666 | USERMODEDEVICEDIR, |
@@ -673,14 +682,14 @@ init_tun () | |||
673 | fprintf (stderr, "CreateFile failed on TAP device: %s\n", device_path); | 682 | fprintf (stderr, "CreateFile failed on TAP device: %s\n", device_path); |
674 | return handle; | 683 | return handle; |
675 | } | 684 | } |
676 | 685 | ||
677 | /* get driver version info */ | 686 | /* get driver version info */ |
678 | if (!check_tapw32_version (handle)) | 687 | if (!check_tapw32_version (handle)) |
679 | { | 688 | { |
680 | CloseHandle (handle); | 689 | CloseHandle (handle); |
681 | return INVALID_HANDLE_VALUE; | 690 | return INVALID_HANDLE_VALUE; |
682 | } | 691 | } |
683 | 692 | ||
684 | /* TODO (opt?): get MTU-Size */ | 693 | /* TODO (opt?): get MTU-Size */ |
685 | 694 | ||
686 | return handle; | 695 | return handle; |