Esempio n. 1
0
        ///// <summary>
        ///// Get data from path - not used
        ///// </summary>
        ///// <param name="path">full path</param>
        //public void GetDataFromPath(string path)
        //{
        //    //acpiLib.GetValue();
        //}
        /// <summary>
        /// Constructor acpi data from a method arg
        /// </summary>
        /// <param name="arg">arg</param>
        public AcpiData(AcpiMethodArg arg)
        {
            switch (arg.Type)
            {
            case 0:
                this.Type  = AcpiDataType.Int;
                this.Value = arg.ulValue;
                break;

            case 1:
                Type          = AcpiDataType.String;
                this.strValue = new string(arg.strValue.ToArray());
                break;

            case 2:
                Type         = AcpiDataType.Buffer;
                this.bpValue = new byte[arg.bValue.Length];
                Array.Copy(arg.bValue, 0, this.bpValue, 0, arg.bValue.Length);
                break;

            case 3:
                Type         = AcpiDataType.Packge;
                this.bpValue = new byte[arg.bValue.Length];
                Array.Copy(arg.bValue, 0, this.bpValue, 0, arg.bValue.Length);
                break;

            default:
                //System.Diagnostics.Debug.Assert(false);
                Log.Logs("public AcpiData(AcpiMethodArg arg)");
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Submit all args
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string Value;

            _Args.Clear();
            bEval = true;
            for (int pageIdx = 0; pageIdx < tabControl1.TabPages.Count; pageIdx++)
            {
                // clear all edits..
                if (tabControl1.TabPages[pageIdx].Controls.Count > 0)
                {
                    Value = tabControl1.TabPages[pageIdx].Controls[0].Text;
                    if (tabControl1.TabPages[pageIdx].Controls[0].Text.Length == 0)
                    {
                        tabControl1.SelectedIndex = pageIdx;
                        break;
                    }
                    else
                    {
                        // check all values...
                        try
                        {
                            if (TabArgType[pageIdx] == 0)
                            {
                                // integer
                                //byte[] bytex = BitConverter.GetBytes(
                                Value = Value.Trim().ToLower();
                                UInt64 num = 0;
                                if (IsHexValue(ref Value))
                                {
                                    // hex value
                                    if (Value.Length > 16)
                                    {
                                        MessageBox.Show("Hex value is too big, over 64bit integer(0xFFFFFFFF FFFFFFFF)");
                                        break;
                                    }
                                    else if (Value.Contains("x"))
                                    {
                                        MessageBox.Show("Invalid Hex value which contain extra 'x'");
                                        break;
                                    }
                                    num = UInt64.Parse(Value, System.Globalization.NumberStyles.HexNumber);
                                }
                                else
                                {
                                    if (Value.Contains("x"))
                                    {
                                        MessageBox.Show("Invalid Hex value which contain extra 'x'");
                                        break;
                                    }
                                    num = UInt64.Parse(Value, System.Globalization.NumberStyles.Integer);
                                }
                                byte[]        bytex = Encoding.ASCII.GetBytes(tabControl1.TabPages[pageIdx].Controls[0].Text);
                                AcpiMethodArg arg   = new AcpiMethodArg();
                                arg.Type    = 0;
                                arg.ulValue = num;
                                _Args.Add(arg);
                            }
                            else if (TabArgType[pageIdx] == 1)
                            {
                                AcpiMethodArg arg = new AcpiMethodArg();
                                arg.Type     = 1;
                                arg.strValue = Value.Trim();
                                _Args.Add(arg);
                            }
                            else if (TabArgType[pageIdx] == 2)
                            {
                                string[]      strBytes = tabControl1.TabPages[pageIdx].Controls[0].Text.Split(new char[] { ',' });
                                AcpiMethodArg arg      = new AcpiMethodArg();
                                arg.Type   = 2;
                                arg.Count  = strBytes.Length;
                                arg.bValue = new byte[arg.Count];
                                arg.Count  = 0;
                                foreach (string strByte in strBytes)
                                {
                                    string strByteValue = strByte.Trim().ToLower();
                                    strByteValue = strByteValue.Replace(" ", "");
                                    IsHexValue(ref strByteValue);
                                    UInt32 bValue = UInt32.Parse(strByteValue, System.Globalization.NumberStyles.HexNumber);
                                    arg.bValue[arg.Count] = (byte)bValue;
                                    arg.Count++;
                                }
                                _Args.Add(arg);
                            }
                        }
                        catch (Exception ex)
                        {
                            bEval = false;
                            tabControl1.SelectedIndex = pageIdx;
                            MessageBox.Show(ex.Message);
                            Log.Logs(ex.Message);
                            break;
                        }
                    }
                }
            }
            if (bEval)
            {
                this.Hide();
            }
        }