The MASM Forum

General => The Campus => Topic started by: six_L on March 03, 2015, 06:07:08 AM

Title: where is the ConnectEx api?
Post by: six_L on March 03, 2015, 06:07:08 AM
The ConnectEx extension function is a much-needed API available with Windows XP and later versions. This function allows for overlapped connect calls. Previously, the only way to issue multiple connect calls without using one thread for each connect was to use multiple non-blocking connects, which can be cumbersome to manage.
in mswsock.dll?
Title: Re: where is the ConnectEx api?
Post by: AssemblyChallenge on March 03, 2015, 07:27:15 AM
Hi.

Try  here  (https://msdn.microsoft.com/en-us/library/windows/desktop/ms737606%28v=vs.85%29.aspx)

Greetings.
Title: Re: where is the ConnectEx api?
Post by: dedndave on March 03, 2015, 10:20:23 AM
took me a few minutes - lol

https://msdn.microsoft.com/en-us/library/windows/desktop/ms737606%28v=vs.85%29.aspx (https://msdn.microsoft.com/en-us/library/windows/desktop/ms737606%28v=vs.85%29.aspx)

QuoteNote  The function pointer for the ConnectEx function must be obtained at run time by making a
call to the WSAIoctl function with the SIO_GET_EXTENSION_FUNCTION_POINTER opcode specified.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms741621%28v=vs.85%29.aspx (https://msdn.microsoft.com/en-us/library/windows/desktop/ms741621%28v=vs.85%29.aspx)

that'll be $50....
or a beer   :P
Title: Re: where is the ConnectEx api?
Post by: six_L on March 03, 2015, 01:31:40 PM
thanks your responses.
QuoteRequirements
Minimum supported client
   Windows 8.1, Windows Vista [desktop apps only]
Minimum supported server
   Windows Server 2003 [desktop apps only]
Minimum supported phone
   Windows Phone 8
what's means about "desktop apps only" ? another os ver?
Title: Re: where is the ConnectEx api?
Post by: dedndave on March 03, 2015, 06:09:40 PM
first of all, many functions say that a certain minimum OS is required, when it isn't
i guess this is a "required to work as documented"
or
"if you're still using xp, we need you to upgrade because bill gates is so poor"

you can't always believe what it says

QuoteFor applications targeted to Windows Vista and later, consider using the WSAConnectByList
or WSAConnectByName function which greatly simplify client application design.

that kind of implies that ConnectEx is available on pre-Vista OS's   :P

by "desktop apps", they mean not mobile or embedded solutions (tablets, etc)
Title: Re: where is the ConnectEx api?
Post by: six_L on March 04, 2015, 02:17:21 AM
thanks dedndave. :t
QuoteNote  The function pointer for the ConnectEx function must be obtained at run time by making a
call to the WSAIoctl function with the SIO_GET_EXTENSION_FUNCTION_POINTER opcode specified.
SIO_GET_EXTENSION_FUNCTION_POINTER equ IOC_INOUT or IOC_WS2 or 6
proto_ConnectEx typedef proto stdcall :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
plConnectEx typedef ptr proto_ConnectEx

proto_DisconnectEx typedef proto stdcall :DWORD,:DWORD,:DWORD,:DWORD
plDisconnectEx typedef ptr proto_DisconnectEx
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
.data
s SOCKET 0
ConnectExGuid GUID <25a207b9h,0ddf3h,4660h,<8eh,0e9h,76h,0e5h,8ch,74h,06h,3eh>>
DisconnectExGUID GUID <7fda2e11H,08630H,0436fH,<0A0H,031H,0F5H,036H,0A6H,0EEH,0C1H,057H>>
_DisconnectEx plDisconnectEx 0
_ConnectEx plConnectEx 0
.code
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Exgetapiaddr proc guid_idName:DWORD
Local lpfnfunctionNAME:DWORD
Local dwBytes:DWORD

mov lpfnfunctionNAME,0
invoke WSASocket,AF_INET, SOCK_STREAM,IPPROTO_IP, NULL,0,NULL
cmp eax, NULL
je Exgetapiaddr_err_exit
mov s, eax
invoke WSAIoctl,s,SIO_GET_EXTENSION_FUNCTION_POINTER,guid_idName,sizeof GUID,addr lpfnfunctionNAME,sizeof lpfnfunctionNAME,addr dwBytes,NULL,NULL
.if eax==SOCKET_ERROR
invoke ErrorMessage,CTXT("WSAIoctl"),TRUE
.endif
invoke closesocket,s
Exgetapiaddr_err_exit:
mov eax,lpfnfunctionNAME
ret
Exgetapiaddr endp
;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

invoke Exgetapiaddr,addr DisconnectExGUID
.if eax==0
invoke ErrorMessage,CTXT("DisconnectExGUID_Exgetapiaddr"),TRUE
jmp main_create_exit
.else
mov _DisconnectEx,eax
.endif

invoke Exgetapiaddr,addr ConnectExGuid
.if eax==0
invoke ErrorMessage,CTXT("ConnectExGUID_Exgetapiaddr"),TRUE
jmp main_create_exit
.else
mov _ConnectEx,eax
.endif
Title: Re: where is the ConnectEx api?
Post by: dedndave on March 05, 2015, 11:18:51 AM
 :t