private void SetInputData() { if (bIsAdd) { this.txtValuename.BorderStyle = BorderStyle.Fixed3D; btnOk.Enabled = false; return; } txtValuename.Text = ValueInfo != null ? ValueInfo.sValue : regValueInfo.pValueName; if (ValueInfo != null) { RegistryInteropWrapperWindows.Win32RegKeyValueData(ValueInfo.sParentKey, ValueInfo.sValue, out sDataBuf); } else { RegistryInteropWrapper.ApiRegGetValue(plugin.handle.Handle, regValueInfo, out sDataBuf); sDataBuf = new UnicodeEncoding().GetString(sDataBuf as byte[]).Split('\n'); } string[] sStringdata = sDataBuf as string[]; if (sStringdata != null && sStringdata.Length != 0) { foreach (string data in sStringdata) { sbInuputData.AppendLine(data); } } richTextBoxValueData.Text = sbInuputData.ToString().Replace("\r\n\r\n", "\r\n"); }
private void SetInputData() { object data = null; try { Logger.Log("BinaryValueEditorDialog.SetInputData - Updating the binary value", Logger.RegistryViewerLoglevel); if (bIsAdd) { this.txtValuename.BorderStyle = BorderStyle.Fixed3D; this.btnOk.Enabled = false; if (ValueInfo != null) { ValueInfo.RegDataType = LWRegistryValueKind.REG_BINARY; } else { regValueInfo.pType = (ulong)RegistryApi.REG_BINARY; } LWDataBinarydata.Rows.Add(new string[] { "0000" }); return; } txtValuename.Text = ValueInfo != null ? ValueInfo.sValue : regValueInfo.pValueName; // Note this method can be invoked in two ways // 1. Double click a REG_BINARY key value // 2. Right click any Key and select Modify Binary Value // We need to find the key type and handle different scenarios if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows) { ValueInfo.RegDataType = RegistryInteropWrapperWindows.Win32RegKeyValueKind(ValueInfo.sParentKey, ValueInfo.sValue); RegistryInteropWrapperWindows.Win32RegKeyValueData(ValueInfo.sParentKey, ValueInfo.sValue, out data); if (data == null && ValueInfo.RegDataType == LWRegistryValueKind.REG_RESOURCE_LIST) { string[] sKey = ValueInfo.sParentKey.ToString().Split(new char[] { '\\' }, 2); data = RegistryInteropWrapperWindows.RegGetValue(RegistryInteropWrapperWindows.GetRegistryHive(ValueInfo.hKey), sKey[1], ValueInfo.sValue, out ValueInfo.intDataType); } } else { RegistryInteropWrapper.ApiRegGetValue(plugin.handle.Handle, regValueInfo, out data); } if (data == null) { Logger.Log("BinaryValueEditorDialog.SetInputData - RegistryKey.GetValue returns null", Logger.RegistryViewerLoglevel); LWDataBinarydata.Rows.Add(new string[] { "0000" }); return; } if (ValueInfo != null) { switch (ValueInfo.RegDataType) { case LWRegistryValueKind.REG_BINARY: case LWRegistryValueKind.REG_RESOURCE_LIST: ParseBinaryData(data); break; case LWRegistryValueKind.REG_EXPAND_SZ: case LWRegistryValueKind.REG_SZ: ParseStringData(data.ToString() + "\r\n"); break; case LWRegistryValueKind.REG_MULTI_SZ: ParseMultiStringData(data); break; case LWRegistryValueKind.REG_DWORD: ParseDWordData(data); break; case LWRegistryValueKind.REG_QUADWORD: ParseQWordData(data); break; case LWRegistryValueKind.REG_NONE: throw new NotImplementedException("Not supported data type"); default: break; } } else { switch (regValueInfo.pType) { case (ulong)RegistryApi.REG_BINARY: case (ulong)RegistryApi.REG_FULL_RESOURCE_DESCRIPTOR: case (ulong)RegistryApi.REG_RESOURCE_LIST: case (ulong)RegistryApi.REG_RESOURCE_REQUIREMENTS_LIST: ParseBinaryData(data); break; case (ulong)RegistryApi.REG_SZ: case (ulong)RegistryApi.REG_PLAIN_TEXT: case (ulong)RegistryApi.REG_EXPAND_SZ: if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows) { ParseStringData(new ASCIIEncoding().GetString(data as byte[])); } else { ParseStringData(new UnicodeEncoding().GetString(data as byte[])); } break; case (ulong)RegistryApi.REG_MULTI_SZ: ParseMultiStringData(data); break; case (ulong)RegistryApi.REG_DWORD: ParseDWordData(data); break; case (ulong)RegistryApi.REG_QWORD: ParseQWordData(data); break; case (ulong)RegistryApi.REG_NONE: throw new NotImplementedException("Not supported data type"); default: break; } this.LWDataBinarydata.BeginEdit(true); this.LWDataBinarydata.Rows[0].Selected = true; } //LWDataBinarydata.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCellsExceptHeader); } catch (Exception ex) { Logger.LogException("BinaryValueEditorDialog.SetInputData()", ex); } }