Exemplo n.º 1
0
        private void PrepareDynamicCalls()
        {
            // Prepare dynamic call to CSharp-firstpass library
            // Load from assembly file at currently executing path
            var      fistPLibPath = HSKB.Get().GetAssemblyPath((int)HSKB.LIB_TYPE.LIB_CSHARP_FIRSTPASS);
            Assembly libAssembly  = Assembly.LoadFrom(fistPLibPath);

            TypeSslParams  = libAssembly.GetType("bgs.SslParameters");
            TypeBattleNetC = libAssembly.GetType("bgs.BattleNetCSharp");
        }
Exemplo n.º 2
0
        private void Init()
        {
            // All necessary libraries should be next to this assembly file.
            // GetExecutingAssembly does not always give the desired effect. In case of dynamic invocation
            // it will return the location of the Assembly DOING the incovation!
            var assemblyPath    = Assembly.GetExecutingAssembly().Location;
            var assemblyDirPath = Path.GetDirectoryName(assemblyPath);

            // Initialise the game knowledge database with the discovered path.
            HSKB.Get(assemblyDirPath);
        }
Exemplo n.º 3
0
        private void PrepareDynamicCalls()
        {
            // Prepare dynamic call to CSharp-firstpass library
            // Load from assembly file at currently executing path
            var      fistPLibPath = HSKB.Get().GetAssemblyPath((int)HSKB.LIB_TYPE.LIB_CSHARP_FIRSTPASS);
            Assembly libFirstPass = Assembly.LoadFrom(fistPLibPath);

            TypeBattleNetPacket = libFirstPass.GetType("bgs.BattleNetPacket");
            TypeBattleNetHeader = libFirstPass.GetType("bnet.protocol.Header");

            var      libPath = HSKB.Get().GetAssemblyPath((int)HSKB.LIB_TYPE.LIB_CSHARP);
            Assembly lib     = Assembly.LoadFrom(libPath);

            TypePegasusPacket = lib.GetType("PegasusPacket");
        }
Exemplo n.º 4
0
        // Load necessary types for dynamic method calls
        private void PrepareDynamicCalls()
        {
            // Prepare dynamic call to Unity
            var      unityLibPath  = HSKB.Get().GetAssemblyPath((int)HSKB.LIB_TYPE.UNITY_ENGINE);
            Assembly unityAssembly = Assembly.LoadFrom(unityLibPath);
            var      unityType     = unityAssembly.GetType("UnityEngine.Debug");

            _LogMethod = unityType.GetMethod("Log", BindingFlags.Static | BindingFlags.Public,
                                             Type.DefaultBinder, new Type[] { typeof(string) }, null);

            var unityApplication = unityAssembly.GetType("UnityEngine.Application");
            var isPlayingProp    = unityApplication.GetProperty("isPlaying",
                                                                BindingFlags.Static | BindingFlags.Public);

            // Silently fail if we cannot determing if we are running within the Unity engine or not!
            // If the property is not found _IsInGameMethod stays null.
            if (isPlayingProp != null)
            {
                _IsInGameMethod = isPlayingProp.GetGetMethod();
            }
        }
Exemplo n.º 5
0
        private void PrepareDynamicCalls()
        {
            // Prepare dynamic call to CSharp-firstpass library
            // Load from assembly file at currently executing path
            var      fistPLibPath = HSKB.Get().GetAssemblyPath((int)HSKB.LIB_TYPE.LIB_CSHARP_FIRSTPASS);
            Assembly libFirstPass = Assembly.LoadFrom(fistPLibPath);

            TypeBattleNetPacket = libFirstPass.GetType("bgs.BattleNetPacket");

            TypeSslConnection    = libFirstPass.GetType("bgs.SslClientConnection");
            TypeClientConnection = libFirstPass.GetType("bgs.ClientConnection`1");

            var      libPath = HSKB.Get().GetAssemblyPath((int)HSKB.LIB_TYPE.LIB_CSHARP);
            Assembly lib     = Assembly.LoadFrom(libPath);

            TypePegasusPacket = lib.GetType("PegasusPacket");

            // Construct generic substituted types
            TypePegasusConnection   = TypeClientConnection.MakeGenericType(new Type[] { TypePegasusPacket });
            TypeBattleNetConnection = TypeClientConnection.MakeGenericType(new Type[] { TypeBattleNetPacket });
        }
Exemplo n.º 6
0
        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);
        }