Skip to content

Commit

Permalink
Update movie fix to hook earlier.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyall committed Sep 21, 2024
1 parent c963a3d commit fbac1bb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,27 +562,29 @@ void HUD()

if (bFixMovies) {
// Movies
uint8_t* MoviesScanResult = Memory::PatternScan(baseModule, "C4 ?? ?? ?? ?? ?? C5 ?? ?? ?? ?? C5 ?? ?? ?? 48 ?? ?? ?? 4C ?? ?? ?? C5 ?? ?? ?? 48 ?? ?? ??");
uint8_t* MoviesScanResult = Memory::PatternScan(baseModule, "8B ?? ?? 48 8B ?? C5 ?? ?? ?? C4 ?? ?? ?? ?? C5 ?? ?? ?? ?? ?? C5 ?? ?? ?? ?? ??");
if (MoviesScanResult) {
spdlog::info("HUD: Movies: Address is {:s}+{:x}", sExeName.c_str(), (uintptr_t)MoviesScanResult - (uintptr_t)baseModule);
// Change xmm8 to xmm9
Memory::PatchBytes((uintptr_t)MoviesScanResult + 0x1E, "\x4C", 1);

static SafetyHookMid MoviesMidHook{};
MoviesMidHook = safetyhook::create_mid(MoviesScanResult + 0x6,
MoviesMidHook = safetyhook::create_mid(MoviesScanResult + 0xF,
[](SafetyHookContext& ctx) {
float Width = ctx.xmm0.f32[0];
float Height = ctx.xmm2.f32[0];
float Height = ctx.xmm1.f32[0];

if (fAspectRatio > fNativeAspect) {
float HUDWidth = ctx.xmm2.f32[0] * fNativeAspect;
float HUDWidth = Height * fNativeAspect;
float WidthOffset = (Width - HUDWidth) / 2.00f;
ctx.xmm0.f32[0] = HUDWidth + WidthOffset;
ctx.xmm1.f32[0] = WidthOffset;
ctx.xmm9.f32[0] = WidthOffset;
}
else if (fAspectRatio < fNativeAspect) {
float HUDHeight = ctx.xmm0.f32[0] / fNativeAspect;
float HUDHeight = Width / fNativeAspect;
float HeightOffset = (Height - HUDHeight) / 2.00f;
ctx.xmm2.f32[0] = HUDHeight + HeightOffset;
ctx.xmm3.f32[0] = HeightOffset;
ctx.xmm1.f32[0] = HUDHeight + HeightOffset;
ctx.xmm8.f32[0] = HeightOffset;
}
});
}
Expand Down

0 comments on commit fbac1bb

Please sign in to comment.