public override void OnInstalled()
        {
            while (!this.Initialized)
            {
                foreach (var window in OpenWindowGetter.GetOpenWindows())
                {
                    var handle = window.Key;
                    var title  = window.Value;

                    if (title.StartsWith("Endless Online"))
                    {
                        this.Initialized = true;

                        this.EndlessHandle = handle;
                        this.EndlessTitle  = title;
                    }
                }

                Thread.Sleep(100);
            }

            this.EOPacketManager = new EOPacketManager(this);
            this.NetworkDetour   = new NetworkDetour().Install(PacketChannel.Send | PacketChannel.WSARecv, new InterceptCallback((packet) => {
                if (packet.Destination.Port == 8076 || packet.Destination.Port == 0)
                {
                    return(new InterceptResponse(false));
                }

                if (!this.EOPacketInit)
                {
                    if (packet.Channel == PacketChannel.WSARecv)
                    {
                        var decode = new OldPacket(packet.Buffer.Skip(2));

                        if (decode.Family != PacketFamily.Init || decode.Action != PacketAction.Init)
                        {
                            return(new InterceptResponse(false));
                        }

                        this.EOPacketInit = true;
                        decode.Skip(3);

                        this.EOPacketManager.SetMultiples(decode.GetByte(), decode.GetByte());
                    }

                    return(new InterceptResponse(false));
                }

                var channel = packet.Channel == PacketChannel.Send ? EOPacketChannel.Send : EOPacketChannel.Receive;
                this.EOPacketManager.HandlePacket(channel, packet.Buffer.Skip(2));

                return(new InterceptResponse(false));
            }));

            Thread.Sleep(1000);

            EasyTimer.SetInterval(() => {
                if (this.IsMovingWindow)
                {
                    RepositionMarketWindow();
                }
            }, 16);

            EasyTimer.SetInterval(() => {
                if (Program.Market.Visible)
                {
                    SetWindowPos(Program.Market.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
                    RepositionMarketWindow();
                }
            }, 5000);

            Program.Market.Load += (s, e) => {
                var threadId = GetWindowThreadProcessId(this.EndlessHandle, out var processId);
                this.CBTCallback = this.CBT_Callback;
                this.CBTHook     = SetWindowsHookEx(HookType.WH_CBT, CBTCallback, instancePtr: IntPtr.Zero, threadID: threadId);

                SetWindowPos(Program.Market.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
                RepositionMarketWindow();
            };

            Program.Market.Shown += (s, e) => {
                SetWindowPos(Program.Market.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
                RepositionMarketWindow();
            };

            Program.Market.VisibleChanged += (s, e) => {
                if (Program.Market.Visible)
                {
                    SetWindowPos(Program.Market.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
                    RepositionMarketWindow();
                }
            };

            Program.Market.Hide();
            Application.EnableVisualStyles();

            new Thread(() => {
                Application.Run();
            }).Start();
        }
Example #2
0
 public static extern IntPtr SetWindowsHookEx(HookType hookType, CBTProc hookProc, IntPtr instancePtr, uint threadID);
 internal static extern IntPtr SetWindowsHookEx(Int32 idHook, CBTProc lpfn, IntPtr hMod, Int32 dwThreadId);
Example #4
0
 internal static extern IntPtr SetWindowsHookEx(Int32 idHook, CBTProc lpfn, IntPtr hMod, Int32 dwThreadId);
 public HookingClass()
 {
     _callbackDelegate = CallbackFunction;
 }
Example #6
0
 public static extern int SetWindowsHookEx(int idHook, CBTProc lpfn,
                                           IntPtr hInstance, int threadId);
Example #7
0
 public static extern int SetWindowsHookEx(int idHook, CBTProc lpfn,
 IntPtr hInstance, int threadId);