Example #1
0
        private static void InitLogger()
        {
            logger = LogManager.GetCurrentClassLogger();

            var logFactory = logger.Factory;

            if (logFactory == null)
            {
                return;
            }

            var logConfig = logFactory.Configuration;

            if (logConfig == null)
            {
                return;
            }

            var logRules = logConfig.LoggingRules;

            if (logRules == null)
            {
                return;
            }

            bool needConsole = false;

            foreach (var rule in logRules)
            {
                var targets = rule.Targets;
                if (targets == null)
                {
                    continue;
                }

                foreach (var target in targets)
                {
                    var targetName = target.Name;
                    if (targetName == "console")
                    {
                        needConsole = true;
                        break;
                    }
                }

                if (needConsole)
                {
                    break;
                }
            }

            if (needConsole)
            {
                var hWnd = Kernel32.GetConsoleWindow();
                if (hWnd == IntPtr.Zero)
                {
                    Kernel32.AllocConsole();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Attempts to allocate and attach a console, if this was built in debug mode,
        /// or if the calling assembly is not this assembly.
        /// </summary>
        public static void CreateConsole()
        {
            bool shouldCreateConsole = IsDebugBuild ||
                                       Assembly.CallingAssembly != System.Reflection.Assembly.GetAssembly(typeof(Debug));

            if (shouldCreateConsole)
            {
                Kernel32.AllocConsole();
                Kernel32.AttachConsole(-1);
            }
        }
Example #3
0
        /// <summary>
        /// not used
        /// </summary>
        public static void NewConsole()
        {
            Kernel32.AllocConsole();
            IntPtr         stdHandle      = Kernel32.GetStdHandle(STD_OUTPUT_HANDLE);
            SafeFileHandle safeFileHandle = new SafeFileHandle(stdHandle, true);
            FileStream     fileStream     = new FileStream(safeFileHandle, FileAccess.Write);
            Encoding       encoding       = Encoding.GetEncoding(MY_CODE_PAGE);
            StreamWriter   standardOutput = new StreamWriter(fileStream, encoding);

            standardOutput.AutoFlush = true;
            Console.SetOut(standardOutput);
        }
Example #4
0
 private static void ParseArgs(string[] args, RgssPlayer game)
 {
     string[] debugArgs = { "-d", "-debug", "-t", "-test" };
     game.Debug = args.Any(arg => debugArgs.Contains(arg));
     if ((game.Debug && args.Contains("-noconsole")) || args.Contains("-console"))
     {
         Kernel32.AllocConsole();
         Kernel32.SetConsoleTitle(game.Window.Title + " - Console");
         var handle = Kernel32.GetConsoleWindow();
         User32.SetWindowPos(handle, IntPtr.Zero, 32, 32, 640, 480, SetWindowPosFlags.ShowWindow);
     }
 }
Example #5
0
        public override int Main(string arg)
        {
            // this function is called when KnifeMain() is called from C++ code
            // we should probably launch a thread and run init code from here
            new Thread(() => {
#if DEBUG
                Kernel32.AllocConsole();
#endif
                Ioc.Register <SignaturePool>();
                Ioc.Get <Hack.Hack>().Init();
                Ioc.Get <Hook>().Init();
            }).Start();
            return(0);
        }
Example #6
0
        public static void NewConsole()
        {
            Kernel32.AllocConsole();

            IntPtr         stdHandle      = Kernel32.GetStdHandle(STD_OUTPUT_HANDLE);
            SafeFileHandle safeFileHandle = new SafeFileHandle(stdHandle, true);
            FileStream     fileStream     = new FileStream(safeFileHandle, FileAccess.Write);
            StreamWriter   standardOutput = new StreamWriter(fileStream, Encoding.Default)
            {
                AutoFlush = true
            };

            Console.SetOut(standardOutput);
        }
Example #7
0
        public static void Main()
        {
            Thread thread = new Thread(() =>
            {
                Kernel32.AllocConsole();
                App app = new App();

                app.InitializeComponent();
                app.Run();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }
Example #8
0
        public Nanohook(RemoteHooking.IContext context, int threadId, ExecutableType executableType)
        {
#if DEBUG
            IntPtr consoleWindow = IntPtr.Zero;
            if (Kernel32.AllocConsole())
            {
                consoleWindow = Kernel32.GetConsoleWindow();
                User32.SetLayeredWindowAttributes(consoleWindow, 0u, 225, 2);
            }
            User32.ShowWindow(consoleWindow, 5);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Title           = "Nanocore Debug Console";
#endif
            Tracer.TraceWrite += Log;
            Tracer.SetTraceLevel(6);
        }
Example #9
0
        /// <summary>
        /// Displays a help message in the console.
        /// </summary>
        private static void DisplayHelp()
        {
            bool attatchedConsole = Kernel32.TryAttachConsole();

            if (attatchedConsole)
            {
                Console.WriteLine();
                Console.WriteLine();
            }
            else
            {
                Kernel32.AllocConsole();
            }

            Console.WriteLine($"ModMyFactory v{App.Version}");
            Console.WriteLine();
            Console.WriteLine(@"Usage:");
            Console.WriteLine(@"  modmyfactory.exe -h | --help");
            Console.WriteLine(@"  modmyfactory.exe [options] [<modpack-file>...]");
            Console.WriteLine(@"  modmyfactory.exe [options] -f <version> | --factorio-version=<version> [(-p <name> | --modpack=<name>) (-s <name> | --savegame=<name>) (-c <commandline> | --commands=<commandline>)]");
            Console.WriteLine();
            Console.WriteLine(@"Options:");
            Console.WriteLine(@"  -h, --help                                 Display this help message.");
            Console.WriteLine(@"  MODPACK-FILE                               Imports the specified modpack file.");
            Console.WriteLine(@"  -a PATH, --appdata-path=PATH               Override the default application data path.");
            Console.WriteLine(@"  -l, --no-logs                              Don't create crash logs.");
            Console.WriteLine(@"  -u, --no-update                            Don't search for update on startup.");
            Console.WriteLine(@"  -t, --no-register-filetype                 Don't register file types on startup.");
            Console.WriteLine(@"  -n NAME, --factorio-name=NAME              Start the specified Factorio installation.");
            Console.WriteLine(@"  -f VERSION, --factorio-version=VERSION     Start a Factorio installation that matches this version.");
            Console.WriteLine(@"  -p NAME, --modpack=NAME                    Enable the specified modpack.");
            Console.WriteLine(@"  -s NAME, --savegame=NAME                   Load the specified savegame.");
            Console.WriteLine(@"  -c COMMANDLINE, --commands=COMMANDLINE     Start Factorio with the specified command line.");

            if (attatchedConsole)
            {
                System.Windows.Forms.SendKeys.SendWait("{Enter}");
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine(@"Press any key to continue.");
                Console.ReadKey();
            }
            Kernel32.FreeConsole();
        }
Example #10
0
        public ConsoleWindow(AugmentrexContext context)
        {
            context.Info("Allocating game console window... ");

            if (Kernel32.AllocConsole())
            {
                context.SuccessLine("OK.");

                var asmName = Assembly.GetExecutingAssembly().GetName();

                Console.Title = $"{asmName.Name} {asmName.Version} - Game Process";
            }
            else
            {
                context.WarningLine("{0}.", Win32.GetLastError());
            }
        }
Example #11
0
    public static void Run()
    {
        #region DEBUGCONSOLE
#if DEBUG
        IntPtr consoleWindow = IntPtr.Zero;
        if (Kernel32.AllocConsole())
        {
            consoleWindow = Kernel32.GetConsoleWindow();
            User32.SetLayeredWindowAttributes(consoleWindow, 0u, 225, 2);
        }
        User32.ShowWindow(consoleWindow, 5);
        Console.ForegroundColor = ConsoleColor.Green;
        Console.Title           = "Coriander Debug Console";
        Tracer.TraceWrite      += Log;
        Tracer.SetTraceLevel(6);
#endif
        #endregion
        Console.WriteLine(".Net Core active.");
        Console.ReadLine();
    }
Example #12
0
        private void ConsoleNeeded(bool redirectLogs = false)
        {
            if (redirectLogs)
            {
                var listener = new OutputTraceListener();
                listener.Other = LogViewTraceListener.Actual;
                LogViewTraceListener.Actual = listener;
            }

            if (Kernel32.GetConsoleWindow() == IntPtr.Zero)
            {
                var parentPid = GetParentProcessId(Process.GetCurrentProcess());
                Kernel32.AttachConsole((uint)parentPid);
                if (Kernel32.GetConsoleWindow() == IntPtr.Zero)
                {
                    Kernel32.AllocConsole();
                }
            }

            Terminal.WriteLine();
        }
Example #13
0
        /// <summary>
        /// Displays a help message in the console.
        /// </summary>
        private static void DisplayHelp()
        {
            bool attatchedConsole = Kernel32.TryAttachConsole();

            if (attatchedConsole)
            {
                Console.WriteLine();
                Console.WriteLine();
            }
            else
            {
                Kernel32.AllocConsole();
            }

            Console.WriteLine(@"Usage:");
            Console.WriteLine(@"  modmyfactory.exe -h | --help");
            Console.WriteLine(@"  modmyfactory.exe [options] [<modpack-file>...]");
            Console.WriteLine(@"  modmyfactory.exe [options] -f <version> | --factorio-version=<version> [(-p <name> | --modpack=<name>)]");
            Console.WriteLine();
            Console.WriteLine(@"Options:");
            Console.WriteLine(@"  -h, --help                                 Display this help message.");
            Console.WriteLine(@"  MODPACK-FILE                               Imports the specified modpack file.");
            Console.WriteLine(@"  -l, --no-logs                              Don't create crash logs.");
            Console.WriteLine(@"  -a PATH, --appdata-path=PATH               Override the default application data path.");
            Console.WriteLine(@"  -u, --no-update                            Don't search for update on startup.");
            Console.WriteLine(@"  -f VERSION, --factorio-version=VERSION     Start the specified version of Factorio.");
            Console.WriteLine(@"  -p NAME, --modpack=NAME                    Enable the specified modpack.");

            if (attatchedConsole)
            {
                System.Windows.Forms.SendKeys.SendWait("{Enter}");
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine(@"Press any key to continue.");
                Console.ReadKey();
            }
            Kernel32.FreeConsole();
        }
Example #14
0
        public static bool Allocate()
        {
            if (!Kernel32.AllocConsole())
            {
                return(false);
            }

            var inputHandle = Kernel32.GetStdHandle(StdHandleType.Input);
            var inputStream = new FileStream(new SafeFileHandle(inputHandle, true), FileAccess.Read);

            Console.SetIn(new StreamReader(inputStream));

            var outputHandle = Kernel32.GetStdHandle(StdHandleType.Output);
            var outputStream = new FileStream(new SafeFileHandle(outputHandle, true), FileAccess.Write);

            Console.SetOut(new StreamWriter(outputStream)
            {
                AutoFlush = true
            });

            return(true);
        }
Example #15
0
        /// <summary>
        /// Creates and attaches a console window if necessary
        /// </summary>
        public void AttachConsole()
        {
            if (_consoleAttached)
            {
                throw new InvalidOperationException();
            }

            lock (_lockObject)
            {
                if (!Kernel32.AttachConsole(0xFFFFFFFF) && !Kernel32.AllocConsole())
                {
                    throw new Win32Exception();
                }

                Console.SetOut(new StreamWriter(Console.OpenStandardOutput(), Console.OutputEncoding)
                {
                    AutoFlush = true
                });

                _consoleAttached = true;
            }
        }
Example #16
0
        private static int Init(IntPtr parameter)
        {
            Console.WriteLine($"Init (in-game: {Util.IsInGame})");
            if (Util.IsInGame)
            {
                while (System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle == IntPtr.Zero)
                {
                    Console.WriteLine("Waiting for game window");
                    Thread.Sleep(5000);
                }
                Thread.Sleep(5000);

                Kernel32.AllocConsole();

                Console.SetOut(new StreamWriter(Console.OpenStandardOutput())
                {
                    AutoFlush = true
                });
                Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                Console.SetError(new StreamWriter(Console.OpenStandardError())
                {
                    AutoFlush = true
                });
            }

            using var scriptMgr = new ScriptManager();
            var cmdMgr = new CommandManager(scriptMgr);

            cmdMgr.MainLoop();

            Console.WriteLine("Init End");

            if (Util.IsInGame)
            {
                Kernel32.FreeConsole();
            }
            return(0);
        }
Example #17
0
        public static void spoon(out int Res)
        {
            Res = -1;
            ProcessInfo *PInf = (ProcessInfo *)Marshal.AllocHGlobal(sizeof(ProcessInfo));

            if (NtDll.RtlCloneUserProcess(CloneProcessFlags.CreateSuspended | CloneProcessFlags.InheritHandles,
                                          IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, PInf) == CloneStatus.Parent)
            {
                Res = Kernel32.GetProcessId(PInf->ProcInfo.Process);

                Kernel32.ResumeThread(PInf->ProcInfo.Thread);
                Kernel32.CloseHandle(PInf->ProcInfo.Process);
                Kernel32.CloseHandle(PInf->ProcInfo.Thread);
                Marshal.FreeHGlobal(new IntPtr(PInf));
            }
            else
            {
                Res = 0;

                if (Kernel32.FreeConsole())
                {
                    Kernel32.AllocConsole();

                    StreamWriter OutWriter = new StreamWriter(Console.OpenStandardOutput());
                    OutWriter.AutoFlush = true;
                    Console.SetOut(OutWriter);

                    StreamWriter ErrWriter = new StreamWriter(Console.OpenStandardError());
                    ErrWriter.AutoFlush = true;
                    Console.SetError(ErrWriter);

                    StreamReader InReader = new StreamReader(Console.OpenStandardInput());
                    Console.SetIn(InReader);
                }
            }
        }
Example #18
0
 public override void Call()
 {
     AssemblerExecute.registers.EAX = Kernel32.AllocConsole() ? 1 : 0;
 }
Example #19
0
        public static int Main(string[] args)
        {
#if DEBUG
            IntPtr hConsole = IntPtr.Zero;
            if (Kernel32.AllocConsole())
            {
                hConsole = Kernel32.GetConsoleWindow();
                User32.SetLayeredWindowAttributes(hConsole, 0u, 225, 2);
            }
            User32.ShowWindow(hConsole, 5);
            Console.ForegroundColor = ConsoleColor.Green;
            Tracer.TraceWrite      += TraceWrite;
#endif
            Console.CancelKeyPress += ConsoleCancel;
            Kernel32.Win32FindDataW findFileData = new Kernel32.Win32FindDataW();
            IntPtr hSearch = Kernel32.FindFirstFileW("lotrsec.big", ref findFileData);
            if (hSearch == (IntPtr)(-1))
            {
                StringBuilder fileName = new StringBuilder(Kernel32.MAX_PATH);
                Kernel32.GetModuleFileNameW(IntPtr.Zero, fileName, Kernel32.MAX_PATH);
                for (int idx = fileName.Length - 1; idx != 0; --idx)
                {
                    if (fileName[idx] == '\\')
                    {
                        fileName[idx] = '\0';
                        break;
                    }
                }
                Kernel32.SetCurrentDirectoryW(fileName.ToString());
            }
            else
            {
                Kernel32.FindClose(hSearch);
            }
            string        config    = null;
            string        modconifg = null;
            List <string> argList   = new List <string>(args.Length);
            for (int idx = 0; idx < args.Length; ++idx)
            {
                if (string.Equals(args[idx], "-config"))
                {
                    if (idx == args.Length - 1)
                    {
                        MessageBox.Show("Invalid config parameter. A path needs to be set.");
                        return(-1);
                    }
                    config = args[idx++ + 1];
                }
                if (string.Equals(args[idx], "-modconfig"))
                {
                    if (idx == args.Length - 1)
                    {
                        MessageBox.Show("Invalid modconfig parameter. A path needs to be set.");
                        return(-1);
                    }
                    modconifg = args[idx++ + 1];
                }
                else
                {
                    argList.Add(args[idx]);
                }
            }
            args = argList.ToArray();
            Kernel32.StartupInfoW       si = new Kernel32.StartupInfoW(true);
            Kernel32.ProcessInformation pi = new Kernel32.ProcessInformation();
            int            overallTries    = 0;
            int            tries           = 0;
            Registry       registry        = new Registry();
            string         executablePath  = System.IO.Path.Combine(registry.InstallPath, "data", "ra3_1.12.game");
            ExecutableType executableType  = ExecutableType.Unknown;
            using (System.IO.Stream stream = new System.IO.FileStream(executablePath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
            {
                byte[] buffer = new byte[stream.Length];
                stream.Read(buffer, 0, buffer.Length);
                uint hash = Nanocore.Core.FastHash.GetHashCode(buffer);
                switch (hash)
                {
                case 0xCFAAD44Bu:
                case 0xE6D223E6u:
                case 0xCF5817CCu:
                    executableType = ExecutableType.Steam;
                    break;

                case 0xE7AF6A35u:
                case 0x2F121290u:
                    executableType = ExecutableType.Origin;
                    break;

                case 0xA05DEB39:     // this has the 4gb thing applied, need to check the original
                    executableType = ExecutableType.Retail;
                    break;

                case 0xBFE68CAD:     // should I care? this is mostly here because origins and reloaded exe have the same size
                    executableType = ExecutableType.ReLOADeD;
                    break;
                }
            }
            if (executableType == ExecutableType.Unknown)
            {
                MessageBox.Show("A version of the game is installed. Please get the game from an official source.");
                return(-1);
            }
            else if (executableType == ExecutableType.Retail)
            {
                MessageBox.Show("The retail or an old origin version is installed. If you are using Origin please update the game. Retail versions cannot be supported due to SecuROM.");
                return(-1);
            }
            while (!_isConsoleCancel)
            {
                ++tries;
                if (tries > 20)
                {
                    if (MessageBox.Show("Windows caching interferred with injecting into the game, do you want to try again?", "Error", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        overallTries += tries;
                        tries         = 1;
                    }
                    else
                    {
                        break;
                    }
                }
                try
                {
                    Kernel32.CreateProcessW(null, $"\"{executablePath}\" {string.Join(" ", args)} -config \"{config ?? System.IO.Path.Combine(registry.InstallPath, $"RA3_{registry.Language}_1.12.skudef")}\" {(modconifg is null ? string.Empty : $"-modconfig \"{modconifg}\"")}",
                                            IntPtr.Zero,
                                            IntPtr.Zero,
                                            true,
                                            4,
                                            IntPtr.Zero,
                                            null,
                                            ref si,
                                            ref pi);
                    EZHook.Inject(pi.DwProcessId, "Nanocore.dll", pi.DwThreadId, executableType);
                }
Example #20
0
        public static void Start(string[] args)
        {
            bool          isAlreadyRunning = false;
            List <string> filesToOpen      = new List <string>();

            // Init Log4NET
            LogFileLocation = LogHelper.InitializeLog4NET();
            // Get logger
            LOG = log4net.LogManager.GetLogger(typeof(MainForm));

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            // Log the startup
            LOG.Info("Starting: " + EnvironmentInfo.EnvironmentToString(false));

            IniConfig.Init();
            AppConfig.UpgradeToIni();
            // Read configuration
            conf = IniConfig.GetIniSection <CoreConfiguration>();
            try
            {
                // Fix for Bug 2495900, Multi-user Environment
                // check whether there's an local instance running already

                try
                {
                    // Added Mutex Security, hopefully this prevents the UnauthorizedAccessException more gracefully
                    // See an example in Bug #3131534
                    SecurityIdentifier sid           = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
                    MutexSecurity      mutexsecurity = new MutexSecurity();
                    mutexsecurity.AddAccessRule(new MutexAccessRule(sid, MutexRights.FullControl, AccessControlType.Allow));
                    mutexsecurity.AddAccessRule(new MutexAccessRule(sid, MutexRights.ChangePermissions, AccessControlType.Deny));
                    mutexsecurity.AddAccessRule(new MutexAccessRule(sid, MutexRights.Delete, AccessControlType.Deny));

                    bool created = false;
                    // 1) Create Mutex
                    applicationMutex = new Mutex(false, @"Local\F48E86D3-E34C-4DB7-8F8F-9A0EA55F0D08", out created, mutexsecurity);
                    // 2) Get the right to it, this returns false if it's already locked
                    if (!applicationMutex.WaitOne(0, false))
                    {
                        LOG.Debug("Greenshot seems already to be running!");
                        isAlreadyRunning = true;
                        // Clean up
                        applicationMutex.Close();
                        applicationMutex = null;
                    }
                }
                catch (AbandonedMutexException e)
                {
                    // Another Greenshot instance didn't cleanup correctly!
                    // we can ignore the exception, it happend on the "waitone" but still the mutex belongs to us
                    LOG.Warn("Greenshot didn't cleanup correctly!", e);
                }
                catch (UnauthorizedAccessException e)
                {
                    LOG.Warn("Greenshot is most likely already running for a different user in the same session, can't create mutex due to error: ", e);
                    isAlreadyRunning = true;
                }
                catch (Exception e)
                {
                    LOG.Warn("Problem obtaining the Mutex, assuming it was already taken!", e);
                    isAlreadyRunning = true;
                }

                if (args.Length > 0 && LOG.IsDebugEnabled)
                {
                    StringBuilder argumentString = new StringBuilder();
                    for (int argumentNr = 0; argumentNr < args.Length; argumentNr++)
                    {
                        argumentString.Append("[").Append(args[argumentNr]).Append("] ");
                    }
                    LOG.Debug("Greenshot arguments: " + argumentString.ToString());
                }

                for (int argumentNr = 0; argumentNr < args.Length; argumentNr++)
                {
                    string argument = args[argumentNr];
                    // Help
                    if (argument.ToLower().Equals("/help"))
                    {
                        // Try to attach to the console
                        bool attachedToConsole = Kernel32.AttachConsole(Kernel32.ATTACHCONSOLE_ATTACHPARENTPROCESS);
                        // If attach didn't work, open a console
                        if (!attachedToConsole)
                        {
                            Kernel32.AllocConsole();
                        }
                        StringBuilder helpOutput = new StringBuilder();
                        helpOutput.AppendLine();
                        helpOutput.AppendLine("Greenshot commandline options:");
                        helpOutput.AppendLine();
                        helpOutput.AppendLine();
                        helpOutput.AppendLine("\t/help");
                        helpOutput.AppendLine("\t\tThis help.");
                        helpOutput.AppendLine();
                        helpOutput.AppendLine();
                        helpOutput.AppendLine("\t/exit");
                        helpOutput.AppendLine("\t\tTries to close all running instances.");
                        helpOutput.AppendLine();
                        helpOutput.AppendLine();
                        helpOutput.AppendLine("\t/reload");
                        helpOutput.AppendLine("\t\tReload the configuration of Greenshot.");
                        helpOutput.AppendLine();
                        helpOutput.AppendLine();
                        helpOutput.AppendLine("\t/language [language code]");
                        helpOutput.AppendLine("\t\tSet the language of Greenshot, e.g. greenshot /language en-US.");
                        helpOutput.AppendLine();
                        helpOutput.AppendLine();
                        helpOutput.AppendLine("\t[filename]");
                        helpOutput.AppendLine("\t\tOpen the bitmap files in the running Greenshot instance or start a new instance");
                        Console.WriteLine(helpOutput.ToString());

                        // If attach didn't work, wait for key otherwise the console will close to quickly
                        if (!attachedToConsole)
                        {
                            Console.ReadKey();
                        }
                        FreeMutex();
                        return;
                    }

                    if (argument.ToLower().Equals("/exit"))
                    {
                        // unregister application on uninstall (allow uninstall)
                        try
                        {
                            LOG.Info("Sending all instances the exit command.");
                            // Pass Exit to running instance, if any
                            SendData(new CopyDataTransport(CommandEnum.Exit));
                        }
                        catch (Exception e)
                        {
                            LOG.Warn("Exception by exit.", e);
                        }
                        FreeMutex();
                        return;
                    }

                    // Reload the configuration
                    if (argument.ToLower().Equals("/reload"))
                    {
                        // Modify configuration
                        LOG.Info("Reloading configuration!");
                        // Update running instances
                        SendData(new CopyDataTransport(CommandEnum.ReloadConfig));
                        FreeMutex();
                        return;
                    }

                    // Stop running
                    if (argument.ToLower().Equals("/norun"))
                    {
                        // Make an exit possible
                        FreeMutex();
                        return;
                    }

                    // Language
                    if (argument.ToLower().Equals("/language"))
                    {
                        conf.Language = args[++argumentNr];
                        IniConfig.Save();
                        continue;
                    }

                    // Files to open
                    filesToOpen.Add(argument);
                }

                // Finished parsing the command line arguments, see if we need to do anything
                CopyDataTransport transport = new CopyDataTransport();
                if (filesToOpen.Count > 0)
                {
                    foreach (string fileToOpen in filesToOpen)
                    {
                        transport.AddCommand(CommandEnum.OpenFile, fileToOpen);
                    }
                }

                if (MainForm.instance == null)
                {
                    MainForm.instance = new MainForm(transport);
                }

                // if language is not set, show language dialog
                if (string.IsNullOrEmpty(conf.Language))
                {
                    LanguageDialog languageDialog = LanguageDialog.GetInstance();
                    languageDialog.ShowDialog();
                    conf.Language = languageDialog.SelectedLanguage;
                    IniConfig.Save();
                }

                // Check if it's the first time launch?
                if (conf.IsFirstLaunch)
                {
                    conf.IsFirstLaunch = false;
                    IniConfig.Save();
                    transport.AddCommand(CommandEnum.FirstLaunch);
                }
            }
            catch (Exception ex)
            {
                LOG.Error("Exception in startup.", ex);
                Application_ThreadException(MainForm.ActiveForm, new ThreadExceptionEventArgs(ex));
            }
        }
Example #21
0
 private static void CreateConsole()
 {
     Kernel32.AllocConsole();
 }
Example #22
0
 private static void InitializeConsole()
 {
     Kernel32.AllocConsole();
     Console.Title = "Google Drive Loader";
 }
 public static void AllocConsole(this MoonlightAPI moonlightApi)
 {
     Kernel32.AllocConsole();
 }