diff options
author | LRN <lrn1986@gmail.com> | 2013-12-19 18:39:09 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2013-12-19 18:39:09 +0000 |
commit | bbfebd03c83c09915c23470944533c8d6c611a1e (patch) | |
tree | f3748ebb8236f5b5a3d8c5b2ba486596ba3c33c1 /src/gns | |
parent | d36bd0d011441ddd76f7136b4a59bf98687c236b (diff) | |
download | gnunet-bbfebd03c83c09915c23470944533c8d6c611a1e.tar.gz gnunet-bbfebd03c83c09915c23470944533c8d6c611a1e.zip |
Fudge includes to prevent GUID leaks, make non-exported functions static, use mingw-w64-provided definitions for NSP
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/w32nsp.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/gns/w32nsp.c b/src/gns/w32nsp.c index fcd922560..9737c7502 100644 --- a/src/gns/w32nsp.c +++ b/src/gns/w32nsp.c | |||
@@ -26,7 +26,6 @@ | |||
26 | * "Network Programming For Microsoft Windows, 2Nd Edition". | 26 | * "Network Programming For Microsoft Windows, 2Nd Edition". |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #define INITGUID | ||
30 | #include <stdint.h> | 29 | #include <stdint.h> |
31 | #include <ws2tcpip.h> | 30 | #include <ws2tcpip.h> |
32 | #include <ws2spi.h> | 31 | #include <ws2spi.h> |
@@ -69,8 +68,10 @@ | |||
69 | #endif | 68 | #endif |
70 | #endif | 69 | #endif |
71 | #endif | 70 | #endif |
72 | #include "gnunet_w32nsp_lib.h" | ||
73 | #include "w32resolver.h" | 71 | #include "w32resolver.h" |
72 | #define INITGUID | ||
73 | #include "gnunet_w32nsp_lib.h" | ||
74 | #undef INITGUID | ||
74 | 75 | ||
75 | #define NSPAPI_VERSION_MAJOR 4 | 76 | #define NSPAPI_VERSION_MAJOR 4 |
76 | #define NSPAPI_VERSION_MINOR 4 | 77 | #define NSPAPI_VERSION_MINOR 4 |
@@ -82,7 +83,7 @@ | |||
82 | #define STATE_REPLY 0x04 | 83 | #define STATE_REPLY 0x04 |
83 | #define STATE_GHBN 0x08 | 84 | #define STATE_GHBN 0x08 |
84 | 85 | ||
85 | CRITICAL_SECTION records_cs; | 86 | static CRITICAL_SECTION records_cs; |
86 | 87 | ||
87 | struct record | 88 | struct record |
88 | { | 89 | { |
@@ -97,7 +98,7 @@ static struct record *records = NULL; | |||
97 | static size_t records_len = 0; | 98 | static size_t records_len = 0; |
98 | static size_t records_size = 0; | 99 | static size_t records_size = 0; |
99 | 100 | ||
100 | int | 101 | static int |
101 | resize_records () | 102 | resize_records () |
102 | { | 103 | { |
103 | size_t new_size = records_len > 0 ? records_len * 2 : 5; | 104 | size_t new_size = records_len > 0 ? records_len * 2 : 5; |
@@ -115,7 +116,7 @@ resize_records () | |||
115 | return 1; | 116 | return 1; |
116 | } | 117 | } |
117 | 118 | ||
118 | int | 119 | static int |
119 | add_record (SOCKET s, const wchar_t *name, DWORD flags) | 120 | add_record (SOCKET s, const wchar_t *name, DWORD flags) |
120 | { | 121 | { |
121 | int res = 1; | 122 | int res = 1; |
@@ -148,7 +149,7 @@ add_record (SOCKET s, const wchar_t *name, DWORD flags) | |||
148 | return res; | 149 | return res; |
149 | } | 150 | } |
150 | 151 | ||
151 | void | 152 | static void |
152 | free_record (int i) | 153 | free_record (int i) |
153 | { | 154 | { |
154 | if (records[i].name) | 155 | if (records[i].name) |
@@ -267,7 +268,7 @@ send_name_to_ip_request (LPWSAQUERYSETW lpqsRestrictions, | |||
267 | return ret; | 268 | return ret; |
268 | } | 269 | } |
269 | 270 | ||
270 | int WSPAPI | 271 | static int WSPAPI |
271 | NSPCleanup (LPGUID lpProviderId) | 272 | NSPCleanup (LPGUID lpProviderId) |
272 | { | 273 | { |
273 | DEBUGLOG ("NSPCleanup\n"); | 274 | DEBUGLOG ("NSPCleanup\n"); |
@@ -304,7 +305,7 @@ DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) | |||
304 | 305 | ||
305 | 306 | ||
306 | 307 | ||
307 | int WSPAPI | 308 | static int WSPAPI |
308 | GNUNET_W32NSP_LookupServiceBegin (LPGUID lpProviderId, LPWSAQUERYSETW lpqsRestrictions, | 309 | GNUNET_W32NSP_LookupServiceBegin (LPGUID lpProviderId, LPWSAQUERYSETW lpqsRestrictions, |
309 | LPWSASERVICECLASSINFOW lpServiceClassInfo, DWORD dwControlFlags, | 310 | LPWSASERVICECLASSINFOW lpServiceClassInfo, DWORD dwControlFlags, |
310 | LPHANDLE lphLookup) | 311 | LPHANDLE lphLookup) |
@@ -363,7 +364,7 @@ GNUNET_W32NSP_LookupServiceBegin (LPGUID lpProviderId, LPWSAQUERYSETW lpqsRestri | |||
363 | if (ptr) \ | 364 | if (ptr) \ |
364 | ptr = (ptrtype *) (base + (uintptr_t) ptr) | 365 | ptr = (ptrtype *) (base + (uintptr_t) ptr) |
365 | 366 | ||
366 | void | 367 | static void |
367 | UnmarshallWSAQUERYSETW (LPWSAQUERYSETW req) | 368 | UnmarshallWSAQUERYSETW (LPWSAQUERYSETW req) |
368 | { | 369 | { |
369 | int i; | 370 | int i; |
@@ -387,7 +388,7 @@ UnmarshallWSAQUERYSETW (LPWSAQUERYSETW req) | |||
387 | UnmarshallPtr (req->lpBlob->pBlobData, BYTE, base); | 388 | UnmarshallPtr (req->lpBlob->pBlobData, BYTE, base); |
388 | } | 389 | } |
389 | 390 | ||
390 | int WSAAPI | 391 | static int WSAAPI |
391 | GNUNET_W32NSP_LookupServiceNext (HANDLE hLookup, DWORD dwControlFlags, | 392 | GNUNET_W32NSP_LookupServiceNext (HANDLE hLookup, DWORD dwControlFlags, |
392 | LPDWORD lpdwBufferLength, LPWSAQUERYSETW lpqsResults) | 393 | LPDWORD lpdwBufferLength, LPWSAQUERYSETW lpqsResults) |
393 | { | 394 | { |
@@ -558,7 +559,7 @@ GNUNET_W32NSP_LookupServiceNext (HANDLE hLookup, DWORD dwControlFlags, | |||
558 | return NO_ERROR; | 559 | return NO_ERROR; |
559 | } | 560 | } |
560 | 561 | ||
561 | int WSPAPI | 562 | static int WSPAPI |
562 | GNUNET_W32NSP_LookupServiceEnd (HANDLE hLookup) | 563 | GNUNET_W32NSP_LookupServiceEnd (HANDLE hLookup) |
563 | { | 564 | { |
564 | DWORD effective_flags; | 565 | DWORD effective_flags; |
@@ -604,7 +605,7 @@ GNUNET_W32NSP_LookupServiceEnd (HANDLE hLookup) | |||
604 | return NO_ERROR; | 605 | return NO_ERROR; |
605 | } | 606 | } |
606 | 607 | ||
607 | int WSAAPI | 608 | static int WSAAPI |
608 | GNUNET_W32NSP_SetService (LPGUID lpProviderId, | 609 | GNUNET_W32NSP_SetService (LPGUID lpProviderId, |
609 | LPWSASERVICECLASSINFOW lpServiceClassInfo, LPWSAQUERYSETW lpqsRegInfo, | 610 | LPWSASERVICECLASSINFOW lpServiceClassInfo, LPWSAQUERYSETW lpqsRegInfo, |
610 | WSAESETSERVICEOP essOperation, DWORD dwControlFlags) | 611 | WSAESETSERVICEOP essOperation, DWORD dwControlFlags) |
@@ -614,7 +615,7 @@ GNUNET_W32NSP_SetService (LPGUID lpProviderId, | |||
614 | return SOCKET_ERROR; | 615 | return SOCKET_ERROR; |
615 | } | 616 | } |
616 | 617 | ||
617 | int WSAAPI | 618 | static int WSAAPI |
618 | GNUNET_W32NSP_InstallServiceClass (LPGUID lpProviderId, | 619 | GNUNET_W32NSP_InstallServiceClass (LPGUID lpProviderId, |
619 | LPWSASERVICECLASSINFOW lpServiceClassInfo) | 620 | LPWSASERVICECLASSINFOW lpServiceClassInfo) |
620 | { | 621 | { |
@@ -624,7 +625,7 @@ GNUNET_W32NSP_InstallServiceClass (LPGUID lpProviderId, | |||
624 | } | 625 | } |
625 | 626 | ||
626 | 627 | ||
627 | int WSAAPI | 628 | static int WSAAPI |
628 | GNUNET_W32NSP_RemoveServiceClass (LPGUID lpProviderId, LPGUID lpServiceClassId) | 629 | GNUNET_W32NSP_RemoveServiceClass (LPGUID lpProviderId, LPGUID lpServiceClassId) |
629 | { | 630 | { |
630 | DEBUGLOG ("GNUNET_W32NSP_RemoveServiceClass\n"); | 631 | DEBUGLOG ("GNUNET_W32NSP_RemoveServiceClass\n"); |
@@ -632,7 +633,7 @@ GNUNET_W32NSP_RemoveServiceClass (LPGUID lpProviderId, LPGUID lpServiceClassId) | |||
632 | return SOCKET_ERROR; | 633 | return SOCKET_ERROR; |
633 | } | 634 | } |
634 | 635 | ||
635 | int WSAAPI | 636 | static int WSAAPI |
636 | GNUNET_W32NSP_GetServiceClassInfo (LPGUID lpProviderId, LPDWORD lpdwBufSize, | 637 | GNUNET_W32NSP_GetServiceClassInfo (LPGUID lpProviderId, LPDWORD lpdwBufSize, |
637 | LPWSASERVICECLASSINFOW lpServiceClassInfo) | 638 | LPWSASERVICECLASSINFOW lpServiceClassInfo) |
638 | { | 639 | { |
@@ -641,7 +642,7 @@ GNUNET_W32NSP_GetServiceClassInfo (LPGUID lpProviderId, LPDWORD lpdwBufSize, | |||
641 | return SOCKET_ERROR; | 642 | return SOCKET_ERROR; |
642 | } | 643 | } |
643 | 644 | ||
644 | int WSAAPI | 645 | static int WSAAPI |
645 | GNUNET_W32NSP_Ioctl (HANDLE hLookup, DWORD dwControlCode, LPVOID lpvInBuffer, | 646 | GNUNET_W32NSP_Ioctl (HANDLE hLookup, DWORD dwControlCode, LPVOID lpvInBuffer, |
646 | DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, | 647 | DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, |
647 | LPDWORD lpcbBytesReturned, LPWSACOMPLETION lpCompletion, | 648 | LPDWORD lpcbBytesReturned, LPWSACOMPLETION lpCompletion, |
@@ -657,8 +658,8 @@ GNUNET_W32NSP_Ioctl (HANDLE hLookup, DWORD dwControlCode, LPVOID lpvInBuffer, | |||
657 | * It is the only function that [should be/is] exported by the | 658 | * It is the only function that [should be/is] exported by the |
658 | * provider. All other routines are passed as pointers in lpnspRoutines. | 659 | * provider. All other routines are passed as pointers in lpnspRoutines. |
659 | */ | 660 | */ |
660 | int WSPAPI | 661 | int WSAAPI |
661 | NSPStartup (LPGUID lpProviderId, LPNSP_ROUTINE lpnspRoutines) | 662 | GNUNET_W32NSP_NSPStartup (LPGUID lpProviderId, LPNSP_ROUTINE lpnspRoutines) |
662 | { | 663 | { |
663 | if (IsEqualGUID (lpProviderId, &GNUNET_NAMESPACE_PROVIDER_DNS)) | 664 | if (IsEqualGUID (lpProviderId, &GNUNET_NAMESPACE_PROVIDER_DNS)) |
664 | { | 665 | { |
@@ -670,7 +671,7 @@ NSPStartup (LPGUID lpProviderId, LPNSP_ROUTINE lpnspRoutines) | |||
670 | * If it does, you need to use FIELD_OFFSET() macro to get offset of NSPIoctl | 671 | * If it does, you need to use FIELD_OFFSET() macro to get offset of NSPIoctl |
671 | * and use that offset as cbSize. | 672 | * and use that offset as cbSize. |
672 | */ | 673 | */ |
673 | lpnspRoutines->cbSize = sizeof(NSP_ROUTINE_XP); | 674 | lpnspRoutines->cbSize = sizeof(NSP_ROUTINE); |
674 | 675 | ||
675 | lpnspRoutines->dwMajorVersion = NSPAPI_VERSION_MAJOR; | 676 | lpnspRoutines->dwMajorVersion = NSPAPI_VERSION_MAJOR; |
676 | lpnspRoutines->dwMinorVersion = NSPAPI_VERSION_MINOR; | 677 | lpnspRoutines->dwMinorVersion = NSPAPI_VERSION_MINOR; |
@@ -682,7 +683,8 @@ NSPStartup (LPGUID lpProviderId, LPNSP_ROUTINE lpnspRoutines) | |||
682 | lpnspRoutines->NSPInstallServiceClass = GNUNET_W32NSP_InstallServiceClass; | 683 | lpnspRoutines->NSPInstallServiceClass = GNUNET_W32NSP_InstallServiceClass; |
683 | lpnspRoutines->NSPRemoveServiceClass = GNUNET_W32NSP_RemoveServiceClass; | 684 | lpnspRoutines->NSPRemoveServiceClass = GNUNET_W32NSP_RemoveServiceClass; |
684 | lpnspRoutines->NSPGetServiceClassInfo = GNUNET_W32NSP_GetServiceClassInfo; | 685 | lpnspRoutines->NSPGetServiceClassInfo = GNUNET_W32NSP_GetServiceClassInfo; |
685 | ((NSP_ROUTINE_XP *) lpnspRoutines)->NSPIoctl = GNUNET_W32NSP_Ioctl; | 686 | /*((NSP_ROUTINE_XP *) lpnspRoutines)->NSPIoctl = GNUNET_W32NSP_Ioctl;*/ |
687 | lpnspRoutines->NSPIoctl = GNUNET_W32NSP_Ioctl; | ||
686 | return NO_ERROR; | 688 | return NO_ERROR; |
687 | } | 689 | } |
688 | SetLastError (WSAEINVALIDPROVIDER); | 690 | SetLastError (WSAEINVALIDPROVIDER); |