4
回答
msvcr100d.dll处有未处理的异常
终于搞明白,存储TCO原来是这样算的>>>   

@平原君 你好,想跟你请教个问题:

void TCPScan::OnScanStart() 
{
	// TODO: Add your control notification handler code here
	GetDlgItem(IDC_ScanStart)->EnableWindow(FALSE);

	bStop = false;
	bPause = false;
    ThreadParament *param = new ThreadParament;
	memset(param,0,sizeof(ThreadParament));
	DWORD startip,endip;
	this->m_ipfrom.GetAddress(startip);
	this->m_ipto.GetAddress(endip);
	param->dwOriginalIP = startip;
	if(this->m_ifsingleip)
    {
        param->dwLastIP =startip;
	}
	else
    {
	   param->dwLastIP = endip;
	}
	this->UpdateData(true);
	param->dwOriginalPort = this->m_portfrom;
    if(m_ifsingleport)
	{
		param->dwLastPort = this->m_portfrom;
	}
	else
	{
	    param->dwLastPort = this->m_portto;
	}
	this->UpdateData(false);
	param->dwTimeOut = 2;

AfxGetApp()->m_pMainWnd->SendMessage(WM_SCAN_START,WPARAM(param),scantype);           
}

其中,ThreadParament的代码为:

struct ThreadParament
{
	DWORD dwOriginalIP,dwLastIP,dwOriginalPort,dwLastPort,dwTimeOut,dwTimeForOnePort,dwPacketNo;
	pcap_if_t *SelectDev;
	char HostMac[6];
	DWORD dwHostIP,dwNetMAsk,dwDefaultGateway,dwTimeBetweenToPackets;
};

但执行到
   AfxGetApp()->m_pMainWnd->SendMessage(WM_SCAN_START,WPARAM(param),scantype);
报错。单步调试时,运行到afxwin2.inl中这一处时,报上面的错误:
AFXWIN_INLINE LRESULT CWnd::_AFX_FUNCNAME(SendMessage)(UINT message, WPARAM wParam, LPARAM lParam) const
    { ASSERT(::IsWindow(m_hWnd)); return ::SendMessage(m_hWnd, message, wParam, lParam); }
求解决。。。。。。。


举报
查理-charlie
发帖于4年前 4回/2K+阅
共有4个答案 最后回答: 4年前
楼上说的差不多,一般爆出这种错误的,都是一个指针未赋值或者数组越界,结合你的描述来看,应该就是m_pMainWnd没有赋值了。另外,你的问题提的很详细,这样才是好的提问,不然我想回答都未必能回答的了。

引用来自“平原君”的答案

楼上说的差不多,一般爆出这种错误的,都是一个指针未赋值或者数组越界,结合你的描述来看,应该就是m_pMainWnd没有赋值了。另外,你的问题提的很详细,这样才是好的提问,不然我想回答都未必能回答的了。
我在给m_pMainWnd赋值了。这是代码:
// scanport.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "scanport.h"
#include "scanportDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CScanportApp

BEGIN_MESSAGE_MAP(CScanportApp, CWinApp)
	//{{AFX_MSG_MAP(CScanportApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CScanportApp construction

CScanportApp::CScanportApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CScanportApp object

CScanportApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CScanportApp initialization

BOOL CScanportApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	CScanportDlg dlg;
	m_pMainWnd=&dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
这是执行语句:
// TCPScan.cpp : implementation file
//

#include "stdafx.h"
#include "scanport.h"
#include "TCPScan.h"
#include "source.h"

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

/////////////////////////////////////////////////////////////////////////////
// TCPScan dialog


TCPScan::TCPScan(CWnd* pParent /*=NULL*/)
	: CDialog(TCPScan::IDD, pParent)
{
	//{{AFX_DATA_INIT(TCPScan)
	m_ifsingleip = FALSE;
	m_ifsingleport = FALSE;
	m_portfrom = 0;
	m_portto = 0;
	m_Select = 0;
	scantype = CONNECT_SCAN;
	//}}AFX_DATA_INIT
}


void TCPScan::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(TCPScan)
	DDX_Control(pDX, IDC_ScanStart, m_btn_start);
	DDX_Control(pDX, IDC_Portto, m_portTo);
	DDX_Control(pDX, IDC_IPADDRESSTO, m_ipto);
	DDX_Control(pDX, IDC_IPADDRESSFROM, m_ipfrom);
	DDX_Check(pDX, IDC_IfsingleIp, m_ifsingleip);
	DDX_Check(pDX, IDC_IfsinglePort, m_ifsingleport);
	DDX_Text(pDX, IDC_Portfrom, m_portfrom);
	DDX_Text(pDX, IDC_Portto, m_portto);
	DDX_Radio(pDX, IDC_RADIO1, m_Select);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(TCPScan, CDialog)
	//{{AFX_MSG_MAP(TCPScan)
	ON_BN_CLICKED(IDC_ScanStart, OnScanStart)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO3, OnFIN)
	ON_BN_CLICKED(IDC_RADIO2, OnSYN)
	ON_BN_CLICKED(IDC_RADIO4, OnACK)
	ON_BN_CLICKED(IDC_IfsingleIp, OnIfsingleIp)
	ON_BN_CLICKED(IDC_IfsinglePort, OnIfsinglePort)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// TCPScan message handlers

BOOL TCPScan::OnInitDialog()
{
	CDialog::OnInitDialog();
	pTcpWindow = this;

	// 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);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void TCPScan::OnScanStart() 
{
	
	// TODO: Add your control notification handler code here
	GetDlgItem(IDC_ScanStart)->EnableWindow(FALSE);

	bStop = false;
	bPause = false;
    ThreadParament *param = new ThreadParament;
	memset(param,0,sizeof(ThreadParament));
	DWORD startip,endip;
	this->m_ipfrom.GetAddress(startip);
	this->m_ipto.GetAddress(endip);
	param->dwOriginalIP = startip;
	if(this->m_ifsingleip)
    {
        param->dwLastIP =startip;
	}
	else
    {
	   param->dwLastIP = endip;
	}
	this->UpdateData(true);
	param->dwOriginalPort = this->m_portfrom;
    if(m_ifsingleport)
	{
		param->dwLastPort = this->m_portfrom;
	}
	else
	{
	    param->dwLastPort = this->m_portto;
	}
	this->UpdateData(false);
	param->dwTimeOut = 2;
	AfxGetApp()->m_pMainWnd->SendMessage(WM_SCAN_START,WPARAM(param),scantype);
}

void TCPScan::OnRadio1() 
{
	// TODO: Add your control notification handler code here
	scantype = CONNECT_SCAN;
    
}

void TCPScan::OnFIN() 
{
	// TODO: Add your control notification handler code here
	scantype = FIN_SCAN;
}

void TCPScan::OnSYN() 
{
	// TODO: Add your control notification handler code here
	scantype = SYN_SCAN;
}

void TCPScan::OnACK() 
{
	// TODO: Add your control notification handler code here
	scantype = ACK_SCAN;
}

void TCPScan::OnIfsingleIp() 
{
	// TODO: Add your control notification handler code here

	if(this->m_ifsingleip==FALSE)
	{
		this->m_ipto.EnableWindow(FALSE);
		this->m_ifsingleip=TRUE;
	}
	else
	{
		this->m_ipto.EnableWindow(TRUE);
		this->m_ifsingleip=FALSE;
	}
	
}

void TCPScan::OnIfsinglePort() 
{
	// TODO: Add your control notification handler code here
    if(this->m_ifsingleport==FALSE)
	{
		this->m_portTo.EnableWindow(FALSE);
		this->m_ifsingleport=TRUE;
	}
	else
	{
		this->m_portTo.EnableWindow(TRUE);
		this->m_ifsingleport=FALSE;
	}
	
}
最后来得是整个的文件框架:

求帮忙!这是我从网上找的一个程序,我想将它修改弄成毕业设计。结果现在,根本弄不了。。。
顶部