Code:
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace Dxovlay
{
public partial class Form1 : Form
{
internal struct Margins
{
public int Left;
public int Right;
public int Top;
public int Bottom;
}
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
public const string WINDOW_NAME = "Call of Duty®: BlackOps";//Call of Duty®: BlackOps
public const int GWL_EXSTYLE = -20;
public const int WS_EX_LAYERED = 524288;
public const int WS_EX_TRANSPARENT = 32;
public const int LWA_ALPHA = 2;
public const int LWA_COLORKEY = 1;
private Device device;
private static Microsoft.DirectX.Direct3D.Font font;
private static Microsoft.DirectX.Direct3D.Font fontSmall;
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
private static extern uint GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
[DllImport("user32.dll")]
private static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);
[DllImport("dwmapi.dll")]
private static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMargins);
public static RECT GetWindowRect(IntPtr hWnd)
{
RECT result = default(RECT);
GetWindowRect(hWnd, out result);
return result;
}
public IntPtr handle = FindWindow(null, "Call of Duty®: BlackOps");
public IntPtr selectedWindow;
private static Line line;
private static Line lineAA;
private Margins marg;
private void Overlay_Paint(object sender, PaintEventArgs e)
{
this.marg.Left = 0;
this.marg.Top = 0;
this.marg.Right = base.Width;
this.marg.Bottom = base.Height;
DwmExtendFrameIntoClientArea(base.Handle, ref this.marg);
}
private void Overlay_Load(object sender, EventArgs e)
{
base.Top = rect.top;
base.Left = rect.left;
this.timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
base.Top = rect.top;
base.Left = rect.left;
}
public Form1()
{
InitializeComponent();
RECT rect = GetWindowRect(handle);
selectedWindow = FindWindow(null, "Call of Duty®: BlackOps");
this.marg.Left = 0;
this.marg.Top = 0;
this.marg.Right = 0;
this.marg.Bottom = 0;
DwmExtendFrameIntoClientArea(handle, ref marg);
Paint += new PaintEventHandler(this.Overlay_Paint);
base.Size = new Size(rect.right - rect.left, rect.bottom - rect.top);
SetWindowLong(Handle, -20, (IntPtr)((long)((ulong)(GetWindowLong(base.Handle, -20)))));
SetLayeredWindowAttributes(base.Handle, 0, 255, 2);
this.components = new Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
base.SuspendLayout();
this.timer1.Interval = 86;
this.timer1.Tick += new EventHandler(this.timer1_Tick);
base.AutoScaleDimensions = new SizeF(6f, 13f);
base.AutoScaleMode = AutoScaleMode.Font;
FormBorderStyle = FormBorderStyle.Fixed3D;
this.BackColor = Color.Black;
base.ClientSize = new Size(284, 262);
base.FormBorderStyle = FormBorderStyle.None;
base.Name = "Overlay";
base.ShowIcon = false;
base.ShowInTaskbar = false;
this.Text = "Overlay";
base.TopMost = true;
base.TransparencyKey = Color.Black;
base.Load += new EventHandler(this.Overlay_Load);
base.Paint += new PaintEventHandler(this.Overlay_Paint);
base.ResumeLayout(false);
PresentParameters presentParameters = new PresentParameters();
presentParameters.Windowed = true;
presentParameters.SwapEffect = SwapEffect.Discard;
presentParameters.BackBufferFormat = Format.A8R8G8B8;
this.device = new Device(0, DeviceType.Hardware, base.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters[]
{
presentParameters
});
font = new Microsoft.DirectX.Direct3D.Font(this.device, new System.Drawing.Font("Microsoft Sans Serif", 12f, FontStyle.Bold));
fontSmall = new Microsoft.DirectX.Direct3D.Font(this.device, new System.Drawing.Font("Segoe UI", 15f, FontStyle.Bold));
line = new Line(this.device);
line.Antialias = false;
lineAA = new Line(this.device);
lineAA.Antialias = true;
new Thread(new ThreadStart(this.dxThread))
{
IsBackground = true
}.Start();
}
public static bool isRunning = true;
public RECT rect;
public static void DrawShadowText(string text, Point position, Color color, Color colorShadow)
{
fontSmall.DrawText((Sprite)null, text, new Point(position.X - 2, position.Y - 2), colorShadow);
fontSmall.DrawText((Sprite)null, text, position, color);
}
private void dxThread()
{
while (isRunning)
{
this.device.Clear(ClearFlags.Target, Color.FromArgb(0, 0, 0, 0), 1.0f, 0);
this.device.RenderState.ZBufferEnable = false;
this.device.RenderState.Lighting = false;
this.device.RenderState.CullMode = Cull.None;
this.device.Transform.Projection = Matrix.OrthoOffCenterLH(0.0f, (float)this.Width, (float)this.Height, 0.0f, 0.0f, 1f);
this.device.BeginScene();
GetWindowRect(this.handle, out rect);
this.selectedWindow = FindWindow((string)null, "Call of Duty®: BlackOps");//Call of Duty®: BlackOps
DrawShadowText("Fine workng DXD9", new Point(10, 30), Color.Green, Color.Black);
DrawShadowText("SOME TEXT", new Point(900, 950), Color.Blue, Color.Blue);
//if (Engine.globalStuffs.bEspMaster)
//{
// this.DrawEsp();
Thread.Sleep(10);
//}
this.device.EndScene();
this.device.Present();
}
this.device.Dispose();
Application.Exit();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
}
}
}