吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3768|回复: 11
收起左侧

[其他转载] C/C++封装的DLL封装到易语言模块中易调用----例:扫雷

[复制链接]
Patty 发表于 2020-5-30 15:58
本帖最后由 Patty 于 2020-5-30 16:26 编辑

语言:C/C++ 易语言
工具:VS2017,OD,Dll查看器depends_32,扫雷

知识: 远程线程汇编代码注入技术,调试分析,动态链接库dll编写,VS封装DLL易调用
------------------------------------------------------------------------------------------------------------------------------
一、调试
1.通过程序涉及的API,雷的位置随机可以推出,用了srand 、rand函数获取的随机值。
从而找到重新开始Call和【数据地址和数据存储的方式】用来实现重新开始Call与雷标记旗的功能
//0x10=墙//0x8F=雷//0x8E=旗//0x40=空//0x41=1//0x42=2//0x43=3//0x44=4//0x45=5
1.png


2.通过程序窗口的消息机制,找到点击坐标Call  依据获取的数据储存方式遍历坐标实现秒杀

2.png
------------------------------------------------------------------------------------------------------------------------------

二、用VS2017的控制台测试出功能
2020-05-30.gif
------------------------------------------------------------------------------------------------------------------------------
三、将VS控制台的代码封装到Dll中
3.png
4.png
------------------------------------------------------------------------------------------------------------------------------
完毕感谢观看~!
扫雷exe: 扫雷.rar (62.06 KB, 下载次数: 16)
扫雷辅助exe: 扫雷辅助.rar (386.55 KB, 下载次数: 12) //程序我加了签名应该不会报毒
扫雷模块ec: 扫雷模块.rar (5.59 KB, 下载次数: 20)
扫雷Dll: SaoLeiDll.rar (4.71 KB, 下载次数: 26)
控制台源码大家试试看能否自己实现封装调用
[C++] 纯文本查看 复制代码
#include <windows.h>
#include <stdio.h>

typedef struct g_GETPROCESSINFO {
        HWND     WindowsHwand;
        DWORD    Pid;
        HANDLE   ProcessHandle;
        PVOID    AllocMemoryAddr;
        DWORD    ThunderArrayBase;//雷数组基址
        DWORD    WidthBase;//宽度基址
}g_GetProcessInfo, *g_pGetProcessInfo;


//重新开始
void Restart(g_GetProcessInfo& info)
{
        byte RestartCallCode[] = { 0x60 ,0x9C ,0xB8 ,0x7A ,0x36 ,0x00 ,0x01 ,0xFF ,0xD0 ,0x61 ,0x9D ,0xC3 };
        WriteProcessMemory(info.ProcessHandle, info.AllocMemoryAddr, RestartCallCode, sizeof(RestartCallCode), NULL);
        CreateRemoteThread(info.ProcessHandle, NULL, NULL, (LPTHREAD_START_ROUTINE)info.AllocMemoryAddr, NULL, NULL, NULL);
}

//点击Call
void ClickCallCode(g_GetProcessInfo& info,BYTE x, BYTE y)
{
        BYTE Code1[] = { 0x60 ,0x9C ,0x6A ,x ,0x6A ,y ,0xB8 ,0x12 ,0x35 ,0x00 ,0x01 ,0xFF ,0xD0 ,0x61 ,0x9D ,0xC3 };
        WriteProcessMemory(info.ProcessHandle, info.AllocMemoryAddr, Code1, sizeof(Code1), NULL);
}
//点击
void Click(g_GetProcessInfo& info)
{
        DWORD Width = 0;
        BYTE  ThunderValue = 0;

        ReadProcessMemory(info.ProcessHandle, (LPCVOID)info.WidthBase, &Width, 0x4, NULL);
        for (BYTE i = 1; i < (Width + 0x1); i++)//行
        {
                DWORD FirstThunderArray = info.ThunderArrayBase + i * 0x20;//定位左上角第一个框的内存地址
                DWORD index = 0;
                for (BYTE j = 1; j < (Width + 0x1); j++)//列
                {
                        DWORD FirstBase = FirstThunderArray + j * 0x1;
                        ReadProcessMemory(info.ProcessHandle, (LPCVOID)FirstBase, &ThunderValue, 0x1, NULL);
                        if (ThunderValue == 0x10)//墙
                        {
                                break;
                        }
                        //0x8F=雷 0x8E=旗 0x40=空 0x41=1 0x42=2 0x43=3 0x44=4 0x45=5
                        if (ThunderValue != 0x8F
                                && ThunderValue != 0x8E
                                && ThunderValue != 0x40
                                && ThunderValue != 0x41
                                && ThunderValue != 0x42
                                && ThunderValue != 0x43
                                && ThunderValue != 0x44
                                && ThunderValue != 0x45)
                        {
                                ClickCallCode(info, i, j);
                                Sleep(10);
                                CreateRemoteThread(info.ProcessHandle, NULL, NULL, (LPTHREAD_START_ROUTINE)info.AllocMemoryAddr, NULL, NULL, NULL);
                                Sleep(20);
                        }
                        index++;
                }
                if (index==0)
                {
                        break;
                }
        }
}

//判断是否有雷并标记
void ThunderArray(g_GetProcessInfo& info)
{
        BYTE  ifThunder = 0;
        for (int i = 0; i < (int)0x360; i++)
        {
                ReadProcessMemory(info.ProcessHandle, (LPCVOID)(info.ThunderArrayBase +i), &ifThunder, 0x1, NULL);

                if (ifThunder == (byte)0x8F)//雷
                {
                        BYTE Flag = 0x8E;//旗
                        WriteProcessMemory(info.ProcessHandle, (LPVOID)(info.ThunderArrayBase + i), &Flag, 0x1, NULL);
                }
        }
        RECT rt = { 0 };
        GetClientRect(info.WindowsHwand, &rt);
        InvalidateRect(info.WindowsHwand, &rt, true);
}


void GetProcessInfo(g_GetProcessInfo& info)
{
        info.WindowsHwand = FindWindow(NULL, L"扫雷");
        GetWindowThreadProcessId(info.WindowsHwand, &info.Pid);
        info.ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, info.Pid);
        info.AllocMemoryAddr = VirtualAllocEx(info.ProcessHandle, NULL, 0x4096, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
}

void HotKey(g_GetProcessInfo& info)
{
        MSG msg;
        SecureZeroMemory(&msg, sizeof(msg));
        DWORD  KeyCodeF1 = 112;
        DWORD  KeyCodeF2 = 113;
        DWORD  KeyCodeF3 = 114;

        RegisterHotKey(NULL, KeyCodeF1, NULL, KeyCodeF1);
        RegisterHotKey(NULL, KeyCodeF2, NULL, KeyCodeF2);
        RegisterHotKey(NULL, KeyCodeF3, NULL, KeyCodeF3);
        while (GetMessageA(&msg, NULL, 0, 0) != 0)
        {
                if (msg.message == WM_HOTKEY)
                {
                        if (msg.wParam == KeyCodeF1)
                        {
                                Restart(info);
                        }
                        if (msg.wParam == KeyCodeF2)
                        {
                                ThunderArray(info);
                        }
                        if (msg.wParam == KeyCodeF3)
                        {
                                Click(info);
                        }
                        
                }
        }
}

int main()
{
        g_GetProcessInfo info = {0};
        GetProcessInfo(info);//取游戏信息
        info.ThunderArrayBase = 0x1005340;//雷数组基址
        info.WidthBase = 0x10056AC;//宽度基址

        printf("F1=重新开局\n");
        printf("F2=雷标记旗\n");
        printf("F3=激活框框\n\n");

        HotKey(info);

        getchar();getchar();
        return 0;
}


免费评分

参与人数 1吾爱币 +7 热心值 +1 收起 理由
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| Patty 发表于 2020-5-31 13:34
小非凡 发表于 2020-5-31 00:16
大佬你好,我问一下,是不是不兼容Win10啊,
绑定游戏、标记雷棋,这两个功能都是正常的。
但是,重 ...

image.png
兼容Win10的,我的问题:远程线程是直接调用Call的不需要保存栈环境
image.png
Hook调用才需要保存栈环境去掉栈保存寄存器Win10运行没问题
SaoLei秒杀套.rar (461.67 KB, 下载次数: 5)

免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
小非凡 + 1 + 1 感谢大佬的回复,有时间的话,可以安排一下新版本的扫雷:https://www.52po.

查看全部评分

头像被屏蔽
小非凡 发表于 2020-5-31 14:33
TH_ZL 发表于 2020-5-30 16:02
bachelor66 发表于 2020-5-30 16:30
小白只能摩拜了                                
ningxuan 发表于 2020-5-30 17:10
小白只能摩拜了
成熟的美羊羊 发表于 2020-5-30 23:05
小白赶紧膜拜【滑稽】
头像被屏蔽
小非凡 发表于 2020-5-31 00:16
提示: 作者被禁止或删除 内容自动屏蔽
小闹 发表于 2020-5-31 14:08
学习了,多谢楼主
ok318 发表于 2020-6-3 09:40
谢谢分享,下来看看

北京朝阳望京北路9号叶青大厦C座一层 高存玉13241743772
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-4 08:39

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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