Access data passing through the networkcard using C++
Is there a way to control the data coming from the internet from specific address through the network card before it received by the kernel of the operating system using C++ or any language?
In another word, Is there a way to access OSI Seven Layer Model using C++ to control the data passing through any layer of the seven layer or they are just logically implemented.
In case they are not logically implemented and you can access I want to access the packages passing the physical layer that received from specific address and do some operation before they move to the next layer.
also is there any simulation software for OSI开发者_JAVA技巧?.
Device driver is what sits between between hardware and kernel so this is your only choice. It depends of the OS but one can write a device driver in C++ for all the major ones. Be ready to encounter plain C interface though.
Are you asking if an untrusted application can control what the operating system sees coming from the network?
The answer should be obvious.
Most operating systems provide interfaces to access the raw data coming off the network, and you should use those, rather than trying to wedge yourself between the network card and the operating system.
Also, C++ != C#. Not even close.
You could conceivably create a layered service provider that can intercept data by inserting itself onto the winsock stack, but this won't short-circuit the data going through the kernel and the NDIS layer in windows. Your only real solution here would be a device driver. Also, there are some network cards that implement their own TCP/IP stack in hardware and you can communicate with those directly however these are not very common. Any of these approaches is not trivial and you're looking at a lot of kernel-mode C. If you're not comfortable with that, you shouldn't be trying this.
You could also consider using winpcap as this would give you a lot of the functionality that you need. http://www.winpcap.org/devel.htm
精彩评论