当前位置: 首页>>代码示例>>C#>>正文


C# Objects.LoggedIn方法代码示例

本文整理汇总了C#中System.Objects.LoggedIn方法的典型用法代码示例。如果您正苦于以下问题:C# Objects.LoggedIn方法的具体用法?C# Objects.LoggedIn怎么用?C# Objects.LoggedIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Objects的用法示例。


在下文中一共展示了Objects.LoggedIn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendPacketToClientByMemory

        public bool SendPacketToClientByMemory(Objects.Client client, byte[] packet)
        {
            bool ret = false;
            if (client.LoggedIn())
            {
                if (!client.IO.IsSendToClientCodeWritten)
                    if (!client.IO.WriteOnGetNextPacketCode()) return false;

                byte[] originalStream = client.Memory.ReadBytes(Pokemon.Addresses.Client.RecvStream, 12);

                IntPtr myStreamAddress = WinAPI.VirtualAllocEx(
                    client.Handle,
                    IntPtr.Zero,
                    (uint)packet.Length,
                    WinAPI.AllocationType.Commit | WinAPI.AllocationType.Reserve,
                    WinAPI.MemoryProtection.ExecuteReadWrite);
                if (myStreamAddress != IntPtr.Zero)
                {

                    if (client.Memory.WriteBytes(
                        myStreamAddress.ToInt64(),
                        packet,
                        (uint)packet.Length))
                    {
                        byte[] myStream = new byte[12];
                        Array.Copy(BitConverter.GetBytes(myStreamAddress.ToInt32()), myStream, 4);
                        Array.Copy(BitConverter.GetBytes(packet.Length), 0, myStream, 4, 4);

                        if (client.Memory.WriteBytes(Pokemon.Addresses.Client.RecvStream,
                            myStream, 12))
                        {
                            if (client.Memory.WriteByte(client.IO.SendToClientAddress.ToInt64(), 0x1))
                            {

                                IntPtr threadHandle = WinAPI.CreateRemoteThread(
                                                            client.Handle,
                                                            IntPtr.Zero,
                                                            0,
                                                            new IntPtr(Pokemon.Addresses.Client.ParserFunc),
                                                            IntPtr.Zero,
                                                            0,
                                                            IntPtr.Zero);
                                WinAPI.WaitForSingleObject(threadHandle, 0xFFFFFFFF);//INFINITE=0xFFFFFFFF
                                WinAPI.CloseHandle(threadHandle);

                                ret = true;
                                client.Memory.WriteByte(client.IO.SendToClientAddress.ToInt64(), 0x0);

                            }

                            client.Memory.WriteBytes(Pokemon.Addresses.Client.RecvStream,
                            originalStream, 12);
                        }

                    }
                }
                if (myStreamAddress != IntPtr.Zero)
                {
                    WinAPI.VirtualFreeEx(
                        client.Handle,
                        myStreamAddress,
                        12,
                        WinAPI.AllocationType.Release);
                }
            }
            return ret;
        }
开发者ID:FaNtA91,项目名称:pokemonapi,代码行数:67,代码来源:Packet.cs

示例2: SendPacketToServerByMemory

        // (http://www.tpforums.org/forum/showthread.php?t=2832)
        /// <summary>
        /// Send a packet through the client by writing some code in memory and running it.
        /// The packet must not contain any header(no length nor Adler checksum) and be unencrypted
        /// </summary>
        /// <param name="client"></param>
        /// <param name="packet"></param>
        /// <returns></returns>
        public static bool SendPacketToServerByMemory(Objects.Client client, byte[] packet)
        {
            if (client.LoggedIn())
            {
                if (!client.IO.IsSendToServerCodeWritten)
                    if (!client.IO.WriteSocketSendCode()) return false;

                uint bufferSize = (uint)(4 + msg.Length);
                byte[] readyPacket = new byte[bufferSize];
                Array.Copy(BitConverter.GetBytes(msg.Length), readyPacket, 4);
                Array.Copy(packet, 0, readyPacket, 4, packet.Length);

                IntPtr pRemote = WinAPI.VirtualAllocEx(client.Handle, IntPtr.Zero, /*bufferSize*/
                    bufferSize,
                    WinAPI.AllocationType.Commit | WinAPI.AllocationType.Reserve,
                    WinAPI.MemoryProtection.ExecuteReadWrite);

                if (pRemote != IntPtr.Zero)
                {
                    if (client.Memory.WriteBytes(pRemote.ToInt64(), readyPacket, bufferSize))
                    {
                        IntPtr threadHandle = Pokemon.Util.WinAPI.CreateRemoteThread(client.Handle, IntPtr.Zero, 0,
                            client.IO.SendToServerAddress, pRemote, 0, IntPtr.Zero);
                        Pokemon.Util.WinAPI.WaitForSingleObject(threadHandle, 0xFFFFFFFF);//INFINITE=0xFFFFFFFF
                        Pokemon.Util.WinAPI.CloseHandle(threadHandle);
                        return true;
                    }
                }
                return false;

            }
            else return false;
        }
开发者ID:FaNtA91,项目名称:pokemonapi,代码行数:41,代码来源:Packet.cs


注:本文中的System.Objects.LoggedIn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。