0
0
mirror of https://github.com/sp-tarkov/assembly-tool.git synced 2025-02-13 01:50: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

@ -323,8 +323,7 @@ public class ReMapper
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,9 +353,30 @@ 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())
{
tasks.Add(Task.Run(() =>
{
try
{
HollowType(type);
}
catch (Exception ex)
{
Logger.LogSync($"Exception in task: {ex.Message}", ConsoleColor.Red);
}
}));
}
Task.WaitAll(tasks.ToArray());
}
private void HollowType(TypeDef type)
{ {
foreach (var method in type.Methods.Where(m => m.HasBody)) foreach (var method in type.Methods.Where(m => m.HasBody))
{ {
@ -366,5 +386,4 @@ public class ReMapper
method.Body.Instructions.Add(OpCodes.Ret.ToInstruction()); method.Body.Instructions.Add(OpCodes.Ret.ToInstruction());
} }
} }
}
} }