Esempio n. 1
0
        //Use this function to make a new one with cbSize already filled in.
        //For example:
        //var WndClss = WNDCLASSEX.Build()
        public static WNDCLASSEX Build()
        {
            var nw = new WNDCLASSEX();

            nw.cbSize = Marshal.SizeOf(typeof(WNDCLASSEX));
            return(nw);
        }
Esempio n. 2
0
        public void Create()
        {
            var swapChainVtable = new List <IntPtr>();

            var desc = new SwapChainDescription();

            var wc = new WNDCLASSEX()
            {
                cbSize        = Marshal.SizeOf(typeof(WNDCLASSEX)),
                style         = 0x0040, //CS_CLASSDC
                lpszClassName = " ",
                lpfnWndProc   = Marshal.GetFunctionPointerForDelegate(new WndProc(WndProcHelper))
            };

            RegisterClassEx(ref wc);

            /*if (wc.hInstance == IntPtr.Zero) {
             *  ModConsole.Print(Marshal.GetLastWin32Error().ToString());
             *  return;
             * }*/

            hwnd = CreateWindowEx(WindowStylesEx.WS_EX_OVERLAPPEDWINDOW, " ", "", WindowStyles.WS_OVERLAPPEDWINDOW, 5, 5, 7, 8, IntPtr.Zero, IntPtr.Zero, wc.hInstance, IntPtr.Zero);

            if (hwnd == IntPtr.Zero)
            {
                ModConsole.Print(Marshal.GetLastWin32Error().ToString());
                return;
            }
            SharpDX.Direct3D11.Device.CreateWithSwapChain(
                DriverType.Hardware,
                DeviceCreationFlags.Debug | DeviceCreationFlags.BgraSupport,
                CreateSwapChainDescription(hwnd),
                out device,
                out swapChain
                );

            swapChainVtable.AddRange(GetVTblAddresses(swapChain.NativePointer, DXGI_SWAPCHAIN_METHOD_COUNT));

            //8 = Present
            var present = swapChainVtable[8];

            originalFunc = (DXGISwapChain_PresentDelegate)Marshal.GetDelegateForFunctionPointer(present, typeof(DXGISwapChain_PresentDelegate));

            var hook = new DXGISwapChain_PresentDelegate(presentHandler);

            localHook = LocalHook.Create(present, hook, this);
            localHook.ThreadACL.SetExclusiveACL(new int[] { 0 });
        }
Esempio n. 3
0
 static extern short RegisterClassEx([In] ref WNDCLASSEX lpwcx);