├── src ├── stdafx.cpp ├── stdafx.h ├── helper.hpp └── dllmain.cpp ├── .github └── FUNDING.yml ├── .gitmodules ├── OctopathFix.ini ├── LICENSE ├── OctopathFix.sln ├── OctopathFix.filters ├── README.md ├── .gitattributes ├── .gitignore └── OctopathFix.vcxproj /src/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | 2 | ko_fi: lyall 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/external/length-disassembler"] 2 | path = src/external/length-disassembler 3 | url = https://github.com/Nomade040/length-disassembler 4 | [submodule "src/external/loguru"] 5 | path = src/external/loguru 6 | url = https://github.com/emilk/loguru 7 | [submodule "src/external/inih"] 8 | path = src/external/inih 9 | url = https://github.com/jtilly/inih 10 | [submodule "src/external/inipp"] 11 | path = src/external/inipp 12 | url = https://github.com/mcmtroffaes/inipp 13 | -------------------------------------------------------------------------------- /OctopathFix.ini: -------------------------------------------------------------------------------- 1 | [OctopathFix Parameters] 2 | ; Injection delay in milliseconds. 3 | InjectionDelay = 500 4 | 5 | ;;;;;;;;;; Fixes ;;;;;;;;;; 6 | 7 | [Fix Aspect Ratio] 8 | ; Fixes aspect ratio. 9 | Enabled = true 10 | 11 | [Center HUD] 12 | ; Centers HUD to 16:9. 13 | Enabled = true 14 | 15 | [Fix HUD] 16 | ; Corrects offset HUD elements. 17 | Enabled = true 18 | 19 | [Fix FOV] 20 | ; Corrects FOV. 21 | ; Can add additional FOV. 22 | Enabled = true 23 | AdditionalFOV = 0 24 | 25 | [Uncap FPS] 26 | ; Uncaps 60FPS limit. 27 | Enabled = true -------------------------------------------------------------------------------- /src/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma comment(lib,"Version.lib") 3 | 4 | #define WIN32_LEAN_AND_MEAN 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "external/loguru/loguru.hpp" 19 | #include "external/inipp/inipp/inipp.h" 20 | #include "external/length-disassembler/headerOnly/ldisasm.h" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Lyall 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /OctopathFix.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32901.215 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OctopathFix", "OctopathFix.vcxproj", "{C6644269-B721-4F94-BE7F-77BFB2343BA5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {C6644269-B721-4F94-BE7F-77BFB2343BA5}.Debug|x64.ActiveCfg = Debug|x64 17 | {C6644269-B721-4F94-BE7F-77BFB2343BA5}.Debug|x64.Build.0 = Debug|x64 18 | {C6644269-B721-4F94-BE7F-77BFB2343BA5}.Debug|x86.ActiveCfg = Debug|Win32 19 | {C6644269-B721-4F94-BE7F-77BFB2343BA5}.Debug|x86.Build.0 = Debug|Win32 20 | {C6644269-B721-4F94-BE7F-77BFB2343BA5}.Release|x64.ActiveCfg = Release|x64 21 | {C6644269-B721-4F94-BE7F-77BFB2343BA5}.Release|x64.Build.0 = Release|x64 22 | {C6644269-B721-4F94-BE7F-77BFB2343BA5}.Release|x86.ActiveCfg = Release|Win32 23 | {C6644269-B721-4F94-BE7F-77BFB2343BA5}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {BD882CE7-25BA-4751-8EB4-4B14C55192CA} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /OctopathFix.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | 40 | 41 | Source Files 42 | 43 | 44 | Source Files 45 | 46 | 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Octopath Traveler Fix 2 | [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/W7W01UAI9)
3 | [![Github All Releases](https://img.shields.io/github/downloads/Lyall/OctopathFix/total.svg)](https://github.com/Lyall/OctopathFix/releases) 4 | 5 | This is a **work-in-progress** fix for ultrawide/narrower displays in Octopath Traveler. 6 | 7 | ## Features 8 | - Removes pillarboxing at ultrawide or non 16:9 resolutions. 9 | - Corrects FOV at ultrawide or non 16:9 resolutions. 10 | - 16:9 centered HUD with fixed UI elements. 11 | - 60 FPS cap removal. 12 | 13 | ## Installation 14 | - Grab the latest release of OctopathFix from [here.](https://github.com/Lyall/OctopathFix/releases) 15 | - Extract the contents of the release zip in to the game directory.
(e.g. "**steamapps\common\OCTOPATH TRAVELER**" for Steam). 16 | 17 | ## Configuration 18 | - See **OctopathFix.ini** to adjust settings for the fix. 19 | 20 | ## Linux/Steam Deck 21 | - Make sure you set the Steam launch options to `WINEDLLOVERRIDES="d3d11.dll=n,b" %command%` 22 | 23 | 24 | ## Known Issues 25 | Please report any issues you see. (**Check the known issues list first!**) 26 | - Screen fades and the battle wipe transitions are not spanned to fill the screen. 27 | 28 | ## Screenshots 29 | 30 | | ![ezgif-1-3a596def59](https://user-images.githubusercontent.com/695941/227731085-44e780fb-333b-4661-8b32-88bf300696ad.gif) | 31 | |:--:| 32 | | Disabled pillarboxing. | 33 | 34 | ## Credits 35 | [p1xel8ted](https://github.com/p1xel8ted) for kindly providing a copy of the game.
36 | [Flawless Widescreen](https://www.flawlesswidescreen.org/) for the LOD fix.
37 | [Ultimate ASI Loader](https://github.com/ThirteenAG/Ultimate-ASI-Loader) for ASI loading.
38 | [inipp](https://github.com/mcmtroffaes/inipp) for ini parsing.
39 | [Loguru](https://github.com/emilk/loguru) for logging.
40 | [length-disassembler](https://github.com/Nomade040/length-disassembler) for length disassembly. 41 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /OctopathFix.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 16.0 37 | Win32Proj 38 | {c6644269-b721-4f94-be7f-77bfb2343ba5} 39 | OctopathFix 40 | 10.0 41 | 42 | 43 | 44 | DynamicLibrary 45 | true 46 | Intel C++ Compiler 19.2 47 | Unicode 48 | 49 | 50 | DynamicLibrary 51 | false 52 | Intel C++ Compiler 19.2 53 | true 54 | Unicode 55 | 56 | 57 | DynamicLibrary 58 | true 59 | Intel C++ Compiler 19.2 60 | Unicode 61 | 62 | 63 | DynamicLibrary 64 | false 65 | Intel C++ Compiler 19.2 66 | true 67 | Unicode 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | .asi 89 | 90 | 91 | .asi 92 | 93 | 94 | 95 | Level3 96 | true 97 | WIN32;_DEBUG;OctopathFix_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 98 | true 99 | Use 100 | pch.h 101 | 102 | 103 | Windows 104 | true 105 | false 106 | 107 | 108 | 109 | 110 | Level3 111 | true 112 | true 113 | true 114 | WIN32;NDEBUG;OctopathFix_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS 115 | true 116 | NotUsing 117 | pch.h 118 | 119 | 120 | Windows 121 | true 122 | true 123 | true 124 | false 125 | 126 | 127 | 128 | 129 | Level3 130 | true 131 | _DEBUG;OctopathFix_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 132 | true 133 | Use 134 | pch.h 135 | 136 | 137 | Windows 138 | true 139 | false 140 | 141 | 142 | 143 | 144 | Level3 145 | true 146 | true 147 | true 148 | NDEBUG;OctopathFix_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS 149 | true 150 | NotUsing 151 | pch.h 152 | 153 | 154 | Windows 155 | true 156 | true 157 | true 158 | false 159 | 160 | 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /src/helper.hpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | namespace Memory 7 | { 8 | float roundf1(float var) 9 | { 10 | // we use array of chars to store number 11 | // as a string. 12 | char str[40]; 13 | 14 | // Print in string the value of var 15 | // with two decimal point 16 | sprintf(str, "%.1f", var); 17 | 18 | // scan string value in var 19 | sscanf(str, "%f", &var); 20 | 21 | return var; 22 | } 23 | 24 | template 25 | void Write(uintptr_t writeAddress, T value) 26 | { 27 | DWORD oldProtect; 28 | VirtualProtect((LPVOID)(writeAddress), sizeof(T), PAGE_EXECUTE_WRITECOPY, &oldProtect); 29 | *(reinterpret_cast(writeAddress)) = value; 30 | VirtualProtect((LPVOID)(writeAddress), sizeof(T), oldProtect, &oldProtect); 31 | } 32 | 33 | void PatchBytes(uintptr_t address, const char* pattern, unsigned int numBytes) 34 | { 35 | DWORD oldProtect; 36 | VirtualProtect((LPVOID)address, numBytes, PAGE_EXECUTE_READWRITE, &oldProtect); 37 | memcpy((LPVOID)address, pattern, numBytes); 38 | VirtualProtect((LPVOID)address, numBytes, oldProtect, &oldProtect); 39 | } 40 | 41 | void ReadBytes(const uintptr_t address, void* const buffer, const SIZE_T size) 42 | { 43 | memcpy(buffer, reinterpret_cast(address), size); 44 | } 45 | 46 | uintptr_t ReadMultiLevelPointer(uintptr_t base, const std::vector& offsets) 47 | { 48 | MEMORY_BASIC_INFORMATION mbi; 49 | for (auto& offset : offsets) 50 | { 51 | if (!VirtualQuery(reinterpret_cast(base), &mbi, sizeof(MEMORY_BASIC_INFORMATION)) || mbi.Protect & (PAGE_NOACCESS | PAGE_GUARD)) 52 | return 0; 53 | 54 | base = *reinterpret_cast(base) + offset; 55 | } 56 | 57 | return base; 58 | } 59 | 60 | int GetHookLength(char* src, int minLen) 61 | { 62 | int lengthHook = 0; 63 | const int size = 15; 64 | char buffer[size]; 65 | 66 | memcpy(buffer, src, size); 67 | 68 | // must be >= 14 69 | while (lengthHook <= minLen) 70 | lengthHook += ldisasm(&buffer[lengthHook], true); 71 | 72 | return lengthHook; 73 | } 74 | 75 | uintptr_t GetAbsolute(uintptr_t address) noexcept 76 | { 77 | return (address + 4 + *reinterpret_cast(address)); 78 | } 79 | 80 | bool DetourFunction32(void* src, void* dst, int len) 81 | { 82 | if (len < 5) return false; 83 | 84 | DWORD curProtection; 85 | VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &curProtection); 86 | 87 | memset(src, 0x90, len); 88 | 89 | uintptr_t relativeAddress = ((uintptr_t)dst - (uintptr_t)src) - 5; 90 | 91 | *(BYTE*)src = 0xE9; 92 | *(uintptr_t*)((uintptr_t)src + 1) = relativeAddress; 93 | 94 | DWORD temp; 95 | VirtualProtect(src, len, curProtection, &temp); 96 | 97 | return true; 98 | } 99 | 100 | void* DetourFunction64(void* pSource, void* pDestination, int dwLen) 101 | { 102 | DWORD MinLen = 14; 103 | 104 | if (dwLen < MinLen) return NULL; 105 | 106 | BYTE stub[] = { 107 | 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, // jmp qword ptr [$+6] 108 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // ptr 109 | }; 110 | 111 | void* pTrampoline = VirtualAlloc(0, dwLen + sizeof(stub), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); 112 | 113 | DWORD dwOld = 0; 114 | VirtualProtect(pSource, dwLen, PAGE_EXECUTE_READWRITE, &dwOld); 115 | 116 | DWORD64 retto = (DWORD64)pSource + dwLen; 117 | 118 | // trampoline 119 | memcpy(stub + 6, &retto, 8); 120 | memcpy((void*)((DWORD_PTR)pTrampoline), pSource, dwLen); 121 | memcpy((void*)((DWORD_PTR)pTrampoline + dwLen), stub, sizeof(stub)); 122 | 123 | // orig 124 | memcpy(stub + 6, &pDestination, 8); 125 | memcpy(pSource, stub, sizeof(stub)); 126 | 127 | for (int i = MinLen; i < dwLen; i++) 128 | { 129 | *(BYTE*)((DWORD_PTR)pSource + i) = 0x90; 130 | } 131 | 132 | VirtualProtect(pSource, dwLen, dwOld, &dwOld); 133 | return (void*)((DWORD_PTR)pTrampoline); 134 | } 135 | 136 | static HMODULE GetThisDllHandle() 137 | { 138 | MEMORY_BASIC_INFORMATION info; 139 | size_t len = VirtualQueryEx(GetCurrentProcess(), (void*)GetThisDllHandle, &info, sizeof(info)); 140 | assert(len == sizeof(info)); 141 | return len ? (HMODULE)info.AllocationBase : NULL; 142 | } 143 | 144 | // CSGOSimple's pattern scan 145 | // https://github.com/OneshotGH/CSGOSimple-master/blob/master/CSGOSimple/helpers/utils.cpp 146 | std::uint8_t* PatternScan(void* module, const char* signature) 147 | { 148 | static auto pattern_to_byte = [](const char* pattern) { 149 | auto bytes = std::vector{}; 150 | auto start = const_cast(pattern); 151 | auto end = const_cast(pattern) + strlen(pattern); 152 | 153 | for (auto current = start; current < end; ++current) { 154 | if (*current == '?') { 155 | ++current; 156 | if (*current == '?') 157 | ++current; 158 | bytes.push_back(-1); 159 | } 160 | else { 161 | bytes.push_back(strtoul(current, ¤t, 16)); 162 | } 163 | } 164 | return bytes; 165 | }; 166 | 167 | auto dosHeader = (PIMAGE_DOS_HEADER)module; 168 | auto ntHeaders = (PIMAGE_NT_HEADERS)((std::uint8_t*)module + dosHeader->e_lfanew); 169 | 170 | auto sizeOfImage = ntHeaders->OptionalHeader.SizeOfImage; 171 | auto patternBytes = pattern_to_byte(signature); 172 | auto scanBytes = reinterpret_cast(module); 173 | 174 | auto s = patternBytes.size(); 175 | auto d = patternBytes.data(); 176 | 177 | for (auto i = 0ul; i < sizeOfImage - s; ++i) { 178 | bool found = true; 179 | for (auto j = 0ul; j < s; ++j) { 180 | if (scanBytes[i + j] != d[j] && d[j] != -1) { 181 | found = false; 182 | break; 183 | } 184 | } 185 | if (found) { 186 | return &scanBytes[i]; 187 | } 188 | } 189 | return nullptr; 190 | } 191 | 192 | std::string GetVersionString() 193 | { 194 | auto hInst = GetModuleHandle(NULL); 195 | auto hResInfo = FindResourceW(hInst, MAKEINTRESOURCE(1), RT_VERSION); 196 | if (!hResInfo) return {}; 197 | auto dwSize = SizeofResource(hInst, hResInfo); 198 | if (!dwSize) return {}; 199 | auto hResData = LoadResource(hInst, hResInfo); 200 | char* pRes = static_cast(LockResource(hResData)); 201 | if (!pRes) return {}; 202 | 203 | std::vector ResCopy(pRes, pRes + dwSize); 204 | 205 | VS_FIXEDFILEINFO* pvFileInfo; 206 | UINT uiFileInfoLen; 207 | 208 | if (!VerQueryValueA(ResCopy.data(), "\\", reinterpret_cast(&pvFileInfo), &uiFileInfoLen)) 209 | return "(unknown)"; 210 | 211 | char buf[25]; 212 | int len = sprintf(buf, "%hu.%hu.%hu.%hu", 213 | HIWORD(pvFileInfo->dwFileVersionMS), 214 | LOWORD(pvFileInfo->dwFileVersionMS), 215 | HIWORD(pvFileInfo->dwFileVersionLS), 216 | LOWORD(pvFileInfo->dwFileVersionLS) 217 | ); 218 | 219 | return std::string(buf, len); 220 | } 221 | 222 | vector string_to_ints(const string& s, char delimiter) { 223 | vector tokens; 224 | string token; 225 | istringstream tokenStream(s); 226 | while (getline(tokenStream, token, delimiter)) { 227 | tokens.push_back(stoi(token)); 228 | } 229 | return tokens; 230 | } 231 | 232 | 233 | std::wstring GetVersionProductName() 234 | { 235 | struct LANGCODEPAGE { 236 | WORD wLang; 237 | WORD wCode; 238 | } *lpTranslate; 239 | 240 | UINT cbTranslate; 241 | 242 | HMODULE baseModule = GetModuleHandle(NULL); 243 | 244 | auto exePath = new WCHAR[_MAX_PATH]; 245 | GetModuleFileName(baseModule, exePath, _MAX_PATH); 246 | auto size = GetFileVersionInfoSize(exePath, NULL); 247 | std::vector buffer(size); 248 | GetFileVersionInfo(exePath, NULL, size, buffer.data()); 249 | VerQueryValue(buffer.data(), L"VarFileInfo\\Translation", (LPVOID*)&lpTranslate, &cbTranslate); 250 | 251 | if (cbTranslate < sizeof(LANGCODEPAGE)) { 252 | return L""; 253 | } 254 | 255 | wchar_t query[512]; 256 | _snwprintf(query, sizeof(query), L"\\StringFileInfo\\%04x%04x\\ProductName", lpTranslate[0].wLang, lpTranslate[0].wCode); 257 | wchar_t const* p; 258 | UINT n_chars; 259 | VerQueryValue(buffer.data(), query, (LPVOID*)&p, &n_chars); 260 | return std::wstring(p, p + n_chars); 261 | } 262 | } -------------------------------------------------------------------------------- /src/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "helper.hpp" 3 | 4 | using namespace std; 5 | 6 | HMODULE baseModule = GetModuleHandle(NULL); 7 | 8 | inipp::Ini ini; 9 | 10 | // INI Variables 11 | bool bAspectFix; 12 | bool bFOVFix; 13 | bool bHUDFix; 14 | bool bHUDCenter; 15 | bool bUncapFPS; 16 | int iCustomResX; 17 | int iCustomResY; 18 | int iInjectionDelay; 19 | float fAdditionalFOV; 20 | int iAspectFix; 21 | int iFOVFix; 22 | 23 | // Variables 24 | int iNarrowAspect; 25 | float fNewX; 26 | float fNewY; 27 | float fNativeAspect = 1.777777791f; 28 | float fPi = 3.14159265358979323846f; 29 | float fNewAspect; 30 | float fAspectMultiplier; 31 | float fZero = (float)0; 32 | float fOne = (float)1; 33 | float fTwo = (float)2; 34 | 35 | string sExeName; 36 | string sGameName; 37 | string sExePath; 38 | string sGameVersion; 39 | string sFixVer = "0.0.1"; 40 | 41 | // CurrResolution Hook 42 | DWORD64 CurrResolutionReturnJMP; 43 | float UIWidth; 44 | float UIHeight; 45 | float UIHorOffset; 46 | float UIVertOffset; 47 | void __declspec(naked) CurrResolution_CC() 48 | { 49 | __asm 50 | { 51 | mov r12d, r9d // Original code 52 | mov rbx, rdx // Original code 53 | mov rdi, [rax + r8 * 0x8] // Original code 54 | add rdi, rcx // Original code 55 | mov eax, [rdi] // Original code 56 | 57 | // Get current resolution + aspect ratio 58 | mov[iCustomResX], r15d // Grab current resX 59 | mov[iCustomResY], r12d // Grab current resY 60 | cvtsi2ss xmm14, r15d 61 | cvtsi2ss xmm15, r12d 62 | divss xmm14, xmm15 63 | movss[fNewAspect], xmm14 // Grab current aspect ratio 64 | 65 | // Get 16:9 HUD values 66 | movd xmm14, [iCustomResY] 67 | cvtdq2ps xmm14, xmm14 68 | mulss xmm14, [fNativeAspect] 69 | movss [UIWidth], xmm14 70 | movd xmm14, [iCustomResX] 71 | cvtdq2ps xmm14, xmm14 72 | subss xmm14, [UIWidth] 73 | divss xmm14, [fTwo] 74 | movss[UIHorOffset], xmm14 75 | movd xmm14, [iCustomResX] 76 | cvtdq2ps xmm14, xmm14 77 | divss xmm14, [fNativeAspect] 78 | movss [UIHeight], xmm14 79 | movd xmm14, [iCustomResY] 80 | cvtdq2ps xmm14, xmm14 81 | subss xmm14, [UIHeight] 82 | divss xmm14, [fTwo] 83 | movss [UIVertOffset], xmm14 84 | movss xmm14, [fNewAspect] 85 | movss xmm15, [fNativeAspect] 86 | divss xmm14, xmm15 87 | movss [fAspectMultiplier], xmm14 88 | 89 | xorps xmm14, xmm14 90 | xorps xmm15, xmm15 91 | jmp[CurrResolutionReturnJMP] 92 | } 93 | } 94 | 95 | // Aspect Ratio/FOV Hook 96 | DWORD64 AspectFOVFixReturnJMP; 97 | float FOVPiDiv; 98 | float FOVDivPi; 99 | float FOVFinalValue; 100 | void __declspec(naked) AspectFOVFix_CC() 101 | { 102 | __asm 103 | { 104 | mov [iNarrowAspect], 1 105 | mov eax, [fNewAspect] // Move new aspect to eax 106 | cmp eax, [fNativeAspect] // Compare new aspect to native 107 | jle originalCode // Skip FOV fix if fNewAspect<=fNativeAspect 108 | cmp[iFOVFix], 1 // Check if FOVFix is enabled 109 | je modifyFOV // jmp to FOV fix 110 | jmp originalCode // jmp to originalCode 111 | 112 | modifyFOV: 113 | mov[iNarrowAspect], 0 // Note that aspect ratio is <= 1.78 114 | fld dword ptr[rdi + 0x290] // Push original FOV to FPU register st(0) 115 | fmul[FOVPiDiv] // Multiply st(0) by Pi/360 116 | fptan // Get partial tangent. Store result in st(1). Store 1.0 in st(0) 117 | fxch st(1) // Swap st(1) to st(0) 118 | fdiv[fNativeAspect] // Divide st(0) by 1.778~ 119 | fmul[fNewAspect] // Multiply st(0) by new aspect ratio 120 | fxch st(1) // Swap st(1) to st(0) 121 | fpatan // Get partial arc tangent from st(0), st(1) 122 | fmul[FOVDivPi] // Multiply st(0) by 360/Pi 123 | fadd[fAdditionalFOV] // Add additional FOV 124 | fstp[FOVFinalValue] // Store st(0) 125 | movss xmm0, [FOVFinalValue] // Copy final FOV value to xmm0 126 | jmp originalCode 127 | 128 | originalCode: 129 | movss[rsi + 0x18], xmm0 // Original code 130 | cmp[iAspectFix], 1 131 | je modifyAspect 132 | mov eax, [rdi + 0x000002A0] // Original code 133 | mov[rsi + 0x28], eax // Original code 134 | jmp[AspectFOVFixReturnJMP] 135 | 136 | modifyAspect: 137 | mov eax, [fNewAspect] 138 | mov[rsi + 0x28], eax // Original code 139 | jmp[AspectFOVFixReturnJMP] 140 | } 141 | } 142 | 143 | // FOV Culling Hook 144 | DWORD64 FOVCullingReturnJMP; 145 | void __declspec(naked) FOVCulling_CC() 146 | { 147 | __asm 148 | { 149 | cmp iFOVFix, 0 150 | je originalCode 151 | movss xmm0, [fOne] 152 | jmp originalCode 153 | 154 | originalCode: 155 | movss[rcx + 0x000003F0], xmm0 // Original code 156 | movsd xmm0, [rbp + 0x000000F0] // Original code 157 | jmp[FOVCullingReturnJMP] 158 | } 159 | } 160 | 161 | // CenterHUD Hook 162 | DWORD64 CenterHUDReturnJMP; 163 | void __declspec(naked) CenterHUD_CC() 164 | { 165 | __asm 166 | { 167 | movups xmm0, [rcx + 0x000001B0] // Original code 168 | mov rax, rdx // Original code 169 | movups[rdx], xmm0 // Original code 170 | 171 | cmp byte ptr[rcx + 0x248], 1 172 | je fixBattleWipe 173 | cmp [iNarrowAspect], 0 174 | je resizeHUDHor 175 | cmp [iNarrowAspect], 1 176 | je resizeHUDVert 177 | ret // Original code 178 | jmp[CenterHUDReturnJMP] // Just in case 179 | 180 | resizeHUDHor: 181 | movss xmm0, [UIHorOffset] 182 | movd xmm15, [iCustomResX] 183 | cvtdq2ps xmm15, xmm15 184 | divss xmm0, xmm15 185 | movss [rdx], xmm0 186 | movss xmm0, [fOne] 187 | subss xmm0, [rdx] 188 | movss [rdx+0x8], xmm0 189 | xorps xmm14, xmm14 190 | xorps xmm15, xmm15 191 | ret // Original code 192 | jmp[CenterHUDReturnJMP] // Just in case 193 | 194 | resizeHUDVert: 195 | movss xmm0, [UIVertOffset] 196 | movd xmm15, [iCustomResY] 197 | cvtdq2ps xmm15, xmm15 198 | divss xmm0, xmm15 199 | movss[rdx+0x4], xmm0 200 | movss xmm0, [fOne] 201 | subss xmm0, [rdx+0x4] 202 | movss [rdx+0xC], xmm0 203 | xorps xmm14, xmm14 204 | xorps xmm15, xmm15 205 | ret // Original code 206 | jmp[CenterHUDReturnJMP] // Just in case 207 | 208 | fixBattleWipe: 209 | cmp dword ptr[rcx + 0xb6], 1024 210 | jne $-0xA1 211 | cmp byte ptr[rcx + 0xb7], 4 212 | jne $-0xAE 213 | push r8 214 | cmp iNarrowAspect, 1 215 | je resizeScaleHor 216 | movss xmm15, [fOne] 217 | mulss xmm15, [fAspectMultiplier] 218 | mov r8, [rcx + 0x208] 219 | movss [r8 + 0x98], xmm15 220 | mov r8, [rcx + 0x218] 221 | movss[r8 + 0x98], xmm15 222 | mov r8, [rcx + 0x220] 223 | movss[r8 + 0x98], xmm15 224 | mov r8, [rcx + 0x228] 225 | movss[r8 + 0x98], xmm15 226 | mov r8, [rcx + 0x230] 227 | movss[r8 + 0x98], xmm15 228 | mov r8, [rcx + 0x238] 229 | movss[r8 + 0x98], xmm15 230 | mov r8, [rcx + 0x240] 231 | movss[r8 + 0x98], xmm15 232 | pop r8 233 | xorps xmm15,xmm15 234 | jmp $-0x14B 235 | 236 | resizeScaleHor: 237 | movss xmm15, [fOne] 238 | divss xmm15, [fAspectMultiplier] 239 | mov r8, [rcx + 0x208] 240 | movss[r8 + 0x9C], xmm15 241 | mov r8, [rcx + 0x218] 242 | movss[r8 + 0x9C], xmm15 243 | mov r8, [rcx + 0x220] 244 | movss[r8 + 0x9C], xmm15 245 | mov r8, [rcx + 0x228] 246 | movss[r8 + 0x9C], xmm15 247 | mov r8, [rcx + 0x230] 248 | movss[r8 + 0x9C], xmm15 249 | mov r8, [rcx + 0x238] 250 | movss[r8 + 0x9C], xmm15 251 | mov r8, [rcx + 0x240] 252 | movss[r8 + 0x9C], xmm15 253 | pop r8 254 | xorps xmm15, xmm15 255 | jmp $-0x1D8 256 | 257 | doNothing: 258 | ret // Original code 259 | jmp[CenterHUDReturnJMP] // Just in case 260 | } 261 | } 262 | 263 | // HUDMarkers Hook 264 | DWORD64 HUDMarkersReturnJMP; 265 | void __declspec(naked) HUDMarkers_CC() 266 | { 267 | __asm 268 | { 269 | cmp iNarrowAspect, 1 270 | je markersVert 271 | cvtdq2ps xmm1, xmm1 // Original code 272 | movss xmm1, [UIHorOffset] 273 | movd xmm0, eax // Original code 274 | cvtdq2ps xmm0, xmm0 // Original code 275 | subss xmm3, xmm1 // Original code 276 | jmp[HUDMarkersReturnJMP] 277 | 278 | markersVert: 279 | cvtdq2ps xmm1,xmm1 // Original code 280 | movd xmm0,eax // Original code 281 | cvtdq2ps xmm0,xmm0 // Original code 282 | movss xmm0, [UIVertOffset] 283 | subss xmm3,xmm1 // Original code 284 | jmp[HUDMarkersReturnJMP] 285 | } 286 | } 287 | 288 | // BattleCursor Hook 289 | DWORD64 BattleCursorReturnJMP; 290 | void __declspec(naked) BattleCursor_CC() 291 | { 292 | __asm 293 | { 294 | cmp iNarrowAspect, 1 295 | je cursorVert 296 | movss xmm1, [UIHorOffset] 297 | movd xmm2, ecx // Original code 298 | subss xmm0, xmm1 // Original code 299 | movss xmm1, [rbx + 0x04] // Original code 300 | cvtdq2ps xmm2, xmm2 // Original code 301 | jmp[BattleCursorReturnJMP] 302 | 303 | cursorVert: 304 | movd xmm2, ecx // Original code 305 | subss xmm0, xmm1 // Original code 306 | movss xmm1, [rbx + 0x04] // Original code 307 | cvtdq2ps xmm2, xmm2 // Original code 308 | movss xmm2, [UIVertOffset] 309 | jmp[BattleCursorReturnJMP] 310 | } 311 | } 312 | 313 | // UncapFPS Hook 314 | DWORD64 UncapFPSReturnJMP; 315 | void __declspec(naked) UncapFPS_CC() 316 | { 317 | __asm 318 | { 319 | movaps xmm6, [rsp + 0x40] // Original code 320 | movaps xmm8, [rsp + 0x30] // Original code 321 | movaps xmm9, [rsp + 0x20] // Original code 322 | movss xmm0, [fZero] 323 | jmp[UncapFPSReturnJMP] 324 | } 325 | } 326 | 327 | // Fade Hook 328 | DWORD64 FadeReturnJMP; 329 | float fFadeBrushX = (float)1280; 330 | float fFadeBrushY = (float)720; 331 | void __declspec(naked) Fade_CC() 332 | { 333 | __asm 334 | { 335 | mov[rsp + 0x08], rbx // Original code 336 | mov[rsp + 0x18], rbp // Original code 337 | push rsi // Original code 338 | push rdi // Original code 339 | push r14 // Original code 340 | 341 | mov rdi, [rcx+0x248] // rdi/edi is xor'd later so safe to use 342 | cmp rdi, 0 343 | je $+0xD // if image pointer address is 0 then return 344 | cmp iNarrowAspect, 1 345 | je fadeBrushY 346 | jmp fadeBrushX 347 | jmp[FadeReturnJMP] 348 | 349 | fadeBrushX: 350 | movss xmm15, [fFadeBrushY] 351 | movss xmm14, [fFadeBrushX] 352 | movss [rdi+0x104], xmm15 353 | mulss xmm15, [fNewAspect] 354 | movss [rdi + 0x100], xmm15 // Write new Brush.ImageSize.X 355 | xorps xmm15, xmm15 356 | xorps xmm14, xmm14 357 | jmp[FadeReturnJMP] 358 | 359 | fadeBrushY: 360 | movss xmm15, [fFadeBrushX] 361 | movss xmm14, [fFadeBrushY] 362 | movss[rdi + 0x100], xmm15 363 | divss xmm15, [fNewAspect] 364 | movss[rdi + 0x104], xmm15 // Write new Brush.ImageSize.Y 365 | xorps xmm15, xmm15 366 | xorps xmm14, xmm14 367 | jmp[FadeReturnJMP] 368 | } 369 | } 370 | 371 | void Logging() 372 | { 373 | loguru::add_file("OctopathFix.log", loguru::Truncate, loguru::Verbosity_MAX); 374 | loguru::set_thread_name("Main"); 375 | 376 | LOG_F(INFO, "OctopathFix v%s loaded", sFixVer.c_str()); 377 | } 378 | 379 | void ReadConfig() 380 | { 381 | // Get game name and exe path 382 | LPWSTR exePath = new WCHAR[_MAX_PATH]; 383 | GetModuleFileNameW(baseModule, exePath, _MAX_PATH); 384 | wstring exePathWString(exePath); 385 | sExePath = string(exePathWString.begin(), exePathWString.end()); 386 | wstring wsGameName = Memory::GetVersionProductName(); 387 | sExeName = sExePath.substr(sExePath.find_last_of("/\\") + 1); 388 | sGameName = string(wsGameName.begin(), wsGameName.end()); 389 | 390 | LOG_F(INFO, "Game Name: %s", sGameName.c_str()); 391 | LOG_F(INFO, "Game Path: %s", sExePath.c_str()); 392 | 393 | // Initialize config 394 | // UE4 games use launchers so config path is relative to launcher 395 | sGameVersion = "Steam"; 396 | std::ifstream iniFile(".\\Octopath_Traveler\\Binaries\\Win64\\OctopathFix.ini"); 397 | if (!iniFile) 398 | { 399 | LOG_F(ERROR, "Failed to load config file. (Steam)"); 400 | LOG_F(ERROR, "Trying alternate config path."); 401 | std::ifstream iniFile("OctopathFix.ini"); 402 | if (!iniFile) 403 | { 404 | LOG_F(ERROR, "Failed to load config file. (Alternate path)"); 405 | LOG_F(ERROR, "Please ensure that the ini configuration file is in the correct place."); 406 | } 407 | else 408 | { 409 | ini.parse(iniFile); 410 | LOG_F(INFO, "Successfuly loaded config file. (Alternate path)"); 411 | } 412 | } 413 | else 414 | { 415 | ini.parse(iniFile); 416 | LOG_F(INFO, "Successfuly loaded config file. (Steam)"); 417 | } 418 | 419 | LOG_F(INFO, "Game Version: %s", sGameVersion.c_str()); 420 | 421 | inipp::get_value(ini.sections["OctopathFix Parameters"], "InjectionDelay", iInjectionDelay); 422 | inipp::get_value(ini.sections["Fix Aspect Ratio"], "Enabled", bAspectFix); 423 | iAspectFix = (int)bAspectFix; 424 | inipp::get_value(ini.sections["Center HUD"], "Enabled", bHUDCenter); 425 | inipp::get_value(ini.sections["Fix HUD"], "Enabled", bHUDFix); 426 | inipp::get_value(ini.sections["Fix FOV"], "Enabled", bFOVFix); 427 | iFOVFix = (int)bFOVFix; 428 | inipp::get_value(ini.sections["Fix FOV"], "AdditionalFOV", fAdditionalFOV); 429 | inipp::get_value(ini.sections["Uncap FPS"], "Enabled", bUncapFPS); 430 | 431 | // Custom resolution 432 | if (iCustomResX > 0 && iCustomResY > 0) 433 | { 434 | fNewX = (float)iCustomResX; 435 | fNewY = (float)iCustomResY; 436 | fNewAspect = (float)iCustomResX / (float)iCustomResY; 437 | } 438 | else 439 | { 440 | // Grab desktop resolution 441 | RECT desktop; 442 | GetWindowRect(GetDesktopWindow(), &desktop); 443 | fNewX = (float)desktop.right; 444 | fNewY = (float)desktop.bottom; 445 | iCustomResX = (int)desktop.right; 446 | iCustomResY = (int)desktop.bottom; 447 | fNewAspect = (float)desktop.right / (float)desktop.bottom; 448 | } 449 | 450 | // Log config parse 451 | LOG_F(INFO, "Config Parse: iInjectionDelay: %dms", iInjectionDelay); 452 | LOG_F(INFO, "Config Parse: bAspectFix: %d", bAspectFix); 453 | LOG_F(INFO, "Config Parse: bFOVFix: %d", bFOVFix); 454 | LOG_F(INFO, "Config Parse: fAdditionalFOV: %.2f", fAdditionalFOV); 455 | LOG_F(INFO, "Config Parse: bHUDCenter: %d", bHUDCenter); 456 | LOG_F(INFO, "Config Parse: bHUDFix: %d", bHUDFix); 457 | LOG_F(INFO, "Config Parse: bUncapFPS: %d", bUncapFPS); 458 | LOG_F(INFO, "Config Parse: iCustomResX: %d", iCustomResX); 459 | LOG_F(INFO, "Config Parse: iCustomResY: %d", iCustomResY); 460 | LOG_F(INFO, "Config Parse: fNewX: %.2f", fNewX); 461 | LOG_F(INFO, "Config Parse: fNewY: %.2f", fNewY); 462 | LOG_F(INFO, "Config Parse: fNewAspect: %.4f", fNewAspect); 463 | } 464 | 465 | void AspectFOVFix() 466 | { 467 | if (bAspectFix || bFOVFix) 468 | { 469 | // Grab important values like current resolution/aspect ratio. 470 | uint8_t* CurrResolutionScanResult = Memory::PatternScan(baseModule, "33 ?? B9 ?? ?? ?? ?? 45 ?? ?? 48 ?? ?? 4A ?? ?? ?? 48 ?? ?? 8B ??"); 471 | if (CurrResolutionScanResult) 472 | { 473 | DWORD64 CurrResolutionAddress = (uintptr_t)CurrResolutionScanResult + 0x7; 474 | int CurrResolutionHookLength = Memory::GetHookLength((char*)CurrResolutionAddress, 13); 475 | CurrResolutionReturnJMP = CurrResolutionAddress + CurrResolutionHookLength; 476 | Memory::DetourFunction64((void*)CurrResolutionAddress, CurrResolution_CC, CurrResolutionHookLength); 477 | 478 | LOG_F(INFO, "Current Resolution: Hook length is %d bytes", CurrResolutionHookLength); 479 | LOG_F(INFO, "Current Resolution: Hook address is 0x%" PRIxPTR, (uintptr_t)CurrResolutionAddress); 480 | } 481 | else if (!CurrResolutionScanResult) 482 | { 483 | LOG_F(INFO, "Current Resolution: Pattern scan failed."); 484 | } 485 | 486 | // Set correct aspect ratio + FOV 487 | uint8_t* AspectFOVFixScanResult = Memory::PatternScan(baseModule, "F3 0F ?? ?? ?? 8B ?? ?? ?? ?? ?? 89 ?? ?? 8B ?? ?? 33 ?? ?? ?? ?? ??"); 488 | if (AspectFOVFixScanResult) 489 | { 490 | FOVPiDiv = fPi / 360; 491 | FOVDivPi = 360 / fPi; 492 | 493 | DWORD64 AspectFOVFixAddress = (uintptr_t)AspectFOVFixScanResult; 494 | int AspectFOVFixHookLength = Memory::GetHookLength((char*)AspectFOVFixAddress, 13); 495 | AspectFOVFixReturnJMP = AspectFOVFixAddress + AspectFOVFixHookLength; 496 | Memory::DetourFunction64((void*)AspectFOVFixAddress, AspectFOVFix_CC, AspectFOVFixHookLength); 497 | 498 | LOG_F(INFO, "Aspect Ratio/FOV: Hook length is %d bytes", AspectFOVFixHookLength); 499 | LOG_F(INFO, "Aspect Ratio/FOV: Hook address is 0x%" PRIxPTR, (uintptr_t)AspectFOVFixAddress); 500 | } 501 | else if (!AspectFOVFixScanResult) 502 | { 503 | LOG_F(INFO, "Aspect Ratio/FOV: Pattern scan failed."); 504 | } 505 | } 506 | 507 | if (bFOVFix) 508 | { 509 | // Fix worse LOD at higher FOVs 510 | uint8_t* FOVCullingScanResult = Memory::PatternScan(baseModule, "F3 0F ?? ?? F3 0F ?? ?? ?? ?? ?? ?? F2 0F ?? ?? ?? ?? ?? ?? 8B 85 ?? ?? ?? ??"); 511 | if (FOVCullingScanResult) 512 | { 513 | DWORD64 FOVCullingAddress = (uintptr_t)FOVCullingScanResult + 0x4; 514 | int FOVCullingHookLength = Memory::GetHookLength((char*)FOVCullingAddress, 13); 515 | FOVCullingReturnJMP = FOVCullingAddress + FOVCullingHookLength; 516 | Memory::DetourFunction64((void*)FOVCullingAddress, FOVCulling_CC, FOVCullingHookLength); 517 | 518 | LOG_F(INFO, "FOV Culling: Hook length is %d bytes", FOVCullingHookLength); 519 | LOG_F(INFO, "FOV Culling: Hook address is 0x%" PRIxPTR, (uintptr_t)FOVCullingAddress); 520 | } 521 | else if (!FOVCullingScanResult) 522 | { 523 | LOG_F(INFO, "FOV Culling: Pattern scan failed."); 524 | } 525 | } 526 | } 527 | 528 | void HUDFix() 529 | { 530 | if (bHUDCenter) 531 | { 532 | // Center HUD to 16:9 533 | uint8_t* CenterHUDScanResult = Memory::PatternScan(baseModule, "0F 10 ? ? ? ? ? 48 8B ? 0F 11 ? C3 CC CC 48 89 ? ? ? 57"); 534 | if (CenterHUDScanResult) 535 | { 536 | DWORD64 CenterHUDAddress = (uintptr_t)CenterHUDScanResult; 537 | int CenterHUDHookLength = Memory::GetHookLength((char*)CenterHUDAddress, 13); 538 | CenterHUDReturnJMP = CenterHUDAddress + CenterHUDHookLength; 539 | Memory::DetourFunction64((void*)CenterHUDAddress, CenterHUD_CC, CenterHUDHookLength); 540 | 541 | LOG_F(INFO, "Center HUD: Hook length is %d bytes", CenterHUDHookLength); 542 | LOG_F(INFO, "Center HUD: Hook address is 0x%" PRIxPTR, (uintptr_t)CenterHUDAddress); 543 | } 544 | else if (!CenterHUDScanResult) 545 | { 546 | LOG_F(INFO, "Center HUD: Pattern scan failed."); 547 | } 548 | } 549 | 550 | if (bHUDFix) 551 | { 552 | // Fix offset hud elements (such as dialogue bubbles) 553 | if (bHUDCenter) 554 | { 555 | uint8_t* HUDMarkersScanResult = Memory::PatternScan(baseModule, "74 ?? 48 8B ?? ?? ?? ?? ?? ?? 66 0F ?? ?? 48 C1 ?? ??"); 556 | if (HUDMarkersScanResult) 557 | { 558 | DWORD64 HUDMarkersAddress = (uintptr_t)HUDMarkersScanResult + 0x12; 559 | int HUDMarkersHookLength = Memory::GetHookLength((char*)HUDMarkersAddress, 13); 560 | HUDMarkersReturnJMP = HUDMarkersAddress + HUDMarkersHookLength; 561 | Memory::DetourFunction64((void*)HUDMarkersAddress, HUDMarkers_CC, HUDMarkersHookLength); 562 | 563 | LOG_F(INFO, "HUD Markers: Hook length is %d bytes", HUDMarkersHookLength); 564 | LOG_F(INFO, "HUD Markers: Hook address is 0x%" PRIxPTR, (uintptr_t)HUDMarkersAddress); 565 | } 566 | else if (!HUDMarkersScanResult) 567 | { 568 | LOG_F(INFO, "HUD Markers: Pattern scan failed."); 569 | } 570 | } 571 | 572 | // Fix battle icons/cursor being offset 573 | if (bHUDCenter) 574 | { 575 | uint8_t* BattleCursorScanResult = Memory::PatternScan(baseModule, "66 0F ?? ?? F3 0F ?? ?? F3 0F ?? ?? ?? 0F 5B ?? F3 0F ?? ?? F3 0F ?? ?? F3 0F"); 576 | if (BattleCursorScanResult) 577 | { 578 | DWORD64 BattleCursorAddress = (uintptr_t)BattleCursorScanResult; 579 | int BattleCursorHookLength = Memory::GetHookLength((char*)BattleCursorAddress, 13); 580 | BattleCursorReturnJMP = BattleCursorAddress + BattleCursorHookLength; 581 | Memory::DetourFunction64((void*)BattleCursorAddress, BattleCursor_CC, BattleCursorHookLength); 582 | 583 | LOG_F(INFO, "Battle Cursor: Hook length is %d bytes", BattleCursorHookLength); 584 | LOG_F(INFO, "Battle Cursor: Hook address is 0x%" PRIxPTR, (uintptr_t)BattleCursorAddress); 585 | } 586 | else if (!BattleCursorScanResult) 587 | { 588 | LOG_F(INFO, "Battle Cursor: Pattern scan failed."); 589 | } 590 | } 591 | 592 | // Resize fades to fill screen 593 | if (bHUDCenter) 594 | { 595 | uint8_t* FadeScanResult = Memory::PatternScan(baseModule, "5F 5E C3 CC CC CC 48 89 ?? ?? ?? 48 89 ?? ?? ?? 48 89 ?? ?? ?? 57 48 83 EC ?? 33 FF"); 596 | if (FadeScanResult) 597 | { 598 | DWORD64 FadeAddress = (uintptr_t)FadeScanResult - 0xDA; 599 | int FadeHookLength = Memory::GetHookLength((char*)FadeAddress, 13); 600 | FadeReturnJMP = FadeAddress + FadeHookLength; 601 | Memory::DetourFunction64((void*)FadeAddress, Fade_CC, FadeHookLength); 602 | 603 | LOG_F(INFO, "Fade: Hook length is %d bytes", FadeHookLength); 604 | LOG_F(INFO, "Fade: Hook address is 0x%" PRIxPTR, (uintptr_t)FadeAddress); 605 | } 606 | else if (!FadeScanResult) 607 | { 608 | LOG_F(INFO, "Fade: Pattern scan failed."); 609 | } 610 | } 611 | } 612 | } 613 | 614 | void UncapFPS() 615 | { 616 | if (bUncapFPS) 617 | { 618 | // Uncap 60FPS limit 619 | uint8_t* UncapFPSScanResult = Memory::PatternScan(baseModule, "77 ?? 0F 28 ?? 0F 28 ?? ?? ?? 44 0F ?? ?? ?? ?? 44 0F ?? ?? ?? ?? 48 83 ?? ?? 5B C3"); 620 | if (UncapFPSScanResult) 621 | { 622 | DWORD64 UncapFPSAddress = (uintptr_t)UncapFPSScanResult + 0x5; 623 | int UncapFPSHookLength = Memory::GetHookLength((char*)UncapFPSAddress, 13); 624 | UncapFPSReturnJMP = UncapFPSAddress + UncapFPSHookLength; 625 | Memory::DetourFunction64((void*)UncapFPSAddress, UncapFPS_CC, UncapFPSHookLength); 626 | 627 | LOG_F(INFO, "Uncap FPS: Hook length is %d bytes", UncapFPSHookLength); 628 | LOG_F(INFO, "Uncap FPS: Hook address is 0x%" PRIxPTR, (uintptr_t)UncapFPSAddress); 629 | } 630 | else if (!UncapFPSScanResult) 631 | { 632 | LOG_F(INFO, "Uncap FPS: Pattern scan failed."); 633 | } 634 | } 635 | } 636 | 637 | 638 | DWORD __stdcall Main(void*) 639 | { 640 | Logging(); 641 | ReadConfig(); 642 | Sleep(iInjectionDelay); 643 | AspectFOVFix(); 644 | HUDFix(); 645 | UncapFPS(); 646 | return true; // end thread 647 | } 648 | 649 | BOOL APIENTRY DllMain(HMODULE hModule, 650 | DWORD ul_reason_for_call, 651 | LPVOID lpReserved 652 | ) 653 | { 654 | switch (ul_reason_for_call) 655 | { 656 | case DLL_PROCESS_ATTACH: 657 | { 658 | HANDLE mainHandle = CreateThread(NULL, 0, Main, 0, NULL, 0); 659 | 660 | if (mainHandle) 661 | { 662 | CloseHandle(mainHandle); 663 | } 664 | } 665 | case DLL_THREAD_ATTACH: 666 | case DLL_THREAD_DETACH: 667 | case DLL_PROCESS_DETACH: 668 | break; 669 | } 670 | return TRUE; 671 | } 672 | 673 | --------------------------------------------------------------------------------