Esempio n. 1
0
        /// <summary>
        /// Copies Crosire's D3D8To9 and hooks the DX9 device creation.
        /// </summary>
        /// <param name="dllDirectory">Directory containing Crosire's d3d8to9.</param>
        public void HookDevice(string dllDirectory)
        {
            // Copy crosire's d3d8to9 to game directory and then load it. (Game should use D3D9 now).
            if (!File.Exists("d3d8.dll"))
            {
                File.Copy(dllDirectory + $"\\d3d8.dll", "d3d8.dll", true);
            }

            // Load Crosire's D3D8To9 (which in turn loads D3D9 internally)
            LoadLibraryW("d3d8.dll");

            // Get our D3D Interface VTable
            using (Direct3D direct3D = new Direct3D())
                using (Form renderForm = new Form())
                    using (SharpDX.Direct3D9.Device device = new SharpDX.Direct3D9.Device(direct3D, 0, DeviceType.NullReference, IntPtr.Zero, CreateFlags.HardwareVertexProcessing, new PresentParameters()
                    {
                        BackBufferWidth = 1, BackBufferHeight = 1, DeviceWindowHandle = renderForm.Handle
                    }))
                    {
                        _direct3DVirtualFunctionTable       = new VirtualFunctionTable(direct3D.NativePointer, Enum.GetNames(typeof(Interfaces.IDirect3D9)).Length);
                        _direct3DDeviceVirtualFunctionTable = new VirtualFunctionTable(device.NativePointer, Enum.GetNames(typeof(Interfaces.IDirect3DDevice9)).Length);
                    }

            // Hook D3D9 device creation.
            _createDeviceHook = _direct3DVirtualFunctionTable.TableEntries[(int)Interfaces.IDirect3D9.CreateDevice].CreateFunctionHook86 <CreateDevice>(CreateDeviceImpl).Activate();
            //_resetDeviceHook = _direct3DDeviceVirtualFunctionTable.TableEntries[(int)Interfaces.IDirect3DDevice9.Reset].CreateFunctionHook86<Direct3D9DeviceResetDelegate>(ResetDeviceImpl).Activate();
        }
Esempio n. 2
0
        /// <summary>
        /// Your own user code starts here.
        /// If this is your first time, do consider reading the notice above.
        /// It contains some very useful information.
        /// </summary>
        public static void Init()
        {
            /*
             *  Reloaded Mod Loader Utility: Steam Hook
             *  Architectures supported: X86, X64
             *
             *  Hooks the Steam function responsible for checking if the game should be
             *  restarted and just says "no, it shouldn't".
             */

            #if DEBUG
            Debugger.Launch();
            #endif

            // PS. I know the code below could be written better, but I wrote it FOR CLARITY.
            // Get directory of executing executable.
            string steamAPI32 = Path.GetFullPath(SteamAPI32);
            string steamAPI64 = Path.GetFullPath(SteamAPI64);

            // X86
            if (IntPtr.Size == 4)
            {
                if (File.Exists(steamAPI32))
                {
                    // Load file and get address of export.
                    IntPtr libraryAddress           = Native.LoadLibraryW(steamAPI32);
                    IntPtr restartAppIfNecessaryPtr = Native.GetProcAddress(libraryAddress, FunctionName);

                    // Hook!
                    if (restartAppIfNecessaryPtr != IntPtr.Zero)
                    {
                        restartIfNecessaryHook32 = FunctionHook <SteamAPI_RestartAppIfNecessary>
                                                   .Create((long)restartAppIfNecessaryPtr, FunctionDelegate).Activate();
                    }
                }
            }

            // X64
            if (IntPtr.Size == 8)
            {
                if (File.Exists(steamAPI64))
                {
                    // Load file and get address of export.
                    IntPtr libraryAddress           = Native.LoadLibraryW(steamAPI64);
                    IntPtr restartAppIfNecessaryPtr = Native.GetProcAddress(libraryAddress, FunctionName);

                    // If the debugger tells you that those two numbers are 0, it's bullshit.
                    // It's a debugger bug, you'll see it right after the next if statement.

                    // Hook!
                    if (restartAppIfNecessaryPtr != IntPtr.Zero)
                    {
                        restartIfNecessaryHook64 = X64FunctionHook <SteamAPI_RestartAppIfNecessary>
                                                   .Create((long)restartAppIfNecessaryPtr, FunctionDelegate).Activate();
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// For class definition, see Class Summary <see cref="MemoryTracer"/>.
        /// Hooks Sonic Heroes' free & malloc functions and exposes delegates which
        /// you may use to either alter the parameters of the function or act.
        /// </summary>
        public MemoryTracer()
        {
            // Hook the game functions.
            _mallocHook = FunctionHook <Malloc> .Create(0x0067B475, MallocHookImpl).Activate();

            _freeHook = FunctionHook <Free> .Create(0x0067B35D, FreeHookImpl).Activate();

            MallocFunction = _mallocHook.OriginalFunction;
            FreeFunction   = _freeHook.OriginalFunction;
        }
Esempio n. 4
0
            protected override IDisposable[] RequestHooks()
            {
                delegate * unmanaged <void *, void *, int, void> pSignalMeleeDamageHook = &OnSignalMeleeDamage;
                signalMeleeDamageHook = HookService.RequestHook <SignalMeleeDamageHook>(pSignalMeleeDamageHook, FunctionsLinux._ZN12CNWSCreature17SignalMeleeDamageEP10CNWSObjecti, HookOrder.Late);

                delegate * unmanaged <void *, void *, int, void> pSignalRangedDamageHook = &OnSignalRangedDamage;
                signalRangedDamageHook = HookService.RequestHook <SignalRangedDamageHook>(pSignalRangedDamageHook, FunctionsLinux._ZN12CNWSCreature18SignalRangedDamageEP10CNWSObjecti, HookOrder.Late);

                return(new IDisposable[] { signalMeleeDamageHook, signalRangedDamageHook });
            }
Esempio n. 5
0
            protected override IDisposable[] RequestHooks()
            {
                delegate * unmanaged <void *, int, int> pSetListAcceptedHook = &OnSetListAccepted;
                setListAcceptedHook = HookService.RequestHook <SetListAcceptedHook>(pSetListAcceptedHook, FunctionsLinux._ZN10CNWSBarter15SetListAcceptedEi, HookOrder.Earliest);

                delegate * unmanaged <void *, uint, uint, int, int> pSendServerToPlayerBarterCloseBarterHook = &OnSendServerToPlayerBarterCloseBarter;
                sendServerToPlayerBarterCloseBarterHook = HookService.RequestHook <SendServerToPlayerBarterCloseBarterHook>(pSendServerToPlayerBarterCloseBarterHook, FunctionsLinux._ZN11CNWSMessage35SendServerToPlayerBarterCloseBarterEjji, HookOrder.Earliest);

                return(new IDisposable[] { setListAcceptedHook, sendServerToPlayerBarterCloseBarterHook });
            }
Esempio n. 6
0
        /// <summary>
        /// Your own user code starts here.
        /// If this is your first time, do consider reading the notice above.
        /// It contains some very useful information.
        /// </summary>
        public static void Init()
        {
            /*
             *  Reloaded Mod Loader Sample: File Redirector (New)
             *  Architectures supported: X86, X64
             *
             *  This sample mod builds upon the File Monitor sample, providing universal file redirection for modifications
             *  which implement a `Plugins/Redirector/` folder.
             *
             *  This is the same NtCreateFile hook as seen in the monitor, except that, we instead build
             *  a list of files present within enabled mods' `Plugins/Redirector/` folder and build a dictionary mapping
             *  a path to path.
             *
             *  In our hooks, we just check if the file path exists in the dictionary, and override it if so.
             */

            // Debugger.Launch();

            // This should automatically resolve to ntdll.dll as it is already registered by Windows.
            // The handle should return from already loaded library in memory, following the standard search strategy.
            IntPtr ntdllHandle = Reloaded.Process.Native.Native.LoadLibraryW("ntdll");

            // Get the addresses of our desired NtCreateFile
            IntPtr ntCreateFilePointer = Reloaded.Process.Native.Native.GetProcAddress(ntdllHandle, "NtCreateFile");

            // Retreieve all enabled mods using utility functions in libReloaded.
            _currentGameConfig = GameConfig.GetGameConfigFromExecutablePath(ExecutingGameLocation);
            _enabledMods       = GameConfig.GetAllEnabledMods(_currentGameConfig);
            _enabledMods       = GameConfig.TopologicallySortConfigurations(_enabledMods);

            // Generate a list of new filesystemwatchers which will let us monitor redirector folders in real time.
            _fileSystemWatcherDictionary = new Dictionary <ModConfig, FileSystemWatcher>();

            // Build a dictionary of enabled mods.
            BuildFileRedirectionDictionary(_enabledMods, _currentGameConfig);

            // Hook the obtained function pointers.

            // X86
            if (IntPtr.Size == 4)
            {
                if (ntCreateFilePointer != IntPtr.Zero)
                {
                    _ntCreateFileHook = FunctionHook <NtCreateFile> .Create((long)ntCreateFilePointer, NtCreateFileImpl).Activate();
                }
            }
            // X64
            else if (IntPtr.Size == 8)
            {
                if (ntCreateFilePointer != IntPtr.Zero)
                {
                    _ntCreateFileHook64 = X64FunctionHook <NtCreateFile> .Create((long)ntCreateFilePointer, NtCreateFileImpl).Activate();
                }
            }
        }
Esempio n. 7
0
        public FunctionHook <T> CreateHook <T>(MemoryOffset offset, string name, T hook)
            where T : Delegate
        {
            var address  = Memory.ToAddress(offset);
            var original = Marshal.GetDelegateForFunctionPointer <T>(address);
            var fh       = new FunctionHook <T>(address, name, original, hook);

            _hooks.Add(fh);

            return(fh);
        }
Esempio n. 8
0
        public PresentHook(CppObject swapChain)
        {
            _presentHook = new FunctionHook <Present>(
                VirtualTableAddress.GetVtableAddress(swapChain.NativePointer, (int)VirtualTableIndices.DxgiSwapChain.Present),
                new Present(OnPresent),
                this);

            // This is not the SwapChain we're looking for...
            swapChain.Dispose();

            _presentHook.Activate();
        }
Esempio n. 9
0
        /// <summary>
        /// Your own user code starts here.
        /// If this is your first time, do consider reading the notice above.
        /// It contains some very useful information.
        /// </summary>
        public static void Init()
        {
            /*
             *  Reloaded Mod Loader Sample: File Monitor
             *  Architectures supported: X86, X64
             *
             *  Gets our Windows API function pointers by first grabbing a handle to Kernel32 where
             *  the individual functions are located and then calling the GetProcAddress() Windows API
             *  function in order to obtain the address of the exported functions.
             *
             *  We then hook the functions using the Reloaded Hooking classes, print to console the fileName
             *  parameter and redirect to the original functions.
             */

            // Debugger.Launch();

            // This should automatically resolve to kernel32.dll as it is already registered by Windows.
            // The handle should return from already loaded library in memory, following the standard search strategy.
            IntPtr kernel32Handle = Reloaded.Process.Native.Native.LoadLibraryW("kernel32");

            // Get the addresses of the CreateFileA, CreateFileW, CreateFile functions.
            IntPtr createFileAPointer = Reloaded.Process.Native.Native.GetProcAddress(kernel32Handle, "CreateFileA");
            IntPtr createFileWPointer = Reloaded.Process.Native.Native.GetProcAddress(kernel32Handle, "CreateFileW");

            // Hook the obtained function pointers.

            // X86
            if (IntPtr.Size == 4)
            {
                if (createFileWPointer != IntPtr.Zero)
                {
                    _createFileWHook = FunctionHook <CreateFileW> .Create((long)createFileWPointer, CreateFileWImpl).Activate();
                }
                if (createFileAPointer != IntPtr.Zero)
                {
                    _createFileAHook = FunctionHook <CreateFileA> .Create((long)createFileAPointer, CreateFileAImpl).Activate();
                }
            }
            // X64
            else if (IntPtr.Size == 8)
            {
                if (createFileWPointer != IntPtr.Zero)
                {
                    _createFileWHook64 = X64FunctionHook <CreateFileW> .Create((long)createFileWPointer, CreateFileWImpl).Activate();
                }
                if (createFileAPointer != IntPtr.Zero)
                {
                    _createFileAHook64 = X64FunctionHook <CreateFileA> .Create((long)createFileAPointer, CreateFileAImpl).Activate();
                }
            }
        }
Esempio n. 10
0
        public DrawIndexedHook(DeviceContext deviceContext, DepthStencilState depthDisabledState, Shaders shaders)
        {
            _deviceContext      = deviceContext;
            _depthDisabledState = depthDisabledState;
            _shaders            = shaders;
            _modelsInScene      = new List <ModelInfo>();
            SavedModels         = new List <ModelInfo>();

            _drawIndexedHook = new FunctionHook <DrawIndexed>(
                VirtualTableAddress.GetVtableAddress(_deviceContext.NativePointer, (int)VirtualTableIndices.D3D11DeviceContext.DrawIndexed),
                new DrawIndexed(OnDrawIndexed),
                this);

            _drawIndexedHook.Activate();
        }
Esempio n. 11
0
        /// <summary>
        /// Instantiates the DirectX overlay, by first finding the applicable
        /// version of DirectX for the application and then finding the individual
        /// details. For more details, see <see cref="DX11Overlay"/>
        ///
        /// Note: The delegates you will need to call the original function are members of this class, see <see cref="PresentHook"/> and <see cref="ResizeTargetHook"/>
        /// Note: This method is blocking and Reloaded mods are required to return in order
        /// to boot up the games, please do not assign this statically - instead assign it in a background thread!
        /// </summary>
        /// <param name="DXGIPresentDelegate">
        ///     A delegate type to use for DirectX rendering. The delegate type should
        ///     contain an appropriate DirectX <see cref="DXGISwapChain_PresentDelegate"/>
        ///     object for drawing overlays.
        /// </param>
        /// <param name="DXGIResizeTargetDelegate">
        ///     A delegate or function of type of <see cref="DXGISwapChain_ResizeTargetDelegate"/> to call when DXGI Buffer
        ///     commits a resolution change or windowed/fullscreen change.
        /// </param>
        /// <param name="hookDelay">
        ///     Specifies the amount of time to wait until the hook is instantiation begins.
        ///     Some games are known to crash if DirectX is hooked too early.
        /// </param>
        /// <remarks>The delegates you will need to call the original function are members of this class, see <see cref="PresentHook"/> and <see cref="ResizeTargetHook"/></remarks>
        public static async Task <DX11Overlay> CreateDirectXOverlay(DXGISwapChain_PresentDelegate DXGIPresentDelegate, DXGISwapChain_ResizeTargetDelegate DXGIResizeTargetDelegate, int hookDelay)
        {
            // Wait the hook delay.
            await Task.Delay(hookDelay);

            // Create a new self-object.
            DX11Overlay dx11Overlay = new DX11Overlay();

            // Wait for DirectX
            Direct3DVersion direct3DVersion = await DXHookCommon.GetDirectXVersion();

            // Return nothing if not D3D9
            if (direct3DVersion != Direct3DVersion.Direct3D11 && direct3DVersion != Direct3DVersion.Direct3D11_1 &&
                direct3DVersion != Direct3DVersion.Direct3D11_3 && direct3DVersion != Direct3DVersion.Direct3D11_4)
            {
                Bindings.PrintError(
                    "libReloaded Hooking: DirectX 11 module not found, the application is either not " +
                    "a DirectX 11 application or uses an unsupported version of DirectX.");

                return(null);
            }

            // Instantiate DX9 hook
            dx11Overlay.DirectX11Hook = new DX11Hook();;

            // Obtain Virtual Function Table Entries
            VirtualFunctionTable.TableEntry presentTableEntry = dx11Overlay.DirectX11Hook.DXGISwapChainFunctions[(int)IDXGISwapChain.Present];
            VirtualFunctionTable.TableEntry resizeTableEntry  = dx11Overlay.DirectX11Hook.DXGISwapChainFunctions[(int)IDXGISwapChain.ResizeTarget];

            // Hook relevant DirectX functions.
            if (IntPtr.Size == 4)
            {
                // X86
                dx11Overlay.PresentHook = FunctionHook <DXGISwapChain_PresentDelegate> .Create((long)presentTableEntry.FunctionPointer, DXGIPresentDelegate);

                dx11Overlay.ResizeTargetHook = FunctionHook <DXGISwapChain_ResizeTargetDelegate> .Create((long)resizeTableEntry.FunctionPointer, DXGIResizeTargetDelegate);
            }
            else if (IntPtr.Size == 8)
            {
                // X64
                dx11Overlay.PresentHook64 = X64FunctionHook <DXGISwapChain_PresentDelegate> .Create((long)presentTableEntry.FunctionPointer, DXGIPresentDelegate);

                dx11Overlay.ResizeTargetHook64 = X64FunctionHook <DXGISwapChain_ResizeTargetDelegate> .Create((long)resizeTableEntry.FunctionPointer, DXGIResizeTargetDelegate);
            }

            // Return our DX9Overlay
            return(dx11Overlay);
        }
Esempio n. 12
0
            protected override IDisposable[] RequestHooks()
            {
                delegate * unmanaged <void *, void *, uint, void> pCreatureExamineHook = &OnCreatureExamine;
                creatureExamineHook = HookService.RequestHook <CreatureExamineHook>(pCreatureExamineHook, FunctionsLinux._ZN11CNWSMessage41SendServerToPlayerExamineGui_CreatureDataEP10CNWSPlayerj, HookOrder.Earliest);

                delegate * unmanaged <void *, void *, uint, void> pDoorExamineHook = &OnDoorExamine;
                doorExamineHook = HookService.RequestHook <DoorExamineHook>(pDoorExamineHook, FunctionsLinux._ZN11CNWSMessage37SendServerToPlayerExamineGui_DoorDataEP10CNWSPlayerj, HookOrder.Earliest);

                delegate * unmanaged <void *, void *, uint, void> pItemExamineHook = &OnItemExamine;
                itemExamineHook = HookService.RequestHook <ItemExamineHook>(pItemExamineHook, FunctionsLinux._ZN11CNWSMessage37SendServerToPlayerExamineGui_ItemDataEP10CNWSPlayerj, HookOrder.Earliest);

                delegate * unmanaged <void *, void *, uint, void> pPlaceableExamineHook = &OnPlaceableExamine;
                placeableExamineHook = HookService.RequestHook <PlaceableExamineHook>(pPlaceableExamineHook, FunctionsLinux._ZN11CNWSMessage42SendServerToPlayerExamineGui_PlaceableDataEP10CNWSPlayerj, HookOrder.Earliest);

                return(new IDisposable[] { creatureExamineHook, doorExamineHook, itemExamineHook, placeableExamineHook });
            }
Esempio n. 13
0
        /// <summary>
        /// Instantiates the DirectX overlay, by first finding the applicable
        /// version of DirectX for the application and then finding the individual
        /// details. For more details, see <see cref="DX9Overlay"/>
        /// Note: This method is blocking and Reloaded mods are required to return in order
        /// to boot up the games, please do not assign this statically - instead assign it in a background thread!
        /// </summary>
        /// <param name="renderDelegate">
        ///     A delegate type to use for DirectX rendering. The delegate type should
        ///     contain an appropriate DirectX <see cref="Direct3D9Device_EndSceneDelegate"/>
        ///     object for drawing overlays.
        /// </param>
        /// <param name="resetDelegate">
        ///     A delegate or function of type of <see cref="Direct3D9Device_ResetDelegate"/> to call when D3D9 fires its Reset function,
        ///     called on resolution change or windowed/fullscreen change - we can reset some things as well.
        /// </param>
        /// <param name="hookDelay">
        ///     Specifies the amount of time to wait until the hook is instantiation begins.
        ///     Some games are known to crash if DirectX is hooked too early.
        /// </param>
        public static async Task <DX9Overlay> CreateDirectXOverlay(Direct3D9Device_EndSceneDelegate renderDelegate, Direct3D9Device_ResetDelegate resetDelegate, int hookDelay)
        {
            // Wait the hook delay.
            await Task.Delay(hookDelay);

            // Create a new self-object.
            DX9Overlay dx9Overlay = new DX9Overlay();

            // Wait for DirectX
            Direct3DVersion direct3DVersion = await DXHookCommon.GetDirectXVersion();

            // Return nothing if not D3D9
            if (direct3DVersion != Direct3DVersion.Direct3D9)
            {
                Bindings.PrintError(
                    "libReloaded Hooking: DirectX 9 module not found, the application is either not" +
                    "a DirectX 9 application or uses an unsupported version of DirectX.");

                return(null);
            }

            // Instantiate DX9 hook
            dx9Overlay.DirectX9Hook = new DX9Hook();

            // Obtain Virtual Function Table Entries
            VirtualFunctionTable.TableEntry endSceneTableEntry = dx9Overlay.DirectX9Hook.DirectXFunctions[(int)Direct3DDevice9.EndScene];
            VirtualFunctionTable.TableEntry resetTableEntry    = dx9Overlay.DirectX9Hook.DirectXFunctions[(int)Direct3DDevice9.Reset];

            // Hook relevant DirectX functions.
            if (IntPtr.Size == 4)
            {
                // X86
                dx9Overlay.EndSceneHook = FunctionHook <Direct3D9Device_EndSceneDelegate> .Create((long)endSceneTableEntry.FunctionPointer, renderDelegate);

                dx9Overlay.ResetHook = FunctionHook <Direct3D9Device_ResetDelegate> .Create((long)resetTableEntry.FunctionPointer, resetDelegate);
            }
            else if (IntPtr.Size == 8)
            {
                // X64
                dx9Overlay.EndSceneHook64 = X64FunctionHook <Direct3D9Device_EndSceneDelegate> .Create((long)endSceneTableEntry.FunctionPointer, renderDelegate);

                dx9Overlay.ResetHook64 = X64FunctionHook <Direct3D9Device_ResetDelegate> .Create((long)resetTableEntry.FunctionPointer, resetDelegate);
            }

            // Return our DX9Overlay
            return(dx9Overlay);
        }
Esempio n. 14
0
        /// <summary>
        /// Your own user code starts here.
        /// If this is your first time, do consider reading the notice above.
        /// It contains some very useful information.
        /// </summary>
        public static void Init()
        {
            /*
             *  Reloaded Mod Loader Sample: File Monitor (New)
             *  Architectures supported: X86, X64
             *
             *  Retrieves our Windows API function pointer by first grabbing a handle to Ntdll where
             *  the individual function is located then calls the GetProcAddress() Windows API function
             *  in order to obtain the address of the exported function.
             *
             *  We then hook the function using the Reloaded hooking classes, print to console the filename
             *  and redirect to the original function.
             */

            // Debugger.Launch();

            // This should automatically resolve to ntdll.dll as it is already registered by Windows.
            // The handle should return from already loaded library in memory, following the standard search strategy.
            IntPtr ntdllHandle = Reloaded.Process.Native.Native.LoadLibraryW("ntdll");

            // Get the addresses of our desired NtCreateFile
            IntPtr ntCreateFilePointer = Reloaded.Process.Native.Native.GetProcAddress(ntdllHandle, "NtCreateFile");

            // Hook the obtained function pointers.

            // X86
            if (IntPtr.Size == 4)
            {
                if (ntCreateFilePointer != IntPtr.Zero)
                {
                    _ntCreateFileHook = FunctionHook <NtCreateFile> .Create((long)ntCreateFilePointer, NtCreateFileImpl).Activate();
                }
            }
            // X64
            else if (IntPtr.Size == 8)
            {
                if (ntCreateFilePointer != IntPtr.Zero)
                {
                    _ntCreateFileHook64 = X64FunctionHook <NtCreateFile> .Create((long)ntCreateFilePointer, NtCreateFileImpl).Activate();
                }
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Your own user code starts here.
        /// If this is your first time, do consider reading the notice above.
        /// It contains some very useful information.
        /// </summary>
        public static unsafe void Init()
        {
            #if DEBUG
            Debugger.Launch();
            #endif

            // Get graphics settings
            _graphicsSettings = Settings.GraphicsSettings.ParseConfig(ModDirectory);
            Settings.GraphicsSettings.WriteConfig(_graphicsSettings, ModDirectory);     // Will add comments if they are not present.

            // Hooks
            _rwCameraSetViewWindowHook = FunctionHook <RWAspect.RwCameraSetViewWindow> .Create(0x0064AC80, RwCameraSetViewWindowImpl).Activate();

            _cameraBuildPerspClipPlanesHook = FunctionHook <RWAspect.CameraBuildPerspClipPlanes> .Create(0x0064AF80, CameraBuildPerspClipPlanesImpl).Activate();

            _readConfigFromIniHook = FunctionHook <ReadConfigfromINI> .Create(0x00629CE0, ReadConfigFromIniImpl).Activate();

            // Patches
            PatchHardcodedResolutions();
            PatchWindowStyle();

            if (_graphicsSettings.StupidlyFastLoadTimes)
            {
                GameProcess.WriteMemory((IntPtr)0x0078A578, (double)9999999999F);
            }

            if (_graphicsSettings.EnableAspectHack)
            {
                _someTitlecardCreateHook = FunctionHook <TObjCamera_Init> .Create(0x0061D3B0, TObjCameraInitHook).Activate();
            }

            if (_graphicsSettings.Disable2PFrameskip)
            {
                GameProcess.WriteMemory((IntPtr)0x402D07, new byte[] { 0x90 });
            }

            if (_graphicsSettings.D3D9Settings.Enable)
            {
                _dx9Device = new Device(_graphicsSettings.D3D9Settings, ModDirectory);
            }
        }
Esempio n. 16
0
        /* Entry Point */
        public static unsafe void Init()
        {
#if DEBUG
            Debugger.Launch();
#endif

            // Setup controllers.
            var controllerManager = new ControllerManager();
            playerOneController   = new ReloadedController(Player.PlayerOne, controllerManager);
            playerTwoController   = new ReloadedController(Player.PlayerTwo, controllerManager);
            playerThreeController = new ReloadedController(Player.PlayerThree, controllerManager);
            playerFourController  = new ReloadedController(Player.PlayerFour, controllerManager);

            // Hook get controls function.
            psPADServerHook = FunctionHook <psPADServerPC> .Create(0x444F30, PSPADServerImpl).Activate();

            // Copy the old function to a new place and create a function from it.
            byte[] periMakeRepeatBytes = GameProcess.ReadMemory((IntPtr)0x00434FF0, 0xDD);
            IntPtr functionPtr         = MemoryBufferManager.Add(periMakeRepeatBytes);

            periMakeRepeatFunction  = FunctionWrapper.CreateWrapperFunction <sGamePeri__MakeRepeatCount>((long)functionPtr);
            periMakeRepeatCountHook = FunctionHook <sGamePeri__MakeRepeatCount> .Create(0x00434FF0, MakeRepeatCountImpl).Activate();
        }
Esempio n. 17
0
 protected override IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, void *, int, int> pHook = &OnCanUseItem;
     Hook = HookService.RequestHook <CanUseItemHook>(pHook, FunctionsLinux._ZN12CNWSCreature10CanUseItemEP8CNWSItemi, HookOrder.Early);
     return(new IDisposable[] { Hook });
 }
Esempio n. 18
0
 protected override IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, uint, uint, uint, int> pHook = &OnRequestBuy;
     Hook = HookService.RequestHook <RequestBuyHook>(pHook, FunctionsLinux._ZN12CNWSCreature10RequestBuyEjjj, HookOrder.Early);
     return(new IDisposable[] { Hook });
 }
Esempio n. 19
0
 protected override IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, uint, uint, void> pHook = &OnPayToIdentifyItem;
     Hook = HookService.RequestHook <PayToIdentifyItemHook>(pHook, FunctionsLinux._ZN12CNWSCreature17PayToIdentifyItemEjj, HookOrder.Early);
     return(new IDisposable[] { Hook });
 }
Esempio n. 20
0
 protected override IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, ushort, void *, void *, void> pHook = &OnSendFeedbackMessage;
     Hook = HookService.RequestHook <SendFeedbackMessageHook>(pHook, FunctionsLinux._ZN12CNWSCreature19SendFeedbackMessageEtP16CNWCCMessageDataP10CNWSPlayer, HookOrder.Earliest);
     return(new IDisposable[] { Hook });
 }
Esempio n. 21
0
 public Factory(HookService hookService)
 {
     reloadAllHook = hookService.RequestHook <ReloadAllHook>(OnReloadAll, FunctionsLinux._ZN8CNWRules9ReloadAllEv, HookOrder.Latest);
     LoadRules();
 }
Esempio n. 22
0
 protected override IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, void *, void *, int, int> pHook = &OnEffectApplied;
     Hook = HookService.RequestHook <OnEffectAppliedHook>(pHook, FunctionsLinux._ZN21CNWSEffectListHandler15OnEffectAppliedEP10CNWSObjectP11CGameEffecti, HookOrder.Earliest);
     return(new IDisposable[] { Hook });
 }
Esempio n. 23
0
 protected override IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, void *, byte, int> pHook = &OnHandlePlayerToServerLevelUpMessage;
     Hook = HookService.RequestHook <HandlePlayerToServerLevelUpMessageHook>(pHook, FunctionsLinux._ZN11CNWSMessage34HandlePlayerToServerLevelUpMessageEP10CNWSPlayerh, HookOrder.Early);
     return(new IDisposable[] { Hook });
 }
Esempio n. 24
0
 protected override IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, byte, void> pHook = &OnSetDetectMode;
     Hook = HookService.RequestHook <SetDetectModeHook>(pHook, FunctionsLinux._ZN12CNWSCreature13SetDetectModeEh, HookOrder.Early);
     return(new IDisposable[] { Hook });
 }
Esempio n. 25
0
 protected override IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, void *, int, int> pHook = &OnDoListenDetection;
     Hook = HookService.RequestHook <DoListenDetectionHook>(pHook, FunctionsLinux._ZN12CNWSCreature17DoListenDetectionEPS_i, HookOrder.Early);
     return(new IDisposable[] { Hook });
 }
Esempio n. 26
0
 protected override IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, byte, byte, byte, void> pHook = &OnClearMemorizedSpellSlot;
     Hook = HookService.RequestHook <ClearMemorizedSpellSlotHook>(pHook, FunctionsLinux._ZN17CNWSCreatureStats23ClearMemorizedSpellSlotEhhh, HookOrder.Early);
     return(new IDisposable[] { Hook });
 }
Esempio n. 27
0
 protected override unsafe IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, void *, int> pHook = &OnSendServerToPlayerCharList;
     Hook = HookService.RequestHook <SendServerToPlayerCharListHook>(pHook, FunctionsLinux._ZN11CNWSMessage26SendServerToPlayerCharListEP10CNWSPlayer, HookOrder.Early);
     return(new IDisposable[] { Hook });
 }
Esempio n. 28
0
 protected override IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, byte, byte, uint, Vector3, uint, uint, int, int> pHook = &OnUseSkill;
     Hook = HookService.RequestHook <UseSkillHook>(pHook, FunctionsLinux._ZN12CNWSCreature8UseSkillEhhj6Vectorjji, HookOrder.Early);
     return(new IDisposable[] { Hook });
 }
Esempio n. 29
0
 protected override IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, uint, int> pHook = &OnLearnScroll;
     Hook = HookService.RequestHook <LearnScrollHook>(pHook, FunctionsLinux._ZN12CNWSCreature11LearnScrollEj, HookOrder.Early);
     return(new IDisposable[] { Hook });
 }
Esempio n. 30
0
 protected override IDisposable[] RequestHooks()
 {
     delegate * unmanaged <void *, uint, int, int, int, int, Vector3, uint, int, int, int, byte, int, int, int, byte, int> pHook = &OnAddCastSpellActions;
     Hook = HookService.RequestHook <AddCastSpellActionsHook>(pHook, FunctionsLinux._ZN12CNWSCreature19AddCastSpellActionsEjiiii6Vectorjiiihiiih, HookOrder.Early);
     return(new IDisposable[] { Hook });
 }