
| typedef struct tagHostList { unsigned long ip; char mac[6]; bool sniffer; bool arpCheat; bool ipConflict; } HostList; |
| typedef struct tagPacketList { unsigned long srcIp; unsigned long desIp; unsigned char protocol; unsigned long srcPort; unsigned long desPort; unsigned long len; char data[256]; }PacketList; |
| BOOL CNetHackerDlg::OnInitDialog() { CDialog::OnInitDialog(); // 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); } } // 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; //… m_hostList.Create(CRect(12,115,435,466),this, 1000,WS_BORDER |WS_VISIBLE |WS_VSCROLL|WS_CHILD); m_hostList.SetScrollRange(1,0,351); m_hostList.EnableScrollBar(ESB_ENABLE_BOTH); m_hostList.SetCols (5); m_hostList.SetRows (256); for (i = 0; i < 256; i ++) { m_hostList.SetRowHeight (i, 13); for(int j =0;j<5;j++) { m_hostList.SetAlignment(i,j,DT_CENTER); } } m_hostList.SetColWidth (0, 100); m_hostList.SetColWidth (1, 130); m_hostList.SetColWidth (2, 50); m_hostList.SetColWidth (3, 55); m_hostList.SetColWidth (4, 70); m_hostList.SetText (0,0,"IP地址"); m_hostList.SetText (0,1,"MAC地址"); m_hostList.SetText (0,2,"Sniffer"); m_hostList.SetText (0,3,"ARP欺骗"); m_hostList.SetText (0,4,"报告IP冲突"); m_packetList.Create(CRect(444,26,768,466),this, 1000); m_packetList.SetCols (6); m_packetList.SetRows (31); for (i = 0; i < 30; i ++) { m_packetList.SetRowHeight (i, 13); for(int j =0;j<6;j++) { m_packetList.SetAlignment(i,j,DT_CENTER); } } m_packetList.SetRowHeight (i, 47); m_packetList.SetColWidth (0, 75); m_packetList.SetColWidth (1, 75); m_packetList.SetColWidth (2, 32); m_packetList.SetColWidth (3, 45); m_packetList.SetColWidth (4, 55); m_packetList.SetColWidth (5, 40); m_packetList.SetText (0,0,"源IP"); m_packetList.SetText (0,1,"目的IP"); m_packetList.SetText (0,2,"协议"); m_packetList.SetText (0,3,"源端口"); m_packetList.SetText (0,4,"目的端口"); m_packetList.SetText (0,5,"长度"); m_packetList.JoinCells (30,0,30,5); mailDlg = this; return TRUE; // return TRUE unless you set the focus to a control } |
| int XTable::JoinCells (int startRow, int startCol, int endRow, int endCol) { if (startRow < 0 || startRow >= rows) return -1; if (endRow < 0 || startRow >= rows) return -1; if (startCol < 0 || startCol >= cols) return -1; if (endCol < 0 || endCol >= cols) return -1; if (startRow > endRow || startCol > endCol) return -1; for (int i = startRow; i <= endRow; i++) { for (int j = startCol; j <=endCol; j++) { cells [i * cols + j].SetSpan(0,0); } } cells [startRow * cols + startCol].SetSpan(endRow - startRow+1, endCol - startCol+1); return 0; } |
| int XTable::UnjoinCells (int row, int col) { if (row < 0 || row >= this->rows) return -1; if (col < 0 || col >= this->cols) return -1; if (cells [row * cols + col].rowSpan <= 1 && cells [row * cols + col].colSpan <= 1 ) return -1; for (int i = row; i <= row + cells [row * cols + col].rowSpan; i++) { for (int j = col; j <= cells [row * cols + col].colSpan; j++) { cells[i*cols+j] = defaultCell; cells [i * cols + j].SetSpan(1,1); } } return 0; } |
| char errbuf[PCAP_ERRBUF_SIZE]; /* 取得列表 */ if (pcap_findalldevs(&alldevs, errbuf) == - 1) { AfxMessageBox("获得网卡列表失败!\n"); 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); } |