pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
int i = 0;
char errbuf[PCAP_ERRBUF_SIZE];
/* 取得列表 */
if (pcap_findalldevs(&alldevs, errbuf) == - 1)
{
MessageBox("获得网络适配器列表失败,请确认您正确安装了WINPCAP!", "网络黑手", MB_ICONEXCLAMATION);
GetDlgItem(IDC_STARTSTOP_BUTTON)->EnableWindow(FALSE);
}
/* 输出列表 */
for (d = alldevs; d; d = d->next)
{
CString str(d->name);
if (str.Find("\\Device\\NPF_Generic", 0) == - 1)
m_adapterList.AddString(str);
}
m_hostList.Create(CRect(12, 114, 435, 322), this, 1000);
m_hostList.SetCols(4);
m_hostList.SetRows(16);
for (i = 0; i < 16; i++)
{
m_hostList.SetRowHeight(i, 13);
for (int j = 0; j < 5; j++)
{
m_hostList.SetAlignment(i, j, DT_CENTER);
}
}
m_hostList.SetColWidth(0, 120);
m_hostList.SetColWidth(1, 140);
m_hostList.SetColWidth(2, 100);
m_hostList.SetColWidth(3, 62);
m_hostList.SetColWidth(4, 62);
m_hostList.SetText(0, 0, "IP地址");
m_hostList.SetText(0, 1, "MAC地址");
m_hostList.SetText(0, 2, "是否网络黑手");
m_hostList.SetText(0, 3, "黑手状态");
return TRUE; // return TRUE unless you set the focus to a control
}
void GetData(LPPACKET lp)
{
ULONG ulbytesreceived, off;
ETHDR *eth;
ARPHDR *arp;
char *buf, *pChar, *base;
struct bpf_hdr *hdr;
ulbytesreceived = lp->ulBytesReceived;
buf = (char*)lp->Buffer;