Guest User

Untitled

a guest
Aug 6th, 2014
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Runtime.InteropServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using Microsoft.DirectX;
  12. using Microsoft.DirectX.Direct3D;
  13. using System.Threading;
  14.  
  15. namespace DWH_Arma_2_OA
  16. {
  17.     public partial class Form1 : Form
  18.     {
  19.         private static Microsoft.DirectX.Direct3D.Font font;
  20.  
  21.         private Margins marg;
  22.         // This is used to specify the boundaries of the transparent area
  23.         internal struct Margins
  24.         {
  25.             public int Left, Right, Top, Bottom;
  26.         }
  27.  
  28.         [DllImport("user32.dll", SetLastError = true)]
  29.         private static extern UInt32 GetWindowLong(IntPtr hWnd, int nIndex);
  30.         [DllImport("user32.dll")]
  31.         static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
  32.         [DllImport("user32.dll")]
  33.  
  34.         static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);
  35.         public const int GWL_EXSTYLE = -20;
  36.         public const int WS_EX_LAYERED = 0x80000;
  37.         public const int WS_EX_TRANSPARENT = 0x20;
  38.         public const int LWA_ALPHA = 0x2;
  39.         public const int LWA_COLORKEY = 0x1;
  40.  
  41.         [DllImport("dwmapi.dll")]
  42.         static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMargins);
  43.         private Device device = null;
  44.  
  45.         public Form1()
  46.         {
  47.             InitializeComponent();
  48.             // Make the window's border completely transparant
  49.             SetWindowLong(Handle, GWL_EXSTYLE,
  50.                     (IntPtr)(GetWindowLong(Handle, GWL_EXSTYLE) ^ WS_EX_LAYERED ^ WS_EX_TRANSPARENT));
  51.  
  52.             // Set the Alpha on the Whole Window to 255 (solid)
  53.             SetLayeredWindowAttributes(Handle, 0, 255, LWA_ALPHA);
  54.  
  55.             // Init DirectX
  56.             // This initializes the DirectX device. It needs to be done once.
  57.             // The alpha channel in the backbuffer is critical.
  58.             PresentParameters presentParameters = new PresentParameters();
  59.             presentParameters.Windowed = true;
  60.             presentParameters.SwapEffect = SwapEffect.Discard;
  61.             presentParameters.BackBufferFormat = Format.A8R8G8B8;
  62.  
  63.             device = new Device(0, DeviceType.Hardware, Handle,
  64.             CreateFlags.HardwareVertexProcessing, presentParameters);
  65.  
  66.             font = new Microsoft.DirectX.Direct3D.Font(device, new System.Drawing.Font("Corbel", 9f, FontStyle.Regular));
  67.  
  68.             Thread dx = new Thread(new ThreadStart(dxThread));
  69.             dx.IsBackground = true;
  70.             dx.Start();
  71.         }
  72.  
  73.         public static void DrawShadowText(string text, Point Position, Color color)
  74.         {
  75.             font.DrawText(null, text, new Point(Position.X + 1, Position.Y + 1), Color.Black);
  76.             font.DrawText(null, text, Position, color);
  77.         }
  78.  
  79.         private void dxThread()
  80.         {
  81.             while (true)
  82.             {
  83.                 // Place your update logic here
  84.                 device.Clear(ClearFlags.Target, Color.FromArgb(0, 0, 0, 0), 1.0f, 0);
  85.                 device.RenderState.ZBufferEnable = false;
  86.                 device.RenderState.Lighting = false;
  87.                 device.RenderState.CullMode = Cull.None;
  88.                 device.Transform.Projection = Matrix.OrthoOffCenterLH(0, Width, Height, 0, 0, 1);
  89.                 device.BeginScene();
  90.  
  91.                 string TitleText = "DWH - Arma 2 OA Hack v1.0";
  92.                 DrawShadowText(TitleText, new Point(2, 2), Color.White);
  93.  
  94.                 // Place your rendering logic here
  95.                 device.EndScene();
  96.                 device.Present();
  97.             }
  98.             device.Dispose(); // Unreachable code detected
  99.             Application.Exit(); // Unreachable code detected
  100.         }
  101.  
  102.         private void DirectXOverlayForm_Paint(object sender, PaintEventArgs e)
  103.         {
  104.             // Create a margin (the whole form)
  105.             marg.Left = 0;
  106.             marg.Top = 0;
  107.             marg.Right = Width;
  108.             marg.Bottom = Height;
  109.  
  110.             // Expand the Aero Glass Effect Border to the WHOLE form.
  111.             // since we have already had the border invisible we now
  112.             // have a completely invisible window - apart from the DirectX
  113.             // renders NOT in black.
  114.             DwmExtendFrameIntoClientArea(Handle, ref marg);
  115.         }
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment