阅读:2436回复:3
弄了个ndis 驱动, 在64位windows 下不工作, 请大神帮忙
搬来ddk的例子, 写了个ndis驱动, 在32位系统下, 工作正常
但是移植到 windows 2003 x64 下面的时候, 系统不调用协议回调函数, 不知道怎么回事, 请大神指导迷津 driverentry里面所有注册函数都成功, 就是不调用回调 我的ndis 是5.0的, windows 2003 x64, 支持5.0吗? 我安装驱动是用安装服务的方式安装的 驱动注册表 图片:未命名.JPG |
|
最新喜欢:y396co... |
沙发#
发布于:2015-08-26 07:52
部分代码
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) { NDIS_STRING Name; NDIS_STATUS status = STATUS_SUCCESS; NDIS_PROTOCOL_CHARACTERISTICS PChars; NDIS_MINIPORT_CHARACTERISTICS MChars; KdPrint(("SCP_NDIS: DriverEntry\n")); .... NdisAllocateSpinLock(&g_GlobalLock); NdisMInitializeWrapper(&g_NdisWrapperHandle, DriverObject, RegistryPath, NULL); do { status = RegistryMiniport(); if (!NT_SUCCESS(status)) { SCP_PRINT("SCPNDIS: Failed to register miniport with NDIS; status: %08X\n", status); break; } status = RegistryProtocol(); if (!NT_SUCCESS(status)) { SCP_PRINT("SCPNDIS: Failed to register protocol with NDIS; status: %08X\n", status); break; } NdisIMAssociateMiniport(g_DriverHandle, g_ProtHandle); Ndis_RegisterDevice(); } while (FALSE); ... if (status != NDIS_STATUS_SUCCESS) { NdisTerminateWrapper(g_NdisWrapperHandle, NULL); } return status; } NDIS_STATUS RegistryMiniport() { NDIS_STATUS Status = NDIS_STATUS_SUCCESS; NDIS_MINIPORT_CHARACTERISTICS MChars; // Register the miniport with NDIS. Note that it is the miniport which was started as a driver and not the protocol. Also the miniport // must be registered prior to the protocol since the protocol's BindAdapter handler can be initiated anytime and when it is, // it must be ready to start driver instances. NdisZeroMemory(&MChars, sizeof(NDIS_MINIPORT_CHARACTERISTICS)); MChars.MajorNdisVersion = 5; MChars.MinorNdisVersion = 1; MChars.InitializeHandler = MPInitialize; MChars.QueryInformationHandler = MPQueryInformation; MChars.SetInformationHandler = MPSetInformation; MChars.ResetHandler = NULL; MChars.TransferDataHandler = MPTransferData; MChars.HaltHandler = MPHalt; MChars.CancelSendPacketsHandler = MPCancelSendPackets; MChars.PnPEventNotifyHandler = MPDevicePnPEvent; MChars.AdapterShutdownHandler = MPAdapterShutdown; // We will disable the check for hang timeout so we do not need a check for hang handler! MChars.CheckForHangHandler = NULL; MChars.ReturnPacketHandler = MPReturnPacket; // Either the Send or the SendPackets handler should be specified. If SendPackets handler is specified, SendHandler is ignored MChars.SendHandler = NULL; // MPSend; MChars.SendPacketsHandler = MPSendPackets; Status = NdisIMRegisterLayeredMiniport(g_NdisWrapperHandle, &MChars, sizeof(MChars), &g_DriverHandle); return Status; } NDIS_STATUS RegistryProtocol() { NDIS_STATUS Status = NDIS_STATUS_SUCCESS; NDIS_PROTOCOL_CHARACTERISTICS PChars; NDIS_STRING Name = SCP_NDIS_BIND_NAME; NdisZeroMemory(&PChars, sizeof(NDIS_PROTOCOL_CHARACTERISTICS)); PChars.MajorNdisVersion = 5; PChars.MinorNdisVersion = 1; // Make sure the protocol-name matches the service-name (from the INF) under which this protocol is installed. // This is needed to ensure that NDIS can correctly determine the binding and call us to bind to miniports below. PChars.Name = Name; PChars.OpenAdapterCompleteHandler = PtOpenAdapterComplete; PChars.CloseAdapterCompleteHandler = PtCloseAdapterComplete; PChars.SendCompleteHandler = PtSendComplete; PChars.TransferDataCompleteHandler = PtTransferDataComplete; PChars.ResetCompleteHandler = PtResetComplete; PChars.RequestCompleteHandler = PtRequestComplete; PChars.ReceiveHandler = PtReceive; PChars.ReceiveCompleteHandler = PtReceiveComplete; PChars.StatusHandler = PtStatus; PChars.StatusCompleteHandler = PtStatusComplete; PChars.BindAdapterHandler = PtBindAdapter; PChars.UnbindAdapterHandler = PtUnbindAdapter; PChars.UnloadHandler = PtUnloadProtocol; PChars.ReceivePacketHandler = PtReceivePacket; PChars.PnPEventHandler = PtPNPHandler; NdisRegisterProtocol(&Status, &g_ProtHandle, &PChars, sizeof(NDIS_PROTOCOL_CHARACTERISTICS)); return Status; } NDIS_STATUS Ndis_RegisterDevice() { NDIS_STATUS Status = NDIS_STATUS_SUCCESS; UNICODE_STRING DeviceName; UNICODE_STRING DeviceLinkUnicodeString; PDRIVER_DISPATCH DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1]; SCP_DEBUG(__FUNCTION__); NdisAcquireSpinLock(&g_GlobalLock); ++MiniportCount; if (1 == MiniportCount) { ASSERT(ControlDeviceState != PS_DEVICE_STATE_CREATING); // Another thread could be running PtDeregisterDevice on behalf of another miniport instance. If so, wait for it to exit. while (ControlDeviceState != PS_DEVICE_STATE_READY) { NdisReleaseSpinLock(&g_GlobalLock); NdisMSleep(1); NdisAcquireSpinLock(&g_GlobalLock); } ControlDeviceState = PS_DEVICE_STATE_CREATING; NdisReleaseSpinLock(&g_GlobalLock); NdisZeroMemory(DispatchTable, (IRP_MJ_MAXIMUM_FUNCTION+1) * sizeof(PDRIVER_DISPATCH)); DispatchTable[IRP_MJ_CREATE] = Ndis_DefaultDispatch; DispatchTable[IRP_MJ_CLEANUP] = Ndis_DefaultDispatch; DispatchTable[IRP_MJ_CLOSE] = Ndis_DefaultDispatch; DispatchTable[IRP_MJ_SHUTDOWN] = Ndis_DefaultDispatch; DispatchTable[IRP_MJ_DEVICE_CONTROL] = Ndis_IoCtlDispatch; NdisInitUnicodeString(&DeviceName, SCPNDIS_DEVICE_NAME_W); NdisInitUnicodeString(&DeviceLinkUnicodeString, SCPNDIS_DOS_DEVICE_NAME_W); // Create a device object and register our dispatch handlers Status = NdisMRegisterDevice(g_NdisWrapperHandle, &DeviceName, &DeviceLinkUnicodeString, &DispatchTable[0], &ControlDeviceObject, &NdisDeviceHandle); NdisAcquireSpinLock(&g_GlobalLock); ControlDeviceState = PS_DEVICE_STATE_READY; } NdisReleaseSpinLock(&g_GlobalLock); return Status; } |
|
板凳#
发布于:2015-08-26 07:54
不知道ndis 这种驱动, 在x64 下面有没有什么特殊限制之类的
第一次接触ndis 这种驱动,什么都不懂 现在进入一筹莫展的状态, 请大神指点一下迷津 非常感谢 |
|
地板#
发布于:2015-09-10 18:44
windows 是啥版本的?
|
|
|