Skip to content

Commit

Permalink
add hooks back in
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniMacaroni committed Feb 29, 2024
1 parent 7e4c345 commit a85179e
Show file tree
Hide file tree
Showing 6 changed files with 886 additions and 885 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
- Added `playcutscene` command back.
- Fixed `dump` command (except for prefabs).
- Automatically rename Reshade dll to be able to be loaded by Redloader.
- Log harmony exceptions
- Log harmony exceptions.
- Added hooks back in.
64 changes: 32 additions & 32 deletions Dependencies/Il2CppAssemblyGenerator/Packages/Il2CppInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal override bool Execute()
Il2CppPrefixMode = GeneratorOptions.PrefixMode.OptIn,
};

//opts.AddPass<HookGenPass>();
opts.AddPass<HookGenPass>();

//Inform cecil of the unity base libs
var trusted = (string) AppDomain.CurrentDomain.GetData("TRUSTED_PLATFORM_ASSEMBLIES");
Expand Down Expand Up @@ -95,37 +95,37 @@ internal override bool Execute()
}
}

// internal class HookGenPass : ICustomPass
// {
// public void DoPass(RewriteGlobalContext context)
// {
// //var depsDirs = new List<string> { LoaderEnvironment.Il2CppAssembliesDirectory, Path.Combine(LoaderEnvironment.LoaderDirectory, "net6") };
// // foreach (var assembly in assemblies)
// // {
// // GenerateHookAssembly(Path.Combine(LoaderEnvironment.Il2CppAssembliesDirectory, assembly + ".dll"),
// // Path.Combine(LoaderEnvironment.HooksDirectory, "HK_" + assembly + ".dll"), depsDirs);
// // }
//
// foreach (var assembly in context.Assemblies)
// {
// var name = assembly.OriginalAssembly.Name.Name;
// if(!name.Contains("Sons") && !name.Contains("Endnight"))
// continue;
//
// RLog.Msg($"Generating hooks for {assembly.OriginalAssembly.Name.Name}");
// var gen = new HookGeneratorV2(assembly.OriginalAssembly.MainModule, assembly.NewAssembly.MainModule);
//
// try
// {
// gen.Generate();
// }
// catch (Exception e)
// {
// Console.WriteLine($"Error while processing {name}: \n {e}");
// }
// }
// }
// }
internal class HookGenPass : ICustomPass
{
public void DoPass(RewriteGlobalContext context)
{
//var depsDirs = new List<string> { LoaderEnvironment.Il2CppAssembliesDirectory, Path.Combine(LoaderEnvironment.LoaderDirectory, "net6") };
// foreach (var assembly in assemblies)
// {
// GenerateHookAssembly(Path.Combine(LoaderEnvironment.Il2CppAssembliesDirectory, assembly + ".dll"),
// Path.Combine(LoaderEnvironment.HooksDirectory, "HK_" + assembly + ".dll"), depsDirs);
// }

foreach (var assembly in context.Assemblies)
{
var name = assembly.OriginalAssembly.Name.Name;
if(!name.Contains("Sons") && !name.Contains("Endnight"))
continue;

RLog.Msg($"Generating hooks for {assembly.OriginalAssembly.Name.Name}");
var gen = new HookGeneratorV2(assembly.OriginalAssembly.MainModule, assembly.NewAssembly.MainModule);

try
{
gen.Generate();
}
catch (Exception e)
{
Console.WriteLine($"Error while processing {name}: \n {e}");
}
}
}
}

internal class InteropLogger : ILogger
{
Expand Down
Loading

0 comments on commit a85179e

Please sign in to comment.