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 offsets #66

Open
wants to merge 4 commits into
base: master
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
21 changes: 20 additions & 1 deletion Memory/BeatmapOffsetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ public enum CompareCondition
public int BeatmapSetAddressOffset { get; set; }
public int BeatmapFolderAddressOffset { get; set; }
public int BeatmapFileNameAddressOffset { get; set; }
public int BeatMapCreatorAddressOffset {get; set; }
public CompareCondition VersionCompareCondition { get; set; }
public void AddOffset(BeatmapOffsetInfo beatmapOffsetInfo)
{
BeatmapAddressOffset += beatmapOffsetInfo.BeatmapAddressOffset;
BeatmapFolderAddressOffset += beatmapOffsetInfo.BeatmapFolderAddressOffset;
BeatmapSetAddressOffset += beatmapOffsetInfo.BeatmapSetAddressOffset;
BeatmapFileNameAddressOffset += beatmapOffsetInfo.BeatmapFileNameAddressOffset;
if (beatmapOffsetInfo.Version >= 20231219.2)
{
BeatMapCreatorAddressOffset += beatmapOffsetInfo.BeatMapCreatorAddressOffset;
}
}

public void SetOffset(BeatmapOffsetInfo beatmapOffsetInfo)
Expand All @@ -39,6 +44,10 @@ public void SetOffset(BeatmapOffsetInfo beatmapOffsetInfo)
BeatmapFolderAddressOffset = beatmapOffsetInfo.BeatmapFolderAddressOffset;
BeatmapSetAddressOffset = beatmapOffsetInfo.BeatmapSetAddressOffset;
BeatmapFileNameAddressOffset = beatmapOffsetInfo.BeatmapFileNameAddressOffset;
if (beatmapOffsetInfo.Version >= 20231219.2)
{
BeatMapCreatorAddressOffset = beatmapOffsetInfo.BeatMapCreatorAddressOffset;
}
}


Expand Down Expand Up @@ -136,6 +145,16 @@ public static BeatmapOffsetInfo MatchVersion(double version)
VersionCompareCondition = CompareCondition.NewerOrEquals
};


[OsuVersionCompareInfo(20231219.2, CompareCondition.NewerOrEquals)]
public static BeatmapOffsetInfo Version202312192 { get; } = new BeatmapOffsetInfo
{
Version = 20231219.2,
BeatmapFileNameAddressOffset = 0,
BeatmapSetAddressOffset = 0,
BeatmapAddressOffset = 0,
BeatmapFolderAddressOffset = 4,
BeatMapCreatorAddressOffset = 4,
VersionCompareCondition = CompareCondition.NewerOrEquals
};
}
}
26 changes: 22 additions & 4 deletions Memory/OsuBeatmapFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ internal class OsuBeatmapFinder : OsuFinderBase

private static readonly string s_beatmap_mask = "xxxx????xxxx";

private static readonly int s_beatmap_offset = 0xc4;
private static readonly int s_beatmap_set_offset = 0xc8;
private static readonly int s_beatmap_offset = 0xc8;
private static readonly int s_beatmap_set_offset = 0xcc;

private static readonly int s_beatmap_folder_offset = 0x74;
private static readonly int s_beatmap_filename_offset = 0x8c;
private static readonly int s_beatmap_filename_offset = 0x80;

private static readonly int s_beatmap_creator_offset = 0x78;

private BeatmapOffsetInfo CurrentOffset { get; } = new BeatmapOffsetInfo()
{
BeatmapAddressOffset = s_beatmap_offset,
BeatmapSetAddressOffset = s_beatmap_set_offset,
BeatmapFolderAddressOffset = s_beatmap_folder_offset,
BeatmapFileNameAddressOffset = s_beatmap_filename_offset
BeatmapFileNameAddressOffset = s_beatmap_filename_offset,
BeatMapCreatorAddressOffset = s_beatmap_creator_offset
};

private const int MAX_RETRY_COUNT = 10;
Expand Down Expand Up @@ -123,6 +126,21 @@ private string GetCurrentBeatmapFilename()
TryReadIntPtrFromMemory(m_beatmap_address, out var cur_beatmap_address);
bool success = TryReadStringFromMemory(cur_beatmap_address + CurrentOffset.BeatmapFileNameAddressOffset, out string str);
if (!success) return "";

List<string> fileName = new List<string>(str.Split('['));
string creator = GetCurrentBeatmapCreator();
fileName[0] += $"({creator}) ";

str = string.Join("[", fileName.ToArray());
str += ".osu";
return str;
}

private string GetCurrentBeatmapCreator()
{
TryReadIntPtrFromMemory(m_beatmap_address, out var cur_beatmap_address);
bool success = TryReadStringFromMemory(cur_beatmap_address + CurrentOffset.BeatMapCreatorAddressOffset, out string str);
if (!success) return "";
return str;
}

Expand Down
12 changes: 4 additions & 8 deletions OsuRTDataProvider.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OsuRTDataProvider</RootNamespace>
<AssemblyName>OsuRTDataProvider</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand Down Expand Up @@ -71,6 +71,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Sync">
<HintPath>.\Sync.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
Expand Down Expand Up @@ -110,13 +113,6 @@
<Compile Include="UpdateChecker.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\osuSync\Sync\Sync.csproj">
<Project>{FBD514C2-2830-479E-B050-D1C383028456}</Project>
<Name>Sync</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /y $(TargetPath) $(SolutionDir)\Sync\bin\$(ConfigurationName)\Plugins</PostBuildEvent>
Expand Down
2 changes: 1 addition & 1 deletion OsuRTDataProviderPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class OsuRTDataProviderPlugin : Plugin
{
public const string PLUGIN_NAME = "OsuRTDataProvider";
public const string PLUGIN_AUTHOR = "KedamaOvO";
public const string VERSION = "1.7.0";
public const string VERSION = "1.7.1";

private PluginConfigurationManager m_config_manager;

Expand Down