Solved how to hook public static bool?

Status
Not open for further replies.

SmilingSword

Platinian
Original poster
Feb 17, 2018
38
17
8
31
hey how to hook this type?


[Address(RVA = "0x15803A8", Offset = "0x15803A8", VA = "0x15803A8")]
public static bool NewRewardAvailable(ISocialInvitesStateModel state, ISocialInvitesRewardsSetModel currentSet, ISocialInvitesRewardsProgressionModel progressionModel, int unhandledInvites = 0)
{
return default(bool);



[Address(RVA = "0x1580150", Offset = "0x1580150", VA = "0x1580150")]
public static bool HasCompletedRewardsSet(ISocialInvitesStateModel state, ISocialInvitesRewardsSetModel currentSet)
{
return default(bool);
 
  • Like
Reactions: nowhere_222

nik2143

Jr. PMT Modder
Staff member
Modding-Team
Jun 30, 2018
532
28,309
1,193
Italy
Like other hookings but It Is statics so hasn't an instance as parameter
 

Tosilegit

Platinian
Feb 1, 2022
10
1
3
Perttilä
It seems like you're interested in hooking into a static method within a .NET assembly. Hooking involves intercepting the execution flow of a function to inject custom code or modify its behavior. In the context of .NET, this often involves the use of techniques like method interception, detours, or code injection.

Here's a basic outline of how you might approach hooking a static method like the one you've provided:

Identify the Target Method: You've already identified the method you want to hook, which is NewRewardAvailable and HasCompletedRewardsSet.

Choose a Hooking Method: There are various methods to hook into a .NET method. Some common techniques include:

Using Profiling APIs: .NET Profiling APIs allow you to intercept method calls at runtime. This is a complex but powerful approach.
Using Detours or Method Interception Libraries: There are libraries available that facilitate method interception, such as Harmony or Mono.Cecil.
Using Dynamic Code Generation: You can dynamically generate code at runtime to replace or augment the behavior of the target method.
Implement the Hook: Depending on the chosen method, you'll need to implement the hooking mechanism. Here's a basic example using a hypothetical library:

public static class HookManager {
public static bool NewRewardAvailableHooked(ISocialInvitesStateModel state, ISocialInvitesRewardsSetModel currentSet, ISocialInvitesRewardsProgressionModel progressionModel, int unhandledInvites = 0) {
// Your custom logic here

// Call the original method
return OriginalMethods.NewRewardAvailable(state, currentSet, progressionModel, unhandledInvites);
}

public static bool HasCompletedRewardsSetHooked(ISocialInvitesStateModel state, ISocialInvitesRewardsSetModel currentSet) {
// Your custom logic here

// Call the original method
return OriginalMethods.HasCompletedRewardsSet(state, currentSet);
}
}
Replace the Original Method with the Hooked Method: Depending on your chosen approach, you'll need to replace the original method with your hooked version. This can involve modifying IL code, using method interception libraries, or other techniques.

Handle Compatibility and Side Effects: Ensure that your hooking mechanism doesn't introduce compatibility issues or unexpected side effects into the target application.

Testing: Thoroughly test your hooking mechanism to ensure that it behaves as expected and doesn't cause any unintended consequences.

Remember that hooking into methods like this can be complex and may require a good understanding of both .NET internals and the specific application you're targeting. Additionally, keep in mind that modifying the behavior of applications without proper authorization may violate terms of service or legal agreements. Always ensure that you have the necessary permissions before attempting to hook into any software.
Nahh did you use ChatGPT 😂
 

DaRealPanDa

Co-Administrator
Staff member
Supporting-Team
Global Moderator
Social Media
Mar 12, 2018
6,758
15,621
2,120
27
Skyrim
Thread will be set to "solved" and closed.
When you're not happy with that just send me a message and i will re-open the thread for you.

Thanks.
 
Status
Not open for further replies.