[PATCH 1/2] wpcap: Implement pcap_dump_open and pcap_dump(try 2)
Jianqiu Zhang
zhangjianqiu_133 at yeah.net
Thu Feb 11 02:55:28 CST 2016
From 770a1250794833aa7d9a9596a7fc56bfc19c65f0 Mon Sep 17 00:00:00 2001
From: Jianqiu Zhang <zhangjianqiu_133 at yeah.net>
Date: Thu, 29 Oct 2015 15:33:28 +0800
Subject: [PATCH 1/2] wpcap: Implement pcap_dump_open and pcap_dump
Signed-off-by: Jianqiu Zhang <zhangjianqiu_133 at yeah.net>
---
dlls/wpcap/wpcap.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++
dlls/wpcap/wpcap.spec | 4 ++--
2 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c
index ae9e482..e03e18e 100644
--- a/dlls/wpcap/wpcap.c
+++ b/dlls/wpcap/wpcap.c
@@ -22,6 +22,8 @@
#include "winsock2.h"
#include "windef.h"
#include "winbase.h"
+#include "winternl.h"
+#include "ntstatus.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(wpcap);
@@ -40,6 +42,8 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
#define PCAP_SRC_IFLOCAL 3
#endif
+#define MAX_LENGTH 1024
+
void CDECL wine_pcap_breakloop(pcap_t *p)
{
TRACE("(%p)\n", p);
@@ -339,3 +343,53 @@ int CDECL wine_wsockinit(void)
if (WSAStartup(MAKEWORD(1,1), &wsadata)) return -1;
return 0;
}
+
+pcap_dumper_t* CDECL wine_pcap_dump_open(pcap_t *p, const char *fname)
+{
+ UNICODE_STRING nt_name, dospathW;
+ ANSI_STRING fname_dos;
+ ANSI_STRING fname_unix;
+ CHAR fpath[MAX_LENGTH] = { 0 };
+ NTSTATUS res;
+ TRACE("(%p %s)\n", p, fname);
+ RtlInitAnsiString(&fname_dos, fname);
+ res = RtlAnsiStringToUnicodeString(&dospathW, &fname_dos, TRUE);
+ if(res)
+ {
+ SetLastError(RtlNtStatusToDosError(res));
+ return NULL;
+ }
+ if(!RtlDosPathNameToNtPathName_U(dospathW.Buffer, &nt_name, NULL, NULL))
+ {
+ RtlFreeUnicodeString(&dospathW);
+ SetLastError(ERROR_FILENAME_EXCED_RANGE);
+ return NULL;
+ }
+ res = wine_nt_to_unix_file_name(&nt_name, &fname_unix, FILE_OPEN_IF, FALSE);
+ if(res)
+ {
+ if(res == STATUS_NO_SUCH_FILE)
+ SetLastError(ERROR_SUCCESS);
+ else
+ {
+ RtlFreeUnicodeString(&dospathW);
+ RtlFreeUnicodeString(&nt_name);
+ SetLastError(RtlNtStatusToDosError(res));
+ return NULL;
+ }
+ }
+ else
+ {
+ SetLastError(ERROR_FILE_EXISTS);
+ }
+ memcpy(fpath, fname_unix.Buffer, fname_unix.Length);
+ RtlFreeUnicodeString(&nt_name);
+ RtlFreeUnicodeString(&dospathW);
+ RtlFreeAnsiString(&fname_unix);
+ return pcap_dump_open(p, fpath);
+}
+
+void CDECL wine_pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
+{
+ return pcap_dump(user, h, sp);
+}
diff --git a/dlls/wpcap/wpcap.spec b/dlls/wpcap/wpcap.spec
index 66303b4..541fc49 100644
--- a/dlls/wpcap/wpcap.spec
+++ b/dlls/wpcap/wpcap.spec
@@ -16,12 +16,12 @@
@ cdecl pcap_datalink_val_to_description(long) wine_pcap_datalink_val_to_description
@ cdecl pcap_datalink_val_to_name(long) wine_pcap_datalink_val_to_name
@ cdecl pcap_dispatch(ptr long ptr ptr) wine_pcap_dispatch
-@ stub pcap_dump
+@ cdecl pcap_dump(ptr ptr ptr) wine_pcap_dump
@ stub pcap_dump_close
@ stub pcap_dump_file
@ stub pcap_dump_flush
@ stub pcap_dump_ftell
-@ stub pcap_dump_open
+@ cdecl pcap_dump_open(ptr str) wine_pcap_dump_open
@ stub pcap_file
@ stub pcap_fileno
@ cdecl pcap_findalldevs(ptr ptr) wine_pcap_findalldevs
--
2.7.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20160211/bf58fb2c/attachment.html>
More information about the wine-patches
mailing list