@@ -797,6 +797,17 @@ public async Task StopImportAsync() {
797
797
string keyDeleted = null ;
798
798
string keyName = null ;
799
799
object value = null ;
800
+ string fullPath = null ;
801
+
802
+ try {
803
+ fullPath = Path . GetFullPath ( Name ) ;
804
+ } catch ( PathTooLongException ) {
805
+ throw new ArgumentException ( ) ;
806
+ } catch ( SecurityException ) {
807
+ throw new TaskRequiresElevationException ( ) ;
808
+ } catch ( NotSupportedException ) {
809
+ throw new ArgumentException ( ) ;
810
+ }
800
811
801
812
RegistryView registryView = RegistryView . Registry32 ;
802
813
@@ -836,7 +847,7 @@ public async Task StopImportAsync() {
836
847
break ;
837
848
case TYPE . VALUE :
838
849
try {
839
- value = AddVariablesToCanonicalizedValue ( CanonicalizeValue ( GetValueInRegistryView ( keyName , registryBackupElement . ValueName , registryView ) , RemoveTrailingSlash ( Application . StartupPath ) + " \\ " + Name ) ) ;
850
+ value = AddVariablesToLengthenedValue ( LengthenValue ( GetValueInRegistryView ( keyName , registryBackupElement . ValueName , registryView ) , fullPath ) ) ;
840
851
} catch ( ArgumentException ) {
841
852
// value doesn't exist
842
853
value = null ;
@@ -899,7 +910,7 @@ public async Task StopImportAsync() {
899
910
break ;
900
911
case TYPE . VALUE :
901
912
try {
902
- SetValueInRegistryView ( keyName , registryBackupElement . ValueName , RemoveVariablesFromCanonicalizedValue ( registryBackupElement . Value ) , registryBackupElement . ValueKind . GetValueOrDefault ( ) , registryView ) ;
913
+ SetValueInRegistryView ( keyName , registryBackupElement . ValueName , RemoveVariablesFromLengthenedValue ( registryBackupElement . Value ) , registryBackupElement . ValueKind . GetValueOrDefault ( ) , registryView ) ;
903
914
} catch ( InvalidOperationException ) {
904
915
// value marked for deletion
905
916
Deactivate ( ) ;
@@ -999,7 +1010,7 @@ public async Task StopImportAsync() {
999
1010
if ( value == null ) {
1000
1011
clear = true ;
1001
1012
} else {
1002
- if ( value . ToString ( ) != RemoveVariablesFromCanonicalizedValue ( registryBackupElement . Value ) . ToString ( ) ) {
1013
+ if ( value . ToString ( ) != RemoveVariablesFromLengthenedValue ( registryBackupElement . Value ) . ToString ( ) ) {
1003
1014
clear = true ;
1004
1015
}
1005
1016
}
@@ -1042,7 +1053,7 @@ public async Task StopImportAsync() {
1042
1053
if ( String . IsNullOrEmpty ( activeRegistryBackupElement . _Deleted ) ) {
1043
1054
try {
1044
1055
// value was different before
1045
- SetValueInRegistryView ( GetUserKeyValueName ( activeRegistryBackupElement . KeyName ) , activeRegistryBackupElement . ValueName , RemoveVariablesFromCanonicalizedValue ( activeRegistryBackupElement . Value ) , activeRegistryBackupElement . ValueKind . GetValueOrDefault ( ) , registryView ) ;
1056
+ SetValueInRegistryView ( GetUserKeyValueName ( activeRegistryBackupElement . KeyName ) , activeRegistryBackupElement . ValueName , RemoveVariablesFromLengthenedValue ( activeRegistryBackupElement . Value ) , activeRegistryBackupElement . ValueKind . GetValueOrDefault ( ) , registryView ) ;
1046
1057
} catch ( InvalidOperationException ) {
1047
1058
// value doesn't exist and can't be created
1048
1059
throw new RegistryBackupFailedException ( ) ;
@@ -1125,6 +1136,14 @@ private void ModificationAdded(RegistryTraceData registryTraceData) {
1125
1136
1126
1137
ulong safeKeyHandle = registryTraceData . KeyHandle & 0x00000000FFFFFFFF ;
1127
1138
object value = null ;
1139
+ string fullPath = null ;
1140
+
1141
+ try {
1142
+ fullPath = Path . GetFullPath ( Name ) ;
1143
+ }
1144
+ catch ( PathTooLongException ) { }
1145
+ catch ( SecurityException ) { }
1146
+ catch ( NotSupportedException ) { }
1128
1147
1129
1148
RegistryView registryView = RegistryView . Registry32 ;
1130
1149
@@ -1138,9 +1157,9 @@ private void ModificationAdded(RegistryTraceData registryTraceData) {
1138
1157
1139
1158
registryBackupElement . ValueKind = GetValueKindInRegistryView ( registryBackupElement . KeyName , registryBackupElement . ValueName , registryView ) ;
1140
1159
value = null ;
1141
-
1160
+
1142
1161
try {
1143
- value = AddVariablesToCanonicalizedValue ( CanonicalizeValue ( GetValueInRegistryView ( registryBackupElement . KeyName , registryBackupElement . ValueName , registryView ) , RemoveTrailingSlash ( Application . StartupPath ) + " \\ " + Name ) ) ;
1162
+ value = AddVariablesToLengthenedValue ( LengthenValue ( GetValueInRegistryView ( registryBackupElement . KeyName , registryBackupElement . ValueName , registryView ) , fullPath ) ) ;
1144
1163
} catch ( ArgumentException ) {
1145
1164
// value doesn't exist
1146
1165
value = null ;
@@ -1180,7 +1199,7 @@ private void ModificationAdded(RegistryTraceData registryTraceData) {
1180
1199
value = null ;
1181
1200
1182
1201
try {
1183
- value = AddVariablesToCanonicalizedValue ( CanonicalizeValue ( GetValueInRegistryView ( registryBackupElement . KeyName , registryBackupElement . ValueName , registryView ) , RemoveTrailingSlash ( Application . StartupPath ) + " \\ " + Name ) ) ;
1202
+ value = AddVariablesToLengthenedValue ( LengthenValue ( GetValueInRegistryView ( registryBackupElement . KeyName , registryBackupElement . ValueName , registryView ) , fullPath ) ) ;
1184
1203
} catch ( ArgumentException ) {
1185
1204
} catch ( SecurityException ) {
1186
1205
// we have permission to access the key at this point so this must not be important
@@ -1326,6 +1345,14 @@ private void KCBStopped(RegistryTraceData registryTraceData) {
1326
1345
KeyValuePair < DateTime , RegistryBackupElement > queuedModification ;
1327
1346
RegistryBackupElement registryBackupElement ;
1328
1347
object value = null ;
1348
+ string fullPath = null ;
1349
+
1350
+ try {
1351
+ fullPath = Path . GetFullPath ( Name ) ;
1352
+ }
1353
+ catch ( PathTooLongException ) { }
1354
+ catch ( SecurityException ) { }
1355
+ catch ( NotSupportedException ) { }
1329
1356
1330
1357
RegistryView registryView = RegistryView . Registry32 ;
1331
1358
@@ -1348,7 +1375,7 @@ private void KCBStopped(RegistryTraceData registryTraceData) {
1348
1375
1349
1376
// value
1350
1377
try {
1351
- value = AddVariablesToCanonicalizedValue ( CanonicalizeValue ( GetValueInRegistryView ( registryBackupElement . KeyName , registryBackupElement . ValueName , registryView ) , RemoveTrailingSlash ( Application . StartupPath ) + " \\ " + Name ) ) ;
1378
+ value = AddVariablesToLengthenedValue ( LengthenValue ( GetValueInRegistryView ( registryBackupElement . KeyName , registryBackupElement . ValueName , registryView ) , fullPath ) ) ;
1352
1379
} catch ( ArgumentException ) {
1353
1380
// value doesn't exist
1354
1381
value = null ;
0 commit comments