阅读:1754回复:3
修改注册表加载NDIS IMD在PPC2002中!
如题,工具是PPC2002 SDK + EVC3.0
一个英国人给了我一个,他说他的能运行,他的工具也是PPC2002 SDK + EVC3.0。可是我的就没有看到调用DriverEntry()! 这是为什么呢?在Adapter List中我可以看到我的IMD虚拟出的网卡,可是就是不被加载。 我想问的是: 我在DriverEntry()中这样处理是否可以确定我的驱动的DriverEntry一定被调用过? //#pragma NDIS_INIT_FUNCTION(DriverEntry) NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath ) { NDIS_STATUS Status; ULONG InitShutdownMask; PWCHAR EventLogString = IMDeviceName.Buffer; PVOID DumpData; LPWSTR lpRegPath = L\"\\0\"; //Debug////////////////////////////////////////////////////////////////////////////////////////////////////////// char InPut[30] = \"DriverEntry\"; DWORD Return; //Debug////////////////////////////////////////////////////////////////////////////////////////////////////////// //#ifdef PACKET_POOL_LOG // NDIS_PHYSICAL_ADDRESS HighAddress = NDIS_PHYSICAL_ADDRESS_CONST( -1, -1 ); //#endif hMyFile = CreateFile( TEXT(\"\\\\Windows\\\\Yangti.TXT\"), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); WriteFile(hMyFile, InPut, sizeof(InPut), &Return, NULL); // //CHeck wether the function was called // wcscpy( lpRegPath, (TEXT(\"Comm\\\\NdisIMD\\\\\")) ); AddKeyValues(lpRegPath, PcmKeyValues); // // store a copy of our driver object. Used by NdisWriteEventLogEntry // IMDriverObject = DriverObject; NdisInitializeListHead( &AdapterList ); NdisAllocateSpinLock( &AdapterListLock ); // // initialize the wrapper with NDIS // Status = InitializeNdisWrapper( DriverObject, RegistryPath ); if ( !NT_SUCCESS( Status )) { NdisWriteErrorLogEntry(IMDriverObject, EVENT_TRANSPORT_REGISTER_FAILED, IM_ERROR_INIT_NDIS_WRAPPER, 1, &EventLogString, 0, NULL); goto DriverEntryError; } InitShutdownMask = SHUTDOWN_TERMINATE_WRAPPER; // // do Protocol initialize first // Status = DoMiniportInit( DriverObject, RegistryPath ); if ( !NT_SUCCESS( Status )) { DumpData = &Status; NdisWriteErrorLogEntry(IMDriverObject, EVENT_TRANSPORT_REGISTER_FAILED, IM_ERROR_PROTOCOL_INIT, 1, &EventLogString, sizeof( Status ), DumpData); goto DriverEntryError; } InitShutdownMask |= SHUTDOWN_DEREGISTER_PROTOCOL; // // Initialize as a Miniport driver to the transports. no shutdown mask value // since there is no way to dereg a miniport... // Status = DoProtocolInit( DriverObject, RegistryPath ); if ( !NT_SUCCESS( Status )) { DumpData = &Status; NdisWriteErrorLogEntry(IMDriverObject, (ULONG)IM_EVENT_MINIPORT_REGISTER_FAILED, 0, 1, &EventLogString, sizeof( Status ), DumpData); goto DriverEntryError; } if ( !NT_SUCCESS( Status )) { goto DriverEntryError; } //#ifdef PACKET_POOL_LOG // NdisAllocateMemory( &PktPoolLog, sizeof(PKTPOOLLOG) * PPLogSize, 0, HighAddress ); //#endif return (STATUS_SUCCESS); // // An error occured so we need to cleanup things // DriverEntryError: InitializationCleanup( InitShutdownMask ); return (STATUS_UNSUCCESSFUL); //MapPtrToProcess(); } |
|
|
沙发#
发布于:2003-04-05 17:15
1、要注意关闭文件的句柄
2、你的文件是存在内存中,不要关闭CE,关掉内容就丢了。 |
|
板凳#
发布于:2003-04-05 21:47
那你说在DriverEntry()加的哪个 CreateFile()与WriteFile()和RegCreateKeyEx()是否可以判断DriverEntry()是否被加载过呢?
|
|
|
地板#
发布于:2003-04-08 20:46
应该可以,但成功与否就不好说了
|
|