[PATCH] packet: create packet.dll and Implement GetAdapterNames(try 3)

Jianqiu Zhang zhangjianqiu13 at gmail.com
Thu Feb 18 04:15:45 CST 2016


>From 4810b411a8b76ce09356da0333d5aef434e30465 Mon Sep 17 00:00:00 2001
From: Jianqiu Zhang <zhangjianqiu_133 at yeah.net>
Date: Sun, 14 Feb 2016 17:27:37 +0800
Subject: [PATCH] packet: create packet.dll and Implement GetAdapterNames

Signed-off-by: Jianqiu Zhang <zhangjianqiu_133 at yeah.net>
---
 configure.ac            |  7 +++++++
 dlls/packet/Makefile.in |  5 +++++
 dlls/packet/packet.c    | 54
+++++++++++++++++++++++++++++++++++++++++++++++++
 dlls/packet/packet.spec | 32 +++++++++++++++++++++++++++++
 4 files changed, 98 insertions(+)
 create mode 100644 dlls/packet/Makefile.in
 create mode 100644 dlls/packet/packet.c
 create mode 100644 dlls/packet/packet.spec

diff --git a/configure.ac b/configure.ac
index 8a90202..7095b8b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,6 +69,8 @@ AC_ARG_WITH(osmesa,
AS_HELP_STRING([--without-osmesa],[do not use the OSMesa
 AC_ARG_WITH(oss,       AS_HELP_STRING([--without-oss],[do not use the OSS
sound support]))
 AC_ARG_WITH(pcap,      AS_HELP_STRING([--without-pcap],[do not use the
Packet Capture library]),
             [if test "x$withval" = "xno"; then
ac_cv_header_pcap_pcap_h=no; fi])
+AC_ARG_WITH(packet,      AS_HELP_STRING([--without-packet],[do not use the
Packet DLL]),
+            [if test "x$withval" = "xno"; then
ac_cv_header_pcap_pcap_h=no; fi])
 AC_ARG_WITH(png,       AS_HELP_STRING([--without-png],[do not use PNG]))
 AC_ARG_WITH(pthread,   AS_HELP_STRING([--without-pthread],[do not use the
pthread library]),
             [if test "x$withval" = "xno"; then ac_cv_header_pthread_h=no;
fi])
@@ -1186,7 +1188,11 @@ then
 fi
 WINE_NOTICE_WITH(pcap,[test "x$ac_cv_lib_pcap_pcap_create" != xyes],
                  [pcap ${notice_platform}development files not found,
wpcap won't be supported.])
+WINE_NOTICE_WITH(packet,[test "x$ac_cv_lib_pcap_pcap_create" != xyes],
+                 [pcap ${notice_platform}development files not found,
packet won't be supported.])
 test "x$ac_cv_lib_pcap_pcap_create" != xyes &&
enable_wpcap=${enable_wpcap:-no}
+test "x$ac_cv_lib_pcap_pcap_create" != xyes &&
enable_packet=${enable_packet:-no}
+

 dnl **** Check for libxml2 ****

@@ -3387,6 +3393,7 @@ WINE_CONFIG_DLL(wmvcore)
 WINE_CONFIG_DLL(wnaspi32,,[implib])
 WINE_CONFIG_DLL(wow32,enable_win16,[implib])
 WINE_CONFIG_DLL(wpcap)
+WINE_CONFIG_DLL(packet)
 WINE_CONFIG_DLL(ws2_32,,[implib])
 WINE_CONFIG_TEST(dlls/ws2_32/tests)
 WINE_CONFIG_DLL(wshom.ocx,,[clean])
diff --git a/dlls/packet/Makefile.in b/dlls/packet/Makefile.in
new file mode 100644
index 0000000..7627d4c
--- /dev/null
+++ b/dlls/packet/Makefile.in
@@ -0,0 +1,5 @@
+MODULE    = packet.dll
+IMPORTS = iphlpapi
+
+C_SRCS = \
+ packet.c
diff --git a/dlls/packet/packet.c b/dlls/packet/packet.c
new file mode 100644
index 0000000..845762c
--- /dev/null
+++ b/dlls/packet/packet.c
@@ -0,0 +1,54 @@
+#include "config.h"
+
+#include "windows.h"
+#include "wine/debug.h"
+
+#include "iphlpapi.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(packet);
+
+BOOLEAN CDECL PacketGetAdapterNames(char *nameList, PULONG pSize)
+{
+    IP_ADAPTER_INFO *adInfo, *adInfoList = NULL;
+    DWORD errcode;
+    ULONG needsize = 0, minDescLen = 0, minAdNameLen = 0, minTotLen = 0,
nameOffset, descOffset;
+
+    TRACE("nameList %p &size %p size %d\n", nameList, pSize, *pSize);
+
+    errcode = GetAdaptersInfo(adInfoList, &needsize);
+    adInfoList = HeapAlloc(GetProcessHeap(), 0, needsize);
+
+    errcode = GetAdaptersInfo(adInfoList, &needsize);
+    if(errcode)
+    {
+        SetLastError(errcode);
+        return FALSE;
+    }
+    for(adInfo = adInfoList; adInfo != NULL; adInfo = adInfo->Next)
+    {
+        minAdNameLen += lstrlenA(adInfo->AdapterName) + 1;
+        minDescLen += lstrlenA(adInfo->Description) + 1;
+    }
+    minTotLen = minAdNameLen + minDescLen + 2;
+    TRACE("minAdNameLen = %d, minDescLen = %d\n", minAdNameLen,
minDescLen);
+    if(nameList == NULL || *pSize < minTotLen)
+    {
+        SetLastError(ERROR_INSUFFICIENT_BUFFER);
+        *pSize = minTotLen;
+        return FALSE;
+    }
+
+    nameOffset = descOffset = 0;
+    for(adInfo = adInfoList; adInfo != NULL; adInfo = adInfo->Next)
+    {
+        lstrcpyA(nameList + nameOffset, adInfo->AdapterName);
+        lstrcpyA(nameList + minAdNameLen + descOffset + 1,
adInfo->Description);
+        nameOffset += lstrlenA(adInfo->AdapterName) + 1;
+        descOffset += lstrlenA(adInfo->Description) + 1;
+    }
+    nameList[minAdNameLen] = '\0';
+    nameList[minTotLen - 1] = '\0';
+
+    HeapFree(GetProcessHeap(), 0, adInfoList);
+    return TRUE;
+}
diff --git a/dlls/packet/packet.spec b/dlls/packet/packet.spec
new file mode 100644
index 0000000..b7f2781
--- /dev/null
+++ b/dlls/packet/packet.spec
@@ -0,0 +1,32 @@
+ 1 stub PacketAllocatePacket
+ 2 stub PacketCloseAdapter
+ 3 stub PacketFreePacket
+ 4 cdecl PacketGetAdapterNames(str long)
+ 5 stub PacketGetAirPcapHandle
+ 6 stub PacketGetDriverVersion
+ 7 stub PacketGetNetInfoEx
+ 8 stub PacketGetNetType
+ 9 stub PacketGetReadEvent
+10 stub PacketGetStats
+11 stub PacketGetStatsEx
+12 stub PacketGetVersion
+13 stub PacketInitPacket
+14 stub PacketIsDumpEnded
+15 stub PacketLibraryVersion
+16 stub PacketOpenAdapter
+17 stub PacketReceivePacket
+18 stub PacketRequest
+19 stub PacketSendPacket
+20 stub PacketSendPackets
+21 stub PacketSetBpf
+22 stub PacketSetBuff
+23 stub PacketSetDumpLimits
+24 stub PacketSetDumpName
+25 stub PacketSetHwFilter
+26 stub PacketSetLoopbackBehavior
+27 stub PacketSetMinToCopy
+28 stub PacketSetMode
+29 stub PacketSetNumWrites
+30 stub PacketSetReadTimeout
+31 stub PacketSetSnapLen
+32 stub PacketStopDriver
-- 
2.7.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20160218/aa58c18e/attachment.html>


More information about the wine-patches mailing list