Exemplo n.º 1
0
 public void CreateNewMainForm()
 {
     ++m_formCount;
     MainForm frm = new MainForm(m_comRegistry);
     frm.FormClosed += OnFormClosed;
     frm.Show();
 }
Exemplo n.º 2
0
        static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using (LoadingDialog loader = new LoadingDialog(Microsoft.Win32.Registry.ClassesRoot))
            {
                if (loader.ShowDialog() == DialogResult.OK)
                {
                    using (_mainForm = new MainForm())
                    {
                        Application.Run(_mainForm);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            string database_file = null;
            string save_file = null;
            bool enum_clsid = false;
            bool show_help = false;
            bool user_only = false;

            OptionSet opts = new OptionSet() {
                { "i|in=",  "Open a database file.", v => database_file = v },
                { "o|out=", "Save database and exit.", v => save_file = v },
                { "e|enum",  "Enumerate the provided CLSID (GUID).", v => enum_clsid = v != null },
                { "u|user",  "Use only current user registrations.", v => user_only = v != null },
                { "h|help",  "Show this message and exit.", v => show_help = v != null },
            };

            List<string> additional_args = opts.Parse(args);

            if (show_help || (enum_clsid && additional_args.Count < 4))
            {
                StringWriter writer = new StringWriter();
                writer.WriteLine("Usage: OleViewDotNet [options] [enum args]");
                writer.WriteLine();
                writer.WriteLine("Options:");
                opts.WriteOptionDescriptions(writer);
                MessageBox.Show(writer.ToString(), "Help", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Environment.Exit(1);
            }

            if (enum_clsid)
            {
                try
                {
                    Environment.Exit(EnumInterfaces(additional_args));
                }
                catch
                {
                    Environment.Exit(42);
                }
            }
            else
            {
                Exception error = null;
                COMRegistry instance = null;
                AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                using (LoadingDialog loader = new LoadingDialog(user_only, database_file))
                {
                    if (loader.ShowDialog() == DialogResult.OK)
                    {
                        instance = loader.Instance;
                        if (save_file != null)
                        {
                            try
                            {
                                instance.Save(save_file);
                            }
                            catch (Exception ex)
                            {
                                error = ex;
                            }
                            Environment.Exit(0);
                        }
                    }
                    else
                    {
                        error = loader.Error;
                    }
                }

                if (error == null)
                {
                    using (_mainForm = new MainForm(instance))
                    {
                        Application.Run(_mainForm);
                    }
                }
                else
                {
                    MessageBox.Show(error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }