Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Winpcap technology

2025-02-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

We need the WpdPack_4_1_2.zip file, extract to disk c, so that we can find the file later, it contains the lib library and the header file, open the software Microsoft Visual Studio 2010, and create a new project.

The code that the page will run will be copied into it, as follows

/ / 111.cpp: defines the entry point for the console application.

/ /

# include "stdafx.h"

# include "pcap.h"

Int _ tmain (int argc, _ TCHAR* argv [])

{

Pcap_if_t * alldevs

Pcap_if_t * d

Int iTunes 0

Char errbuf[PCAP _ ERRBUF_SIZE]

/ * get the list of local machines and equipment * /

If (pcap_findalldevs_ex (PCAP_SRC_IF_STRING, NULL / * auth is not needed * /, & alldevs, errbuf) =-1)

{

Fprintf (stderr, "Error in pcap_findalldevs_ex:% s\ n", errbuf)

Exit (1)

}

/ * print list * /

For (d = alldevs; d! = NULL; d = d-> next)

{

Printf ("d. S", + + I, d-> name)

If (d-> description)

Printf ("(% s)\ n", d-> description)

Else

Printf ("(No description available)\ n")

}

If (I = = 0)

{

Printf ("\ nNo interfaces found! Make sure WinPcap is installed.\ n")

Return 0

}

}

1) if it does not work, find the following ways to change the properties:

Project-- > * * attribute (alt+F7)

Configure properties-- > inventory tool-- > input and output-- > embed list-- > No

Project-- > * * attribute (alt+F7)

Configuration Properties-- > Cramp Cure colors-- > General-- > additional inclusion directories-- > (include)

Project-- > * * attribute (alt+F7)

Configure Properties-- > Linker-- > General-- > additional Library Directory-- > (Library File path)

Project-- > * * attribute (alt+F7)

Configure properties-- > linker-- > input-- > attach dependencies-- > supplement "; Packet.lib;wpcap.lib"

Project-- > * * attribute (alt+F7)

Configuration properties-- > Candlestick colors-- > preprocessor-- > preprocessor definition-- > supplement "; HAVE_REMOTE"

If the operation is successful, the result will flash by. You can press ctrl+f5 to view the result at the same time.

-LINK:fatal error LNK1123: failed during conversion to COFF: invalid or corrupted file--

Step 1: change project-project properties-configuration properties-connectors-manifest files-embedded manifest "yes" to "no". If you can't solve the problem, move on to the second step.

Step 2: check to see if your computer is an 64bit operating system. If so, continue as follows.

Find out if there are two cvtres.exe.

C:\ Program Files (x86)\ Microsoft Visual Studio 10.0\ vc\ bin\ cvtres.exe (delete)

C:\ Windows\ Microsoft.NET\ Framework\ v4.0.30319\ cvtres.exe

Right-click properties-for more information, check both version numbers, delete / rename older versions, or reset the Path variable.

The way to get to the root of the problem is the second step. After deleting the old version of cvtres.exe, you don't need to set the configuration every time.

For example: del C:\ "Program Files (x86)"\ "Microsoft Visual Studio 10.0"\ VC\ bin\ cvtres.exe

2) if it appears

"unparsable external symbol _ _ imp__ntohs@4, which is in the function" case, be careful to add it to the header file

# pragma comment (lib, "Ws2_32.lib") or

Project-- > * * attribute (alt+F7)

Configure properties-- > linker-- > input-- > attach dependencies-- > supplement "; Packet.lib;wpcap.lib;Ws2_32.lib;"

3) if "" rror C2664: "pcap_dump_open" appears: parameter 2 cannot be converted from "_ TCHAR *" to "const char *"

To run the project properties-- configure properties-- General-- character set: "use Unicode character set" instead of "use multi-byte character set"

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report