unsafe private void SetInputData() { Logger.Log("ResourceListDialog.SetInputData", Logger.RegistryViewerLoglevel); string[] sKey = null; object data = null; if (ValueInfo != null) { sKey = ValueInfo.sParentKey.ToString().Split(new char[] { '\\' }, 2); data = RegistryInteropWrapperWindows.RegGetValue(RegistryInteropWrapperWindows.GetRegistryHive(ValueInfo.hKey), sKey[1], ValueInfo.sValue, out ValueInfo.intDataType); } else { sKey = regValueInfo.sKeyname.ToString().Split(new char[] { '\\' }, 2); data = regValueInfo.bDataBuf; } if (data == null) { Logger.Log("ResourceListDialog.SetInputData - RegistryKey.GetValue returns null", Logger.RegistryViewerLoglevel); return; } try { int RESOURCE_LIST = 8; int FULL_RESOURCE_DESCRIPTOR = 9; byte[] buffer = data as byte[]; RegResourceItem.ResourceList resourceList = null; fixed(byte *pBuffer = buffer) { IntPtr p = (IntPtr)pBuffer; resourceList = new RegResourceItem.ResourceList(); if ((ValueInfo != null && ValueInfo.intDataType == RESOURCE_LIST) || (regValueInfo != null && (int)regValueInfo.pType == RESOURCE_LIST)) { RegResourceItem.RESOURCE_LIST_COUNT rCount = new RegResourceItem.RESOURCE_LIST_COUNT(); Marshal.PtrToStructure(p, rCount); p = (IntPtr)(p.ToInt32() + Marshal.SizeOf(rCount)); for (int i = 0; i < rCount.Count; i++) { ExtractResourceDescriptor(resourceList, ref p); } } else if ((ValueInfo != null && ValueInfo.intDataType == FULL_RESOURCE_DESCRIPTOR) || (regValueInfo != null && (int)regValueInfo.pType == FULL_RESOURCE_DESCRIPTOR)) { ExtractResourceDescriptor(resourceList, ref p); } } if (LWlvResourceList.Items.Count > 0) { btnDisplay.Enabled = true; } } finally { } }
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); } }