[Last Edited on 12/7/2004]
The target audience for this post is LSP developers who are looking to install their LSP. Developers with experience with desktop LSP installation will also find this very useful.
This post also explains LSP installation differences between CE and XP, and explains how to install an LSP on CE.
Note this post applies to Windows CE 5.0 and greater. As with earlier releases, LSP chain order on CE is solely determined by the order of installation. However, prior to version 5.0 there was no “Order” key and installation order was difficult to coordinate.
1) LSP Installation differences between CE and the desktop
Installed catalog is not persisted across reboots No WSCWriteProviderOrder function No SPORDER application WSCEnemurateProviders returns current catalog (not catalog at time app started) Installing LSP on the fly can be dangerous All LSP Installers run on every bootup Order of LSP chains is based on order installation routines run LSPs have cooperative installers
2) Problems when installing LSPs on the fly:
* LSP change hasn’t taken effect for all apps: device.exe/services.exe runs for the lifetime of the CE device Already open sockets will not use new LSP but new sockets will LSP usually cache catalog at startup. LSP won’t see changed catalog till restart.
Server application is creating and using sockets Socket A is created with one chain before the LSP installs Socket B is created with another chain after install If the application calls select with socket A and B, select fails because the sockets have two different providers (see the documentation for select).
3) Why select works for IPv4 / IPv6, TCP / UDP:
SOCKET sv4 = socket (AF_INET,..); SOCKET sv6 = socket (AF_INET6,...); FDSET fds; FD_SET(fds,sv4); FD_SET(fds,sv6); Select (fdset1,...);
You would expect this to fail since sv4 and sv6 should be implemented by different providers. But our default base providers install with same GUID, so this call will work with no LSPs installed. Several apps, including Activesync, call select on both IPv4 and IPv6 sockets in the same fd_set.
4) What should your LSP Installer do?
* Layer over TCPv4/TCPv6/UDPv4/UDPv6 with the same ProviderId GUID. Keeps select() working for all applications.
5) How to configure CE to install your LSP
* Add a key to:
[HKEY_LOCAL_MACHINE\Comm\WS2\LSP\<your lsp>] "Dll"="your_lsp.dll" ; DLL containing your installer ;"DllEntry"="DllRegisterServer" ; // Function called to perform installation ; // Default value is DllRegisterServer
"Order"=dword:400 ; // Order at which you’ll install ; // Default value is 0xFFFFFFFF ; // Change this value to change your position in the ; // Protocol Stack
* On startup, before any apps have called WSAStartup, all installers will be run in the order specified (lowest Order value first).
[Author: Igor Dvorkin]