// Fetches the MAC address and prints it void GetNetConfig::print(void) { IP_ADAPTER_INFO AdapterInfo[16]; // Allocate information for up to 16 NICs DWORD dwBufLen = sizeof(AdapterInfo); // Save the memory size of buffer DWORD dwStatus = GetAdaptersInfo( // Call GetAdapterInfo AdapterInfo, // [out] buffer to receive data &dwBufLen); // [in] size of receive data buffer assert(dwStatus == ERROR_SUCCESS); // Verify return value is valid, no buffer overflow PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;// Contains pointer to current adapter info do { GetInterfaceName(pAdapterInfo->AdapterName); GetMACaddress(pAdapterInfo->Address); if (((m_nMatches & pt_ifname) != pt_ifname || ((m_nMatches & pt_ifname) == pt_ifname && strcmp(m_szCheck_IntefaceName, m_szIntefaceName) == 0)) && ((m_nMatches & pt_mac) != pt_mac || ((m_nMatches & pt_mac) == pt_mac && strcmp(m_szCheck_MAC_Address, m_szMAC_Address) == 0 )) && ((m_nMatches & pt_ipv4) != pt_ipv4 || ((m_nMatches & pt_ipv4) == pt_ipv4 && strcmp(m_szCheck_IP_Address, pAdapterInfo->IpAddressList.IpAddress.String) == 0 )) && ((m_nMatches & pt_mask) != pt_mask || ((m_nMatches & pt_mask) == pt_mask && strcmp(m_szCheck_MASK_Address, pAdapterInfo->IpAddressList.IpMask.String) == 0 )) && ((m_nMatches & pt_gateway) != pt_gateway || ((m_nMatches & pt_gateway) == pt_gateway && strcmp(m_szCheck_Gateway_Address, pAdapterInfo->GatewayList.IpAddress.String) == 0 )) && ((m_nMatches & pt_dns) != pt_dns || ((m_nMatches & pt_dns) == pt_dns && FindDNSAddress(pAdapterInfo) == TRUE )) ) { PrintInterfaceName(); PrintAdapterInfo(pAdapterInfo); } pAdapterInfo = pAdapterInfo->Next; // Progress through linked list } while(pAdapterInfo); // Terminate if last adapter }
int pcap_io_init(char *adapter) { printf("WINPCAP: Opening adapter '%s'...",adapter); GetMACaddress(adapter,&host_mac); /* Open the adapter */ if ((adhandle= pcap_open_live(adapter, // name of the device 65536, // portion of the packet to capture. // 65536 grants that the whole packet will be captured on all the MACs. 1, // promiscuous mode (nonzero means promiscuous) 1, // read timeout errbuf // error buffer )) == NULL) { printf("\nWINPCAP: Unable to open the adapter. %s is not supported by WinPcap\n", adapter); return -1; } /* if(pcap_setnonblock(adhandle,1,errbuf)==-1) { printf("WINPCAP: Error setting non-blocking mode. Default mode will be used.\n"); } */ packet_log=fopen("logs/packet.log","w"); dump_pcap = pcap_dump_open(adhandle,"logs/pkt_log.pcap"); CreateThread(0,0,rx_thread,0,0,0); pcap_io_running=1; printf("WINPCAP: Ok.\n"); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { LPNETRESOURCE lpnr = NULL; GetMACaddress(); printf("\n"); if (EnumerateFunc(lpnr) == FALSE) { printf("Call to EnumerateFunc failed\n"); } getchar(); return 0; }
Application::Application(void): main_frame(), ec(), ecm(), fc(), evc(), evcm(), fcm(), navigator_manager(), graphic_factory(), layer_tree(), plugin_map(), three_dimension_camera_controller(NULL), two_dimension_camera_controller(NULL), dc(NULL), plugin_running(false), srs() { //for being able to load all type of images wxInitAllImageHandlers(); #ifdef WIN32 //This is to activate memory-leaks detection _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif wmsInitialize(); application_time = ApplicationTime::GetInstance(); application_time->Off(); cpw::IdGenerator::SetNamespace(GetMACaddress()); #ifdef WIN32 SetThreadAffinityMask(GetCurrentThread(), 0); #endif }
virtual BOOL InitInstance() { try{ SetRegistryKey(G_softwarename()); //boost process priority SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS); AfxInitRichEdit(); // AfxEnableControlContainer(); // AfxOleInit(); {//create documents folder QString dir; GetDocumentsDir(dir);dir+=_qstr("\\");dir+=G_softwarename(); CreateDirectory(dir,NULL); } CWinApp::InitInstance(); //for 3D Connexion if (!AfxOleInit()) { AfxMessageBox(L"OLE Init failed"); return FALSE; } AfxEnableControlContainer(); StrChar locstartupdir[600]; GetCurrentDirectory(599,locstartupdir); startupdir=locstartupdir; datadir=startupdir+_qstr("/Data"); { QString storeddatadir; QParamRead(PARAMLOCATION_REGISTRY,_qstr("DataDirectory"),storeddatadir); if (qstrlen(storeddatadir)>0) datadir=storeddatadir; } initlog(); addlog(TFormatString(_text("Data directory: ^1"),datadir)); scriptsdir=datadir;scriptsdir+=_qstr("\\Scripts"); texturesdir=datadir;texturesdir+=_qstr("\\textures"); addlog(_text("Fetching MAC address")); GetMACaddress(MACaddr); addlog(MACaddr); G_3DCosmos().LoadSettings(); G_3DCosmos().init(); loadstockcyclorbits(); G_QXSys().startup(); addlog(_text("Loading languages"),+1); QTranslate::Get().loadlanguages(); addlog(_text("Loaded languages"),-1); addlog(_text("Creating source code window"),+1); mainwin= new Tmainwin(); mainwin->createwindow(NULL,QString("Source code window")); addlog(_text("Source code window created"),-1); addlog(_text("")); addlog(_text("")); mainwin->ShowWindow(m_nCmdShow); m_pMainWnd=mainwin; } catch(QError &err) { reporterror(err.G_content()); } return TRUE; }