summaryrefslogtreecommitdiffstats
path: root/third_party/rust/winapi/src/um/ws2spi.rs
blob: d26128949164b21ca377454b4c1fc9ca5f2a8e0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
// All files in the project carrying such notice may not be copied, modified, or distributed
// except according to those terms.
//! Definitions to be used with the WinSock service provider.
use ctypes::{c_char, c_int, c_long, c_uint};
use shared::basetsd::{DWORD_PTR, PDWORD_PTR, ULONG_PTR};
use shared::guiddef::{GUID, LPGUID};
use shared::minwindef::{
    BOOL, DWORD, INT, LPARAM, LPDWORD, LPHANDLE, LPINT, LPVOID, PBYTE, UINT, WORD, WPARAM,
};
use shared::windef::HWND;
use shared::ws2def::{LPSOCKADDR, LPWSABUF, SOCKADDR};
use shared::wtypesbase::LPBLOB;
use um::winnt::{HANDLE, LPCWSTR, LPWSTR, PVOID, WCHAR};
use um::winsock2::{
    GROUP, LPCONDITIONPROC, LPQOS, LPWSACOMPLETION, LPWSANETWORKEVENTS, LPWSAOVERLAPPED,
    LPWSAOVERLAPPED_COMPLETION_ROUTINE, LPWSAPROTOCOL_INFOW, LPWSAQUERYSET2W, LPWSAQUERYSETW,
    LPWSASERVICECLASSINFOW, SOCKET, WSAESETSERVICEOP, WSAEVENT, fd_set, timeval,
};
#[cfg(target_pointer_width = "64")]
use um::winsock2::{LPWSANAMESPACE_INFOEXW, LPWSANAMESPACE_INFOW};
use vc::vcruntime::size_t;
pub const WSPDESCRIPTION_LEN: usize = 255;
pub const WSS_OPERATION_IN_PROGRESS: ULONG_PTR = 0x00000103;
STRUCT!{struct WSPDATA {
    wVersion: WORD,
    wHighVersion: WORD,
    szDescription: [WCHAR; WSPDESCRIPTION_LEN + 1],
}}
pub type LPWSPDATA = *mut WSPDATA;
STRUCT!{struct WSATHREADID {
    ThreadHandle: HANDLE,
    Reserved: DWORD_PTR,
}}
pub type LPWSATHREADID = *mut WSATHREADID;
FN!{stdcall LPBLOCKINGCALLBACK(
    dwContext: DWORD_PTR,
) -> BOOL}
FN!{stdcall LPWSAUSERAPC(
    dwContext: DWORD_PTR,
) -> ()}
FN!{stdcall LPWSPACCEPT(
    s: SOCKET,
    addr: *mut SOCKADDR,
    addrlen: LPINT,
    lpfnCondition: LPCONDITIONPROC,
    dwCallbackData: DWORD_PTR,
    lpErrno: LPINT,
) -> SOCKET}
FN!{stdcall LPWSPADDRESSTOSTRING(
    lpsaAddress: LPSOCKADDR,
    dwAddressLength: DWORD,
    lpProtocolInfo: LPWSAPROTOCOL_INFOW,
    lpszAddressString: LPWSTR,
    lpdwAddressStringLength: LPDWORD,
    lpErrno: LPINT,
) -> INT}
FN!{stdcall LPWSPASYNCSELECT(
    s: SOCKET,
    hWnd: HWND,
    wMsg: c_uint,
    lEvent: c_long,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPBIND(
    s: SOCKET,
    name: *mut SOCKADDR,
    namelen: c_int,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPCANCELBLOCKINGCALL(
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPCLEANUP(
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPCLOSESOCKET(
    s: SOCKET,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPCONNECT(
    s: SOCKET,
    name: *mut SOCKADDR,
    namelen: c_int,
    lpCallerData: LPWSABUF,
    lpCalleeData: LPWSABUF,
    lpSQOS: LPQOS,
    lpGQOS: LPQOS,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPDUPLICATESOCKET(
    s: SOCKET,
    dwProcessId: DWORD,
    lpProtocolInfo: LPWSAPROTOCOL_INFOW,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPENUMNETWORKEVENTS(
    s: SOCKET,
    hEventObject: WSAEVENT,
    lpNetworkEvents: LPWSANETWORKEVENTS,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPEVENTSELECT(
    s: SOCKET,
    hEventObject: WSAEVENT,
    lNetworkEvents: c_long,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPGETOVERLAPPEDRESULT(
    s: SOCKET,
    lpOverlapped: LPWSAOVERLAPPED,
    lpcbTransfer: LPDWORD,
    fWait: BOOL,
    lpdwFlags: LPDWORD,
    lpErrno: LPINT,
) -> BOOL}
FN!{stdcall LPWSPGETPEERNAME(
    s: SOCKET,
    name: *mut SOCKADDR,
    namelen: LPINT,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPGETSOCKNAME(
    s: SOCKET,
    name: *mut SOCKADDR,
    namelen: LPINT,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPGETSOCKOPT(
    s: SOCKET,
    level: c_int,
    optname: c_int,
    optval: *mut c_char,
    optlen: LPINT,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPGETQOSBYNAME(
    s: SOCKET,
    lpQOSName: LPWSABUF,
    lpQOS: LPQOS,
    lpErrno: LPINT,
) -> BOOL}
FN!{stdcall LPWSPIOCTL(
    s: SOCKET,
    dwIoControlCode: DWORD,
    lpvInBuffer: LPVOID,
    cbInBuffer: DWORD,
    lpvOutBuffer: LPVOID,
    cbOutBuffer: DWORD,
    lpcbBytesReturned: LPDWORD,
    lpOverlapped: LPWSAOVERLAPPED,
    lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
    lpThreadId: LPWSATHREADID,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPJOINLEAF(
    s: SOCKET,
    name: *mut SOCKADDR,
    namelen: c_int,
    lpCallerData: LPWSABUF,
    lpCalleeData: LPWSABUF,
    lpSQOS: LPQOS,
    lpGQOS: LPQOS,
    dwFlags: DWORD,
    lpErrno: LPINT,
) -> SOCKET}
FN!{stdcall LPWSPLISTEN(
    s: SOCKET,
    backlog: c_int,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPRECV(
    s: SOCKET,
    lpBuffers: LPWSABUF,
    dwBufferCount: DWORD,
    lpNumberOfBytesRecvd: LPDWORD,
    lpFlags: LPDWORD,
    lpOverlapped: LPWSAOVERLAPPED,
    lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
    lpThreadId: LPWSATHREADID,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPRECVDISCONNECT(
    s: SOCKET,
    lpInboundDisconnectData: LPWSABUF,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPRECVFROM(
    s: SOCKET,
    lpBuffers: LPWSABUF,
    dwBufferCount: DWORD,
    lpNumberOfBytesRecvd: LPDWORD,
    lpFlags: LPDWORD,
    lpFrom: *mut SOCKADDR,
    lpFromlen: LPINT,
    lpOverlapped: LPWSAOVERLAPPED,
    lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
    lpThreadId: LPWSATHREADID,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPSELECT(
    nfds: c_int,
    readfds: *mut fd_set,
    writefds: *mut fd_set,
    exceptfds: *mut fd_set,
    timeout: *const timeval,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPSEND(
    s: SOCKET,
    lpBuffers: LPWSABUF,
    dwBufferCount: DWORD,
    lpNumberOfBytesSent: LPDWORD,
    dwFlags: DWORD,
    lpOverlapped: LPWSAOVERLAPPED,
    lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
    lpThreadId: LPWSATHREADID,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPSENDDISCONNECT(
    s: SOCKET,
    lpOutboundDisconnectData: LPWSABUF,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPSENDTO(
    s: SOCKET,
    lpBuffers: LPWSABUF,
    dwBufferCount: DWORD,
    lpNumberOfBytesSent: LPDWORD,
    dwFlags: DWORD,
    lpTo: *const SOCKADDR,
    iTolen: c_int,
    lpOverlapped: LPWSAOVERLAPPED,
    lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
    lpThreadId: LPWSATHREADID,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPSETSOCKOPT(
    s: SOCKET,
    level: c_int,
    optname: c_int,
    optval: *const c_char,
    optlen: c_int,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPSHUTDOWN(
    s: SOCKET,
    how: c_int,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWSPSOCKET(
    af: c_int,
    _type: c_int,
    protocol: c_int,
    lpProtocolInfo: LPWSAPROTOCOL_INFOW,
    g: GROUP,
    dwFlags: DWORD,
    lpErrno: LPINT,
) -> SOCKET}
FN!{stdcall LPWSPSTRINGTOADDRESS(
    AddressString: LPWSTR,
    AddressFamily: INT,
    lpProtocolInfo: LPWSAPROTOCOL_INFOW,
    lpAddress: LPSOCKADDR,
    lpAddressLength: LPINT,
    lpErrno: LPINT,
) -> c_int}
STRUCT!{struct WSPPROC_TABLE {
    lpWSPAccept: LPWSPACCEPT,
    lpWSPAddressToString: LPWSPADDRESSTOSTRING,
    lpWSPAsyncSelect: LPWSPASYNCSELECT,
    lpWSPBind: LPWSPBIND,
    lpWSPCancelBlockingCall: LPWSPCANCELBLOCKINGCALL,
    lpWSPCleanup: LPWSPCLEANUP,
    lpWSPCloseSocket: LPWSPCLOSESOCKET,
    lpWSPConnect: LPWSPCONNECT,
    lpWSPDuplicateSocket: LPWSPDUPLICATESOCKET,
    lpWSPEnumNetworkEvents: LPWSPENUMNETWORKEVENTS,
    lpWSPEventSelect: LPWSPEVENTSELECT,
    lpWSPGetOverlappedResult: LPWSPGETOVERLAPPEDRESULT,
    lpWSPGetPeerName: LPWSPGETPEERNAME,
    lpWSPGetSockName: LPWSPGETSOCKNAME,
    lpWSPGetSockOpt: LPWSPGETSOCKOPT,
    lpWSPGetQOSByName: LPWSPGETQOSBYNAME,
    lpWSPIoctl: LPWSPIOCTL,
    lpWSPJoinLeaf: LPWSPJOINLEAF,
    lpWSPListen: LPWSPLISTEN,
    lpWSPRecv: LPWSPRECV,
    lpWSPRecvDisconnect: LPWSPRECVDISCONNECT,
    lpWSPRecvFrom: LPWSPRECVFROM,
    lpWSPSelect: LPWSPSELECT,
    lpWSPSend: LPWSPSEND,
    lpWSPSendDisconnect: LPWSPSENDDISCONNECT,
    lpWSPSendTo: LPWSPSENDTO,
    lpWSPSetSockOpt: LPWSPSETSOCKOPT,
    lpWSPShutdown: LPWSPSHUTDOWN,
    lpWSPSocket: LPWSPSOCKET,
    lpWSPStringToAddress: LPWSPSTRINGTOADDRESS,
}}
pub type LPWSPPROC_TABLE = *mut WSPPROC_TABLE;
FN!{stdcall LPWPUCLOSEEVENT(
    hEvent: WSAEVENT,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWPUCLOSESOCKETHANDLE(
    s: SOCKET,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWPUCREATEEVENT(
    lpErrno: LPINT,
) -> WSAEVENT}
FN!{stdcall LPWPUCREATESOCKETHANDLE(
    dwCatalogEntryId: DWORD,
    dwContext: DWORD_PTR,
    lpErrno: LPINT,
) -> SOCKET}
FN!{stdcall LPWPUFDISSET(
    s: SOCKET,
    fdset: *mut fd_set,
) -> c_int}
FN!{stdcall LPWPUGETPROVIDERPATH(
    lpProviderId: LPGUID,
    lpszProviderDllPath: *mut WCHAR,
    lpProviderDllPathLen: LPINT,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWPUMODIFYIFSHANDLE(
    dwCatalogEntryId: DWORD,
    ProposedHandle: SOCKET,
    lpErrno: LPINT,
) -> SOCKET}
FN!{stdcall LPWPUPOSTMESSAGE(
    hWnd: HWND,
    Msg: UINT,
    wParam: WPARAM,
    lParam: LPARAM,
) -> BOOL}
FN!{stdcall LPWPUQUERYBLOCKINGCALLBACK(
    dwCatalogEntryId: DWORD,
    lplpfnCallback: *mut LPBLOCKINGCALLBACK,
    lpdwContext: PDWORD_PTR,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWPUQUERYSOCKETHANDLECONTEXT(
    s: SOCKET,
    lpContext: PDWORD_PTR,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWPUQUEUEAPC(
    lpThreadId: LPWSATHREADID,
    lpfnUserApc: LPWSAUSERAPC,
    dwContext: DWORD_PTR,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWPURESETEVENT(
    hEvent: WSAEVENT,
    lpErrno: LPINT,
) -> BOOL}
FN!{stdcall LPWPUSETEVENT(
    hEvent: WSAEVENT,
    lpErrno: LPINT,
) -> BOOL}
FN!{stdcall LPWPUOPENCURRENTTHREAD(
    lpThreadId: LPWSATHREADID,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWPUCLOSETHREAD(
    lpThreadId: LPWSATHREADID,
    lpErrno: LPINT,
) -> c_int}
FN!{stdcall LPWPUCOMPLETEOVERLAPPEDREQUEST(
    s: SOCKET,
    lpOverlapped: LPWSAOVERLAPPED,
    dwError: DWORD,
    cbTransferred: DWORD,
    lpErrno: LPINT,
) -> c_int}
STRUCT!{struct WSPUPCALLTABLE {
    lpWPUCloseEvent: LPWPUCLOSEEVENT,
    lpWPUCloseSocketHandle: LPWPUCLOSESOCKETHANDLE,
    lpWPUCreateEvent: LPWPUCREATEEVENT,
    lpWPUCreateSocketHandle: LPWPUCREATESOCKETHANDLE,
    lpWPUFDIsSet: LPWPUFDISSET,
    lpWPUGetProviderPath: LPWPUGETPROVIDERPATH,
    lpWPUModifyIFSHandle: LPWPUMODIFYIFSHANDLE,
    lpWPUPostMessage: LPWPUPOSTMESSAGE,
    lpWPUQueryBlockingCallback: LPWPUQUERYBLOCKINGCALLBACK,
    lpWPUQuerySocketHandleContext: LPWPUQUERYSOCKETHANDLECONTEXT,
    lpWPUQueueApc: LPWPUQUEUEAPC,
    lpWPUResetEvent: LPWPURESETEVENT,
    lpWPUSetEvent: LPWPUSETEVENT,
    lpWPUOpenCurrentThread: LPWPUOPENCURRENTTHREAD,
    lpWPUCloseThread: LPWPUCLOSETHREAD,
}}
pub type LPWSPUPCALLTABLE = *mut WSPUPCALLTABLE;
extern "system" {
    pub fn WSPStartup(
        wVersionRequested: WORD,
        lpWSPData: LPWSPDATA,
        lpProtocolInfo: LPWSAPROTOCOL_INFOW,
        UpcallTable: WSPUPCALLTABLE,
        lpProcTable: LPWSPPROC_TABLE,
    ) -> c_int;
}
FN!{stdcall LPWSPSTARTUP(
    wVersionRequested: WORD,
    lpWSPData: LPWSPDATA,
    lpProtocolInfo: LPWSAPROTOCOL_INFOW,
    UpcallTable: WSPUPCALLTABLE,
    lpProcTable: LPWSPPROC_TABLE,
) -> c_int}
extern "system" {
    pub fn WSCEnumProtocols(
        lpiProtocols: LPINT,
        lpProtocolBuffer: LPWSAPROTOCOL_INFOW,
        lpdwBufferLength: LPDWORD,
        lpErrno: LPINT,
    ) -> c_int;
}
FN!{stdcall LPWSCENUMPROTOCOLS(
    lpiProtocols: LPINT,
    lpProtocolBuffer: LPWSAPROTOCOL_INFOW,
    lpdwBufferLength: LPDWORD,
    lpErrno: LPINT,
) -> c_int}
extern "system" {
    #[cfg(target_pointer_width = "64")]
    pub fn WSCEnumProtocols32(
        lpiProtocols: LPINT,
        lpProtocolBuffer: LPWSAPROTOCOL_INFOW,
        lpdwBufferLength: LPDWORD,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WSCDeinstallProvider(
        lpProviderId: LPGUID,
        lpErrno: LPINT,
    ) -> c_int;
}
FN!{stdcall LPWSCDEINSTALLPROVIDER(
    lpProviderId: LPGUID,
    lpErrno: LPINT,
) -> c_int}
extern "system" {
    #[cfg(target_pointer_width = "64")]
    pub fn WSCDeinstallProvider32(
        lpProviderId: LPGUID,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WSCInstallProvider(
        lpProviderId: LPGUID,
        lpszProviderDllPath: *const WCHAR,
        lpProtocolInfoList: LPWSAPROTOCOL_INFOW,
        dwNumberOfEntries: DWORD,
        lpErrno: LPINT,
    ) -> c_int;
}
FN!{stdcall LPWSCINSTALLPROVIDER(
    lpProviderId: LPGUID,
    lpszProviderDllPath: *const WCHAR,
    lpProtocolInfoList: LPWSAPROTOCOL_INFOW,
    dwNumberOfEntries: DWORD,
    lpErrno: LPINT,
) -> c_int}
extern "system" {
    #[cfg(target_pointer_width = "64")]
    pub fn WSCInstallProvider64_32(
        lpProviderId: LPGUID,
        lpszProviderDllPath: *const WCHAR,
        lpProtocolInfoList: LPWSAPROTOCOL_INFOW,
        dwNumberOfEntries: DWORD,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WSCGetProviderPath(
        lpProviderId: LPGUID,
        lpszProviderDllPath: *mut WCHAR,
        lpProviderDllPathLen: LPINT,
        lpErrno: LPINT,
    ) -> c_int;
}
FN!{stdcall LPWSCGETPROVIDERPATH(
    lpProviderId: LPGUID,
    lpszProviderDllPath: *mut WCHAR,
    lpProviderDllPathLen: LPINT,
    lpErrno: LPINT,
) -> c_int}
extern "system" {
    #[cfg(target_pointer_width = "64")]
    pub fn WSCGetProviderPath32(
        lpProviderId: LPGUID,
        lpszProviderDllPath: *mut WCHAR,
        lpProviderDllPathLen: LPINT,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WSCUpdateProvider(
        lpProviderId: LPGUID,
        lpszProviderDllPath: *const WCHAR,
        lpProtocolInfoList: LPWSAPROTOCOL_INFOW,
        dwNumberOfEntries: DWORD,
        lpErrno: LPINT,
    ) -> c_int;
}
FN!{stdcall LPWSCUPDATEPROVIDER(
    lpProviderId: LPGUID,
    lpszProviderDllPath: *const WCHAR,
    lpProtocolInfoList: LPWSAPROTOCOL_INFOW,
    dwNumberOfEntries: DWORD,
    lpErrno: LPINT,
) -> c_int}
#[cfg(target_pointer_width = "64")]
extern "system" {
    pub fn WSCUpdateProvider32(
        lpProviderId: LPGUID,
        lpszProviderDllPath: *const WCHAR,
        lpProtocolInfoList: LPWSAPROTOCOL_INFOW,
        dwNumberOfEntries: DWORD,
        lpErrno: LPINT,
    ) -> c_int;
}
pub const LSP_SYSTEM: DWORD = 0x80000000;
pub const LSP_INSPECTOR: DWORD = 0x00000001;
pub const LSP_REDIRECTOR: DWORD = 0x00000002;
pub const LSP_PROXY: DWORD = 0x00000004;
pub const LSP_FIREWALL: DWORD = 0x00000008;
pub const LSP_INBOUND_MODIFY: DWORD = 0x00000010;
pub const LSP_OUTBOUND_MODIFY: DWORD = 0x00000020;
pub const LSP_CRYPTO_COMPRESS: DWORD = 0x00000040;
pub const LSP_LOCAL_CACHE: DWORD = 0x00000080;
ENUM!{enum WSC_PROVIDER_INFO_TYPE {
    ProviderInfoLspCategories,
    ProviderInfoAudit,
}}
STRUCT!{struct WSC_PROVIDER_AUDIT_INFO {
    RecordSize: DWORD,
    Reserved: PVOID,
}}
extern "system" {
    pub fn WSCSetProviderInfo(
        lpProviderId: LPGUID,
        InfoType: WSC_PROVIDER_INFO_TYPE,
        Info: PBYTE,
        InfoSize: size_t,
        Flags: DWORD,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WSCGetProviderInfo(
        lpProviderId: LPGUID,
        InfoType: WSC_PROVIDER_INFO_TYPE,
        Info: PBYTE,
        InfoSize: *mut size_t,
        Flags: DWORD,
        lpErrno: LPINT,
    ) -> c_int;
    #[cfg(target_pointer_width = "64")]
    pub fn WSCSetProviderInfo32(
        lpProviderId: LPGUID,
        InfoType: WSC_PROVIDER_INFO_TYPE,
        Info: PBYTE,
        InfoSize: size_t,
        Flags: DWORD,
        lpErrno: LPINT,
    ) -> c_int;
    #[cfg(target_pointer_width = "64")]
    pub fn WSCGetProviderInfo32(
        lpProviderId: LPGUID,
        InfoType: WSC_PROVIDER_INFO_TYPE,
        Info: PBYTE,
        InfoSize: *mut size_t,
        Flags: DWORD,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WSCSetApplicationCategory(
        Path: LPCWSTR,
        PathLength: DWORD,
        Extra: LPCWSTR,
        ExtraLength: DWORD,
        PermittedLspCategories: DWORD,
        pPrevPermLspCat: *mut DWORD,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WSCGetApplicationCategory(
        Path: LPCWSTR,
        PathLength: DWORD,
        Extra: LPCWSTR,
        ExtraLength: DWORD,
        pPermittedLspCategories: *mut DWORD,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WPUCloseEvent(
        hEvent: WSAEVENT,
        lpErrno: LPINT,
    ) -> BOOL;
    pub fn WPUCloseSocketHandle(
        s: SOCKET,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WPUCreateEvent(
        lpErrno: LPINT,
    ) -> WSAEVENT;
    pub fn WPUCreateSocketHandle(
        dwCatalogEntryId: DWORD,
        dwContext: DWORD_PTR,
        lpErrno: LPINT,
    ) -> SOCKET;
    pub fn WPUFDIsSet(
        s: SOCKET,
        fdset: *mut fd_set,
    ) -> c_int;
    pub fn WPUGetProviderPath(
        lpProviderId: LPGUID,
        lpszProviderDllPath: *mut WCHAR,
        lpProviderDllPathLen: LPINT,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WPUModifyIFSHandle(
        dwCatalogEntryId: DWORD,
        ProposedHandle: SOCKET,
        lpErrno: LPINT,
    ) -> SOCKET;
    pub fn WPUPostMessage(
        hWnd: HWND,
        Msg: UINT,
        wParam: WPARAM,
        lParam: LPARAM,
    ) -> BOOL;
    pub fn WPUQueryBlockingCallback(
        dwCatalogEntryId: DWORD,
        lplpfnCallback: *mut LPBLOCKINGCALLBACK,
        lpdwContext: PDWORD_PTR,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WPUQuerySocketHandleContext(
        s: SOCKET,
        lpContext: PDWORD_PTR,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WPUQueueApc(
        lpThreadId: LPWSATHREADID,
        lpfnUserApc: LPWSAUSERAPC,
        dwContext: DWORD_PTR,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WPUResetEvent(
        hEvent: WSAEVENT,
        lpErrno: LPINT,
    ) -> BOOL;
    pub fn WPUSetEvent(
        hEvent: WSAEVENT,
        lpErrno: LPINT,
    ) -> BOOL;
    pub fn WPUCompleteOverlappedRequest(
        s: SOCKET,
        lpOverlapped: LPWSAOVERLAPPED,
        dwError: DWORD,
        cbTransferred: DWORD,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WPUOpenCurrentThread(
        lpThreadId: LPWSATHREADID,
        lpErrno: LPINT,
    ) -> c_int;
    pub fn WPUCloseThread(
        lpThreadId: LPWSATHREADID,
        lpErrno: LPINT,
    ) -> c_int;
    #[cfg(target_pointer_width = "64")]
    pub fn WSCEnumNameSpaceProviders32(
        lpdwBufferLength: LPDWORD,
        lpnspBuffer: LPWSANAMESPACE_INFOW,
    ) -> INT;
    #[cfg(target_pointer_width = "64")]
    pub fn WSCEnumNameSpaceProvidersEx32(
        lpdwBufferLength: LPDWORD,
        lpnspBuffer: LPWSANAMESPACE_INFOEXW,
    ) -> INT;
    pub fn WSCInstallNameSpace(
        lpszIdentifier: LPWSTR,
        lpszPathName: LPWSTR,
        dwNameSpace: DWORD,
        dwVersion: DWORD,
        lpProviderId: LPGUID,
    ) -> INT;
}
FN!{stdcall LPWSCINSTALLNAMESPACE(
    lpszIdentifier: LPWSTR,
    lpszPathName: LPWSTR,
    dwNameSpace: DWORD,
    dwVersion: DWORD,
    lpProviderId: LPGUID,
) -> INT}
extern "system" {
    #[cfg(target_pointer_width = "64")]
    pub fn WSCInstallNameSpace32(
        lpszIdentifier: LPWSTR,
        lpszPathName: LPWSTR,
        dwNameSpace: DWORD,
        dwVersion: DWORD,
        lpProviderId: LPGUID,
    ) -> INT;
    pub fn WSCUnInstallNameSpace(
        lpProviderId: LPGUID,
    ) -> INT;
}
FN!{stdcall LPWSCUNINSTALLNAMESPACE(
    lpProviderId: LPGUID,
) -> INT}
extern "system" {
    pub fn WSCInstallNameSpaceEx(
        lpszIdentifier: LPWSTR,
        lpszPathName: LPWSTR,
        dwNameSpace: DWORD,
        dwVersion: DWORD,
        lpProviderId: LPGUID,
        lpProviderSpecific: LPBLOB,
    ) -> INT;
    #[cfg(target_pointer_width = "64")]
    pub fn WSCInstallNameSpaceEx32(
        lpszIdentifier: LPWSTR,
        lpszPathName: LPWSTR,
        dwNameSpace: DWORD,
        dwVersion: DWORD,
        lpProviderId: LPGUID,
        lpProviderSpecific: LPBLOB,
    ) -> INT;
    #[cfg(target_pointer_width = "64")]
    pub fn WSCUnInstallNameSpace32(
        lpProviderId: LPGUID,
    ) -> INT;
    pub fn WSCEnableNSProvider(
        lpProviderId: LPGUID,
        fEnable: BOOL,
    ) -> INT;
}
FN!{stdcall LPWSCENABLENSPROVIDER(
    lpProviderId: LPGUID,
    fEnable: BOOL,
) -> INT}
extern "system" {
    #[cfg(target_pointer_width = "64")]
    pub fn WSCEnableNSProvider32(
        lpProviderId: LPGUID,
        fEnable: BOOL,
    ) -> INT;
    #[cfg(target_pointer_width = "64")]
    pub fn WSCInstallProviderAndChains64_32(
        lpProviderId: LPGUID,
        lpszProviderDllPath: LPWSTR,
        lpszProviderDllPath32: LPWSTR,
        lpszLspName: LPWSTR,
        dwServiceFlags: DWORD,
        lpProtocolInfoList: LPWSAPROTOCOL_INFOW,
        dwNumberOfEntries: DWORD,
        lpdwCatalogEntryId: LPDWORD,
        lpErrno: LPINT,
    ) -> c_int;
    #[cfg(target_pointer_width = "32")]
    pub fn WSCInstallProviderAndChains(
        lpProviderId: LPGUID,
        lpszProviderDllPath: LPWSTR,
        lpszLspName: LPWSTR,
        dwServiceFlags: DWORD,
        lpProtocolInfoList: LPWSAPROTOCOL_INFOW,
        dwNumberOfEntries: DWORD,
        lpdwCatalogEntryId: LPDWORD,
        lpErrno: LPINT,
    ) -> c_int;
}
FN!{stdcall LPNSPCLEANUP(
    lpProviderId: LPGUID,
) -> INT}
FN!{stdcall LPNSPLOOKUPSERVICEBEGIN(
    lpProviderId: LPGUID,
    lpqsRestrictions: LPWSAQUERYSETW,
    lpServiceClassInfo: LPWSASERVICECLASSINFOW,
    dwControlFlags: DWORD,
    lphLookup: LPHANDLE,
) -> INT}
FN!{stdcall LPNSPLOOKUPSERVICENEXT(
    hLookup: HANDLE,
    dwControlFlags: DWORD,
    lpdwBufferLength: LPDWORD,
    lpqsResults: LPWSAQUERYSETW,
) -> INT}
FN!{stdcall LPNSPIOCTL(
    hLookup: HANDLE,
    dwControlCode: DWORD,
    lpvInBuffer: LPVOID,
    cbInBuffer: DWORD,
    lpvOutBuffer: LPVOID,
    cbOutBuffer: DWORD,
    lpcbBytesReturned: LPDWORD,
    lpCompletion: LPWSACOMPLETION,
    lpThreadId: LPWSATHREADID,
) -> INT}
FN!{stdcall LPNSPLOOKUPSERVICEEND(
    hLookup: HANDLE,
) -> INT}
FN!{stdcall LPNSPSETSERVICE(
    lpProviderId: LPGUID,
    lpServiceClassInfo: LPWSASERVICECLASSINFOW,
    lpqsRegInfo: LPWSAQUERYSETW,
    essOperation: WSAESETSERVICEOP,
    dwControlFlags: DWORD,
) -> INT}
FN!{stdcall LPNSPINSTALLSERVICECLASS(
    lpProviderId: LPGUID,
    lpServiceClassInfo: LPWSASERVICECLASSINFOW,
) -> INT}
FN!{stdcall LPNSPREMOVESERVICECLASS(
    lpProviderId: LPGUID,
    lpServiceClassId: LPGUID,
) -> INT}
FN!{stdcall LPNSPGETSERVICECLASSINFO(
    lpProviderId: LPGUID,
    lpdwBufSize: LPDWORD,
    lpServiceClassInfo: LPWSASERVICECLASSINFOW,
) -> INT}
STRUCT!{struct NSP_ROUTINE {
    cbSize: DWORD,
    dwMajorVersion: DWORD,
    dwMinorVersion: DWORD,
    NSPCleanup: LPNSPCLEANUP,
    NSPLookupServiceBegin: LPNSPLOOKUPSERVICEBEGIN,
    NSPLookupServiceNext: LPNSPLOOKUPSERVICENEXT,
    NSPLookupServiceEnd: LPNSPLOOKUPSERVICEEND,
    NSPSetService: LPNSPSETSERVICE,
    NSPInstallServiceClass: LPNSPINSTALLSERVICECLASS,
    NSPRemoveServiceClass: LPNSPREMOVESERVICECLASS,
    NSPGetServiceClassInfo: LPNSPGETSERVICECLASSINFO,
    NSPIoctl: LPNSPIOCTL,
}}
pub type LPNSP_ROUTINE = *mut NSP_ROUTINE;
extern "system" {
    pub fn NSPStartup(
        lpProviderId: LPGUID,
        lpnspRoutines: LPNSP_ROUTINE,
    ) -> INT;
}
FN!{stdcall LPNSPSTARTUP(
    lpProviderId: LPGUID,
    lpnspRoutines: LPNSP_ROUTINE,
) -> INT}
FN!{stdcall LPNSPV2STARTUP(
    lpProviderId: LPGUID,
    ppvClientSessionArg: *mut LPVOID,
) -> INT}
FN!{stdcall LPNSPV2CLEANUP(
    lpProviderId: LPGUID,
    pvClientSessionArg: LPVOID,
) -> INT}
FN!{stdcall LPNSPV2LOOKUPSERVICEBEGIN(
    lpProviderId: LPGUID,
    lpqsRestrictions: LPWSAQUERYSET2W,
    dwControlFlags: DWORD,
    lpvClientSessionArg: LPVOID,
    lphLookup: LPHANDLE,
) -> INT}
FN!{stdcall LPNSPV2LOOKUPSERVICENEXTEX(
    hAsyncCall: HANDLE,
    hLookup: HANDLE,
    dwControlFlags: DWORD,
    lpdwBufferLength: LPDWORD,
    lpqsResults: LPWSAQUERYSET2W,
) -> ()}
FN!{stdcall LPNSPV2LOOKUPSERVICEEND(
    hLookup: HANDLE,
) -> INT}
FN!{stdcall LPNSPV2SETSERVICEEX(
    hAsyncCall: HANDLE,
    lpProviderId: LPGUID,
    lpqsRegInfo: LPWSAQUERYSET2W,
    essOperation: WSAESETSERVICEOP,
    dwControlFlags: DWORD,
    lpvClientSessionArg: LPVOID,
) -> ()}
FN!{stdcall LPNSPV2CLIENTSESSIONRUNDOWN(
    lpProviderId: LPGUID,
    pvClientSessionArg: LPVOID,
) -> ()}
STRUCT!{struct NSPV2_ROUTINE {
    cbSize: DWORD,
    dwMajorVersion: DWORD,
    dwMinorVersion: DWORD,
    NSPv2Startup: LPNSPV2STARTUP,
    NSPv2Cleanup: LPNSPV2CLEANUP,
    NSPv2LookupServiceBegin: LPNSPV2LOOKUPSERVICEBEGIN,
    NSPv2LookupServiceNextEx: LPNSPV2LOOKUPSERVICENEXTEX,
    NSPv2LookupServiceEnd: LPNSPV2LOOKUPSERVICEEND,
    NSPv2SetServiceEx: LPNSPV2SETSERVICEEX,
    NSPv2ClientSessionRundown: LPNSPV2CLIENTSESSIONRUNDOWN,
}}
pub type PNSPV2_ROUTINE = *mut NSPV2_ROUTINE;
pub type LPNSPV2_ROUTINE = *mut NSPV2_ROUTINE;
pub type PCNSPV2_ROUTINE = *const NSPV2_ROUTINE;
pub type LPCNSPV2_ROUTINE = *const NSPV2_ROUTINE;
extern "system" {
    pub fn WSAAdvertiseProvider(
        puuidProviderId: *const GUID,
        pNSPv2Routine: *const LPCNSPV2_ROUTINE,
    ) -> INT;
    pub fn WSAUnadvertiseProvider(
        puuidProviderId: *const GUID,
    ) -> INT;
    pub fn WSAProviderCompleteAsyncCall(
        hAsyncCall: HANDLE,
        iRetCode: INT,
    ) -> INT;
}