Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Reloaded.Hooks: Issue when code relocation is >2GiB for hook, to be fixed by Rust Rewrite] #245

Open
Obi-Laws opened this issue Aug 11, 2023 · 1 comment
Labels
untriaged No decision has been made by the developers.

Comments

@Obi-Laws
Copy link

Did you install the Prerequisites?
Yes, the prerequisites were installed, as the program was working fine before and technically still is, but is running into an error now after moving the P5R installation. The Windows installation was unchanged, so the same prerequisites that were present before are present now.

Describe the Issue
So the original source of the issue is from relocating a P5R installation. I work in IT and I helped my friend (who isn't tech savvy) install a new SSD, and then move the P5R installation via Steam from her old drive to the new SSD. After doing this, we started running into issues with Reloaded-II, even after updating its location under the "Edit Application" button. The first thing I noticed was that the "Working Directory" line did not update automatically, and even after manually updating it Reloaded-II would still fail. Eventually we got past this by adding a new application and pointing it to P5R again. However, at this point, we ran into a new issue. The game now starts and appears to load the mods properly but Reloaded-II is running into a new issue. It throws an error involving Reloaded Hooks: Internal/IcedPatcher and an IP relative memory error regarding memory being allocated too far away from the original instruction. I'll include a screenshot of the error window and a copy of the log for more detail, as I'm not a software engineer/coder at all so it's a little beyond my means to fully explain. In terms of practical effect, the game fails to load mods properly inconsistently with this error. Sometimes it loads all the mods correctly, and other times it only loads some mods and fails to load others.

Screenshots
Reloaded-2 error

Additional Resources
Relevant Log Text:

[00:06:59] [Reloaded] Failed to Load Reloaded-II.
One or more errors occurred. (Reloaded Hooks: Internal Error in Internal/IcedPatcher. Failed to re-encode code for new address. Process will probably die.Error: IP relative memory operand is too far away and isn't currently supported. Try to allocate memory close to the original instruction (+/-2GB).)
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Reloaded.Mod.Loader.EntryPoint.SetupLoader2(EntryPointParameters* parameters)
at Reloaded.Mod.Loader.EntryPoint.SetupLoader(EntryPointParameters* parameters)
A log is available at: C:\Users\kx\AppData\Roaming\Reloaded-Mod-Loader-II\Logs\2023-08-11 05.06.36 ~ P5R.txt
Inner Exception: Reloaded Hooks: Internal Error in Internal/IcedPatcher. Failed to re-encode code for new address. Process will probably die.Error: IP relative memory operand is too far away and isn't currently supported. Try to allocate memory close to the original instruction (+/-2GB). | at Reloaded.Hooks.Internal.IcedPatcher.EncodeForNewAddress(UIntPtr newAddress)
at Reloaded.Hooks.Internal.IcedPatcher.<>c__DisplayClass7_0.b__0()
at Reloaded.Memory.Buffers.MemoryBuffer.ExecuteWithLockT
at Reloaded.Hooks.Internal.IcedPatcher.ToMemoryBuffer(Nullable1 jumpTarget) at Reloaded.Hooks.Hook1.CreateHook(UIntPtr functionAddress, Int32 minHookLength, FunctionHookOptions options)
at Reloaded.Hooks.ReloadedHooks.CreateHook[TFunction](TFunction function, Int64 functionAddress, Int32 minHookLength)
at Reloaded.Hooks.ReloadedHooks.CreateHook[TFunction](TFunction function, Int64 functionAddress)
at Reloaded.Mod.Loader.Utilities.ProcessExitHook..ctor(IReloadedHooks hooks)
at Reloaded.Mod.Loader.Utilities.ProcessExitHook..ctor(Action codeToRun, IReloadedHooks hooks)
at Reloaded.Mod.Loader.EntryPoint.SetupHooks(IReloadedHooks hooks)
at Reloaded.Mod.Loader.EntryPoint.<>c__DisplayClass14_0.b__2()
at Reloaded.Mod.Loader.EntryPoint.ExecuteTimed(String text, Action action)
at Reloaded.Mod.Loader.EntryPoint.<>c__DisplayClass14_0.b__0()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---

Here's the full log text file:
2023-08-11_05.06.36__P5R.txt

@Obi-Laws Obi-Laws added the untriaged No decision has been made by the developers. label Aug 11, 2023
@Sewer56
Copy link
Member

Sewer56 commented Aug 11, 2023

A reboot would probably solve the issue in the meantime. It's just some bad luck relating to where some memory was allocated in the game's address space (virtual memory). There's probably a subtle bug/edge case there in current implementation.

The component where this error originates from (Reloaded.Hooks) I'm actually rewriting in Rust (right now!) during my free time, so hopefully in 2-3 weeks, it'll be replaced on Reloaded's end.

@Sewer56 Sewer56 changed the title Help: Please help me with an error Reloaded is running into after moving installation location for P5R [Reloaded.Hooks: Issue when code relocation is >2GiB, to be fixed by Rust Rewrite] Feb 19, 2024
@Sewer56 Sewer56 changed the title [Reloaded.Hooks: Issue when code relocation is >2GiB, to be fixed by Rust Rewrite] [Reloaded.Hooks: Issue when code relocation is >2GiB for hook, to be fixed by Rust Rewrite] Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged No decision has been made by the developers.
Projects
None yet
Development

No branches or pull requests

2 participants