-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
602f37c
commit e290ab7
Showing
3 changed files
with
92 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
using HarmonyLib; | ||
using JetBrains.Annotations; | ||
using Osu.Stubs; | ||
using static System.Reflection.Emit.OpCodes; | ||
|
||
namespace Osu.Patcher.Hook.Patches; | ||
|
||
/// <summary> | ||
/// Re-enable osu!direct. This has no impact on Bancho since you can't even use this project on Bancho. | ||
/// Changes the following code in <c>osu.Online.OsuDirect:HandlePickup()</c> | ||
/// <br /><br /> | ||
/// From: | ||
/// <code><![CDATA[ | ||
/// if (BanchoClient.Permission & Permissions.Supporter > Permissions.None || ...) | ||
/// ]]></code> | ||
/// To: | ||
/// <code><![CDATA[ | ||
/// if ((BanchoClient.Permission & Permissions.Supporter) + 8 > Permissions.None || ...) | ||
/// ]]></code> | ||
/// </summary> | ||
[HarmonyPatch] | ||
[UsedImplicitly] | ||
public class PatchOsuDirect : BasePatch | ||
{ | ||
private static readonly OpCode[] Signature = | ||
{ | ||
// Call, | ||
// Ldc_I4_4, | ||
// And, | ||
// -- Inject right here to replace the result of And -- | ||
Ldc_I4_0, | ||
Bgt_S, | ||
Ldsfld, | ||
Call, | ||
Ldc_I4_S, | ||
}; | ||
|
||
[UsedImplicitly] | ||
[HarmonyTargetMethod] | ||
private static MethodBase Target() => OsuDirect.HandlePickup.Reference; | ||
|
||
[UsedImplicitly] | ||
[HarmonyTranspiler] | ||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) => | ||
InsertBeforeSignature( | ||
instructions, | ||
Signature, | ||
new CodeInstruction[] | ||
{ | ||
// Replace the result of Add with a higher value than compared against | ||
new(Pop), | ||
new(Ldc_I4_8), | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using JetBrains.Annotations; | ||
using Osu.Stubs.Opcode; | ||
using static System.Reflection.Emit.OpCodes; | ||
|
||
namespace Osu.Stubs; | ||
|
||
/// <summary> | ||
/// Original: <c>osu.Online.OsuDirect</c> | ||
/// b20240102.2: <c>#=zz3BVwBujgm4LKna55Dwx3UA=</c> | ||
/// </summary> | ||
public abstract class OsuDirect | ||
{ | ||
/// <summary> | ||
/// Original: <c>HandlePickup()</c> | ||
/// b20240102.2: <c>#=zJczNz_3lxxrQQnnZog==</c> | ||
/// </summary> | ||
[UsedImplicitly] | ||
public static readonly LazyMethod HandlePickup = new( | ||
"osu.Online.OsuDirect#HandlePickup", | ||
new[] | ||
{ | ||
Ldloc_0, | ||
Ldfld, | ||
Ldloc_0, | ||
Ldflda, | ||
Call, | ||
Ldloc_0, | ||
Ldftn, | ||
Newobj, | ||
Call, | ||
Ret, | ||
} | ||
); | ||
} |