資源簡介
C# 最簡單使用 EasyHook 源碼,極簡而全,Hook入門者,讓大家都會Hook。支持注入托管非托管程序,32位和64位程序,windows 10 x64 調試通過。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Runtime.InteropServices;
using?EasyHook;
using?System.Threading;
using?System.Diagnostics;
using?System.Windows.Forms;
namespace?ClassLibrary1
{
????[Serializable]
????public?class?HookParameter
????{
????????public?string?Msg?{?get;?set;?}
????????public?int?HostProcessId?{?get;?set;?}
????}
????public?class?Main?:?EasyHook.IEntryPoint
????{
????????public?LocalHook?MessageBoxWHook?=?null;
????????public?LocalHook?MessageBoxAHook?=?null;
????????public?Main(
????????????RemoteHooking.IContext?context
????????????String?channelName
?????????????HookParameter?parameter
????????????)
????????{
????????????MessageBox.Show(parameter.Msg?“Hooked“);
????????}
????????public?void?Run(
????????????RemoteHooking.IContext?context
????????????String?channelName
?????????????HookParameter?parameter
????????????)
????????{
????????????try
????????????{
????????????????MessageBoxWHook?=?LocalHook.Create(
????????????????????LocalHook.GetProcAddress(“user32.dll“?“MessageBoxW“)
????????????????????new?DMessageBoxW(MessageBoxW_Hooked)
????????????????????this);
????????????????MessageBoxWHook.ThreadACL.SetExclusiveACL(new?Int32[1]);
????????????????MessageBoxAHook?=?LocalHook.Create(
????????????????????LocalHook.GetProcAddress(“user32.dll“?“MessageBoxA“)
????????????????????new?DMessageBoxW(MessageBoxA_Hooked)
????????????????????this);
????????????????MessageBoxAHook.ThreadACL.SetExclusiveACL(new?Int32[1]);
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????MessageBox.Show(ex.Message);
????????????????return;
????????????}
????????????try
????????????{
????????????????while?(true)
????????????????{
????????????????????Thread.Sleep(10);
????????????????}
????????????}
????????????catch
????????????{
????????????}
????????}
????????#region?MessageBoxW
????????[DllImport(“user32.dll“?EntryPoint?=?“MessageBoxW“?CharSet?=?CharSet.Unicode)]
????????public?static?extern?IntPtr?MessageBoxW(int?hWnd?string?text?string?caption?uint?type);
????????[UnmanagedFunctionPointer(CallingConvention.StdCall?CharSet?=?CharSet.Unicode)]
????????delegate?IntPtr?DMessageBoxW(int?hWnd?string?text?string?caption?uint?type);
????????static?IntPtr?MessageBoxW_Hooked(int?hWnd?string?text?string?caption?uint?type)
????????{
????????????return?MessageBoxW(hWnd?“Hooked?-?“?+?text?“Hooked?-?“?+?caption?type);
????????}
????????#endregion
????????#region?MessageBoxA
????????[DllImport(“user32.dll“?EntryPoint?=?“MessageBoxA“?CharSet?=?CharSet.Ansi)]
????????public?static?extern?IntPtr?MessageBoxA(int?hWnd?string?text?string?caption?uint?type);
????????[UnmanagedFunctionPointer(CallingConvention.StdCall?CharSet?=?CharSet.Ansi)]
????????delegate?IntPtr?DMessageBoxA(int?hWnd?string?text?string?caption?uint?type);
????????static?IntP
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6656??2017-09-27?17:26??ClassLibrary1\bin\Debug\ClassLibrary1.dll
?????文件??????15872??2017-09-27?17:26??ClassLibrary1\bin\Debug\ClassLibrary1.pdb
?????文件???????2976??2017-09-27?16:58??ClassLibrary1\ClassLibrary1.csproj
?????文件???????3218??2017-09-27?17:26??ClassLibrary1\Main.cs
?????文件????????999??2017-09-27?16:33??ClassLibrary1\obj\Debug\ClassLibrary1.csproj.FileListAbsolute.txt
?????文件???????6680??2017-09-27?16:32??ClassLibrary1\obj\Debug\ClassLibrary1.csprojResolveAssemblyReference.cache
?????文件???????6656??2017-09-27?17:26??ClassLibrary1\obj\Debug\ClassLibrary1.dll
?????文件??????15872??2017-09-27?17:26??ClassLibrary1\obj\Debug\ClassLibrary1.pdb
?????文件???????6105??2017-09-27?17:26??ClassLibrary1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????1358??2017-09-27?15:47??ClassLibrary1\Properties\AssemblyInfo.cs
?????文件??????49152??2017-09-27?15:50??ClassLibrary1\RefLib\EasyHook.dll
?????文件????????596??2017-09-27?16:10??ClassLibrary1\SN.snk
?????文件???????6656??2017-09-27?17:26??WindowsFormsApplication8\bin\Debug\ClassLibrary1.dll
?????文件??????15872??2017-09-27?17:26??WindowsFormsApplication8\bin\Debug\ClassLibrary1.pdb
?????文件??????49152??2017-09-27?16:22??WindowsFormsApplication8\bin\Debug\EasyHook.dll
?????文件?????263680??2017-09-27?16:21??WindowsFormsApplication8\bin\Debug\EasyHook32.dll
?????文件?????299008??2017-09-27?16:21??WindowsFormsApplication8\bin\Debug\EasyHook64.dll
?????文件??????10240??2017-09-27?17:26??WindowsFormsApplication8\bin\Debug\WindowsFormsApplication8.exe
?????文件??????34304??2017-09-27?17:26??WindowsFormsApplication8\bin\Debug\WindowsFormsApplication8.pdb
?????文件??????11592??2017-09-28?13:49??WindowsFormsApplication8\bin\Debug\WindowsFormsApplication8.vshost.exe
?????文件????????490??2015-07-10?19:01??WindowsFormsApplication8\bin\Debug\WindowsFormsApplication8.vshost.exe.manifest
?????文件??????49152??2017-09-27?16:22??WindowsFormsApplication8\EasyHook.dll
?????文件?????263680??2017-09-27?16:21??WindowsFormsApplication8\EasyHook32.dll
?????文件?????299008??2017-09-27?16:21??WindowsFormsApplication8\EasyHook64.dll
?????文件???????4189??2017-09-27?17:18??WindowsFormsApplication8\Form1.cs
?????文件???????3112??2017-09-27?17:11??WindowsFormsApplication8\Form1.Designer.cs
?????文件???????5817??2017-09-27?17:11??WindowsFormsApplication8\Form1.resx
?????文件???????5420??2017-09-27?16:18??WindowsFormsApplication8\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????7128??2017-09-27?17:26??WindowsFormsApplication8\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????3518??2017-09-28?13:49??WindowsFormsApplication8\obj\x86\Debug\WindowsFormsApplication8.csproj.FileListAbsolute.txt
............此處省略40個文件信息
- 上一篇:c#做的一個計算器
- 下一篇:局域網聊天軟件C#源碼
評論
共有 條評論