Skip to content

Commit

Permalink
added a detours injector command-line app
Browse files Browse the repository at this point in the history
  • Loading branch information
lostmsu committed Aug 24, 2023
1 parent 3f61278 commit e6e3236
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
16 changes: 15 additions & 1 deletion NDetours.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NDetours", "src\NDetours.cs
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NDetours.Tests", "test\NDetours.Tests.csproj", "{241AC79D-0399-4B2A-9C01-07C609F74B69}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DetoursUWPLauncher", "launcher\DetoursUWPLauncher.csproj", "{24B7865E-B818-4AE2-B46D-CA061DF1D23B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DetoursUWPLauncher", "launcher\DetoursUWPLauncher.csproj", "{24B7865E-B818-4AE2-B46D-CA061DF1D23B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Detours", "app\Detours.csproj", "{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -66,6 +68,18 @@ Global
{24B7865E-B818-4AE2-B46D-CA061DF1D23B}.Release|x64.Build.0 = Release|Any CPU
{24B7865E-B818-4AE2-B46D-CA061DF1D23B}.Release|x86.ActiveCfg = Release|Any CPU
{24B7865E-B818-4AE2-B46D-CA061DF1D23B}.Release|x86.Build.0 = Release|Any CPU
{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}.Debug|x64.ActiveCfg = Debug|Any CPU
{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}.Debug|x64.Build.0 = Debug|Any CPU
{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}.Debug|x86.ActiveCfg = Debug|Any CPU
{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}.Debug|x86.Build.0 = Debug|Any CPU
{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}.Release|Any CPU.Build.0 = Release|Any CPU
{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}.Release|x64.ActiveCfg = Release|Any CPU
{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}.Release|x64.Build.0 = Release|Any CPU
{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}.Release|x86.ActiveCfg = Release|Any CPU
{E3F09AA1-E054-4325-84F9-BB4E5E1D9380}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
25 changes: 25 additions & 0 deletions app/Detours.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\src\NDetours.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="..\src\AMD64\*.dll" />
</ItemGroup>

<ItemGroup>
<Content Update="..\src\AMD64\detours.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions app/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Linq;

using NDetours;

if (args.Length == 0) {
Console.Error.WriteLine("Usage: detours.exe <executable> [dlls...]");
return -1;
}

var startInfo = new ProcessDetour.StartInfo(args[0]);
foreach (string dll in args.Skip(1)) {
startInfo.InjectDlls.Add(dll);
}

Console.Write("starting...");
using var process = ProcessDetour.Start(startInfo);
Console.WriteLine("OK");
Console.Write("running...");
process.WaitForExit();
Console.WriteLine(process.ExitCode);
return 0;

0 comments on commit e6e3236

Please sign in to comment.