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

Fix for latest Elden Ring patch (1.12 Shadow of the Erdtree) and include new options for ultrawide #147

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions EldenRingFPSUnlockAndMore/App.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="EldenRingFPSUnlockAndMore.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<userSettings>
Expand Down Expand Up @@ -49,6 +49,12 @@
<setting name="DisableCamLockResetTicked" serializeAs="String">
<value>False</value>
</setting>
<setting name="LongAnimations" serializeAs="String">
<value>False</value>
</setting>
<setting name="AutoStartTicked" serializeAs="String">
<value>False</value>
</setting>
</EldenRingFPSUnlockAndMore.Properties.Settings>
</userSettings>
</configuration>
24 changes: 16 additions & 8 deletions EldenRingFPSUnlockAndMore/GameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal class GameData
internal const string PROCESS_DESCRIPTION = "elden";
internal static readonly string[] PROCESS_EXE_VERSION_SUPPORTED = new string[]
{
"1.2.0.0",
"1.2.1.0"
"2.0.1.0",
"2.2.0.0"
};

/**
Expand All @@ -22,7 +22,7 @@ internal class GameData

00007FF6AEA0EF5F (Version 1.2.0.0)
*/
internal const string PATTERN_FRAMELOCK = "C7 ?? ?? ?? 88 88 3C EB"; // first byte can can be 88/90 instead of 89 due to precision loss on floating point numbers
internal const string PATTERN_FRAMELOCK = "C7 43 1C 89 88 3C EB"; // first byte can can be 88/90 instead of 89 due to precision loss on floating point numbers
internal const int PATTERN_FRAMELOCK_OFFSET = 3; // offset to byte array from found position
internal const string PATTERN_FRAMELOCK_FUZZY = "89 73 ?? C7 ?? ?? ?? ?? ?? ?? EB ?? 89 73";
internal const int PATTERN_FRAMELOCK_OFFSET_FUZZY = 6;
Expand All @@ -39,10 +39,11 @@ HARDCODED limit to 60 Hz monitor refresh rate on every resolution change. FromSo

00007FF7A30CAB27 (Version 1.2.0.0)
*/
//"eb .. c7 .. .. 3c 00 00 00 c7 .. .. 01 00 00 00
internal const string PATTERN_HERTZLOCK = "EB ?? C7 ?? ?? 3C 00 00 00 C7 ?? ?? 01 00 00 00";
internal const int PATTERN_HERTZLOCK_OFFSET = 2;
internal const int PATTERN_HERTZLOCK_OFFSET_INTEGER1 = 3;
internal const int PATTERN_HERTZLOCK_OFFSET_INTEGER2 = 10;
internal const int PATTERN_HERTZLOCK_OFFSET = 5;// 2
internal const int PATTERN_HERTZLOCK_OFFSET_INTEGER1 = 0; //3
internal const int PATTERN_HERTZLOCK_OFFSET_INTEGER2 = 0; // 10
internal const int PATCH_HERTZLOCK_INSTRUCTION_LENGTH = 14;


Expand All @@ -66,8 +67,8 @@ DATA SECTION. All resolutions are listed in memory as <int>width1 <int>height1 <
00007FF7A30C8D80 | 74 39 | je eldenring.7FF7A30C8DBB |
00007FF7A30C8D82 | 41:8BD3 | mov edx,r11d |
*/
internal const string PATTERN_RESOLUTION_SCALING_FIX = "8B ?? 85 ?? 74 ?? 44 8B ?? ?? 45 85 ?? 74 ?? 41 8B";
internal const int PATTERN_RESOLUTION_SCALING_FIX_OFFSET = 4;
internal const string PATTERN_RESOLUTION_SCALING_FIX = "74 4F 45 8B 94 CC";
internal const int PATTERN_RESOLUTION_SCALING_FIX_OFFSET = 0;
internal static readonly byte[] PATCH_RESOLUTION_SCALING_FIX_ENABLE = new byte[] { 0xEB }; // jmp
internal static readonly byte[] PATCH_RESOLUTION_SCALING_FIX_DISABLE = new byte[] { 0x74 }; // je

Expand Down Expand Up @@ -159,5 +160,12 @@ DATA SECTION. All resolutions are listed in memory as <int>width1 <int>height1 <
internal const int PATTERN_CAMRESET_LOCKON_OFFSET = 7;
internal static readonly byte[] PATCH_CAMRESET_LOCKON_ENABLE = new byte[1] { 0xEB }; // jmp
internal static readonly byte[] PATCH_CAMRESET_LOCKON_DISABLE = new byte[1] { 0x74 }; // je


internal const string PATTERN_LONGANIMATION_LOCKON = "C7 ?? ?? ?? 01 00 00 00 F3 ?? 0F 10 ?? ?? ?? F3 ?? 0F 10 ?? ?? ?? F3 0F 59 ?? ?? ?? ?? ?? ?? 0F 28 ?? F3 ?? 0F 5C ?? ?? 58";
internal const int PATTERN_LONGANIMATION_LOCKON_OFFSET = 72;
internal const int PATCH_LONGANIMATION_INSTRUCTION_LENGTH = 7;
internal static readonly byte[] PATCH_LONGANIMATION = new byte[] { 0x0F ,0x57 ,0xc9 ,0x90 ,0x90 ,0x90 ,0x90 };

}
}
6 changes: 5 additions & 1 deletion EldenRingFPSUnlockAndMore/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@
</DockPanel>
<DockPanel Margin="0,5,0,0" LastChildFill="False">
<CheckBox x:Name="cbAddWidescreen" DockPanel.Dock="Left" Margin="0,0,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Widescreen support" ToolTip="Adds your monitors native resolution to the game" IsChecked="{Binding WidescreenTicked, Mode=TwoWay, Source={x:Static p:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" TabIndex="3" />
<CheckBox x:Name="cbLongAnimation" Margin="3,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Widescreen Animation" ToolTip="Extends the animation window to the removed black bars area in the widescreen option." IsChecked="{Binding LongAnimations, Mode=TwoWay, Source={x:Static p:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" />
</DockPanel>
<DockPanel Margin="0,5,0,0" LastChildFill="False">
<CheckBox x:Name="cbDisableSteamCheck" DockPanel.Dock="Left" Margin="0,0,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Disable Steam check" ToolTip="Won't check nor auto-start Steam, untick this if your game doesn't start" IsChecked="{Binding DisableSteamCheckTicked, Mode=TwoWay, Source={x:Static p:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" TabIndex="3" />
</DockPanel>
<DockPanel Margin="0,5,0,0" LastChildFill="False">
<CheckBox x:Name="cbAutoStart" DockPanel.Dock="Left" Margin="0,0,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Auto start" ToolTip="Automatically start the game when opening this form" IsChecked="{Binding AutoStartTicked, Mode=TwoWay, Source={x:Static p:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" TabIndex="3" />
</DockPanel>
<Expander x:Name="exGameMods" Height="Auto" FontSize="14 px" Header="Modifications" IsExpanded="True" TabIndex="11">
<Grid x:Name="gSubGrid1" Margin="3,1,0,0" Background="#FFF9F9F9">
<StackPanel Width="Auto" Height="Auto">
<CheckBox x:Name="cbCamRotation" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Disable camera auto rotate on movement" ToolTip="isables automatic camera adjustment on movement. Intended for mouse users" IsChecked="{Binding DisableCamRotationTicked, Mode=TwoWay, Source={x:Static p:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox x:Name="cbCamRotation" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Disable camera auto rotate on movement" ToolTip="Disables automatic camera adjustment on movement. Intended for mouse users" IsChecked="{Binding DisableCamRotationTicked, Mode=TwoWay, Source={x:Static p:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox x:Name="cbCamLockReset" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Disable camera reset on lock-on" ToolTip="Disables camera centering on lock-on when there is no target" IsChecked="{Binding DisableCamLockResetTicked, Mode=TwoWay, Source={x:Static p:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox x:Name="cbDeathPenalty" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Disable Runes loss on death" ToolTip="Disables Runes loss upon death" IsChecked="{Binding DisablePenaltyTicked, Mode=TwoWay, Source={x:Static p:Settings.Default}, UpdateSourceTrigger=PropertyChanged}" TabIndex="16" />
<DockPanel Margin="0,3,0,0" LastChildFill="False">
Expand Down
66 changes: 56 additions & 10 deletions EldenRingFPSUnlockAndMore/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ public partial class MainWindow : Window
internal long _offset_camrotation = 0x0;
internal long _offset_camreset = 0x0;
internal long _offset_timescale = 0x0;
internal long _offset_longanimations = 0x0;

internal byte[] _patch_hertzlock_disable;
internal byte[] _patch_resolution_enable;
internal byte[] _patch_resolution_disable;
internal byte[] _patch_deathpenalty_disable;
internal byte[] _patch_camrotation_disable;
internal byte[] _patch_longanimation_disable;

internal bool _codeCave_fovmultiplier = false;
internal const string _DATACAVE_FOV_MULTIPLIER = "dfovMultiplier";
Expand Down Expand Up @@ -72,7 +74,7 @@ public MainWindow()
/// <summary>
/// On window loaded.
/// </summary>
private void Window_Loaded(object sender, RoutedEventArgs e)
private async void Window_Loaded(object sender, RoutedEventArgs e)
{
string local = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
_path_logs = Path.Combine(local, "EldenRingFPSUnlockAndMore", "logs.log");
Expand Down Expand Up @@ -112,6 +114,11 @@ private void Window_Loaded(object sender, RoutedEventArgs e)

ResetGame();
bStart.IsEnabled = true;

if (Properties.Settings.Default.AutoStartTicked)
{
await doStartClick();
}
}

/// <summary>
Expand Down Expand Up @@ -475,6 +482,17 @@ private void ReadGame(object sender, DoWorkEventArgs doWorkEventArgs)
if (!IsValidAddress(_offset_camreset))
_offset_camreset = 0x0;

_offset_longanimations = patternScan.FindPattern(GameData.PATTERN_LONGANIMATION_LOCKON) + GameData.PATTERN_LONGANIMATION_LOCKON_OFFSET;
Debug.WriteLine($"long animation found at: 0x{_offset_longanimations:X}");
if (!IsValidAddress(_offset_longanimations))
_offset_longanimations = 0x0;
else
{
_patch_longanimation_disable = new byte[GameData.PATCH_LONGANIMATION_INSTRUCTION_LENGTH];
if (!WinAPI.ReadProcessMemory(_gameAccessHwndStatic, _offset_longanimations, _patch_longanimation_disable, GameData.PATCH_LONGANIMATION_INSTRUCTION_LENGTH, out _))
_offset_longanimations = 0x0;
}

patternScan.Dispose();
}

Expand Down Expand Up @@ -539,6 +557,12 @@ private void OnReadGameFinish(object sender, RunWorkerCompletedEventArgs runWork
cbGameSpeed.IsEnabled = false;
}

if (_offset_longanimations == 0x0)
{
UpdateStatus("long animation not found...", Brushes.Red);
LogToFile("long animation not found...");
}

bPatch.IsEnabled = true;
_running = true;
PatchGame();
Expand Down Expand Up @@ -616,7 +640,8 @@ private void PatchGame()
PatchCamRotation(),
PatchCamReset(),
PatchDeathPenalty(),
PatchGameSpeed()
PatchGameSpeed(),
PatchLongAnimations()
};
if (results.Contains(true))
UpdateStatus("game patched!", Brushes.Green);
Expand Down Expand Up @@ -774,6 +799,22 @@ private bool PatchCamReset()
return true;
}

private bool PatchLongAnimations()
{
if (!cbLongAnimation.IsEnabled || _offset_longanimations == 0x0 || !CanPatchGame()) return false;
if (cbLongAnimation.IsChecked == true)
{
WriteBytes(_offset_longanimations, GameData.PATCH_LONGANIMATION);
}
else if (cbLongAnimation.IsChecked == false)
{
WriteBytes(_offset_longanimations, _patch_longanimation_disable);
return false;
}

return true;
}

/// <summary>
/// Patches game's global speed.
/// </summary>
Expand Down Expand Up @@ -1116,6 +1157,18 @@ private void UpdateStatus(string text, Brush color)
}

#region EventHandler

private async Task doStartClick()
{
bStart.IsEnabled = false;
bool res = await CheckGame();
if (!res)
{
ResetGame();
await SafeStartGame();
}
bStart.IsEnabled = true;
}

private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
{
Expand All @@ -1130,14 +1183,7 @@ private void bPatch_Click(object sender, RoutedEventArgs e)

private async void bStart_Click(object sender, RoutedEventArgs e)
{
bStart.IsEnabled = false;
bool res = await CheckGame();
if (!res)
{
ResetGame();
await SafeStartGame();
}
bStart.IsEnabled = true;
await doStartClick();
}

private void BFov0_Click(object sender, RoutedEventArgs e)
Expand Down
33 changes: 28 additions & 5 deletions EldenRingFPSUnlockAndMore/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions EldenRingFPSUnlockAndMore/Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="UTF-8"?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="EldenRingFPSUnlockAndMore.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
Expand Down Expand Up @@ -41,5 +41,12 @@
<Setting Name="DisableCamLockResetTicked" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="LongAnimations" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="AutoStartTicked" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
</SettingsFile>