我尝试写入 NdisProt 驱动程序并发送原始以太网数据包。我将一些 C++ 命令导入到我的 C# 程序中,以便我可以访问驱动程序。当我尝试打开驱动程序的句柄时,我总是得到一个无效的句柄。我已经尝试使用“NdisProt”作为路径,但它没有解决它。你有什么建议为什么我得到一个无效的句柄?
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;
}
如果您现在有任何其他解决方案可以在 C# 程序中发送原始以太网数据包,请告诉我。
谢谢你的帮助!