Esempio n. 1
0
        public InterfaceManager(Dalamud dalamud, SigScanner scanner)
        {
            this.dalamud = dalamud;

            try {
                var sigResolver = new SwapChainSigResolver();
                sigResolver.Setup(scanner);

                Log.Verbose("Found SwapChain via signatures.");

                Address = sigResolver;
            } catch (Exception ex) {
                // The SigScanner method fails on wine/proton since DXGI is not a real DLL. We fall back to vtable to detect our Present function address.
                Log.Error(ex, "Could not get SwapChain address via sig method, falling back to vtable...");

                var vtableResolver = new SwapChainVtableResolver();
                vtableResolver.Setup(scanner);

                Log.Verbose("Found SwapChain via vtable.");

                Address = vtableResolver;
            }

            var setCursorAddr = LocalHook.GetProcAddress("user32.dll", "SetCursor");

            Log.Verbose("===== S W A P C H A I N =====");
            Log.Verbose("SetCursor address {SetCursor}", setCursorAddr);
            Log.Verbose("Present address {Present}", Address.Present);
            Log.Verbose("ResizeBuffers address {ResizeBuffers}", Address.ResizeBuffers);

            this.setCursorHook = new Hook <SetCursorDelegate>(setCursorAddr, new SetCursorDelegate(SetCursorDetour), this);

            this.presentHook =
                new Hook <PresentDelegate>(Address.Present,
                                           new PresentDelegate(PresentDetour),
                                           this);

            this.resizeBuffersHook =
                new Hook <ResizeBuffersDelegate>(Address.ResizeBuffers,
                                                 new ResizeBuffersDelegate(ResizeBuffersDetour),
                                                 this);
        }
Esempio n. 2
0
        public InterfaceManager(Dalamud dalamud, SigScanner scanner)
        {
            this.dalamud = dalamud;

            this.fontBuildSignal = new ManualResetEvent(false);

            try {
                var sigResolver = new SwapChainSigResolver();
                sigResolver.Setup(scanner);

                Log.Verbose("Found SwapChain via signatures.");

                Address = sigResolver;
            } catch (Exception ex) {
                // The SigScanner method fails on wine/proton since DXGI is not a real DLL. We fall back to vtable to detect our Present function address.
                Log.Debug(ex, "Could not get SwapChain address via sig method, falling back to vtable...");

                var vtableResolver = new SwapChainVtableResolver();
                vtableResolver.Setup(scanner);

                Log.Verbose("Found SwapChain via vtable.");

                Address = vtableResolver;
            }

            try {
                var rtss = NativeFunctions.GetModuleHandle("RTSSHooks64.dll");

                if (rtss != IntPtr.Zero)
                {
                    var fileName = new StringBuilder(255);
                    NativeFunctions.GetModuleFileName(rtss, fileName, fileName.Capacity);
                    this.rtssPath = fileName.ToString();
                    Log.Verbose("RTSS at {0}", this.rtssPath);

                    if (!NativeFunctions.FreeLibrary(rtss))
                    {
                        throw new Win32Exception();
                    }
                }
            } catch (Exception e) {
                Log.Error(e, "RTSS Free failed");
            }


            var setCursorAddr = LocalHook.GetProcAddress("user32.dll", "SetCursor");

            Log.Verbose("===== S W A P C H A I N =====");
            Log.Verbose("SetCursor address {SetCursor}", setCursorAddr);
            Log.Verbose("Present address {Present}", Address.Present);
            Log.Verbose("ResizeBuffers address {ResizeBuffers}", Address.ResizeBuffers);

            this.setCursorHook = new Hook <SetCursorDelegate>(setCursorAddr, new SetCursorDelegate(SetCursorDetour), this);

            this.presentHook =
                new Hook <PresentDelegate>(Address.Present,
                                           new PresentDelegate(PresentDetour),
                                           this);

            this.resizeBuffersHook =
                new Hook <ResizeBuffersDelegate>(Address.ResizeBuffers,
                                                 new ResizeBuffersDelegate(ResizeBuffersDetour),
                                                 this);
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InterfaceManager"/> class.
        /// </summary>
        /// <param name="dalamud">The Dalamud instance.</param>
        /// <param name="scanner">The SigScanner instance.</param>
        public InterfaceManager(Dalamud dalamud, SigScanner scanner)
        {
            this.dalamud = dalamud;

            this.fontBuildSignal = new ManualResetEvent(false);

            try
            {
                var sigResolver = new SwapChainSigResolver();
                sigResolver.Setup(scanner);

                Log.Verbose("Found SwapChain via signatures.");

                this.address = sigResolver;
            }
            catch (KeyNotFoundException)
            {
                // The SigScanner method fails on wine/proton since DXGI is not a real DLL. We fall back to vtable to detect our Present function address.
                Log.Debug("Could not get SwapChain address via sig method, falling back to vtable");

                var vtableResolver = new SwapChainVtableResolver();
                vtableResolver.Setup(scanner);

                Log.Verbose("Found SwapChain via vtable.");

                this.address = vtableResolver;
            }

            try
            {
                var rtss = NativeFunctions.GetModuleHandleW("RTSSHooks64.dll");

                if (rtss != IntPtr.Zero)
                {
                    var fileName = new StringBuilder(255);
                    _             = NativeFunctions.GetModuleFileNameW(rtss, fileName, fileName.Capacity);
                    this.rtssPath = fileName.ToString();
                    Log.Verbose($"RTSS at {this.rtssPath}");

                    if (!NativeFunctions.FreeLibrary(rtss))
                    {
                        throw new Win32Exception();
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e, "RTSS Free failed");
            }

            this.setCursorHook = HookManager.DirtyLinuxUser ? null
                : Hook <SetCursorDelegate> .FromSymbol("user32.dll", "SetCursor", this.SetCursorDetour);

            this.presentHook       = new Hook <PresentDelegate>(this.address.Present, this.PresentDetour);
            this.resizeBuffersHook = new Hook <ResizeBuffersDelegate>(this.address.ResizeBuffers, this.ResizeBuffersDetour);

            var setCursorAddress = this.setCursorHook?.Address ?? IntPtr.Zero;

            Log.Verbose("===== S W A P C H A I N =====");
            Log.Verbose($"SetCursor address 0x{setCursorAddress.ToInt64():X}");
            Log.Verbose($"Present address 0x{this.presentHook.Address.ToInt64():X}");
            Log.Verbose($"ResizeBuffers address 0x{this.resizeBuffersHook.Address.ToInt64():X}");
        }