12558网页游戏私服论坛

 找回密码
 立即注册
游戏开服表 申请开服
游戏名称 游戏描述 开服状态 游戏福利 运营商 游戏链接
攻城掠地-仿官 全新玩法,觉醒武将,觉醒技能 每周新区 经典复古版本,长久稳定 进入游戏
巅峰新版攻 攻城掠地公益服 攻城掠地SF 新兵种、新武将(兵种) 进入游戏
攻城掠地公 散人玩家的天堂 新开 进入游戏
改版攻城掠 上线即可国战PK 稳定新区 全新改版,功能强大 进入游戏
少年江山 高福利高爆率 刚开一秒 江湖水落潜蛟龙 进入游戏
太古封魔录 开服送10亿钻石 福利多多 不用充钱也可升级 进入游戏
神魔之道 签到送元宝 稳定开新区 送豪华签到奖励 进入游戏
神奇三国 统帅三军,招揽名将 免费玩新区 激情国战,征战四方 进入游戏
龙符 三日豪礼领到爽 天天开新区 助你征战无双 进入游戏
王者之师 免费领豪华奖励 免费玩新区 6元送6888元宝 进入游戏
查看: 278|回复: 0

使用 EasyHook 让系统计算器显示文字

[复制链接]

312

主题

312

帖子

634

积分

实习版主

Rank: 7Rank: 7Rank: 7

积分
634
发表于 2020-9-17 18:10:40 | 显示全部楼层 |阅读模式
效果:


我在学习利用EasyHook的时候,遇到一些坑,也慢慢解决了。
我将采用MarshalByRefObject按引用传递和Serializable按值传递这两种方式实现计算器显示文字的效果
这也是对EasyHook学习的一个过程

第一种方式:利用RemoteHooking.IpcConnectClient和RemoteHooking.IpcCreateServer进行传递
[C#] 纯文本检察 复制代码RemoteHooking.IpcConnectClient(InChannelName);RemoteHooking.IpcCreateServer(ref channelName,WellKnownObjectMode.SingleCall);

第二种方式:利用类的Serializable,并在函数构造时要参加类
[C#] 纯文本检察 复制代码[Serializable]public class FileMonInterface { } public Main(RemoteHooking.IContext context, string InChnnelName, FileMonInterface fmi){ }
两种方式创建的时候Run函数与构造函数的参数都要对应
[C#] 纯文本检察 复制代码public void Run(RemoteHooking.IContext context, string InChannelName)public void Run(RemoteHooking.IContext context, string InChannelName, FileMonInterface fmi)

利用方法:
1、打开软件
2、打开系统计算器
3、点击软件上的注入
4、在计算器任意点击
附上软件界面,很Low


源码: 分为两个类
[C#] 纯文本检察 复制代码using System;using System.Collections.Generic;using System.Linq;using System.Runtime.InteropServices;using System.Text;using System.Threading;using EasyHook;namespace EasyHookDemo{    [Serializable]    public class FileMonInterface { }    public class Main : EasyHook.IEntryPoint    {        private LocalHook Hook;        [DllImport("user32.dll")]        public static extern bool SetWindowText(IntPtr hWnd, string text);        [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = true)]        public delegate bool DSetWindowText(IntPtr hWnd, string text);        public bool SetWindowTextHook(IntPtr hWnd, string text)        {            return SetWindowText(hWnd, "吾爱破解-wtujoxk");        }        #region 第一种方式,按引用传递,MarshalByRefObject        public Main(RemoteHooking.IContext context, string InChannelName)        {            RemoteHooking.IpcConnectClient(InChannelName);        }        public void Run(RemoteHooking.IContext context, string InChannelName)        {            Hook = LocalHook.Create(                LocalHook.GetProcAddress("user32.dll", "SetWindowTextW"),                new DSetWindowText(SetWindowTextHook),                this            );            Hook.ThreadACL.SetExclusiveACL(new[] { 0 });            try            {                while (true)                {                    Thread.Sleep(500);                }            }            catch { }        }        #endregion        #region 第二种方式,按值传递,Serializable        public Main(RemoteHooking.IContext context, string InChnnelName, FileMonInterface fmi)        {        }        public void Run(RemoteHooking.IContext context, string InChannelName, FileMonInterface fmi)        {            Hook = LocalHook.Create(                LocalHook.GetProcAddress("user32.dll", "SetWindowTextW"),                new DSetWindowText(SetWindowTextHook),                this            );            Hook.ThreadACL.SetExclusiveACL(new[] { 0 });            try            {                while (true)                {                    Thread.Sleep(500);                }            }            catch { }        }        #endregion    }}

[C#] 纯文本检察 复制代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Diagnostics;using System.Drawing;using System.Linq;using System.Runtime.Remoting;using System.Text;using System.Windows.Forms;using EasyHook;namespace EasyHookDemo{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void button1_Click(object sender, EventArgs e)        {            int targetPID = 0;            string channelName = null;            targetPID = Process.GetProcessesByName("calc")[0].Id;            #region 第一种方式,按引用传递,MarshalByRefObject            //RemoteHooking.IpcCreateServer(ref channelName,WellKnownObjectMode.SingleCall);            //RemoteHooking.Inject(            //    targetPID,            //    typeof(Main).Assembly.Location,            //    typeof(Main).Assembly.Location,            //    channelName            //);            #endregion            #region 第二种方式,按值传递,Serializable,这种方式Dll要在根目录,不知道为什么            FileMonInterface fmi = new FileMonInterface();            RemoteHooking.Inject(                targetPID,                typeof(Main).Assembly.Location,                typeof(Main).Assembly.Location,                "这个参数必须要有",                fmi            );            #endregion        }    }}

编译好的可执行文件:EasyHookDemo.rar

最后附上工程,为VS2015  .net4.0 环境编写
EasyHookDemo.rar

来源:http://www.12558.net
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
楼主热帖
回复

使用道具 举报

*滑块验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|12558网页游戏私服论坛 |网站地图

GMT+8, 2024-4-25 12:05 , Processed in 0.109375 second(s), 31 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表