www.pudn.com > HTTP协议分析器开发源码.rar > mainfrm.h


// MainFrm.h : interface of the CMainFrame class 
// 
///////////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_MAINFRM_H__05C61369_8DFA_4A1D_B3ED_CBC31AA5404E__INCLUDED_) 
#define AFX_MAINFRM_H__05C61369_8DFA_4A1D_B3ED_CBC31AA5404E__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
#include "packet32.h" 
#include "ntddndis.h" 
 
class CMainFrame : public CFrameWnd 
{ 
protected: // create from serialization only 
	CMainFrame(); 
	DECLARE_DYNCREATE(CMainFrame) 
 
protected: 
	CSplitterWnd m_wndSplitter; 
	CSplitterWnd m_wndSplitter2; 
	CDialogBar   m_wndMyDialogBar; 
 
// Attributes 
public: 
 
// Operations 
public: 
 
// Overrides 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CMainFrame) 
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 
	virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext); 
	//}}AFX_VIRTUAL 
 
// Implementation 
public: 
	CString GetOneUrl(); 
	virtual ~CMainFrame(); 
#ifdef _DEBUG 
	virtual void AssertValid() const; 
	virtual void Dump(CDumpContext& dc) const; 
#endif 
 
protected:  // control bar embedded members 
	CStatusBar  m_wndStatusBar; 
	CToolBar    m_wndToolBar; 
 
// Generated message map functions 
protected: 
	//{{AFX_MSG(CMainFrame) 
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 
	afx_msg void OnPosone(); 
	afx_msg void OnMpo(); 
	afx_msg void OnStop(); 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
}; 
////////////////////////////////////////////////////////////////////////////////////////// 
//////////////////////////////////////////////////////////////////////////////////////////// 
 
// BPOThread.h : header file 
// 
///////////////////////////////////////////////////////////////////////////// 
// CBPOThread thread 
 
class CBPOThread : public CWinThread 
{ 
	DECLARE_DYNCREATE(CBPOThread) 
protected: 
public: 
	CBPOThread();           // protected constructor used by dynamic creation 
 
// Attributes 
public: 
    CBPOThread(CString str) 
	{ 
	// 
	} 
 
// Overrides 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CBPOThread) 
	public: 
	virtual BOOL InitInstance(); 
	virtual int ExitInstance(); 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	virtual UINT Sniff(LPVOID lParam); 
	virtual UINT PosOneUrl(LPVOID lParam); 
	virtual UINT MPO(LPVOID lParam); 
public: 
	void   PrintPackets(LPPACKET lpPacket); 
	static UINT StartSniff(LPVOID lParam); 
	static UINT StartMPO(LPVOID lParam); 
	static UINT StartPosOneUrl(LPVOID lParam); 
	virtual ~CBPOThread(); 
 
	// Generated message map functions 
	//{{AFX_MSG(CBPOThread) 
		// NOTE - the ClassWizard will add and remove member functions here. 
	//}}AFX_MSG 
 
	DECLARE_MESSAGE_MAP() 
private: 
 
}; 
 
///////////////////////////////////////////////////////////////////////////////////// 
////////////////////////////////////////////////////////////////////////////////////// 
 
///////////////////////////////////////////////////////////////////////////// 
// CEditView1 view 
 
class CEditView1 : public CEditView 
{ 
protected: 
	CEditView1();           // protected constructor used by dynamic creation 
	DECLARE_DYNCREATE(CEditView1) 
	 
		CFont m_NewFont; 
// Attributes 
public: 
 
// Operations 
public: 
 
// Overrides 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CEditView1) 
	protected: 
	virtual void OnDraw(CDC* pDC);      // overridden to draw this view 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	virtual ~CEditView1(); 
#ifdef _DEBUG 
	virtual void AssertValid() const; 
	virtual void Dump(CDumpContext& dc) const; 
#endif 
 
	// Generated message map functions 
protected: 
	//{{AFX_MSG(CEditView1) 
	afx_msg void OnChange(); 
	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); 
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 
	//}}AFX_MSG 
	afx_msg LRESULT OnShowInfo(WPARAM wParam,LPARAM lParam); 
	DECLARE_MESSAGE_MAP() 
}; 
//////////////////////////////////////////////////////////////////////////////////// 
///////////////////////////////////////////////////////////////////////////////////// 
 
///////////////////////////////////////////////////////////////////////////// 
// CEditView2 view 
 
class CEditView2 : public CView 
{ 
protected: 
	CEditView2();           // protected constructor used by dynamic creation 
	DECLARE_DYNCREATE(CEditView2) 
 
// Attributes 
public: 
 
// Operations 
public: 
	void ShowMessage(CString str); 
 
// Overrides 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CEditView2) 
	protected: 
	virtual void OnDraw(CDC* pDC);      // overridden to draw this view 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	virtual ~CEditView2(); 
#ifdef _DEBUG 
	virtual void AssertValid() const; 
	virtual void Dump(CDumpContext& dc) const; 
#endif 
 
	// Generated message map functions 
protected: 
	//{{AFX_MSG(CEditView2) 
		// NOTE - the ClassWizard will add and remove member functions here. 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
}; 
 
////////////////////////////////////////////////////////////////////////////// 
////////////////////////////////////////////////////////////////////////////// 
 
// BPOParaClass.h: interface for the CBPOParaClass class. 
// 
////////////////////////////////////////////////////////////////////// 
//////////////////////////////全局变量。。。 
 
class CBPOParaClass   
{ 
public: 
		typedef struct 
	{ 
		CString url; 
		LPVOID pThread; 
	}ONEURL_INFO; 
 
		typedef struct Msg 
	{ 
		CString user,pass,email,url,tele,mean,subj,cont; 
	}Msg; 
 
		typedef struct 
	{ 
		CStringArray urllist; 
		LPVOID pThread; 
		Msg m_msg; 
	}MPO_INFO; 
 
		typedef struct 
	{ 
		LPADAPTER ipAdapter; 
		LPVOID pThread; 
	}Sniff_INFO; 
 
	CBPOParaClass(); 
	virtual ~CBPOParaClass(); 
 
}; 
 
 
///////////////////////////////////////////////////////////////////////////////// 
/////////////////////////////////////////////////////////////////////////////////// 
 
/************************************************************************ 
HTTP socket - DTS Project 
************************************************************************/ 
 
/************************************************************************ 
clicksocket.h 
************************************************************************/ 
 
 
#include  
#include  
 
//rem next  line if no debug dump wanted  
#define DEBON 
#include  
 
//default send and recieve timeouts in sec 
#define HTTPRTIMEOUTDEF 6000 
#define HTTPSTIMEOUTDEF 6000 
 
#define MAXHOSTLENGTH   65 
#define MAXIPLENGTH     16 
#define MAXBLOCKSIZE    1024 
#define MAXURLLENGTH    512 
#define MAXPLMMLEN      2048 
#define MAXHEADERLENGTH 2048 
 
#define MEM_PHYSICAL       0x400000 
 
#define ERR_OK           0 
#define ERR_WSAINTERNAL  1 
#define ERR_URLNOTHING   2 
#define ERR_URLTOOLONG   3 
#define ERR_HOSTUNKNOWN  4 
#define ERR_PROXYUNKNOWN 5 
#define ERR_PROTOPARSE   6 
#define ERR_BADHOST      7 
#define ERR_BADPORT      8 
 
 
class CHTTPSocket 
{ 
 static int nInstanceCount; 
 
SOCKET              sckHTTPSocket; 
struct sockaddr_in  sinHTTPSocket; 
struct sockaddr_in  sinHTTPServer; 
// remote server host address, size 64 bytes, 65th set to \0 
	   char         m_szServerHost[MAXHOSTLENGTH]; 
// host 
	   char         m_szHost[MAXHOSTLENGTH]; 
// requested URI/URL 
	   char         m_szURL[MAXURLLENGTH]; 
// remote server IP address, size 15 bytes, 16th set to \0 
	   char         m_szServerHostIP[MAXIPLENGTH]; 
//-- Win32 specific 
WSADATA           wsaData; 
 
void szcopy(char* dest,const char* src,int nMaxBytes); 
void szsent(SOCKET sckDest,const char* szHttp); 
 
public: 
// set to TRUE in InitInstance if TIME_WAIT not need () 
       BOOL  m_bNoTimeWait; 
// recieve timeout change in InitInstance 
       int   m_nRecvTimeout; 
// send timeout change in InitInstance 
       int   m_nSendTimeout; 
// remote server port 
	   int m_nServerPort; 
// use proxy flag 
       BOOL  m_bUseProxy; 
// error code 
	   int m_nErrCode; 
// extended error code; 
	   int m_nExtErrCode; 
// error info 
	   char m_nErrInfo[255]; 
// response content 
	   LPVOID m_szResponse; 
// response size 
	   ULONG m_ulResponseSize; 
public: 
	CString URLEncode(CString sIn); 
	BYTE toHex(const BYTE &x); 
   //const/destr 
   CHTTPSocket(); 
   virtual ~CHTTPSocket(); 
    
   //utils 
   // sets proxy or http server's host 
   void SetServerHost(const char* src); 
   // sets proxy or http server's ip  
   //(should be skipped if SetServerHost used) 
   void SetServerHostIP(const char* src); 
   //starts request transaction 
   void Request(const char* url="http://www.ywetrade.com",const char* plmm=""); 
   //used for free memory allocated for page 
   //(should be skipped if You use CHTTPSocket::OnResponse call in OnResponse) 
   void memPostup(); 
   //fire your OnError with specific error cdes and message 
   void ThrowError(int err, int xerr, const char* errdesc); 
    
   //overridable 
    
   //shoul be used for additional inits 
   virtual BOOL InitInstance(); 
    
   //trigger on any transaction error  
   virtual void OnError(); 
    
   //trigger on response recieved 
   //(its great if U will call CHTTPSocket::OnResponse inside, 
   //to free allocated memory pages) 
   virtual void OnResponse(); 
 
}; 
////////////////////////////////////////////////////////////////////////////////////// 
///////////////////////////////////////////////////////////////////////////////////////// 
// StringFile.h: interface for the CStringFile class. 
//读取文本文件每一行的类。。。速度快。。。 
////////////////////////////////////////////////////////////////////// 
 
 
#define SFBUF_SIZE	2048 
 
class CStringFile   
{ 
public: 
	CStringFile(int nBufSize = SFBUF_SIZE); 
	virtual ~CStringFile(); 
	BOOL Open(LPCSTR szFile, CFileException *feError=NULL); 
	void Close(); 
	void Reset(void); 
	void GetErrorText(CString &szMsg); 
	DWORD GetNextLine(LPSTR szLine,int iLineSize); 
	DWORD GetNextLine(CString &szLine); 
 
protected: 
	int m_nBufferSize; 
	CString m_szError; 
	DWORD	m_nMaxSize; 
	DWORD	m_dwRead; 
	DWORD	m_dwLine; 
	DWORD	m_dwMasterIndex; 
	DWORD	m_dwIndex; 
	int		m_nSectionCount; 
	BYTE	*m_pBuffer; 
	CFile	m_fFile; 
}; 
///////////////////////////////////////////////////////////////////////////////// 
///////////////////////////////////////////////////////////////////////////////// 
// MpoDlg.h : header file 
// 
 
///////////////////////////////////////////////////////////////////////////// 
// CMpoDlg dialog 
 
class CMpoDlg : public CDialog 
{ 
// Construction 
public: 
	CMpoDlg(CWnd* pParent = NULL);   // standard constructor 
 
// Dialog Data 
	//{{AFX_DATA(CMpoDlg) 
	enum { IDD = IDD_MPO }; 
	CString	m_cont; 
	CString	m_email; 
	CString	m_pass; 
	CString	m_subj; 
	CString	m_tele; 
	CString	m_url; 
	CString	m_user; 
	CString	m_mean; 
	//}}AFX_DATA 
 
 
// Overrides 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CMpoDlg) 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
 
	// Generated message map functions 
	//{{AFX_MSG(CMpoDlg) 
	afx_msg void OnMpo(); 
	virtual void OnCancel(); 
	afx_msg void OnEmpty(); 
	afx_msg void OnHMA(); 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
}; 
 
 
 
/////////////////////////////////////////////////////////////////////////////////////// 
/////////////////////////////////////////////////////////////////////////////////////// 
 
// BPONView.h : interface of the CBPONView class 
// 
///////////////////////////////////////////////////////////////////////////// 
 
class CBPONDoc; 
class CBPONView : public CListView  //对返回信息进行处理的视图类。。 
{ 
protected: // create from serialization only 
	CBPONView(); 
	DECLARE_DYNCREATE(CBPONView) 
 
// Attributes 
public: 
	CBPONDoc* GetDocument(); 
 
	typedef struct tagSPS { //定义结构 
		char szUrl[50]; //网站 
		char szState[10]; //状态 
		char szIsOk[10]; //是否成功 
		char szKeep[10]; //保留 
	}SPS; 
 
// Operations 
public: 
 
// Overrides 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CBPONView) 
	public: 
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view 
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 
	protected: 
	virtual void OnInitialUpdate(); // called first time after construct 
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); 
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); 
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); 
	//}}AFX_VIRTUAL 
 
// Implementation 
public: 
	void SetLvItem(); 
	virtual ~CBPONView(); 
#ifdef _DEBUG 
	virtual void AssertValid() const; 
	virtual void Dump(CDumpContext& dc) const; 
#endif 
 
protected: 
 
// Generated message map functions 
protected: 
	//{{AFX_MSG(CBPONView) 
	afx_msg void OnState(); 
	//}}AFX_MSG 
	afx_msg LRESULT OnReturn(WPARAM wParam,LPARAM lParam); 
	DECLARE_MESSAGE_MAP() 
}; 
 
#ifndef _DEBUG  // debug version in BPONView.cpp 
inline CBPONDoc* CBPONView::GetDocument() 
   { return (CBPONDoc*)m_pDocument; } 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
 
///////////////////////////////////////////////////////////////////////////// 
//{{AFX_INSERT_LOCATION}} 
// Microsoft Visual C++ will insert additional declarations immediately before the previous line. 
 
#endif // !defined(AFX_MAINFRM_H__05C61369_8DFA_4A1D_B3ED_CBC31AA5404E__INCLUDED_)