Xamarin.Windows.Injector
1.0.0
Prefix Reserved
See the version list below for details.
dotnet add package Xamarin.Windows.Injector --version 1.0.0
NuGet\Install-Package Xamarin.Windows.Injector -Version 1.0.0
<PackageReference Include="Xamarin.Windows.Injector" Version="1.0.0" />
<PackageVersion Include="Xamarin.Windows.Injector" Version="1.0.0" />
<PackageReference Include="Xamarin.Windows.Injector" />
paket add Xamarin.Windows.Injector --version 1.0.0
#r "nuget: Xamarin.Windows.Injector, 1.0.0"
#:package Xamarin.Windows.Injector@1.0.0
#addin nuget:?package=Xamarin.Windows.Injector&version=1.0.0
#tool nuget:?package=Xamarin.Windows.Injector&version=1.0.0
Allows injecting .NET code into a remote process on Windows
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
# Windows.Injector
Allows injecting .NET code into a remote process on Windows
Heavily based on [Cory Plott](http://www.cplotts.com/)'s [Snoop](https://github.com/cplotts/snoopwpf).
Usage:
* Install:
```
install-package Xamarin.Windows.Injector
```
The following properties are used to determine which version (`x86` or `x64`) of the `boostrap.dll`
assembly will be referenced: `PlatformTarget`, `Platform` and `RuntimeIdentifier`. If any of those
specify either `x86` or `x64`, the assembly will be automatically referenced. Note that you cannot
invoke the injector via its API from an `AnyCPU` library, since it has to be of a specific bitness.
The targets automatically include as content both the assembly as well as a helper `Injector.exe`
executable which you can use to inject into processes that have a different bitness than the calling one.
* Launch:
```
var targetProcess = System.Diagnostics.Process.GetProcessesByName("devenv.exe")[0];
Injector.Launch(
// IntPtr of the main window handle of the process to inject
targetProcess.MainWindowHandle,
// The full path to the .NET assembly to load in the remote process
Assembly.GetExecutingAssembly().Location,
// Full type name of the public static class to invoke in the remote process
"MyApp.Startup",
// Name of the static method in that class to invoke in the remote process
"Start");
```
Optionally, the injected method call can also receive parameters, in a `{method}:arg1:arg2:argN` format:
```
var targetProcess = System.Diagnostics.Process.GetProcessesByName("devenv.exe")[0];
Injector.Launch(
// IntPtr of the main window handle of the process to inject
targetProcess.MainWindowHandle,
// The full path to the .NET assembly to load in the remote process
Assembly.GetExecutingAssembly().Location,
// Full type name of the public static class to invoke in the remote process
"MyApp.Startup",
// Name of the static method in that class to invoke in the remote process
"Start:hello:42:true");
```
See [Program.cs](src/Sample/Program.cs) for complete example.
When referencing the package from an `AnyCPU` project, the `x86` and `x64` folders will be included as
content and copied to the project output path. This allows you to run the relevant `Injector.exe` for
that matches the target process bitness. This executable receives the same parameters as the `Launch`
method shown above.
> NOTE: parameter type conversion is supported and happens via the `TypeConverter` associated with the
parameter type.
Built from https://github.com/xamarin/Windows.Injector/commit/f38b5f9