internal static void Init() { RegistryItem thisItem = RegistryManager.RootItem.AddDirectoryChild("Camera"); thisItem.AddChild(new RegistryNumber("Speed", thisItem, CameraSpeed)); thisItem.AddChild(new RegistryMethod("SetSpeed", thisItem, new RegistryMethod.InvokeMethod(SetSpeed))); }
public async Task SaveSettingAsync(SaveAccountSettingRequestDTO dto) { var mapper = new SettingMapper(); var registryItemKey = $"{mapper.UserSettingString(dto.UserName)}{dto.Key}"; var registryItemValue = dto.Value.ToString(); var existingRegistryItem = await _context.Registry.SingleOrDefaultAsync(x => x.Key == registryItemKey); if (existingRegistryItem != null) { existingRegistryItem.Value = registryItemValue; } else { var newRegistryItem = new RegistryItem { Id = Guid.NewGuid(), Key = registryItemKey, Value = registryItemValue }; _context.Registry.Add(newRegistryItem); } }
internal void InternalSub <TEventType>(IHandle <TEventType> handler, bool handleOnce) { Args.IsNotNull(() => handler); Throw.Exception <NullReferenceException>(() => this.m_eventRegistry == null, "EventAggregator registry is null. Please re-initialize aggregator"); var type = this.GetEventType <TEventType>(); if (!this.m_eventRegistry.ContainsKey(type)) { var item = new RegistryItem <TEventType, EventScope>(handler, (handler as EventScope), handleOnce); this.m_eventRegistry.Add(type, new List <IHandle>() { item }); } else { var handlers = this.m_eventRegistry[type].Select(x => x as RegistryItem <TEventType, EventScope>).Select(x => x.Handler); Vars.HandleNull(handlers, this.HandleNull); Throw.Exception <InvalidOperationException>(() => handlers.Contains(handler)); // Note: if we made it this far, the event type is registered correctly var item = new RegistryItem <TEventType, EventScope>(handler, (handler as EventScope), handleOnce); Vars.HandleNull(item, this.HandleNull); this.m_eventRegistry[type].Add(item); } }
public static void CreateVector(RegistryItem parent, string name, float x, float y) { RegistryItem vector = parent.AddDirectoryChild(name); vector.AddChild(new RegistryNumber("X", vector, x)); vector.AddChild(new RegistryNumber("Y", vector, y)); }
/// <summary>Matches Binary data from the key/value.</summary> /// <param name="methodResult">The data from the match.</param> /// <param name="valueName">The name of the value.</param> /// <param name="valueData">The data for the value.</param> /// <returns><c>True</c> if it was a match, otherwise; <c>False</c>.</returns> static bool MatchBinary(ref RegistryItem methodResult, string valueName, string valueData) { if (Regex.IsMatch( valueData, @"^hex(\(0*3\))?:(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { // Put everything on one line valueData = PutOnOneLineAndTrim(valueData); // Remove hex: or hex(3): at the beginning valueData = Regex.Replace( valueData, @"^hex(\(0*3\))?:", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline); methodResult.ValueKind = RegistryValueKind.Binary; methodResult.Data = valueData; methodResult.KeyValue = valueName; // Return Partial Line return(true); } return(false); }
public GameWindow(int width, int height) { EngineGlobals.Init(); CameraManager.Init(); this.RendererItem = RegistryManager.RootItem.AddDirectoryChild("Renderer"); this.RendererItem.AddChild(new RegistryMethod("Exit", this.RendererItem, new RegistryMethod.InvokeMethod(Exit))); this.NWindow = new Tier2NativeWindow(width, height); }
/// <summary>Matches hex data from the key/value.</summary> /// <param name="methodResult">The data from the match.</param> /// <param name="valueName">The name of the value.</param> /// <param name="valueData">The data for the value.</param> /// <returns><c>True</c> if it was a match, otherwise; <c>False</c>.</returns> static bool MatchStringHex(ref RegistryItem methodResult, string valueName, string valueData) { if (Regex.IsMatch( valueData, @"^hex\(0*1\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { // Put everything on one line valueData = PutOnOneLineAndTrim(valueData); // Remove hex(1): at the beginning valueData = Regex.Replace( valueData, @"^hex\(0*1\):", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline); // Remove trailing 00,00s valueData = Regex.Replace( valueData, @",00,00$", string.Empty, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture); // Check for empty ValueData if (string.IsNullOrEmpty(valueData.Trim())) { methodResult.ValueKind = RegistryValueKind.String; methodResult.Data = valueData; methodResult.KeyValue = valueName; return(true); } // Get the string with UnicodeEncoding Create an array to hold the hex values var temporaryArray = new List <string>(valueData.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); // Treat as DBCS (Double byte characters) List <byte> byteArray = temporaryArray.ConvertAll(String2Byte); valueData = Encoding.Unicode.GetString(byteArray.ToArray()); // Apply Fixes valueData = ApplyFixes(valueData, true); // Look for CR + LF and append warning if found if (valueData.Contains("\r\n")) { valueData = valueData.Replace("\r\n", "_"); } methodResult.ValueKind = RegistryValueKind.String; methodResult.Data = valueData; methodResult.KeyValue = valueName; return(true); } return(false); }
public static RegistryItem CreateRegistryEntity(RegistryItem parent, string name, string filename, float xloc, float yloc) { RegistryItem entity = parent.AddDirectoryChild(name); CreateVector(entity, "Location", xloc, yloc); entity.AddChild(new RegistryMethod("Draw", entity, new RegistryMethod.InvokeMethod(DrawBasic))); entity.AddChild(new RegistryImage("Image", entity, ResourceManager.GetImage(filename))); return(entity); }
public static void SetString(string name, string value) { RegistryItem item = RegistryManager.GetItem(name); if (item is RegistryString) { item.SetValue(value); } }
public static void SetNumber(string name, float value) { RegistryItem item = RegistryManager.GetItem(name); if (item is RegistryNumber) { item.SetValue(value); } }
public static float GetNumber(string name) { RegistryItem search = RegistryManager.GetItem(name); if (search is RegistryNumber) { return((float)search.GetValue()); } return(0); }
public static string GetString(string name) { RegistryItem search = RegistryManager.GetItem(name); if (search is RegistryString) { return((string)search.GetValue()); } return(""); }
/// <summary>Adds a new <c>RegistryItem</c>.</summary> /// <param name="sender">The object that called the event.</param> /// <param name="e">The <c>System.Windows.RoutedEventArgs</c> instance containing the event data.</param> void NewRegistryItem(object sender, RoutedEventArgs e) { var registryItem = new RegistryItem { KeyValue = Properties.Resources.NewRegistryItem, Key = @"HKLM\Software\MyApp", Action = RegistryAction.Add, ValueKind = RegistryValueKind.String }; Core.UpdateInfo.RegistryItems.Add(registryItem); }
private void AddRegistryItemToContainer(RegistryItem item) { switch (item.Lifecycle) { case LifecycleType.Application: this.Container.RegisterType(item.FromType, item.ToType, new ContainerControlledLifetimeManager()); break; case LifecycleType.HttpContext: this.Container.RegisterType(item.FromType, item.ToType, new HttpContextLifetimeManager()); break; default: this.Container.RegisterType(item.FromType, item.ToType); break; } }
public async Task Ingest(RegistryItem newItem, Stream stream) { var item = _itemContext.GetItem(newItem); if (item is not null && !HasVersion(item, newItem.Version)) { throw new AlreadyExistsException(item); } if (item is null) { item = newItem; item.Id = Guid.NewGuid(); _itemContext.Add(item); } item.AddVersion(newItem.Version); Validate(item); var fileKey = item.FileId(newItem.Version.Version); if (fileKey is null) { return(request.CreateStringResponse(HttpStatusCode.InternalServerError, "There was an issue trying to create the new version.")); } bool hadContent = await _storageProvider.UploadZipAsync(fileKey.Value, stream, ObjectType.Module); if (hadContent) { _moduleContext.SaveChanges(); return(request.CreateResponse(HttpStatusCode.Created)); } else { return(request.CreateStringResponse(HttpStatusCode.BadRequest, "Uploaded file had zero bytes, and the module was not saved.")); } }
/// <summary>Common processing for normal binary types.</summary> /// <param name="hexType">Single char for hex type.</param> /// <param name="valueNameData">Value Name for generating INF format line.</param> /// <param name="valueData">ValueData to operate on.</param> /// <param name="flag">INF flag for this binary type.</param> /// <param name="methodResult">Instance to return result in.</param> /// <returns>Finished INFConversionResult instance.</returns> static RegistryItem ProcessBinaryType( char hexType, ref string valueNameData, ref string valueData, RegistryValueKind flag, ref RegistryItem methodResult) { // Put everything on one line valueData = PutOnOneLineAndTrim(valueData); // Remove hex: at the beginning valueData = Regex.Replace( valueData, @"^hex\(0*" + hexType + @"\):", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline); methodResult.ValueKind = flag; methodResult.KeyValue = valueNameData; // Return Partial Line methodResult.Data = valueData; return(methodResult); }
/// <summary>Matches Binary data from the key/value.</summary> /// <param name="methodResult">The data from the match.</param> /// <param name="valueName">The name of the value.</param> /// <param name="valueData">The data for the value.</param> /// <returns><c>True</c> if it was a match, otherwise; <c>False</c>.</returns> static bool MatchBinary(ref RegistryItem methodResult, string valueName, string valueData) { if (Regex.IsMatch( valueData, @"^hex(\(0*3\))?:(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { // Put everything on one line valueData = PutOnOneLineAndTrim(valueData); // Remove hex: or hex(3): at the beginning valueData = Regex.Replace( valueData, @"^hex(\(0*3\))?:", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline); methodResult.ValueKind = RegistryValueKind.Binary; methodResult.Data = valueData; methodResult.KeyValue = valueName; // Return Partial Line return true; } return false; }
public RegistryImage(string name, RegistryItem parent, ExposeImage img) : base(name, parent) { this.Img = img; }
public RegistryItem?GetItem(RegistryItem item) { var provider = (Provider)item; return(GetProvider(provider.Namespace, provider.Name)); }
protected abstract bool HasVersion(RegistryItem item, RegistryItemVersion version);
/// <summary>Common processing for normal binary types.</summary> /// <param name="hexType">Single char for hex type.</param> /// <param name="valueNameData">Value Name for generating INF format line.</param> /// <param name="valueData">ValueData to operate on.</param> /// <param name="flag">INF flag for this binary type.</param> /// <param name="methodResult">Instance to return result in.</param> /// <returns>Finished INFConversionResult instance.</returns> static RegistryItem ProcessBinaryType( char hexType, ref string valueNameData, ref string valueData, RegistryValueKind flag, ref RegistryItem methodResult) { // Put everything on one line valueData = PutOnOneLineAndTrim(valueData); // Remove hex: at the beginning valueData = Regex.Replace( valueData, @"^hex\(0*" + hexType + @"\):", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline); methodResult.ValueKind = flag; methodResult.KeyValue = valueNameData; // Return Partial Line methodResult.Data = valueData; return methodResult; }
protected abstract bool Validate(RegistryItem item);
/// <summary>Matches ExpandString from the key/value.</summary> /// <param name="methodResult">The data from the match.</param> /// <param name="valueName">The name of the value.</param> /// <param name="valueData">The data for the value.</param> /// <returns><c>True</c> if it was a match, otherwise; <c>False</c>.</returns> static bool MathExpandString(ref RegistryItem methodResult, string valueName, string valueData) { if (Regex.IsMatch( valueData, @"^hex\(0*2\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { // Put everything on one line valueData = PutOnOneLineAndTrim(valueData); // Remove hex(2): at the beginning valueData = Regex.Replace( valueData, @"^hex\(0*2\):", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline); // Remove trailing 00,00s (v5) or 00s (v4) valueData = Regex.Replace( valueData, @",00,00$", string.Empty, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture); // Check for empty ValueData if (string.IsNullOrEmpty(valueData.Trim())) { methodResult.ValueKind = RegistryValueKind.ExpandString; methodResult.Data = valueData; methodResult.KeyValue = valueName; return true; } // Get the string, with UnicodeEncoding if v5 else ASCIIEncoding if (regVersionSignature == 5) { // Create an array to hold the hex values var temporaryArray = new List<string>(valueData.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); // Treat as DBCS (Double byte characters) List<byte> byteArray = temporaryArray.ConvertAll(String2Byte); valueData = Encoding.Unicode.GetString(byteArray.ToArray()); } else { // Nuke all 00s to prevent conversion to null, if this line causes changes ValueData then its 99% // possible that the wrong REG signature is present in the REG file being processed. valueData = Regex.Replace(valueData, @"00,?", string.Empty); // Create an array to hold the hex values var temporaryArray = new List<string>(valueData.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); // Treat as SBCS (Single byte characters) List<byte> byteArray = temporaryArray.ConvertAll(String2ByteForAscii); valueData = Encoding.Default.GetString(byteArray.ToArray()); } // Apply Fixes valueData = ApplyFixes(valueData, true); // Set Flag // Return Partial Line methodResult.ValueKind = RegistryValueKind.ExpandString; methodResult.Data = valueData; methodResult.KeyValue = valueName; return true; } return false; }
/// <summary>Internal method for extracting the data part of the reg line.</summary> /// <param name="line">A line in the registry file.</param> /// <returns>Object containing AddReg or DelReg INF format partial lines for further processing.</returns> static RegistryItem ProcessRegLine(string line) { // Create new INFConversionResult to hold result of this method var methodResult = new RegistryItem(); // Return empty INFConversionResult instance if Line is empty if (string.IsNullOrEmpty(line)) { return(methodResult); } // ValueNameData string definition ValueData string definition Is ValueData string ? bool valueDataIsString = false; // Define Match object that will test all criteria Match criteriaMatch = RegexStringValueMatcher.Match(line); if (!criteriaMatch.Success) { criteriaMatch = RegexOtherValueMatcher.Match(line); } else { valueDataIsString = true; } if (!criteriaMatch.Success) { return(methodResult); } // Set the value name (blank if default, else value name) string valueName = criteriaMatch.Groups["Value"].Value; // Apply fixes to value name data regardless of value data valueName = ApplyFixes(valueName, false); // Set the value data (string or otherwise, this will be checked later) string valueData = criteriaMatch.Groups["Data"].Value; if (valueDataIsString) { // Apply fixes valueData = ApplyFixes(valueData, false); methodResult.Action = RegistryAction.Add; methodResult.Data = valueData; methodResult.KeyValue = valueName; methodResult.ValueKind = RegistryValueKind.String; return(methodResult); } // Fix ValueData - Remove SPACE / TAB / CR / LF from beginning and end valueData = valueData.Trim(); // If ValueData is equal to -, this means that this is a removal instruction and the line should be added to // the DelReg part of the INFConversionResult instance if (string.Compare(valueData, "-", StringComparison.CurrentCulture) == 0) { methodResult.Data = null; methodResult.Action = RegistryAction.DeleteValue; methodResult.KeyValue = valueName; return(methodResult); } // If ValueData is still empty, that means a normal string value with its value explicitly set to blank if (string.IsNullOrEmpty(valueData)) { methodResult.KeyValue = valueName; methodResult.Data = valueData; methodResult.ValueKind = RegistryValueKind.String; return(methodResult); } // Test for the aforementioned possibilities // Binary: [hex:] | [hex(3):] - No reverse of order needed if (MatchBinary(ref methodResult, valueName, valueData)) { return(methodResult); } // Dword: | [hex(4):]AABBCCDDEEFF (no reverse) | [hex(4):]FF,EE,DD,CC,BB,AA (reverse) if (MatchDWord(ref methodResult, valueName, valueData)) { return(methodResult); } // hex(2): | REG_EXPAND_SZ if (MathExpandString(ref methodResult, valueName, valueData)) { return(methodResult); } // hex(7): | REG_MULTI_SZ if (MatchMutiString(ref methodResult, valueName, valueData)) { return(methodResult); } // hex(1): | REG_SZ expressed in Hex notation if (MatchStringHex(ref methodResult, valueName, valueData)) { return(methodResult); } // hex(a): | REG_RESOURCE_REQUIRED if (Regex.IsMatch( valueData, @"^hex\(0*a\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { return(ProcessBinaryType('a', ref valueName, ref valueData, RegistryValueKind.None, ref methodResult)); } // hex(b): | REG_QWORD if (Regex.IsMatch( valueData, @"^hex\(0*b\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline)) { return(ProcessBinaryType('b', ref valueName, ref valueData, RegistryValueKind.QWord, ref methodResult)); } // hex(8): | REG_RESOURCE_LIST if (Regex.IsMatch( valueData, @"^hex\(0*8\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { return(ProcessBinaryType('8', ref valueName, ref valueData, RegistryValueKind.None, ref methodResult)); } // hex(9): | REG_FULL_RESOURCE_DESCRIPTORS if (Regex.IsMatch( valueData, @"^hex\(0*9\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { return(ProcessBinaryType('9', ref valueName, ref valueData, RegistryValueKind.None, ref methodResult)); } // hex(5): | REG_DWORD_BIG_ENDIAN if (Regex.IsMatch( valueData, @"^hex\(0*5\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { return(ProcessBinaryType('5', ref valueName, ref valueData, RegistryValueKind.DWord, ref methodResult)); } // hex(6): | REG_LINK if (Regex.IsMatch( valueData, @"^hex\(0*6\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { return(ProcessBinaryType('6', ref valueName, ref valueData, RegistryValueKind.None, ref methodResult)); } // hex(0): | REG_NONE return(Regex.IsMatch( valueData, @"^hex\(0*0\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline) ? ProcessBinaryType('0', ref valueName, ref valueData, RegistryValueKind.None, ref methodResult) : methodResult); // Fallback in case nothing matches }
public void Exit(RegistryItem parent) { this.NWindow.Stop(); }
/// <summary>Matches ExpandString from the key/value.</summary> /// <param name="methodResult">The data from the match.</param> /// <param name="valueName">The name of the value.</param> /// <param name="valueData">The data for the value.</param> /// <returns><c>True</c> if it was a match, otherwise; <c>False</c>.</returns> static bool MathExpandString(ref RegistryItem methodResult, string valueName, string valueData) { if (Regex.IsMatch( valueData, @"^hex\(0*2\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { // Put everything on one line valueData = PutOnOneLineAndTrim(valueData); // Remove hex(2): at the beginning valueData = Regex.Replace( valueData, @"^hex\(0*2\):", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline); // Remove trailing 00,00s (v5) or 00s (v4) valueData = Regex.Replace( valueData, @",00,00$", string.Empty, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture); // Check for empty ValueData if (string.IsNullOrEmpty(valueData.Trim())) { methodResult.ValueKind = RegistryValueKind.ExpandString; methodResult.Data = valueData; methodResult.KeyValue = valueName; return(true); } // Get the string, with UnicodeEncoding if v5 else ASCIIEncoding if (regVersionSignature == 5) { // Create an array to hold the hex values var temporaryArray = new List <string>(valueData.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); // Treat as DBCS (Double byte characters) List <byte> byteArray = temporaryArray.ConvertAll(String2Byte); valueData = Encoding.Unicode.GetString(byteArray.ToArray()); } else { // Nuke all 00s to prevent conversion to null, if this line causes changes ValueData then its 99% // possible that the wrong REG signature is present in the REG file being processed. valueData = Regex.Replace(valueData, @"00,?", string.Empty); // Create an array to hold the hex values var temporaryArray = new List <string>(valueData.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); // Treat as SBCS (Single byte characters) List <byte> byteArray = temporaryArray.ConvertAll(String2ByteForAscii); valueData = Encoding.Default.GetString(byteArray.ToArray()); } // Apply Fixes valueData = ApplyFixes(valueData, true); // Set Flag // Return Partial Line methodResult.ValueKind = RegistryValueKind.ExpandString; methodResult.Data = valueData; methodResult.KeyValue = valueName; return(true); } return(false); }
/// <summary>Matches DWord from the key/value.</summary> /// <param name="methodResult">The data from the match.</param> /// <param name="valueName">The name of the value.</param> /// <param name="valueData">The data for the value.</param> /// <returns><c>True</c> if it was a match, otherwise; <c>False</c>.</returns> static bool MatchDWord(ref RegistryItem methodResult, string valueName, string valueData) { if (Regex.IsMatch( valueData, @"^(dword:([0-9A-Fa-f]){1,8})|(hex\(0*4\):([0-9A-Fa-f]{1,2},?)+)", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline)) { // Remove dword: at the beginning valueData = Regex.Replace( valueData, @"^(dword|hex\(0*4\)):", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline); // Check for empty ValueData if (string.IsNullOrEmpty(valueData.Trim())) { methodResult.ValueKind = RegistryValueKind.DWord; methodResult.Data = valueData; methodResult.KeyValue = valueName; return true; } // In case of hex(4) notation, very little changes are needed - no reverse needed as in hex(4) they are // already revered and in the correct format for INF if (Regex.IsMatch(valueData, @"^([0-9A-Fa-f]{1,2},)+[0-9A-Fa-f]{1,2}$", RegexOptions.ExplicitCapture)) { valueData = valueData.TrimEnd(new[] { ',' }); } else { // Check if length is equal to 8, else pad with 0s to 8 if (valueData.Length < 8) { int numberOfZeroesNeeded = 8 - valueData.Length; for (int i = 0; i < numberOfZeroesNeeded; i++) { valueData = "0" + valueData; } } // Put a comma after each 2 digits var digitsSeparated = new StringBuilder(); MatchCollection splitThem = Regex.Matches( valueData, @"(([0-9]|[A-F]){2})", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.RightToLeft); digitsSeparated.Append(splitThem[0].Value + ","); digitsSeparated.Append(splitThem[1].Value + ","); digitsSeparated.Append(splitThem[2].Value + ","); digitsSeparated.Append(splitThem[3].Value); valueData = digitsSeparated.ToString(); } methodResult.ValueKind = RegistryValueKind.DWord; methodResult.Data = valueData; methodResult.KeyValue = valueName; return true; } return false; }
/// <summary>Matches MutiString from the key/value.</summary> /// <param name="methodResult">The data from the match.</param> /// <param name="valueName">The name of the value.</param> /// <param name="valueData">The data for the value.</param> /// <returns><c>True</c> if it was a match, otherwise; <c>False</c>.</returns> static bool MatchMutiString(ref RegistryItem methodResult, string valueName, string valueData) { if (Regex.IsMatch( valueData, @"^hex\(0*7\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { // Put everything on one line valueData = PutOnOneLineAndTrim(valueData); // Remove hex(7): at the beginning valueData = Regex.Replace( valueData, @"^hex\(0*7\):", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline); // Remove trailing 00,00s is now done by the RegEx below the following block // Check for empty ValueData if (string.IsNullOrEmpty(valueData.Trim())) { // Set Flag - Undocumented but used inside XP Setup's own files to specify REG_MULTI_SZ. The // documented method seems to be to use 0x10000 Return Partial Line methodResult.Data = valueName; methodResult.ValueKind = RegistryValueKind.MultiString; return true; } // Create a List<string> for holding the split parts var multiStringEntries = new List<string>(5); // Create a StringBuilder for holding the semi-processed string var valueDataBuilder = new StringBuilder(valueData.Length); // Convert the bytes back to the string using the new UnicodeEncoding method for v5 signature (DBCS) and // using the old method for v4 signature which uses SBCS. if (regVersionSignature == 5) { // RegEx match all pairs of bytes MatchCollection readInTwos = Regex.Matches( valueData, @"[a-zA-Z0-9]{2},[a-zA-Z0-9]{2}", RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); foreach (Match found in readInTwos) { if (string.Compare(found.Value, "00,00", StringComparison.CurrentCulture) != 0) { var z = new List<string>(found.Value.Split(new[] { ',' })); List<byte> y = z.ConvertAll(String2Byte); valueDataBuilder.Append(Encoding.Unicode.GetString(y.ToArray())); } else { valueDataBuilder.Append("\r\n"); } } } else { // Use old behavior - invalid and non-printable chars will convert to ? (63) Convert 00 to a // carriage return / line-feed (CR-LF): 0d 0a valueData = Regex.Replace( valueData, @"00", @"0d,0a", RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); // Convert to byte and back to characters using ASCIIEncoding var z = new List<string>(valueData.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); List<byte> y = z.ConvertAll(String2ByteForAsciiAllowCrlf); valueDataBuilder.Append(Encoding.Default.GetString(y.ToArray())); } multiStringEntries.AddRange( Regex.Split( valueDataBuilder.ToString(), @"\r\n", RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture)); // multiStringEntries.RemoveAt((multiStringEntries.Count-1)); multiStringEntries.RemoveAll(EmptyString); // Re init StringBuilder to clear valueDataBuilder = new StringBuilder(valueData.Length); for (int i = 0; i < multiStringEntries.Count; i++) { // Apply Fixes multiStringEntries[i] = ApplyFixes(multiStringEntries[i], true); // Append to StringBuilder if ((i + 1) == multiStringEntries.Count) { valueDataBuilder.Append("\"" + multiStringEntries[i] + "\""); } else { valueDataBuilder.Append("\"" + multiStringEntries[i] + "\","); } } // Set ValueData valueData = valueDataBuilder.ToString(); // Set Flag - REG_MULTI_SZ overwrite methodResult.ValueKind = RegistryValueKind.MultiString; methodResult.Data = valueData; methodResult.KeyValue = valueName; return true; } return false; }
public RegistryItem?GetItem(RegistryItem item) { var module = (Module)item; return(GetModule(module.Namespace, module.Name, module.Provider)); }
/// <summary>Internal method for extracting the data part of the reg line.</summary> /// <param name="line">A line in the registry file.</param> /// <returns>Object containing AddReg or DelReg INF format partial lines for further processing.</returns> static RegistryItem ProcessRegLine(string line) { // Create new INFConversionResult to hold result of this method var methodResult = new RegistryItem(); // Return empty INFConversionResult instance if Line is empty if (string.IsNullOrEmpty(line)) { return methodResult; } // ValueNameData string definition ValueData string definition Is ValueData string ? bool valueDataIsString = false; // Define Match object that will test all criteria Match criteriaMatch = RegexStringValueMatcher.Match(line); if (!criteriaMatch.Success) { criteriaMatch = RegexOtherValueMatcher.Match(line); } else { valueDataIsString = true; } if (!criteriaMatch.Success) { return methodResult; } // Set the value name (blank if default, else value name) string valueName = criteriaMatch.Groups["Value"].Value; // Apply fixes to value name data regardless of value data valueName = ApplyFixes(valueName, false); // Set the value data (string or otherwise, this will be checked later) string valueData = criteriaMatch.Groups["Data"].Value; if (valueDataIsString) { // Apply fixes valueData = ApplyFixes(valueData, false); methodResult.Action = RegistryAction.Add; methodResult.Data = valueData; methodResult.KeyValue = valueName; methodResult.ValueKind = RegistryValueKind.String; return methodResult; } // Fix ValueData - Remove SPACE / TAB / CR / LF from beginning and end valueData = valueData.Trim(); // If ValueData is equal to -, this means that this is a removal instruction and the line should be added to // the DelReg part of the INFConversionResult instance if (string.Compare(valueData, "-", StringComparison.CurrentCulture) == 0) { methodResult.Data = null; methodResult.Action = RegistryAction.DeleteValue; methodResult.KeyValue = valueName; return methodResult; } // If ValueData is still empty, that means a normal string value with its value explicitly set to blank if (string.IsNullOrEmpty(valueData)) { methodResult.KeyValue = valueName; methodResult.Data = valueData; methodResult.ValueKind = RegistryValueKind.String; return methodResult; } // Test for the aforementioned possibilities // Binary: [hex:] | [hex(3):] - No reverse of order needed if (MatchBinary(ref methodResult, valueName, valueData)) { return methodResult; } // Dword: | [hex(4):]AABBCCDDEEFF (no reverse) | [hex(4):]FF,EE,DD,CC,BB,AA (reverse) if (MatchDWord(ref methodResult, valueName, valueData)) { return methodResult; } // hex(2): | REG_EXPAND_SZ if (MathExpandString(ref methodResult, valueName, valueData)) { return methodResult; } // hex(7): | REG_MULTI_SZ if (MatchMutiString(ref methodResult, valueName, valueData)) { return methodResult; } // hex(1): | REG_SZ expressed in Hex notation if (MatchStringHex(ref methodResult, valueName, valueData)) { return methodResult; } // hex(a): | REG_RESOURCE_REQUIRED if (Regex.IsMatch( valueData, @"^hex\(0*a\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { return ProcessBinaryType('a', ref valueName, ref valueData, RegistryValueKind.None, ref methodResult); } // hex(b): | REG_QWORD if (Regex.IsMatch( valueData, @"^hex\(0*b\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline)) { return ProcessBinaryType('b', ref valueName, ref valueData, RegistryValueKind.QWord, ref methodResult); } // hex(8): | REG_RESOURCE_LIST if (Regex.IsMatch( valueData, @"^hex\(0*8\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { return ProcessBinaryType('8', ref valueName, ref valueData, RegistryValueKind.None, ref methodResult); } // hex(9): | REG_FULL_RESOURCE_DESCRIPTORS if (Regex.IsMatch( valueData, @"^hex\(0*9\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { return ProcessBinaryType('9', ref valueName, ref valueData, RegistryValueKind.None, ref methodResult); } // hex(5): | REG_DWORD_BIG_ENDIAN if (Regex.IsMatch( valueData, @"^hex\(0*5\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { return ProcessBinaryType('5', ref valueName, ref valueData, RegistryValueKind.DWord, ref methodResult); } // hex(6): | REG_LINK if (Regex.IsMatch( valueData, @"^hex\(0*6\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { return ProcessBinaryType('6', ref valueName, ref valueData, RegistryValueKind.None, ref methodResult); } // hex(0): | REG_NONE return Regex.IsMatch( valueData, @"^hex\(0*0\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline) ? ProcessBinaryType('0', ref valueName, ref valueData, RegistryValueKind.None, ref methodResult) : methodResult; // Fallback in case nothing matches }
/// <summary>Internal method for processing extracted REG format blocks. Real processing takes place here.</summary> /// <param name="regBlock">The reg block.</param> void ProcessRegBlock(string regBlock) { // Define variable for RootKey string infRootKey = "_unknown"; // Extract Root Key switch (RegexRootKey.Match(regBlock).Groups["RootKey"].Value.ToLower(CultureInfo.CurrentCulture)) { case @"hkey_local_machine": infRootKey = "HKLM"; break; case @"hkey_current_user": infRootKey = "HKCU"; break; case @"hkey_classes_root": infRootKey = "HKCR"; break; case @"hkey_users": infRootKey = "HKU"; break; case @"hklm": infRootKey = "HKLM"; break; case @"hkcu": infRootKey = "HKCU"; break; case @"hkcr": infRootKey = "HKCR"; break; case @"hku": infRootKey = "HKU"; break; } infRootKey = infRootKey + @"\"; // Drop line if no valid root key found (This will drop all comments too) if (infRootKey == "_unknown") { return; } // Extract SubKey string rawSubKeyName = RegexSubKey.Match(regBlock).Groups[@"Subkey"].Value; if (rawSubKeyName.Length == 0) { return; } // rawSubKeyName string infSubKeyValue = ApplyFixes(rawSubKeyName, true); // Check for removal of RegBlock - [-... if (Regex.IsMatch(regBlock, @"^\[-HK", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture)) { // Then return data to DelReg instead of AddReg property of INFConversionResult instance var regBlockResult = new RegistryItem { Key = infRootKey + infSubKeyValue, Action = RegistryAction.DeleteKey }; this.regItem.Add(regBlockResult); return; } // Put RegBlock header out of the way to process lines (Remove header) regBlock = Regex.Replace( regBlock, RegexSubKey + @"\r\n", string.Empty, RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase | RegexOptions.Multiline); // CleanUp RegBlock from extra carriage returns regBlock = regBlock.Trim(); // Check for empty RegBlock (will happen if sub key is empty) if (string.IsNullOrEmpty(regBlock)) { return; } // Filter bad regex Match badLinesMatches = Regex.Match(regBlock, @"\\\\n\r\r\n", RegexOptions.Singleline); if (badLinesMatches.Success) { regBlock = regBlock.Replace("\\\\n\r\r\n", @"\r\n "); } // Split block into appropriate lines by adding marker after each line regBlock = LineSplitter.Replace(regBlock, "$0" + SplitToken); // Do the actual splitting and cleanup var regLines = new List<string>(); regLines.AddRange( Regex.Split(regBlock, SplitToken + @"\s*", RegexOptions.Multiline | RegexOptions.ExplicitCapture)); // Internal check for splitter validity The last entry of the array MUST be empty, otherwise something // didn't match and that can never be a comment because we strip them in an earlier stage of processing. if (regLines[regLines.Count - 1].Length != 0) { return; } // Pass RegLines to method for figuring out the FLAGS, VALUENAME and VALUEDATA foreach (var regBlockResult in regLines.Select(ProcessRegLine)) { regBlockResult.Key = infRootKey + infSubKeyValue; if (regBlockResult.Data == null && regBlockResult.KeyValue == null) { continue; } this.regItem.Add(regBlockResult); } }
/// <summary>Internal method for processing extracted REG format blocks. Real processing takes place here.</summary> /// <param name="regBlock">The reg block.</param> void ProcessRegBlock(string regBlock) { // Define variable for RootKey string infRootKey = "_unknown"; // Extract Root Key switch (RegexRootKey.Match(regBlock).Groups["RootKey"].Value.ToLower(CultureInfo.CurrentCulture)) { case @"hkey_local_machine": infRootKey = "HKLM"; break; case @"hkey_current_user": infRootKey = "HKCU"; break; case @"hkey_classes_root": infRootKey = "HKCR"; break; case @"hkey_users": infRootKey = "HKU"; break; case @"hklm": infRootKey = "HKLM"; break; case @"hkcu": infRootKey = "HKCU"; break; case @"hkcr": infRootKey = "HKCR"; break; case @"hku": infRootKey = "HKU"; break; } infRootKey = infRootKey + @"\"; // Drop line if no valid root key found (This will drop all comments too) if (infRootKey == "_unknown") { return; } // Extract SubKey string rawSubKeyName = RegexSubKey.Match(regBlock).Groups[@"Subkey"].Value; if (rawSubKeyName.Length == 0) { return; } // rawSubKeyName string infSubKeyValue = ApplyFixes(rawSubKeyName, true); // Check for removal of RegBlock - [-... if (Regex.IsMatch(regBlock, @"^\[-HK", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture)) { // Then return data to DelReg instead of AddReg property of INFConversionResult instance var regBlockResult = new RegistryItem { Key = infRootKey + infSubKeyValue, Action = RegistryAction.DeleteKey }; this.regItem.Add(regBlockResult); return; } // Put RegBlock header out of the way to process lines (Remove header) regBlock = Regex.Replace( regBlock, RegexSubKey + @"\r\n", string.Empty, RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase | RegexOptions.Multiline); // CleanUp RegBlock from extra carriage returns regBlock = regBlock.Trim(); // Check for empty RegBlock (will happen if sub key is empty) if (string.IsNullOrEmpty(regBlock)) { return; } // Filter bad regex Match badLinesMatches = Regex.Match(regBlock, @"\\\\n\r\r\n", RegexOptions.Singleline); if (badLinesMatches.Success) { regBlock = regBlock.Replace("\\\\n\r\r\n", @"\r\n "); } // Split block into appropriate lines by adding marker after each line regBlock = LineSplitter.Replace(regBlock, "$0" + SplitToken); // Do the actual splitting and cleanup var regLines = new List <string>(); regLines.AddRange( Regex.Split(regBlock, SplitToken + @"\s*", RegexOptions.Multiline | RegexOptions.ExplicitCapture)); // Internal check for splitter validity The last entry of the array MUST be empty, otherwise something // didn't match and that can never be a comment because we strip them in an earlier stage of processing. if (regLines[regLines.Count - 1].Length != 0) { return; } // Pass RegLines to method for figuring out the FLAGS, VALUENAME and VALUEDATA foreach (var regBlockResult in regLines.Select(ProcessRegLine)) { regBlockResult.Key = infRootKey + infSubKeyValue; if (regBlockResult.Data == null && regBlockResult.KeyValue == null) { continue; } this.regItem.Add(regBlockResult); } }
internal static void DrawBasic(RegistryItem item) { RegistryItem loc = item.GetChild("Location"); Graphics.DrawImage(item.GetChild("Image").GetValue(), loc.GetChild("X").GetValue(), loc.GetChild("Y").GetValue()); }
/// <summary>Matches DWord from the key/value.</summary> /// <param name="methodResult">The data from the match.</param> /// <param name="valueName">The name of the value.</param> /// <param name="valueData">The data for the value.</param> /// <returns><c>True</c> if it was a match, otherwise; <c>False</c>.</returns> static bool MatchDWord(ref RegistryItem methodResult, string valueName, string valueData) { if (Regex.IsMatch( valueData, @"^(dword:([0-9A-Fa-f]){1,8})|(hex\(0*4\):([0-9A-Fa-f]{1,2},?)+)", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline)) { // Remove dword: at the beginning valueData = Regex.Replace( valueData, @"^(dword|hex\(0*4\)):", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline); // Check for empty ValueData if (string.IsNullOrEmpty(valueData.Trim())) { methodResult.ValueKind = RegistryValueKind.DWord; methodResult.Data = valueData; methodResult.KeyValue = valueName; return(true); } // In case of hex(4) notation, very little changes are needed - no reverse needed as in hex(4) they are // already revered and in the correct format for INF if (Regex.IsMatch(valueData, @"^([0-9A-Fa-f]{1,2},)+[0-9A-Fa-f]{1,2}$", RegexOptions.ExplicitCapture)) { valueData = valueData.TrimEnd(new[] { ',' }); } else { // Check if length is equal to 8, else pad with 0s to 8 if (valueData.Length < 8) { int numberOfZeroesNeeded = 8 - valueData.Length; for (int i = 0; i < numberOfZeroesNeeded; i++) { valueData = "0" + valueData; } } // Put a comma after each 2 digits var digitsSeparated = new StringBuilder(); MatchCollection splitThem = Regex.Matches( valueData, @"(([0-9]|[A-F]){2})", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.RightToLeft); digitsSeparated.Append(splitThem[0].Value + ","); digitsSeparated.Append(splitThem[1].Value + ","); digitsSeparated.Append(splitThem[2].Value + ","); digitsSeparated.Append(splitThem[3].Value); valueData = digitsSeparated.ToString(); } methodResult.ValueKind = RegistryValueKind.DWord; methodResult.Data = valueData; methodResult.KeyValue = valueName; return(true); } return(false); }
/// <summary>Matches hex data from the key/value.</summary> /// <param name="methodResult">The data from the match.</param> /// <param name="valueName">The name of the value.</param> /// <param name="valueData">The data for the value.</param> /// <returns><c>True</c> if it was a match, otherwise; <c>False</c>.</returns> static bool MatchStringHex(ref RegistryItem methodResult, string valueName, string valueData) { if (Regex.IsMatch( valueData, @"^hex\(0*1\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { // Put everything on one line valueData = PutOnOneLineAndTrim(valueData); // Remove hex(1): at the beginning valueData = Regex.Replace( valueData, @"^hex\(0*1\):", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline); // Remove trailing 00,00s valueData = Regex.Replace( valueData, @",00,00$", string.Empty, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture); // Check for empty ValueData if (string.IsNullOrEmpty(valueData.Trim())) { methodResult.ValueKind = RegistryValueKind.String; methodResult.Data = valueData; methodResult.KeyValue = valueName; return true; } // Get the string with UnicodeEncoding Create an array to hold the hex values var temporaryArray = new List<string>(valueData.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); // Treat as DBCS (Double byte characters) List<byte> byteArray = temporaryArray.ConvertAll(String2Byte); valueData = Encoding.Unicode.GetString(byteArray.ToArray()); // Apply Fixes valueData = ApplyFixes(valueData, true); // Look for CR + LF and append warning if found if (valueData.Contains("\r\n")) { valueData = valueData.Replace("\r\n", "_"); } methodResult.ValueKind = RegistryValueKind.String; methodResult.Data = valueData; methodResult.KeyValue = valueName; return true; } return false; }
internal static void SetSpeed(RegistryItem item) { CameraSpeed = (int)(float)(item.GetChild("Speed").GetValue()); }
/// <summary>Matches MutiString from the key/value.</summary> /// <param name="methodResult">The data from the match.</param> /// <param name="valueName">The name of the value.</param> /// <param name="valueData">The data for the value.</param> /// <returns><c>True</c> if it was a match, otherwise; <c>False</c>.</returns> static bool MatchMutiString(ref RegistryItem methodResult, string valueName, string valueData) { if (Regex.IsMatch( valueData, @"^hex\(0*7\):(([0-9|A-F]{2}),?)*", RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline)) { // Put everything on one line valueData = PutOnOneLineAndTrim(valueData); // Remove hex(7): at the beginning valueData = Regex.Replace( valueData, @"^hex\(0*7\):", string.Empty, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Singleline); // Remove trailing 00,00s is now done by the RegEx below the following block // Check for empty ValueData if (string.IsNullOrEmpty(valueData.Trim())) { // Set Flag - Undocumented but used inside XP Setup's own files to specify REG_MULTI_SZ. The // documented method seems to be to use 0x10000 Return Partial Line methodResult.Data = valueName; methodResult.ValueKind = RegistryValueKind.MultiString; return(true); } // Create a List<string> for holding the split parts var multiStringEntries = new List <string>(5); // Create a StringBuilder for holding the semi-processed string var valueDataBuilder = new StringBuilder(valueData.Length); // Convert the bytes back to the string using the new UnicodeEncoding method for v5 signature (DBCS) and // using the old method for v4 signature which uses SBCS. if (regVersionSignature == 5) { // RegEx match all pairs of bytes MatchCollection readInTwos = Regex.Matches( valueData, @"[a-zA-Z0-9]{2},[a-zA-Z0-9]{2}", RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); foreach (Match found in readInTwos) { if (string.Compare(found.Value, "00,00", StringComparison.CurrentCulture) != 0) { var z = new List <string>(found.Value.Split(new[] { ',' })); List <byte> y = z.ConvertAll(String2Byte); valueDataBuilder.Append(Encoding.Unicode.GetString(y.ToArray())); } else { valueDataBuilder.Append("\r\n"); } } } else { // Use old behavior - invalid and non-printable chars will convert to ? (63) Convert 00 to a // carriage return / line-feed (CR-LF): 0d 0a valueData = Regex.Replace( valueData, @"00", @"0d,0a", RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture); // Convert to byte and back to characters using ASCIIEncoding var z = new List <string>(valueData.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); List <byte> y = z.ConvertAll(String2ByteForAsciiAllowCrlf); valueDataBuilder.Append(Encoding.Default.GetString(y.ToArray())); } multiStringEntries.AddRange( Regex.Split( valueDataBuilder.ToString(), @"\r\n", RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture)); // multiStringEntries.RemoveAt((multiStringEntries.Count-1)); multiStringEntries.RemoveAll(EmptyString); // Re init StringBuilder to clear valueDataBuilder = new StringBuilder(valueData.Length); for (int i = 0; i < multiStringEntries.Count; i++) { // Apply Fixes multiStringEntries[i] = ApplyFixes(multiStringEntries[i], true); // Append to StringBuilder if ((i + 1) == multiStringEntries.Count) { valueDataBuilder.Append("\"" + multiStringEntries[i] + "\""); } else { valueDataBuilder.Append("\"" + multiStringEntries[i] + "\","); } } // Set ValueData valueData = valueDataBuilder.ToString(); // Set Flag - REG_MULTI_SZ overwrite methodResult.ValueKind = RegistryValueKind.MultiString; methodResult.Data = valueData; methodResult.KeyValue = valueName; return(true); } return(false); }