MessageHi.
The bug is in the packet.dll source code. Basically, the adapter device name
must be prepended by the "\\Global" string (because the device is in the
global objects namespace), otherwise the OS looks for it in the namespace of
the current session, and cannot find it.
The diff of this patch (packet32.c) is this one:
707c706,709
< wsprintf(SymbolicLink, TEXT("\\\\.\\%s"), &AdapterName[16]);
---
> if (LOWORD(GetVersion()) == 4)
> wsprintf(SymbolicLink,TEXT("\\\\.\\%s"),&AdapterName[16]);
> else
> wsprintf(SymbolicLink,TEXT("\\\\.\\Global\\%s"),&AdapterName[16]);
Hope it helps.
GV
----- Original Message -----
From: Henrik Sloth
To: [EMAIL PROTECTED]
Sent: Thursday, September 30, 2004 1:28 PM
Subject: RE: [WinPcap-users] Found a issue in AdInfo.c - Function
AddAdapterIPH
Gianluca,
Is it possible for you to elaborate on the bug that you mention, regarding
WinPCap and ts, or is there a way to get hold of the source files affected
by the fix ?
Regards
Henrik Sloth
From: Gianluca Varenni [mailto:[EMAIL PROTECTED]
Sent: Friday, August 27, 2004 6:00 PM
To: [EMAIL PROTECTED]
Subject: Re: [WinPcap-users] Found a issue in AdInfo.c - Function
AddAdapterIPH
Hi.
Regarding the problem about terminal services, Winpcap 3.1beta3 is affected
by a bug that prevents it from working correctly on a ts session. The bug
has been corrected in our source tree and will be avialble in the next
release of winpcap.
Have a nice day
GV
----- Original Message -----
From: Tom McAnnally
To: [EMAIL PROTECTED]
Sent: Friday, August 27, 2004 2:32 PM
Subject: RE: [WinPcap-users] Found a issue in AdInfo.c - Function
AddAdapterIPH
I figured out why I was unable to use WinPCap in the system in question. It
has to do with the fact that the OS is Windows 2000 Terminal Server Ed.
Since this is the case, you have to call CreateFile with the prefix to the
device of GLOBAL\. The device that has this issue is a teaming NIC
consisting of 4 adapters.
I will post more information as I figure it out.
-Tom
From: Tom McAnnally [mailto:[EMAIL PROTECTED]
Sent: Friday, August 27, 2004 12:27 PM
To: [EMAIL PROTECTED]
Subject: [WinPcap-users] Found a issue in AdInfo.c - Function AddAdapterIPH
Hello All,
Do you know if there is a way to enumerate the NPF_ device list?
Also, I found an issue that you may wish to fix. The details follow.
I have a system on which I am unable to use WinPCap since the enumeration of
the network devices fails to find the network device which I wish to use. I
have not solved this yet, but in looking for a solution, I did find the
following issue.
When enumerating devices I end up with the following call stack.
Packet.dll!PacketOpenAdapterNPF(char * AdapterName=0x00141c98) Line 708
C
Packet.dll!AddAdapterIPH(_IP_ADAPTER_INFO * IphAd=0x0014dd10) Line 503 +
0xc C
Packet.dll!PacketGetAdaptersIPH() Line 632 + 0x9 C
Packet.dll!PacketPopulateAdaptersInfoList() Line 1248 C
Packet.dll!PacketGetAdapterNames(unsigned short * pStr=0x00000000, unsigned
long * BufferSize=0x0012cc5c) Line 2032 C
wpcap.dll!pcap_findalldevs(pcap_if * * alldevsp=0x0012f0ac, char *
errbuf=0x0012ef8c) Line 228 + 0xb C
wpcap.dll!pcap_findalldevs_ex(char * source=0x005a199c, pcap_rmtauth *
auth=0x00000000, pcap_if * * alldevs=0x0012f0ac, char * errbuf=0x0012ef8c)
Line 184 + 0xd C
I noticed that PacketOpenAdapterNPF takes a wide string as input, but it
seems that AddAdapterIPH passes in an ascii string.
This causes a bug on the following line in PacketOpenAdapterNPF since the
resulting string stored in SymbolicLink is wrong, any device which is
discovered via IPH will not be added to the adapter list.
wsprintf(SymbolicLink, TEXT("\\\\.\\%s"), &AdapterName[16]);
I would suggest the following patch to AddAdapterIPH to pass the correct
wide string to PacketOpenAdapterNPF.
BOOLEAN AddAdapterIPH(PIP_ADAPTER_INFO IphAd)
{
PIP_ADAPTER_INFO AdList = NULL;
ULONG OutBufLen=0;
PADAPTER_INFO TmpAdInfo, SAdInfo;
PIP_ADDR_STRING TmpAddrStr;
UINT i;
struct sockaddr_in *TmpAddr;
CHAR TName[256];
LPADAPTER adapter;
PWCHAR UAdName;
// Create the NPF device name from the original device name
strcpy(TName, "\\Device\\NPF_");
_snprintf(TName + 12, ADAPTER_NAME_LENGTH - 12, "%s",
IphAd->AdapterName);
// Scan the adapters list to see if this one is already present
for(SAdInfo = AdaptersInfoList; SAdInfo != NULL; SAdInfo =
SAdInfo->Next)
{
if(strcmp(TName, SAdInfo->Name) == 0)
{
ODS("PacketGetAdaptersIPH: Adapter already present in the
list\n");
goto SkipAd;
}
}
if(IphAd->Type == IF_TYPE_PPP || IphAd->Type == IF_TYPE_SLIP)
{
if (!WanPacketTestAdapter())
goto SkipAd;
}
else
{
UAdName = SChar2WChar(TName);
adapter = PacketOpenAdapterNPF((PCHAR)UAdName);
GlobalFreePtr(UAdName);
if(adapter == NULL)
{
// We are not able to open this adapter. Skip to the next
one.
ODS("PacketGetAdaptersIPH: unable to open the adapter\n");
goto SkipAd;
}
else
{
PacketCloseAdapter(adapter);
}
}
//
// Adapter valid and not yet present in the list. Allocate the
ADAPTER_INFO structure
//
TmpAdInfo = GlobalAllocPtr(GMEM_MOVEABLE | GMEM_ZEROINIT,
sizeof(ADAPTER_INFO));
if (TmpAdInfo == NULL) {
ODS("PacketGetAdaptersIPH: GlobalAlloc Failed\n");
return FALSE;
}
// Copy the device name
strcpy(TmpAdInfo->Name, TName);
// Copy the description
_snprintf(TmpAdInfo->Description, ADAPTER_DESC_LENGTH, "%s",
IphAd->Description);
// Copy the MAC address
TmpAdInfo->MacAddressLen = IphAd->AddressLength;
memcpy(TmpAdInfo->MacAddress,
IphAd->Address,
(MAX_MAC_ADDR_LENGTH<MAX_ADAPTER_ADDRESS_LENGTH)?
MAX_MAC_ADDR_LENGTH:MAX_ADAPTER_ADDRESS_LENGTH);
// Calculate the number of IP addresses of this interface
for(TmpAddrStr = &IphAd->IpAddressList, i = 0; TmpAddrStr != NULL;
TmpAddrStr = TmpAddrStr->Next, i++)
{
}
TmpAdInfo->NetworkAddresses = GlobalAllocPtr(GMEM_MOVEABLE |
GMEM_ZEROINIT, MAX_NETWORK_ADDRESSES * sizeof(npf_if_addr));
if (TmpAdInfo->NetworkAddresses == NULL) {
ODS("PacketGetAdaptersIPH: GlobalAlloc Failed\n");
GlobalFreePtr(TmpAdInfo);
return FALSE;
}
// Scan the addresses, convert them to addrinfo structures and put
each of them in the list
for(TmpAddrStr = &IphAd->IpAddressList, i = 0; TmpAddrStr != NULL;
TmpAddrStr = TmpAddrStr->Next)
{
TmpAddr = (struct sockaddr_in
*)&(TmpAdInfo->NetworkAddresses[i].IPAddress);
if((TmpAddr->sin_addr.S_un.S_addr =
inet_addr(TmpAddrStr->IpAddress.String))!= INADDR_NONE)
{
TmpAddr->sin_family = AF_INET;
TmpAddr = (struct sockaddr_in
*)&(TmpAdInfo->NetworkAddresses[i].SubnetMask);
TmpAddr->sin_addr.S_un.S_addr =
inet_addr(TmpAddrStr->IpMask.String);
TmpAddr->sin_family = AF_INET;
TmpAddr = (struct sockaddr_in
*)&(TmpAdInfo->NetworkAddresses[i].Broadcast);
TmpAddr->sin_addr.S_un.S_addr = 0xffffffff; // Consider
255.255.255.255 as broadcast address since IP Helper API doesn't provide
information about it
TmpAddr->sin_family = AF_INET;
i++;
}
}
TmpAdInfo->NNetworkAddresses = i;
// Now Add IPv6 Addresses
PacketAddIP6Addresses(TmpAdInfo);
if(IphAd->Type == IF_TYPE_PPP || IphAd->Type == IF_TYPE_SLIP)
{
// NdisWan adapter
TmpAdInfo->Flags = INFO_FLAG_NDISWAN_ADAPTER;
}
// Update the AdaptersInfo list
TmpAdInfo->Next = AdaptersInfoList;
AdaptersInfoList = TmpAdInfo;
SkipAd:
return TRUE;
}
Thanks,
Tom
==================================================================
This is the WinPcap users list. It is archived at
http://www.mail-archive.com/[EMAIL PROTECTED]/
To unsubscribe use
mailto: [EMAIL PROTECTED]
==================================================================