UINT __stdcall ScaFiltersRead(IMSAdminBase* piMetabase, SCA_WEB* pswList, SCA_FILTER** ppsfList) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; PMSIHANDLE hView, hRec; PMSIHANDLE hViewWeb, hRecWeb; BOOL fIIsWebFilterTable = FALSE; LPWSTR pwzData = NULL; SCA_FILTER* psf = NULL; DWORD dwLen = 0; // check for required table if (S_OK != WcaTableExists(L"IIsFilter")) { WcaLog(LOGMSG_VERBOSE, "Skipping ScaInstallFilters() - no IIsFilter table"); ExitFunction1(hr = S_FALSE); } // loop through all the filters hr = WcaOpenExecuteView(vcsFilterQuery, &hView); ExitOnFailure(hr, "Failed to open view on IIsFilter table"); while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) { hr = AddFilterToList(ppsfList); ExitOnFailure(hr, "failed to add filter to list"); psf = *ppsfList; // get component install state hr = WcaGetRecordString(hRec, fqComponent, &pwzData); ExitOnFailure(hr, "Failed to get Filter.Component_"); er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzData, &psf->isInstalled, &psf->isAction); hr = HRESULT_FROM_WIN32(er); ExitOnFailure(hr, "Failed to get Component state for filter"); ::ZeroMemory(psf->wzFilterRoot, sizeof(psf->wzFilterRoot)); hr = WcaGetRecordString(hRec, fqWeb, &pwzData); ExitOnFailure(hr, "Failed to get Web for VirtualDir"); if (*pwzData) { dwLen = countof(psf->wzWebBase); hr = ScaWebsGetBase(piMetabase, pswList, pwzData, psf->wzWebBase, &dwLen); ExitOnFailure(hr, "Failed to get base of web for Filter"); StringCchPrintfW(psf->wzFilterRoot, countof(psf->wzFilterRoot), L"%s/Filters", psf->wzWebBase); } else { StringCchCopyW(psf->wzFilterRoot, countof(psf->wzFilterRoot), L"/LM/W3SVC/Filters"); } // filter key hr = WcaGetRecordString(hRec, fqFilter, &pwzData); ExitOnFailure(hr, "Failed to get Filter.Filter"); StringCchCopyW(psf->wzKey, countof(psf->wzKey), pwzData); // filter path hr = WcaGetRecordFormattedString(hRec, fqPath, &pwzData); ExitOnFailure(hr, "Failed to get Filter.Path"); StringCchCopyW(psf->wzPath, countof(psf->wzPath), pwzData); // filter description hr = WcaGetRecordFormattedString(hRec, fqDescription, &pwzData); ExitOnFailure(hr, "Failed to get Filter.Description"); StringCchCopyW(psf->wzDescription, countof(psf->wzDescription), pwzData); // filter flags hr = WcaGetRecordInteger(hRec, fqFlags, &psf->iFlags); ExitOnFailure(hr, "Failed to get Filter.Flags"); // filter load order hr = WcaGetRecordInteger(hRec, fqLoadOrder, &psf->iLoadOrder); ExitOnFailure(hr, "Failed to get Filter.LoadOrder"); } if (E_NOMOREITEMS == hr) hr = S_OK; ExitOnFailure(hr, "Failure while processing filters"); LExit: ReleaseStr(pwzData); return hr; }
UINT __stdcall ScaWebDirsRead( __in IMSAdminBase* piMetabase, __in SCA_WEB* pswList, __in WCA_WRAPQUERY_HANDLE hUserQuery, __in WCA_WRAPQUERY_HANDLE hWebBaseQuery, __in WCA_WRAPQUERY_HANDLE hWebDirPropQuery, __in WCA_WRAPQUERY_HANDLE hWebAppQuery, __in WCA_WRAPQUERY_HANDLE hWebAppExtQuery, __inout LPWSTR *ppwzCustomActionData, __out SCA_WEBDIR** ppswdList ) { Assert(piMetabase && ppswdList); HRESULT hr = S_OK; MSIHANDLE hRec; LPWSTR pwzData = NULL; SCA_WEBDIR* pswd; WCA_WRAPQUERY_HANDLE hWrapQuery = NULL; hr = WcaBeginUnwrapQuery(&hWrapQuery, ppwzCustomActionData); ExitOnFailure(hr, "Failed to unwrap query for ScaWebDirsRead"); if (0 == WcaGetQueryRecords(hWrapQuery)) { WcaLog(LOGMSG_VERBOSE, "Skipping ScaInstallWebDirs() because IIsWebDir table not present"); ExitFunction1(hr = S_FALSE); } // loop through all the web directories while (S_OK == (hr = WcaFetchWrappedRecord(hWrapQuery, &hRec))) { pswd = NewWebDir(); ExitOnNull(pswd, hr, E_OUTOFMEMORY, "Failed to allocate memory for web dir object in memory"); // get component install state hr = WcaGetRecordString(hRec, wdqComponent, &pwzData); ExitOnFailure(hr, "Failed to get Component for WebDirs"); hr = ::StringCchCopyW(pswd->wzComponent, countof(pswd->wzComponent), pwzData); ExitOnFailure(hr, "Failed to copy component string to webdir object"); hr = WcaGetRecordInteger(hRec, wdqInstalled, (int *)&pswd->isInstalled); ExitOnFailure(hr, "Failed to get Component installed state for webdir"); hr = WcaGetRecordInteger(hRec, wdqAction, (int *)&pswd->isAction); ExitOnFailure(hr, "Failed to get Component action state for webdir"); // If this record has a component and no action is being taken for it, skip processing it entirely if (0 < lstrlenW(pswd->wzComponent) && !WcaIsInstalling(pswd->isInstalled, pswd->isAction) && !WcaIsUninstalling(pswd->isInstalled, pswd->isAction) && !WcaIsReInstalling(pswd->isInstalled, pswd->isAction)) { FreeWebDir(pswd); pswd = NULL; continue; } hr = WcaGetRecordString(hRec, wdqWeb, &pwzData); ExitOnFailure(hr, "Failed to get Web for WebDir"); hr = ScaWebsGetBase(piMetabase, pswList, pwzData, pswd->wzWebBase, countof(pswd->wzWebBase), hWebBaseQuery); if (WcaIsUninstalling(pswd->isInstalled, pswd->isAction)) { // If we're uninstalling, ignore any failure to find the existing web hr = S_OK; } ExitOnFailure(hr, "Failed to get base of web for WebDir"); hr = WcaGetRecordString(hRec, wdqPath, &pwzData); ExitOnFailure(hr, "Failed to get Path for WebDir"); hr = ::StringCchPrintfW(pswd->wzWebDirRoot, countof(pswd->wzWebDirRoot), L"%s/Root/%s", pswd->wzWebBase, pwzData); ExitOnFailure(hr, "Failed to format webdir root string"); // get the directory properties for this web hr = WcaGetRecordString(hRec, wdqProperties, &pwzData); ExitOnFailure(hr, "Failed to get security identifier for WebDir"); if (*pwzData) { hr = ScaGetWebDirProperties(pwzData, hUserQuery, hWebDirPropQuery, &pswd->swp); ExitOnFailure(hr, "Failed to get properties for WebDir"); pswd->fHasProperties = TRUE; } // get the application information for this web directory hr = WcaGetRecordString(hRec, wdqApplication, &pwzData); ExitOnFailure(hr, "Failed to get application identifier for WebDir"); if (*pwzData) { hr = ScaGetWebApplication(NULL, pwzData, hWebAppQuery, hWebAppExtQuery, &pswd->swapp); ExitOnFailure(hr, "Failed to get application for WebDir"); pswd->fHasApplication = TRUE; } AddWebDirToList(ppswdList, pswd); } if (E_NOMOREITEMS == hr) { hr = S_OK; } ExitOnFailure(hr, "Failure while processing WebDirs"); LExit: WcaFinishUnwrapQuery(hWrapQuery); ReleaseStr(pwzData); return hr; }
HRESULT __stdcall ScaVirtualDirsRead( __in IMSAdminBase* piMetabase, __in SCA_WEB* pswList, __in SCA_VDIR** ppsvdList, __in SCA_MIMEMAP** ppsmmList, __in SCA_HTTP_HEADER** ppshhList, __in SCA_WEB_ERROR** ppsweList, __in WCA_WRAPQUERY_HANDLE hUserQuery, __in WCA_WRAPQUERY_HANDLE hWebBaseQuery, __in WCA_WRAPQUERY_HANDLE hWebDirPropQuery, __in WCA_WRAPQUERY_HANDLE hWebAppQuery, __in WCA_WRAPQUERY_HANDLE hWebAppExtQuery, __inout LPWSTR *ppwzCustomActionData ) { Assert(piMetabase && ppsvdList); HRESULT hr = S_OK; MSIHANDLE hRec; INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; INSTALLSTATE isAction = INSTALLSTATE_UNKNOWN; SCA_VDIR* pvdir = NULL; LPWSTR pwzData = NULL; WCA_WRAPQUERY_HANDLE hWrapQuery = NULL; hr = WcaBeginUnwrapQuery(&hWrapQuery, ppwzCustomActionData); ExitOnFailure(hr, "Failed to unwrap query for ScaAppPoolRead"); if (0 == WcaGetQueryRecords(hWrapQuery)) { WcaLog(LOGMSG_VERBOSE, "Skipping ScaVirtualDirsRead() because IIsWebVirtualDir table not present"); ExitFunction1(hr = S_FALSE); } // loop through all the vdirs while (S_OK == (hr = WcaFetchWrappedRecord(hWrapQuery, &hRec))) { // Get the Component first. If there is a Component and it is not being modified during // this transaction, skip processing this whole record. hr = WcaGetRecordString(hRec, vdqComponent, &pwzData); ExitOnFailure(hr, "failed to get IIsWebVirtualDir.Component"); hr = WcaGetRecordInteger(hRec, vdqInstalled, (int *)&isInstalled); ExitOnFailure(hr, "Failed to get Component installed state for virtual dir"); hr = WcaGetRecordInteger(hRec, vdqAction, (int *)&isAction); ExitOnFailure(hr, "Failed to get Component action state for virtual dir"); if (!WcaIsInstalling(isInstalled, isAction) && !WcaIsReInstalling(isInstalled, isAction) && !WcaIsUninstalling(isInstalled, isAction)) { continue; // skip this record. } hr = AddVirtualDirToList(ppsvdList); ExitOnFailure(hr, "failed to add virtual dir to list"); pvdir = *ppsvdList; hr = ::StringCchCopyW(pvdir->wzComponent, countof(pvdir->wzComponent), pwzData); ExitOnFailure1(hr, "failed to copy component name: %ls", pwzData); pvdir->isInstalled = isInstalled; pvdir->isAction = isAction; // get the web key hr = WcaGetRecordString(hRec, vdqWeb, &pwzData); ExitOnFailure(hr, "Failed to get Web for VirtualDir"); hr = ScaWebsGetBase(piMetabase, pswList, pwzData, pvdir->wzWebBase, countof(pvdir->wzWebBase), hWebBaseQuery); if (WcaIsUninstalling(isInstalled, isAction)) { // If we're uninstalling, ignore any failure to find the existing web hr = S_OK; } ExitOnFailure1(hr, "Failed to get base of web: %ls for VirtualDir", pwzData); hr = WcaGetRecordString(hRec, vdqAlias, &pwzData); ExitOnFailure(hr, "Failed to get Alias for VirtualDir"); if (0 != lstrlenW(pvdir->wzWebBase)) { hr = ::StringCchPrintfW(pvdir->wzVDirRoot, countof(pvdir->wzVDirRoot), L"%s/Root/%s", pvdir->wzWebBase, pwzData); ExitOnFailure(hr, "Failed to set VDirRoot for VirtualDir"); } // get the vdir's directory hr = WcaGetRecordString(hRec, vdqDirectory, &pwzData); ExitOnFailure(hr, "Failed to get Directory for VirtualDir"); // get the web's directory if (INSTALLSTATE_SOURCE == pvdir->isAction) { hr = WcaGetRecordString(hRec, vdqSourcePath, &pwzData); } else { hr = WcaGetRecordString(hRec, vdqTargetPath, &pwzData); } ExitOnFailure(hr, "Failed to get Source/TargetPath for Directory"); // remove trailing backslash(es) while (lstrlenW(pwzData) > 0 && pwzData[lstrlenW(pwzData)-1] == L'\\') { pwzData[lstrlenW(pwzData)-1] = 0; } hr = ::StringCchCopyW(pvdir->wzDirectory, countof(pvdir->wzDirectory), pwzData); ExitOnFailure(hr, "Failed to copy directory string to vdir object"); // get the security information for this web hr = WcaGetRecordString(hRec, vdqProperties, &pwzData); ExitOnFailure(hr, "Failed to get web directory identifier for VirtualDir"); if (*pwzData) { hr = ScaGetWebDirProperties(pwzData, hUserQuery, hWebDirPropQuery, &pvdir->swp); ExitOnFailure(hr, "Failed to get web directory for VirtualDir"); pvdir->fHasProperties = TRUE; } // get the application information for this web hr = WcaGetRecordString(hRec, vdqApplication, &pwzData); ExitOnFailure(hr, "Failed to get application identifier for VirtualDir"); if (*pwzData) { hr = ScaGetWebApplication(NULL, pwzData, hWebAppQuery, hWebAppExtQuery, &pvdir->swapp); ExitOnFailure(hr, "Failed to get application for VirtualDir"); pvdir->fHasApplication = TRUE; } hr = WcaGetRecordString(hRec, vdqVDir, &pwzData); ExitOnFailure(hr, "Failed to get VDir for VirtualDir"); if (*pwzData && *ppsmmList) { hr = ScaGetMimeMap(mmptVDir, pwzData, ppsmmList, &pvdir->psmm); ExitOnFailure(hr, "Failed to get mimemap for VirtualDir"); } if (*pwzData && *ppshhList) { hr = ScaGetHttpHeader(hhptVDir, pwzData, ppshhList, &pvdir->pshh); ExitOnFailure1(hr, "Failed to get custom HTTP headers for VirtualDir: %ls", pwzData); } if (*pwzData && *ppsweList) { hr = ScaGetWebError(weptVDir, pwzData, ppsweList, &pvdir->pswe); ExitOnFailure1(hr, "Failed to get custom web errors for VirtualDir: %ls", pwzData); } } if (E_NOMOREITEMS == hr) { hr = S_OK; } ExitOnFailure(hr, "Failure while processing VirtualDirs"); LExit: WcaFinishUnwrapQuery(hWrapQuery); ReleaseStr(pwzData); return hr; }
HRESULT __stdcall ScaVirtualDirsRead( __in IMSAdminBase* piMetabase, __in SCA_WEB* pswList, __in SCA_VDIR** ppsvdList, __in SCA_MIMEMAP** ppsmmList, __in SCA_HTTP_HEADER** ppshhList, __in SCA_WEB_ERROR** ppsweList ) { Assert(piMetabase && ppsvdList); HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; PMSIHANDLE hView, hRec; SCA_VDIR* pvdir = NULL; LPWSTR pwzData = NULL; DWORD cchData = 0; DWORD dwLen = 0; // check to see if necessary tables are specified if (S_OK != WcaTableExists(L"IIsWebVirtualDir")) { WcaLog(LOGMSG_VERBOSE, "Skipping ScaIntsallVirtualDirs() because IIsWebVirtualDir table not present"); hr = S_FALSE; goto LExit; } // loop through all the vdirs hr = WcaOpenExecuteView(vcsVDirQuery, &hView); ExitOnFailure(hr, "Failed to open view on IIsWebVirtualDir table"); while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) { hr = AddVirtualDirToList(ppsvdList); ExitOnFailure(hr, "failed to add virtual dir to list"); pvdir = *ppsvdList; // get component install state hr = WcaGetRecordString(hRec, vdqComponent, &pwzData); ExitOnFailure(hr, "Failed to get Component for VirtualDirs"); er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzData, &pvdir->isInstalled, &pvdir->isAction); hr = HRESULT_FROM_WIN32(er); ExitOnFailure(hr, "Failed to get Component state for VirtualDirs"); // get the web key hr = WcaGetRecordString(hRec, vdqWeb, &pwzData); ExitOnFailure(hr, "Failed to get Web for VirtualDir"); dwLen = countof(pvdir->wzWebBase); hr = ScaWebsGetBase(piMetabase, pswList, pwzData, pvdir->wzWebBase, &dwLen); ExitOnFailure1(hr, "Failed to get base of web: %S for VirtualDir", pwzData); hr = WcaGetRecordFormattedString(hRec, vdqAlias, &pwzData); ExitOnFailure(hr, "Failed to get Alias for VirtualDir"); hr = StringCchPrintfW(pvdir->wzVDirRoot, countof(pvdir->wzVDirRoot), L"%s/Root/%s", pvdir->wzWebBase, pwzData); ExitOnFailure(hr, "Failed to set VDirRoot for VirtualDir"); // get the vdir's directory hr = WcaGetRecordString(hRec, vdqDirectory, &pwzData); ExitOnFailure(hr, "Failed to get Directory for VirtualDir"); WCHAR wzTargetPath[MAX_PATH]; dwLen = countof(wzTargetPath); if (INSTALLSTATE_SOURCE == pvdir->isAction) er = ::MsiGetSourcePathW(WcaGetInstallHandle(), pwzData, wzTargetPath, &dwLen); else er = ::MsiGetTargetPathW(WcaGetInstallHandle(), pwzData, wzTargetPath, &dwLen); hr = HRESULT_FROM_WIN32(er); ExitOnFailure(hr, "Failed to get TargetPath for Directory for VirtualDir"); // remove trailing backslash(es) while (dwLen > 0 && wzTargetPath[dwLen-1] == L'\\') { wzTargetPath[dwLen-1] = L'\0'; dwLen--; } StringCchCopyW(pvdir->wzDirectory, countof(pvdir->wzDirectory), wzTargetPath); // get the security information for this web hr = WcaGetRecordString(hRec, vdqProperties, &pwzData); ExitOnFailure(hr, "Failed to get web directory identifier for VirtualDir"); if (*pwzData) { hr = ScaGetWebDirProperties(pwzData, &pvdir->swp); ExitOnFailure(hr, "Failed to get web directory for VirtualDir"); pvdir->fHasProperties = TRUE; } // get the application information for this web hr = WcaGetRecordString(hRec, vdqApplication, &pwzData); ExitOnFailure(hr, "Failed to get application identifier for VirtualDir"); if (*pwzData) { hr = ScaGetWebApplication(NULL, pwzData, &pvdir->swapp); ExitOnFailure(hr, "Failed to get application for VirtualDir"); pvdir->fHasApplication = TRUE; } hr = WcaGetRecordString(hRec, vdqVDir, &pwzData); ExitOnFailure(hr, "Failed to get VDir for VirtualDir"); if (*pwzData && *ppsmmList) { hr = ScaGetMimeMap(mmptVDir, pwzData, ppsmmList, &pvdir->psmm); ExitOnFailure(hr, "Failed to get mimemap for VirtualDir"); } if (*pwzData && *ppshhList) { hr = ScaGetHttpHeader(hhptVDir, pwzData, ppshhList, &pvdir->pshh); ExitOnFailure1(hr, "Failed to get custom HTTP headers for VirtualDir: %S", pwzData); } if (*pwzData && *ppsweList) { hr = ScaGetWebError(weptVDir, pwzData, ppsweList, &pvdir->pswe); ExitOnFailure1(hr, "Failed to get custom web errors for VirtualDir: %S", pwzData); } } if (E_NOMOREITEMS == hr) hr = S_OK; ExitOnFailure(hr, "Failure while processing VirtualDirs"); LExit: ReleaseStr(pwzData); return hr; }