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

add configuration for waiting on an external debugger when run from the command line

This commit is contained in:
Cj 2025-01-11 23:49:06 -05:00
parent af62310053
commit 8041089f44
20 changed files with 99 additions and 24 deletions

1
.gitignore vendored
View File

@ -21,6 +21,7 @@ mono_crash.*
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
WAIT_FOR_DEBUGGER/
x64/
x86/
[Ww][Ii][Nn]32/

View File

@ -7,6 +7,8 @@
<LangVersion>latestmajor</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>

View File

@ -1,6 +1,7 @@
using CliFx;
using CliFx.Attributes;
using CliFx.Infrastructure;
using ReCodeItCLI.Utils;
using ReCodeItLib.Utils;
namespace ReCodeItCLI.Commands;
@ -13,6 +14,8 @@ public class AddMissingProperties : ICommand
public ValueTask ExecuteAsync(IConsole console)
{
Debugger.TryWaitForDebuggerAttach();
var remaps = DataProvider.LoadMappingFile(MappingsPath);
DataProvider.UpdateMapping(MappingsPath, remaps);

View File

@ -1,10 +1,7 @@
// Uncomment this to have the application wait for a debugger to attach before running.
//#define WAIT_FOR_DEBUGGER
using System.Diagnostics;
using CliFx;
using CliFx;
using CliFx.Attributes;
using CliFx.Infrastructure;
using ReCodeItCLI.Utils;
using ReCodeItLib.Models;
using ReCodeItLib.ReMapper;
using ReCodeItLib.Utils;
@ -28,13 +25,7 @@ public class AutoMatchCommand : ICommand
public ValueTask ExecuteAsync(IConsole console)
{
#if WAIT_FOR_DEBUGGER
Logger.LogSync("Waiting for debugger...");
while (!Debugger.IsAttached)
{
Thread.Sleep(100);
}
#endif
Debugger.TryWaitForDebuggerAttach();
Logger.LogSync("Finding match...");

View File

@ -1,6 +1,7 @@
using CliFx;
using CliFx.Attributes;
using CliFx.Infrastructure;
using ReCodeItCLI.Utils;
using ReCodeItLib.Utils;
using ReCodeItLib.ReMapper;
@ -17,6 +18,8 @@ public class DeObfuscate : ICommand
public ValueTask ExecuteAsync(IConsole console)
{
Debugger.TryWaitForDebuggerAttach();
Logger.Log("Deobfuscating assembly...");
Deobfuscator.Deobfuscate(AssemblyPath, IsLauncher);

View File

@ -1,6 +1,7 @@
using CliFx;
using CliFx.Attributes;
using CliFx.Infrastructure;
using ReCodeItCLI.Utils;
using ReCodeItLib.Utils;
using ReCodeItLib.Dumper;
@ -14,6 +15,8 @@ public class Dumper : ICommand
public ValueTask ExecuteAsync(IConsole console)
{
Debugger.TryWaitForDebuggerAttach();
Logger.Log("Creating DumperClass...");
var dumper = new DumperClass(ManagedDirectory);

View File

@ -2,6 +2,7 @@
using CliFx.Attributes;
using CliFx.Infrastructure;
using dnlib.DotNet;
using ReCodeItCLI.Utils;
namespace ReCodeItCLI.Commands;
@ -23,6 +24,8 @@ public class GenRefList : ICommand
public ValueTask ExecuteAsync(IConsole console)
{
Debugger.TryWaitForDebuggerAttach();
var references = CountTypeReferences(AssemblyPath);
// Sort and display the top 10 most referenced types

View File

@ -1,6 +1,7 @@
using CliFx;
using CliFx.Attributes;
using CliFx.Infrastructure;
using ReCodeItCLI.Utils;
using ReCodeItLib.Utils;
namespace ReCodeItCLI.Commands;
@ -13,6 +14,8 @@ public class GetRuntimeVersion : ICommand
public ValueTask ExecuteAsync(IConsole console)
{
Debugger.TryWaitForDebuggerAttach();
var module = DataProvider.LoadModule(AssemblyPath);
Logger.LogSync($"Target Runtime Version: {module.RuntimeVersion}");

View File

@ -1,10 +1,7 @@
// Uncomment this to have the application wait for a debugger to attach before running.
//#define WAIT_FOR_DEBUGGER
using System.Diagnostics;
using CliFx;
using CliFx;
using CliFx.Attributes;
using CliFx.Infrastructure;
using ReCodeItCLI.Utils;
using ReCodeItLib.Utils;
using ReCodeItLib.ReMapper;
@ -23,13 +20,7 @@ public class ReMap : ICommand
public ValueTask ExecuteAsync(IConsole console)
{
#if WAIT_FOR_DEBUGGER
Logger.LogSync("Waiting for debugger...");
while (!Debugger.IsAttached)
{
Thread.Sleep(100);
}
#endif
Debugger.TryWaitForDebuggerAttach();
DataProvider.Settings.MappingPath = MappingJsonPath;

View File

@ -7,6 +7,8 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ServerGarbageCollection>true</ServerGarbageCollection>
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>

View File

@ -0,0 +1,25 @@
using System.Diagnostics;
using ReCodeItLib.Utils;
namespace ReCodeItCLI.Utils;
public static class Debugger
{
[Conditional("WAIT_FOR_DEBUGGER")]
public static void TryWaitForDebuggerAttach()
{
const int maxDots = 3;
var dotCount = 0;
while (!System.Diagnostics.Debugger.IsAttached)
{
var dots = new string('.', dotCount);
Console.Clear();
Logger.LogSync($"Waiting for debugger{dots}");
dotCount = (dotCount + 1) % (maxDots + 1);
Thread.Sleep(500);
}
}
}

View File

@ -39,6 +39,7 @@ Global
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
WAIT_FOR_DEBUGGER|Any CPU = WAIT_FOR_DEBUGGER|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@ -61,6 +62,8 @@ Global
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.Release|x86.ActiveCfg = Release|Any CPU
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.Release|x86.Build.0 = Release|Any CPU
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
{FDA58DB6-E114-4FE0-AAF1-C3DEE44AEF99}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Debug|ARM.ActiveCfg = Debug|Any CPU
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Debug|ARM.Build.0 = Debug|Any CPU
@ -81,6 +84,8 @@ Global
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Release|x86.ActiveCfg = Release|Any CPU
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Release|x86.Build.0 = Release|Any CPU
{E404EC0B-06D2-4964-8ABA-A634F259655C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E404EC0B-06D2-4964-8ABA-A634F259655C}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
{E404EC0B-06D2-4964-8ABA-A634F259655C}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Debug|ARM.ActiveCfg = Debug|Any CPU
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Debug|ARM.Build.0 = Debug|Any CPU
@ -101,6 +106,8 @@ Global
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Release|x86.ActiveCfg = Release|Any CPU
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Release|x86.Build.0 = Release|Any CPU
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
{D0837899-F129-46DB-8BDB-7C9AFB72BD30}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Debug|ARM.Build.0 = Debug|Any CPU
@ -120,6 +127,8 @@ Global
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Release|x64.Build.0 = Release|Any CPU
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Release|x86.ActiveCfg = Release|Any CPU
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.Release|x86.Build.0 = Release|Any CPU
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
{7C68B124-809B-4D4A-960B-467B2DAF2A0A}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Debug|ARM.ActiveCfg = Debug|Any CPU
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Debug|ARM.Build.0 = Debug|Any CPU
@ -139,6 +148,8 @@ Global
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Release|x64.Build.0 = Release|Any CPU
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Release|x86.ActiveCfg = Release|Any CPU
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.Release|x86.Build.0 = Release|Any CPU
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
{2BCD50E1-77D5-47E3-B317-04568BF051AB}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Debug|ARM.ActiveCfg = Debug|Any CPU
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Debug|ARM.Build.0 = Debug|Any CPU
@ -158,6 +169,8 @@ Global
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Release|x64.Build.0 = Release|Any CPU
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Release|x86.ActiveCfg = Release|Any CPU
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.Release|x86.Build.0 = Release|Any CPU
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
{C3C1267E-CDB9-4C47-B7F1-C929A6F2F31C}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Debug|ARM.ActiveCfg = Debug|Any CPU
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Debug|ARM.Build.0 = Debug|Any CPU
@ -178,6 +191,8 @@ Global
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Release|x86.ActiveCfg = Release|Any CPU
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Release|x86.Build.0 = Release|Any CPU
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
{CF1A1A5E-292B-42DE-AAA0-6801AD1AD407}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Debug|ARM.ActiveCfg = Debug|Any CPU
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Debug|ARM.Build.0 = Debug|Any CPU
@ -197,6 +212,8 @@ Global
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Release|x64.Build.0 = Release|Any CPU
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Release|x86.ActiveCfg = Release|Any CPU
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.Release|x86.Build.0 = Release|Any CPU
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
{02FBA28C-E86C-49DC-8B44-A69CC542F693}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Debug|ARM.ActiveCfg = Debug|Any CPU
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Debug|ARM.Build.0 = Debug|Any CPU
@ -216,6 +233,8 @@ Global
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Release|x64.Build.0 = Release|Any CPU
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Release|x86.ActiveCfg = Release|Any CPU
{8365D905-3BC4-42A0-B072-035598C6AF8C}.Release|x86.Build.0 = Release|Any CPU
{8365D905-3BC4-42A0-B072-035598C6AF8C}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
{8365D905-3BC4-42A0-B072-035598C6AF8C}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|ARM.ActiveCfg = Debug|Any CPU
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|ARM.Build.0 = Debug|Any CPU
@ -236,6 +255,8 @@ Global
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|x86.ActiveCfg = Release|Any CPU
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Release|x86.Build.0 = Release|Any CPU
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
{3D0F9399-7814-4EB9-8436-D56BA87F874C}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Debug|ARM.ActiveCfg = Debug|Any CPU
@ -256,6 +277,8 @@ Global
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Release|x64.Build.0 = Release|Any CPU
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Release|x86.ActiveCfg = Release|Any CPU
{55E928FA-93D2-410C-8AF6-C074C63D126B}.Release|x86.Build.0 = Release|Any CPU
{55E928FA-93D2-410C-8AF6-C074C63D126B}.WAIT_FOR_DEBUGGER|Any CPU.ActiveCfg = WAIT_FOR_DEBUGGER|Any CPU
{55E928FA-93D2-410C-8AF6-C074C63D126B}.WAIT_FOR_DEBUGGER|Any CPU.Build.0 = WAIT_FOR_DEBUGGER|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -7,6 +7,8 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ServerGarbageCollection>true</ServerGarbageCollection>
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>

View File

@ -1,5 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<Import Project="..\De4DotCommon.props" />
<ItemGroup>

View File

@ -5,6 +5,8 @@
<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
<OutputType>Exe</OutputType>
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>

View File

@ -6,6 +6,8 @@
<PlatformTarget>x64</PlatformTarget>
<OutputType>Exe</OutputType>
<TargetFramework>net48</TargetFramework>
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>

View File

@ -1,5 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<Import Project="..\De4DotCommon.props" />
<ItemGroup>

View File

@ -4,6 +4,8 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>

View File

@ -1,5 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<Import Project="..\De4DotCommon.props" />
<ItemGroup>

View File

@ -4,6 +4,8 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Configurations>Debug;Release;WAIT_FOR_DEBUGGER</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>