Skip to content

Commit 70fe725

Browse files
committed
fix hang if control was already installed and had an expanded registry value
1 parent 5752fd2 commit 70fe725

1 file changed

Lines changed: 96 additions & 96 deletions

File tree

FlashpointSecurePlayer/RegistryStates.cs

Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,109 +1361,109 @@ public void Deactivate(MODIFICATIONS_REVERT_METHOD modificationsRevertMethod) {
13611361
TaskRequiresElevationException taskRequiresElevationException = null;
13621362
Exception exception = null;
13631363

1364-
while (activeModificationsElement.RegistryStates.Count > 0) {
1364+
for (int i = 0; i < activeModificationsElement.RegistryStates.Count; i++) {
13651365
try {
1366-
activeRegistryStateElement = activeModificationsElement.RegistryStates.Get(0) as RegistryStateElement;
1366+
activeRegistryStateElement = activeModificationsElement.RegistryStates.Get(i) as RegistryStateElement;
13671367

13681368
// how can it be deleted already?? just paranoia
1369-
if (activeRegistryStateElement != null) {
1370-
registryStateElement = modificationsElement.RegistryStates.Get(activeRegistryStateElement.Name) as RegistryStateElement;
1369+
if (activeRegistryStateElement == null) {
1370+
throw new ConfigurationErrorsException("The Active Modifications Element is null.");
1371+
}
13711372

1372-
if (registryStateElement != null) {
1373-
switch (activeRegistryStateElement.Type) {
1374-
case TYPE.KEY:
1375-
if (!String.IsNullOrEmpty(activeRegistryStateElement._Deleted)
1376-
|| modificationsRevertMethod == MODIFICATIONS_REVERT_METHOD.DELETE_ALL) {
1377-
try {
1378-
// key didn't exist before
1379-
DeleteKeyInRegistryView(
1380-
GetUserKeyValueName(
1381-
activeRegistryStateElement._Deleted,
1382-
activeCurrentUser,
1383-
activeAdministrator
1384-
),
1385-
1386-
registryView
1387-
);
1388-
} catch (SecurityException ex) {
1389-
// key exists and we can't modify it
1390-
LogExceptionToLauncher(ex);
1391-
throw new TaskRequiresElevationException("Deleting the key \"" + activeRegistryStateElement._Deleted + "\" requires elevation.");
1392-
} catch (UnauthorizedAccessException ex) {
1393-
// key exists and we can't modify it
1394-
LogExceptionToLauncher(ex);
1395-
throw new TaskRequiresElevationException("Deleting the key \"" + activeRegistryStateElement._Deleted + "\" requires elevation.");
1396-
} catch {
1397-
// key doesn't exist
1398-
}
1399-
}
1400-
break;
1401-
case TYPE.VALUE:
1402-
if (String.IsNullOrEmpty(activeRegistryStateElement._Deleted)
1403-
&& modificationsRevertMethod != MODIFICATIONS_REVERT_METHOD.DELETE_ALL) {
1404-
string keyName = GetUserKeyValueName(activeRegistryStateElement.KeyName, activeCurrentUser, activeAdministrator);
1405-
1406-
try {
1407-
// value was different before
1408-
SetValueInRegistryView(
1409-
keyName,
1410-
activeRegistryStateElement.ValueName,
1411-
activeRegistryStateElement.Value,
1412-
activeRegistryStateElement.ValueKind.GetValueOrDefault(),
1413-
registryView
1414-
);
1415-
} catch (SecurityException ex) {
1416-
// value exists and we can't modify it
1417-
LogExceptionToLauncher(ex);
1418-
throw new TaskRequiresElevationException("Setting the value \"" + activeRegistryStateElement.ValueName + "\" in key \"" + keyName + "\" requires elevation.");
1419-
} catch (UnauthorizedAccessException ex) {
1420-
// value exists and we can't modify it
1421-
LogExceptionToLauncher(ex);
1422-
throw new TaskRequiresElevationException("Setting the value \"" + activeRegistryStateElement.ValueName + "\" in key \"" + keyName + "\" requires elevation.");
1423-
} catch (FormatException ex) {
1424-
// value must be Base64
1425-
LogExceptionToLauncher(ex);
1426-
throw new InvalidRegistryStateException("The value \"" + registryStateElement.ValueName + "\" in key \"" + keyName + "\" must be Base64.");
1427-
} catch (InvalidOperationException ex) {
1428-
// value marked for deletion
1429-
LogExceptionToLauncher(ex);
1430-
throw new InvalidRegistryStateException("The value \"" + registryStateElement.ValueName + "\" in key \"" + keyName + "\" is marked for deletion.");
1431-
} catch (Exception ex) {
1432-
// value doesn't exist and can't be created
1433-
LogExceptionToLauncher(ex);
1434-
throw new InvalidRegistryStateException("The value \"" + activeRegistryStateElement.ValueName + "\" in key \"" + keyName + "\" could not be set.");
1435-
}
1436-
} else {
1437-
try {
1438-
// value didn't exist before
1439-
DeleteValueInRegistryView(
1440-
GetUserKeyValueName(
1441-
activeRegistryStateElement.KeyName,
1442-
activeCurrentUser,
1443-
activeAdministrator
1444-
),
1445-
1446-
activeRegistryStateElement.ValueName,
1447-
registryView
1448-
);
1449-
} catch (SecurityException ex) {
1450-
// value exists and we can't modify it
1451-
LogExceptionToLauncher(ex);
1452-
throw new TaskRequiresElevationException("Deleting the value \"" + activeRegistryStateElement.ValueName + "\" requires elevation.");
1453-
} catch (UnauthorizedAccessException ex) {
1454-
// value exists and we can't modify it
1455-
LogExceptionToLauncher(ex);
1456-
throw new TaskRequiresElevationException("Deleting the value \"" + activeRegistryStateElement.ValueName + "\" requires elevation.");
1457-
} catch {
1458-
// value doesn't exist
1459-
}
1460-
}
1461-
break;
1373+
switch (activeRegistryStateElement.Type) {
1374+
case TYPE.KEY:
1375+
if (!String.IsNullOrEmpty(activeRegistryStateElement._Deleted)
1376+
|| modificationsRevertMethod == MODIFICATIONS_REVERT_METHOD.DELETE_ALL) {
1377+
try {
1378+
// key didn't exist before
1379+
DeleteKeyInRegistryView(
1380+
GetUserKeyValueName(
1381+
activeRegistryStateElement._Deleted,
1382+
activeCurrentUser,
1383+
activeAdministrator
1384+
),
1385+
1386+
registryView
1387+
);
1388+
} catch (SecurityException ex) {
1389+
// key exists and we can't modify it
1390+
LogExceptionToLauncher(ex);
1391+
throw new TaskRequiresElevationException("Deleting the key \"" + activeRegistryStateElement._Deleted + "\" requires elevation.");
1392+
} catch (UnauthorizedAccessException ex) {
1393+
// key exists and we can't modify it
1394+
LogExceptionToLauncher(ex);
1395+
throw new TaskRequiresElevationException("Deleting the key \"" + activeRegistryStateElement._Deleted + "\" requires elevation.");
1396+
} catch {
1397+
// key doesn't exist
1398+
}
1399+
}
1400+
break;
1401+
case TYPE.VALUE:
1402+
if (String.IsNullOrEmpty(activeRegistryStateElement._Deleted)
1403+
&& activeRegistryStateElement.Value != null // in case ValueName is also empty
1404+
&& modificationsRevertMethod != MODIFICATIONS_REVERT_METHOD.DELETE_ALL) {
1405+
string keyName = GetUserKeyValueName(activeRegistryStateElement.KeyName, activeCurrentUser, activeAdministrator);
1406+
1407+
try {
1408+
// value was different before
1409+
SetValueInRegistryView(
1410+
keyName,
1411+
activeRegistryStateElement.ValueName,
1412+
activeRegistryStateElement.Value,
1413+
activeRegistryStateElement.ValueKind.GetValueOrDefault(),
1414+
registryView
1415+
);
1416+
} catch (SecurityException ex) {
1417+
// value exists and we can't modify it
1418+
LogExceptionToLauncher(ex);
1419+
throw new TaskRequiresElevationException("Setting the value \"" + activeRegistryStateElement.ValueName + "\" in key \"" + keyName + "\" requires elevation.");
1420+
} catch (UnauthorizedAccessException ex) {
1421+
// value exists and we can't modify it
1422+
LogExceptionToLauncher(ex);
1423+
throw new TaskRequiresElevationException("Setting the value \"" + activeRegistryStateElement.ValueName + "\" in key \"" + keyName + "\" requires elevation.");
1424+
} catch (FormatException ex) {
1425+
// value must be Base64
1426+
LogExceptionToLauncher(ex);
1427+
throw new InvalidRegistryStateException("The value \"" + activeRegistryStateElement.ValueName + "\" in key \"" + keyName + "\" must be Base64.");
1428+
} catch (InvalidOperationException ex) {
1429+
// value marked for deletion
1430+
LogExceptionToLauncher(ex);
1431+
throw new InvalidRegistryStateException("The value \"" + activeRegistryStateElement.ValueName + "\" in key \"" + keyName + "\" is marked for deletion.");
1432+
} catch (Exception ex) {
1433+
// value doesn't exist and can't be created
1434+
LogExceptionToLauncher(ex);
1435+
throw new InvalidRegistryStateException("The value \"" + activeRegistryStateElement.ValueName + "\" in key \"" + keyName + "\" could not be set.");
1436+
}
1437+
} else {
1438+
try {
1439+
// value didn't exist before
1440+
DeleteValueInRegistryView(
1441+
GetUserKeyValueName(
1442+
activeRegistryStateElement.KeyName,
1443+
activeCurrentUser,
1444+
activeAdministrator
1445+
),
1446+
1447+
activeRegistryStateElement.ValueName,
1448+
registryView
1449+
);
1450+
} catch (SecurityException ex) {
1451+
// value exists and we can't modify it
1452+
LogExceptionToLauncher(ex);
1453+
throw new TaskRequiresElevationException("Deleting the value \"" + activeRegistryStateElement.ValueName + "\" requires elevation.");
1454+
} catch (UnauthorizedAccessException ex) {
1455+
// value exists and we can't modify it
1456+
LogExceptionToLauncher(ex);
1457+
throw new TaskRequiresElevationException("Deleting the value \"" + activeRegistryStateElement.ValueName + "\" requires elevation.");
1458+
} catch {
1459+
// value doesn't exist
14621460
}
1463-
1464-
activeModificationsElement.RegistryStates.RemoveAt(0);
14651461
}
1462+
break;
14661463
}
1464+
1465+
activeModificationsElement.RegistryStates.RemoveAt(i);
1466+
i--;
14671467
} catch (TaskRequiresElevationException ex) {
14681468
taskRequiresElevationException = ex;
14691469
} catch (Exception ex) {

0 commit comments

Comments
 (0)