public P4GPCModLoader(ILogger logger, Config configuration, Reloaded.Hooks.ReloadedII.Interfaces.IReloadedHooks hooks) { mLogger = logger; mConfiguration = configuration; mHooks = hooks; #if DEBUG Debugger.Launch(); #endif // Init TrySetConsoleEncoding(EncodingCache.ShiftJIS); var version = typeof(P4GPCModLoader).Assembly.GetName().Version.ToString(); version = version.Substring(0, version.LastIndexOf('.')); mLogger.WriteLine($"[modloader] Persona 4 Golden (Steam) Mod loader by TGE (2020) v{version}"); mNativeFunctions = NativeFunctions.GetInstance(hooks); mFileAccessServer = new FileAccessServer(hooks, mNativeFunctions); // Load mods var modDb = new ModDb(mConfiguration.ModsDirectory, mConfiguration.EnabledMods); // CPK redirector mCpkRedirector = new CpkRedirector(mLogger, modDb, configuration); mFileAccessServer.AddClient(mCpkRedirector); // DW_PACK (PAC) redirector mDwPackRedirector = new DwPackRedirector(mLogger, modDb, configuration, mCpkRedirector); mFileAccessServer.AddClient(mDwPackRedirector); // XACT (XWB, XSB) redirector mXactRedirector = new XactRedirector(mLogger, modDb, configuration); mFileAccessServer.AddClient(mXactRedirector); }
public void Start(IModLoaderV1 loader) { _modLoader = (IModLoader)loader; /* Your mod code starts here. */ _reloadedHooksLegacy = new ReloadedHooks(); _reloadedHooks = _reloadedHooksLegacy; _utilities = new ReloadedHooksUtilities(); _modLoader.AddOrReplaceController(this, _reloadedHooks); _modLoader.AddOrReplaceController(this, _reloadedHooksLegacy); _modLoader.AddOrReplaceController(this, _utilities); }
public static void Initialize(IReloadedHooks hooks, Redirector redirector, RedirectorController redirectorController) { _redirector = redirector; _redirectorController = redirectorController; // Get Hooks var ntdllHandle = Native.LoadLibraryW("ntdll"); var ntCreateFilePointer = Native.GetProcAddress(ntdllHandle, "NtCreateFile"); // Kick off the server if (ntCreateFilePointer != IntPtr.Zero) { _ntCreateFileHook = hooks.CreateHook <Native.NtCreateFile>((delegate * unmanaged[Stdcall] < IntPtr *, FileAccess, Native.OBJECT_ATTRIBUTES *, Native.IO_STATUS_BLOCK *, long *, uint, FileShare, uint, uint, IntPtr, uint, int >) & NtCreateFileHookFn, (long)ntCreateFilePointer).Activate(); } }
public DebugBoot(string modDirectory, string configDirectory, IReloadedHooks hooks) { // Setup Config _configurator = new Configurator(configDirectory); _configurator.Migrate(modDirectory, _configurator.ConfigFolder); _config = _configurator.GetConfiguration <Config.Config>(0); _config.ConfigurationUpdated += configurable => { _config = (Config.Config)configurable; ConfigToPinnable(_config); Console.WriteLine($"Debug Boot Configuration Updated. Set new main menu mode."); }; ConfigToPinnable(_config); // Apply Boot Time Constants *_stageId = _config.BootOptions.Stage; *_teamOne = _config.BootOptions.TeamP1; *_teamTwo = _config.BootOptions.TeamP2; *_teamThree = _config.BootOptions.TeamP3; *_teamFour = _config.BootOptions.TeamP4; // Setup mid function hooks. // Disasm name: Main::Loop string[] asmHookSetMainMenu = { $"use32", $"mov ecx, dword [{(IntPtr)_mainMenuSystemMode.Pointer}]", // New line, sacrificing ECX. $"mov [eax + 0x38], ecx", $"mov ecx, [esi]", $"mov [esi + 4], edi", }; string[] asmHookStartGame = { $"use32", $"mov [{(IntPtr)_ediBackup.Pointer}], edi", // Backup EDI $"mov edi, dword [{(IntPtr)_bootSystemMode.Pointer}]", // Replace EDI $"mov [0xA82034], ebp", $"mov [eax + 0x38], edi", // Set SystemMode $"mov edi, dword [{(IntPtr)_ediBackup.Pointer}]", // Restore EDI }; _loadMainMenuHook = hooks.CreateAsmHook(asmHookSetMainMenu, 0x427342, AsmHookBehaviour.DoNotExecuteOriginal).Activate(); _bootHook = hooks.CreateAsmHook(asmHookStartGame, 0x00427138, AsmHookBehaviour.DoNotExecuteOriginal).Activate(); }
public RenderHooks(float aspectRatioLimit, Reloaded.Hooks.ReloadedII.Interfaces.IReloadedHooks hooks) { _memory = Memory.CurrentProcess; AspectConverter = new AspectConverter(aspectRatioLimit); _draw2PViewPortHook = Fun_DrawViewPorts.Hook(Draw2PViewportHook).Activate(); _drawSpecialStageGaugeHook = Fun_DrawSpecialStageGauge.Hook(DrawSpecialStageGaugeImpl).Activate(); _drawSpecialStageBarHook = Fun_DrawSpecialStageBar.Hook(DrawSpecialStageBarImpl).Activate(); _draw2PStatusHook = Fun_DrawTwoPlayerStatusBar.Hook(Draw2pStatusImpl).Activate(); _renderPrimitiveHook = Fun_D3D8Im2DRenderPrimitive.Hook(RenderPrimitiveImpl).Activate(); _renderVideoHook = Fun_RenderVideoFrame.Hook(RenderVideoHookImpl).Activate(); _drawFullVideoFrameHook = Fun_DrawFullVideoFrame.Hook(DrawFullVideoFrameHookImpl).Activate(); _drawSmallVideoFrameHook = Fun_DrawSmallFrame.Hook(DrawSmallFrameImpl).Activate(); _drawTitlecardElementsHook = Fun_DrawTitlecardElements.Hook(DrawTitlecardElementsImpl).Activate(); _drawSpecialStageLinkHook = Fun_DrawSpecialStageLinkText.Hook(DrawSpecialStageLinkImpl).Activate(); _drawNowLoadingHook = Fun_DrawNowLoading.Hook(DrawNowLoadingImpl).Activate(); _executeCreditsHook = Fun_TObjCreditsExecute.Hook(ExecuteCredits).Activate(); _drawResultScreenDotsHook = Fun_DrawResultScreenLevelupDotsAndSomeOtherElements.Hook(DrawResultScreenDotsImpl).Activate(); _drawPowerupBoxHook = Fun_DrawPowerupBox.Hook(DrawPowerupBoxImpl).Activate(); _drawSpecialStageEmeraldHook = Fun_DrawSpecialStageEmeraldAndResultScreenGauge.Hook(DrawSpecialStageEmeraldImpl).Activate(); // Change permissions for game code regions. _memory.ChangePermission((IntPtr)_descriptionX, sizeof(void *), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_descriptionY, sizeof(void *), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_descriptionWidth, sizeof(void *), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_descriptionHeight, sizeof(void *), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_pickupBoxSeparation, sizeof(void *), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_dotsVertSeparation, sizeof(void *), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_dotsHorzSeparation, sizeof(void *), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_dotsHeight, sizeof(void *), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_dotsWidth, sizeof(void *), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_dotsVertSeparation, sizeof(float), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_dotsHorzSeparation, sizeof(float), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_dotsHeight, sizeof(float), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); _memory.ChangePermission((IntPtr)_dotsWidth, sizeof(float), MEM_PROTECTION.PAGE_EXECUTE_READWRITE); }
public P4GPCModLoader(ILogger logger, Config configuration, Reloaded.Hooks.ReloadedII.Interfaces.IReloadedHooks hooks) { // Enable file logging only if console is enabled // performance impact would be too great otherwise if (Native.GetConsoleWindow() != IntPtr.Zero) { mLogger = new FileLoggingLogger(logger, "p4gpc.modloader.log.txt"); } else { mLogger = logger; } mConfiguration = configuration; mHooks = hooks; #if DEBUG Debugger.Launch(); #endif // Init TrySetConsoleEncoding(EncodingCache.ShiftJIS); mLogger.WriteLine("[modloader] Persona 4 Golden (Steam) Mod loader by TGE (2020) v1.1.2"); mNativeFunctions = NativeFunctions.GetInstance(hooks); mFileAccessServer = new FileAccessServer(hooks, mNativeFunctions); // Load mods var modDb = new ModDb(mConfiguration.ModsDirectory, mConfiguration.EnabledMods); // DW_PACK (PAC) redirector mDwPackRedirector = new DwPackRedirector(mLogger, modDb); mFileAccessServer.AddClient(mDwPackRedirector); // XACT (XWB, XSB) redirector mXactRedirector = new XactRedirector(mLogger, modDb); mFileAccessServer.AddClient(mXactRedirector); }
public unsafe DrawDistanceHook(Config config, IReloadedHooks hooks, IReloadedHooksUtilities utilities) { _config = config; _optimizeHook = hooks.CreateHook <SetParamOptimize>(ModifyObjectDistance, 0x0043DF40).Activate(); }
public ControllerHook(IReloadedHooks hooks) { _hooks = hooks; _inputsHook = _hooks.CreateHook <HandleInputs>(HandleInputsImpl, 0x00513B70).Activate(); _lastFrameInputs = new Sewer56.SonicRiders.Structures.Input.PlayerInput[Player.MaxNumberOfPlayers]; }