/*******************************************************************/ /* Copyright(c) 1992 Microsoft Corporation */ /*******************************************************************/ //*** // // Filename: registry.c // // Description: This module contains the code for DDM parameters // initialization and loading from the registry. // // Author: Stefan Solomon (stefans) May 18, 1992. // //*** #include "ddm.h" #include #include #include #include #include typedef struct _DDM_REGISTRY_PARAMS { LPWSTR pszValueName; DWORD * pValue; DWORD dwDefValue; DWORD Min; DWORD Max; } DDM_REGISTRY_PARAMS, *PDDM_REGISTRY_PARAMS; // // DDM parameter descriptor table // DDM_REGISTRY_PARAMS DDMRegParams[] = { // authenticateretries DDM_VALNAME_AUTHENTICATERETRIES, &gblDDMConfigInfo.dwAuthenticateRetries, DEF_AUTHENTICATERETRIES, MIN_AUTHENTICATERETRIES, MAX_AUTHENTICATERETRIES, // authenticatetime DDM_VALNAME_AUTHENTICATETIME, &gblDDMConfigInfo.dwAuthenticateTime, DEF_AUTHENTICATETIME, MIN_AUTHENTICATETIME, MAX_AUTHENTICATETIME, // callbacktime DDM_VALNAME_CALLBACKTIME, &gblDDMConfigInfo.dwCallbackTime, DEF_CALLBACKTIME, MIN_CALLBACKTIME, MAX_CALLBACKTIME, // Autodisconnect Time DDM_VALNAME_AUTODISCONNECTTIME, &gblDDMConfigInfo.dwAutoDisconnectTime, DEF_AUTODISCONNECTTIME, MIN_AUTODISCONNECTTIME, MAX_AUTODISCONNECTTIME, // Clients per process DDM_VALNAME_CLIENTSPERPROC, &gblDDMConfigInfo.dwClientsPerProc, DEF_CLIENTSPERPROC, MIN_CLIENTSPERPROC, MAX_CLIENTSPERPROC, // Time for 3rd party security DLL to complete DDM_VALNAME_SECURITYTIME, &gblDDMConfigInfo.dwSecurityTime, DEF_SECURITYTIME, MIN_SECURITYTIME, MAX_SECURITYTIME, // Logging level DDM_VALNAME_LOGGING_LEVEL, &gblDDMConfigInfo.dwLoggingLevel, DEF_LOGGINGLEVEL, MIN_LOGGINGLEVEL, MAX_LOGGINGLEVEL, // Number of callback retries DDM_VALNAME_NUM_CALLBACK_RETRIES, &gblDDMConfigInfo.dwCallbackRetries, DEF_NUMCALLBACKRETRIES, MIN_NUMCALLBACKRETRIES, MAX_NUMCALLBACKRETRIES, DDM_VALNAME_SERVERFLAGS, &gblDDMConfigInfo.dwServerFlags, DEF_SERVERFLAGS, 0, 0xFFFFFFFF, // End NULL, NULL, 0, 0, 0 }; //*** // // Function: GetKeyMax // // Descr: returns the nr of values in this key and the maximum // size of the value data. // //*** DWORD GetKeyMax( IN HKEY hKey, OUT LPDWORD MaxValNameSize_ptr, // longest valuename OUT LPDWORD NumValues_ptr, // nr of values OUT LPDWORD MaxValueDataSize_ptr // max size of data ) { DWORD NumSubKeys; DWORD MaxSubKeySize; DWORD dwRetCode; dwRetCode = RegQueryInfoKey( hKey, NULL, NULL, NULL, &NumSubKeys, &MaxSubKeySize, NULL, NumValues_ptr, MaxValNameSize_ptr, MaxValueDataSize_ptr, NULL, NULL ); (*MaxValNameSize_ptr)++; return( dwRetCode ); } //*** // // Function: LoadDDMParameters // // Descr: Opens the registry, reads and sets specified supervisor // parameters. If fatal error reading parameters writes the // error log. // // Returns: NO_ERROR - success // else - fatal error. // //*** DWORD LoadDDMParameters( IN HKEY hkeyParameters, OUT BOOL* pfIpAllowed ) { DWORD dwIndex; DWORD dwRetCode; DWORD cbValueBuf; DWORD dwType; DWORD fIpxAllowed; // // Initialize Global values // gblDDMConfigInfo.fRemoteListen = TRUE; gblDDMConfigInfo.dwAnnouncePresenceTimer = ANNOUNCE_PRESENCE_TIMEOUT; // // Let us not allow any protocol if DdmFindBoundProtocols fails. // gblDDMConfigInfo.dwServerFlags &= ~( PPPCFG_ProjectNbf | PPPCFG_ProjectIp | PPPCFG_ProjectIpx | PPPCFG_ProjectAt ); dwRetCode = DdmFindBoundProtocols( pfIpAllowed, &fIpxAllowed, &gblDDMConfigInfo.fArapAllowed ); if ( dwRetCode != NO_ERROR ) { return( dwRetCode ); } if ( !*pfIpAllowed && !fIpxAllowed && !gblDDMConfigInfo.fArapAllowed ) { DDMLogError( ROUTERLOG_NO_PROTOCOLS_CONFIGURED, 0, NULL, 0 ); return( dwRetCode ); } // // Run through and get all the DDM values // for ( dwIndex = 0; DDMRegParams[dwIndex].pszValueName != NULL; dwIndex++ ) { cbValueBuf = sizeof( DWORD ); dwRetCode = RegQueryValueEx( hkeyParameters, DDMRegParams[dwIndex].pszValueName, NULL, &dwType, (LPBYTE)(DDMRegParams[dwIndex].pValue), &cbValueBuf ); if ((dwRetCode != NO_ERROR) && (dwRetCode != ERROR_FILE_NOT_FOUND)) { DDMLogError( ROUTERLOG_CANT_GET_REGKEYVALUES, 0, NULL, dwRetCode ); break; } if ( dwRetCode == ERROR_FILE_NOT_FOUND ) { *(DDMRegParams[dwIndex].pValue) = DDMRegParams[dwIndex].dwDefValue; dwRetCode = NO_ERROR; } else { if ( ( dwType != REG_DWORD ) ||(*(DDMRegParams[dwIndex].pValue) > DDMRegParams[dwIndex].Max) ||( *(DDMRegParams[dwIndex].pValue)