Retail products


Traffic interception SDK

Control every TCP/IP network connection

  • Route connections via proxy
  • Redirect connections and modify the data
  • Block connections and applications
SSL interception SDK

View SSL in plaintext and modify it

  • View the SSL stream decrypted in plaintext
  • Redirect SSL connection and modify decrypted data
  • Browser shows "SSL lock" without warnings

Documentation


instlsp.h File Reference

#include <winsock2.h>
#include <mswsock.h>
#include <ws2spi.h>
#include <objbase.h>
#include <rpc.h>
#include <rpcdce.h>
#include <sporder.h>
#include <winnt.h>
#include <windows.h>
#include <strsafe.h>
#include "lspcommon.h"
#include <stdio.h>
#include <stdlib.h>

Include dependency graph for instlsp.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


Classes

struct  _LSP_ENTRY

Defines

#define DEFAULT_LSP_NAME   "Test LSP2"
#define LAYERED_CHAIN   ( BASE_PROTOCOL + 1 )
#define UPDATE_LSP_ENTRY   0
#define MAX(a, b)   ( (a) > (b) ? (a) : (b) )
#define MIN(a, b)   ( (a) < (b) ? (a) : (b) )

Typedefs

typedef int(WSAAPI * LPWSCINSTALLPROVIDERANDCHAINS )(LPGUID lpProviderId, LPWSTR lpszProviderDllPath, LPWSTR lpszLspName, DWORD dwServiceFlags, LPWSAPROTOCOL_INFOW lpProtocolInfoList, DWORD dwNumberOfEntries, LPDWORD lpdwCatalogEntryId, LPINT lpErrno)
typedef struct _LSP_ENTRY LSP_ENTRY

Functions

int InstallLsp (WINSOCK_CATALOG eCatalog, __in_z char *lpszLspName, __in_z char *lpszLspPathAndFile, DWORD dwCatalogIdArrayCount, DWORD *pdwCatalogIdArray, BOOL IfsProvider, BOOL InstallOverAll)
int InstallProvider (WINSOCK_CATALOG Catalog, GUID *Guid, __in_z WCHAR *lpwszLspPath, WSAPROTOCOL_INFOW *pProvider, INT iProviderCount)
int InstallProviderVista (WINSOCK_CATALOG eCatalog, __in_z WCHAR *lpszLspName, __in_z WCHAR *lpszLspPathAndFile, GUID *providerGuid, DWORD dwCatalogIdArrayCount, DWORD *pdwCatalogIdArray, BOOL IfsProvider, BOOL InstallOverAll)
WSAPROTOCOL_INFOW * CreateDummyEntry (WINSOCK_CATALOG Catalog, INT CatalogId, __in_z WCHAR *lpwszLspName, BOOL IfsProvider)
int InstallIfsLspProtocolChains (WINSOCK_CATALOG eCatalog, GUID *Guid, __in_z WCHAR *lpszLspName, __in_z WCHAR *lpszLspFullPathAndFile, DWORD *pdwCatalogIdArray, DWORD dwCatalogIdArrayCount)
int InstallNonIfsLspProtocolChains (WINSOCK_CATALOG eCatalog, GUID *Guid, __in_z WCHAR *lpszLspName, __in_z WCHAR *lpszLspFullPathAndFile, DWORD *pdwCatalogIdArray, DWORD dwCatalogIdArrayCount)
int InsertIfsLspIntoAllChains (WSAPROTOCOL_INFOW *OriginalEntry, WSAPROTOCOL_INFOW *Catalog, int CatalogCount, int IfsEntryIdx, int ChainIdx)
int ReorderCatalog (WINSOCK_CATALOG Catalog, DWORD dwLayeredId)
DWORD * ReorderACatalog (WINSOCK_CATALOG Catalog, DWORD dwLayerId, INT *dwEntryCount)
int WriteProviderOrder (WINSOCK_CATALOG Catalog, DWORD *pdwCatalogOrder, DWORD dwNumberOfEntries, INT *lpErrno)
int RemoveAllLayeredEntries (WINSOCK_CATALOG Catalog)
int DeinstallProvider (WINSOCK_CATALOG Catalog, GUID *Guid)
int UpdateProvider (WINSOCK_CATALOG Catalog, LPGUID ProviderId, WCHAR *DllPath, WSAPROTOCOL_INFOW *ProtocolInfoList, DWORD NumberOfEntries, LPINT lpErrno)
int RemoveProvider (WINSOCK_CATALOG Catalog, DWORD dwProviderId)
void PrintProviders (WINSOCK_CATALOG Catalog, BOOL bLayeredOnly, BOOL bVerbose)
LSP_ENTRYBuildLspMap (WSAPROTOCOL_INFOW *pProviders, int iProviderCount, int *pLspCount)
void PrintLspMap (LSP_ENTRY *pLspMap, int iLspCount)
void FreeLspMap (LSP_ENTRY *pLspMap, int iLspCount)
int LspDependencyCheck (LSP_ENTRY *pLspMap, int iLspCount)
void UpdateLspMap (LSP_ENTRY *pLspMap, DWORD dwOldValue, DWORD dwNewValue)
void MapNewEntriesToOld (LSP_ENTRY *pEntry, WSAPROTOCOL_INFOW *pProvider, int iProviderCount)
int AddGuidToLspEntry (LSP_ENTRY *entry, GUID *guid, int *lpErrno)
void UpdateProviderOrder (LSP_ENTRY *UpdatedEntry, DWORD *OrderArray, int ArrayCount)
int MaxLayeredChainCount (LSP_ENTRY *pLspMap, int LspCount)
BOOL RemoveIdFromChain (WSAPROTOCOL_INFOW *pInfo, DWORD dwCatalogId)
BOOL IsIdInChain (WSAPROTOCOL_INFOW *pInfo, DWORD dwId)
int GetProviderCount (WSAPROTOCOL_INFOW *pProviders, int iProviderCount, int iProviderType)
int GetLayeredEntriesByGuid (WSAPROTOCOL_INFOW *pMatchLayers, int *iLayeredCount, WSAPROTOCOL_INFOW *pEntries, int iEntryCount, GUID *MatchGuid)
BOOL IsEqualProtocolEntries (WSAPROTOCOL_INFOW *pInfo1, WSAPROTOCOL_INFOW *pInfo2)
int RetrieveLspGuid (__in_z char *LspPath, GUID *Guid)
BOOL IsNonIfsProvider (WSAPROTOCOL_INFOW *pProvider, int iProviderCount, DWORD dwProviderId)
HMODULE LoadUpdateProviderFunction ()
int CountOrphanedChainEntries (WSAPROTOCOL_INFOW *pCatalog, int iCatalogCount)
WSAPROTOCOL_INFOW * FindProviderById (DWORD CatalogId, WSAPROTOCOL_INFOW *Catalog, int CatalogCount)
WSAPROTOCOL_INFOW * FindProviderByGuid (GUID *Guid, WSAPROTOCOL_INFOW *Catalog, int CatalogCount)
DWORD GetCatalogIdForProviderGuid (GUID *Guid, WSAPROTOCOL_INFOW *Catalog, int CatalogCount)
DWORD FindDummyIdFromProtocolChainId (DWORD CatalogId, WSAPROTOCOL_INFOW *Catalog, int CatalogCount)
void InsertIdIntoProtocolChain (WSAPROTOCOL_INFOW *Entry, int Index, DWORD InsertId)
void BuildSubsetLspChain (WSAPROTOCOL_INFOW *Entry, int Index, DWORD DummyId)

Variables

LPWSCUPDATEPROVIDER fnWscUpdateProvider
LPWSCUPDATEPROVIDER fnWscUpdateProvider32
HMODULE gModule
GUID gProviderGuid

Define Documentation

#define DEFAULT_LSP_NAME   "Test LSP2"

Definition at line 42 of file instlsp.h.

#define LAYERED_CHAIN   ( BASE_PROTOCOL + 1 )

Definition at line 44 of file instlsp.h.

#define MAX ( a,
 )     ( (a) > (b) ? (a) : (b) )

Definition at line 48 of file instlsp.h.

#define MIN ( a,
 )     ( (a) < (b) ? (a) : (b) )

Definition at line 49 of file instlsp.h.

#define UPDATE_LSP_ENTRY   0

Definition at line 46 of file instlsp.h.


Typedef Documentation

typedef int(WSAAPI * LPWSCINSTALLPROVIDERANDCHAINS)(LPGUID lpProviderId, LPWSTR lpszProviderDllPath, LPWSTR lpszLspName, DWORD dwServiceFlags, LPWSAPROTOCOL_INFOW lpProtocolInfoList, DWORD dwNumberOfEntries, LPDWORD lpdwCatalogEntryId, LPINT lpErrno)

Definition at line 51 of file instlsp.h.

typedef struct _LSP_ENTRY LSP_ENTRY


Function Documentation

int AddGuidToLspEntry ( LSP_ENTRY entry,
GUID *  guid,
int *  lpErrno 
)

Definition at line 853 of file lspmap.cpp.

00858 {
00859     BOOL    bFound;
00860     int     rc,
00861             i;
00862 
00863     if ( 0 == entry->Count )
00864     {
00865         entry->LayeredGuids = (GUID *) LspAlloc(
00866                 sizeof( GUID ),
00867                 lpErrno 
00868                 );
00869         if ( NULL == entry->LayeredGuids )
00870         {
00871             fprintf( stderr, "AddGuidToLspEntry: LspAlloc failed: %d\n", *lpErrno );
00872             goto cleanup;
00873         }
00874 
00875         memcpy( &entry->LayeredGuids[ 0 ], guid, sizeof( GUID ) );
00876 
00877         entry->LayeredGuidCount++;
00878     }
00879     else
00880     {
00881         // See if we've already seen this guid
00882         bFound = FALSE;
00883         for(i=0; i < entry->LayeredGuidCount ;i++)
00884         {
00885             rc = memcmp( &entry->LayeredGuids[ i ], guid, sizeof( GUID ) );
00886             if ( 0 == rc )
00887             {
00888                 bFound = TRUE;
00889                 break;
00890             }
00891         }
00892         if ( FALSE == bFound )
00893         {
00894             GUID    *tmpguid = NULL;
00895 
00896             // New GUID -- we need to add it to the array
00897             tmpguid = (GUID *) LspAlloc(
00898                     sizeof( GUID ) * ( entry->LayeredGuidCount + 1 ),
00899                     lpErrno
00900                     );
00901             if ( NULL == tmpguid )
00902             {
00903                 fprintf( stderr, "AddGuidToLspEntry: LspAlloc failed: %d\n", *lpErrno );
00904                 goto cleanup;
00905             }
00906 
00907             memcpy( tmpguid, entry->LayeredGuids, sizeof(GUID) * entry->LayeredGuidCount );
00908 
00909             memcpy( &tmpguid[ entry->LayeredGuidCount ], guid, sizeof( GUID ) );
00910 
00911             LspFree( entry->LayeredGuids );
00912 
00913             entry->LayeredGuids = tmpguid;
00914             entry->LayeredGuidCount++;
00915         }
00916     }
00917 
00918     return NO_ERROR;
00919 
00920 cleanup:
00921 
00922     return SOCKET_ERROR;
00923 }

LSP_ENTRY* BuildLspMap ( WSAPROTOCOL_INFOW *  pProviders,
int  iProviderCount,
int *  pLspCount 
)

Definition at line 110 of file lspmap.cpp.

00115 {
00116     LSP_ENTRY *pLsps = NULL,
00117                lsptmp;
00118     DWORD     *pBaseList = NULL;
00119     int        iLspCount = 0,
00120                iSortLspCount = 0,
00121                iOrphanCount = 0,
00122                iBaseCount = 0,
00123                iProviderPathLen,
00124                ErrorCode,
00125                LspOrder,
00126                start,
00127                end,
00128                idx,
00129                rc,
00130                i, j, k;
00131 
00132     // Retrieve how many orphaned chain entries are present
00133     iOrphanCount = CountOrphanedChainEntries( pProviders, iProviderCount );
00134 
00135     // Retrieve the LSP count
00136     iSortLspCount = iLspCount = GetProviderCount( pProviders, iProviderCount, LAYERED_PROTOCOL );
00137 
00138     if ( ( 0 == iOrphanCount ) && ( 0 == iLspCount ) )
00139     {
00140         fprintf( stderr, "BuildLspMap: No LSP installed on the system!\n");
00141         goto cleanup;
00142     }
00143 
00144     // If orphaned entries are present, create another LSP_ENTRY and put all orphaned
00145     //      entries there.
00146     if ( iOrphanCount > 0 )
00147         iLspCount++;
00148 
00149     // Allocate space for our structure which represents the LSPs installed
00150     pLsps = (LSP_ENTRY *) LspAlloc(
00151             sizeof( LSP_ENTRY ) * iLspCount,
00152            &ErrorCode
00153             );
00154     if ( NULL == pLsps )
00155     {
00156         fprintf( stderr, "BuildLspMap: LspAlloc failed: %d\n", ErrorCode );
00157         goto cleanup;
00158     }
00159 
00160     // If orphaned entries are present, allocate space to hold them
00161     if ( iOrphanCount > 0 )
00162     {
00163         pLsps[ iLspCount-1 ].LayeredEntries = (WSAPROTOCOL_INFOW *)LspAlloc(
00164                 sizeof(WSAPROTOCOL_INFOW) * iOrphanCount, &ErrorCode );
00165         if ( NULL == pLsps[ iLspCount-1 ].LayeredEntries )
00166         {
00167             fprintf( stderr, "BuildLspMap: LspAlloc failed: %d\n", ErrorCode );
00168             goto cleanup;
00169         }
00170 
00171         pLsps[ iLspCount-1 ].OrphanedEntries = TRUE;
00172         pLsps[ iLspCount-1 ].Count = iOrphanCount;
00173 
00174         //
00175         // Find the orphaned entries and save them off
00176         //
00177         idx = 0;
00178         for(i=0; i < iProviderCount ;i++)
00179         {
00180             // Only investigate protocol chain entries (i.e. chainlen > 1)
00181             if ( pProviders[ i ].ProtocolChain.ChainLen > 1 )
00182             {
00183                 // Walk the catalog and look for the dummy entry (i.e. the ID in 
00184                 //    chain entry 0)
00185                 for(j=0; j < iProviderCount ;j++) 
00186                 {
00187                     if ( i == j )
00188                         continue;
00189 
00190                     if ( pProviders[ i ].ProtocolChain.ChainEntries[ 0 ] ==
00191                          pProviders[ j ].dwCatalogEntryId )
00192                     {
00193                         break;
00194                     }
00195                 }
00196                 if ( j >= iProviderCount )
00197                 {
00198                     // If j is past iProviderCount, no match was found so this is
00199                     //    an orphaned entry...save it off
00200                     memcpy( &pLsps[ iLspCount-1 ].LayeredEntries[ idx ],
00201                             &pProviders[ i ],
00202                              sizeof( WSAPROTOCOL_INFOW )
00203                           );
00204                     rc = AddGuidToLspEntry( &pLsps[ iLspCount-1 ], &pProviders[ i ].ProviderId,
00205                             &ErrorCode );
00206                     if ( SOCKET_ERROR == rc )
00207                     {
00208                         fprintf( stderr, "BuildLspMap: AddGuidToLspEntry failed: %d\n", ErrorCode );
00209                         goto cleanup;
00210                     }
00211                         
00212                     idx++;
00213                 }
00214             }
00215         }
00216     }
00217 
00218     //
00219     // Build a list of the valid LSPs installed on the system
00220     //
00221     idx = 0;
00222     for(i=0; i < iProviderCount ;i++)
00223     {
00224         if ( LAYERED_PROTOCOL == pProviders[ i ].ProtocolChain.ChainLen )
00225         {
00226             // Copy the dummy entry
00227             memcpy( &pLsps[ idx ].DummyEntry, &pProviders[ i ], sizeof( WSAPROTOCOL_INFOW ) );
00228 
00229             // Get the DLL path
00230             iProviderPathLen = MAX_PATH-1;
00231             rc = WSCGetProviderPath(
00232                     &pLsps[ idx ].DummyEntry.ProviderId,
00233                      pLsps[ idx ].wszLspDll,
00234                     &iProviderPathLen,
00235                     &ErrorCode
00236                      );
00237             if ( SOCKET_ERROR == rc )
00238             {
00239                 fprintf( stderr, "BuildLspMap: WSCGetProviderPath failed: %d\n", ErrorCode );
00240                 goto cleanup;
00241             }
00242 
00243             //
00244             // Now go find all the layered entries associated with the dummy provider
00245             //
00246 
00247             // First get the count
00248             for(j=0; j < iProviderCount ;j++)
00249             {
00250                 //
00251                 // Compare only the first entry against the dummy ID. Otherwise, 
00252                 //    we may pick up more than the provider's owned by this LSP 
00253                 //    (it may pick up other providers layered over this LSP.
00254                 //
00255                 if ( ( pProviders[ j ].ProtocolChain.ChainLen > 1 ) &&
00256                      ( pProviders[ j ].ProtocolChain.ChainEntries[ 0 ] ==
00257                        pLsps[ idx ].DummyEntry.dwCatalogEntryId ) 
00258                    )
00259                 // if ( IsIdInChain( &pProviders[ j ], pLsps[ idx ].DummyEntry.dwCatalogEntryId ) )
00260                 {
00261                     pLsps[idx].Count++;
00262                 }
00263             }
00264 
00265             // Allocate space
00266             pLsps[ idx ].LayeredEntries = (WSAPROTOCOL_INFOW *) LspAlloc(
00267                     sizeof( WSAPROTOCOL_INFOW ) * pLsps[ idx ].Count,
00268                    &ErrorCode
00269                     );
00270             if ( NULL == pLsps[ idx ].LayeredEntries )
00271             {
00272                 fprintf( stderr, "BuildLspMap: LspAlloc failed: %d\n", ErrorCode );
00273                 goto cleanup;
00274             }
00275 
00276             pLsps[ idx ].LayerChanged = (int *) LspAlloc(
00277                     sizeof( int ) * pLsps[ idx ].Count,
00278                    &ErrorCode
00279                     );
00280             if ( NULL == pLsps[ idx ].LayerChanged )
00281             {
00282                 fprintf( stderr, "BuildLspMap: LspAlloc failed: %d\n", ErrorCode );
00283                 goto cleanup;
00284             }
00285 
00286             // Now go find the entries
00287             pLsps[idx].Count = 0;
00288             for(j=0; j < iProviderCount ;j++)
00289             {
00290                 if ( ( pProviders[ j ].ProtocolChain.ChainLen > 1 ) &&
00291                      ( pProviders[ j ].ProtocolChain.ChainEntries[ 0 ] ==
00292                        pLsps[ idx ].DummyEntry.dwCatalogEntryId ) 
00293                    )
00294                 {
00295                     memcpy( 
00296                            &pLsps[ idx ].LayeredEntries[pLsps[ idx ].Count],
00297                            &pProviders[ j ],
00298                             sizeof( WSAPROTOCOL_INFOW )
00299                             );
00300 
00301                     pLsps[idx].MaxChainLength = MAX( 
00302                             pLsps[ idx ].MaxChainLength,
00303                             pLsps[ idx ].LayeredEntries[ pLsps[idx].Count ].ProtocolChain.ChainLen 
00304                             );
00305 
00306                     // Mark this entry as visited
00307                     pProviders[ j ].dwProviderReserved = 1;
00308 
00309                     // Keep track of how many GUIDs are used to install the layered entries
00310                     rc = AddGuidToLspEntry( &pLsps[ idx ], &pProviders[ j ].ProviderId, &ErrorCode );
00311                     if ( SOCKET_ERROR == rc )
00312                     {
00313                         fprintf( stderr, "BuildLspMap: AddGuidToLspEntry failed: %d\n", ErrorCode );
00314                         goto cleanup;
00315                     }
00316 
00317                     pLsps[ idx ].Count++;
00318                 }
00319             }
00320 
00321             pLsps[ idx ].LspOrder = MAX_PROTOCOL_CHAIN;
00322 
00323             idx++;      // Increment index into the map
00324         }
00325     }
00326 
00327     //
00328     // We now have an array of "LSPs" -- now order them
00329     //
00330 
00331     // First get a list of base provider IDs
00332     iBaseCount = GetProviderCount( pProviders, iProviderCount, BASE_PROTOCOL );
00333     if ( 0 == iBaseCount )
00334     {
00335         fprintf( stderr, "BuildLspMap: GetProviderCount(BASE_PROTOCOL) returned zero!\n" );
00336         goto cleanup;
00337     }
00338 
00339     // Allocate space for the array of base provider ID's
00340     pBaseList = (DWORD *) LspAlloc(
00341             sizeof( DWORD ) * iBaseCount,
00342            &ErrorCode
00343             );
00344     if ( NULL == pBaseList )
00345     {
00346         fprintf( stderr, "BuildLspMap: HeapAlloc failed: %d\n", ErrorCode );
00347         goto cleanup;
00348     }
00349 
00350     //
00351     // Copy the base provider ID's to our array -- this array contains the catalog
00352     // IDs of only base providers which will be used next to determine the order
00353     // in which LSPs were installed.
00354     //
00355     idx = 0;
00356     for(i=0; i < iProviderCount ;i++)
00357     {
00358         if ( BASE_PROTOCOL == pProviders[ i ].ProtocolChain.ChainLen )
00359         {
00360             pBaseList[ idx++ ] = pProviders[ i ].dwCatalogEntryId;
00361         }
00362     }
00363 
00364     //
00365     // For each layered protocol entry of an LSP find the lowest index in the protocol
00366     // chain where a base provider resides. A protocol chain should always terminate
00367     // in a base provider.
00368     //
00369     for(LspOrder = 1; LspOrder < MAX_PROTOCOL_CHAIN ;LspOrder++)
00370     {
00371         for(i=0; i < iSortLspCount ;i++)
00372         {
00373             for(j=0; j < pLsps[ i ].Count ;j++)
00374             {
00375                 for(k=0; k < iBaseCount ;k++)
00376                 {
00377                     if ( pLsps[ i ].LayeredEntries[ j ].ProtocolChain.ChainEntries[ LspOrder ] ==
00378                          pBaseList[ k ] )
00379                     {
00380                         pLsps[ i ].LspOrder = MIN( pLsps[ i ].LspOrder, LspOrder );
00381                         break;
00382                     }
00383                 }
00384             }
00385         }
00386     }
00387 
00388     //
00389     // Sort the entries according to the LspOrder field
00390     //
00391     for(i=0; i < iSortLspCount ;i++)
00392     {
00393         for(j=i; j < iSortLspCount ;j++)
00394         {
00395             if ( pLsps[ i ].LspOrder > pLsps[ j ].LspOrder )
00396             {
00397                 // Exchange positions
00398                 memcpy( &lsptmp,     &pLsps[ i ], sizeof( LSP_ENTRY ) );
00399                 memcpy( &pLsps[ i ], &pLsps[ j ], sizeof( LSP_ENTRY ) );
00400                 memcpy( &pLsps[ j ], &lsptmp,     sizeof( LSP_ENTRY ) );
00401             }
00402         }
00403     }
00404 
00405     //
00406     // Now need to sort by MaxChainLength withing the LspOrder groupings
00407     //
00408     for(LspOrder=1; LspOrder < MAX_PROTOCOL_CHAIN ;LspOrder++)
00409     {
00410         // Find the start and end positions within the array for the given
00411         // LspOrder value
00412         start = -1;
00413         end   = -1;
00414 
00415         for(i=0; i < iSortLspCount ;i++)
00416         {
00417             if ( pLsps[ i ].LspOrder == LspOrder )
00418             {
00419                 start = i;
00420                 break;
00421             }
00422         }
00423 
00424         //
00425         // Find the end position which is the LSP Map entry whose LspOrder
00426         // value doesn't match the current one. This will give us the range
00427         // of LSP entries whose LspOrder value is identical -- we need to
00428         // sort the LSPs of the same LspOrder according to the MaxChainLength
00429         //
00430         if ( -1 != start )
00431         {
00432             for(j=start; j < iSortLspCount ;j++)
00433             {
00434                 if ( pLsps[ j ].LspOrder != LspOrder )
00435                 {
00436                     end = j - 1;
00437                     break;
00438                 }
00439             }
00440         }
00441         
00442         //
00443         // If the following is true then all entries have the same order
00444         // value. We still need to sort by MaxChainLength so set the end
00445         // to the last LSP 
00446         //
00447         if ( ( -1 != start ) && ( -1 == end ) )
00448         {
00449             end = iSortLspCount - 1;
00450         }
00451 
00452         if ( ( -1 != start ) && ( -1 != end ) )
00453         {
00454             for(i=start; i < end ;i++)
00455             {
00456                 for(j=i; j < end ;j++)
00457                 {
00458                     if ( pLsps[ i ].MaxChainLength > pLsps[ j ].MaxChainLength )
00459                     {
00460                         memcpy( &lsptmp,     &pLsps[ i ], sizeof( LSP_ENTRY ) );
00461                         memcpy( &pLsps[ i ], &pLsps[ j ], sizeof( LSP_ENTRY ) );
00462                         memcpy( &pLsps[ j ], &lsptmp,     sizeof( LSP_ENTRY ) );
00463                     }
00464                 }
00465             }
00466         }
00467     }
00468 
00469     // Add the LSP dependency info to the map
00470     rc = LspDependencyCheck( pLsps, iSortLspCount );
00471     if ( SOCKET_ERROR == rc )
00472     {
00473         FreeLspMap( pLsps, iLspCount );
00474         pLsps = NULL;
00475         iLspCount = 0;
00476         goto cleanup;
00477     }
00478 
00479 cleanup:
00480     
00481     if ( NULL != pLspCount )
00482         *pLspCount = iLspCount;
00483 
00484     if ( NULL != pBaseList )
00485         LspFree( pBaseList );
00486 
00487     return pLsps;
00488 }

void BuildSubsetLspChain ( WSAPROTOCOL_INFOW *  Entry,
int  Index,
DWORD  DummyId 
)

Definition at line 570 of file lsputil.cpp.

00575 {
00576     int     Idx, i;
00577 
00578     for(i=Index,Idx=1; i < Entry->ProtocolChain.ChainLen ;i++,Idx++)
00579     {
00580         Entry->ProtocolChain.ChainEntries[ Idx ] = Entry->ProtocolChain.ChainEntries[ i ];
00581     }
00582 
00583     Entry->ProtocolChain.ChainEntries[ 0 ] = DummyId;
00584     Entry->ProtocolChain.ChainLen = Entry->ProtocolChain.ChainLen - Index + 1;
00585 }

int CountOrphanedChainEntries ( WSAPROTOCOL_INFOW *  pCatalog,
int  iCatalogCount 
)

Definition at line 380 of file lsputil.cpp.

00384 {
00385     int     orphanCount = 0,
00386             i, j;
00387 
00388     for(i=0; i < iCatalogCount ;i++)
00389     {
00390         if ( pCatalog[ i ].ProtocolChain.ChainLen > 1 )
00391         {
00392             for(j=0; j < iCatalogCount ;j++)
00393             {
00394                 if ( i == j )
00395                     continue;
00396                 if ( pCatalog[ j ].dwCatalogEntryId == pCatalog[ i ].ProtocolChain.ChainEntries[ 0 ] )
00397                 {
00398                     break;
00399                 }
00400             }
00401             if ( j >= iCatalogCount )
00402                 orphanCount++;
00403         }
00404     }
00405 
00406     return orphanCount;
00407 }

WSAPROTOCOL_INFOW* CreateDummyEntry ( WINSOCK_CATALOG  Catalog,
INT  CatalogId,
__in_z WCHAR *  lpwszLspName,
BOOL  IfsProvider 
)

int DeinstallProvider ( WINSOCK_CATALOG  Catalog,
GUID *  Guid 
)

Definition at line 202 of file lspdel.cpp.

00206 {
00207     INT     ErrorCode,
00208             rc;
00209 
00210 #ifdef _WIN64
00211     if ( LspCatalogBoth == Catalog )
00212     {
00213         // Remove from 64-bit catalog
00214         rc = WSCDeinstallProvider( Guid, &ErrorCode );
00215         if ( SOCKET_ERROR == rc )
00216         {
00217             fprintf( stderr, "DeinstallProvider: WSCDeinstallProvider failed: %d\n", 
00218                     ErrorCode 
00219                     );
00220         }
00221 
00222         // Remove from the 32-bit catalog
00223         rc = WSCDeinstallProvider32( Guid, &ErrorCode );
00224         if ( SOCKET_ERROR == rc )
00225         {
00226             fprintf( stderr, "DeinstallProvider: WSCDeinstallProvider32 failed: %d\n", 
00227                     ErrorCode 
00228                     );
00229         }
00230     }
00231     else if ( LspCatalog64Only == Catalog )
00232     {
00233         // Remove from 64-bit catalog
00234         rc = WSCDeinstallProvider( Guid, &ErrorCode );
00235         if ( SOCKET_ERROR == rc )
00236         {
00237             fprintf( stderr, "DeinstallProvider: WSCDeinstallProvider failed: %d\n", 
00238                     ErrorCode 
00239                     );
00240         }
00241     }
00242     else
00243     {
00244         // Remove from the 32-bit catalog
00245         rc = WSCDeinstallProvider32( Guid, &ErrorCode );
00246         if ( SOCKET_ERROR == rc )
00247         {
00248             fprintf( stderr, "DeinstallProvider: WSCDeinstallProvider32 failed: %d\n", 
00249                     ErrorCode 
00250                     );
00251         }
00252     }
00253 #else
00254     if ( LspCatalog32Only == Catalog )
00255     {
00256         // Remove from the 32-bit catalog
00257         rc = WSCDeinstallProvider( Guid, &ErrorCode );
00258         if ( SOCKET_ERROR == rc )
00259         {
00260             fprintf( stderr, "DeinstallProvider: WSCDeinstallProvider failed: %d\n", 
00261                     ErrorCode 
00262                     );
00263         }
00264     }
00265     else
00266     {
00267         fprintf( stderr, "Unable to remove providers in 64-bit catalog from 32-bit process!\n" );
00268         return SOCKET_ERROR;
00269     }
00270 #endif
00271 
00272     return NO_ERROR;
00273 }

DWORD FindDummyIdFromProtocolChainId ( DWORD  CatalogId,
WSAPROTOCOL_INFOW *  Catalog,
int  CatalogCount 
)

Definition at line 501 of file lsputil.cpp.

00506 {
00507     int     i;
00508 
00509     for(i=0; i < CatalogCount ;i++)
00510     {
00511         if ( CatalogId == Catalog[ i ].dwCatalogEntryId )
00512         {
00513             if ( Catalog[ i ].ProtocolChain.ChainLen == LAYERED_PROTOCOL )
00514                 return Catalog[ i ].dwCatalogEntryId;
00515             else
00516                 return Catalog[ i ].ProtocolChain.ChainEntries[ 0 ];
00517         }
00518     }
00519 
00520     ASSERT( 0 );
00521 
00522     return 0;
00523 }

WSAPROTOCOL_INFOW* FindProviderByGuid ( GUID *  Guid,
WSAPROTOCOL_INFOW *  Catalog,
int  CatalogCount 
)

Definition at line 442 of file lsputil.cpp.

00447 {
00448     int     i;
00449 
00450     for(i=0; i < CatalogCount ;i++)
00451     {
00452         if ( 0 == memcmp( &Catalog[ i ].ProviderId, Guid, sizeof( GUID ) ) )
00453         {
00454             return &Catalog[ i ];
00455         }
00456     }
00457 
00458     return NULL;
00459 }

WSAPROTOCOL_INFOW* FindProviderById ( DWORD  CatalogId,
WSAPROTOCOL_INFOW *  Catalog,
int  CatalogCount 
)

Definition at line 417 of file lsputil.cpp.

00422 {
00423     int     i;
00424 
00425     for(i=0; i < CatalogCount ;i++)
00426     {
00427         if ( Catalog[ i ].dwCatalogEntryId == CatalogId )
00428             return &Catalog[ i ];
00429     }
00430     return NULL;
00431 }

void FreeLspMap ( LSP_ENTRY pLspMap,
int  iLspCount 
)

Definition at line 583 of file lspmap.cpp.

00587 {
00588     int     i;
00589 
00590     for(i=0; i < iLspCount ;i++)
00591     {
00592         // Free the layered providers first
00593         if ( NULL != pLspMap[ i ].LayeredEntries )
00594             LspFree( pLspMap[ i ].LayeredEntries );
00595 
00596         if ( NULL != pLspMap[ i ].LayeredGuids )
00597             LspFree( pLspMap[ i ].LayeredGuids );
00598 
00599         if ( NULL != pLspMap[ i ].LayerChanged )
00600             LspFree( pLspMap[ i ].LayerChanged );
00601 
00602         if ( NULL != pLspMap[ i ].DependentLspIndexArray )
00603             LspFree( pLspMap[ i ].DependentLspIndexArray );
00604     }
00605     LspFree( pLspMap );
00606 }

DWORD GetCatalogIdForProviderGuid ( GUID *  Guid,
WSAPROTOCOL_INFOW *  Catalog,
int  CatalogCount 
)

Definition at line 469 of file lsputil.cpp.

00474 {
00475     WSAPROTOCOL_INFOW *match = NULL;
00476 
00477     match = FindProviderByGuid( Guid, Catalog, CatalogCount );
00478     if ( NULL != match )
00479     {
00480         return match->dwCatalogEntryId;
00481     }
00482 
00483     return 0;
00484 }

int GetLayeredEntriesByGuid ( WSAPROTOCOL_INFOW *  pMatchLayers,
int *  iLayeredCount,
WSAPROTOCOL_INFOW *  pEntries,
int  iEntryCount,
GUID *  MatchGuid 
)

Definition at line 118 of file lsputil.cpp.

00125 {
00126     int                count, 
00127                        err = SOCKET_ERROR,
00128                        i;
00129 
00130     // First count how many entries belong to this GUID
00131     count = 0;
00132     for(i=0; i < iEntryCount ;i++)
00133     {
00134         if ( 0 == memcmp( MatchGuid, &pEntries[i].ProviderId, sizeof( GUID ) ) )
00135             count++;
00136     }
00137 
00138     // Make sure the array passed in is large enough to hold the results
00139     if ( count > *iLayeredCount )
00140     {
00141         *iLayeredCount = count;
00142         goto cleanup;
00143     }
00144 
00145     // Go back and copy the matching providers into our array
00146     count = 0;
00147     for(i=0; i < iEntryCount ;i++)
00148     {
00149         if ( 0 == memcmp( MatchGuid, &pEntries[ i ].ProviderId, sizeof( GUID ) ) )
00150         {
00151             memcpy( &pMatchLayers[ count++ ], &pEntries[ i ], sizeof( WSAPROTOCOL_INFOW ) );
00152         }
00153     }
00154 
00155     *iLayeredCount = count;
00156 
00157     err = NO_ERROR;
00158 
00159 cleanup:
00160 
00161     return err;
00162 }

int GetProviderCount ( WSAPROTOCOL_INFOW *  pProviders,
int  iProviderCount,
int  iProviderType 
)

Definition at line 83 of file lsputil.cpp.

00088 {
00089     int Count, i;
00090 
00091     Count = 0;
00092     for(i=0; i < iProviderCount ;i++)
00093     {
00094         if ( ( LAYERED_CHAIN == iProviderType ) && ( pProviders[ i ].ProtocolChain.ChainLen > 1 ) )
00095             Count++;
00096         else if ( ( LAYERED_CHAIN != iProviderType) && ( pProviders[ i ].ProtocolChain.ChainLen == iProviderType ) )
00097             Count++;
00098     }
00099     return Count;
00100 }

void InsertIdIntoProtocolChain ( WSAPROTOCOL_INFOW *  Entry,
int  Index,
DWORD  InsertId 
)

Definition at line 535 of file lsputil.cpp.

00540 {
00541     int     i;
00542 
00543     for(i=Entry->ProtocolChain.ChainLen; i > Index ;i--)
00544     {
00545         Entry->ProtocolChain.ChainEntries[ i ] = Entry->ProtocolChain.ChainEntries[ i - 1 ];
00546     }
00547 
00548     Entry->ProtocolChain.ChainEntries[ Index ] = InsertId;
00549     Entry->ProtocolChain.ChainLen++;
00550 }

int InsertIfsLspIntoAllChains ( WSAPROTOCOL_INFOW *  OriginalEntry,
WSAPROTOCOL_INFOW *  Catalog,
int  CatalogCount,
int  IfsEntryIdx,
int  ChainIdx 
)

Definition at line 947 of file lspadd.cpp.

00954 {
00955     WSAPROTOCOL_INFOW   TempEntry = {0};
00956     int                 Idx, i, j, k;
00957 
00958     for(i=ChainIdx; i > 0 ;i--)
00959     {
00960         #ifdef DBG
00961         printf( "Looking for entry: %d\n", OriginalEntry->ProtocolChain.ChainEntries[ i ] );
00962         #endif
00963 
00964         for(j=0; j < CatalogCount ;j++)
00965         {
00966             if ( Catalog[ j ].dwCatalogEntryId == OriginalEntry->ProtocolChain.ChainEntries[ i ] ) 
00967             {
00968                 printf( "Found match: %ws\n", Catalog[ j ].szProtocol );
00969                 Idx = j;
00970 
00971                 if ( Catalog[ j ].ProtocolChain.ChainLen == LAYERED_PROTOCOL )
00972                 {
00973                     Idx = -1;
00974 
00975                     // Not good. The catalog ID in the chain points to the dummy
00976                     // entry. We'll need to do some other heuristic to find the
00977                     // "right" entry.
00978                     for(k=0; k < CatalogCount ;k++)
00979                     {
00980                         if ( ( OriginalEntry->iAddressFamily == Catalog[ k ].iAddressFamily ) &&
00981                              ( OriginalEntry->iSocketType == Catalog[ k ].iSocketType ) && 
00982                              ( OriginalEntry->iProtocol == Catalog[ k ].iProtocol ) &&
00983                              ( (i+1) == Catalog[ k ].ProtocolChain.ChainLen )
00984                            )
00985                         {
00986                             Idx = k;
00987                             break;
00988                         }
00989                     }
00990                 }
00991 
00992                 if ( Idx != -1 )
00993                 {
00994                     // Found a match and need to insert the new IFS LSP into the chain
00995                     memcpy( &TempEntry, &Catalog[ Idx ], sizeof( TempEntry ) );
00996 
00997                     if ( Catalog[ Idx ].ProtocolChain.ChainLen >= 2 )
00998                     {
00999                         for(k=Catalog[ Idx ].ProtocolChain.ChainLen-2 ; k >= 0 ;k--)
01000                         {
01001                             if ( TRUE == IsNonIfsProvider( Catalog, CatalogCount, 
01002                                     Catalog[ Idx ].ProtocolChain.ChainEntries[ k ] ) )
01003                             {
01004                                 // K points to first non-IFS provider - insert after
01005                                 InsertIdIntoProtocolChain( &Catalog[ Idx ], k+1, UPDATE_LSP_ENTRY );
01006 
01007                                 // Save the index to the layer which corresponds to this entry
01008                                 Catalog[ Idx ].dwProviderReserved = IfsEntryIdx;
01009                             }
01010                         }
01011                     }
01012                 }
01013                 else
01014                 {
01015                     printf( "????? Index not found ????\n" );
01016                 }
01017 
01018                 break;
01019             }
01020         }
01021     }
01022 
01023     return 0;
01024 }

int InstallIfsLspProtocolChains ( WINSOCK_CATALOG  eCatalog,
GUID *  Guid,
__in_z WCHAR *  lpszLspName,
__in_z WCHAR *  lpszLspFullPathAndFile,
DWORD *  pdwCatalogIdArray,
DWORD  dwCatalogIdArrayCount 
)

int InstallLsp ( WINSOCK_CATALOG  eCatalog,
__in_z char *  lpszLspName,
__in_z char *  lpszLspPathAndFile,
DWORD  dwCatalogIdArrayCount,
DWORD *  pdwCatalogIdArray,
BOOL  IfsProvider,
BOOL  InstallOverAll 
)

Definition at line 31 of file lspadd.cpp.

00040 {
00041     OSVERSIONINFOEX     osv = {0};
00042     WSAPROTOCOL_INFOW  *pProtocolInfo = NULL,
00043                        *pDummyEntry = NULL,
00044                        *pLayeredEntries = NULL;
00045     WCHAR               wszLspName[ WSAPROTOCOL_LEN ],
00046                         wszFullProviderPath[ MAX_PATH+1 ];
00047     GUID                ProviderBaseGuid;
00048     INT                 rc = SOCKET_ERROR;
00049 
00050     //
00051     // Install the LSP over the given entries. If selected to install over all
00052     // entries, then enumerate the catalog to obtain all the available providers.
00053     //
00054 
00055     if ( NULL == lpszLspName )
00056     {
00057         lpszLspName = DEFAULT_LSP_NAME;
00058     }
00059 
00060     // Convert the LSP name to UNICODE since the Winsock catalog is all UNICODE
00061     rc = MultiByteToWideChar(
00062             CP_ACP, 
00063             0, 
00064             lpszLspName, 
00065             (int) strlen( lpszLspName ) + 1,
00066             wszLspName, 
00067             WSAPROTOCOL_LEN 
00068             );
00069     if (rc == 0)
00070     {
00071         fprintf(stderr, "InstallLsp: MultiByteToWideChar failed to convert '%s'; Error = %d\n",
00072                 lpszLspName, GetLastError());
00073         goto cleanup;
00074     }
00075 
00076     rc = MultiByteToWideChar(
00077             CP_ACP,
00078             0,
00079             lpszLspPathAndFile,
00080             (int) strlen( lpszLspPathAndFile ) + 1,
00081             wszFullProviderPath,
00082             MAX_PATH
00083             );
00084     if ( 0 == rc )
00085     {
00086         fprintf( stderr, "InstallLsp: MultiByteToWidechar failed to convert '%s': Error = %d\n",
00087                 lpszLspPathAndFile, GetLastError() );
00088         goto cleanup;
00089     }
00090 
00091     // Verify there's at least one entry to layer over
00092     if ( 0 == dwCatalogIdArrayCount )
00093     {
00094         fprintf(stderr, "InstallLsp: Error! Must specify at least one provider to layer over!\n\n");
00095         goto cleanup;
00096     }
00097 
00098     printf("LSP name is '%S'\n", wszLspName);
00099 
00100     // Retrieve the GUID under which the LSP is to be installed
00101     RetrieveLspGuid( lpszLspPathAndFile, &ProviderBaseGuid );
00102 
00103     osv.dwOSVersionInfoSize = sizeof(osv);
00104     GetVersionEx( (LPOSVERSIONINFO) &osv );
00105 
00106     if ( osv.dwMajorVersion >= 6 ) 
00107     {
00108         // On Windows Vista, use the new LSP install API
00109 
00110         rc = InstallProviderVista(
00111                 eCatalog,
00112                 wszLspName,
00113                 wszFullProviderPath,
00114                &ProviderBaseGuid,
00115                 dwCatalogIdArrayCount,
00116                 pdwCatalogIdArray,
00117                 IfsProvider,
00118                 InstallOverAll
00119                 );
00120         if ( SOCKET_ERROR == rc )
00121         {
00122             goto cleanup;
00123         }
00124 
00125     }
00126     else
00127     {
00128         //
00129         // This isn't Vista so install the LSP the old way
00130         //
00131 
00132         // Create the 'dummy' protocol entry
00133         pDummyEntry = CreateDummyEntry( eCatalog, pdwCatalogIdArray[ 0 ], wszLspName, IfsProvider );
00134         if (pDummyEntry == NULL)
00135         {
00136             fprintf(stderr, "InstallLsp: CreateDummyEntry failed!\n");
00137             goto cleanup;
00138         }
00139 
00140         // Install the 'dummy' protocol entry for the LSP
00141         rc = InstallProvider(
00142                 eCatalog, 
00143                 &ProviderBaseGuid, 
00144                 wszFullProviderPath, 
00145                 pDummyEntry, 
00146                 1
00147                 );
00148         if ( NO_ERROR != rc )
00149         {
00150             fprintf(stderr, "InstallLsp: Unable to install the dummy LSP entry!\n");
00151             goto cleanup;
00152         }
00153 
00154         // Don't need this struture any more
00155         LspFree( pDummyEntry );
00156         pDummyEntry = NULL;
00157 
00158         if ( FALSE == IfsProvider )
00159         {
00160             rc = InstallNonIfsLspProtocolChains( eCatalog, &ProviderBaseGuid, wszLspName,
00161                     wszFullProviderPath, pdwCatalogIdArray, dwCatalogIdArrayCount );
00162 
00163         }
00164         else
00165         {
00166             rc = InstallIfsLspProtocolChains( eCatalog, &ProviderBaseGuid, wszLspName,
00167                     wszFullProviderPath, pdwCatalogIdArray, dwCatalogIdArrayCount );
00168         }
00169 
00170         if ( SOCKET_ERROR == rc )
00171         {
00172             // An error occured installing the chains so remove the dummy entry
00173             DeinstallProvider( eCatalog, &ProviderBaseGuid );
00174         }
00175 
00176     }
00177 
00178 cleanup:
00179 
00180     if ( NULL != pProtocolInfo )
00181         FreeProviders( pProtocolInfo );
00182 
00183     if ( NULL != pDummyEntry )
00184         LspFree( pDummyEntry );
00185 
00186     if ( NULL != pLayeredEntries )
00187         LspFree( pLayeredEntries );
00188 
00189     return rc;
00190 }

int InstallNonIfsLspProtocolChains ( WINSOCK_CATALOG  eCatalog,
GUID *  Guid,
__in_z WCHAR *  lpszLspName,
__in_z WCHAR *  lpszLspFullPathAndFile,
DWORD *  pdwCatalogIdArray,
DWORD  dwCatalogIdArrayCount 
)

int InstallProvider ( WINSOCK_CATALOG  Catalog,
GUID *  Guid,
__in_z WCHAR *  lpwszLspPath,
WSAPROTOCOL_INFOW *  pProvider,
INT  iProviderCount 
)

int InstallProviderVista ( WINSOCK_CATALOG  eCatalog,
__in_z WCHAR *  lpszLspName,
__in_z WCHAR *  lpszLspPathAndFile,
GUID *  providerGuid,
DWORD  dwCatalogIdArrayCount,
DWORD *  pdwCatalogIdArray,
BOOL  IfsProvider,
BOOL  InstallOverAll 
)

BOOL IsEqualProtocolEntries ( WSAPROTOCOL_INFOW *  pInfo1,
WSAPROTOCOL_INFOW *  pInfo2 
)

Definition at line 177 of file lsputil.cpp.

00181 {
00182     if ( (memcmp(&pInfo1->ProviderId, &pInfo2->ProviderId, sizeof(GUID)) == 0) &&
00183          (pInfo1->dwServiceFlags1 == pInfo2->dwServiceFlags1) &&
00184          (pInfo1->dwServiceFlags2 == pInfo2->dwServiceFlags2) &&
00185          (pInfo1->dwServiceFlags3 == pInfo2->dwServiceFlags3) &&
00186          (pInfo1->dwServiceFlags4 == pInfo2->dwServiceFlags4) &&
00187          (pInfo1->ProtocolChain.ChainLen == pInfo2->ProtocolChain.ChainLen) &&
00188          (pInfo1->iVersion == pInfo2->iVersion) &&
00189          (pInfo1->iAddressFamily == pInfo2->iAddressFamily) &&
00190          (pInfo1->iMaxSockAddr == pInfo2->iMaxSockAddr) &&
00191          (pInfo1->iMinSockAddr == pInfo2->iMinSockAddr) &&
00192          (pInfo1->iSocketType == pInfo2->iSocketType) &&
00193          (pInfo1->iProtocol == pInfo2->iProtocol) &&
00194          (pInfo1->iProtocolMaxOffset == pInfo2->iProtocolMaxOffset) &&
00195          (pInfo1->iNetworkByteOrder == pInfo2->iNetworkByteOrder) &&
00196          (pInfo1->iSecurityScheme == pInfo2->iSecurityScheme) &&
00197          (pInfo1->dwMessageSize == pInfo2->dwMessageSize)
00198        )
00199     {
00200         return TRUE;
00201     }
00202     else
00203     {
00204         return FALSE;
00205     }
00206 }

BOOL IsIdInChain ( WSAPROTOCOL_INFOW *  pInfo,
DWORD  dwId 
)

Definition at line 59 of file lsputil.cpp.

00062 {
00063     int     i;
00064 
00065     for(i=0; i < pInfo->ProtocolChain.ChainLen ;i++)
00066     {
00067         if ( pInfo->ProtocolChain.ChainEntries[ i ] == dwId )
00068             return TRUE;
00069     }
00070     return FALSE;
00071 }

BOOL IsNonIfsProvider ( WSAPROTOCOL_INFOW *  pProvider,
int  iProviderCount,
DWORD  dwProviderId 
)

Definition at line 270 of file lsputil.cpp.

00275 {
00276     int     i;
00277 
00278     for(i=0; i < iProviderCount ;i++)
00279     {
00280         if ( pProvider[ i ].dwCatalogEntryId == dwProviderId )
00281         {
00282             return !( pProvider[ i ].dwServiceFlags1 & XP1_IFS_HANDLES );
00283         }
00284     }
00285     
00286     return FALSE;
00287 }

HMODULE LoadUpdateProviderFunction (  ) 

Definition at line 302 of file lsputil.cpp.

00303 {
00304     HMODULE hModule = NULL;
00305     HRESULT hr;
00306     char    WinsockLibraryPath[ MAX_PATH+1 ],
00307             szExpandPath[ MAX_PATH+1 ];
00308 
00309     //
00310     // See if we're on a platform that supports WSCUpdateProvider. If so then
00311     // uninstalling an LSP is easy; otherwise, it is very painful if you're
00312     // removing an LSP that has other LSPs on top if it.
00313     //
00314     if ( GetSystemDirectoryA( WinsockLibraryPath, MAX_PATH+1 ) == 0 )
00315     {
00316         hr = StringCchCopyA( szExpandPath, MAX_PATH+1, "%SYSTEMROOT%\\system32" );
00317         if ( FAILED( hr ) )
00318         {
00319             fprintf( stderr, "LoadUpdateProviderFunctions: StringCchCopyA failed: 0x%x\n", hr );
00320             goto cleanup;
00321         }
00322 
00323         if ( ExpandEnvironmentStringsA( WinsockLibraryPath, szExpandPath, MAX_PATH+1 ) == 0 )
00324         {
00325             fprintf(stderr, "LoadUpdateProviderFunctions: Unable to expand environment string: %d\n", 
00326                     GetLastError()
00327                    );
00328             goto cleanup;
00329         }
00330     }
00331 
00332     hr = StringCchCatA( WinsockLibraryPath, MAX_PATH+1, WINSOCK_DLL );
00333     if ( FAILED( hr ) )
00334     {
00335         fprintf( stderr, "LoadUpdateProviderFunctions: StringCchCatA failed: 0x%x\n", hr );
00336         goto cleanup;
00337     }
00338 
00339     hModule = LoadLibraryA( WinsockLibraryPath );
00340     if (hModule == NULL)
00341     {
00342         fprintf(stderr, "LoadUpdateProviderFunctions: Unable to load %s: %d\n", 
00343                 WinsockLibraryPath, GetLastError()
00344                 );
00345         goto cleanup;
00346     }
00347 #ifdef _WIN64
00348     fnWscUpdateProvider   = (LPWSCUPDATEPROVIDER)GetProcAddress(hModule, "WSCUpdateProvider");
00349 
00350     fnWscUpdateProvider32 = (LPWSCUPDATEPROVIDER)GetProcAddress(hModule, "WSCUpdateProvider32");
00351 #else
00352     fnWscUpdateProvider   = (LPWSCUPDATEPROVIDER)GetProcAddress(hModule, "WSCUpdateProvider");
00353 #endif
00354 
00355     return hModule;
00356 
00357 cleanup:
00358 
00359     if ( NULL != hModule )
00360     {
00361         FreeLibrary( hModule );
00362         hModule = NULL;
00363     }
00364 
00365     return NULL;
00366 }

int LspDependencyCheck ( LSP_ENTRY pLspMap,
int  iLspCount 
)

Definition at line 621 of file lspmap.cpp.

00625 {
00626     BOOL        bDependent;
00627     int         iCheckLspIndex = 0,
00628                 ret = SOCKET_ERROR,
00629                *tmpArray = NULL,
00630                 ErrorCode,
00631                 i, j, k, l;
00632 
00633     // For each LSP entry, find its dependencies
00634     for(i=0; i < iLspCount ;i++)
00635     {
00636         iCheckLspIndex = i;
00637 
00638         // Search all other LSPs for dependencies on this entry
00639         for(j=0; j < iLspCount ;j++)
00640         {
00641             // Skip checking against the same one were currently looking at
00642             if ( j == iCheckLspIndex )
00643                 continue;
00644 
00645             bDependent = FALSE;
00646 
00647             // Check the dummy catalog entry against all the chains for the LSP we're
00648             // currently looking at
00649             for(k=0; k < pLspMap[ j ].Count ;k++)
00650             {
00651                 if ( IsIdInChain(
00652                            &pLspMap[ j ].LayeredEntries[ k ],
00653                             pLspMap[ iCheckLspIndex ].DummyEntry.dwCatalogEntryId )
00654                    )
00655                 {
00656                     // Allocate an array for the dependent LSP indices
00657                     tmpArray = (int *) LspAlloc(
00658                             sizeof( int ) * ( pLspMap[ iCheckLspIndex ].DependentCount + 1),
00659                            &ErrorCode
00660                             );
00661                     if ( NULL == tmpArray )
00662                     {
00663                         fprintf( stderr, "CheckLspDependency: LspAlloc failed: %d\n", ErrorCode );
00664                         goto cleanup;
00665                     }
00666 
00667                     // If one already exists, copy the existing array into the new one
00668                     if ( NULL != pLspMap[ iCheckLspIndex ].DependentLspIndexArray )
00669                     {
00670                         memcpy( 
00671                                 tmpArray + 1,
00672                                 pLspMap[ iCheckLspIndex ].DependentLspIndexArray,
00673                                 sizeof( int ) * pLspMap[ iCheckLspIndex ].DependentCount
00674                                 );
00675 
00676                         // Free the existing array
00677                         LspFree( pLspMap[ iCheckLspIndex ].DependentLspIndexArray );
00678                     }
00679                     
00680                     // Assign the new array and increment the count
00681                     pLspMap[ iCheckLspIndex ].DependentLspIndexArray = tmpArray;
00682                     pLspMap[ iCheckLspIndex ].DependentLspIndexArray[ 0 ] = j;
00683                     pLspMap[ iCheckLspIndex ].DependentCount++;
00684 
00685                     bDependent = TRUE;
00686                 }
00687             }
00688 
00689             //
00690             // If a dependency already exists, don't bother checking the layered protocol
00691             // chains for one
00692             //
00693             if ( TRUE == bDependent )
00694                 continue;
00695 
00696             //
00697             // Now check whether each layered protocol entry ID is present in any
00698             // of the layered protocol entry chains of the LSP we're currently
00699             // looking at.
00700             //
00701             for(l=0; l < pLspMap[ iCheckLspIndex ].Count ;l++)
00702             {
00703                 bDependent = FALSE;
00704 
00705                 // Check against each layered entry
00706                 for(k=0; k < pLspMap[ j ].Count ;k++ )
00707                 {
00708                     if ( IsIdInChain(
00709                            &pLspMap[ j ].LayeredEntries[ k ],
00710                             pLspMap[ iCheckLspIndex ].LayeredEntries[ l ].dwCatalogEntryId )
00711                        )
00712                     {
00713                         {
00714                             tmpArray = (int *) LspAlloc(
00715                                     sizeof( int ) * ( pLspMap[ iCheckLspIndex ].DependentCount + 1),
00716                                     &ErrorCode
00717                                     );
00718                             if ( NULL == tmpArray )
00719                             {
00720                                 fprintf( stderr, "CheckLspDependency: LspAlloc failed: %d\n", ErrorCode );
00721                                 goto cleanup;
00722                             }
00723 
00724                             if ( NULL != pLspMap[ iCheckLspIndex ].DependentLspIndexArray )
00725                             {
00726                                 memcpy( 
00727                                         tmpArray + 1,
00728                                         pLspMap[ iCheckLspIndex ].DependentLspIndexArray,
00729                                         sizeof( int ) * pLspMap[ iCheckLspIndex ].DependentCount
00730                                       );
00731 
00732                                 LspFree( pLspMap[ iCheckLspIndex ].DependentLspIndexArray );
00733                             }
00734 
00735                             pLspMap[ iCheckLspIndex ].DependentLspIndexArray = tmpArray;
00736                             pLspMap[ iCheckLspIndex ].DependentLspIndexArray[ 0 ] = j;
00737                             pLspMap[ iCheckLspIndex ].DependentCount++;
00738 
00739                             bDependent = TRUE;
00740                             break;
00741                         }
00742                     }
00743                 }
00744 
00745                 if ( TRUE == bDependent )  
00746                     break;
00747             }
00748         }
00749     }
00750     
00751     ret = NO_ERROR;
00752 
00753 cleanup:
00754 
00755     return ret;
00756 }

void MapNewEntriesToOld ( LSP_ENTRY pEntry,
WSAPROTOCOL_INFOW *  pProvider,
int  iProviderCount 
)

Definition at line 817 of file lspmap.cpp.

00822 {
00823     int     i, j;
00824 
00825     for(i=0; i < pEntry->Count ;i++)
00826     {
00827         for(j=0; j < iProviderCount ;j++)
00828         {
00829             if ( IsEqualProtocolEntries( &pEntry->LayeredEntries[ i ], &pProvider[ j ] ) )
00830             {
00831                 pEntry->LayeredEntries[ i ].dwProviderReserved = 
00832                         pProvider[ j ].dwCatalogEntryId;
00833 
00834                 dbgprint( "Mapped old %d to new %d\n",
00835                         pEntry->LayeredEntries[ i ].dwCatalogEntryId,
00836                         pProvider[ j ].dwCatalogEntryId
00837                         );
00838 
00839                 break;
00840             }
00841         }
00842     }
00843 }

int MaxLayeredChainCount ( LSP_ENTRY pLspMap,
int  LspCount 
)

Definition at line 971 of file lspmap.cpp.

00975 {
00976     int MaxSize = 0,
00977         i;
00978 
00979     for(i=0; i < LspCount ;i++)
00980     {
00981         MaxSize = MAX( MaxSize, pLspMap[ i ].Count );
00982     }
00983 
00984     return MaxSize;
00985 }

void PrintLspMap ( LSP_ENTRY pLspMap,
int  iLspCount 
)

Definition at line 498 of file lspmap.cpp.

00502 {
00503     WCHAR   szGuidString[ MAX_PATH ];
00504     int     i, j, k;
00505 
00506     if ( NULL == pLspMap )
00507     {
00508         printf( "\tNo LSPs currently installed\n\n" );
00509         goto cleanup;
00510     }
00511   
00512     for(i=0; i < iLspCount ;i++)
00513     {
00514         if ( pLspMap[ i ].OrphanedEntries != TRUE )
00515         {
00516             // Display the LSP name and its DLL (and path)
00517             printf( "%3d LSP: %ws   DLL '%ws' ID: %d\n", 
00518                     i, 
00519                     pLspMap[ i ].DummyEntry.szProtocol,
00520                     pLspMap[ i ].wszLspDll,
00521                     pLspMap[ i ].DummyEntry.dwCatalogEntryId
00522                     );
00523 
00524             // Display the GUIDs under which the layered entries of this LSP are installed
00525             printf( "\t LSP Installed under %d GUIDs\n", pLspMap[ i ].LayeredGuidCount );
00526             for(k=0; k < pLspMap[ i ].LayeredGuidCount ;k++)
00527             {
00528                 StringFromGUID2( pLspMap[ i ].LayeredGuids[ k ], szGuidString, MAX_PATH-1 );
00529                 printf( "\t\t%ws\n", szGuidString );
00530             }
00531         }
00532         else
00533         {
00534             printf("Orphaned layered chain entries:\n");
00535         }
00536 
00537         // Display the layered entries and the protocol chains
00538         for(j=0; j < pLspMap[ i ].Count ;j++)
00539         {
00540             printf( "\t Layer %-5d \"%ws\" \n\t       Chain %d [ ", 
00541                     pLspMap[ i ].LayeredEntries[ j ].dwCatalogEntryId,
00542                     pLspMap[ i ].LayeredEntries[ j ].szProtocol,
00543                     pLspMap[ i ].LayeredEntries[ j ].ProtocolChain.ChainLen
00544                     );
00545 
00546             for(k=0; k < pLspMap[ i ].LayeredEntries[ j ].ProtocolChain.ChainLen ;k++)
00547             {
00548                 printf( "%d ", pLspMap[ i ].LayeredEntries[ j ].ProtocolChain.ChainEntries[ k ] );
00549             }
00550             printf( "]\n" );
00551         }
00552 
00553         // Display any LSPs which depend on this one (i.e. other LSPs layered over this one)
00554         printf( "\t Dependent LSPs:\n" );
00555         if ( pLspMap[ i ].DependentCount == 0 )
00556             printf( "\t\tNone\n");
00557         else
00558         {
00559             for(j=0; j < pLspMap[ i ].DependentCount ;j++)
00560             {
00561                 printf("\t\t%d %ws\n",
00562                         pLspMap[ pLspMap[ i ].DependentLspIndexArray[ j ] ].DummyEntry.dwCatalogEntryId,
00563                         pLspMap[ pLspMap[ i ].DependentLspIndexArray[ j ] ].DummyEntry.szProtocol
00564                         );
00565             }
00566         }
00567 
00568         printf( "\n" );
00569     }
00570 
00571 cleanup:
00572 
00573     return;
00574 }

void PrintProviders ( WINSOCK_CATALOG  Catalog,
BOOL  bLayeredOnly,
BOOL  bVerbose 
)

Definition at line 35 of file lspmap.cpp.

00040 {
00041     WSAPROTOCOL_INFOW  *pProtocolInfo = NULL;
00042     INT                 iProtocolCount = 0,
00043                         i;
00044 
00045     // Enumerate catalog and print it
00046     pProtocolInfo = EnumerateProviders( Catalog, &iProtocolCount );
00047     if ( NULL == pProtocolInfo )
00048     {
00049         fprintf( stderr, "PrintProviders: Unable to enumerate catalog!\n" );
00050         goto cleanup;
00051     }
00052 
00053     for(i=0; i < iProtocolCount ;i++)
00054     {
00055         if ( FALSE == bLayeredOnly )
00056         {
00057             // Print all providers
00058             if ( TRUE == bVerbose )
00059                 PrintProtocolInfo( &pProtocolInfo[ i ] );
00060             else
00061                 printf("%04d - %S\n", 
00062                         pProtocolInfo[ i ].dwCatalogEntryId,
00063                         pProtocolInfo[ i ].szProtocol
00064                         );
00065         }
00066         else if ( LAYERED_PROTOCOL == pProtocolInfo[ i ].ProtocolChain.ChainLen )
00067         {
00068             // Print only layered providers
00069             if ( TRUE == bVerbose )
00070                 PrintProtocolInfo( &pProtocolInfo[ i ] );
00071             else
00072                 printf("%04d - %S\n", 
00073                         pProtocolInfo[ i ].dwCatalogEntryId,
00074                         pProtocolInfo[ i ].szProtocol
00075                         );
00076         }
00077     }
00078     
00079 cleanup:
00080 
00081     if ( NULL != pProtocolInfo )
00082         FreeProviders( pProtocolInfo );
00083 
00084     return;
00085 }

int RemoveAllLayeredEntries ( WINSOCK_CATALOG  Catalog  ) 

Definition at line 25 of file lspdel.cpp.

00028 {
00029     WSAPROTOCOL_INFOW   *pProviders = NULL,
00030                         *pAssociated = NULL;
00031     WCHAR                szGuidString[ MAX_PATH ];
00032     LSP_ENTRY           *pLspMap = NULL;
00033     INT                  iProviderCount,
00034                          iAssociatedCount,
00035                          iMaxCount,
00036                          iLspCount = 0,
00037                          Status,
00038                          rc,
00039                          i, j, k;
00040 
00041     Status = SOCKET_ERROR;
00042 
00043     // First enumerate the catalog
00044     pProviders = EnumerateProviders( Catalog, &iProviderCount );
00045     if ( NULL == pProviders )
00046     {
00047         fprintf(stderr, "RemoveAllLayeredEntries: Unable to enumerate catalog!\n");
00048         goto cleanup;
00049     }
00050 
00051     // Build a mapping of the LSPs installed on the system
00052     pLspMap = BuildLspMap( pProviders, iProviderCount, &iLspCount );
00053     if ( NULL == pLspMap )
00054     {
00055         printf("\nNo LSPs to remove!\n");
00056         goto cleanup;
00057     }
00058 
00059     iMaxCount = MaxLayeredChainCount( pLspMap, iLspCount );
00060 
00061     pAssociated = (WSAPROTOCOL_INFOW *) LspAlloc(
00062             sizeof( WSAPROTOCOL_INFOW ) * iMaxCount,
00063            &rc
00064             );
00065     if ( NULL == pAssociated )
00066     {
00067         fprintf( stderr, "RemoveAllLayeredEntries: LspAlloc failed: %d\n", rc );
00068         goto cleanup;
00069     }
00070 
00071     printf( "\n%d LSPs installed:\n", iLspCount );
00072     for(i=0; i < iLspCount ;i++)
00073     {
00074         if ( pLspMap[ i ].OrphanedEntries != TRUE )
00075         {
00076             printf("   %d: %ws with %d layered entries\n",
00077                     pLspMap[ i ].DummyEntry.dwCatalogEntryId, 
00078                     pLspMap[ i ].DummyEntry.szProtocol,
00079                     pLspMap[ i ].Count
00080                     );
00081         }
00082         else
00083         {
00084             printf("   Orphaned LSP chain entries:\n");
00085             for(j=0; j < pLspMap[ i ].Count ;j++)
00086             {
00087                 printf("\t   %d %ws\n",
00088                     pLspMap[ i ].LayeredEntries[ j ].dwCatalogEntryId,
00089                     pLspMap[ i ].LayeredEntries[ j ].szProtocol
00090                     );
00091             }
00092         }
00093     }
00094 
00095     printf("\nRemoving LSPs...\n\n");
00096 
00097     for(i=0; i < iLspCount ;i++)
00098     {
00099         if ( pLspMap[ i ].OrphanedEntries != TRUE )
00100         {
00101             // First remove the dummy entry
00102             printf( "Removing dummy entry for: %ws\n", pLspMap[ i ].DummyEntry.szProtocol );
00103 
00104             rc = DeinstallProvider( Catalog, &pLspMap[ i ].DummyEntry.ProviderId );
00105 
00106             if ( pLspMap[ i ].LayeredGuidCount > 0 )
00107                 printf("Removing the associated layered entries with GUIDs:\n");
00108 
00109             for(j=0; j < pLspMap[ i ].LayeredGuidCount ;j++)
00110             {
00111                 StringFromGUID2( pLspMap[ i ].LayeredGuids[ j ], szGuidString, MAX_PATH-1 );
00112                 printf( "\tGUID: %ws\n", szGuidString );
00113 
00114                 iAssociatedCount = iMaxCount;
00115 
00116                 // Get a list of all providers under this GUID so we can print it out
00117                 rc = GetLayeredEntriesByGuid(
00118                         pAssociated,
00119                         &iAssociatedCount,
00120                         pLspMap[ i ].LayeredEntries, 
00121                         pLspMap[ i ].Count,
00122                         &pLspMap[ i ].LayeredGuids[ j ]
00123                         );
00124                 if ( SOCKET_ERROR == rc )
00125                 {
00126                     fprintf( stderr, "RemoveAllLayeredProviders: GetLayeredEntriesByGuid failed!\n" );
00127                     goto cleanup;
00128                 }
00129 
00130                 for(k=0; k < iAssociatedCount ;k++)
00131                 {
00132                     printf("\t  %d: %ws\n", 
00133                             pAssociated[ k ].dwCatalogEntryId,
00134                             pAssociated[ k ].szProtocol
00135                           );
00136                 }
00137 
00138                 rc = DeinstallProvider( Catalog, &pLspMap[ i ].LayeredGuids[ j ] );
00139                 if ( SOCKET_ERROR == rc )
00140                 {
00141                     fprintf( stderr, "RemoveAllLayeredProviders: DeinstallProvider failed!\n" );
00142                 }
00143                 else
00144                 {
00145                     printf( "   Uninstalled providers for %ws\n", szGuidString );
00146                 }
00147             }
00148         }
00149         else
00150         {
00151             printf("Removing the following orphaned entries:\n");
00152             for(j=0; j < pLspMap[ i ].Count ;j++)
00153             {
00154                 printf("\t  %d: %ws\n",
00155                         pLspMap[ i ].LayeredEntries[ j ].dwCatalogEntryId,
00156                         pLspMap[ i ].LayeredEntries[ j ].szProtocol
00157                         );
00158             }
00159 
00160             for(j=0; j < pLspMap[ i ].LayeredGuidCount ;j++)
00161             {
00162                 StringFromGUID2( pLspMap[ i ].LayeredGuids[ j ], szGuidString, MAX_PATH-1 );
00163 
00164                 rc = DeinstallProvider( Catalog, &pLspMap[ i ].LayeredGuids[ j ] );
00165                 if ( SOCKET_ERROR == rc )
00166                 {
00167                     fprintf( stderr, "RemoveAllLayeredProviders: DeinstallProvider failed!\n");
00168                 }
00169                 else
00170                 {
00171                     printf("\tUninstalled providers for %ws\n", szGuidString );
00172                 }
00173             }
00174         }
00175     }
00176 
00177     Status = NO_ERROR;
00178 
00179 cleanup:
00180 
00181     if ( NULL != pProviders )
00182         FreeProviders( pProviders );
00183 
00184     if ( NULL != pLspMap )
00185         FreeLspMap( pLspMap, iLspCount );
00186 
00187     if ( NULL != pAssociated )
00188         LspFree( pAssociated );
00189 
00190     return Status;
00191 }

BOOL RemoveIdFromChain ( WSAPROTOCOL_INFOW *  pInfo,
DWORD  dwCatalogId 
)

Definition at line 27 of file lsputil.cpp.

00031 {
00032     int     i, 
00033             j;
00034 
00035     for(i=0; i < pInfo->ProtocolChain.ChainLen ;i++)
00036     {
00037         if ( pInfo->ProtocolChain.ChainEntries[ i ] == dwCatalogId )
00038         {
00039             for(j=i; j < pInfo->ProtocolChain.ChainLen-1 ; j++)
00040             {
00041                 pInfo->ProtocolChain.ChainEntries[ j ] = 
00042                         pInfo->ProtocolChain.ChainEntries[ j+1 ];
00043             }
00044             pInfo->ProtocolChain.ChainLen--;
00045             return TRUE;
00046         }
00047     }
00048     return FALSE;
00049 }

int RemoveProvider ( WINSOCK_CATALOG  Catalog,
DWORD  dwProviderId 
)

Definition at line 370 of file lspdel.cpp.

00374 {
00375     WSAPROTOCOL_INFOW   *pProvider = NULL,
00376                         *pLayeredEntries = NULL;
00377     LSP_ENTRY           *pLspMap = NULL,
00378                         *pLspMapEntryDel = NULL;
00379     DWORD               *pdwCatalogOrder = NULL;
00380     INT                  iProviderCount = 0,
00381                          iLayerCount = 0,
00382                          iLspCount = 0,
00383                          ErrorCode,
00384                          Status,
00385                          rc, 
00386                          i, j, k, l;
00387 
00388     Status = SOCKET_ERROR;
00389 
00390     // Enumerate the catalog
00391     pProvider = EnumerateProviders( Catalog, &iProviderCount );
00392     if ( pProvider == NULL )
00393     {
00394         fprintf( stderr, "RemoveProvider: Unable to enumerate catalog!\n" );
00395         goto cleanup;
00396     }
00397 
00398     // Allocate an array to save of the provider order in case we have to
00399     //    do uninstall and reinstall providers
00400     pdwCatalogOrder = (DWORD *) LspAlloc(
00401             sizeof( DWORD ) * iProviderCount,
00402            &ErrorCode
00403             );
00404     if ( NULL == pdwCatalogOrder )
00405     {
00406         fprintf( stderr, "RemoveProvider: LspAlloc failed: %d\n", ErrorCode );
00407         goto cleanup;
00408     }
00409 
00410     for(i=0; i < iProviderCount ;i++)
00411     {
00412         pdwCatalogOrder[ i ] = pProvider[ i ].dwCatalogEntryId;
00413     }
00414 
00415     // Build a map of the LSPs installed on the system
00416     pLspMap = BuildLspMap( pProvider, iProviderCount, &iLspCount );
00417     if ( NULL == pLspMap )
00418     {
00419         fprintf( stderr, "RemoveProvider: Unable to build LSP map!\n" );
00420         goto cleanup;
00421     }
00422 
00423     // Validate the catalog entry ID to remove
00424     pLspMapEntryDel = NULL;
00425 
00426     for(i=0; ( i < iLspCount ) && ( NULL == pLspMapEntryDel ) ;i++)
00427     {
00428         if ( dwProviderId == pLspMap[ i ].DummyEntry.dwCatalogEntryId )
00429         {
00430             pLspMapEntryDel = &pLspMap[ i ];
00431         }
00432         else
00433         {
00434             for(j=0; j < pLspMap[ i ].Count ;j++)
00435             {
00436                 if ( dwProviderId == pLspMap[ i ].LayeredEntries[ j ].dwCatalogEntryId )
00437                 {
00438                     // In this case the user supplied the catalog ID of an LSP protocol
00439                     // chain entry -- not the hidden layered entry (dummy). Here we'll
00440                     // reset the dwProviderId to that of the dummy hidden entry.
00441                     //
00442                     if ( pLspMap[ i ].OrphanedEntries != TRUE )
00443                     {
00444                         printf( "Catalog ID %d is a layered protocol entry and not the hidden\n"
00445                                 "provider representing the entire LSP. The LSP which owns this\n"
00446                                 "provider is ID %d (%ws). This entire LSP will be removed!\n",
00447                                 dwProviderId,
00448                                 pLspMap[ i ].DummyEntry.dwCatalogEntryId,
00449                                 pLspMap[ i ].DummyEntry.szProtocol
00450                               );
00451                         dwProviderId = pLspMap[ i ].DummyEntry.dwCatalogEntryId;
00452                         pLspMapEntryDel = &pLspMap[ i ];
00453                     }
00454                     else
00455                     {
00456                         printf( "Catalog ID %d is one of %d orphaned protocol entries.\n"
00457                                 "These entries could be causing serious problems and\n"
00458                                 "will be removed. The following providers are to be\n"
00459                                 "deleted:\n",
00460                                 pLspMap[ i ].LayeredEntries[ j ].dwCatalogEntryId,
00461                                 pLspMap[ i ].Count
00462                                 );
00463                         for(k=0; k < pLspMap[ i ].Count ;k++)
00464                         {
00465                             printf("   %d: %ws\n",
00466                                     pLspMap[ i ].LayeredEntries[ k ].dwCatalogEntryId,
00467                                     pLspMap[ i ].LayeredEntries[ k ].szProtocol
00468                                     );
00469                         }
00470                         pLspMapEntryDel = &pLspMap[ i ];
00471                     }
00472                     break;
00473                 }
00474             }
00475         }
00476     }
00477 
00478     // Make sure we found a provider to remove
00479     if ( NULL == pLspMapEntryDel )
00480     {
00481         fprintf( stderr, "\n\nError! Invalid Winsock catalog ID supplied: %d\n",
00482                 dwProviderId
00483                 );
00484         goto cleanup;
00485     }
00486 
00487     //
00488     // Print which entries are being removed
00489     //
00490 
00491     printf( "\nThe following LSP entries will be removed:\n" );
00492     if ( pLspMapEntryDel->OrphanedEntries != TRUE )
00493     {
00494         printf( "LSP Hidden ID: %6d Name %ws\n",
00495                 pLspMapEntryDel->DummyEntry.dwCatalogEntryId,
00496                 pLspMapEntryDel->DummyEntry.szProtocol
00497                 );
00498     }
00499     else
00500     {
00501         printf( "Orphaned LSP protocol chain entries:\n");
00502     }
00503     for(i=0; i < pLspMapEntryDel->Count ;i++)
00504     {
00505         printf( "LSP Layer  ID: %6d Name %ws\n",
00506                 pLspMapEntryDel->LayeredEntries[ i ].dwCatalogEntryId,
00507                 pLspMapEntryDel->LayeredEntries[ i ].szProtocol
00508                 );
00509     }
00510 
00511     printf( "\n\nTo remove press a key, otherwise CTRL+C now! ");
00512     getchar();
00513     printf( "\n" );
00514 
00515     ErrorCode = NO_ERROR;
00516 
00517     if ( 0 != pLspMapEntryDel->DependentCount )
00518     {
00519         int iLspIdx;
00520 
00521         printf( "\n\nOther LSPs are dependent on this one! "
00522                 "Additional cleanup is required..\n\n" );
00523 
00524         for(i=0; i < pLspMapEntryDel->DependentCount ;i++)
00525         {
00526             iLspIdx =  pLspMapEntryDel->DependentLspIndexArray[ i ];
00527 
00528             printf( "Fixing LSP index %d: %ws\n", 
00529                     pLspMap[ iLspIdx ].DummyEntry.dwCatalogEntryId,
00530                     pLspMap[ iLspIdx ].DummyEntry.szProtocol
00531                     );
00532 
00533             // Remove any reference to the deleted LSPs dummy catalog ID
00534             for(j=0; j < pLspMap[ iLspIdx ].Count ;j++)
00535             {
00536                 if ( IsIdInChain( &pLspMap[ iLspIdx ].LayeredEntries[ j ],
00537                             pLspMapEntryDel->DummyEntry.dwCatalogEntryId ) 
00538                    )
00539                 {
00540                     printf( "Removing ID %d from layered chain %d: %ws\n",
00541                             pLspMapEntryDel->DummyEntry.dwCatalogEntryId,
00542                             pLspMap[ iLspIdx ].LayeredEntries[ j ].dwCatalogEntryId,
00543                             pLspMap[ iLspIdx ].LayeredEntries[ j ].szProtocol
00544                             );
00545 
00546                     // Remove the deleted LSPs ID from the chain
00547                     rc = RemoveIdFromChain(
00548                            &pLspMap[ iLspIdx ].LayeredEntries[ j ],
00549                             pLspMapEntryDel->DummyEntry.dwCatalogEntryId
00550                             );
00551                     if ( FALSE == rc )
00552                     {
00553                         fprintf( stderr, "RemoveProvider: ID not found in chain!\n" );
00554                         continue;
00555                     }
00556 
00557                     pLspMap[ iLspIdx ].LayerChanged[ j ] = TRUE;
00558                 }
00559             }
00560 
00561             // Remove any reference to the deleted LSPs layered entries catalog
00562             // IDs from the layers of the dependent LSP
00563             for(l=0; l < pLspMapEntryDel->Count ;l++)
00564             {
00565                 for(j=0; j < pLspMap[ iLspIdx ].Count ;j++)
00566                 {
00567                     if ( IsIdInChain( &pLspMap[ iLspIdx ].LayeredEntries[ j ],
00568                             pLspMapEntryDel->LayeredEntries[ l ].dwCatalogEntryId )
00569                        )
00570                     {
00571                         printf( "Removing ID %d from layered chain %d: %ws\n",
00572                                 pLspMapEntryDel->DummyEntry.dwCatalogEntryId,
00573                                 pLspMap[ iLspIdx ].LayeredEntries[ j ].dwCatalogEntryId,
00574                                 pLspMap[ iLspIdx ].LayeredEntries[ j ].szProtocol
00575                                 );
00576 
00577                         // Remove the deleted LSPs ID from the chain
00578                         rc = RemoveIdFromChain(
00579                                &pLspMap[ iLspIdx ].LayeredEntries[ j ],
00580                                 pLspMapEntryDel->LayeredEntries[ l ].dwCatalogEntryId
00581                                 );
00582                         if ( FALSE == rc )
00583                         {
00584                             fprintf( stderr, "RemoveProvider: ID not found in chain!\n" );
00585                             continue;
00586                         }
00587 
00588                         pLspMap[ iLspIdx ].LayerChanged[ j ] = TRUE;
00589                     }
00590                 }
00591             }
00592         }
00593 
00594         //
00595         // All dependent LSPs should no longer reference any of the LSPs IDs which is
00596         //    to be removed. Now we must write our changes back to the catalog. Life
00597         //    is easy if we're on a system that supports WSCUpdateProvider.
00598         //
00599 
00600         if ( NULL != fnWscUpdateProvider )
00601         {
00602             //
00603             // Life is good, simply call UpdateProvider on each entry in the LSP map
00604             //    that was updated.
00605             //
00606             for(i=0; i < pLspMapEntryDel->DependentCount ;i++)
00607             {
00608                 iLspIdx = pLspMapEntryDel->DependentLspIndexArray[ i ];
00609 
00610                 for(j=0; j < pLspMap[ iLspIdx ].Count; j++)
00611                 {
00612                     if ( TRUE == pLspMap[ iLspIdx ].LayerChanged[ j ] )
00613                     {
00614                         rc = UpdateProvider(
00615                                 Catalog,
00616                                &pLspMap[ iLspIdx ].LayeredEntries[ j ].ProviderId,
00617                                 pLspMap[ iLspIdx ].wszLspDll,
00618                                &pLspMap[ iLspIdx ].LayeredEntries[ j ],
00619                                 1,
00620                                &ErrorCode
00621                                 );
00622                     }
00623                 }
00624             }
00625         }
00626         else        // fnWscUpdateProvider == NULL
00627         {
00628             int                 MaxLayers = 0;
00629 
00630             //
00631             // Life isn't so good. We need to remove all dependent LSPs first in the
00632             //    reverse order they were installed so that if something fails, we
00633             //    won't leave the catalog in a bad state. Then we need to reinstall
00634             //    them in the same order they were originally installed and fix any
00635             //    of the remaining dependent LSPs to reference the correct catalog IDs
00636             //    before they are also reinstalled.
00637             //
00638 
00639             // Find the maximum protocol chain length of all the LSPs since we need
00640             //    scratch space. We do the allocation first before making changes to
00641             //    the catalog.
00642             MaxLayers = MaxLayeredChainCount(
00643                     pLspMap,
00644                     iLspCount
00645                     );
00646             
00647             pLayeredEntries = (WSAPROTOCOL_INFOW *) LspAlloc(
00648                     sizeof( WSAPROTOCOL_INFOW ) * MaxLayers,
00649                    &ErrorCode
00650                     );
00651             if ( NULL == pLayeredEntries )
00652             {
00653                 fprintf( stderr, "RemoveProvider: LspAlloc failed: %d\n",
00654                         ErrorCode );
00655                 goto cleanup;
00656             }
00657 
00658             // Remove the dependent LSPs in reverse order. NOTE: We don't have to
00659             //    remove the dummy hidden entries since there is no information
00660             //    in those providers that need updating.
00661             for(i=0; i < pLspMapEntryDel->DependentCount ;i++)
00662             {
00663                 iLspIdx = pLspMapEntryDel->DependentLspIndexArray[ i ];
00664 
00665                 for(j=0; j < pLspMap[ iLspIdx ].LayeredGuidCount ;j++)
00666                 {
00667                     rc = DeinstallProvider(
00668                             Catalog,
00669                            &pLspMap[ iLspIdx ].LayeredGuids[ j ]
00670                             );
00671                     if ( SOCKET_ERROR == rc )
00672                     {
00673                         fprintf( stderr, 
00674                                 "RemoveProvider: An error occured trying to remove an LSP.\n"
00675                                 "\t\tThis may be due to another process changing the Catalog\n"
00676                                 "\t\tAborting...\n"
00677                                 );
00678                         goto cleanup;
00679                     }
00680                 }
00681             }
00682 
00683             // All the dependent LSP layers have been removed, now add them
00684             // back in reverse order
00685             for(i=pLspMapEntryDel->DependentCount-1; i >= 0 ;i--)
00686             {
00687                 iLspIdx = pLspMapEntryDel->DependentLspIndexArray[ i ];
00688 
00689                 // Install the layered entries
00690                 for(j=0; j < pLspMap[ iLspIdx ].LayeredGuidCount ;j++)
00691                 {
00692                     iLayerCount = MaxLayers;
00693 
00694                     rc = GetLayeredEntriesByGuid(
00695                             pLayeredEntries,
00696                            &iLayerCount,
00697                             pLspMap[ iLspIdx ].LayeredEntries, 
00698                             pLspMap[ iLspIdx ].Count,
00699                            &pLspMap[ iLspIdx ].LayeredGuids[ j ]
00700                             );
00701 
00702                     rc = InstallProvider(
00703                             Catalog, 
00704                            &pLspMap[ iLspIdx ].LayeredGuids[ j ],
00705                             pLspMap[ iLspIdx ].wszLspDll,
00706                             pLayeredEntries,
00707                             iLayerCount
00708                             );
00709 
00710                 }
00711 
00712                 // Enumerate catalog to find new IDs
00713 
00714                 DWORD ProviderLen = iProviderCount * sizeof( WSAPROTOCOL_INFOW );
00715 
00716                 int NewProviderCount = EnumerateProvidersExisting( 
00717                         Catalog, 
00718                         pProvider, 
00719                        &ProviderLen
00720                         );
00721                 if ( SOCKET_ERROR == NewProviderCount )
00722                 {
00723                     fprintf( stderr, "RemoveProvider: EnumerateProvidersExisting failed: %d\n",
00724                             GetLastError() );
00725                 }
00726 
00727                 // Update the old references to the new
00728                 MapNewEntriesToOld(
00729                        &pLspMap[ iLspIdx ],
00730                         pProvider,
00731                         NewProviderCount
00732                         );
00733 
00734                 // Update the provider order array with the new provider values
00735                 UpdateProviderOrder(
00736                        &pLspMap[ iLspIdx ],
00737                         pdwCatalogOrder,
00738                         iProviderCount
00739                         );
00740                 
00741                 // For the remaining LSPs which we still need to install, update any
00742                 //    references to the removed LSPs with their new IDs
00743                 for(k=i-1; k >= 0 ;k--)
00744                 {
00745                     int iLspIdx2 = pLspMapEntryDel->DependentLspIndexArray[ k ];
00746 
00747                     printf( "Updating IDs for index %d\n", iLspIdx2 );
00748 
00749                     for(l=0; l < pLspMap[ iLspIdx ].Count ;l++)
00750                     {
00751                         UpdateLspMap(
00752                                &pLspMap[ iLspIdx2 ],
00753                                 pLspMap[ iLspIdx ].LayeredEntries[ l ].dwCatalogEntryId,
00754                                 pLspMap[ iLspIdx ].LayeredEntries[ l ].dwProviderReserved
00755                                 );
00756                     }
00757                 }
00758             }
00759 
00760             // Reorder the catalog back to what it was before. Since we've added
00761             //    back all the LSPs we removed earlier, the catalog should be the
00762             //    same size as when we started.
00763             rc = WriteProviderOrder(
00764                     Catalog,
00765                     pdwCatalogOrder,
00766                     iProviderCount,
00767                    &ErrorCode
00768                     );
00769             if ( SOCKET_ERROR == rc )
00770             {
00771                 fprintf( stderr, "RemoveProvider: WriteProviderOrder failed: %d\n",
00772                         ErrorCode );
00773             }
00774         }
00775     }
00776 
00777     //
00778     // Now all dependencies have been fixed, remove the specified provider
00779     //
00780 
00781     // Remove the layered protocol entries
00782     for(i=0; i < pLspMapEntryDel->LayeredGuidCount ;i++)
00783     {
00784         rc = DeinstallProvider(
00785                 Catalog,
00786                &pLspMapEntryDel->LayeredGuids[ i ]
00787                 );
00788     }
00789 
00790     // Remove the dummy entry
00791     rc = DeinstallProvider(
00792             Catalog,
00793            &pLspMapEntryDel->DummyEntry.ProviderId
00794             );
00795 
00796     Status = NO_ERROR;
00797 
00798 cleanup:
00799 
00800     //
00801     // Cleanup allocations
00802     //
00803 
00804     if ( NULL != pLayeredEntries )
00805         LspFree( pLayeredEntries );
00806 
00807     if ( NULL != pProvider )
00808         FreeProviders(pProvider);
00809 
00810     if ( NULL != pLspMap )
00811         FreeLspMap( pLspMap, iLspCount );
00812 
00813     if ( NULL != pdwCatalogOrder )
00814         LspFree( pdwCatalogOrder );
00815 
00816     return Status;
00817 }

DWORD* ReorderACatalog ( WINSOCK_CATALOG  Catalog,
DWORD  dwLayerId,
INT *  dwEntryCount 
)

Definition at line 1128 of file lspadd.cpp.

01133 {
01134     WSAPROTOCOL_INFOW   *pProvider = NULL;
01135     DWORD               *pdwProtocolOrder = NULL;
01136     INT                  iProviderCount = 0,
01137                          idx,
01138                          err,
01139                          i;
01140 
01141     // Validate parameters
01142     if ( ( NULL == dwEntryCount ) || ( LspCatalogBoth == Catalog ) )
01143         return NULL;
01144 
01145     // Enumerate the catalog
01146     pProvider = EnumerateProviders( Catalog, &iProviderCount );
01147     if ( NULL == pProvider )
01148     {
01149         fprintf( stderr, "ReorderACatalog: Unable to enumerate Winsock catalog!\n" );
01150         goto cleanup;
01151     }
01152 
01153     // Allocate space for the array of catalog IDs (the catalog order)
01154     pdwProtocolOrder = (DWORD *) LspAlloc(
01155             sizeof( DWORD ) * iProviderCount,
01156            &err
01157             );
01158     if ( NULL == pdwProtocolOrder )
01159     {
01160         fprintf(stderr, "ReorderACatalog: LspAlloc failed: %d\n", GetLastError());
01161         goto cleanup;
01162     }
01163 
01164     idx = 0;
01165 
01166     // First put all the layered entries at the head of the catalog
01167     for(i=0; i < iProviderCount ;i++)
01168     {
01169         if ( TRUE == IsIdInChain( &pProvider[ i ], dwLayerId ) )
01170         {
01171             pdwProtocolOrder[ idx++ ] = pProvider[ i ].dwCatalogEntryId;
01172         }
01173     }
01174 
01175     // Put the remaining entries after the layered chain entries
01176     for(i=0; i < iProviderCount ;i++)
01177     {
01178         if ( FALSE == IsIdInChain( &pProvider[ i ], dwLayerId ) )
01179         {
01180             pdwProtocolOrder[ idx++ ] = pProvider[ i ].dwCatalogEntryId;
01181         }
01182     }
01183 
01184 cleanup:
01185 
01186     if (pProvider)
01187         FreeProviders(pProvider);
01188 
01189     // Update the count
01190     *dwEntryCount = iProviderCount;
01191 
01192 
01193     return pdwProtocolOrder;
01194 }

int ReorderCatalog ( WINSOCK_CATALOG  Catalog,
DWORD  dwLayeredId 
)

Definition at line 1036 of file lspadd.cpp.

01040 {
01041     DWORD     *pdwProtocolOrder = NULL;
01042     INT        iProviderCount,
01043                ErrorCode,
01044                rc = SOCKET_ERROR;
01045 
01046 #ifdef _WIN64
01047     if ( ( LspCatalog32Only == Catalog ) || ( LspCatalogBoth == Catalog ) )
01048     {
01049         printf("Reordering 32-bit Winsock catalog...\n");
01050         pdwProtocolOrder = ReorderACatalog(
01051                 LspCatalog32Only, 
01052                 dwLayeredId, 
01053                &iProviderCount
01054                 );
01055         if ( NULL == pdwProtocolOrder )
01056         {
01057             fprintf( stderr, "ReorderCatalog: ReorderACatalog failed!\n" );
01058             goto cleanup;
01059         }
01060         
01061         rc = WriteProviderOrder( LspCatalog32Only, pdwProtocolOrder, iProviderCount, &ErrorCode );
01062         if ( SOCKET_ERROR == rc )
01063         {
01064             fprintf( stderr, "ReorderCatalog: Reorder of 32-bit catalog failed: %d\n", rc );
01065         }
01066     }
01067     if ( ( LspCatalog64Only == Catalog ) || ( LspCatalogBoth == Catalog ) )
01068     {
01069         printf("Reordering 64-bit Winsock catalog...\n");
01070         pdwProtocolOrder = ReorderACatalog(
01071                 LspCatalog64Only, 
01072                 dwLayeredId, 
01073                &iProviderCount
01074                 );
01075         if ( NULL == pdwProtocolOrder )
01076         {
01077             fprintf(stderr, "ReorderCatalog: ReorderACatalog failed!\n");
01078             goto cleanup;
01079         }
01080        
01081         rc = WriteProviderOrder( LspCatalog64Only, pdwProtocolOrder, iProviderCount, &ErrorCode );
01082         if ( SOCKET_ERROR == rc )
01083         {
01084             fprintf(stderr, "ReorderCatalog: Reorder of 64-bit catalog failed: %d\n", rc);
01085         }
01086     }
01087 #else
01088     if ( ( LspCatalog32Only == Catalog ) || ( LspCatalogBoth == Catalog ) )
01089     {
01090         printf("Reordering 32-bit Winsock catalog...\n");
01091         pdwProtocolOrder = ReorderACatalog(
01092                 LspCatalog32Only, 
01093                 dwLayeredId, 
01094                &iProviderCount
01095                 );
01096         if ( NULL == pdwProtocolOrder )
01097         {
01098             fprintf( stderr, "ReorderCatalog: ReorderACatalog failed!\n" );
01099             goto cleanup;
01100         }
01101         
01102         rc = WriteProviderOrder( LspCatalog32Only, pdwProtocolOrder, iProviderCount, &ErrorCode );
01103         if ( SOCKET_ERROR == rc )
01104         {
01105             fprintf(stderr, "ReorderCatalog: Reorder of 32-bit catalog failed: %d\n", rc);
01106         }
01107     }
01108 #endif
01109 
01110 cleanup:
01111 
01112     if ( NULL != pdwProtocolOrder )
01113         LspFree( pdwProtocolOrder );
01114 
01115     return rc;
01116 }

int RetrieveLspGuid ( __in_z char *  LspPath,
GUID *  Guid 
)

Definition at line 218 of file lsputil.cpp.

00222 {
00223     HMODULE         hMod = NULL;
00224     LPFN_GETLSPGUID fnGetLspGuid = NULL;
00225     int             retval = SOCKET_ERROR;
00226 
00227     // Load teh library
00228     hMod = LoadLibraryA( LspPath );
00229     if ( NULL == hMod )
00230     {
00231         fprintf( stderr, "RetrieveLspGuid: LoadLibraryA failed: %d\n", GetLastError() );
00232         goto cleanup;
00233     }
00234 
00235     // Get a pointer to the LSPs GetLspGuid function
00236     fnGetLspGuid = (LPFN_GETLSPGUID) GetProcAddress( hMod, "GetLspGuid" );
00237     if ( NULL == fnGetLspGuid )
00238     {
00239         fprintf( stderr, "RetrieveLspGuid: GetProcAddress failed: %d\n", GetLastError() );
00240         goto cleanup;
00241     }
00242 
00243     // Retrieve the LSPs GUID
00244     fnGetLspGuid( Guid );
00245 
00246     retval = NO_ERROR;
00247 
00248 cleanup:
00249 
00250     if ( NULL != hMod )
00251         FreeLibrary( hMod );
00252 
00253     return retval;
00254 }

void UpdateLspMap ( LSP_ENTRY pLspMap,
DWORD  dwOldValue,
DWORD  dwNewValue 
)

Definition at line 773 of file lspmap.cpp.

00778 {
00779     int i, j;
00780 
00781     // Go through all providers beloging to this LSP
00782     for(i=0; i < pLspMap->Count ;i++)
00783     {
00784         // Go through the protocol chain and update references if they match
00785         for(j=0; j < pLspMap->LayeredEntries[ i ].ProtocolChain.ChainLen ;j++)
00786         {
00787             if ( pLspMap->LayeredEntries[ i ].ProtocolChain.ChainEntries[ j ] == 
00788                     dwOldValue 
00789                )
00790             {
00791                 pLspMap->LayeredEntries[ i ].ProtocolChain.ChainEntries[ j ] = 
00792                         dwNewValue;
00793             }
00794         }
00795     }
00796 
00797     return;
00798 }

int UpdateProvider ( WINSOCK_CATALOG  Catalog,
LPGUID  ProviderId,
WCHAR *  DllPath,
WSAPROTOCOL_INFOW *  ProtocolInfoList,
DWORD  NumberOfEntries,
LPINT  lpErrno 
)

Definition at line 283 of file lspdel.cpp.

00291 {
00292     int     rc = SOCKET_ERROR;
00293 
00294 #ifdef _WIN64
00295     if ( LspCatalog64Only == Catalog )
00296     {
00297         rc = fnWscUpdateProvider(
00298                 ProviderId,
00299                 DllPath,
00300                 ProtocolInfoList,
00301                 NumberOfEntries,
00302                 lpErrno
00303                 );
00304     }
00305     else if ( LspCatalog32Only == Catalog )
00306     {
00307         rc = fnWscUpdateProvider32(
00308                 ProviderId,
00309                 DllPath,
00310                 ProtocolInfoList,
00311                 NumberOfEntries,
00312                 lpErrno
00313                 );
00314     }
00315 #else
00316     if ( LspCatalog32Only == Catalog )
00317     {
00318         rc = fnWscUpdateProvider(
00319                 ProviderId,
00320                 DllPath,
00321                 ProtocolInfoList,
00322                 NumberOfEntries,
00323                 lpErrno
00324                 );
00325     }
00326     else
00327     {
00328         fprintf( stderr, "UpdateProvider: Unable to manipulate 64-bit catalog from a 32"
00329                 "-bit process\n" );
00330     }
00331 #endif
00332 
00333     if ( SOCKET_ERROR == rc )
00334     {
00335         fprintf( stderr, "UpdateProvider: WSCUpdateProvider failed: %d\n",
00336                 *lpErrno );
00337     }
00338 
00339     return rc;
00340 }

void UpdateProviderOrder ( LSP_ENTRY UpdatedEntry,
DWORD *  OrderArray,
int  ArrayCount 
)

Definition at line 939 of file lspmap.cpp.

00944 {
00945     int     i, j;
00946 
00947 
00948     for(i=0; i < UpdatedEntry->Count ;i++)
00949     {
00950         for(j=0; j < ArrayCount ;j++)
00951         {
00952             // Replace an occurence of the old value with the new value
00953             if ( OrderArray[ j ] == UpdatedEntry->LayeredEntries[ i ].dwCatalogEntryId )
00954             {
00955                 OrderArray[ j ] = UpdatedEntry->LayeredEntries[ i ].dwProviderReserved;
00956             }
00957         }
00958     }
00959 }

int WriteProviderOrder ( WINSOCK_CATALOG  Catalog,
DWORD *  pdwCatalogOrder,
DWORD  dwNumberOfEntries,
INT *  lpErrno 
)

Definition at line 1205 of file lspadd.cpp.

01211 {
01212     int     rc = NO_ERROR;
01213 
01214 #ifdef _WIN64
01215     if ( LspCatalog32Only == Catalog )
01216     {
01217         rc = WSCWriteProviderOrder32( pdwCatalogOrder, dwNumberOfEntries );
01218     }
01219     else if ( LspCatalog64Only == Catalog )
01220     {
01221         rc = WSCWriteProviderOrder( pdwCatalogOrder, dwNumberOfEntries );
01222     }
01223 #else
01224     if ( LspCatalog32Only == Catalog )
01225     {
01226         rc = WSCWriteProviderOrder(pdwCatalogOrder, dwNumberOfEntries );
01227     }
01228     else
01229     {
01230         fprintf( stderr, "WriteProviderOrder: Unable to manipulate 64-bit catalog from "
01231                 "a 32-bit process\n" );
01232     }
01233 #endif
01234     if ( 0 != rc )
01235     {
01236         *lpErrno = rc;
01237         fprintf( stderr, "WriteProviderOrder: WSCWriteProviderOrder failed: %d\n", *lpErrno );
01238         rc = SOCKET_ERROR;
01239     }
01240 
01241     return rc;
01242 }


Variable Documentation

LPWSCUPDATEPROVIDER fnWscUpdateProvider

Definition at line 96 of file instlsp.cpp.

LPWSCUPDATEPROVIDER fnWscUpdateProvider32

Definition at line 97 of file instlsp.cpp.

HMODULE gModule

Definition at line 98 of file instlsp.cpp.

Definition at line 99 of file instlsp.cpp.