about WSAStartup minor & major vesrion number.. what to specify ?

Started by Rainstorm, September 08, 2008, 04:05:42 AM

Previous topic - Next topic

Rainstorm

hi,
in the WSAStartup call, what do i specify for the minor & major version (revision) number for the wVersionRequested  argument ? what does the revision refer to ? - I looked in the properties of the dll on my comp..& couldn't find any specific revision number specified.. unless its part of the whole version number
(I just specified 2 & 2 in the high & low byte)

Also, in WSAPROTOCOL_INFO what's the GUID & ProtocolChain types - want a confirmation on their size mainly.. am suposing they are DWORD.

thanks!
-

Tedd

Use: invoke WSAStartup, 202h,ADDR wsadata
It's just a version number of the winsock library - version 2 added extra functionality that wasn't available in version 1, and the revision is a modification/update of that (which may or may not change the way anything works, but it's there just in case; so you could just ask for v2.0 and see no change from v2.2). For most purposes you can just set it and ignore it.


GUID will be a standard windows guid, which is already specified in windows.inc (16 bytes)

WSASPROTOCOLCHAIN is:

MAX_PROTOCOL_CHAIN equ 7

WSASPROTOCOLCHAIN struct
    ChainLen       DWORD ?         ;length of the chain; 0=layered, 1=base, >1=protocol chain
    ChainEntries   DWORD MAX_PROTOCOL_CHAIN dup(?)    ;list of dwCatalogEntryIds
WSASPROTOCOLCHAIN ends

(Don't ask me what any of that actually means, I've never had use for it :bdg)
No snowflake in an avalanche feels responsible.

Rainstorm

lol : )

am having 2 problems with this code
when i call WSAStartup with a dword value for the version parameter, like        invoke WSAStartup, ebx, addr wsocket2_info the code works.. but I get a 10055 error for WSAEnumProtocols, after calling WSAGetLastError. & the enumeration fails. the WSAStartup function seems to work though in this case & it returns 514 - I don't know why this works though.. because WSAStartup asks for a WORD argument & am supplying a DWORD argument there.

if i specify a WORD value..(bx) nothing happens (that is none of what i stated above happens) - when i run it likeWSAStartup, bx, addr wsocket2_info - the app doesn't seem to be hanging,(i checked in the windows process list) but the exit_ block doesn't seem to be triggering either

10055 says..
QuoteNo buffer space available.
An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.

    .data

  WSAPROTOCOL_INFO  struct

    dwServiceFlags1     dd      0
    dwServiceFlags2     dd      0
    dwServiceFlags3     dd      0
    dwServiceFlags4     dd      0
    dwProviderFlags     dd      0
    ProviderId          dd      0
    dwCatalogEntryId    dd      0
    ProtocolChain       dd      0
    iVersion            dd      0
    iAddressFamily      dd      0
    iMaxSockAddr        dd      0
    iMinSockAddr        dd      0
    iSocketType         dd      0
    iProtocol           dd      0
    iProtocolMaxOffset  dd      0
    iNetworkByteOrder   dd      0
    iSecurityScheme     dd      0
    dwMessageSize       dd      0
    dwProviderReserved  dd      0
    szProtocol         BYTE   WSAPROTOCOL_LEN + 1 dup (0)            ; WSAPROTOCOL_LEN+1

  WSAPROTOCOL_INFO ends

; protocol_info   WSAPROTOCOL_INFO  <0>
  protocol_info   WSAPROTOCOL_INFO  10 dup   ({0})

  wsocket2_info   WSADATA   <0>

  protocol_buffer_length           dd       0 
  retnval                          dd       0
  buffer_length_needed             dd       0
  sockets_error_code               dd       0
  temp                             dd       0
  sockver                          dw       0

; -----------------------------------------------------------------------


    .code
   
start:

        xor ebx, ebx
        mov bl, 2
        mov bh, 2

        invoke WSAStartup, bx, addr wsocket2_info
        cmp eax, 0
        je @F
        fn MessageBox,0,"WSAStartup Failed","WSAStartup",MB_OK
        jmp exit_

     @@:
        movzx eax, wsocket2_info.wVersion
;       movzx eax, wsocket2_info.wHighVersion
        fn MessageBox,0,ustr$(eax),"wVersion",MB_OK

        invoke WSAEnumProtocols, NULL, addr protocol_info, addr protocol_buffer_length
        mov retnval, eax
        invoke WSAGetLastError
        mov sockets_error_code, eax

        fn MessageBox,0,ustr$(sockets_error_code),"WSAEnumProtocols - error_code",MB_OK
       
        fn MessageBox,0,ustr$(retnval),"Return value - WSAEnumProtocols",MB_OK

        fn MessageBox,0,ustr$(protocol_buffer_length),"Needed buffer length",MB_OK

    exit_:
        fn MessageBox,0,"exit triggered!","Title",MB_OK

        invoke WSACleanup
        exit

end start

Tedd

Quote from: Rainstorm on September 09, 2008, 12:36:48 AM
when i call WSAStartup with a dword value for the version parameter, like
        invoke WSAStartup, ebx, addr wsocket2_info
the code works.. but I get a 10055 error for WSAEnumProtocols, after calling WSAGetLastError. & the enumeration fails. the WSAStartup function seems to work though in this case & it returns 514 - I don't know why this works though.. because WSAStartup asks for a WORD argument & am supplying a DWORD argument there.

word parameters should still be pushed onto the stack as dwords :wink (it just ignores the upper 16 bits)

514 is 0202h - which is what you requested.

There are two problems with your call to WSAEnumProtocols:
The first is simply that you didn't initialise protocol_buffer_length with the length of the buffer you're providing (so you're essentially giving it a buffer of length zero - no wonder it doesn't like that.) Try adding mov protocol_buffer_length,SIZEOF protocol_info before the call.
Secondly, the buffer you supply only has space for 10 protocols. I have to increase it to 17 before it will work for me, so I'd go with 20 just to be sure; though you should probably dynamically allocate it and increase the size if it fails for that reason.
To reduce that you can be more specific in the protocols to enumerate (why do you want to enumerate them anyway?)
No snowflake in an avalanche feels responsible.

Rainstorm

thanks tedd, it works properly now.

QuoteTo reduce that you can be more specific in the protocols to enumerate (why do you want to enumerate them anyway?)
was reading up a bit on related stuff(tcp/ip etc).. then just fooling around with some of the sockets apis  to see what protocols were installed etc.