阅读:2361回复:14
请问在packet例子中怎么得到的adapter name,我这怎么得不到了?
谢谢
|
|
沙发#
发布于:2002-05-28 22:49
若为应用层在:
EnumAdapters(hWnd); 若为驱动层着在PacketBindAdapter的NdisQueryAdapterInstanceName中。。。。。。。 黑黑。。。。。。。 :) |
|
|
板凳#
发布于:2002-05-29 09:28
不好意思,刚研究完。
自己从注册表读。 现在已经实现 一个驱动程序,一个应用程序 不用任何安装过程, 直接可以抓包。 给你一个函数,在 DriverEntry 的最后调用就可以了。 NTSTATUS GetAdapterRegistry() { NTSTATUS status = STATUS_SUCCESS; NDIS_STRING NetCardKey = NDIS_STRING_CONST( \"\\\\REGISTRY\\\\MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\NetworkCards\" ); NDIS_STRING NetCardKey1 = NDIS_STRING_CONST( \"\\\\REGISTRY\\\\MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\NetworkCards\\\\\" ); NDIS_STRING NetCardKey2 = NDIS_STRING_CONST( \"\\\\DEVICE\\\\\" ); NDIS_STRING NetService = NDIS_STRING_CONST( \"ServiceName\" ); NDIS_STRING NetCardName; NDIS_STRING NetCardDev; HANDLE hKey, hKeyNet; OBJECT_ATTRIBUTES KeyAttrib; OBJECT_ATTRIBUTES KeyAttribNet; ULONG i, lRtn; UCHAR keyBuffer[256]; PKEY_BASIC_INFORMATION pKeyInfo; KEY_VALUE_PARTIAL_INFORMATION * KeyValInfo; PWSTR NetCardGuid = NULL; // 网卡 //REGISTRY\\MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards //ServiceName // RtlZeroMemory( &KeyAttrib, sizeof(OBJECT_ATTRIBUTES) ); InitializeObjectAttributes( &KeyAttrib, &NetCardKey, 0, NULL, NULL ); status = ZwOpenKey( &hKey, KEY_ALL_ACCESS, &KeyAttrib ); if( NT_SUCCESS(status) ) { for( i = 0 ; TRUE ; i++ ) { RtlZeroMemory(keyBuffer, sizeof(keyBuffer)); pKeyInfo = (PKEY_BASIC_INFORMATION) keyBuffer; status = ZwEnumerateKey( hKey, i, KeyBasicInformation, pKeyInfo, sizeof(keyBuffer), &lRtn ); if (!NT_SUCCESS(status)) { if (status != STATUS_NO_MORE_ENTRIES) { DebugPrint( ( \"FindScsiAdapter: Error %lx enumerating key\\n\", status) ); return(status); } DebugPrint( ( \"Enum Key Finished !\\n\") ); break; // return NOT_FOUND } //////////////////// 取得一个子键 NetCardName.MaximumLength = NetCardKey1.Length + 40 + sizeof(UNICODE_NULL); NetCardName.Length = NetCardKey1.Length; NetCardName.Buffer = ExAllocatePool( PagedPool, NetCardName.MaximumLength ); if ( !NetCardName.Buffer ) { DebugPrint( (\"Can\'t allocate pool for NetCardName !\\n\") ); continue; } RtlCopyUnicodeString( &NetCardName, &NetCardKey1 ); status = RtlAppendUnicodeToString( &NetCardName, pKeyInfo->Name ); if (!NT_SUCCESS(status)) { DebugPrint( (\"%ws \\n\", NetCardName.Buffer ) ); if( NetCardName.Buffer ) ExFreePool( NetCardName.Buffer ); continue; } RtlZeroMemory( &KeyAttribNet, sizeof(OBJECT_ATTRIBUTES) ); InitializeObjectAttributes( &KeyAttribNet, &NetCardName, 0, NULL, NULL ); status = ZwOpenKey( &hKeyNet, KEY_ALL_ACCESS, &KeyAttribNet ); if (!NT_SUCCESS(status)) { DebugPrint( (\" Can`t Oepn Key : %ws \\n\", NetCardName.Buffer) ); if( NetCardName.Buffer ) ExFreePool( NetCardName.Buffer ); continue; } //DebugPrint( (\"%ws \\n\", NetCardName.Buffer) ); KeyValInfo = (KEY_VALUE_PARTIAL_INFORMATION * )keyBuffer; status = ZwQueryValueKey( hKeyNet, &NetService, KeyValuePartialInformation, KeyValInfo, sizeof(keyBuffer), &lRtn ); if ( NT_SUCCESS(status) ) { //DebugPrint( (\" %ws \\n\", KeyValInfo->Data) ); NetCardDev.MaximumLength = NetCardKey2.Length + 80 + sizeof(UNICODE_NULL); NetCardDev.Length = NetCardKey2.Length + 80; NetCardDev.Buffer = ExAllocatePool( PagedPool, NetCardDev.MaximumLength ); if ( NetCardDev.Buffer ) { RtlCopyUnicodeString( &NetCardDev, &NetCardKey2 ); NetCardGuid = ExAllocatePool( NonPagedPool, KeyValInfo->DataLength ); swprintf( NetCardGuid, L\"%ws\", KeyValInfo->Data ); DebugPrint( (\"%ws \\n\", NetCardGuid ) ); status = RtlAppendUnicodeToString( &NetCardDev, NetCardGuid ); if ( NT_SUCCESS(status)) { DebugPrint( (\"%ws \\n\", NetCardDev.Buffer) ); //此处是你编写的 BindAdapter 函数 HNCBindAdapter( &status, NULL, &NetCardDev, NULL, NULL ); ExFreePool( NetCardGuid ); } else { DebugPrint( (\"Can`t Append NetCardDev : %ws %x \\n\", NetCardDev.Buffer, status) ); } if( NetCardDev.Buffer ) ExFreePool( NetCardDev.Buffer ); } else { DebugPrint( (\"Can\'t allocate pool for NetCardDev !\\n\") ); } } else { DebugPrint( (\" Can`t get Key value: %ws %x \\n\", NetService.Buffer, status) ); } if( NetCardName.Buffer ) ExFreePool( NetCardName.Buffer ); ZwClose( hKeyNet ); } ZwClose( hKey ); } else { DebugPrint( (\"Can`t Open Registry \\n!\") ); } return( STATUS_SUCCESS ); } 附件是 可以动态加载卸载的实现抓包功能的驱动程序和应用程序。 |
|
|
地板#
发布于:2002-05-29 09:36
我也是刚刚,正式些 核心级的程序,
对很多核心函数不熟,代码很乱, 不要见笑。 |
|
|
地下室#
发布于:2002-05-29 21:16
下不了给我发一个吧
|
|
|
5楼#
发布于:2002-05-30 15:01
我也下载不下来,请给我发一个吧,谢谢!
wbyjr@163.com |
|
6楼#
发布于:2002-05-30 15:26
也给我一份吧。
luke_gem@hotmail.com |
|
7楼#
发布于:2002-05-30 15:47
给我一份吧,谢谢!
|
|
8楼#
发布于:2002-05-30 16:47
我的flyinto@371.net
3x, 3x!!! |
|
9楼#
发布于:2002-05-30 19:03
哎。。。。。。。。。。。 又是一个下不了的。。。。。。。。。。。。。 WHY........................ :o :o :o |
|
|
10楼#
发布于:2002-05-31 02:19
斑竹、站长为什么下不了!!!
|
|
11楼#
发布于:2002-05-31 11:14
兄弟们是想要原码吧。
我传。 |
|
|
12楼#
发布于:2002-05-31 11:21
其实只是在 2K ddk 的 packet 例子改的。
只加了 上边的一个函数。别的还不会呢。 |
|
|
13楼#
发布于:2002-06-04 14:45
谢谢,Tomgin
magicw,PacketBindAdapter这个函数什么时候调用? 我用drivermonitor没发现这个函数被调用了 请写详细些,我们这些初学的没法和你们比,谢谢! |
|
14楼#
发布于:2007-02-05 00:17
菜鸟学习中!!
|
|