Skip to content

Commit

Permalink
fix branch trampoline allocation underflow (same as f4se, thought I d…
Browse files Browse the repository at this point in the history
…id this forever ago)
  • Loading branch information
ianpatt committed Dec 28, 2020
1 parent 2540ea5 commit 4a1e121
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion skse64_common/BranchTrampoline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ bool BranchTrampoline::Create(size_t len, void * module)
// search backwards from module base
uintptr_t moduleBase = uintptr_t(module);
uintptr_t addr = moduleBase;
uintptr_t lowestOKAddress = moduleBase - 0x80000000 + (1024 * 1024 * 128); // largest 32-bit displacement with 128MB scratch space
uintptr_t maxDisplacement = 0x80000000 - (1024 * 1024 * 128); // largest 32-bit displacement with 128MB scratch space
uintptr_t lowestOKAddress = (moduleBase >= maxDisplacement) ? moduleBase - maxDisplacement : 0;
addr--;

while (!m_base)
Expand Down

1 comment on commit 4a1e121

@chriku
Copy link

@chriku chriku commented on 4a1e121 Feb 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please also copy this into the VR edition and make a release? If there is anything I can do to help it, please just let me know

Please sign in to comment.