AnyHook 1.0.1

dotnet add package AnyHook --version 1.0.1                
NuGet\Install-Package AnyHook -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AnyHook" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AnyHook --version 1.0.1                
#r "nuget: AnyHook, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AnyHook as a Cake Addin
#addin nuget:?package=AnyHook&version=1.0.1

// Install AnyHook as a Cake Tool
#tool nuget:?package=AnyHook&version=1.0.1                

This library gives you a possibility to hook any Windows x64 functions from any code: native C++, managed .NET Framework and managed .NET Core (.NET 6.0). You can set local hooks (hooking functions calls of local process), remote hooks (hooking functions calls of remote process by process ID) and global hooks (hooking functions calls of any process which uses Windows GetMessage call). Callback functions could be set by their addresses, names (module name plus function name) and as delegate instances (managed code).

C# example (.NET 6.0)

using System.Diagnostics;

AnyHook.AnyHook.SetLocalHook("kernel32.dll", "TerminateProcess", new ShadowTerminateProcessDelegate(ShadowTerminateProcess)); Process.GetCurrentProcess().Kill(); Console.ReadKey();

public delegate bool ShadowTerminateProcessDelegate(IntPtr handle, int exitCode);

partial class Program { public static bool ShadowTerminateProcess(IntPtr handle, int exitCode) { Console.WriteLine(handle.ToString()); return true; } }

C++ example (native)

__declspec(dllimport) extern BOOL SetRemoteHook(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, DWORD);

int wmain() { SetRemoteHook(L"kernel32.dll", L"TerminateProcess", "C:\Users\kacha\source\repos\AnyHook\ManagedShadow\bin\Debug\ManagedShadow.dll", L"ShadowTerminateProcess", 8780); TerminateProcess(GetCurrentProcess(), 0); WaitForSingleObject(GetCurrentProcess(), INFINITE); return 0; }

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
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.

Version Downloads Last updated
1.0.1 291 2/28/2023