static int Main(string[] args) { // Operation string invokedOperation = ""; // General options. GeneralOptions generalOptions = null; // Options specific to the action to perform. object invokedOperationOptions = null; var opts = new Options(); // Must check for null, because the parser won't.. if (args == null || args.Length == 0) { Console.WriteLine(opts.GetUsage("help")); goto ERROR; } CommandLine.Parser.Default.ParseArgumentsStrict(args, opts, (verb, subOptions) => { // Action to store correct information for further instructing the processor. invokedOperation = verb; invokedOperationOptions = subOptions; }, () => { // Failed attempt at parsing the provided arguments. Environment.Exit(-2); }); try { // Process general options generalOptions = (GeneralOptions)invokedOperationOptions; Prepare(generalOptions); } catch (Exception e) { Log.Exception(e.Message, e); goto ERROR; } // Use knowledge about the game HearthStone. Game knowledge is defined in the shared code // project KnowledgeBase. See `GameKnowledgeBase.HSKB` for more information. // Change the following line if you want to hook another game. GameKB gameKnowledge = HSKB.Get(generalOptions.GamePath); try { switch (invokedOperation) { case OPERATION_HOOK: var hookHelper = new HookHelper((HookSubOptions)invokedOperationOptions); hookHelper.TryHook(gameKnowledge); Log.Info("Succesfully hooked the game libraries!"); break; case OPERATION_RESTORE: var restore = new Restore((RestoreSubOptions)invokedOperationOptions); restore.TryRestore(gameKnowledge); Log.Info("Succesfully restored the original game libraries!"); break; default: throw new ArgumentException("Invalid verb processed"); } } catch (Exception e) { Log.Exception(EXCEPTION_MSG, e); goto ERROR; } // All OK return(0); ERROR: return(1); }
static int Main(string[] args) { bool succeeded = YanderePrepare.PrepareMod(); if (!succeeded) { Console.ReadLine(); return(0); } if (File.Exists(Environment.CurrentDirectory + "\\hooked")) { LaunchGame(); return(0); } string[] actions = CustomArgs(args); //Console.ReadLine(); // Operation string invokedOperation = ""; // General options. GeneralOptions generalOptions = null; // Options specific to the action to perform. object invokedOperationOptions = null; var opts = new Options(); // Must check for null, because the parser won't.. if (actions == null || actions.Length == 0) { Console.WriteLine(opts.GetUsage("help")); goto ERROR; } CommandLine.Parser.Default.ParseArgumentsStrict(actions, opts, (verb, subOptions) => { // Action to store correct information for further instructing the processor. invokedOperation = verb; invokedOperationOptions = subOptions; }, () => { // Failed attempt at parsing the provided arguments. Environment.Exit(-2); }); try { // Process general options generalOptions = (GeneralOptions)invokedOperationOptions; Prepare(generalOptions); } catch (Exception e) { Log.Exception(e.Message, e); goto ERROR; } // Use knowledge about the game HearthStone. Game knowledge is defined in the shared code // project KnowledgeBase. See `GameKnowledgeBase.HSKB` for more information. // Change the following line if you want to hook another game. var gameKnowledge = new GameKB(generalOptions.GamePath, new YandereSimulatorKB()); try { switch (invokedOperation) { case OPERATION_HOOK: Log.Info("Hooking operation started!\n"); var hookHelper = new HookHelper((HookSubOptions)invokedOperationOptions); hookHelper.TryHook(gameKnowledge); Log.Info("Hooked the game libraries!"); break; case OPERATION_RESTORE: Log.Info("Restore operation started!\n"); var restore = new Restore((RestoreSubOptions)invokedOperationOptions); restore.TryRestore(gameKnowledge); Log.Info("Restored the original game libraries!"); break; default: throw new ArgumentException("Invalid verb processed"); } } catch (Exception e) { Log.Exception(EXCEPTION_MSG, e); goto ERROR; } //Console.ReadLine(); // All OK if (args.Length == 0) { LaunchGame(); } return(0); ERROR: var tprocess = new System.Diagnostics.Process(); var tstartInfo = new System.Diagnostics.ProcessStartInfo { FileName = Environment.CurrentDirectory + "\\unhook.bat" }; tprocess.StartInfo = tstartInfo; tprocess.Start(); Console.ReadLine(); return(1); }
// Initialise the logger according to the options provided public Logger(GeneralOptions options) { DebugMode = options.DebugMode; SetupLogStream(options.LogFile); }