@@ -797,6 +797,17 @@ public async Task StopImportAsync() {
797797 string keyDeleted = null ;
798798 string keyName = null ;
799799 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+ }
800811
801812 RegistryView registryView = RegistryView . Registry32 ;
802813
@@ -836,7 +847,7 @@ public async Task StopImportAsync() {
836847 break ;
837848 case TYPE . VALUE :
838849 try {
839- value = AddVariablesToCanonicalizedValue ( CanonicalizeValue ( GetValueInRegistryView ( keyName , registryBackupElement . ValueName , registryView ) , RemoveTrailingSlash ( Application . StartupPath ) + " \\ " + Name ) ) ;
850+ value = AddVariablesToLengthenedValue ( LengthenValue ( GetValueInRegistryView ( keyName , registryBackupElement . ValueName , registryView ) , fullPath ) ) ;
840851 } catch ( ArgumentException ) {
841852 // value doesn't exist
842853 value = null ;
@@ -899,7 +910,7 @@ public async Task StopImportAsync() {
899910 break ;
900911 case TYPE . VALUE :
901912 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 ) ;
903914 } catch ( InvalidOperationException ) {
904915 // value marked for deletion
905916 Deactivate ( ) ;
@@ -999,7 +1010,7 @@ public async Task StopImportAsync() {
9991010 if ( value == null ) {
10001011 clear = true ;
10011012 } else {
1002- if ( value . ToString ( ) != RemoveVariablesFromCanonicalizedValue ( registryBackupElement . Value ) . ToString ( ) ) {
1013+ if ( value . ToString ( ) != RemoveVariablesFromLengthenedValue ( registryBackupElement . Value ) . ToString ( ) ) {
10031014 clear = true ;
10041015 }
10051016 }
@@ -1042,7 +1053,7 @@ public async Task StopImportAsync() {
10421053 if ( String . IsNullOrEmpty ( activeRegistryBackupElement . _Deleted ) ) {
10431054 try {
10441055 // 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 ) ;
10461057 } catch ( InvalidOperationException ) {
10471058 // value doesn't exist and can't be created
10481059 throw new RegistryBackupFailedException ( ) ;
@@ -1125,6 +1136,14 @@ private void ModificationAdded(RegistryTraceData registryTraceData) {
11251136
11261137 ulong safeKeyHandle = registryTraceData . KeyHandle & 0x00000000FFFFFFFF ;
11271138 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 ) { }
11281147
11291148 RegistryView registryView = RegistryView . Registry32 ;
11301149
@@ -1138,9 +1157,9 @@ private void ModificationAdded(RegistryTraceData registryTraceData) {
11381157
11391158 registryBackupElement . ValueKind = GetValueKindInRegistryView ( registryBackupElement . KeyName , registryBackupElement . ValueName , registryView ) ;
11401159 value = null ;
1141-
1160+
11421161 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 ) ) ;
11441163 } catch ( ArgumentException ) {
11451164 // value doesn't exist
11461165 value = null ;
@@ -1180,7 +1199,7 @@ private void ModificationAdded(RegistryTraceData registryTraceData) {
11801199 value = null ;
11811200
11821201 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 ) ) ;
11841203 } catch ( ArgumentException ) {
11851204 } catch ( SecurityException ) {
11861205 // 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) {
13261345 KeyValuePair < DateTime , RegistryBackupElement > queuedModification ;
13271346 RegistryBackupElement registryBackupElement ;
13281347 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 ) { }
13291356
13301357 RegistryView registryView = RegistryView . Registry32 ;
13311358
@@ -1348,7 +1375,7 @@ private void KCBStopped(RegistryTraceData registryTraceData) {
13481375
13491376 // value
13501377 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 ) ) ;
13521379 } catch ( ArgumentException ) {
13531380 // value doesn't exist
13541381 value = null ;
0 commit comments