0
0
mirror of https://github.com/sp-tarkov/assembly-tool.git synced 2025-02-12 21:10:45 -05:00

Thread hollow process

This commit is contained in:
Cj 2025-01-11 05:50:19 -05:00
parent e6364092aa
commit 2915c63c51

View File

@ -322,9 +322,8 @@ public class ReMapper
Logger.LogSync(e); Logger.LogSync(e);
throw; throw;
} }
Logger.LogSync("\nCreating Hollow...", ConsoleColor.Green); StartHollow();
Hollow();
var hollowedDir = Path.GetDirectoryName(OutPath); var hollowedDir = Path.GetDirectoryName(OutPath);
var hollowedPath = Path.Combine(hollowedDir!, "Assembly-CSharp-hollowed.dll"); var hollowedPath = Path.Combine(hollowedDir!, "Assembly-CSharp-hollowed.dll");
@ -354,17 +353,37 @@ public class ReMapper
/// <summary> /// <summary>
/// Hollows out all logic from the dll /// Hollows out all logic from the dll
/// </summary> /// </summary>
private void Hollow() private void StartHollow()
{ {
foreach (var type in Module!.GetTypes()) Logger.LogSync("\nCreating Hollow...", ConsoleColor.Green);
var tasks = new List<Task>(Module!.GetTypes().Count());
foreach (var type in Module.GetTypes())
{ {
foreach (var method in type.Methods.Where(m => m.HasBody)) tasks.Add(Task.Run(() =>
{ {
if (!method.HasBody) continue; try
{
HollowType(type);
}
catch (Exception ex)
{
Logger.LogSync($"Exception in task: {ex.Message}", ConsoleColor.Red);
}
}));
}
Task.WaitAll(tasks.ToArray());
}
method.Body = new CilBody(); private void HollowType(TypeDef type)
method.Body.Instructions.Add(OpCodes.Ret.ToInstruction()); {
} foreach (var method in type.Methods.Where(m => m.HasBody))
{
if (!method.HasBody) continue;
method.Body = new CilBody();
method.Body.Instructions.Add(OpCodes.Ret.ToInstruction());
} }
} }
} }