aboutsummaryrefslogtreecommitdiff
path: root/src/ext/ComPlus/ca/cppartexec.cpp
diff options
context:
space:
mode:
authorBevan Weiss <bevan.weiss@gmail.com>2024-07-28 00:12:25 +1000
committerRob Mensching <rob@firegiant.com>2024-12-26 08:26:26 -0800
commitee41358bb583619ef4fe6707958dc3c6c62cd13f (patch)
tree04d702b39cd37be9b6c66c897f6c774a7dd1c0a6 /src/ext/ComPlus/ca/cppartexec.cpp
parent85745284cd76858f8699190c53719607e0058712 (diff)
downloadwix-ee41358bb583619ef4fe6707958dc3c6c62cd13f.tar.gz
wix-ee41358bb583619ef4fe6707958dc3c6c62cd13f.tar.bz2
wix-ee41358bb583619ef4fe6707958dc3c6c62cd13f.zip
Fix up COM+ to be back in working order under Wix4+
Table names updated for Wix4 prefix. Custom action names similarly updated. Table names Wix4ComPlusUserInApplicationRole, Wix4ComPlusGroupInApplicationRole and Wix4ComPlusApplicationRoleProperty had to be shortened to fit within MSI 31 character table name limit. Migrated from fixed GUID for RegistrationHelper to use CLSIDFromProgID in an attempt to fix behaviour under .NET 4+ DLLs. Added setting of Partition enable if a Partition is configured in authoring, new Windows config has Partitions disabled by default, and they don't work at all under Windows workstation (non-server) versions. Added a new Runtime condition for `RequireWindowsServer` which will skip execution of Runtime test on workstation/desktop OSes, since COM+ Partitions only work correctly under Windows Server. Quite a lot of basic typos fixed also. Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>
Diffstat (limited to 'src/ext/ComPlus/ca/cppartexec.cpp')
-rw-r--r--src/ext/ComPlus/ca/cppartexec.cpp71
1 files changed, 69 insertions, 2 deletions
diff --git a/src/ext/ComPlus/ca/cppartexec.cpp b/src/ext/ComPlus/ca/cppartexec.cpp
index 673bdaf9..06aa16f4 100644
--- a/src/ext/ComPlus/ca/cppartexec.cpp
+++ b/src/ext/ComPlus/ca/cppartexec.cpp
@@ -34,6 +34,7 @@ static HRESULT ReadPartitionAttributes(
34static void FreePartitionAttributes( 34static void FreePartitionAttributes(
35 CPI_PARTITION_ATTRIBUTES* pAttrs 35 CPI_PARTITION_ATTRIBUTES* pAttrs
36 ); 36 );
37static HRESULT CpiEnsurePartitionsEnabled();
37static HRESULT CreatePartition( 38static HRESULT CreatePartition(
38 CPI_PARTITION_ATTRIBUTES* pAttrs 39 CPI_PARTITION_ATTRIBUTES* pAttrs
39 ); 40 );
@@ -71,7 +72,7 @@ HRESULT CpiConfigurePartitions(
71 hr = CpiActionStartMessage(ppwzData, FALSE); 72 hr = CpiActionStartMessage(ppwzData, FALSE);
72 ExitOnFailure(hr, "Failed to send action start message"); 73 ExitOnFailure(hr, "Failed to send action start message");
73 74
74 // ger partition count 75 // get partition count
75 int iCnt = 0; 76 int iCnt = 0;
76 hr = WcaReadIntegerFromCaData(ppwzData, &iCnt); 77 hr = WcaReadIntegerFromCaData(ppwzData, &iCnt);
77 ExitOnFailure(hr, "Failed to read count"); 78 ExitOnFailure(hr, "Failed to read count");
@@ -215,7 +216,7 @@ HRESULT CpiConfigurePartitionUsers(
215 hr = CpiActionStartMessage(ppwzData, FALSE); 216 hr = CpiActionStartMessage(ppwzData, FALSE);
216 ExitOnFailure(hr, "Failed to send action start message"); 217 ExitOnFailure(hr, "Failed to send action start message");
217 218
218 // ger partition count 219 // get partition count
219 int iCnt = 0; 220 int iCnt = 0;
220 hr = WcaReadIntegerFromCaData(ppwzData, &iCnt); 221 hr = WcaReadIntegerFromCaData(ppwzData, &iCnt);
221 ExitOnFailure(hr, "Failed to read count"); 222 ExitOnFailure(hr, "Failed to read count");
@@ -384,6 +385,69 @@ static void FreePartitionAttributes(
384 CpiFreePropertyList(pAttrs->pPropList); 385 CpiFreePropertyList(pAttrs->pPropList);
385} 386}
386 387
388static HRESULT CpiEnsurePartitionsEnabled()
389{
390 HRESULT hr = S_OK;
391
392 ICatalogCollection* piLocalComputerColl = NULL;
393 IDispatch* piDisp = NULL;
394 ICatalogObject* piLocalComputerObj = NULL;
395 VARIANT vtVal;
396 BSTR bsPartitionsEnabledName = ::SysAllocString(L"PartitionsEnabled");
397 long numChanges = 0;
398
399 ::VariantInit(&vtVal);
400
401 // get collection
402 hr = CpiExecGetCatalogCollection(L"LocalComputer", &piLocalComputerColl);
403 ExitOnFailure(hr, "Failed to get catalog collection");
404
405 // find object, there will be only one in the LocalComputer collection
406 hr = piLocalComputerColl->get_Item(0, &piDisp);
407 ExitOnFailure(hr, "Failed to get object from collection");
408
409 hr = piDisp->QueryInterface(IID_ICatalogObject, (void**)&piLocalComputerObj);
410 ExitOnFailure(hr, "Failed to get IID_ICatalogObject interface");
411
412 // and then we get the value of the PartitionsEnabled property
413 hr = piLocalComputerObj->get_Value(bsPartitionsEnabledName, &vtVal);
414 if (!vtVal.boolVal)
415 {
416 vtVal.boolVal = true;
417 hr = piLocalComputerObj->put_Value(bsPartitionsEnabledName, vtVal);
418 ExitOnFailure(hr, "Failed to put value to Enable COM+ PartitionsEnabled property");
419 hr = piLocalComputerColl->SaveChanges(&numChanges);
420 ExitOnFailure(hr, "Failed to save PartitionsEnabled property");
421
422 // we'll read back the hopefully updated values of the PartitionsEnabled property
423 // if it's still False, then we're on a Windows Desktop that doesn't allow Partitions
424 // (as of Windows Server2003 Microsoft limited Partitions to only ServerOS platforms)
425 hr = piLocalComputerObj->get_Value(bsPartitionsEnabledName, &vtVal);
426 ExitOnFailure(hr, "Failed to read PartitionsEnabled property");
427 }
428
429 if (vtVal.boolVal)
430 {
431 // everything went well, we have the Partitioning available
432 hr = S_OK;
433 }
434 else
435 {
436 // we're on a Desktop OS, or couldn't otherwise enable partitioning
437 WcaLog(LOGMSG_STANDARD, "Failed to Enable COM+ PartitionEnabled property. This suggests Partitioning was attempted on a Desktop OS, which is not supported");
438 hr = S_FALSE;
439 }
440
441LExit:
442 // clean up
443 ReleaseObject(piLocalComputerColl);
444 ReleaseObject(piLocalComputerObj);
445 ReleaseBSTR(bsPartitionsEnabledName);
446 ::VariantClear(&vtVal);
447
448 return hr;
449}
450
387static HRESULT CreatePartition( 451static HRESULT CreatePartition(
388 CPI_PARTITION_ATTRIBUTES* pAttrs 452 CPI_PARTITION_ATTRIBUTES* pAttrs
389 ) 453 )
@@ -408,6 +472,9 @@ static HRESULT CreatePartition(
408 472
409 if (S_FALSE == hr) 473 if (S_FALSE == hr)
410 { 474 {
475 hr = CpiEnsurePartitionsEnabled();
476 ExitOnFailure(hr, "Failed to enable partitions");
477
411 // create partition 478 // create partition
412 hr = CpiAddCollectionObject(piPartColl, &piPartObj); 479 hr = CpiAddCollectionObject(piPartColl, &piPartObj);
413 ExitOnFailure(hr, "Failed to add partition to collection"); 480 ExitOnFailure(hr, "Failed to add partition to collection");