diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/sam | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/sam')
-rw-r--r-- | private/sam/dirs | 23 | ||||
-rw-r--r-- | private/sam/icfg32/cfgapi.h | 206 | ||||
-rw-r--r-- | private/sam/icfg32/icfg32.cpp | 269 | ||||
-rw-r--r-- | private/sam/icfg32/icfg32.def | 13 | ||||
-rw-r--r-- | private/sam/icfg32/makefile | 2 | ||||
-rw-r--r-- | private/sam/icfg32/sources | 35 | ||||
-rw-r--r-- | private/sam/icfg32/version.rc | 10 |
7 files changed, 558 insertions, 0 deletions
diff --git a/private/sam/dirs b/private/sam/dirs new file mode 100644 index 000000000..741082439 --- /dev/null +++ b/private/sam/dirs @@ -0,0 +1,23 @@ +!IF 0 + +Copyright (c) 1989 Microsoft Corporation + +Module Name: + + dirs. + +Abstract: + + This file specifies the subdirectories of the current directory that + contain component makefiles. + + +Author: + + Steve Wood (stevewo) 17-Apr-1990 + +NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl + +!ENDIF + +DIRS= icfg32 diff --git a/private/sam/icfg32/cfgapi.h b/private/sam/icfg32/cfgapi.h new file mode 100644 index 000000000..cab2e4f34 --- /dev/null +++ b/private/sam/icfg32/cfgapi.h @@ -0,0 +1,206 @@ +//******************************************************************* +// +// Copyright(c) Microsoft Corporation, 1996 +// +// FILE: CFGAPI.H +// +// PURPOSE: Contains API's exported from icfg32.dll and structures +// required by those functions. +// +//******************************************************************* + +#ifndef _CFGAPI_H_ +#define _CFGAPI_H_ + +// Maximum buffer size for error messages. +#define MAX_ERROR_TEXT 512 + +// Flags for dwfOptions + +// install TCP (if needed) +#define ICFG_INSTALLTCP 0x00000001 + +// install RAS (if needed) +#define ICFG_INSTALLRAS 0x00000002 + +// install exchange and internet mail +#define ICFG_INSTALLMAIL 0x00000004 + + +// DRIVERTYPE_ defines for TCP/IP configuration apis +#define DRIVERTYPE_NET 0x0001 +#define DRIVERTYPE_PPP 0x0002 + + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + + +//******************************************************************* +// +// FUNCTION: IcfgNeedInetComponents +// +// PURPOSE: Detects whether the specified system components are +// installed or not. +// +// PARAMETERS: dwfOptions - a combination of ICFG_ flags that specify +// which components to detect as follows: +// +// ICFG_INSTALLTCP - is TCP/IP needed? +// ICFG_INSTALLRAS - is RAS needed? +// ICFG_INSTALLMAIL - is exchange or internet mail needed? +// +// lpfNeedComponents - TRUE if any specified component needs +// to be installed. +// +// RETURNS: HRESULT code, ERROR_SUCCESS if no errors occurred +// +//******************************************************************* + +HRESULT IcfgNeedInetComponents(DWORD dwfOptions, LPBOOL lpfNeedComponents); + + +//******************************************************************* +// +// FUNCTION: IcfgInstallInetComponents +// +// PURPOSE: Install the specified system components. +// +// PARAMETERS: hwndParent - Parent window handle. +// dwfOptions - a combination of ICFG_ flags that controls +// the installation and configuration as follows: +// +// ICFG_INSTALLTCP - install TCP/IP (if needed) +// ICFG_INSTALLRAS - install RAS (if needed) +// ICFG_INSTALLMAIL - install exchange and internet mail +// +// lpfNeedsRestart - if non-NULL, then on return, this will be +// TRUE if windows must be restarted to complete the installation. +// +// RETURNS: HRESULT code, ERROR_SUCCESS if no errors occurred +// +//******************************************************************* + +HRESULT IcfgInstallInetComponents(HWND hwndParent, DWORD dwfOptions, + LPBOOL lpfNeedsRestart); + + +//******************************************************************* +// +// FUNCTION: IcfgGetLastInstallErrorText +// +// PURPOSE: Get a text string that describes the last installation +// error that occurred. The string should be suitable +// for display in a message box with no further formatting. +// +// PARAMETERS: lpszErrorDesc - points to buffer to receive the string. +// cbErrorDesc - size of buffer. +// +// RETURNS: The length of the string returned. +// +//******************************************************************* + +DWORD IcfgGetLastInstallErrorText(LPSTR lpszErrorDesc, DWORD cbErrorDesc); + + +//******************************************************************* +// +// FUNCTION: IcfgSetInstallSourcePath +// +// PURPOSE: Sets the path where windows looks when installing files. +// +// PARAMETERS: lpszSourcePath - full path of location of files to install. +// If this is NULL, default path is used. +// +// RETURNS: HRESULT code, ERROR_SUCCESS if no errors occurred +// +//******************************************************************* + +HRESULT IcfgSetInstallSourcePath(LPCSTR lpszSourcePath); + + +//******************************************************************* +// +// FUNCTION: IcfgIsGlobalDNS +// +// PURPOSE: Determines whether there is Global DNS set. +// +// PARAMETERS: lpfGlobalDNS - TRUE if global DNS is set, FALSE otherwise. +// +// RETURNS: HRESULT code, ERROR_SUCCESS if no errors occurred +// NOTE: This function is for Windows 95 only, and +// should always return ERROR_SUCCESS and set lpfGlobalDNS +// to FALSE in Windows NT. +// +//******************************************************************* + +HRESULT IcfgIsGlobalDNS(LPBOOL lpfGlobalDNS); + + +//******************************************************************* +// +// FUNCTION: IcfgRemoveGlobalDNS +// +// PURPOSE: Removes global DNS info from registry. +// +// PARAMETERS: None. +// +// RETURNS: HRESULT code, ERROR_SUCCESS if no errors occurred +// NOTE: This function is for Windows 95 only, and +// should always return ERROR_SUCCESS in Windows NT. +// +//******************************************************************* + +HRESULT IcfgRemoveGlobalDNS(void); + + +//******************************************************************* +// +// FUNCTION: IcfgIsFileSharingTurnedOn +// +// PURPOSE: Determines if file server (VSERVER) is bound to TCP/IP +// for specified driver type (net card or PPP). +// +// PARAMETERS: dwfDriverType - a combination of DRIVERTYPE_ flags +// that specify what driver type to check server-TCP/IP +// bindings for as follows: +// +// DRIVERTYPE_NET - net card +// DRIVERTYPE_PPP - PPPMAC +// +// lpfSharingOn - TRUE if bound once or more, FALSE if not bound +// +// RETURNS: HRESULT code, ERROR_SUCCESS if no errors occurred +// +//******************************************************************* + +HRESULT IcfgIsFileSharingTurnedOn(DWORD dwfDriverType, LPBOOL lpfSharingOn); + + +//******************************************************************* +// +// FUNCTION: IcfgTurnOffFileSharing +// +// PURPOSE: Unbinds file server (VSERVER) from TCP/IP for +// specified driver type (net card or PPP). +// +// PARAMETERS: dwfDriverType - a combination of DRIVERTYPE_ flags +// that specify what driver type to remove server-TCP/IP +// bindings for as follows: +// +// DRIVERTYPE_NET - net card +// DRIVERTYPE_PPP - PPPMAC +// +// RETURNS: HRESULT code, ERROR_SUCCESS if no errors occurred +// +//******************************************************************* + +HRESULT IcfgTurnOffFileSharing(DWORD dwfDriverType); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif //_CFGAPI_H_ diff --git a/private/sam/icfg32/icfg32.cpp b/private/sam/icfg32/icfg32.cpp new file mode 100644 index 000000000..7b7fec978 --- /dev/null +++ b/private/sam/icfg32/icfg32.cpp @@ -0,0 +1,269 @@ +#include <windows.h> +#include <wtypes.h> +#include <cfgapi.h> +#include <stdio.h> +#include <stdlib.h> + +const DWORD INFINSTALL_PRIMARYINSTALL = 0x00000001; +const DWORD INFINSTALL_INPROCINTERP = 0x00000002; + + +DWORD (WINAPI *pfnNetSetupReviewBindings)(HWND hwndParent, + DWORD dwBindFlags); +DWORD (WINAPI *pfnNetSetupComponentInstall)(HWND hwndParent, + PCWSTR pszInfOption, + PCWSTR pszInfName, + PCWSTR pszInstallPath, + PCWSTR plszInfSymbols, + DWORD dwInstallFlags, + PDWORD dwReturn); +DWORD (WINAPI *pfnNetSetupComponentRemove)(HWND hwndParent, + PCWSTR pszInfOption, + DWORD dwInstallFlags, + PDWORD pdwReturn); +DWORD (WINAPI *pfnNetSetupComponentProperties)(HWND hwndParent, + PCWSTR pszInfOption, + DWORD dwInstallFlags, + PDWORD pdwReturn); +DWORD (WINAPI *pfnNetSetupFindHardwareComponent)(PCWSTR pszInfOption, + PWSTR pszInfName, + PDWORD pcchInfName, + PWSTR pszRegBase, // optional, may be NULL + PDWORD pcchRegBase ); // optional, NULL if pszRegBase is NULL +DWORD (WINAPI *pfnNetSetupFindSoftwareComponent)(PCWSTR pszInfOption, + PWSTR pszInfName, + PDWORD pcchInfName, + PWSTR pszRegBase = NULL, + PDWORD pcchRegBase = NULL); +DWORD (WINAPI *pfnRegCopyTree)(); + +HINSTANCE hNetcfgInst = NULL; +LPWSTR wszInstallPath = 0; +DWORD dwLastError = ERROR_SUCCESS; + +typedef struct tagFunctionTableEntry { + LPVOID *pfn; + LPSTR szEntryPoint; +} FunctionTableEntry; + +FunctionTableEntry NetcfgTable[] = { + { (LPVOID *) &pfnNetSetupComponentInstall, "NetSetupComponentInstall" }, + { (LPVOID *) &pfnNetSetupFindSoftwareComponent, "NetSetupFindSoftwareComponent" }, + { (LPVOID *) &pfnNetSetupReviewBindings, "NetSetupReviewBindings" }, + { (LPVOID *) &pfnNetSetupComponentRemove, "NetSetupComponentRemove" }, + { (LPVOID *) &pfnNetSetupComponentProperties, "NetSetupComponentProperties" }, + { (LPVOID *) &pfnNetSetupFindHardwareComponent, "NetSetupFindHardwareComponent" }, + { 0, 0 } +}; + +HINSTANCE +LoadLibraryToFunctionTable(FunctionTableEntry *pTab, LPSTR szDLL) +{ + HINSTANCE hInst; + + hInst = LoadLibrary(szDLL); + if(hInst == 0) + return(hInst); + + while(pTab->pfn) { + *pTab->pfn = (LPVOID) GetProcAddress(hInst, pTab->szEntryPoint); + if(*pTab->pfn == 0) { + FreeLibrary(hInst); + return(0); + } + pTab++; + } + + return(hInst); +} + +DWORD +LoadNetcfg() { + if(hNetcfgInst == NULL) + hNetcfgInst = LoadLibraryToFunctionTable(NetcfgTable, "NETCFG.DLL"); + + if(hNetcfgInst == NULL) + return(!ERROR_SUCCESS); + else + return(ERROR_SUCCESS); +} + +inline void +ParseNetSetupReturn(DWORD dwReturn, BOOL &fReboot, BOOL &fBindReview) +{ + if(dwReturn == 0 || dwReturn == 4) + fBindReview = TRUE; + if(dwReturn == 0 || dwReturn == 5) + fReboot = TRUE; +} + +DWORD +ReviewBindings(HWND hwndParent) +{ + DWORD dwErr; + + dwErr = LoadNetcfg(); + if(dwErr != ERROR_SUCCESS) + return(dwErr); + + return(pfnNetSetupReviewBindings(hwndParent, 0)); +} + +HRESULT WINAPI +IcfgNeedInetComponents(DWORD dwfOptions, LPBOOL lpfNeedComponents) { + DWORD dwErr; + + // + // Assume need nothing + // + *lpfNeedComponents = FALSE; + + dwErr = LoadNetcfg(); + if(dwErr != ERROR_SUCCESS) + return(dwLastError = dwErr); // Shouldn't we map to hResult? + + WCHAR wszInfNameBuf[512]; + DWORD cchInfName = sizeof(wszInfNameBuf) / sizeof(WCHAR); + + if(dwfOptions & ICFG_INSTALLTCP) { + dwErr = pfnNetSetupFindSoftwareComponent(L"TC", + wszInfNameBuf, + &cchInfName, + 0, + 0); + if(dwErr != ERROR_SUCCESS) + *lpfNeedComponents = TRUE; + } + + if(dwfOptions & ICFG_INSTALLRAS) { + dwErr = pfnNetSetupFindSoftwareComponent(L"RAS", + wszInfNameBuf, + &cchInfName, + 0, + 0); + if(dwErr != ERROR_SUCCESS) + *lpfNeedComponents = TRUE; + } + + if(dwfOptions & ICFG_INSTALLMAIL) { + // How do we do this? + } + + return(ERROR_SUCCESS); +} + +HRESULT WINAPI +IcfgInstallINetComponents(HWND hwndParent, DWORD dwfOptions, LPBOOL lpfNeedsRestart) +{ + DWORD dwErr; + DWORD dwReturn; + BOOL fNeedsReview; + BOOL fNeedsRestart; + BOOL fDoReview = FALSE; + + // + // Assume don't need restart + // + *lpfNeedsRestart = FALSE; + + dwErr = LoadNetcfg(); + if(dwErr != ERROR_SUCCESS) + return(dwLastError = dwErr); // Review: Shouldn't we map to hResult? + + if(dwfOptions & ICFG_INSTALLTCP) { + dwErr = pfnNetSetupComponentInstall(hwndParent, + L"TC", + L"OEMNXPTC.INF", + wszInstallPath, + L"\0\0", + INFINSTALL_INPROCINTERP, // Install Flags + &dwReturn); + if(dwErr != ERROR_SUCCESS) + return(dwLastError = dwErr); // Review: Shouldn't we map to hResult? + + ParseNetSetupReturn(dwReturn, fNeedsRestart, fNeedsReview); + if(fNeedsRestart) + *lpfNeedsRestart = TRUE; + if(fNeedsReview) + fDoReview = TRUE; + } + + if(dwfOptions & ICFG_INSTALLRAS) { + dwErr = pfnNetSetupComponentInstall(hwndParent, + L"RAS", + L"OEMNSVRA.INF", + wszInstallPath, + L"\0\0", + INFINSTALL_INPROCINTERP, // Install Flags + &dwReturn); + if(dwErr != ERROR_SUCCESS) + return(dwLastError = dwErr); // Review: Shouldn't we map to hResult? + + ParseNetSetupReturn(dwReturn, fNeedsRestart, fNeedsReview); + if(fNeedsRestart) + *lpfNeedsRestart = TRUE; + if(fNeedsReview) + fDoReview = TRUE; + } + + if(dwfOptions & ICFG_INSTALLMAIL) { + // Review: How do we do this? --> See mail from AlexDun + } + + if(fDoReview) + return(dwLastError = ReviewBindings(hwndParent)); // Review: Shouldn't we map to hresult? + else + return(ERROR_SUCCESS); +} + +DWORD WINAPI +IcfgGetLastInstallErrorText(LPSTR lpszErrorDesc, DWORD cbErrorDesc) +{ + return(FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + dwLastError, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language + lpszErrorDesc, + cbErrorDesc, + NULL)); +} + +HRESULT WINAPI +IcfgSetInstallSourcePath(LPSTR lpszSourcePath) +{ + if(wszInstallPath) + HeapFree(GetProcessHeap(), 0, (LPVOID) wszInstallPath); + + DWORD dwLen = strlen(lpszSourcePath); + wszInstallPath = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, dwLen * 2 + 2); + if(wszInstallPath == 0) + return(dwLastError = ERROR_OUTOFMEMORY); + + mbstowcs(wszInstallPath, lpszSourcePath, dwLen + 1); + return(ERROR_SUCCESS); +} + +HRESULT WINAPI +IcfgIsGlobalDNS(LPBOOL lpfGlobalDNS) { + *lpfGlobalDNS = FALSE; + return(ERROR_SUCCESS); +} + +HRESULT WINAPI +IcfgRemoveGlobalDNS() { + return(ERROR_SUCCESS); +} + +HRESULT WINAPI +IcfgIsFileSharingTurnedOn(DWORD dwfDriverType, LPBOOL lpfSharingOn) { + *lpfSharingOn = FALSE; + // Review: Write this code. + return(ERROR_SUCCESS); +} + +HRESULT WINAPI +IcfgTurnOffFileSharing(DWORD dwfDriverType) { + // Review: Write this code. + return(ERROR_SUCCESS); +} + diff --git a/private/sam/icfg32/icfg32.def b/private/sam/icfg32/icfg32.def new file mode 100644 index 000000000..62e67e36a --- /dev/null +++ b/private/sam/icfg32/icfg32.def @@ -0,0 +1,13 @@ +LIBRARY ICFG32 +DESCRIPTION 'OS Specific calls for signup wizard' +HEAPSIZE 512 + +EXPORTS + IcfgNeedInetComponents + IcfgInstallINetComponents + IcfgGetLastInstallErrorText + IcfgSetInstallSourcePath + IcfgIsGlobalDNS + IcfgRemoveGlobalDNS + IcfgIsFileSharingTurnedOn + IcfgTurnOffFileSharing diff --git a/private/sam/icfg32/makefile b/private/sam/icfg32/makefile new file mode 100644 index 000000000..9d1429be0 --- /dev/null +++ b/private/sam/icfg32/makefile @@ -0,0 +1,2 @@ +!include $(NTMAKEENV)\makefile.def + diff --git a/private/sam/icfg32/sources b/private/sam/icfg32/sources new file mode 100644 index 000000000..110c6bd53 --- /dev/null +++ b/private/sam/icfg32/sources @@ -0,0 +1,35 @@ +MAJORCOMP=inetwiz +MINORCOMP=icfg32 + +TARGETNAME=icfg32 +# Use this to drop target somewhere +TARGETPATH=obj +TARGETTYPE=DYNLINK + +#DLLENTRY=DllEntryPoint +USE_CRTDLL=1 +DLLBASE=0x2000000 + +C_DEFINES= +INCLUDES= + +SOURCES=icfg32.cpp version.rc + +# Use this libraries to link target +TARGETLIBS=\ + $(BASEDIR)\public\sdk\lib\*\kernel32.lib \ + $(BASEDIR)\public\sdk\lib\*\user32.lib \ + $(BASEDIR)\public\sdk\lib\*\gdi32.lib \ + $(BASEDIR)\public\sdk\lib\*\advapi32.lib \ + $(BASEDIR)\public\sdk\lib\*\shell32.lib \ + $(BASEDIR)\public\sdk\lib\*\comdlg32.lib \ + $(BASEDIR)\public\sdk\lib\*\comctl32.lib \ + $(BASEDIR)\public\sdk\lib\*\version.lib + + +#OPTIONAL_UMTEST= +#UMTYPE=windows +#UMLIBS=$(BASEDIR)\public\sdk\lib\*\setupapi.lib + + + diff --git a/private/sam/icfg32/version.rc b/private/sam/icfg32/version.rc new file mode 100644 index 000000000..94e8d3e5b --- /dev/null +++ b/private/sam/icfg32/version.rc @@ -0,0 +1,10 @@ +#include <windows.h> +#include <ntverp.h> + +#define VER_FILETYPE VFT_DLL +#define VER_FILESUBTYPE VFT2_UNKNOWN +#define VER_FILEDESCRIPTION_STR "Windows NT signup wizard support" +#define VER_INTERNALNAME_STR "ICFG32.DLL" + +#include "common.ver" + |