Skip to content

Commit

Permalink
Updated OsuMemoryDataProvider
Browse files Browse the repository at this point in the history
It works in x64 now
  • Loading branch information
OliBomby committed May 22, 2021
1 parent 6cffcb0 commit f2ca649
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Mapping_Tools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D01ED42E-8057-489C-96B4-FFDCEBD5E53F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D01ED42E-8057-489C-96B4-FFDCEBD5E53F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D01ED42E-8057-489C-96B4-FFDCEBD5E53F}.Debug|x64.ActiveCfg = Debug|Any CPU
{D01ED42E-8057-489C-96B4-FFDCEBD5E53F}.Debug|x64.Build.0 = Debug|Any CPU
{D01ED42E-8057-489C-96B4-FFDCEBD5E53F}.Debug|x64.ActiveCfg = Debug|x64
{D01ED42E-8057-489C-96B4-FFDCEBD5E53F}.Debug|x64.Build.0 = Debug|x64
{D01ED42E-8057-489C-96B4-FFDCEBD5E53F}.Debug|x86.ActiveCfg = Debug|x86
{D01ED42E-8057-489C-96B4-FFDCEBD5E53F}.Debug|x86.Build.0 = Debug|x86
{D01ED42E-8057-489C-96B4-FFDCEBD5E53F}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -31,8 +31,8 @@ Global
{D01ED42E-8057-489C-96B4-FFDCEBD5E53F}.Release|x86.Build.0 = Release|Any CPU
{F418EF3E-C92E-4303-A00D-8D0B78793AAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F418EF3E-C92E-4303-A00D-8D0B78793AAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F418EF3E-C92E-4303-A00D-8D0B78793AAA}.Debug|x64.ActiveCfg = Debug|Any CPU
{F418EF3E-C92E-4303-A00D-8D0B78793AAA}.Debug|x64.Build.0 = Debug|Any CPU
{F418EF3E-C92E-4303-A00D-8D0B78793AAA}.Debug|x64.ActiveCfg = Debug|x64
{F418EF3E-C92E-4303-A00D-8D0B78793AAA}.Debug|x64.Build.0 = Debug|x64
{F418EF3E-C92E-4303-A00D-8D0B78793AAA}.Debug|x86.ActiveCfg = Debug|x86
{F418EF3E-C92E-4303-A00D-8D0B78793AAA}.Debug|x86.Build.0 = Debug|x86
{F418EF3E-C92E-4303-A00D-8D0B78793AAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
21 changes: 17 additions & 4 deletions Mapping_Tools/Classes/SystemTools/IOHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
using OsuMemoryDataProvider;
using Mapping_Tools.Classes.ToolHelpers;
using Microsoft.Win32;
using OsuMemoryDataProvider.OsuMemoryModels;
using OsuMemoryDataProvider.OsuMemoryModels.Direct;

namespace Mapping_Tools.Classes.SystemTools {
public class IOHelper {
private static readonly IOsuMemoryReader PioReader = OsuMemoryReader.Instance;
private static readonly StructuredOsuMemoryReader pioStructuredReader = StructuredOsuMemoryReader.Instance;
private static readonly OsuBaseAddresses osuBaseAddresses = new();

public static string FolderDialog(string initialDirectory = "") {
bool restore = initialDirectory == "";
Expand Down Expand Up @@ -143,6 +146,16 @@ public static string[] BeatmapFileDialog(string initialDirectory, bool multisele
return openFileDialog.FileNames;
}

private static T ReadClassProperty<T>(object readObj, string propName, T defaultValue = default) where T : class {
if (pioStructuredReader.TryReadProperty(readObj, propName, out var readResult))
return (T)readResult;

return defaultValue;
}

private static string ReadString(object readObj, string propName)
=> ReadClassProperty<string>(readObj, propName);

public static string GetCurrentBeatmap() {
string path;
try {
Expand All @@ -152,9 +165,9 @@ public static string GetCurrentBeatmap() {
throw new Exception(
@"Can't fetch current in-game beatmap, because there is no Songs path specified in Preferences.");
}

string folder = PioReader.GetMapFolderName();
string filename = PioReader.GetOsuFileName();
string folder = ReadString(osuBaseAddresses.Beatmap, nameof(CurrentBeatmap.FolderName));
string filename = ReadString(osuBaseAddresses.Beatmap, nameof(CurrentBeatmap.OsuFileName));

if (string.IsNullOrEmpty(folder)) {
throw new Exception(@"Can't fetch the folder name of the current in-game beatmap.");
Expand Down
18 changes: 11 additions & 7 deletions Mapping_Tools/Mapping_Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
<FileVersion>1.8.1</FileVersion>
<AssemblyName>Mapping Tools</AssemblyName>
<ApplicationIcon>Data\mt_icon.ico</ApplicationIcon>
<Platforms>AnyCPU;x86</Platforms>
<Platforms>AnyCPU;x86;x64</Platforms>
<RootNamespace>Mapping_Tools</RootNamespace>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand All @@ -26,6 +30,11 @@
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
Expand All @@ -35,12 +44,6 @@
<Reference Include="..\lib\EditorReader.dll">
<Private>true</Private>
</Reference>
<Reference Include="..\lib\OsuMemoryDataProvider.dll">
<Private>true</Private>
</Reference>
<Reference Include="..\lib\ProcessMemoryDataFinder.dll">
<Private>true</Private>
</Reference>
<Reference Include="NonInvasiveKeyboardHookLibrary.Core">
<HintPath>..\lib\NonInvasiveKeyboardHookLibrary.Core.dll</HintPath>
</Reference>
Expand All @@ -57,6 +60,7 @@
<PackageReference Include="NVorbis" Version="0.10.3" />
<PackageReference Include="OggVorbisEncoder" Version="1.2.0" />
<PackageReference Include="Onova" Version="2.6.2" />
<PackageReference Include="OsuMemoryDataProvider" Version="0.6.2" />
<PackageReference Include="Overlay.NET" Version="1.0.2" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Mapping_Tools_Tests/Mapping_Tools_Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Platforms>AnyCPU;x86</Platforms>
<Platforms>AnyCPU;x86;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<None Update="Resources\EmptyTestMap.osu">
Expand Down
Binary file removed lib/OsuMemoryDataProvider.dll
Binary file not shown.
Binary file removed lib/ProcessMemoryDataFinder.dll
Binary file not shown.

0 comments on commit f2ca649

Please sign in to comment.