gpt4 book ai didi

c++ - 如何使用 NDIS_SUPPORT_NDIS630 将 NDIS 6.2 移植到 NDIS 6.3?

转载 作者:行者123 更新时间:2023-11-28 02:14:52 27 4
gpt4 key购买 nike

我有 NDIS 6.2 支持微型端口驱动程序。现在我想将 NDIS 6.2 移植到 NDIS 6.3 。

https://msdn.microsoft.com/en-us/library/windows/hardware/dn232191(v=vs.85).aspx

使用此链接,我更改了 NDIS 6.30 中增强功能的一些一般要求和电源管理。

我将所有更改都放在同一个 NDIS 6.2 文件中。

变化是 (miniport.cpp)

ndisMiniportDriverCharacteristics.MajorNdisVersion                = 6;
ndisMiniportDriverCharacteristics.MinorNdisVersion = 30;

ndisMiniportDriverCharacteristics.MajorDriverVersion = VERSION_MAJOR_NUM;
ndisMiniportDriverCharacteristics.MinorDriverVersion = VERSION_MINOR_NUM;

ndisMiniportDriverCharacteristics.SetOptionsHandler = CMiniport::SetOptions;
ndisMiniportDriverCharacteristics.InitializeHandlerEx = CMiniport::InitializeEx;

…………等

然后在 InitializeEx() 函数中,NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES 的更改是:

NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES ndisMiniportAdapterRegistrationAttributes;
NdisZeroMemory(&ndisMiniportAdapterRegistrationAttributes, sizeof(NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES));

#if (NDIS_SUPPORT_NDIS630)

C_ASSERT(sizeof(NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES) >= NDIS_SIZEOF_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_2);
ndisMiniportAdapterRegistrationAttributes.Header.Type = NDIS_OBJECT_TYPE_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES;
ndisMiniportAdapterRegistrationAttributes.Header.Size = NDIS_SIZEOF_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_2;
ndisMiniportAdapterRegistrationAttributes.Header.Revision = NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_2;

#else

C_ASSERT(sizeof(NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES) >= NDIS_SIZEOF_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_1);
ndisMiniportAdapterRegistrationAttributes.Header.Type = NDIS_OBJECT_TYPE_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES;
ndisMiniportAdapterRegistrationAttributes.Header.Size = NDIS_SIZEOF_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_1;
ndisMiniportAdapterRegistrationAttributes.Header.Revision = NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_1;

#endif // NDIS MINIPORT VERSION

ndisMiniportAdapterRegistrationAttributes.MiniportAdapterContext = CMiniport::m_pMiniport;


#if (NDIS_SUPPORT_NDIS630)

ndisMiniportAdapterRegistrationAttributes.AttributeFlags |= NDIS_MINIPORT_ATTRIBUTES_NO_PAUSE_ON_SUSPEND;

#else

ndisMiniportAdapterRegistrationAttributes.AttributeFlags = NDIS_MINIPORT_ATTRIBUTES_SURPRISE_REMOVE_OK | NDIS_MINIPORT_ATTRIBUTES_NDIS_WDM;

#endif

ndisMiniportAdapterRegistrationAttributes.CheckForHangTimeInSeconds = 5;

对于更改 NDIS_PM_CAPABILITIES 我这样写:

 NDIS_PM_CAPABILITIES ndisPmCapabilities;
NdisZeroMemory(&ndisPmCapabilities, sizeof(NDIS_PM_CAPABILITIES));


#if (NDIS_SUPPORT_NDIS630)

C_ASSERT(sizeof(NDIS_PM_CAPABILITIES) >= NDIS_SIZEOF_NDIS_PM_CAPABILITIES_REVISION_2);
ndisPmCapabilities.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
ndisPmCapabilities.Header.Size = NDIS_SIZEOF_NDIS_PM_CAPABILITIES_REVISION_2;
ndisPmCapabilities.Header.Revision = NDIS_PM_CAPABILITIES_REVISION_2;

ndisPmCapabilities.MinMagicPacketWakeUp = NdisDeviceStateUnspecified;
ndisPmCapabilities.MinPatternWakeUp = NdisDeviceStateUnspecified;
ndisPmCapabilities.MinLinkChangeWakeUp = NdisDeviceStateUnspecified;

#else

C_ASSERT(sizeof(NDIS_PM_CAPABILITIES) >= NDIS_SIZEOF_NDIS_PM_CAPABILITIES_REVISION_1);
ndisPmCapabilities.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
ndisPmCapabilities.Header.Size = NDIS_SIZEOF_NDIS_PM_CAPABILITIES_REVISION_1;
ndisPmCapabilities.Header.Revision = NDIS_PM_CAPABILITIES_REVISION_1;

ndisPmCapabilities.MinMagicPacketWakeUp = NdisDeviceStateUnspecified;
ndisPmCapabilities.MinPatternWakeUp = NdisDeviceStateUnspecified;
ndisPmCapabilities.MinLinkChangeWakeUp = NdisDeviceStateUnspecified;

#endif // NDIS MINIPORT VERSION

所以我的疑问是:

  1. 我可以将此 NDIS 6.30 用于 Windows 7 NDIS 6.2 吗?
  2. 如何激活 NDIS_SUPPORT_NDIS630 宏?

在 ndis.h WDK 文件中,宏是这样的:

#if !defined(NDIS_SUPPORT_NDIS630)
#if (((defined (NDIS_MINIPORT_MAJOR_VERSION) && (NDIS_MINIPORT_MAJOR_VERSION >= 6)) && \
(defined (NDIS_MINIPORT_MINOR_VERSION) && (NDIS_MINIPORT_MINOR_VERSION >= 30))) || \
(defined (NDIS630)) || NDIS_WRAPPER)
#define NDIS_SUPPORT_NDIS630 1
#else
#define NDIS_SUPPORT_NDIS630 0
#endif
#endif // !defined(NDIS_SUPPORT_NDIS630)

但是当我直接使用 ndisPmCapabilities.Header.Revision = NDIS_PM_CAPABILITIES_REVISION_2; 时,我得到了如下错误 NDIS_PM_CAPABILITIES_REVISION_2 未定义

如何使用这个 NDIS_SUPPORT_NDIS630 宏?

最佳答案

您可以通过在项目中定义适当的 NDIS6XX_MINIPORT 来激活相关的 NDIS 版本。您可以在 ndis.h header 开头的注释中查看更多详细信息。

您可以使用您想要的任何 NDIS 版本编译您的驱动程序,但它们不向后兼容 - 每个 Windows 版本都提供不同的 NDIS 版本,自然是旧版本OS 版本无法与较新的 NDIS 版本一起使用。

关于c++ - 如何使用 NDIS_SUPPORT_NDIS630 将 NDIS 6.2 移植到 NDIS 6.3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34331918/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com