Exemple #1
0
        private void work_on_source_code(string source_code)
        {
            try
            {
                update_status_bar("Parsing source code...");
                CodeGenerator code_gen = new CodeGenerator(source_code);

                bool bFoundClassesInInputText = false;

                SortedDictionary <string, int> classes = code_gen.build_class_db();

                // show the "choose class" dialoge, allowing to choose which class(es) to work on,
                // and also on which generation mode to run.

                Choose_Class choose_class = new Choose_Class();

                foreach (KeyValuePair <String, int> entry in classes)
                {
                    bFoundClassesInInputText = true;
                    // do something with entry.Value or entry.Key
                    choose_class.UpdateList(entry.Key);
                }

                choose_class.UpdateGenerationOptions();

                //choose_class.up

                string result = "";

                if (bFoundClassesInInputText)
                {
                    if (choose_class.ShowDialog() == DialogResult.OK)
                    {
                        List <string> list = choose_class.get_selected_classes();

                        bool entered = false;

                        //comboBox1.Items.Add("Wrapper");
                        //comboBox1.Items.Add("VTable Hook");
                        string gen_mode = choose_class.get_chosen_gen_mode();

                        foreach (string class_name in list)
                        {
                            if ("Wrapper" == gen_mode)
                            {
                                result += code_gen.build_class_code_WRAPPER(class_name);
                            }
                            else if ("VTable Hook" == gen_mode)
                            {
                                result += code_gen.build_class_code_VTABLE_HOOK(class_name);
                            }
                            else
                            {
                                MessageBox.Show("Error! unsupported generation mode: [" + gen_mode + "]");
                            }
                            //result += "Class ["+class_name+"]:\r\n";

                            //result += "\r\n";
                            //result += "\r\n";
                            entered = true;
                        }



                        if (!entered)
                        {
                            update_status_bar("No classes seleceted.");
                        }
                        else
                        {
                            update_status_bar("Done.");
                        }
                    }
                    else
                    {
                        update_status_bar("Canceled.");
                        result = "No selected classes.\r\n";
                    }
                }
                else
                {
                    update_status_bar("No classes found, looking for global functions");
                    result = code_gen.build_global_functions_hook();
                    update_status_bar("Done.");
                }

                textBox_Output.Text = result;
            }
            catch (Exception exception)
            {
                textBox_Output.Text = "Error!\n\r " + exception.ToString();
            }
        }
Exemple #2
0
        private void work_on_source_code(string source_code)
        {
            try
            {
                update_status_bar("Parsing source code...");
                CodeGenerator code_gen = new CodeGenerator(source_code);

                bool bFoundClassesInInputText = false;

                SortedDictionary<string, int> classes = code_gen.build_class_db();

                // show the "choose class" dialoge, allowing to choose which class(es) to work on,
                // and also on which generation mode to run.

                Choose_Class choose_class = new Choose_Class();

                foreach (KeyValuePair<String, int> entry in classes)
                {
                    bFoundClassesInInputText = true;
                    // do something with entry.Value or entry.Key
                    choose_class.UpdateList(entry.Key);
                }

                choose_class.UpdateGenerationOptions();

                //choose_class.up

                string result = "";

                if (bFoundClassesInInputText)
                {

                    if (choose_class.ShowDialog() == DialogResult.OK)
                    {
                        List<string> list = choose_class.get_selected_classes();

                        bool entered = false;

                        //comboBox1.Items.Add("Wrapper");
                        //comboBox1.Items.Add("VTable Hook");
                        string gen_mode = choose_class.get_chosen_gen_mode();

                        foreach (string class_name in list)
                        {
                            if ("Wrapper" == gen_mode)
                            {
                                result += code_gen.build_class_code_WRAPPER(class_name);
                            }
                            else if ("VTable Hook" == gen_mode)
                            {
                                result += code_gen.build_class_code_VTABLE_HOOK(class_name);
                            }
                            else
                            {
                                MessageBox.Show("Error! unsupported generation mode: [" + gen_mode + "]");
                            }
                            //result += "Class ["+class_name+"]:\r\n";

                            //result += "\r\n";
                            //result += "\r\n";
                            entered = true;
                        }

                        if (!entered)
                        {
                            update_status_bar("No classes seleceted.");
                        }
                        else
                        {
                            update_status_bar("Done.");
                        }

                    }
                    else
                    {
                        update_status_bar("Canceled.");
                        result = "No selected classes.\r\n";
                    }

                }
                else
                {
                    update_status_bar("No classes found, looking for global functions");
                    result = code_gen.build_global_functions_hook();
                    update_status_bar("Done.");
                }

                textBox_Output.Text = result;
            }
            catch (Exception exception)
            {
                textBox_Output.Text = "Error!\n\r " + exception.ToString();
            }
        }