コード例 #1
0
        public static void RegisterDeclaringType(RuntimeTypeHandle typeHandle)
        {
            string message = string.Format("Registering parent generic type `{0}`", typeHandle.ToString());

            HookRegistry.Get().Log(message);
            HookRegistry.Get().declaringTypes.Add(typeHandle);
        }
コード例 #2
0
        private object ProxyCall(object thisObj, object[] args)
        {
            object retValue = null;

            try
            {
                // Get the GetGlobalType static method.
                var method = TypeReflectionUtils.GetMethod("GetGlobalType",
                                                           BindingFlags.Static | BindingFlags.Public);
                // Invoke it.
                retValue = method.Invoke(null, args);
            }
            catch (TargetInvocationException e)
            {
                var reflException = e.InnerException;
                var msg           = string.Format("Error in `HutongGames.PlayMaker.ReflectionUtils::GetGlobalType` for param {0}",
                                                  args[0]);
                HookRegistry.Get().Log(msg);
                HookRegistry.Get().Log(e.ToString());

                if (reflException is ReflectionTypeLoadException)
                {
                    HookRegistry.Get().Log("Dumping all types that were tried loading:");
                    var strTypes  = "";
                    var typeArray = (reflException as ReflectionTypeLoadException).Types;
                    foreach (var tp in typeArray)
                    {
                        if (tp == null)
                        {
                            strTypes += "NULL - ERROR\n";
                        }
                        else
                        {
                            strTypes += tp.FullName + "\n";
                        }
                    }
                    HookRegistry.Get().Log(strTypes);


                    HookRegistry.Get().Log("Dumping all loaded assemblies:");
                    var strAssemblies = "";
                    var allAssemblies = AppDomain.CurrentDomain.GetAssemblies();
                    foreach (var assembly in allAssemblies)
                    {
                        strAssemblies += assembly.FullName + "\n";
                    }
                    HookRegistry.Get().Log(strAssemblies);
                }
            }

            return(retValue);
        }
コード例 #3
0
ファイル: IncomingPackets.cs プロジェクト: zfz12345/UnityHook
        // Dumps the current packet onto the tee stream.
        // The packet has to be reconstructed according to the rules found in the respective
        // encoding(..) method.
        private void DumpPacket(string typeName, object thisObj)
        {
            // Object that does the duplication of packets.
            var dumper = DumpServer.Get();

            // the name of the packet is retrievable in generalized form.
            Type packetType = thisObj.GetType();
            // More packet specific details.
            string packetTypeString = packetType.Name;
            int    methodID         = -1;
            int    serviceID        = -1;

            if (packetType.Equals(typeof(BattleNetPacket)))
            {
                var packet = ((BattleNetPacket)thisObj);

                // Debug information
                bnet.protocol.Header header = packet.GetHeader();
                methodID  = (int)header.MethodId;
                serviceID = (int)header.ServiceId;

                byte[] packetData = DumpServer.SerializePacket(packet);
                dumper.SendPacket(PacketType.Battlenetpacket, PacketDirection.Incoming, 0, packetData);
            }
            else if (packetType.Equals(typeof(PegasusPacket)))
            {
                var packet = ((PegasusPacket)thisObj);

                // Debug information
                serviceID = packet.Type;

                byte[] packetData = DumpServer.SerializePacket(packet);
                dumper.SendPacket(PacketType.Pegasuspacket, PacketDirection.Incoming, 0, packetData);
            }
            else
            {
                // Returning false here would just introduce undefined behaviour
                HookRegistry.Panic("Unknown packet type!");
            }

            string message = string.Format(RECEIVED_PACKET_NOTIFY, packetTypeString, serviceID, methodID);

            HookRegistry.Get().Internal_Log(message);
        }
コード例 #4
0
ファイル: OutgoingPackets.cs プロジェクト: zfz12345/UnityHook
        // Dump data just as we receive it.
        private void DumpPacket(string typeName, object[] args)
        {
            // Object that does the duplication of packets.
            var dumper = DumpServer.Get();

            object packetObj  = args[0];
            Type   packetType = packetObj.GetType();

            string packetTypeString = packetType.Name;
            int    methodID         = -1;
            int    serviceID        = -1;
            object body             = null;

            if (packetType.Equals(typeof(BattleNetPacket)))
            {
                var packet = ((BattleNetPacket)packetObj);

                // Debug information
                bnet.protocol.Header header = packet.GetHeader();
                methodID  = (int)header.MethodId;
                serviceID = (int)header.ServiceId;
                body      = packet.GetBody();

                // Calculate the hash of the body, which is passed to analyzers.
                uint bodyHash = Util.GenerateHashFromObjectType(body);

                byte[] packetData = DumpServer.SerializePacket(packet);
                dumper.SendPacket(PacketType.Battlenetpacket, PacketDirection.Outgoing, bodyHash, packetData);

                // Test for LogonRequest body packet, since that one contains the version string
                var logonRequest = body as LogonRequest;
                if (logonRequest != null)
                {
                    dumper.InitialiseHandshake(logonRequest.Version);
                }
            }
            else if (packetType.Equals(typeof(PegasusPacket)))
            {
                var packet = ((PegasusPacket)packetObj);

                // Debug information
                serviceID = packet.Type;
                body      = packet.GetBody();

                // Calculate the hash of the body, which is passed to analyzers.
                uint bodyHash = Util.GenerateHashFromObjectType(body);

                byte[] packetData = DumpServer.SerializePacket(packet);
                dumper.SendPacket(PacketType.Pegasuspacket, PacketDirection.Outgoing, bodyHash, packetData);
            }
            else
            {
                // Returning false here would just introduce undefined behaviour
                HookRegistry.Panic("Unknown packet type!");
            }

            string message = string.Format(SENT_PACKET_NOTIFY, packetTypeString, serviceID, methodID,
                                           body.GetType().FullName);

            HookRegistry.Get().Internal_Log(message);
        }
コード例 #5
0
 // Remove a hook listener
 public static void Unregister(Callback cb)
 {
     HookRegistry.Get().callbacks.Remove(cb);
 }
コード例 #6
0
 // Add a hook listener
 public static void Register(Callback cb)
 {
     HookRegistry.Get().callbacks.Add(cb);
 }
コード例 #7
0
 // First function called by modified libraries.
 // Return the response coming from the hook, because it's needed by the original library code   ! important
 public static object OnCall(RuntimeMethodHandle rmh, object thisObj, object[] args)
 {
     return(HookRegistry.Get().Internal_OnCall(rmh, thisObj, args));
 }
コード例 #8
0
        object OnCall(string typeName, string methodName, object thisObj, object[] args, IntPtr[] refArgs, int[] refIdxMatch)
        {
            switch (typeName + "::" + methodName)
            {
            case "UILoader::OnInit":
                HookRegistry.Get().CtrlServer.Start();
                return(null);

            case "UILoader::OnRelease":
                HookRegistry.Get().CtrlServer.Stop();
                return(null);

            case "Pathea.RiderNs.RidableModuleManager::TryDecreaseLoyalty":                     //忠诚不减
                return(false);

            case "Pathea.EG.EGMgr::StartEngagement":                    // 约会/玩耍直接满
            {
                var egMgr = (EGMgr)thisObj;
                if (egMgr.IsEngagement())
                {
                    var th = new Thread(() => {
                            HookRegistry.Debug("[StartEngagement] wait 3 second");
                            Thread.Sleep(3000);
                            var mDate = (EGDate)HookRegistry.GetInstanceField(typeof(EGMgr), thisObj, "mDate");
                            mDate.SetMood(100);
                            HookRegistry.Debug("[StartEngagement] set mood {0}", mDate.GetMood());
                        });
                    th.Start();
                }
            }
                return(null);

            case "Pathea.EG.EGMgr::StopEngagement":                     //取消嫉妒
                if ((EGStopType)args[0] == EGStopType.Jealous)
                {
                    return(false);
                }
                else
                {
                    return(null);
                }

            case "Pathea.FavorSystemNs.FavorUtility::GetFavorBehaviorInfo":                     //玫瑰花1颗心
                if ((int)args[1] == 7000016)
                {
                    return(new GiveGiftResult("75", 100, FeeLevelEnum.Excellent, GiftType.Normal));
                }
                else
                {
                    return(null);
                }

            default:
                return(null);
            }


            try
            {
            }
            catch (Exception e)
            {
                // Write meaningful information to the game output.
                string message = String.Format(HOOK_FAILED, e.Message);
                HookRegistry.Panic(message);
            }

            // Never return null after typeName check!
            return((object)true);
        }
コード例 #9
0
ファイル: HookRegistry.cs プロジェクト: jakibaki/UnityHook
 public static void RegisterDeclaringType(RuntimeTypeHandle typeHandle)
 {
     HookRegistry.Get().declaringTypes.Add(typeHandle);
 }