public FormMain()
 {
     InitializeComponent();
     // This doesn't create the enclave, it just initializes what we need
     // to do so in an multithreaded environment.
     EnclaveLinkManaged.init_enclave();
 }
        public ProgressRandom(int mb_in, int num_in)
        {
            enclave   = new EnclaveLinkManaged();
            mb        = mb_in;
            num       = num_in;
            uicontext = TaskScheduler.FromCurrentSynchronizationContext();
            callback  = new progress_callback(UpdateProgress);

            InitializeComponent();

            labelTask.Text = String.Format("Generating {0} MB of random data", mb);
        }
        private void buttonCPUID_Click(object sender, EventArgs e)
        {
            int rv;

            UInt32[]           flags   = new UInt32[4];
            EnclaveLinkManaged enclave = new EnclaveLinkManaged();

            // Query CPUID and get back an array of 4 32-bit unsigned integers

            rv = enclave.cpuid(Convert.ToInt32(textBoxLeaf.Text), flags);
            if (rv == 1)
            {
                textBoxEAX.Text = String.Format("{0:X8}", flags[0]);
                textBoxEBX.Text = String.Format("{0:X8}", flags[1]);
                textBoxECX.Text = String.Format("{0:X8}", flags[2]);
                textBoxEDX.Text = String.Format("{0:X8}", flags[3]);
            }
            else
            {
                MessageBox.Show("CPUID query failed");
            }
        }