I try to write to a NdisProt driver and send raw ethernet packets. I imported some C++ comands to my C# program, so that I can access the driver. When I try to open a handle to the driver I always get a invalid handle. I already tried it with just "NdisProt" as the path, but it didn't solve it. Do you have any suggestions why i get a invalid handle?
private bool OpenDriver()
{
// User the CreateFile API to open a handle to the file
this.m_iHandle = CreateFile("\\\\.\\NdisProt,
GENERIC_WRITE | GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
// Check to see if we got a valid handle
if ((int)m_iHandle <= 0)
{
// If not, then return false and reset the handle to 0
this.m_iHandle = IntPtr.Zero;
return false;
}
If you now any other solutions to send raw ethernet packets in a C# program please let me know.
Thanks for any help!
Update: I just solved the problem by adding another manifest, so that the application is run as admin.
The solution with the NDIS Driver did still not work so I searched for another solution. I found the SharpPcap library. With that library I am able to modify the packets I want to send e.g. change the Destination-MAC-Adress.
Thanks for your answers!