随笔 - 58  文章 - 0  trackbacks - 0
<2010年11月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿

随笔分类

随笔档案

文章档案

电影

搜索

  •  

最新评论

阅读排行榜

评论排行榜

// ListenforQQDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ListenforQQ.h"
#include "ListenforQQDlg.h"
#include <iostream>
#include <wchar.h>
#include <string.h>
//#include "ForDebug.h"
#include "ToCopyData.h"
#include "FORMCopyData.h"
#include "ToUDPData.h"



char bufCopyData[200]="\0";
char bufRead[800];
int bufNum=0;


char IMCopyData[2];

#define _UNICODE 
#define UNICODE 
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg public CDialog
{
public:
    
CAboutDlg();
    
    
// Dialog Data
    //{{AFX_DATA(CAboutDlg)
    
enum IDD IDD_ABOUTBOX };
    
//}}AFX_DATA
    
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CAboutDlg)
protected:
    
virtual void DoDataExchange(CDataExchangepDX);    // DDX/DDV support
    //}}AFX_VIRTUAL
    
    // Implementation
protected:
    
//{{AFX_MSG(CAboutDlg)
    //}}AFX_MSG
    
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
    
//{{AFX_DATA_INIT(CAboutDlg)
    //}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchangepDX)
{
    
CDialog::DoDataExchange(pDX);
    
//{{AFX_DATA_MAP(CAboutDlg)
    //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlgCDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CListenforQQDlg dialog

CListenforQQDlg::CListenforQQDlg(CWndpParent /*=NULL*/)
CDialog(CListenforQQDlg::IDDpParent)
{
    
//{{AFX_DATA_INIT(CListenforQQDlg)
    // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
    // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
    
m_hIcon AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CListenforQQDlg::DoDataExchange(CDataExchangepDX)
{
    
CDialog::DoDataExchange(pDX);
    
//{{AFX_DATA_MAP(CListenforQQDlg)
    // NOTE: the ClassWizard will add DDX and DDV calls here
    //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CListenforQQDlgCDialog)
//{{AFX_MSG_MAP(CListenforQQDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_COPYDATA()
ON_WM_CANCELMODE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()



BOOL InitSocket(void)
{
    
if(WSAStartup(MAKEWORD(2,2),&wsaData)!=0)
    {
        
//    cout<<"加载winsock失败,错误ID为:"<<WSAGetLastError()<<endl;
        
return FALSE;
    }
    
m_socket=socket(AF_INET,SOCK_DGRAM,0);
    
if(INVALID_SOCKET==m_socket)
    {
        
//    cout<<"套接字创建失败!错误ID为:"<<WSAGetLastError()<<endl;
        
return FALSE;
    }
    
SerAdd.sin_family=AF_INET;
    
SerAdd.sin_port=htons(Const_Port);
    
SerAdd.sin_addr.S_un.S_addr=inet_addr("127.0.0.1");
    
return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CListenforQQDlg message handlers

BOOL CListenforQQDlg::OnInitDialog()
{
    
CDialog::OnInitDialog();
    
    
// Add "About..." menu item to system menu.
    
    // IDM_ABOUTBOX must be in the system command range.
    
ASSERT((IDM_ABOUTBOX 0xFFF0) == IDM_ABOUTBOX);
    
ASSERT(IDM_ABOUTBOX 0xF000);
    
    
CMenupSysMenu GetSystemMenu(FALSE);
    
if (pSysMenu != NULL)
    {
        
CString strAboutMenu;
        
strAboutMenu.LoadString(IDS_ABOUTBOX);
        
if (!strAboutMenu.IsEmpty())
        {
            
pSysMenu->AppendMenu(MF_SEPARATOR);
            
pSysMenu->AppendMenu(MF_STRINGIDM_ABOUTBOXstrAboutMenu);
        }
    }
    
    
// Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    
SetIcon(m_hIconTRUE);            // Set big icon
    
SetIcon(m_hIconFALSE);        // Set small icon
    
    // TODO: Add extra initialization here/*/
    
InitSocket();
//////////////1,int TYPE 2,char im类型[2] 3,char im型号4,char 版本5, char主号码6,char主名称7,次号码8,次名称   9,int内容长度 10,内容
     
SendUDP(0x01,"QQ","QQ2010","SP1","12345","傻瓜","1000","小春","0001f2e","111111111ttttttttt");

     
SendUDP(0x01,"QQ","QQ2010","111111","2222222","3333333","1000","4444","0001f2e","111111111ttttttttt");

     
return TRUE;  // return TRUE  unless you set the focus to a control
}

void CListenforQQDlg::OnSysCommand(UINT nIDLPARAM lParam)
{
    
if ((nID 0xFFF0) == IDM_ABOUTBOX)
    {
        
CAboutDlg dlgAbout;
        
dlgAbout.DoModal();
    }
    
else
    
{
        
CDialog::OnSysCommand(nIDlParam);
    }
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CListenforQQDlg::OnPaint() 
{
    
if (IsIconic())
    {
        
CPaintDC dc(this); // device context for painting
        
        
SendMessage(WM_ICONERASEBKGND, (WPARAMdc.GetSafeHdc(), 0);
        
        
// Center icon in client rectangle
        
int cxIcon GetSystemMetrics(SM_CXICON);
        
int cyIcon GetSystemMetrics(SM_CYICON);
        
CRect rect;
        
GetClientRect(&rect);
        
int = (rect.Width() - cxIcon 1) / 2;
        
int = (rect.Height() - cyIcon 1) / 2;
        
        
// Draw the icon
        
dc.DrawIcon(xym_hIcon);
    }
    
else
    
{
        
CDialog::OnPaint();
    }
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CListenforQQDlg::OnQueryDragIcon()
{
    
return (HCURSORm_hIcon;
}


int ToDealQQ2010SP1()
{
    
CString temp,test,mess_context;
    
int iNum;//固定地址
    
    
DWORD dwProcessId=0;
    
HWND hAA =::FindWindow(NULL,"QQ2010");
    
    
if(!hAA)
    {
        
AfxMessageBox("找不到需要的进程");
        
return 0;
    }
    
DWORD ThreadId =  GetWindowThreadProcessIdhAA , &dwProcessId);
    
HANDLE  hProcess OpenProcess(PROCESS_VM_OPERATIONPROCESS_VM_WRITE|PROCESS_VM_READ,FALSE,dwProcessId); 
    
    
    
if(bufCopyData[DTOGOTYPE]==TO_MESSAGE)//发信息判断
    
{
        
//读取,创建,过滤        
        /*            AfxMessageBox("111111");
        /////////窗口-人物信息/////////
        char *s_BufWin;
        s_BufWin=(char *)malloc(256);
        
          HWND hWnd = ::GetForegroundWindow();//GetActiveWindow(); //'得到活动窗口的句柄 
          ::GetWindowText(hWnd,s_BufWin,255);
          AfxMessageBox(s_BufWin);
          free(s_BufWin);
        */
        //////////读取内容///////////
        /*        
        test.Format("测试入口数据 :");
        for(int i=0;i<200;i++)// 
        {
        temp.Format("%X ",bufCopyData[i]);
        test+=temp;
        }
        AfxMessageBox(test);
        */
        
        
        ////////
        
char m_add_right_Data[6];
        
test.Format("正向地址 :");
        
for(int t=FIXADD1,int atemp=0;t<FIXADD1+6;t++,atemp++)
        {
            
m_add_right_Data[atemp]=bufCopyData[t];  //char 数据问题
        
}
        
        
mess_context.Format("%s",m_add_right_Data);
        
        
//                 nt resultnum=-1;   
        
char *pStr2=(char *)mess_context.GetBuffer(0);   
        
sscanf(pStr2,"%x",&iNum);
        
        
temp.Format("内容地址iNum为 %x",(DWORD*)iNum);  //正解的
        
        
AfxMessageBox(temp);
        
        
        
        
/////自己//////
        
DWORD QQNum=0x01C27964;//号码地址
        
ReadProcessMemory(hProcess,(LPVOID)QQNum,&bufNum,4,NULL);
        
/////内容//////
        
DWORD QQADD=0x00127A64;//内容长度地址
        
int m_ContestLong=0;  
        
ReadProcessMemory(hProcess,(LPVOID)QQADD,&m_ContestLong,4,NULL);     //内容长度
        
        
iNum =iNum 12;//读取内容起始
        
ReadProcessMemory(hProcess,(LPVOID)iNum,&bufRead,200,NULL);
        
        
wchar_t *chTest=new wchar_t[500];
        
for(int i=0;i<8;i++)
        {
            
chTest[i]=bufRead[i];
        }
        
//wchar_t str[]=L"中国";
        
test.Format("TTTTT内容测试");
        
for(i=0;i<8;i++)
        {
            
temp.Format("%X ",chTest[i]);
            
test+=temp;
        }
        
AfxMessageBox(test);
        
MessageBoxW(NULL,chTest,chTest,MB_OK|MB_ICONINFORMATION);       

        
///////结构/////for()
            ///1,IM类型,消息类型,1,自己号码名称, 2,别人号码,名称,3,内容,,

//////////////1,int TYPE 2,char im类型[2] 3,char im型号4,char 版本5, char主号码6,char主名称7,次号码8,次名称   9,int内容长度 10,内容
//Int SendUDP(int n_comtype,char n_imtype,char n_immodel,char n_edition,char n_masnum,char n_masname ,char n_guestnum ,char n_guestname,char n_contentlong,char n_content)
     
SendUDP(0x01,"QQ","QQ2010","SP1","12345","傻瓜","1000","小春","0001f2e","ttttttttt");

    
//    bufUDPData[];
        //////过滤////////
    
}
    
    
if(bufCopyData[DTOGOTYPE]==RE_MESSAGE)//收信息判断
    
{            AfxMessageBox("22222222");
    
//读取,过滤
    
int m_ContestLong=0;    //内容长度
    /////自己//////
    
DWORD QQNum=0x01C27964;//号码
    
ReadProcessMemory(hProcess,(LPVOID)QQNum,&bufNum,4,NULL);
    

    
    
wchar_t *chTest;
    
chTest=(wchar_t*) malloc(m_ContestLong);
    
    
///收的--内容 
    
iNum =iNum 12;//读取内容起始
    
ReadProcessMemory(hProcess,(LPVOID)iNum ,&chTest,m_ContestLong*2,NULL);
    
test.Format("内容为:");
    
    
MessageBoxW(NULL,chTest,chTest,MB_OK|MB_ICONINFORMATION);       

    
free(chTest);
    
    
    }

    
//发送信息
    //send
//    
    
return 0;
}

//接收
//提取--------IM,型号,版本
//

//情况分析
//发----Read,Get
//收----Read,Read

//
//Read
//过滤
//显示
//

int ToDisPosal()
{
    
//    if(strcmp(bufCopyData[DIM_TYPE1],"T")==0 &&strcmp(bufCopyData[DIM_TYPE2],"M")==0)//
    
IMCopyData[0]=bufCopyData[DIM_TYPE1];
    
IMCopyData[1]=bufCopyData[DIM_TYPE2];
    
    
if(strcmp(IMCopyData,"TM")==0)//TM
    
{
        
switch(bufCopyData[DTYPE]) //版本
        
{
        
case TM2009://TM2009
            
switch(bufCopyData[DMODLULE])//型号
            
{
            
/*    case SP1://sp1
            
              
                case SP2://sp2
                case SP3://sp3
                */            
default:
                
break;
            }
            
break;
            
            
case TM2007://
                
switch(bufCopyData[DMODLULE])//型号
                
{
                
/*    case SP1://sp1
                
                  
                    case SP2://sp2
                    case SP3://sp3
                    */            
default:
                    
break;
                }
                
//    case:
                
                
default:
                    
break;
        }
    }
    
//    if(strcmp(bufCopyData[DIM_TYPE1],"Q")==0 &&strcmp(bufCopyData[DIM_TYPE2],"Q")==0)//QQ信息
    
    
    
if(strcmp(IMCopyData,"QQ")==0)//QQ信息
    
{
        
        
switch(bufCopyData[DTYPE])
        {
        
case QQ2010://QQ2010
            
switch(bufCopyData[DMODLULE])
            {
            
case SP1ToDealQQ2010SP1();
                
break;
            
case SP2:
                
break;
            
case SP3:
                
break;
            
default:
                
break;
            }
            
/*
            case://sp1
            case://sp2
            case://sp3
            }
            }
            case://QQ2009
            case://QQ2008
            */        
}
            
            
    }
    
    
return 0;
}

DWORD WINAPI SetToDealQQ2010ProcLPVOID lpParameter)
{
    
Sleep(500);
    
ToDealQQ2010SP1();
    
return 0;
}


BOOL CListenforQQDlg::OnCopyData(CWndpWndCOPYDATASTRUCTpCopyDataStruct
{
    
// TODO: Add your message handler code here and/or call default
    
    
strcpy(bufCopyData,(char*)pCopyDataStruct->lpData);//数据传递
    
    
CreateThread(NULL,0,SetToDealQQ2010Proc,NULL,0,NULL); //创建处理线程
    
    
if(pCopyDataStruct->dwData==11)
    {
        
AfxMessageBox("测试第一个");
        
        
        
//        BYTE m_MessageContex[500];
        
char buf[100]="\0";
        
strcpy(buf,(char*)pCopyDataStruct->lpData);
        
buf[pCopyDataStruct->cbData]='\0';
        
        
CString temp,mess_context;
        
temp.Format("长度为%x",pCopyDataStruct->cbData-10);
        
//    AfxMessageBox(temp);
        
        /*
        int iNum = 0; 
        //char szNum[32] = {1234}; 
        iNum = (const char *)atoi(pCopyDataStruct->lpData);*/ 
        
        
DWORD iNum 0
        
//char szNum[32] = {1234}; 
        
iNum atoi(buf);
        
        
//    temp.Format("%s",buf);
        //    AfxMessageBox(buf);
        //    AfxMessageBox(temp);
        /*
        temp.Format("内容地址iNum为 %x",(DWORD*)iNum);
        AfxMessageBox(temp);
        
          temp.Format("内容地址i为 %x",(DWORD*)pCopyDataStruct->lpData);
        AfxMessageBox(temp);*/
        
        //    mess_context.Format("内容为:");
        
        
char m_context[8];
        
for(int t=0;t<7;t++)
        {
            
//temp.Format("%X",buf[t]);
            
m_context[t]=buf[t];
        }
        
//    mess_context.Format("这个垃圾 %s",m_context);
        
        //    AfxMessageBox(mess_context);
        
        //    iNum = atoi(m_context);//默认为 10进制
        
        
        
        
mess_context.Format("%s",m_context);
        
        
//                 nt resultnum=-1;   
        
char *pStr=(char *)mess_context.GetBuffer(0);   
        
sscanf(pStr,"%x",&iNum);
        
        
temp.Format("内容地址iNum为 %x",(DWORD*)iNum);
        
//    AfxMessageBox(temp);
        
        
        
        
DWORD dwProcessId=0;
        
HWND hAA =::FindWindow(NULL,"QQ2010");
        
        
if(!hAA)
        {
            
AfxMessageBox("找不到需要的进程");
            
return 0;
        }
        
DWORD ThreadId =  GetWindowThreadProcessIdhAA , &dwProcessId);
        
HANDLE  hProcess OpenProcess(PROCESS_VM_OPERATIONPROCESS_VM_WRITE|PROCESS_VM_READ,FALSE,dwProcessId); 
        
        
        
        
        
        
        
char s_Buf[256];
        
HWND hWnd = ::GetForegroundWindow();//GetActiveWindow(); //'得到活动窗口的句柄 
        
::GetWindowText(hWnd,s_Buf,255);
        
AfxMessageBox(s_Buf);
        
//printf("tttt   %s \n",s_Buf);
        
        
        
wchar_t pwchello[500];
        
ReadProcessMemory(hProcess,(LPVOID)iNum,&pwchello,800,NULL);
        
mess_context.Format("内容为:");
        
        
        
//      AfxMessageBox(pwchello);
        
CString atemp[50];
        
wchar_t *chTest=new wchar_t[pCopyDataStruct->cbData-10];
        
        
//  MessageBox(NULL,"","");
        
for(int i=0;i<pCopyDataStruct->cbData-10;i++)
        {
            
chTest[i]=pwchello[i];
            
temp.Format("%X",pwchello[i]);
            
mess_context+=temp;
            
//              atemp[i]=m_MessageContex[i];
        
}        
        
MessageBoxW(NULL,chTest,chTest,MB_OK|MB_ICONINFORMATION);
    }
    
    
    
//  mess_context.Format("%s",pwchello);
    //      AfxMessageBox(_T(pwchello));
    // MessageBox(_T(pwchello));
    //      mess_context.Format("%s",m_MessageContex[2]);
    
    //    locale loc( "chs" );//定义“区域设置”为中文方式
    //    wcout.imbue( loc );//载入中文字符输入方式
    
    //      AfxMessageBox(_T(mess_context));
    
    //      temp.Format("%S",chTest);
    //     AfxMessageBox(temp);
    //      temp.Format("%S",pwchello);
    //    AfxMessageBox(temp);
    
    
    
    
    
return CDialog::OnCopyData(pWndpCopyDataStruct);
}




void CListenforQQDlg::OnCancelMode() 
{
    
CDialog::OnCancelMode();
    
    
// TODO: Add your message handler code here
    
}
posted on 2010-08-25 18:57 傅先生2 阅读(160) 评论(0)  编辑 收藏 引用 所属分类: 社会心理学探研

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理