Skip to content
Merged
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
16 changes: 16 additions & 0 deletions ShapezShifter/src/ShapezShifter.SharpDetour/DetourHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void Patch(Action<TObject> orig, TObject self)
}
}

[Obsolete("Use the version that gets passed self")]
public static Hook CreatePrefixHook<TObject, TArg0>(
Expression<Action<TObject, TArg0>> original,
Func<TArg0, TArg0> prefix)
Expand All @@ -47,6 +48,21 @@ void Patch(Action<TObject, TArg0> orig, TObject self, TArg0 arg0)
orig(self, arg0);
}
}

public static Hook CreatePrefixHook<TObject, TArg0>(
Expression<Action<TObject, TArg0>> original,
Func<TObject, TArg0, TArg0> prefix)
{
MethodInfo actualMethodBody = GetRuntimeMethod<TObject>(original);

return new Hook(actualMethodBody, target: (Action<Action<TObject, TArg0>, TObject, TArg0>)Patch);

void Patch(Action<TObject, TArg0> orig, TObject self, TArg0 arg0)
{
arg0 = prefix(self, arg0);
orig(self, arg0);
}
}

public static Hook CreatePrefixHook<TObject, TArg0, TArg1>(
Expression<Action<TObject, TArg0, TArg1>> original,
Expand Down