我有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文件中。
chnages是(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;
和我写的这样的chnage 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
所以我怀疑是:
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 is not defined
。
如何使用此NDIS_SUPPORT_NDIS630
宏?
答案 0 :(得分:1)
您可以通过在项目中定义相应的NDIS
来激活相关的NDIS6XX_MINIPORT
版本。您可以在ndis.h
标题开头的注释中查看更多详细信息。
您可以使用您想要的任何NDIS
版本编译驱动程序,但它们不向后兼容 - 每个Windows版本都提供了不同的NDIS
版本,自然版本较旧OS
版本无法使用较新的NDIS
版本。