public static void Main(string[] args) { Process process = Process.GetProcessesByName("PathOfExile").FirstOrDefault <Process>(); if (process == null) { MessageBox.Show("Path of Exile is not running!"); return; } Sounds.LoadSounds(); if (!Settings.LoadSettings()) { return; } using (Memory memory = new Memory(process.Id)) { Offsets.DoPatternScans(memory); PathOfExile pathOfExile = new PathOfExile(memory); pathOfExile.Update(); OverlayRenderer overlay = null; AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs exceptionArgs) { if (overlay != null) { overlay.Detach(); } MessageBox.Show("Program exited with message:\n " + exceptionArgs.ExceptionObject.ToString()); Environment.Exit(1); }; try { Console.WriteLine("Starting overlay"); TransparentDXOverlay transparentDXOverlay = new TransparentDXOverlay(pathOfExile.Window); transparentDXOverlay.InitD3D(); overlay = new OverlayRenderer(pathOfExile, transparentDXOverlay.RC); Application.Run(transparentDXOverlay); } finally { if (overlay != null) { overlay.Detach(); } } } }
private void TransparentDXOverlay_Load(object sender, EventArgs e) { Console.WriteLine("SetWindowLong: " + TransparentDXOverlay.SetWindowLong(base.Handle, -20, (IntPtr)((long)((ulong)(TransparentDXOverlay.GetWindowLong(base.Handle, -20) | 524288u | 32u))))); Console.WriteLine("SetWindowLong error: " + Marshal.GetLastWin32Error()); TransparentDXOverlay.SetLayeredWindowAttributes(base.Handle, 0u, 255, 2u); Rect rect = this.window.ClientRect(); this.marg.Left = rect.X; this.marg.Top = rect.Y; this.marg.Right = rect.X + rect.W; this.marg.Bottom = rect.Y + rect.H; IntPtr intPtr = TransparentDXOverlay.DwmExtendFrameIntoClientArea(base.Handle, ref this.marg); Console.WriteLine("DwmExtendFrameIntoClientArea: " + intPtr); base.Bounds = new Rectangle(rect.X, rect.Y, rect.W, rect.H); TransparentDXOverlay.CurrentHandle = base.Handle; this.dxThread = new Thread(new ThreadStart(this.DxLoop)); this.dxThread.IsBackground = true; this.dxThread.Start(); }