Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Microsoft.DirectX;
- using Microsoft.DirectX.Direct3D;
- using System.Threading;
- namespace DWH_Arma_2_OA
- {
- public partial class Form1 : Form
- {
- private static Microsoft.DirectX.Direct3D.Font font;
- private Margins marg;
- // This is used to specify the boundaries of the transparent area
- internal struct Margins
- {
- public int Left, Right, Top, Bottom;
- }
- [DllImport("user32.dll", SetLastError = true)]
- private static extern UInt32 GetWindowLong(IntPtr hWnd, int nIndex);
- [DllImport("user32.dll")]
- static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
- [DllImport("user32.dll")]
- static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);
- public const int GWL_EXSTYLE = -20;
- public const int WS_EX_LAYERED = 0x80000;
- public const int WS_EX_TRANSPARENT = 0x20;
- public const int LWA_ALPHA = 0x2;
- public const int LWA_COLORKEY = 0x1;
- [DllImport("dwmapi.dll")]
- static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMargins);
- private Device device = null;
- public Form1()
- {
- InitializeComponent();
- // Make the window's border completely transparant
- SetWindowLong(Handle, GWL_EXSTYLE,
- (IntPtr)(GetWindowLong(Handle, GWL_EXSTYLE) ^ WS_EX_LAYERED ^ WS_EX_TRANSPARENT));
- // Set the Alpha on the Whole Window to 255 (solid)
- SetLayeredWindowAttributes(Handle, 0, 255, LWA_ALPHA);
- // Init DirectX
- // This initializes the DirectX device. It needs to be done once.
- // The alpha channel in the backbuffer is critical.
- PresentParameters presentParameters = new PresentParameters();
- presentParameters.Windowed = true;
- presentParameters.SwapEffect = SwapEffect.Discard;
- presentParameters.BackBufferFormat = Format.A8R8G8B8;
- device = new Device(0, DeviceType.Hardware, Handle,
- CreateFlags.HardwareVertexProcessing, presentParameters);
- font = new Microsoft.DirectX.Direct3D.Font(device, new System.Drawing.Font("Corbel", 9f, FontStyle.Regular));
- Thread dx = new Thread(new ThreadStart(dxThread));
- dx.IsBackground = true;
- dx.Start();
- }
- public static void DrawShadowText(string text, Point Position, Color color)
- {
- font.DrawText(null, text, new Point(Position.X + 1, Position.Y + 1), Color.Black);
- font.DrawText(null, text, Position, color);
- }
- private void dxThread()
- {
- while (true)
- {
- // Place your update logic here
- device.Clear(ClearFlags.Target, Color.FromArgb(0, 0, 0, 0), 1.0f, 0);
- device.RenderState.ZBufferEnable = false;
- device.RenderState.Lighting = false;
- device.RenderState.CullMode = Cull.None;
- device.Transform.Projection = Matrix.OrthoOffCenterLH(0, Width, Height, 0, 0, 1);
- device.BeginScene();
- string TitleText = "DWH - Arma 2 OA Hack v1.0";
- DrawShadowText(TitleText, new Point(2, 2), Color.White);
- // Place your rendering logic here
- device.EndScene();
- device.Present();
- }
- device.Dispose(); // Unreachable code detected
- Application.Exit(); // Unreachable code detected
- }
- private void DirectXOverlayForm_Paint(object sender, PaintEventArgs e)
- {
- // Create a margin (the whole form)
- marg.Left = 0;
- marg.Top = 0;
- marg.Right = Width;
- marg.Bottom = Height;
- // Expand the Aero Glass Effect Border to the WHOLE form.
- // since we have already had the border invisible we now
- // have a completely invisible window - apart from the DirectX
- // renders NOT in black.
- DwmExtendFrameIntoClientArea(Handle, ref marg);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment