2424HMODULE exeModule = GetModuleHandle(NULL );
2525HMODULE thisModule;
2626HMODULE dllModule2 = nullptr ;
27+ HMODULE dllModule3 = nullptr ;
2728
2829// Fix details
2930std::string sFixName = " RevolutionFOVFix" ;
30- std::string sFixVersion = " 1.2 " ;
31+ std::string sFixVersion = " 1.3 " ;
3132std::filesystem::path sFixPath ;
3233
3334// Ini
@@ -52,7 +53,11 @@ float fFOVFactor;
5253// Variables
5354float fNewAspectRatio ;
5455float fAspectRatioScale ;
55- float fNewCameraFOV ;
56+ float fNewAspectRatio2 ;
57+ float fNewGeneralFOV ;
58+ float fNewCutscenesFOV1 ;
59+ float fNewCutscenesFOV2 ;
60+ float fNewInterfaceWeaponFOV ;
5661
5762// Game detection
5863enum class Game
@@ -61,6 +66,14 @@ enum class Game
6166 Unknown
6267};
6368
69+ enum CameraFOVInstructionsIndices
70+ {
71+ GeneralFOV,
72+ CutscenesFOV1,
73+ CutscenesFOV2,
74+ InterfaceWeaponFOV
75+ };
76+
6477struct GameInfo
6578{
6679 std::string GameTitle;
@@ -193,37 +206,17 @@ bool DetectGame()
193206 return false ;
194207 }
195208
196- while ((dllModule2 = GetModuleHandleA (" EngineDll.dll" )) == nullptr )
197- {
198- spdlog::warn (" EngineDll.dll not loaded yet. Waiting..." );
199- Sleep (100 );
200- }
209+ dllModule2 = Memory::GetHandle (" EngineDll.dll" );
201210
202- spdlog::info ( " Successfully obtained handle for EngineDll .dll: 0x{:X} " , reinterpret_cast < uintptr_t >(dllModule2) );
211+ dllModule3 = Memory::GetHandle ( " InterfaceDll .dll" );
203212
204213 return true ;
205214}
206215
207- static SafetyHookMid CameraFOVInstructionHook{};
208-
209- void CameraFOVInstructionMidHook (SafetyHookContext& ctx)
210- {
211- float & fCurrentCameraFOV = *reinterpret_cast <float *>(ctx.ebx + 0xD0 );
212-
213- if (fCurrentCameraFOV == 90 .0f )
214- {
215- fNewCameraFOV = Maths::CalculateNewFOV_DegBased (fCurrentCameraFOV , fAspectRatioScale ) * fFOVFactor ;
216- }
217- else
218- {
219- fNewCameraFOV = Maths::CalculateNewFOV_DegBased (fCurrentCameraFOV , fAspectRatioScale );
220- }
221-
222- _asm
223- {
224- fld dword ptr ds:[fNewCameraFOV ]
225- }
226- }
216+ static SafetyHookMid AspectRatioInstructionsHook{};
217+ static SafetyHookMid GeneralFOVInstructionHook{};
218+ static SafetyHookMid CutscenesFOVInstruction1Hook{};
219+ static SafetyHookMid CutscenesFOVInstruction2Hook{};
227220
228221void FOVFix ()
229222{
@@ -233,45 +226,77 @@ void FOVFix()
233226
234227 fAspectRatioScale = fNewAspectRatio / fOldAspectRatio ;
235228
236- std::uint8_t * CameraFOVInstructionScanResult = Memory::PatternScan (dllModule2, " D9 83 D0 00 00 00 D8 0D ?? ?? ?? ??" );
237- if (CameraFOVInstructionScanResult )
229+ std::uint8_t * AspectRatioInstructionsScanResult = Memory::PatternScan (dllModule2, " d9 83 ?? ?? ?? ?? d9 83 ?? ?? ?? ?? d9 c2 " );
230+ if (AspectRatioInstructionsScanResult )
238231 {
239- spdlog::info (" Camera FOV Instruction: Address is EngineDll.dll+{:x}" , CameraFOVInstructionScanResult - (std::uint8_t *)dllModule2);
232+ spdlog::info (" Aspect Ratio Instructions Scan: Address is EngineDll.dll+{:x}" , AspectRatioInstructionsScanResult - (std::uint8_t *)dllModule2);
233+
234+ fNewAspectRatio2 = 0 .75f / fAspectRatioScale ;
240235
241- Memory::PatchBytes (CameraFOVInstructionScanResult, " \x90\x90\x90\x90\x90\x90 " , 6 );
236+ Memory::WriteNOPs (AspectRatioInstructionsScanResult, 12 );
237+
238+ AspectRatioInstructionsHook = safetyhook::create_mid (AspectRatioInstructionsScanResult, [](SafetyHookContext& ctx)
239+ {
240+ FPU::FLD (fNewAspectRatio2 );
242241
243- CameraFOVInstructionHook = safetyhook::create_mid (CameraFOVInstructionScanResult, CameraFOVInstructionMidHook);
242+ FPU::FLD (1 .0f );
243+ });
244244 }
245245 else
246246 {
247- spdlog::error (" Failed to locate camera FOV instruction memory address." );
247+ spdlog::error (" Failed to locate aspect ratio instructions scan memory address." );
248248 return ;
249249 }
250250
251- std::uint8_t * AspectRatioInstructionsScanResult = Memory::PatternScan (dllModule2, " D9 93 DC 00 00 00 D9 83 D4 00 00 00" );
252- if (AspectRatioInstructionsScanResult)
251+ std::vector<std::uint8_t *> CameraFOVInstructionsScansResult = Memory::PatternScan (dllModule2, " D9 83 ?? ?? ?? ?? D8 0D ?? ?? ?? ?? D9 F2" , " D9 45 ?? D8 9B" , " 8B 45 ?? 8B CB 89 83" ,
252+ dllModule3, " 68 ?? ?? ?? ?? 8D 8D ?? ?? ?? ?? FF D6" );
253+ if (Memory::AreAllSignaturesValid (CameraFOVInstructionsScansResult) == true )
253254 {
254- spdlog::info (" Aspect Ratio Instructions Scan: Address is EngineDll.dll+{:x}" , AspectRatioInstructionsScanResult - (std::uint8_t *)dllModule2);
255+ spdlog::info (" General FOV Instruction: Address is EngineDll.dll+{:x}" , CameraFOVInstructionsScansResult[GeneralFOV] - (std::uint8_t *)dllModule2);
256+
257+ spdlog::info (" Cutscenes FOV Instruction 1: Address is EngineDll.dll+{:x}" , CameraFOVInstructionsScansResult[CutscenesFOV1] - (std::uint8_t *)dllModule2);
255258
256- static SafetyHookMid AspectRatioInstruction1MidHook{} ;
259+ spdlog::info ( " Cutscenes FOV Instruction 2: Address is EngineDll.dll+{:x} " , CameraFOVInstructionsScansResult[CutscenesFOV2] - (std:: uint8_t *)dllModule2) ;
257260
258- AspectRatioInstruction1MidHook = safetyhook::create_mid (AspectRatioInstructionsScanResult + 6 , [](SafetyHookContext& ctx)
261+ spdlog::info (" Interface Weapon FOV Instruction: Address is InterfaceDll.dll+{:x}" , CameraFOVInstructionsScansResult[InterfaceWeaponFOV] - (std::uint8_t *)dllModule3);
262+
263+ Memory::WriteNOPs (CameraFOVInstructionsScansResult[GeneralFOV], 6 );
264+
265+ GeneralFOVInstructionHook = safetyhook::create_mid (CameraFOVInstructionsScansResult[GeneralFOV], [](SafetyHookContext& ctx)
259266 {
260- *reinterpret_cast <float *>(ctx.ebx + 0xD4 ) = 0 .75f / fAspectRatioScale ;
267+ float & fCurrentGeneralFOV = *reinterpret_cast <float *>(ctx.ebx + 0xD0 );
268+
269+ fNewGeneralFOV = Maths::CalculateNewFOV_DegBased (fCurrentGeneralFOV , fAspectRatioScale ) * fFOVFactor ;
270+
271+ FPU::FLD (fNewGeneralFOV );
261272 });
262273
263- static SafetyHookMid AspectRatioInstruction2MidHook{} ;
274+ Memory::WriteNOPs (CameraFOVInstructionsScansResult[CutscenesFOV1], 3 ) ;
264275
265- AspectRatioInstruction2MidHook = safetyhook::create_mid (AspectRatioInstructionsScanResult + 12 , [](SafetyHookContext& ctx)
276+ CutscenesFOVInstruction1Hook = safetyhook::create_mid (CameraFOVInstructionsScansResult[CutscenesFOV1] , [](SafetyHookContext& ctx)
266277 {
267- *reinterpret_cast <float *>(ctx.ebx + 0xD8 ) = 1 .0f ;
278+ float & fCurrentCutscenesFOV1 = *reinterpret_cast <float *>(ctx.ebp + 0x10 );
279+
280+ fNewCutscenesFOV1 = fCurrentCutscenesFOV1 / fFOVFactor ;
281+
282+ FPU::FLD (fNewCutscenesFOV1 );
268283 });
269- }
270- else
271- {
272- spdlog::error (" Failed to locate aspect ratio instructions scan memory address." );
273- return ;
274- }
284+
285+ Memory::WriteNOPs (CameraFOVInstructionsScansResult[CutscenesFOV2], 3 );
286+
287+ CutscenesFOVInstruction2Hook = safetyhook::create_mid (CameraFOVInstructionsScansResult[CutscenesFOV2], [](SafetyHookContext& ctx)
288+ {
289+ float & fCurrentCutscenesFOV2 = *reinterpret_cast <float *>(ctx.ebp + 0x10 );
290+
291+ fNewCutscenesFOV2 = fCurrentCutscenesFOV2 / fFOVFactor ;
292+
293+ ctx.eax = std::bit_cast<uintptr_t >(fNewCutscenesFOV2 );
294+ });
295+
296+ fNewInterfaceWeaponFOV = 60 .0f / fFOVFactor ;
297+
298+ Memory::Write (CameraFOVInstructionsScansResult[InterfaceWeaponFOV] + 1 , fNewInterfaceWeaponFOV );
299+ }
275300 }
276301}
277302
0 commit comments