本文整理汇总了C++中ExitOnFailure1函数的典型用法代码示例。如果您正苦于以下问题:C++ ExitOnFailure1函数的具体用法?C++ ExitOnFailure1怎么用?C++ ExitOnFailure1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ExitOnFailure1函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ExecuteStrings
static HRESULT ExecuteStrings(
__in SCA_DB* psdList,
__in SCA_SQLSTR* psssList,
__in BOOL fInstall
)
{
HRESULT hr = S_FALSE; // assume nothing will be done
int iRollback = -1;
int iOldRollback = iRollback;
LPCWSTR wzOldDb = NULL;
UINT uiCost = 0;
WCHAR* pwzCustomActionData = NULL;
WCHAR wzNumber[64];
// loop through all sql strings
for (SCA_SQLSTR* psss = psssList; psss; psss = psss->psssNext)
{
// if installing this component
if ((fInstall && (psss->iAttributes & SCASQL_EXECUTE_ON_INSTALL) && WcaIsInstalling(psss->isInstalled, psss->isAction) && !WcaIsReInstalling(psss->isInstalled, psss->isAction)) ||
(fInstall && (psss->iAttributes & SCASQL_EXECUTE_ON_REINSTALL) && WcaIsReInstalling(psss->isInstalled, psss->isAction)) ||
(!fInstall && (psss->iAttributes & SCASQL_EXECUTE_ON_UNINSTALL) && WcaIsUninstalling(psss->isInstalled, psss->isAction)))
{
// determine if this is a rollback scheduling or normal deferred scheduling
if (psss->iAttributes & SCASQL_ROLLBACK)
{
iRollback = 1;
}
else
{
iRollback = 0;
}
// if we need to create a connection to a new server\database
if (!wzOldDb || 0 != lstrcmpW(wzOldDb, psss->wzSqlDb) || iOldRollback != iRollback)
{
const SCA_DB* psd = ScaDbsFindDatabase(psss->wzSqlDb, psdList);
if (!psd)
{
ExitOnFailure1(hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND), "failed to find data for Database: %ls", psss->wzSqlDb);
}
if (-1 == iOldRollback)
{
iOldRollback = iRollback;
}
Assert(0 == iOldRollback || 1 == iOldRollback);
// if there was custom action data before, schedule the action to write it
if (pwzCustomActionData && *pwzCustomActionData)
{
Assert(pwzCustomActionData && *pwzCustomActionData && uiCost);
hr = WcaDoDeferredAction(1 == iOldRollback ? L"RollbackExecuteSqlStrings" : L"ExecuteSqlStrings", pwzCustomActionData, uiCost);
ExitOnFailure1(hr, "failed to schedule ExecuteSqlStrings action, rollback: %d", iOldRollback);
iOldRollback = iRollback;
*pwzCustomActionData = L'\0';
uiCost = 0;
}
Assert(!pwzCustomActionData || (pwzCustomActionData && 0 == *pwzCustomActionData) && 0 == uiCost);
hr = WcaWriteStringToCaData(psd->wzKey, &pwzCustomActionData);
ExitOnFailure1(hr, "Failed to add SQL Server Database String to CustomActionData for Database String: %ls", psd->wzKey);
hr = WcaWriteStringToCaData(psd->wzServer, &pwzCustomActionData);
ExitOnFailure1(hr, "Failed to add SQL Server to CustomActionData for Database String: %ls", psd->wzKey);
hr = WcaWriteStringToCaData(psd->wzInstance, &pwzCustomActionData);
ExitOnFailure1(hr, "Failed to add SQL Instance to CustomActionData for Database String: %ls", psd->wzKey);
hr = WcaWriteStringToCaData(psd->wzDatabase, &pwzCustomActionData);
ExitOnFailure1(hr, "Failed to add SQL Database to CustomActionData for Database String: %ls", psd->wzKey);
hr = ::StringCchPrintfW(wzNumber, countof(wzNumber), L"%d", psd->iAttributes);
ExitOnFailure(hr, "Failed to format attributes integer value to string");
hr = WcaWriteStringToCaData(wzNumber, &pwzCustomActionData);
ExitOnFailure1(hr, "Failed to add SQL Attributes to CustomActionData for Database String: %ls", psd->wzKey);
hr = ::StringCchPrintfW(wzNumber, countof(wzNumber), L"%d", psd->fUseIntegratedAuth);
ExitOnFailure(hr, "Failed to format UseIntegratedAuth integer value to string");
hr = WcaWriteStringToCaData(wzNumber, &pwzCustomActionData);
ExitOnFailure1(hr, "Failed to add SQL IntegratedAuth flag to CustomActionData for Database String: %ls", psd->wzKey);
hr = WcaWriteStringToCaData(psd->scau.wzName, &pwzCustomActionData);
ExitOnFailure1(hr, "Failed to add SQL UserName to CustomActionData for Database String: %ls", psd->wzKey);
hr = WcaWriteStringToCaData(psd->scau.wzPassword, &pwzCustomActionData);
ExitOnFailure1(hr, "Failed to add SQL Password to CustomActionData for Database String: %ls", psd->wzKey);
uiCost += COST_SQL_CONNECTDB;
wzOldDb = psss->wzSqlDb;
}
WcaLog(LOGMSG_VERBOSE, "Scheduling SQL string: %ls", psss->pwzSql);
hr = WcaWriteStringToCaData(psss->wzKey, &pwzCustomActionData);
//.........这里部分代码省略.........
开发者ID:BMurri,项目名称:wix3,代码行数:101,代码来源:scasqlstr.cpp
示例2: DependencyPlanPackageBegin
extern "C" HRESULT DependencyPlanPackageBegin(
__in BOOL fPerMachine,
__in BURN_PACKAGE* pPackage,
__in BURN_PLAN* pPlan
)
{
HRESULT hr = S_OK;
STRINGDICT_HANDLE sdIgnoredDependents = NULL;
DEPENDENCY* rgDependents = NULL;
UINT cDependents = 0;
HKEY hkHive = pPackage->fPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
BURN_DEPENDENCY_ACTION dependencyExecuteAction = BURN_DEPENDENCY_ACTION_NONE;
BURN_DEPENDENCY_ACTION dependencyRollbackAction = BURN_DEPENDENCY_ACTION_NONE;
pPackage->dependencyExecute = BURN_DEPENDENCY_ACTION_NONE;
pPackage->dependencyRollback = BURN_DEPENDENCY_ACTION_NONE;
// Make sure the package defines at least one provider.
if (0 == pPackage->cDependencyProviders)
{
LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_SKIP_NOPROVIDERS, pPackage->sczId);
ExitFunction1(hr = S_OK);
}
// Make sure the package is in the same scope as the bundle.
if (fPerMachine != pPackage->fPerMachine)
{
LogId(REPORT_STANDARD, MSG_DEPENDENCY_PACKAGE_SKIP_WRONGSCOPE, pPackage->sczId, LoggingPerMachineToString(fPerMachine), LoggingPerMachineToString(pPackage->fPerMachine));
ExitFunction1(hr = S_OK);
}
// If we're uninstalling the package, check if any dependents are registered.
if (BOOTSTRAPPER_ACTION_STATE_UNINSTALL == pPackage->execute)
{
// Build up a list of dependents to ignore, including the current bundle.
hr = GetIgnoredDependents(pPackage, pPlan, &sdIgnoredDependents);
ExitOnFailure(hr, "Failed to build the list of ignored dependents.");
// Skip the dependency check if "ALL" was authored for IGNOREDEPENDENCIES.
hr = DictKeyExists(sdIgnoredDependents, L"ALL");
if (E_NOTFOUND != hr)
{
ExitOnFailure(hr, "Failed to check if \"ALL\" was set in IGNOREDEPENDENCIES.");
}
else
{
for (DWORD i = 0; i < pPackage->cDependencyProviders; ++i)
{
const BURN_DEPENDENCY_PROVIDER* pProvider = &pPackage->rgDependencyProviders[i];
hr = DepCheckDependents(hkHive, pProvider->sczKey, 0, sdIgnoredDependents, &rgDependents, &cDependents);
if (E_FILENOTFOUND != hr)
{
ExitOnFailure1(hr, "Failed dependents check on package provider: %ls", pProvider->sczKey);
}
else
{
hr = S_OK;
}
}
}
}
// Calculate the dependency actions before the package itself is planned.
CalculateDependencyActionStates(pPackage, pPlan->action, &dependencyExecuteAction, &dependencyRollbackAction);
// If dependents were found, change the action to not uninstall the package.
if (0 < cDependents)
{
LogId(REPORT_STANDARD, MSG_DEPENDENCY_PACKAGE_HASDEPENDENTS, pPackage->sczId, cDependents);
for (DWORD i = 0; i < cDependents; ++i)
{
const DEPENDENCY* pDependency = &rgDependents[i];
LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_DEPENDENT, pDependency->sczKey, LoggingStringOrUnknownIfNull(pDependency->sczName));
}
pPackage->fDependencyManagerWasHere = TRUE;
pPackage->execute = BOOTSTRAPPER_ACTION_STATE_NONE;
pPackage->rollback = BOOTSTRAPPER_ACTION_STATE_NONE;
}
else // use the calculated dependency actions as the provider actions if there are any non-imported providers
{ // that will need to be registered.
BOOL fAllImportedProviders = TRUE; // assume all providers were imported.
for (DWORD i = 0; i < pPackage->cDependencyProviders; ++i)
{
const BURN_DEPENDENCY_PROVIDER* pProvider = &pPackage->rgDependencyProviders[i];
if (!pProvider->fImported)
{
fAllImportedProviders = FALSE;
break;
}
}
if (!fAllImportedProviders)
{
pPackage->providerExecute = dependencyExecuteAction;
pPackage->providerRollback = dependencyRollbackAction;
}
}
//.........这里部分代码省略.........
开发者ID:Alyoshak,项目名称:wix3,代码行数:101,代码来源:dependency.cpp
示例3: RecursePath
static HRESULT RecursePath(
__in_z LPCWSTR wzPath,
__in_z LPCWSTR wzId,
__in_z LPCWSTR wzComponent,
__in_z LPCWSTR wzProperty,
__in int iMode,
__inout DWORD* pdwCounter,
__inout MSIHANDLE* phTable,
__inout MSIHANDLE* phColumns
)
{
HRESULT hr = S_OK;
DWORD er;
LPWSTR sczSearch = NULL;
LPWSTR sczProperty = NULL;
HANDLE hFind = INVALID_HANDLE_VALUE;
WIN32_FIND_DATAW wfd;
LPWSTR sczNext = NULL;
// First recurse down to all the child directories.
hr = StrAllocFormatted(&sczSearch, L"%s*", wzPath);
ExitOnFailure1(hr, "Failed to allocate file search string in path: %S", wzPath);
hFind = ::FindFirstFileW(sczSearch, &wfd);
if (INVALID_HANDLE_VALUE == hFind)
{
er = ::GetLastError();
if (ERROR_PATH_NOT_FOUND == er)
{
ExitFunction1(hr = S_FALSE);
}
else
{
hr = HRESULT_FROM_WIN32(er);
}
ExitOnFailure1(hr, "Failed to find all files in path: %S", wzPath);
}
do
{
// Skip files and the dot directories.
if (FILE_ATTRIBUTE_DIRECTORY != (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || L'.' == wfd.cFileName[0] && (L'\0' == wfd.cFileName[1] || (L'.' == wfd.cFileName[1] && L'\0' == wfd.cFileName[2])))
{
continue;
}
hr = StrAllocFormatted(&sczNext, L"%s%s\\", wzPath, wfd.cFileName);
ExitOnFailure2(hr, "Failed to concat filename '%S' to string: %S", wfd.cFileName, wzPath);
hr = RecursePath(sczNext, wzId, wzComponent, wzProperty, iMode, pdwCounter, phTable, phColumns);
ExitOnFailure1(hr, "Failed to recurse path: %S", sczNext);
} while (::FindNextFileW(hFind, &wfd));
er = ::GetLastError();
if (ERROR_NO_MORE_FILES == er)
{
hr = S_OK;
}
else
{
hr = HRESULT_FROM_WIN32(er);
ExitOnFailure1(hr, "Failed while looping through files in directory: %S", wzPath);
}
// Finally, set a property that points at our path.
hr = StrAllocFormatted(&sczProperty, L"_%s_%u", wzProperty, *pdwCounter);
ExitOnFailure1(hr, "Failed to allocate Property for RemoveFile table with property: %S.", wzProperty);
++(*pdwCounter);
hr = WcaSetProperty(sczProperty, wzPath);
ExitOnFailure2(hr, "Failed to set Property: %S with path: %S", sczProperty, wzPath);
// Add the row to remove any files and another row to remove the folder.
hr = WcaAddTempRecord(phTable, phColumns, L"RemoveFile", NULL, 1, 5, L"RfxFiles", wzComponent, L"*.*", sczProperty, iMode);
ExitOnFailure2(hr, "Failed to add row to remove all files for WixRemoveFolderEx row: %S under path:", wzId, wzPath);
hr = WcaAddTempRecord(phTable, phColumns, L"RemoveFile", NULL, 1, 5, L"RfxFolder", wzComponent, NULL, sczProperty, iMode);
ExitOnFailure2(hr, "Failed to add row to remove folder for WixRemoveFolderEx row: %S under path: %S", wzId, wzPath);
LExit:
if (INVALID_HANDLE_VALUE != hFind)
{
::FindClose(hFind);
}
ReleaseStr(sczNext);
ReleaseStr(sczProperty);
ReleaseStr(sczSearch);
return hr;
}
开发者ID:lukaswinzenried,项目名称:WixCustBa,代码行数:91,代码来源:RemoveFoldersEx.cpp
示例4: ExeEngineParsePackageFromXml
extern "C" HRESULT ExeEngineParsePackageFromXml(
__in IXMLDOMNode* pixnExePackage,
__in BURN_PACKAGE* pPackage
)
{
HRESULT hr = S_OK;
IXMLDOMNodeList* pixnNodes = NULL;
IXMLDOMNode* pixnNode = NULL;
DWORD cNodes = 0;
LPWSTR scz = NULL;
// @DetectCondition
hr = XmlGetAttributeEx(pixnExePackage, L"DetectCondition", &pPackage->Exe.sczDetectCondition);
ExitOnFailure(hr, "Failed to get @DetectCondition.");
// @InstallArguments
hr = XmlGetAttributeEx(pixnExePackage, L"InstallArguments", &pPackage->Exe.sczInstallArguments);
ExitOnFailure(hr, "Failed to get @InstallArguments.");
// @UninstallArguments
hr = XmlGetAttributeEx(pixnExePackage, L"UninstallArguments", &pPackage->Exe.sczUninstallArguments);
ExitOnFailure(hr, "Failed to get @UninstallArguments.");
// @RepairArguments
hr = XmlGetAttributeEx(pixnExePackage, L"RepairArguments", &pPackage->Exe.sczRepairArguments);
ExitOnFailure(hr, "Failed to get @RepairArguments.");
// @Repairable
hr = XmlGetYesNoAttribute(pixnExePackage, L"Repairable", &pPackage->Exe.fRepairable);
if (E_NOTFOUND != hr)
{
ExitOnFailure(hr, "Failed to get @Repairable.");
}
// @Protocol
hr = XmlGetAttributeEx(pixnExePackage, L"Protocol", &scz);
if (SUCCEEDED(hr))
{
if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"burn", -1))
{
pPackage->Exe.protocol = BURN_EXE_PROTOCOL_TYPE_BURN;
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"netfx4", -1))
{
pPackage->Exe.protocol = BURN_EXE_PROTOCOL_TYPE_NETFX4;
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"none", -1))
{
pPackage->Exe.protocol = BURN_EXE_PROTOCOL_TYPE_NONE;
}
else
{
hr = E_UNEXPECTED;
ExitOnFailure1(hr, "Invalid protocol type: %ls", scz);
}
}
else if (E_NOTFOUND != hr)
{
ExitOnFailure(hr, "Failed to get @Protocol.");
}
// select exit code nodes
hr = XmlSelectNodes(pixnExePackage, L"ExitCode", &pixnNodes);
ExitOnFailure(hr, "Failed to select exit code nodes.");
// get exit code node count
hr = pixnNodes->get_length((long*)&cNodes);
ExitOnFailure(hr, "Failed to get exit code node count.");
if (cNodes)
{
// allocate memory for exit codes
pPackage->Exe.rgExitCodes = (BURN_EXE_EXIT_CODE*)MemAlloc(sizeof(BURN_EXE_EXIT_CODE) * cNodes, TRUE);
ExitOnNull(pPackage->Exe.rgExitCodes, hr, E_OUTOFMEMORY, "Failed to allocate memory for exit code structs.");
pPackage->Exe.cExitCodes = cNodes;
// parse package elements
for (DWORD i = 0; i < cNodes; ++i)
{
BURN_EXE_EXIT_CODE* pExitCode = &pPackage->Exe.rgExitCodes[i];
hr = XmlNextElement(pixnNodes, &pixnNode, NULL);
ExitOnFailure(hr, "Failed to get next node.");
// @Type
hr = XmlGetAttributeEx(pixnNode, L"Type", &scz);
ExitOnFailure(hr, "Failed to get @Type.");
if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"success", -1))
{
pExitCode->type = BURN_EXE_EXIT_CODE_TYPE_SUCCESS;
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"error", -1))
{
pExitCode->type = BURN_EXE_EXIT_CODE_TYPE_ERROR;
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"scheduleReboot", -1))
{
pExitCode->type = BURN_EXE_EXIT_CODE_TYPE_SCHEDULE_REBOOT;
//.........这里部分代码省略.........
开发者ID:925coder,项目名称:wix3,代码行数:101,代码来源:exeengine.cpp
示例5: CpiRollbackConfigurePartitionUsers
HRESULT CpiRollbackConfigurePartitionUsers(
LPWSTR* ppwzData,
CPI_ROLLBACK_DATA* pRollbackDataList
)
{
HRESULT hr = S_OK;
int iRollbackStatus;
CPI_PARTITION_USER_ATTRIBUTES attrs;
::ZeroMemory(&attrs, sizeof(attrs));
// read action text
hr = CpiActionStartMessage(ppwzData, NULL == pRollbackDataList);
ExitOnFailure(hr, "Failed to send action start message");
// get count
int iCnt = 0;
hr = WcaReadIntegerFromCaData(ppwzData, &iCnt);
ExitOnFailure(hr, "Failed to read count");
for (int i = 0; i < iCnt; i++)
{
// read partition attributes from CustomActionData
hr = ReadPartitionUserAttributes(ppwzData, &attrs);
ExitOnFailure(hr, "Failed to read attributes");
// rollback status
hr = CpiFindRollbackStatus(pRollbackDataList, attrs.pwzKey, &iRollbackStatus);
if (S_FALSE == hr)
continue; // not found, nothing to rollback
// progress message
hr = CpiActionDataMessage(1, attrs.pwzAccount);
ExitOnFailure(hr, "Failed to send progress messages");
if (S_FALSE == hr)
ExitFunction();
// action
switch (attrs.iActionType)
{
case atCreate:
hr = CreatePartitionUser(&attrs);
ExitOnFailure1(hr, "Failed to create partition user, key: %S", attrs.pwzKey);
break;
case atRemove:
hr = RemovePartitionUser(&attrs);
ExitOnFailure1(hr, "Failed to remove partition user, key: %S", attrs.pwzKey);
break;
}
// check rollback status
if (0 == iRollbackStatus)
continue; // operation did not complete, skip progress
// progress
hr = WcaProgressMessage(attrs.iActionCost, FALSE);
ExitOnFailure(hr, "Failed to update progress");
}
hr = S_OK;
LExit:
// clean up
FreePartitionUserAttributes(&attrs);
return hr;
}
开发者ID:925coder,项目名称:wix3,代码行数:70,代码来源:cppartexec.cpp
示例6: CustomAction
/******************************************************************
CaSchedServiceConfig - entry point for CaSchedServiceConfig Custom Action
called as Type 1 CustomAction (binary DLL) from Windows Installer
in InstallExecuteSequence before CaExecServiceConfig
********************************************************************/
extern "C" UINT __stdcall SchedServiceConfig(
__in MSIHANDLE hInstall
)
{
// AssertSz(FALSE, "debug SchedServiceConfig");
HRESULT hr = S_OK;
UINT uiResult = ERROR_SUCCESS;
DWORD dwError = 0;
LPWSTR pwzData = NULL;
int iData = 0;
BOOL fExistingService = FALSE;
PMSIHANDLE hView = NULL;
PMSIHANDLE hRec = NULL;
INSTALLSTATE isInstalled;
INSTALLSTATE isAction;
SC_HANDLE hSCM = NULL;
SC_HANDLE hService = NULL;
LPSERVICE_FAILURE_ACTIONSW psfa;
LPWSTR pwzCustomActionData = NULL;
LPWSTR pwzRollbackCustomActionData = NULL;
DWORD cServices = 0;
DWORD dwRestartDelay = 0;
WCHAR wzActionName[32] = { 0 };
DWORD dwSizeNeeded = 0;
// initialize
hr = WcaInitialize(hInstall, "SchedServiceConfig");
ExitOnFailure(hr, "failed to initialize");
//Get a handle to the service control manager
hSCM = ::OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT);
if (hSCM == NULL)
ExitOnLastError(hr, "failed to get handle to SCM");
// loop through all the services to be configured
hr = WcaOpenExecuteView(wzQUERY_SERVICECONFIG, &hView);
ExitOnFailure(hr, "failed to open view on ServiceConfig table");
while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
{
hr = WcaGetRecordInteger(hRec, QSC_NEWSERVICE, &iData);
ExitOnFailure(hr, "failed to get object NewService");
fExistingService = 1 != iData;
// Get component name
hr = WcaGetRecordString(hRec, QSC_COMPONENT, &pwzData);
ExitOnFailure(hr, "failed to get component name");
// check if we are installing this Component
hr = ::MsiGetComponentStateW(hInstall, pwzData, &isInstalled, &isAction);
ExitOnFailure1(hr = HRESULT_FROM_WIN32(hr), "failed to get install state for Component: %S", pwzData);
// We want to configure either a service we're installing or one already on the box
if (WcaIsInstalling(isInstalled, isAction))
{
// Check if we're configuring an existing service
if (fExistingService)
{
// Confirm the service is actually on the box
hr = WcaGetRecordFormattedString(hRec, QSC_SERVICENAME, &pwzData);
ExitOnFailure(hr, "failed to get object NewService");
//Get a handle to the service
hService = ::OpenServiceW(hSCM, pwzData, SERVICE_QUERY_CONFIG);
if (hService == NULL)
{
dwError = ::GetLastError();
hr = HRESULT_FROM_WIN32(dwError);
if (hr == ERROR_SERVICE_DOES_NOT_EXIST)
{
ExitOnFailure1(hr, "Service \"%s\" does not exist on this system.", pwzData);
}
else
{
ExitOnFailure1(hr, "Failed to get handle to the service \"%S\".", pwzData);
}
}
// Get Current Service Config info
if(!::QueryServiceConfig2W(hService, SERVICE_CONFIG_FAILURE_ACTIONS, NULL, 0, &dwSizeNeeded) && ERROR_INSUFFICIENT_BUFFER != ::GetLastError())
{
ExitOnLastError(hr, "Failed to get current service config info.");
}
//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:101,代码来源:serviceconfig.cpp
示例7: SchedAddinRegistration
/******************************************************************
SchedAddinRegistration - entry point for AddinRegistration Custom Action
********************************************************************/
HRESULT SchedAddinRegistration(MSIHANDLE hInstall, BOOL fInstall)
{
// AssertSz(FALSE, "debug SchedRegisterAddins");
HRESULT hr = S_OK;
LPWSTR pwzCustomActionData = NULL;
PMSIHANDLE hView = NULL;
PMSIHANDLE hRec = NULL;
LPWSTR pwzData = NULL;
LPWSTR pwzTemp = NULL;
LPWSTR pwzComponent = NULL;
LPWSTR pwzId = NULL;
LPWSTR pwzFile = NULL;
LPWSTR pwzFriendlyName = NULL;
LPWSTR pwzDescription = NULL;
int iBitness = 0;
int iCommandLineSafe = 1;
int iLoadBehavior = 0;
LPWSTR pwzAllUsers = NULL;
int nAddins = 0;
hr = WcaGetProperty(L"ALLUSERS", &pwzAllUsers);
ExitOnFailure(hr, "failed to read value of ALLUSERS property");
// loop through all the RegisterAddin records
hr = WcaOpenExecuteView(vcsRegisterAddinsQuery, &hView);
ExitOnFailure(hr, "failed to open view on AddinRegistration table");
while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
{
++nAddins;
// Get Id
hr = WcaGetRecordString(hRec, arqId, &pwzId);
ExitOnFailure(hr, "failed to get AddinRegistration.AddinRegistration");
// Get File
hr = WcaGetRecordString(hRec, arqFile, &pwzData);
ExitOnFailure1(hr, "failed to get AddinRegistration.File_ for record: %ls", pwzId);
hr = StrAllocFormatted(&pwzTemp, L"[#%ls]", pwzData);
ExitOnFailure1(hr, "failed to format file string for file: %ls", pwzData);
hr = WcaGetFormattedString(pwzTemp, &pwzFile);
ExitOnFailure1(hr, "failed to get formatted string for file: %ls", pwzData);
// Get name
hr = WcaGetRecordFormattedString(hRec, arqName, &pwzFriendlyName);
ExitOnFailure1(hr, "failed to get AddinRegistration.Name for record: %ls", pwzId);
// Get description
hr = WcaGetRecordFormattedString(hRec, arqDescription, &pwzDescription);
ExitOnFailure1(hr, "failed to get AddinRegistration.Description for record: %ls", pwzId);
// Get description
hr = WcaGetRecordInteger(hRec, arqBitness, &iBitness);
ExitOnFailure1(hr, "failed to get AddinRegistration.Bitnesss for record: %ls", pwzId);
// Get description
hr = WcaGetRecordInteger(hRec, arqCommandLineSafe, &iCommandLineSafe);
ExitOnFailure1(hr, "failed to get AddinRegistration.CommandLineSafe for record: %ls", pwzId);
// Get description
hr = WcaGetRecordInteger(hRec, arqLoadBehavior, &iLoadBehavior);
ExitOnFailure1(hr, "failed to get AddinRegistration.LoadBehavior for record: %ls", pwzId);
// get component and its install/action states
hr = WcaGetRecordString(hRec, arqComponent, &pwzComponent);
ExitOnFailure(hr, "failed to get addin component id");
// we need to know if the component's being installed, uninstalled, or reinstalled
WCA_TODO todo = WcaGetComponentToDo(pwzComponent);
// skip this entry if this is the install CA and we are uninstalling the component
if (fInstall && WCA_TODO_UNINSTALL == todo)
{
continue;
}
// skip this entry if this is an uninstall CA and we are not uninstalling the component
if (!fInstall && WCA_TODO_UNINSTALL != todo)
{
continue;
}
// write custom action data: operation, instance guid, path, directory
hr = WcaWriteIntegerToCaData(todo, &pwzCustomActionData);
ExitOnFailure1(hr, "failed to write operation to custom action data for instance id: %ls", pwzId);
hr = WcaWriteStringToCaData(pwzId, &pwzCustomActionData);
ExitOnFailure1(hr, "failed to write id to custom action data for instance id: %ls", pwzId);
//.........这里部分代码省略.........
开发者ID:nbelyh,项目名称:VisioPanelAddinCOM,代码行数:101,代码来源:CustomActionRegisterAddins.cpp
示例8: AllocateAcl
/********************************************************************
AllocateAcl - allocate an acl and populate it with this user and
permission information user could be user or domain\user
********************************************************************/
HRESULT AllocateAcl(SCA_SMBP* pssp, PACL* ppACL)
{
HRESULT hr = S_OK;
EXPLICIT_ACCESSW* pEA = NULL;
DWORD cEA = 0;
DWORD dwCounter = 0;
PSID psid = NULL;
LPCWSTR wzUser = NULL;
DWORD nPermissions = 0;
DWORD nErrorReturn = 0;
ACCESS_MODE accessMode = NOT_USED_ACCESS;
cEA = pssp->dwUserPermissionCount + 1;
if (cEA >= MAXSIZE_T / sizeof(EXPLICIT_ACCESSW))
{
ExitOnFailure1(hr = E_OUTOFMEMORY, "Too many user permissions to allocate: %u", cEA);
}
pEA = static_cast<EXPLICIT_ACCESSW*>(MemAlloc(cEA * sizeof(EXPLICIT_ACCESSW), TRUE));
ExitOnNull(pEA, hr, E_OUTOFMEMORY, "failed to allocate memory for explicit access structure");
// figure out how big the psid is
for (dwCounter = 0; dwCounter < pssp->dwUserPermissionCount; ++dwCounter)
{
wzUser = pssp->pUserPerms[dwCounter].wzUser;
nPermissions = pssp->pUserPerms[dwCounter].nPermissions;
accessMode = pssp->pUserPerms[dwCounter].accessMode;
//
// create the appropriate SID
//
// figure out the right user to put into the access block
if (0 == lstrcmpW(wzUser, L"Everyone"))
{
hr = AclGetWellKnownSid(WinWorldSid, &psid);
}
else if (0 == lstrcmpW(wzUser, L"Administrators"))
{
hr = AclGetWellKnownSid(WinBuiltinAdministratorsSid, &psid);
}
else if (0 == lstrcmpW(wzUser, L"LocalSystem"))
{
hr = AclGetWellKnownSid(WinLocalSystemSid, &psid);
}
else if (0 == lstrcmpW(wzUser, L"LocalService"))
{
hr = AclGetWellKnownSid(WinLocalServiceSid, &psid);
}
else if (0 == lstrcmpW(wzUser, L"NetworkService"))
{
hr = AclGetWellKnownSid(WinNetworkServiceSid, &psid);
}
else if (0 == lstrcmpW(wzUser, L"AuthenticatedUser"))
{
hr = AclGetWellKnownSid(WinAuthenticatedUserSid, &psid);
}
else if (0 == lstrcmpW(wzUser, L"Guests"))
{
hr = AclGetWellKnownSid(WinBuiltinGuestsSid, &psid);
}
else if(0 == lstrcmpW(wzUser, L"CREATOR OWNER"))
{
hr = AclGetWellKnownSid(WinCreatorOwnerSid, &psid);
}
else
{
hr = AclGetAccountSid(NULL, wzUser, &psid);
}
ExitOnFailure1(hr, "failed to get sid for account: %ls", wzUser);
// we now have a valid pSid, fill in the EXPLICIT_ACCESS
/* Permissions options: (see sca.sdh for defined sdl options)
#define GENERIC_READ (0x80000000L) 2147483648
#define GENERIC_WRITE (0x40000000L) 1073741824
#define GENERIC_EXECUTE (0x20000000L) 536870912
#define GENERIC_ALL (0x10000000L) 268435456
*/
pEA[dwCounter].grfAccessPermissions = nPermissions;
pEA[dwCounter].grfAccessMode = accessMode;
pEA[dwCounter].grfInheritance = SUB_CONTAINERS_AND_OBJECTS_INHERIT;
#pragma prefast(push)
#pragma prefast(disable:25029)
::BuildTrusteeWithSidW(&(pEA[dwCounter].Trustee), psid);
#pragma prefast(pop)
}
// create a new ACL that contains the ACE
*ppACL = NULL;
#pragma prefast(push)
#pragma prefast(disable:25029)
nErrorReturn = ::SetEntriesInAclW(dwCounter, pEA, NULL, ppACL);
#pragma prefast(pop)
ExitOnFailure(hr = HRESULT_FROM_WIN32(nErrorReturn), "failed to allocate ACL");
//.........这里部分代码省略.........
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:101,代码来源:scasmbexec.cpp
示例9: ScaWebAppExtensionsRead
HRESULT ScaWebAppExtensionsRead(
LPCWSTR wzApplication,
SCA_WEB_APPLICATION_EXTENSION** ppswappextList
)
{
HRESULT hr = S_OK;
PMSIHANDLE hView, hRec;
SCA_WEB_APPLICATION_EXTENSION* pswappext = NULL;
LPWSTR pwzData = NULL;
// check pre-requisites
hr = WcaTableExists(L"IIsWebApplicationExtension");
if (S_FALSE == hr)
ExitFunction();
// convert the string into a msi record
hRec = ::MsiCreateRecord(1);
hr = WcaSetRecordString(hRec, 1, wzApplication);
ExitOnFailure(hr, "Failed to set record to look up Web Application");
// open and execute the view on the applicatoin extension table
hr = WcaOpenView(vcsWebAppExtensionQuery, &hView);
ExitOnFailure(hr, "Failed to open view on IIsWebApplicationExtension table");
hr = WcaExecuteView(hView, hRec);
ExitOnFailure1(hr, "Failed to execute view on IIsWebApplicationExtension table looking Application: %S", wzApplication);
// get the application extention information
while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
{
hr = NewAppExt(&pswappext);
ExitOnFailure(hr, "failed to create new web app extension");
// get the extension
hr = WcaGetRecordString(hRec, wappextqExtension, &pwzData);
ExitOnFailure(hr, "Failed to get Web Application Extension");
StringCchCopyW(pswappext->wzExtension, countof(pswappext->wzExtension), pwzData);
// application extension verbs
hr = WcaGetRecordString(hRec, wappextqVerbs, &pwzData);
ExitOnFailure1(hr, "Failed to get Verbs for Application: '%S'", wzApplication);
StringCchCopyW(pswappext->wzVerbs, countof(pswappext->wzVerbs), pwzData);
// extension executeable
hr = WcaGetRecordFormattedString(hRec, wappextqExecutable, &pwzData);
ExitOnFailure1(hr, "Failed to get Executable for Application: '%S'", wzApplication);
StringCchCopyW(pswappext->wzExecutable, countof(pswappext->wzExecutable), pwzData);
hr = WcaGetRecordInteger(hRec, wappextqAttributes, &pswappext->iAttributes);
if (S_FALSE == hr)
{
pswappext->iAttributes = 0;
hr = S_OK;
}
ExitOnFailure(hr, "Failed to get App isolation");
*ppswappextList = AddAppExtToList(*ppswappextList, pswappext);
pswappext = NULL; // set the appext NULL so it doesn't accidentally get freed below
}
if (E_NOMOREITEMS == hr)
hr = S_OK;
LExit:
// if anything was left over after an error clean it all up
if (pswappext)
ScaWebAppExtensionsFreeList(pswappext);
ReleaseStr(pwzData);
return hr;
}
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:73,代码来源:scawebappext.cpp
示例10: CpiApplicationRolesRead
HRESULT CpiApplicationRolesRead(
CPI_APPLICATION_LIST* pAppList,
CPI_APPLICATION_ROLE_LIST* pAppRoleList
)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
PMSIHANDLE hView, hRec;
CPI_APPLICATION_ROLE* pItm = NULL;
LPWSTR pwzData = NULL;
BOOL fMatchingArchitecture = FALSE;
// loop through all application roles
hr = WcaOpenExecuteView(vcsApplicationRoleQuery, &hView);
ExitOnFailure(hr, "Failed to execute view on ComPlusApplicationRole table");
while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
{
// get component
hr = WcaGetRecordString(hRec, arqComponent, &pwzData);
ExitOnFailure(hr, "Failed to get component");
// check if the component is our processor architecture
if (pwzData && *pwzData)
{
hr = CpiVerifyComponentArchitecure(pwzData, &fMatchingArchitecture);
ExitOnFailure(hr, "Failed to get component architecture.");
if (!fMatchingArchitecture)
{
continue; // not the same architecture, ignore
}
}
// create entry
pItm = (CPI_APPLICATION_ROLE*)::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CPI_APPLICATION_ROLE));
if (!pItm)
ExitFunction1(hr = E_OUTOFMEMORY);
// get component install state
if (pwzData && *pwzData)
{
pItm->fHasComponent = TRUE;
er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzData, &pItm->isInstalled, &pItm->isAction);
ExitOnFailure(hr = HRESULT_FROM_WIN32(er), "Failed to get component state");
}
// get key
hr = WcaGetRecordString(hRec, arqApplicationRole, &pwzData);
ExitOnFailure(hr, "Failed to get key");
StringCchCopyW(pItm->wzKey, countof(pItm->wzKey), pwzData);
// get application
hr = WcaGetRecordString(hRec, arqApplication, &pwzData);
ExitOnFailure(hr, "Failed to get application");
hr = CpiApplicationFindByKey(pAppList, pwzData, &pItm->pApplication);
if (S_FALSE == hr)
hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
ExitOnFailure1(hr, "Failed to find application, key: %S", pwzData);
// get name
hr = WcaGetRecordFormattedString(hRec, arqName, &pwzData);
ExitOnFailure(hr, "Failed to get name");
StringCchCopyW(pItm->wzName, countof(pItm->wzName), pwzData);
// get properties
if (CpiTableExists(cptComPlusApplicationRoleProperty))
{
hr = CpiPropertiesRead(vcsApplicationRolePropertyQuery, pItm->wzKey, pdlApplicationRoleProperties, &pItm->pProperties, &pItm->iPropertyCount);
ExitOnFailure(hr, "Failed to get properties");
}
// set references & increment counters
if (pItm->fHasComponent)
{
if (WcaIsInstalling(pItm->isInstalled, pItm->isAction))
{
CpiApplicationAddReferenceInstall(pItm->pApplication);
pAppRoleList->iInstallCount++;
}
if (WcaIsUninstalling(pItm->isInstalled, pItm->isAction))
{
CpiApplicationAddReferenceUninstall(pItm->pApplication);
pAppRoleList->iUninstallCount++;
}
}
// add entry
if (pAppRoleList->pFirst)
pItm->pNext = pAppRoleList->pFirst;
pAppRoleList->pFirst = pItm;
pItm = NULL;
}
if (E_NOMOREITEMS == hr)
hr = S_OK;
//.........这里部分代码省略.........
开发者ID:BMurri,项目名称:wix3,代码行数:101,代码来源:cpapprolesched.cpp
示例11: CreateShare
/********************************************************************
CreateShare - create the file share on this computer
********************************************************************/
HRESULT CreateShare(SCA_SMBP* pssp)
{
if (!pssp || !(pssp->wzKey))
return E_INVALIDARG;
HRESULT hr = S_OK;
PACL pACL = NULL;
SHARE_INFO_502 si;
NET_API_STATUS s;
DWORD dwParamErr = 0;
BOOL fShareExists = SUCCEEDED(DoesShareExist(pssp->wzKey));
PSECURITY_DESCRIPTOR pSD = static_cast<PSECURITY_DESCRIPTOR>(MemAlloc(SECURITY_DESCRIPTOR_MIN_LENGTH, TRUE));
ExitOnNull(pSD, hr, E_OUTOFMEMORY, "Failed to allocate memory for security descriptor");
#pragma prefast(push)
#pragma prefast(disable:25029)
if (!::InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION))
#pragma prefast(pop)
{
ExitOnLastError(hr, "failed to initialize security descriptor");
}
hr = AllocateAcl(pssp, &pACL);
ExitOnFailure(hr, "Failed to allocate ACL for fileshare");
if (NULL == pACL)
{
WcaLog(LOGMSG_VERBOSE, "Ignoring NULL DACL.");
}
#pragma prefast(push)
#pragma prefast(disable:25028) // We only call this when pACL isn't NULL, so this call is safe according to the docs
// add the ACL to the security descriptor.
else if (!::SetSecurityDescriptorDacl(pSD, TRUE, pACL, FALSE))
{
ExitOnLastError(hr, "Failed to set security descriptor");
}
#pragma prefast(pop)
// all that is left is to create the share
FillShareInfo(&si, pssp, pSD);
// Fail if the directory doesn't exist
if (!DirExists(pssp->wzDirectory, NULL))
ExitOnFailure1(hr = HRESULT_FROM_WIN32(ERROR_OBJECT_NOT_FOUND), "Can't create a file share on directory that doesn't exist: %ls.", pssp->wzDirectory);
WcaLog(LOGMSG_VERBOSE, "Creating file share on directory \'%ls\' named \'%ls\'.", pssp->wzDirectory, pssp->wzKey);
if (!fShareExists)
{
s = ::NetShareAdd(NULL, 502, (BYTE*) &si, &dwParamErr);
WcaLog(LOGMSG_VERBOSE, "Adding a new file share.");
}
else
{
// The share exists. Write our new permissions over the top.
s = ::NetShareSetInfo(NULL, pssp->wzKey, 502, (BYTE*) &si, &dwParamErr);
WcaLog(LOGMSG_VERBOSE, "Setting permissions on existing share.");
}
if (NERR_Success != s)
{
hr = E_FAIL;
if (!fShareExists && NERR_DuplicateShare == s)
WcaLog(LOGMSG_VERBOSE, "Duplicate error when existence check failed.");
// error codes listed above.
ExitOnFailure1(hr, "Failed to create/modify file share: Err: %d", s);
}
LExit:
if (pACL)
{
::LocalFree(pACL);
}
ReleaseMem(pSD);
return hr;
}
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:85,代码来源:scasmbexec.cpp
示例12: TrusteesInApplicationRolesRead
static HRESULT TrusteesInApplicationRolesRead(
LPCWSTR pwzQuery,
CPI_APPLICATION_ROLE_LIST* pAppRoleList,
CPI_USER_IN_APPLICATION_ROLE_LIST* pUsrInAppRoleList
)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
PMSIHANDLE hView, hRec;
CPI_USER_IN_APPLICATION_ROLE* pItm = NULL;
LPWSTR pwzData = NULL;
LPWSTR pwzDomain = NULL;
LPWSTR pwzName = NULL;
BOOL fMatchingArchitecture = FALSE;
// loop through all application roles
hr = WcaOpenExecuteView(pwzQuery, &hView);
ExitOnFailure(hr, "Failed to execute view on table");
while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
{
// get component
hr = WcaGetRecordString(hRec, tiarqComponent, &pwzData);
ExitOnFailure(hr, "Failed to get component");
// check if the component is our processor architecture
hr = CpiVerifyComponentArchitecure(pwzData, &fMatchingArchitecture);
ExitOnFailure(hr, "Failed to get component architecture.");
if (!fMatchingArchitecture)
{
continue; // not the same architecture, ignore
}
// create entry
pItm = (CPI_USER_IN_APPLICATION_ROLE*)::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CPI_USER_IN_APPLICATION_ROLE));
if (!pItm)
ExitFunction1(hr = E_OUTOFMEMORY);
// get component install state
er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzData, &pItm->isInstalled, &pItm->isAction);
ExitOnFailure(hr = HRESULT_FROM_WIN32(er), "Failed to get component state");
// get key
hr = WcaGetRecordString(hRec, tiarqUserInApplicationRole, &pwzData);
ExitOnFailure(hr, "Failed to get key");
StringCchCopyW(pItm->wzKey, countof(pItm->wzKey), pwzData);
// get application role
hr = WcaGetRecordString(hRec, tiarqApplicationRole, &pwzData);
ExitOnFailure(hr, "Failed to get application role");
hr = CpiApplicationRoleFindByKey(pAppRoleList, pwzData, &pItm->pApplicationRole);
if (S_FALSE == hr)
hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
ExitOnFailure1(hr, "Failed to find application role, key: %S", pwzData);
// get user domain
hr = WcaGetRecordFormattedString(hRec, tiarqDomain, &pwzDomain);
ExitOnFailure(hr, "Failed to get domain");
// get user name
hr = WcaGetRecordFormattedString(hRec, tiarqName, &pwzName);
ExitOnFailure(hr, "Failed to get name");
// build account name
hr = CpiBuildAccountName(pwzDomain, pwzName, &pItm->pwzAccount);
ExitOnFailure(hr, "Failed to build account name");
// set references & increment counters
if (WcaIsInstalling(pItm->isInstalled, pItm->isAction))
{
CpiApplicationRoleAddReferenceInstall(pItm->pApplicationRole);
pUsrInAppRoleList->iInstallCount++;
}
if (WcaIsUninstalling(pItm->isInstalled, pItm->isAction))
{
CpiApplicationRoleAddReferenceUninstall(pItm->pApplicationRole);
pUsrInAppRoleList->iUninstallCount++;
}
// add entry
if (pUsrInAppRoleList->pFirst)
pItm->pNext = pUsrInAppRoleList->pFirst;
pUsrInAppRoleList->pFirst = pItm;
pItm = NULL;
}
if (E_NOMOREITEMS == hr)
hr = S_OK;
LExit:
// clean up
if (pItm)
FreeUserInApplicationRole(pItm);
ReleaseStr(pwzData);
ReleaseStr(pwzDomain);
//.........这里部分代码省略.........
开发者ID:BMurri,项目名称:wix3,代码行数:101,代码来源:cpapprolesched.cpp
示例13: CpiApplicationRolesVerifyInstall
HRESULT CpiApplicationRolesVerifyInstall(
CPI_APPLICATION_ROLE_LIST* pList
)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
ICatalogObject* piRoleObj = NULL;
for (CPI_APPLICATION_ROLE* pItm = pList->pFirst; pItm; pItm = pItm->pNext)
{
// referenced locaters or roles that are being installed
if (!pItm->fReferencedForInstall && !(pItm->fHasComponent && WcaIsInstalling(pItm->isInstalled, pItm->isAction)))
continue;
// if the role is referensed and is not a locater, it must be installed
if (pItm->fReferencedForInstall && pItm->fHasComponent && !CpiWillBeInstalled(pItm->isInstalled, pItm->isAction))
MessageExitOnFailure1(hr = E_FAIL, msierrComPlusApplicationRoleDependency, "An application role is used by another entity being installed, but is not installed itself, key: %S", pItm->wzKey);
// role is a locater
if (!pItm->fHasComponent)
{
// get collection object for role
hr = FindObjectForApplicationRole(pItm, &piRoleObj);
ExitOnFailure(hr, "Failed to find collection object for role");
// if the role was not found
if (S_FALSE == hr)
MessageExitOnFailure1(hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND), msierrComPlusApplicationRoleNotFound, "An application role required by this installation was not found, key: %S", pItm->wzKey);
}
// role is supposed to be created
else if (!CpiIsInstalled(pItm->isInstalled))
{
do {
// find roles with conflicting name or id
hr = FindObjectForApplicationRole(pItm, NULL);
|
请发表评论