<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Windows Core Networking : Winsock</title><link>http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx</link><description>Tags: Winsock</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Winsock SO_EXCLUSIVEADDRUSE on Vista</title><link>http://blogs.msdn.com/wndp/archive/2007/03/19/winsock-so-exclusiveaddruse-on-vista.aspx</link><pubDate>Tue, 20 Mar 2007 00:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1914989</guid><dc:creator>wndpteam</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/wndp/comments/1914989.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=1914989</wfw:commentRss><description>&lt;P&gt;I've been asked a couple times about the socket option SO_EXCLUSIVEADDRUSE on Vista and especially how it relates to dual stack sockets. The following doc link describes the basic idea of this socket option:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms740621.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms740621.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms740621.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;However, it hasn't been updated with any Vista specific behavior. We're working on updating that doc but it takes a while for the change to propagate to the web.&lt;/P&gt;
&lt;P&gt;Vista follows the same rules as Windows Server 2003 when looking at that documentation, but what happens when using a dual stack socket? A dual stack socket is one that is created as IPv6 but then the IPV6_V6ONLY socket option is set to false. This results in the socket being bound to the same port on both the IPv4 and IPv6 stack. This mans that the security check is performed for the given port on both the IPv4 and IPv6 networking stacks. If either check fails, the entire bind request fails. 
&lt;P&gt;For example, a IPv6 dual stack socket is to be bound to port 5150 on the wildcard address (since it doesn't make sense to bind a dual stack socket to a specfic IP address). If SO_EXCLUSIVEADDRUSE is not set, then the bind will succeed even if there is another socket (IPv4 or IPv6) bound to a specific IP address on port 5150. This is no different what is described in the article above. However, if SO_EXCLUSIVEADDRUSE was set then if any other socket is bound to port 5150 (either IPv4 or IPv6), the bind call will fail thus indicating that you don't have exclusive access to that port. 
&lt;P&gt;Just as a reminder, applications should never set SO_REUSEADDR except for some very specific uses (e.g. multicasting) while servers should always set SO_EXCLUSIVEADDRUSE. 
&lt;P&gt;--Anthony Jones (AJones)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1914989" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category><category domain="http://blogs.msdn.com/wndp/archive/tags/networking/default.aspx">networking</category></item><item><title>Winsock Header Weirdness</title><link>http://blogs.msdn.com/wndp/archive/2006/12/18/winsock-header-weirdness.aspx</link><pubDate>Tue, 19 Dec 2006 02:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1319417</guid><dc:creator>wndpteam</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/wndp/comments/1319417.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=1319417</wfw:commentRss><description>&lt;P&gt;There are two main Winsock headers used depending on which version your application needs. There is winsock.h for Winsock v1.x and winsock2.h for Winsock v2.x and they are mutually exclusive. That is, if you include both header files you will see a lot of compilation errors. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;As you may know, windows.h includes a lot of other header files if you don't define WIN32_LEAN_AND_MEAN in your source code. One of the headers it does include without this define is winsock.h. This can cause problems if you are intending to use Winsock 2 features and are linking to ws2_32.lib. In addition to causing obvious compilation errors (due to structure redefinitions or missing definitions) there is a subtle issue regarding IP multicast support. Winsock 1 defined the IP multicast socket options IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP as 5 and 6; however, when Winsock 2 was defined these values changed to 12 and 13. By including winsock.h and linking to wsock32.lib, these values are fixed up since the Windows operating system will only recognize the Winsock 2 values. By mismatching the header file and link library, the application would see failures when calling setsockopt.&lt;/P&gt;
&lt;P&gt;Winsock developers should define WIN32_LEAN_AND_MEAN and explicitly include the Winsock header for the version they require as well as link with the appropriate lib -- winsock.h goes with wsock32.lib while winsock2.h goes with ws2_32.lib. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1319417" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category><category domain="http://blogs.msdn.com/wndp/archive/tags/networking/default.aspx">networking</category></item><item><title>Our Mike Flasko and Anthony Jones on Channel 9</title><link>http://blogs.msdn.com/wndp/archive/2006/12/13/our-mike-flasko-and-anthony-jones-on-channel-9.aspx</link><pubDate>Wed, 13 Dec 2006 18:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1276131</guid><dc:creator>wndpteam</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/wndp/comments/1276131.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=1276131</wfw:commentRss><description>&lt;P&gt;There is a &lt;A class="" href="http://channel9.msdn.com/Showpost.aspx?postid=265664" mce_href="http://channel9.msdn.com/Showpost.aspx?postid=265664"&gt;new video&lt;/A&gt; up on channel9 talking about Coding to support IPv6. Go check it out!&lt;/P&gt;
&lt;P&gt;&amp;nbsp; -- Ari Pernick&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1276131" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category><category domain="http://blogs.msdn.com/wndp/archive/tags/networking/default.aspx">networking</category><category domain="http://blogs.msdn.com/wndp/archive/tags/IPV6/default.aspx">IPV6</category></item><item><title>LSP Installation Problems with WSCInstallProvider64_32</title><link>http://blogs.msdn.com/wndp/archive/2006/11/28/lsp-installation-problems-with-wscinstallprovider64-32.aspx</link><pubDate>Wed, 29 Nov 2006 00:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1167622</guid><dc:creator>wndpteam</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/wndp/comments/1167622.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=1167622</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;An LSP (or Winsock provider) can be installed into the Winsock catalog through several different function calls. Also, as you might know, on 64-bit Windows there are two different Winsock catalogs – one for 32-bit applications and one for 64-bit native applications. In order for an LSP to be loaded by both native and WOW64 applications, it must be installed into both catalogs. There are two ways to install a Winsock provider into both catalogs:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Call WSCInstallProvider64_32 which installs the same provider entries into both Winsock catalogs&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;On Vista, call WSCInstallProviderAndChains which performs all the necessary steps but results in separate install calls to the 64-bit and 32-bit catalogs&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Each of these functions will install the provider information into the appropriate Winsock catalog. The Winsock catalog is a repository in the registry that contains information about each Winsock provider. For 64-bit Windows, there are two versions of the catalog – one for native 64-bit applications and one for 32-bit applications. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Unfortunately WSCInstallProvider64_32 works in only a handful of cases. The basic problem with this function is it attempts to install the same WSAPROTOCOL_INFOW structures into both Winsock catalogs. This means that the protocol chains specified in the WSAPROTOCOL_INFOW structure will contain the same catalog IDs for both the 32-bit and 64-bit Winsock catalogs. However, if a Winsock provider was installed either into one but not both catalogs or if the Winsock provider was installed into both catalogs using methods #2 then the catalog IDs in each of the two Winsock catalogs become out of sync. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;For example, one way the catalog can become out of sync is if an LSP is installed only into the 64-bit catalog. That is, the application installs an LSP provider which will be assigned the next free catalog entry ID – say 1020. Then another LSP is installed using WSCInstallProvider64_32. This LSP installer builds a protocol chain and layers its entries over the first LSP that has the ID of 1020. Since WSCInstallProvider64_32 installs the same WSAPROTOCOL_INFOW into both catalogs, the 32-bit Winsock catalog now contains an entry that references provider 1020 which does not exist in the 32-bit catalog. This would result in the loss of network connectivity for 32-bit applications.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;For Windows Vista, if WSCInstallProvider64_32 is called and the 32-bit and 64-bit Winsock catalogs are not in sync, then the call will fail with WSANO_RECOVERY.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Because of this it is recommended that LSPs move to the WSCInstallProviderAndChains function on Vista which takes this issue into account (as well as saves you from writing and maintaining the ~600 lines of code to perform all the install steps). Of course, for downlevel Windows OSes, WSCInstallProvider64_32 is the only method for installing an LSP entry into both catalogs. The current LSP SDK sample dynamically checks if WSCInstallProviderAndChains is available and uses that; otherwise, it falls back to using WSCInstallProvider64_32. The latest sample is available from &lt;/FONT&gt;&lt;A href="http://connect.microsoft.com/wndp"&gt;&lt;FONT face=Calibri size=3&gt;http://connect.microsoft.com/wndp&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt;.&lt;/FONT&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;--Anthony Jones (AJones)&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1167622" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category></item><item><title>WSAPoll, A new Winsock API to simplify porting poll() applications to Winsock.</title><link>http://blogs.msdn.com/wndp/archive/2006/10/26/WSAPoll.aspx</link><pubDate>Thu, 26 Oct 2006 18:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:876152</guid><dc:creator>wndpteam</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/wndp/comments/876152.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=876152</wfw:commentRss><description>&lt;p&gt;Hello, my name is Chad Carlin. I'm a software developer on the Winsock Test Team. Among the many improvements to the Winsock API shipping in Vista is the new WSAPoll function. Its primary purpose is to simplify the porting of a sockets application that currently uses poll() by providing an identical facility in Winsock for managing groups of sockets. Depending on the needs of your application, this addition could be an attractive option. &lt;/p&gt; &lt;p&gt;If you are new to poll, (since just about everyone is new to WSAPoll() ), I'll explain its role in network programming with a brief example. Suppose that you have a server application that is providing a service to several clients concurrently. You would not want your process to be blocked while waiting for a client to send or be able to receive data. You could create a thread per socket, but that would hinder the scalability of your application. By creating an array of structures, each with a member, which is a pointer to one of your sockets, you can poll this array to identify which sockets are guaranteed to be available for reading or writing data. This keeps your server process busy servicing ready clients or other performing useful work. &lt;/p&gt; &lt;p&gt;You should be aware that if you are choosing between using select() and WSAPoll(), that WSAPoll() scales better to a larger number of sockets and can accommodate sockets of different types. If you are creating a large-scale, high-performance Winsock2 application, we recommend that you use the native Winsock overlapped IO facilities. &lt;/p&gt; &lt;p&gt;If you have experience developing applications using poll(), WSAPoll will be very familiar. It is designed to behave just like poll(). In fact, I recently ported the Winsock WSAPoll SDK sample to run on BSD Unix. I know that sounds backwards from what you would expect but, we all like sample code after all. As it turns out it didn't matter which direction I ported. I had really hoped to have some clever insight to give you, or some real handy tip about how to work around some special difference. The truth is, the portions of the code dealing with poll() were unchanged from the sample. Except, of course, for changing the name of the API. Frankly, porting the poll() code went so smoothly, it made converting Windows threads to pthreads seem like the lion's share of the work. &lt;/p&gt; &lt;p&gt;To speed up your porting effort here are some tips: &lt;/p&gt; &lt;p&gt;The minimum set of include files that you'll need are: Winsock2.h, ws2tcpip.h and mstcpip.h. You'll want to switch from using the errno global variable to using the WSAGetLastError() function when looking for extended error codes. &lt;/p&gt; &lt;p&gt;For simplicity, the SDK sample uses macros to fill in the IPv6 address structures to connect or bind to the loopback interface. You should use getaddrinfo() which is the preferred method when writing an IP agnostic application. To support both address types you'll want to switch to using SOCKADDR_STORAGE types instead of sockaddr types used in BSD. &lt;/p&gt; &lt;p&gt;Here is an example of calling WSAPoll on a socket to check if it is writable. If the remote endpoint has accepted the connection, we call send. Get the full sample from the SDK for additional details. &lt;/p&gt;&lt;pre&gt;//Call poll for writeability on connecting socket&lt;br&gt;fdarray.fd = csock;&lt;br&gt;fdarray.events = POLLWRNORM;&lt;br&gt;if (SOCKET_ERROR == (ret = WSAPoll(&amp;amp;fdarray, 1, DEFAULT_WAIT )))&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ERR("poll");&lt;br&gt;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;if (ret)&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (fdarray.revents &amp;amp; POLLWRNORM)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf("Established connection and signalled POLLWRNORM \n");&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Send data&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (SOCKET_ERROR == (ret = send(csock, TST_MSG, sizeof (TST_MSG),)))&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ERR("send");&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf("Sent %d bytes@ %d\n",ret, __LINE__);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;... &lt;/pre&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Listing of networking code samples in the Windows SDK:&lt;br&gt;&lt;a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms716684.aspx" mce_href="http://windowssdk.msdn.microsoft.com/en-us/library/ms716684.aspx"&gt;http://windowssdk.msdn.microsoft.com/en-us/library/ms716684.aspx&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Find the latest version of the Platform SDK which includes the sample mentioned above:&lt;br&gt;&lt;a href="http://msdn.microsoft.com/downloads/" mce_href="http://msdn.microsoft.com/downloads/"&gt;http://msdn.microsoft.com/downloads/&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;MSDN WSAPoll documentation page:&lt;br&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/wsapoll.asp" mce_href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/wsapoll.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/wsapoll.asp&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;--Chad Carlin &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=876152" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category><category domain="http://blogs.msdn.com/wndp/archive/tags/networking/default.aspx">networking</category></item><item><title>Creating IP Agnostic Applications - Part 2 (Dual Mode Sockets)</title><link>http://blogs.msdn.com/wndp/archive/2006/10/24/creating-ip-agnostic-applications-part-2-dual-mode-sockets.aspx</link><pubDate>Tue, 24 Oct 2006 20:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:869873</guid><dc:creator>wndpteam</dc:creator><slash:comments>16</slash:comments><comments>http://blogs.msdn.com/wndp/comments/869873.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=869873</wfw:commentRss><description>&lt;P&gt;In a previous post I wrote about how on Windows Vista and Windows Server "Longhorn," IPv6 is installed and enabled by default and that&amp;nbsp;when both IPv4 and IPv6 are enabled, the TCP/IP stack prefers to use IPv6 over IPv4.&amp;nbsp; With the growth of IPv6, applications must now&amp;nbsp;work seamlessly over both protocols (IPv4 &amp;amp; IPv6).&amp;nbsp; The remainder of this post discusses one way to make handling both protocols easier by using a single socket that works with IPv4 &amp;amp; IPv6.&amp;nbsp; No longer do you need to create two sockets to make your application IPv4 &amp;amp; IPv6 aware :).&lt;/P&gt;
&lt;P&gt;Windows Vista and Windows Server Longhorn includes a new TCP/IP stack which&amp;nbsp;includes common TCP &amp;amp; UDP layers on top of the IPv4 and IPv6 layers.&amp;nbsp; This new architecture has made it possible for a single IPv6 socket to work with both IPv6 and IPv4.&amp;nbsp; For example, using a single IPv6 socket one can now accept BOTH IPv4 and IPv6 traffic.&amp;nbsp; Such a socket is typically dubbed a "dual mode" socket.&amp;nbsp; Dual mode sockets are usable by managed code sockets (ie. &lt;A href="http://search.msdn.microsoft.com/search/Redirect.aspx?title=Socket+Class+(System.Net.Sockets)+&amp;amp;url=http://msdn2.microsoft.com/en-us/library/system.net.sockets.socket.aspx" mce_href="http://search.msdn.microsoft.com/search/Redirect.aspx?title=Socket+Class+(System.Net.Sockets)+&amp;amp;url=http://msdn2.microsoft.com/en-us/library/system.net.sockets.socket.aspx"&gt;System.Net.Sockets.Socket&lt;/A&gt;), native &lt;A href="http://search.msdn.microsoft.com/search/Redirect.aspx?title=Winsock+Reference+%5bWinsock%5d&amp;amp;url=http://msdn.microsoft.com/library/en-us/winsock/winsock/winsock_reference.asp" mce_href="http://search.msdn.microsoft.com/search/Redirect.aspx?title=Winsock+Reference+%5bWinsock%5d&amp;amp;url=http://msdn.microsoft.com/library/en-us/winsock/winsock/winsock_reference.asp"&gt;Winsock&lt;/A&gt; sockets as well as &lt;A href="http://blogs.msdn.com/wndp/archive/2006/02/24/538746.aspx" mce_href="http://blogs.msdn.com/wndp/archive/2006/02/24/538746.aspx"&gt;Winsock Kernel (WSK)&lt;/A&gt;&amp;nbsp;sockets.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To create a "dual mode" socket, the following steps are&amp;nbsp;needed:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create an IPv6 socket 
&lt;LI&gt;Set the IPV6_V6ONLY socket option to false&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Once you have created the socket and set the appropriate option,&amp;nbsp;the socket can be used to accept&amp;nbsp;incoming IPv4/v6 connections or connect to an IPv4/v6 destination.&amp;nbsp; The snippets below outline&amp;nbsp;accepting incoming connections over both protocols&amp;nbsp;in native and managed code:&lt;/P&gt;
&lt;P&gt;Note: The code is meant as demonstration code; error code checking and exception handling have been left off the&amp;nbsp;code&amp;nbsp;snippets to keep them as concise as possible.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;.NET (C#)&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;P&gt;Socket sock = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);&lt;/P&gt;
&lt;P&gt;// 27 is equivalent to IPV6_V6ONLY socket option in the winsock snippet below&lt;BR&gt;sock.SetSocketOption(SocketOptionLevel.IPv6, (SocketOptionName)27, 0);&lt;BR&gt;sock.Bind(new IPEndPoint(IPAddress.IPv6Any, 8000));&lt;BR&gt;sock.Listen(5);&lt;BR&gt;Socket client = sock.Accept();&lt;BR&gt;// send / receive data on 'client' socket 
&lt;/P&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Winsock&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;P&gt;WSADATA wsaData;&lt;BR&gt;SOCKET lsock = INVALID_SOCKET;&lt;BR&gt;SOCKET csock = INVALID_SOCKET;&lt;BR&gt;SOCKADDR_STORAGE serverAddr = {0};&lt;BR&gt;SOCKADDR_STORAGE clientAddr = {0};&lt;BR&gt;int off = 0;&lt;BR&gt;int port = 8000;&lt;BR&gt;int clientAddrLen = sizeof(clientAddr);&lt;BR&gt;WSAStartup(MAKEWORD(2,2), &amp;amp;wsaData); 
&lt;P&gt;serverAddr.ss_family = AF_INET6;&lt;BR&gt;INETADDR_SETANY((SOCKADDR *)&amp;amp;serverAddr);&lt;BR&gt;SS_PORT(&amp;amp;serverAddr) = htons(port);&lt;BR&gt;lsock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;//make the socket a dual mode socket&lt;BR&gt;setsockopt(lsock,IPPROTO_IPV6,IPV6_V6ONLY,(char *)&amp;amp;off, sizeof(off));&lt;BR&gt;bind(lsock, (SOCKADDR *)&amp;amp;serverAddr, (int)INET_SOCKADDR_LENGTH(serverAddr.ss_family));&lt;BR&gt;listen(lsock, 5);&lt;BR&gt;csock = accept(lsock, (SOCKADDR *)&amp;amp;clientAddr, &amp;amp;clientAddrLen); &lt;/P&gt;
&lt;P&gt;... 
&lt;P&gt;... 
&lt;P&gt;WSACleanup(); 
&lt;/P&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;When using a dual mode socket, it is important to remember the socket is&amp;nbsp;at&amp;nbsp;root an IPv6 socket.&lt;/STRONG&gt;&amp;nbsp; Since this is the case, when specifying an IPv4 address to such a socket (ie. connect to IPv4 endpoint using a dual mode socket) one must format the IPv4 address as an &lt;A href="http://en.wikipedia.org/wiki/IPv4_mapped_address" mce_href="http://en.wikipedia.org/wiki/IPv4_mapped_address"&gt;IPv4 mapped address&lt;/A&gt; prior to passing the address to a socket function.&amp;nbsp; Fortunately,&amp;nbsp;one can use IN6ADDR_SETV4MAPPED(...), defined in mstcpip.h to simplify this task. 
&lt;P&gt;The following shows&amp;nbsp;an example of what this looks like in Winsock: &lt;PRE&gt;&lt;P&gt;WSADATA wsaData;&lt;BR&gt;SOCKET csock = INVALID_SOCKET;&lt;BR&gt;SOCKADDR_STORAGE addrLoopback4 = {0}; 
&lt;P&gt;int port = 8000;&lt;BR&gt;int off = 0; 
&lt;P&gt;addrLoopback4.ss_family = AF_INET;&lt;BR&gt;INETADDR_SETLOOPBACK((SOCKADDR*)&amp;amp;addrLoopback4);&lt;BR&gt;SS_PORT(&amp;amp;addrLoopback4) = htons(port); 
&lt;P&gt;WSAStartup(MAKEWORD(2,2), &amp;amp;wsaData);&lt;BR&gt;if((csock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET)&lt;/P&gt;&lt;P&gt;{&lt;BR&gt;     //error creating the listening socket&lt;BR&gt;     WSACleanup();&lt;BR&gt;     return 1;&lt;BR&gt;} &lt;/P&gt;
&lt;P&gt;//make the socket a dual mode socket&lt;BR&gt;setsockopt(csock,IPPROTO_IPV6,IPV6_V6ONLY,(char *)&amp;amp;off, sizeof(off)); 
&lt;P&gt;// format the address as a v4 mapped address if needed&lt;BR&gt;ConvertToV4MappedAddressIfNeeded((SOCKADDR *) &amp;amp;addrLoopback4);&lt;BR&gt;// connect&lt;BR&gt;connect(csock, (SOCKADDR *)&amp;amp;addrLoopback4, sizeof(addrLoopback4)); &lt;BR&gt;printf("Connect complete"); 
&lt;P&gt;closesocket(csock); 
&lt;P&gt;WSACleanup();&lt;BR&gt;return 0; 
&lt;P&gt;&amp;nbsp; 
&lt;P&gt;
&lt;P&gt;
&lt;P&gt;void ConvertToV4MappedAddressIfNeeded(PSOCKADDR pAddr)&lt;BR&gt;{&lt;BR&gt;    // if v4 address, convert to v4 mapped v6 address&lt;BR&gt;    if (AF_INET == pAddr-&amp;gt;sa_family)&lt;BR&gt;    {&lt;BR&gt;        IN_ADDR In4addr;    &lt;BR&gt;        SCOPE_ID scope = INETADDR_SCOPE_ID(pAddr);&lt;BR&gt;        USHORT port = INETADDR_PORT(pAddr);&lt;BR&gt;        In4addr = *(IN_ADDR*)INETADDR_ADDRESS(pAddr);&lt;BR&gt;        ZeroMemory(pAddr, sizeof(SOCKADDR_STORAGE));&lt;BR&gt;        IN6ADDR_SETV4MAPPED(&lt;BR&gt;             (PSOCKADDR_IN6)pAddr,&lt;BR&gt;             &amp;amp;In4addr,&lt;BR&gt;             scope,&lt;BR&gt;             port&lt;BR&gt;             ); 
&lt;P&gt;    }&lt;BR&gt;} 
&lt;/P&gt;&lt;/PRE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers, 
&lt;P&gt;-- Mike Flasko&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=869873" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category><category domain="http://blogs.msdn.com/wndp/archive/tags/System.Net/default.aspx">System.Net</category><category domain="http://blogs.msdn.com/wndp/archive/tags/networking/default.aspx">networking</category><category domain="http://blogs.msdn.com/wndp/archive/tags/WSK/default.aspx">WSK</category></item><item><title>Debugging Winsock LSPs</title><link>http://blogs.msdn.com/wndp/archive/2006/10/05/Debugging-Winsock-LSPs.aspx</link><pubDate>Thu, 05 Oct 2006 21:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:794360</guid><dc:creator>wndpteam</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/wndp/comments/794360.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=794360</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Several people have asked for tips on debugging LSPs, and unfortunately there’s no easy method to do so. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;One difficulty with LSPs is that once it’s installed any number of processes can immediately load the faulty LSP and begin to behave badly. This usually isn’t fatal unless one of those processes happens to be WINLOGON.EXE, LSASS.EXE, or another system critical service in which case your computer will shut down.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Problems with LSPs typically manifest in one of two ways:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;An application crash&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l2 level1 lfo1"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;The application fails in an unexpected error&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The first problem is usually easier to diagnose. This is done by using a debugger to either attach to the process and dumping the relevant stack that caused the violation or by running the application under the debugger. Almost all of application crashes from LSPs are due to invalid memory access (i.e. access violation). With the debugger (either Visual Studio, WinDbg.exe, NTSD.EXE, etc.) you can view the faulting instruction and dump the memory address that your LSP was trying to access. This usually gives you enough information to trace through your code and see how and where that structure and/or variable is manipulated to track down the culprit. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;However, in some instances that might not be enough. In that case the next step would be to step through your LSP code for typical socket operations that would lead up to the crash. For example, if the crash occurred in your LSP’s overlapped completion routine then setting breakpoints in your LSP’s &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;WSPSend&lt;/SPAN&gt;&lt;FONT face=Calibri&gt; and &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;OverlappedCompletionRoutine&lt;/SPAN&gt;&lt;FONT face=Calibri&gt; would be the first step.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;When those breakpoints are hit, you can then validate the LSPs internal state for each socket and that request. Setting additional breakpoints on routines that manipulate the LSP internal state may also be necessary.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Other areas of the LSP to look at when debugging access violations are:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo4"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Access to the LSP socket context structure from multiple threads – many apps perform simultaneous socket operations on the same socket from multiple threads. Verify the LSP correctly references and utilizes CRITICAL_SECTIONs when necessary to handle this case.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo4"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Validating calling parameters – the Winsock API specification states that Winsock will catch invalid memory pointers for some input parameters and return WSAEFAULT. This means any LSP must also do this validation.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo4"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Overlapped completion – LSPs add considerable overhead to the amount of time it takes for an overlapped operation to fully complete. Some poorly written applications use stack based WSAOVERLAPPED structures and then leave that function even though the operation is still pending. When the operation completes, the LSP ends up over writing a random stack location. This isn’t a bug in the LSP bug a bug in the application, and there’s nothing the LSP can do to prevent this. The only recourse here is to contact that application owner.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;If you are experiencing a crash in a system critical process like LSASS.EXE then life is much more difficult. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;In this case, debugging can only be performed by piping the user mode debugger to the kernel mode debugger (kd.exe). This will stop the entire OS execution while stepping through the faulting process and will prevent the OS from rebooting underneath you. This type of debugging can only be accomplished using the Windows debugging tools found here:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;A href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx" mce_href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx"&gt;&lt;FONT face=Calibri size=3&gt;http://www.microsoft.com/whdc/devtools/debugging/default.mspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;For the second type of LSP failure, unexpected application errors, the starting point is more nebulous. An example of this is installing an LSP and then having your web browser fail to load a web page you know should succeed. Since you don’t immediately know what call is unexpectedly failing, these problems require more work. Several approaches are:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Use a debugger to step through the expected Winsock calls if known (e.g. Internet Explorer would call &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;socket&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;, &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;connect&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;, &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;select&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;, &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;send&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;, and &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;recv&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Add tracing to your LSP to log unexpected failures.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Tracing is generally a good thing to add since it’s useful and can be reused (if any other problems come up). Additionally, since you probably won’t know what the failing application is explicitly doing in terms of Winsock calls, adding tracing usually takes less time in the long run.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Some other random LSP tips:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l3 level1 lfo2"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Always remember to install your LSP over both TCP and UDP entries for IPv4 &lt;B style="mso-bidi-font-weight: normal"&gt;and&lt;/B&gt; IPv6. Several applications will call &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;select&lt;/SPAN&gt;&lt;FONT face=Calibri&gt; and pass handles owned by multiple providers, and if your LSP doesn’t layer over that provider then there is a possibility that your LSP is completely bypassed and the owning provider will fail its &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;WSPSelect&lt;/SPAN&gt;&lt;FONT face=Calibri&gt; call (as it won’t understand the LSP sockets passed to it).&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l3 level1 lfo2"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;When debugging an LSP you may install and remove your LSP multiple times. After a while you can get into a state where various processes have loaded different versions of your LSP. It’s a good idea to reboot your computer after several iterations of installing and removing your LSP.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l3 level1 lfo2"&gt;&lt;SPAN style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri size=3&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Debug your LSP on a Windows Vista computer&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Winsock LSP categorization will prevent system services from loading your LSP which will prevent the flakiness mentioned in the previous point. See the following blog posting about LSP categorization:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/wndp/archive/2006/02/09/529031.aspx" mce_href="http://blogs.msdn.com/wndp/archive/2006/02/09/529031.aspx"&gt;&lt;FONT face=Calibri size=3&gt;http://blogs.msdn.com/wndp/archive/2006/02/09/529031.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;--Anthony Jones (AJones)&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=794360" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category></item><item><title>Creating IP Agnostic Applications - Part  1</title><link>http://blogs.msdn.com/wndp/archive/2006/08/29/Creating-IP-Agnostic-Applications--Part--1.aspx</link><pubDate>Tue, 29 Aug 2006 18:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:729108</guid><dc:creator>wndpteam</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/wndp/comments/729108.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=729108</wfw:commentRss><description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;In Windows Vista and Windows Server "Longhorn," IPv6 is installed and enabled by default.&amp;nbsp; When both IPv4 and IPv6 are enabled on these OSs, the TCP/IP stack prefers to use IPv6 over IPv4.&amp;nbsp; For example, APIs such as &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/wsaconnectbyname_2.asp" target=_blank&gt;ConnectByName&lt;/A&gt;&amp;nbsp;will attempt to connect first via IPv6.&amp;nbsp; See &lt;A href="http://www.microsoft.com/technet/community/columns/cableguy/cg0206.mspx" target=_blank&gt;this&lt;/A&gt; post for a detailed discussion of address sorting. 
&lt;P&gt;Since the &lt;A href="http://www.microsoft.com/technet/community/columns/cableguy/cg1005.mspx" target=_blank&gt;IPv6 stack has been enhanced, is installed by default and the preferred network layer&lt;/A&gt;, it is important when writing network code to ensure your application is IP agnostic.&amp;nbsp; That is, your application should be able to function well when: 
&lt;UL&gt;
&lt;LI&gt;IPv4 and IPv6 are installed 
&lt;LI&gt;IPv4 is the only network layer protocol installed 
&lt;LI&gt;IPv6 is the only network layer protocol installed&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;At first glance this requirement may seem like significant added complexity for an application developer, but there is good news :).&amp;nbsp; We have been actively working on ways to&amp;nbsp;make writing IP agnostic applications simple.&amp;nbsp; The remainder of this post will&amp;nbsp;talk about how to get started making your apps IPv6 aware.&amp;nbsp; In a subsequent post, I hope to drill down into specific topics.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Check Out the Porting Guide&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;When writing such applications, I suggest reading&amp;nbsp;the &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/ipv6_guide_for_windows_sockets_applications_2.asp" target=_blank&gt;Winsock IPv6 Porting Guide&lt;/A&gt;.&amp;nbsp; This document&amp;nbsp;is applicable to Windows Vista and&amp;nbsp;Windows Server Longhorn as well as many prior OSs&amp;nbsp;such as Windows XP and Window Server 2003.&amp;nbsp; While the document&amp;nbsp;speaks directly to the use of native code Winsock APIs, the concepts presented are&amp;nbsp;directly applicable to&amp;nbsp;both native and managed code (ie.&amp;nbsp;.Net Framework).&amp;nbsp;&amp;nbsp;Would a&amp;nbsp;version of this document targeted&amp;nbsp;at managed code development&amp;nbsp;be useful?&amp;nbsp; Are there areas of the porting guide you would like expanded?&amp;nbsp; If so,&amp;nbsp;please let us know.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;How to Check if IPv4 or IPv6&amp;nbsp;is Installed&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;One of the first tasks you may need to do is determine if IPv4 and/or IPv6 are installed&amp;nbsp;on the machine.&amp;nbsp;&amp;nbsp;I believe there a number of suggested methods&amp;nbsp;out there, but the recommended method which&amp;nbsp;will reliably tell you if&amp;nbsp;a protocol is installed is to attempt to create a socket&amp;nbsp;for the address family in question.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;FONT color=#800000&gt;For Winsock developers, this is accomplished by calling the socket or WSASocket&amp;nbsp;function with the address family parameter set to AF_INET to test IPv4 availability and AF_INET6 for IPv6.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#800000&gt;For .Net Framework applications, use the Socket.SupportsIPv4 property to test IPv4 availability and Socket.OSSupportsIPv6 for IPv6.&lt;/FONT&gt;&amp;nbsp; &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;: There is a Socket.SupportsIPv6 property, but this is &lt;EM&gt;NOT&lt;/EM&gt; the one you want in this case.&amp;nbsp; For compat reasons we could not change the meaning of this property which does not tell you whether the machine has IPv6 installed, but instead gives back the value of a legacy configuration switch.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Previous Posts&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;Brad Williamson has posted already on a couple of the APIs available on Windows Vista &amp;amp; Windows Server "Longhorn" which &lt;A href="http://blogs.msdn.com/wndp/archive/2006/07/25/WSAConnectByName_and_WSAConnectByList.aspx" target=_blank&gt;simplify connection establishment for IP agnostic apps&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Mike Flasko&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=729108" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category><category domain="http://blogs.msdn.com/wndp/archive/tags/System.Net/default.aspx">System.Net</category><category domain="http://blogs.msdn.com/wndp/archive/tags/IPV6/default.aspx">IPV6</category></item><item><title>WSAConnectByName() and WSAConnectByList()</title><link>http://blogs.msdn.com/wndp/archive/2006/07/25/WSAConnectByName-and-WSAConnectByList.aspx</link><pubDate>Wed, 26 Jul 2006 01:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:678280</guid><dc:creator>wndpteam</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/wndp/comments/678280.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=678280</wfw:commentRss><description>G’Day, my name is Brad Williamson, a Software Design Engineer with the Windows Networking Developer Platform (WNDP) group here at Microsoft. I am going to talk about two APIs that were introduced in Windows Vista Beta 2 to simplify the process of connecting to another connection-oriented socket application. 
&lt;P&gt;By far, one of the most common scenarios in sockets programming is to connect to a remote address after resolving the hostname. To do this, you first call getaddrinfo() to resolve a hostname. Then, for each address, you create a socket, bind to that socket, and call connect(),WSAConnect(), or ConnectEx(). This process continues until the connection succeeds or the address list has been exhausted. With IPv6 becoming more prevalent, the address list that you have to traverse will be large. 
&lt;P&gt;Furthermore, if you have a machine with multiple interfaces (whether that be multiple NICs and/or multiple IP addresses on the same NIC), you may want to determine which interface best suits the destination address, and then bind appropriately. 
&lt;P&gt;As you will agree, the process of connecting optimally to a destination connection-oriented socket requires a lot of code. 
&lt;P&gt;With Windows Vista, this process is simplified with the introduction of two new Winsock APIs: WSAConnectByName() and WSAConnectByList(). 
&lt;P&gt;WSAConnectByName() establishes a connection to another application, using an optimal source and destination address pair, given a specified socket, host and port. Given a socket s, host name and port (or a well known service name); WSAConnectByName() will connect to the destination. If successful, WSAConnectByName() will return the local address which socket s is bound to, and the remote address connected to. &lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;PRE&gt;BOOL PASCAL WSAConnectByName(
  SOCKET s,
  LPSTR nodename,
  LPSTR servicename,
  LPDWORD LocalAddressLength,
  LPSOCKADDR LocalAddress,
  LPDWORD RemoteAddressLength,
  LPSOCKADDR RemoteAddress,
  const struct timeval* timeout,
  LPWSAOVERLAPPED Reserved
);&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;In addition to WSAConnectByName(), we have introduced WSAConnectByList() which establishes a connection to one of the addresses specified in the SocketAddressList structure. 
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;PRE&gt;BOOL PASCAL WSAConnectByList(
  SOCKET s,
  PSOCKET_ADDRESS_LIST SocketAddressList,
  LPDWORD LocalAddressLength,
  LPSOCKADDR LocalAddress,
  LPDWORD RemoteAddressLength,
  LPSOCKADDR RemoteAddress,
  const struct timeval* timeout,
  LPWSAOVERLAPPED Reserved
);&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;By using WSAConnectByName() and WSAConnectByList(): &lt;/P&gt;
&lt;P&gt;
&lt;OL&gt;
&lt;LI&gt;For WSAConnectByName(), your application is transparent to the name resolution. The list of remote addresses that we attempt to connect to is determined by the socket type passed in. This also includes dual-mode sockets (supporting IPv4 and IPv6) where the socket option IPV6_V6ONLY has been set to FALSE. 
&lt;LI&gt;Your application does not have to optimize the address list to determine which interface you should bind to. 
&lt;LI&gt;Eliminates the need for your application to include code to minimize the time of the connecting. &lt;/LI&gt;&lt;/OL&gt;Having said this, here are two caveats to using these APIs: 
&lt;OL&gt;
&lt;LI&gt;Connection-oriented mode is only supported, and 
&lt;LI&gt;Overlapped I/O is not supported. These APIs will block even if the socket is in non-blocking mode. &lt;FONT color=#ff0000&gt;Update: We will support Overlapped I/O in a future release.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;More information about these new APIs can be found in: &lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/winsock/winsock/wsaconnectbyname_2.asp"&gt;http://msdn.microsoft.com/library/en-us/winsock/winsock/wsaconnectbyname_2.asp&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;and &lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/winsock/winsock/wsaconnectbylist.asp"&gt;http://msdn.microsoft.com/library/en-us/winsock/winsock/wsaconnectbylist.asp&lt;/A&gt; &lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So, when writing your next Winsock based application using Windows Vista, be sure to try out WSAConnectByName() and WSAConnectByList(). Please let us know if you have any questions, comments or suggestions.&lt;/P&gt;
&lt;P&gt;--Brad Williamson &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=678280" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category><category domain="http://blogs.msdn.com/wndp/archive/tags/IPV6/default.aspx">IPV6</category></item><item><title>The (new) Trouble with select and LSPs...</title><link>http://blogs.msdn.com/wndp/archive/2006/07/13/664737.aspx</link><pubDate>Thu, 13 Jul 2006 21:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:664737</guid><dc:creator>wndpteam</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/wndp/comments/664737.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=664737</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;If you’ve ever had to deal with Winsock LSPs, then you probably know that handling select function calls are rather convoluted – especially with certain apps that pass multiple socket types into select. Some applications (like IE) will pass a UDP/IPv4 and a TCP/IPv4 socket in a single select call. This works fine unless you have a non-IFS LSP installed only over UDP/IPv4 or TCP/IPv4 (but not both) in which case IE may lose network connectivity. This is because the order of the socket handles matter. That is, Winsock will find the first socket in the first non-empty FD_SET and call the provider that owns that handle to service the select call. If the first handle is a UDP/IPv4 socket from a base provider and the second handle is the TCP/IPv4 from an LSP provider, the base provider (BSP) will attempt to lookup the LSP handle which will fail with WSAENOTSOCK. Because of this Microsoft has always recommended that non-IFS LSPs layer over all entries for a particular address family (i.e. layer over all the IPv4 entries).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;With Vista, things have gotten interesting again. Many system services (like DNS) have been updated to support both IPv4 and IPv6 which means there are applications passing in a mix of IPv4 and IPv6 sockets in a single select call. So, the same problem exists now if your LSP layers only over IPv4 entries but not over IPv6 entries. To prevent Vista from breaking (e.g. DNS name resolution not working) when an IPv4 only LSP is installed, a change was made to select to bypass LSPs entirely if a&lt;B&gt; &lt;/B&gt;&lt;SPAN style="mso-bidi-font-weight: bold"&gt;non-IFS&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt; &lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;LSP is installed that is layered over just IPv4 (or only over IPv6). Note that only the LSP’s WSPSelect routine is bypassed, all other calls will still be routed to the LSP. Also, Winsock will only enter the “bypass select” mode if it detects there is an LSP installed over only one of the two required protocols (IPv4 or IPv6). If all non-IFS LSPs are installed over both IPv4 and IPv6, then those LSPs will still intercept the select call.&lt;/SPAN&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;o:p&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/SPAN&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;o:p&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;Most LSPs do not need to intercept select unless they are interjecting data into the application’s stream in which case they would need to inject read events to notify select based applications that data is present. For those LSPs that do need to intercept select calls, they will have to be modified to do so. The method by which an LSP’s WSPSelect is bypassed is as follows:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;The ws2_32 select call translates each application socket to a base provider (BSP) handle&lt;SPAN style="COLOR: navy"&gt;,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: navy; FONT-FAMILY: 'Arial','sans-serif'; mso-bidi-font-size: 10.0pt"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: 'Arial','sans-serif'; mso-bidi-font-weight: bold; mso-bidi-font-size: 12.0pt"&gt;&lt;FONT color=#000000&gt;by calling&lt;/FONT&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-bidi-font-weight: bold; mso-bidi-font-size: 12.0pt"&gt;the ioctl SIO_BSP_HANDLE_SELECT (described below) for each socket handle&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Once all FD_SETs have been translated, select routes the call to the first socket handle in the first non-empty FD_SET which will be a BSP. Since all socket handles are from base providers, all handles are known to be valid&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Once the BSP provider returns, the handles returned are mapped back to the application handles&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;For an LSP to intercept select calls, it will need to trap the WSAIoctl call and the ioctl SIO_BSP_HANDLE_SELECT in the LSP’s WSPIoctl function. This ioctl passes the application handle as the socket parameter and expects the “base” handle to be returned in the output parameter. For an LSP to successfully intercept select calls on Vista it must do the following:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Arial"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;The LSP &lt;B&gt;must&lt;/B&gt; be installed either over all BSP entries or be installed over all IPv4 and IPv6 entries&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;The LSP &lt;B&gt;must&lt;/B&gt; intercept the SIO_BSP_HANDLE_SELECT ioctl call and return the same socket handle value that was passed as the socket parameter (i.e. the LSP’s socket handle that it returned to the caller)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;The following code snippet illustrates the basic idea:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;int WSPAPI&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;WSPIoctl(&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SOCKET&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DWORD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dwIoControlCode,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPVOID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lpvInBuffer,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DWORD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cbInBuffer,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPVOID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lpvOutBuffer,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DWORD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cbOutBuffer,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPDWORD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lpcbBytesReturned,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPWSAOVERLAPPED lpOverlapped,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPWSATHREADID&amp;nbsp;&amp;nbsp; lpThreadId,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPINT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lpErrno&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (SIO_BSP_HANDLE_SELECT == dwIoControlCode) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (cbOutBuffer &amp;lt; sizeof(SOCKET)) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *lpErrno = WSAEFAULT;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return SOCKET_ERROR;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *lpvOutBuffer = s;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *lpcbBytesReturned = sizeof(s);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return NO_ERROR;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // … Rest of your WSPIoctl&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;o:p&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;Finally, its important to point out that if your LSP chooses to intercept select it does not 100% guarantee that the problem described here will not be encountered. Under certain LSP layering configurations its always possible that the first handle belongs to a BSP or an LSP positioned lower in the LSP stack such that it will be unable to translate a given higher layer LSP handle. So, unless you absolutely have to intercept select calls, don’t. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Arial','sans-serif'; mso-highlight: yellow"&gt;Note that this change was made after Beta 2.&lt;/SPAN&gt;&lt;/B&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"&gt;--&lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:PersonName w:st="on"&gt;Anthony Jones&lt;/st1:PersonName&gt; (AJones)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=664737" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category></item><item><title>WNDP Connect Site gets an upgrade!</title><link>http://blogs.msdn.com/wndp/archive/2006/06/06/619215.aspx</link><pubDate>Tue, 06 Jun 2006 19:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:619215</guid><dc:creator>wndpteam</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/wndp/comments/619215.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=619215</wfw:commentRss><description>&lt;P&gt;Last year we &lt;A href="/wndp/archive/2005/10/30/487124.aspx"&gt;setup&lt;/A&gt; a &lt;A href="/wndp/archive/2005/09/27/474679.aspx"&gt;small site&lt;/A&gt; on connect.microsoft.com in order to let our blog&amp;nbsp;readers, developers and users file bugs, make suggestions and get some conntent like whitepapers and samples early. The downside to the site was that you couldn't easily deep link and it required a Windows Live (aka Passport) login. Well the folks at connect.microsoft.com have launched a new version of connect that enables access to much of the site without a login including &lt;A href="https://connect.microsoft.com/WNDP/Feedback"&gt;readonly access to the bugs&lt;/A&gt; filled there much like the popular &lt;A href="http://lab.msdn.microsoft.com/productfeedback/"&gt;MSDN Product Feedback Center&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;Check it out: &lt;A href="http://connect.microsoft.com/WNDP"&gt;http://connect.microsoft.com/WNDP&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- Ari Pernick&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=619215" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category><category domain="http://blogs.msdn.com/wndp/archive/tags/WinINet/default.aspx">WinINet</category><category domain="http://blogs.msdn.com/wndp/archive/tags/WinHttp/default.aspx">WinHttp</category><category domain="http://blogs.msdn.com/wndp/archive/tags/QoS/default.aspx">QoS</category><category domain="http://blogs.msdn.com/wndp/archive/tags/Http.sys/default.aspx">Http.sys</category></item><item><title>Winsock and the new SDK Headers</title><link>http://blogs.msdn.com/wndp/archive/2006/04/07/571105.aspx</link><pubDate>Fri, 07 Apr 2006 23:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:571105</guid><dc:creator>wndpteam</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/wndp/comments/571105.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=571105</wfw:commentRss><description>&lt;P&gt;As you may have noticed in the recent Vista CTP SDK, the Winsock headers have undergone some changes. First, instead of a couple monolithic files (winsock2.h and mswsock.h), they have been split into a number of smaller files for ease of maintenance as well as for use by other components that don't necessarily load Winsock but need to use some of its defines. For example, device drivers that need protocol and structure definitions might only include ws2def.h instead of winsock2.h which pulls in a bunch of conflicting SDK definitions (since the driver already pulls in DDK definitions).&lt;/P&gt;
&lt;P&gt;The other major change is header versioning. Recently all the Windows header files have been versioned to only define constants, structures, and APIs if the source is explicitly compiled for a Windows OS version that supports those definitions.&amp;nbsp; This allows developers to use one set of headers that can be compiled for any target Windows OS. Unfortunately, this also means if you don't define _WIN32_WINNT at all, many of the definitions are not declared at all.&lt;/P&gt;
&lt;P&gt;The good news is the downloadable SDK does set this define according to the target OS selected when running under the SDK environment. However, Visual Studio does not set this define. Therefore if your build environment of choice is VS, you may need to set this define in your project in order to compile correctly for your targeted OS.&lt;/P&gt;
&lt;P&gt;To target a project for Vista, _WIN32_WINNT should be set to 0x0600. For a complete list of OS target version numbers, see the following KB article:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/using_the_windows_headers.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/using_the_windows_headers.asp&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;-Anthony Jones (AJones)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=571105" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category></item><item><title>Introduction to Winsock Kernel (WSK)</title><link>http://blogs.msdn.com/wndp/archive/2006/02/24/538746.aspx</link><pubDate>Fri, 24 Feb 2006 20:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:538746</guid><dc:creator>wndpteam</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/wndp/comments/538746.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=538746</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;Overview of WSK&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;In Windows Vista a new transport-independent kernel mode Network Programming Interface (NPI) called Winsock Kernel (WSK) has been added.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Using WSK, kernel-mode software modules can perform network communication using socket-like programming semantics similar to those supported in user-mode Winsock2.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;While the WSK NPI supports most of the same socket programming concepts as user-mode Winsock2 like socket creation, bind, connect, accept, send and receive, it is a completely new programming interface with unique characteristics such as asynchronous I/O that uses IRPs and event callbacks to enhance performance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;WSK was designed with the following goals in mind:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.4in; TEXT-INDENT: -0.1in; mso-list: l0 level1 lfo1; tab-stops: list .4in"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Courier New'"&gt;&lt;SPAN style="mso-list: Ignore"&gt;o&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; Provide a simple to use, Winsock2-like interface to kernel mode developers.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.3in"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.4in; TEXT-INDENT: -0.1in; mso-list: l0 level1 lfo1; tab-stops: list .4in"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Courier New'"&gt;&lt;SPAN style="mso-list: Ignore"&gt;o&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;Better expose the innovations made by the next generation TCP/IP stack in Windows Vista&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.4in; TEXT-INDENT: -0.1in; mso-list: l0 level1 lfo1; tab-stops: list .4in"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Courier New'"&gt;&lt;SPAN style="mso-list: Ignore"&gt;o&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; Improve scalability and efficiency by improving on the performance and memory limitations of previous Network Programming Interfaces (NPI).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For example, WSK has improved socket creation performance and a smaller memory footprint per socket than past NPIs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.3in"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.4in; TEXT-INDENT: -0.1in; mso-list: l0 level1 lfo1; tab-stops: list .4in"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Courier New'"&gt;&lt;SPAN style="mso-list: Ignore"&gt;o&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; Easy to port existing TDI clients to WSK.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Components such as http.sys (kernel mode HTTP handler) within Windows Vista have ported from TDI to WSK with ease. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;At the core of WSK is the WSK subsystem, which implements the WSK Provider NPI.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;At its upper edge, WSK exposes this provider implementation for use by WSK applications.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;At its lower edge, the WSK subsystem interfaces with transport providers such as the TCP/IP stack.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;WSK applications implement the WSK Client NPI and consume the WSK Provider NPI to perform network I/O operations.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;IMG src="/photos/mflasko/images/538744/original.aspx"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt;: All components in the diagram above reside in the kernel&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;Some of the additional benefits in WSK include:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.4in; TEXT-INDENT: -0.1in; mso-list: l0 level1 lfo1; tab-stops: list .4in"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Courier New'"&gt;&lt;SPAN style="mso-list: Ignore"&gt;o&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; Enhanced IPv6 support.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;WSK clients can use a single IPv6 socket to handle both IPv4 and IPv6 traffic.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For example a single WSK listening socket can accept both IPv4 and IPv6 connections. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.3in"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.4in; TEXT-INDENT: -0.1in; mso-list: l0 level1 lfo1; tab-stops: list .4in"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Courier New'"&gt;&lt;SPAN style="mso-list: Ignore"&gt;o&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; Improved Serviceability. The WSK subsystem hides the intricacies of transport discovery and load/unload handling from the WSK clients. This allows the WSK subsystem to improve the &lt;SPAN style="mso-bidi-font-weight: bold"&gt;system’s&lt;/SPAN&gt; serviceability with minimal direct impact on WSK clients.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.3in"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.4in; TEXT-INDENT: -0.1in; mso-list: l0 level1 lfo1; tab-stops: list .4in"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Courier New'"&gt;&lt;SPAN style="mso-list: Ignore"&gt;o&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; Uniform support for standard options or IOCTLs across all transports&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.3in"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;TDI and WSK&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;TDI is a widely used interface to interact with the network stack and intercept application traffic. Since prior to Windows Vista, the user mode Winsock2 API used the TDI interface to interact with TCP/IP. Kernel-mode TDI filter drivers were used by some software vendors to intercept all Winsock traffic before it was submitted to the TCP/IP stack. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;A TDI client also enabled a driver to send and receive data to/from the TCP/IP stack.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Even though TDI has been a worthy predecessor for WSK for over a decade, it has shortcomings such as a sharp learning curve and performance bottlenecks.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;In Windows Vista, WSK is the recommended NPI for performing network I/O in the kernel and the Windows Filtering Platform (WFP) is the recommended API for network filtering (replacement for TDI filter drivers).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;New kernel mode clients should opt to use WSK for network I/O instead of TDI because WSK is more flexible, easier to use, and offers much better performance.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;To take advantage of the next generation stack, existing TDI applications should move to WSK in the Windows Vista timeframe. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;On Windows Vista, TDI is still supported; however, it has been implemented using a translation layer and thus its performance is sub-optimal resulting in performance degradation for TDI clients.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In addition, the capabilities that are available using TDI are going to be significantly more limited than through WSK as no new functionality is being developed for TDI.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;WSK applications are not limited to the TCP/IP transport implemented in the next generation TCP/IP stack in Windows Vista. WSK allows its clients to use protocols implemented by TDI-based transports by translating WSK operations to TDI operations on behalf of the client for those TDI transports denoted by the client. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;This gives clients of WSK the convenience of a single NPI rather than using WSK for some protocols and TDI for others. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;WSK also allows TDI filters to intercept TCP/IP traffic to/from WSK clients to facilitate a smooth transition period during which software vendors move from TDI filters to WFP for performing network traffic filtering.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;Additional Information&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;If you have any questions, comments or would like to obtain a copy of the WSK documentation and associated sample, please email &lt;A href="mailto:wskapi@microsoft.com"&gt;wskapi@microsoft.com&lt;/A&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;WSK bugs and feature suggestions can be submitted to the Microsoft bug database by joining the Windows Network Developer Platform (WNDP) program at the Microsoft Connect website: &lt;A href="http://connect.microsoft.com"&gt;&lt;FONT color=#800080&gt;http://connect.microsoft.com&lt;/FONT&gt;&lt;/A&gt;. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;Note: The WSK sample will not build in WDK build 5308 due to missing header files.&amp;nbsp; This is a known issue and should be corrected in the Beta 2 WDK.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;-- Mike Flasko&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=538746" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category></item><item><title>Winsock and Vista User Account Control</title><link>http://blogs.msdn.com/wndp/archive/2006/02/22/537082.aspx</link><pubDate>Wed, 22 Feb 2006 20:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:537082</guid><dc:creator>wndpteam</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/wndp/comments/537082.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=537082</wfw:commentRss><description>&lt;SPAN style="COLOR: black"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt; 
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;As you might have heard, &lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:place w:st="on"&gt;Vista&lt;/st1:place&gt; introduces User Account Control (UAC) which is a security feature that enables users to perform some tasks as non-Administrators. This has an effect on LSP writers as the Winsock functions to install and remove LSP entries can only be called as an Administrator. On &lt;st1:place w:st="on"&gt;Vista&lt;/st1:place&gt; there is a difference between the built in local Administrator account and users that are a member of the Administrators group. That is, users that are a member of the Administrators group are actually running with reduced privileges compared to the built in Administrator account.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;The effect of this change is that the LSP install functions will return an access denied error unless the user is the built-in Administrator or unless the installing application is modified to prompt the user whether the installation should be allowed. The sample LSP has been updated to illustrate this change. The updated sample can be obtained from the Microsoft Connect website:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://connect.microsoft.com/"&gt;&lt;FONT color=#800080&gt;http://connect.microsoft.com&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Once at the site, select 'available programs' from the navigation bar on the left side of the screen. You then need to join the 'WNDP' (Windows Network Developer Platform) group. From there the sample is available in the 'downloads' section.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;In order for the install application to prompt a limited user whether to continue with the installation, an application manifest needs to be created. This is an XML file named the same as the installing executable with '.manifest' appended to the end (e.g. instlsp.exe.manifest). The manifest is pretty simple – it simply describes the application and indicates that the application requires administrative privileges to install correctly:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&amp;lt;assembly xmlns="urn:schemas-microsoft-com:asm.v1"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;manifestVersion="1.0"&amp;gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;assemblyIdentity version="1.0.0.0"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;name="instlsp.exe"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;type="win32"/&amp;gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;description&amp;gt;instlsp - Sample LSP installer&amp;lt;/description&amp;gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;!-- Identify the application security requirements. --&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;security&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;requestedPrivileges&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;requestedExecutionLevel&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;level="requireAdministrator"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;uiAccess="false"/&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/requestedPrivileges&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/security&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/trustInfo&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 12.0pt"&gt;&amp;lt;/assembly&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Once the manifest is created, it simply needs to be referenced in the application’s resource file with the following directive:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;#define&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; MANIFEST_RESOURCE_ID&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;MANIFEST_RESOURCE_ID&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;RT_MANIFEST &lt;SPAN style="COLOR: maroon"&gt;"instlsp.exe.manifest"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: black; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: black; mso-no-proof: yes"&gt;You can take a look at the updated sample for the full details, but it is pretty straight forward.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: black; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: black; mso-no-proof: yes"&gt;There are a number of UAC related resources to find more information:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="COLOR: black; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in" type=disc&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: black; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;Getting Started with UAC&lt;o:p&gt;&lt;/o:p&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: navy; FONT-FAMILY: Verdana"&gt;&lt;A title=http://www.microsoft.com/technet/windowsvista/evaluate/feat/uaprot.mspx href="http://www.microsoft.com/technet/windowsvista/evaluate/feat/uaprot.mspx"&gt;&lt;FONT color=#800080&gt;http://www.microsoft.com/technet/windowsvista/evaluate/fea&lt;/FONT&gt;&lt;/A&gt;&lt;A title=http://www.microsoft.com/technet/windowsvista/evaluate/feat/uaprot.mspx href="http://www.microsoft.com/technet/windowsvista/evaluate/feat/uaprot.mspx"&gt;&lt;FONT color=#800080&gt;t/uaprot.mspx&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in" type=disc&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: black; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;UAC Developer Guidelines&lt;o:p&gt;&lt;/o:p&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: navy; FONT-FAMILY: Verdana"&gt;&lt;A title=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnlong/html/AccProtVista.asp href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnlong/html/AccProtVista.asp"&gt;&lt;FONT color=#800080&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-&lt;/FONT&gt;&lt;/A&gt;&lt;A title=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnlong/html/AccProtVista.asp href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnlong/html/AccProtVista.asp"&gt;&lt;FONT color=#800080&gt;us/dnlong/html/AccProtVista.asp&lt;/FONT&gt;&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in" type=disc&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: black; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;UAC Blog&lt;o:p&gt;&lt;/o:p&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;U&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Verdana"&gt;&lt;A title=http://blogs.msdn.com/uac HREF="/uac"&gt;&lt;FONT color=#800080&gt;http://blogs.msdn.com/uac&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/U&gt;&lt;SPAN style="COLOR: black"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL style="MARGIN-TOP: 0in" type=disc&gt;
&lt;LI class=MsoNormal style="MARGIN: 0in 0in 0pt; COLOR: black; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;UAC Question on Update&lt;o:p&gt;&lt;/o:p&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; COLOR: navy; FONT-FAMILY: Verdana"&gt;&lt;A title=http://forums.microsoft.com/msdn/showpost.aspx?postid=111453&amp;amp;siteid=1 href="http://forums.microsoft.com/msdn/showpost.aspx?postid=111453&amp;amp;siteid=1"&gt;&lt;FONT color=#800080&gt;http://forums.microsoft.com/msdn/showpost.aspx?postid=111&lt;/FONT&gt;&lt;/A&gt;&lt;A title=http://forums.microsoft.com/msdn/showpost.aspx?postid=111453&amp;amp;siteid=1 href="http://forums.microsoft.com/msdn/showpost.aspx?postid=111453&amp;amp;siteid=1"&gt;&lt;FONT color=#800080&gt;453&amp;amp;siteid=1&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"&gt;&lt;SPAN style="COLOR: black"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;-- Anthony Jones (AJones)&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=537082" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category></item><item><title>Categorizing LSPs and Applications</title><link>http://blogs.msdn.com/wndp/archive/2006/02/09/529031.aspx</link><pubDate>Fri, 10 Feb 2006 03:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:529031</guid><dc:creator>wndpteam</dc:creator><slash:comments>15</slash:comments><comments>http://blogs.msdn.com/wndp/comments/529031.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wndp/commentrss.aspx?PostID=529031</wfw:commentRss><description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;In Windows Vista there is a new method for categorizing both Winsock Layered Service Providers (LSP) and applications themselves such that only certain LSPs will be loaded. There are a couple reasons for adding this functionality. One of the main reasons is certain system critical processes such as WinLogon and LSASS create sockets but do not send any traffic on the network so most LSPs should not be loaded.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;A large percentage of the crashes we see are due to buggy LSPs that cause LSASS.EXE to crash and if it crashes the system forces a shutdown. A side affect of these system processes loading LSPs is that these processes never exit so when an LSP is installed or removed, a reboot is required.&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Secondly, there are some cases where applications may not want to load certain LSPs. For example, some apps may not want to load crypto LSPs so they can communicate with other machines that do not have the cypto LSP installed.&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Finally, the LSP categories can be used by other LSPs to determine where in the Winsock protocol chain they should install themselves. For years, various LSP developers have wanted a way of knowing how an LSP will behave. For example, an LSP that inspects the data stream would want to be &lt;i style="mso-bidi-font-style: normal"&gt;above&lt;/i&gt; an LSP that encrypts the data. Of course, this method isn’t fool proof since it relies on 3&lt;sup&gt;rd&lt;/sup&gt; party LSPs to categorize themselves appropriately, but hopefully, the security enhancements in &lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:place w:st="on"&gt;Vista&lt;/st1:place&gt; will help prevent users from unintentionally installing malicious LSPs.&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Winsock has defined nine different types of LSPs:&lt;/p&gt;
&lt;ol style="MARGIN-TOP: 0in" type=1&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;LSP_SYSTEM – an LSP that should be loaded into system critical processes 
&lt;/li&gt;&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;LSP_INSPECTOR – an LSP that simply monitors the inbound and outbound traffic but does not the data. An HTTP content filterer is an example of an inspector (as it will deny the request). 
&lt;/li&gt;&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;LSP_REDIRECTOR – this type of LSP simply modifies the addresses used in Winsock calls. 
&lt;/li&gt;&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;LSP_PROXY – this LSP redirects Winsock calls to a proxy server as well as instruct the proxy via a control channel to establish outbound connections. 
&lt;/li&gt;&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;LSP_FIREWALL – an LSP that monitors incoming and outbound connection requests. A firewall LSP should only inspect data and deny request but not actually modify the data. 
&lt;/li&gt;&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;LSP_INBOUND_MODIFY – filters inbound data 
&lt;/li&gt;&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;LSP_OUTBOUT_MODIFY – filter outbound data 
&lt;/li&gt;&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;LSP_CRYPTO_COMPRESS – a crypto or compression LSP can modify both inbound and outbound traffic but also includes and out of band signing/negotiation phase. 
&lt;/li&gt;&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in"&gt;LSP_LOCAL_CACHE – an LSP that inspects the contents of a Winsock request and satisfying the request by generating the expected response without the request actually hitting the intended destination.&lt;/li&gt;&lt;/ol&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Note that it is possible to categorize an LSP as more than one type. In fact an LSP categorized as LSP_SYSTEM should also be categorized with the type(s) that best describe how it inspects or modifies the Winsock calls.&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;On Vista , the majority of the system critical processes and system services are already registered with the appropriate categories depending on their functionality.&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Categorizing LSPs&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;There are two new APIs for categorizing an LSP which are defined in ws2spi.h:&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;int&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;WSPAPI&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;WSCSetProviderInfo(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LPGUID lpProviderId,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;WSC_PROVIDER_INFO_TYPE InfoType,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;PBYTE Info,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;size_t InfoSize,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD Flags,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LPINT lpErrno&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;int&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;WSPAPI&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;WSCGetProviderInfo(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LPGUID lpProviderId,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;WSC_PROVIDER_INFO_TYPE InfoType,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;PBYTE Info,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;size_t *InfoSize,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD Flags,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LPINT lpErrno&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;In order to categorize an LSP, WSCSetProviderInfo is called that specifies the GUID of the hidden LSP entry (i.e. the LSP entry installed whose ProtocolChain.ChainLen is zero). The WSC_PROVIDER_INFO_TYPE is an enumeration and &lt;i style="mso-bidi-font-style: normal"&gt;ProviderInfoLspCategories&lt;/i&gt; should be passed. Then a simple DWORD with the appropriate LSP_* flags above is passed as the &lt;i style="mso-bidi-font-style: normal"&gt;Info &lt;/i&gt;parameter. For example:&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;lspCategory = LSP_INBOUND_MODIFY | LSP_OUTBOUND_MODIFY;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GUID&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;lspGuid = &amp;amp;YOUR_LSP_GUID;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;int&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;rc, err;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;rc = WSCSetProviderInfo( &amp;amp;lspGuid, ProviderInfoLspCategories, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;(PBYTE) &amp;amp;lspCategory, sizeof(lspCategory), 0, &amp;amp;err);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Retrieving the LSP category is similar to setting it but using the WSCGetProviderInfo call.&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Categorizing Applications&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;The other part of the equation is categorizing applications themselves to specify those LSPs that should be loaded in its process. This is done via the following two functions also defined in ws2spi.h:&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;int&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;WSPAPI&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;WSCSetApplicationCategory(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LPCWSTR Path,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD PathLength,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LPCWSTR Extra,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD ExtraLength,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD PermittedLspCategories,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD * pPrevPermLspCat,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LPINT lpErrno&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;int&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;WSPAPI&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;WSCGetApplicationCategory(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LPCWSTR Path,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD PathLength,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LPCWSTR Extra,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD ExtraLength,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD * pPermittedLspCategories,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LPINT lpErrno&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;In the functions above &lt;i style="mso-bidi-font-style: normal"&gt;Path&lt;/i&gt; is the full path and executable name while &lt;i style="mso-bidi-font-style: normal"&gt;Extra&lt;/i&gt; is the arguments passed to that application. The &lt;i style="mso-bidi-font-style: normal"&gt;Path&lt;/i&gt; argument can contain environment variables as the function calls will expand them as necessary. Note that an application is defined as the full path and executable name as well as any arguments. Thus if the application “c:\foo.exe” is categorized as LSP_PROXY, the application “c:\foo.exe –x 12” is different and would not be considered as allowing LSP_PROXY LSPs. &lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;The following code categorizes “foo.exe –x 12”:&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;rc = WSCSetApplicationCategory( &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;L”%windir%\\foo.exe”, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;lstrlenW(L”%windir%\\foo.exe”),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;L”-x 12”,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;lstrlenW(L”-x 12”),&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;LSP_SYSTEM | LSP_FIREWALL | LSP_CRYPTO_COMPRESS,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&amp;amp;err&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in"&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;The &lt;i style="mso-bidi-font-style: normal"&gt;pPrevPermLspCat&lt;/i&gt; parameter is optional and simply returns the previous categories set for this application if it existed.&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Determining Which LSPs Get Loaded&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;The final part of LSP categorization is determining which LSPs will be loaded into which processes. When a process loads Winsock, both the application category and the LSP categories for all installed LSPs and the following comparisons made:&lt;/p&gt;
&lt;ol style="MARGIN-TOP: 0in" type=1&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo2; tab-stops: list .5in"&gt;If the application is not categorized, allow all LSPs 
&lt;/li&gt;&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo2; tab-stops: list .5in"&gt;If both the application and the LSP have assigned categories, all of the following must be true: 
&lt;ol style="MARGIN-TOP: 0in" type=a&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level2 lfo2; tab-stops: list 1.0in"&gt;At least one of the LSP categories is present in the application’s specified categories 
&lt;/li&gt;&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level2 lfo2; tab-stops: list 1.0in"&gt;ONLY categories specified in the application’s specified categories are specified in the LSPs categories (i.e. if the app specifies a category is must be in the LSP’s category, but if the app specifies a category that is not present in the LSPs category then that is OK) 
&lt;/li&gt;&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level2 lfo2; tab-stops: list 1.0in"&gt;If LSP_SYSTEM is present in the application’s category, it MUST be present in the LSP’s categories&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;NOTE: If an LSP is not categorized its category is effectively 0. Basically, for a match to occur all the LSP’s specified categories must be present in the application’s categories (i.e. the app must be a superset of the LSP) – with the caveat that if LSP_SYSTEM is present in the app’s category is must also be present in the LSP’s category.&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Consider the following example:&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Foo.exe is categorized as LSP_SYSTEM + LSP_FIREWALL + LSP_CRYPTO_COMPRESS&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Bar.exe is categorized as LSP_FIREWALL + LSP_CRYPTO_COMPRESS&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;There are four LSPs installed on the system:&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LSP1: &lt;span style="mso-tab-count: 1"&gt;&lt;/span&gt;LSP_SYSTEM&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LSP2: 0 (no category set)&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LSP3: LSP_FIREWALL&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LSP4: LSP_SYSTEM + LSP_FIREWALL + LSP_CRYPTO_COMPRESS + LSP_INSPECTOR&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;In this example, Foo.exe would only load LSP1 while Bar.exe would load LSP3.&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;--Anthony Jones (AJones)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=529031" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wndp/archive/tags/Winsock/default.aspx">Winsock</category></item></channel></rss>