Huw Davies : nsiproxy: Build with msvcrt.

Alexandre Julliard julliard at winehq.org
Fri Oct 1 18:02:23 CDT 2021


Module: wine
Branch: master
Commit: 37097b96874f043d87c22df4055d5f85be356c51
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=37097b96874f043d87c22df4055d5f85be356c51

Author: Huw Davies <huw at codeweavers.com>
Date:   Fri Oct  1 15:07:06 2021 +0100

nsiproxy: Build with msvcrt.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 configure                     |  1 -
 configure.ac                  |  1 -
 dlls/nsiproxy.sys/Makefile.in |  5 +++--
 dlls/nsiproxy.sys/device.c    | 36 ++++++++++++++++++++++++++++--------
 dlls/nsiproxy.sys/ip.c        |  6 ++++++
 dlls/nsiproxy.sys/ndis.c      |  9 +++++++--
 dlls/nsiproxy.sys/nsi.c       | 30 ++++++++++++++++++++++++++++++
 dlls/nsiproxy.sys/tcp.c       |  4 ++++
 dlls/nsiproxy.sys/udp.c       |  4 ++++
 9 files changed, 82 insertions(+), 14 deletions(-)

diff --git a/configure b/configure
index 038391a4439..2a429f4c13d 100755
--- a/configure
+++ b/configure
@@ -8343,7 +8343,6 @@ if test "x$ac_cv_cflags__Wl___disable_stdcall_fixup" = xyes; then :
 fi ;;
     esac
         enable_iphlpapi=${enable_iphlpapi:-no}
-    enable_nsiproxy_sys=${enable_nsiproxy_sys:-no}
     enable_loader=${enable_loader:-no}
     enable_server=${enable_server:-no}
         with_x=${with_x:-no}
diff --git a/configure.ac b/configure.ac
index da80562c445..913692c828a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -725,7 +725,6 @@ case $host_os in
     esac
     dnl Disable modules that can't be used on Windows
     enable_iphlpapi=${enable_iphlpapi:-no}
-    enable_nsiproxy_sys=${enable_nsiproxy_sys:-no}
     enable_loader=${enable_loader:-no}
     enable_server=${enable_server:-no}
     dnl Disable dependencies that are not useful on Windows
diff --git a/dlls/nsiproxy.sys/Makefile.in b/dlls/nsiproxy.sys/Makefile.in
index b33ea0e4c8a..95f2a205816 100644
--- a/dlls/nsiproxy.sys/Makefile.in
+++ b/dlls/nsiproxy.sys/Makefile.in
@@ -1,8 +1,9 @@
 MODULE    = nsiproxy.sys
-IMPORTS   = ntoskrnl uuid
+UNIXLIB   = nsiproxy.so
+IMPORTS   = ntoskrnl
 EXTRALIBS = $(PROCSTAT_LIBS)
 
-EXTRADLLFLAGS = -Wl,--subsystem,native -mcygwin
+EXTRADLLFLAGS = -Wl,--subsystem,native
 
 C_SRCS = \
 	device.c \
diff --git a/dlls/nsiproxy.sys/device.c b/dlls/nsiproxy.sys/device.c
index 80a025acfc9..3afd76487ff 100644
--- a/dlls/nsiproxy.sys/device.c
+++ b/dlls/nsiproxy.sys/device.c
@@ -32,10 +32,24 @@
 #include "netiodef.h"
 #include "wine/nsi.h"
 #include "wine/debug.h"
-#include "nsiproxy_private.h"
+#include "wine/unixlib.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(nsi);
 
+static unixlib_handle_t nsiproxy_handle;
+
+static NTSTATUS nsiproxy_call( unsigned int code, void *args )
+{
+    return __wine_unix_call( nsiproxy_handle, code, args );
+}
+
+enum unix_calls
+{
+    nsi_enumerate_all_ex,
+    nsi_get_all_parameters_ex,
+    nsi_get_parameter_ex,
+};
+
 static void nsiproxy_enumerate_all( IRP *irp )
 {
     IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp );
@@ -73,7 +87,7 @@ static void nsiproxy_enumerate_all( IRP *irp )
     enum_all.static_size = in->static_size;
     enum_all.count = in->count;
 
-    irp->IoStatus.u.Status = nsi_enumerate_all_ex( &enum_all );
+    irp->IoStatus.u.Status = nsiproxy_call( nsi_enumerate_all_ex, &enum_all );
     if (irp->IoStatus.u.Status == STATUS_SUCCESS || irp->IoStatus.u.Status == STATUS_BUFFER_OVERFLOW)
     {
         irp->IoStatus.Information = out_len;
@@ -119,7 +133,7 @@ static void nsiproxy_get_all_parameters( IRP *irp )
     get_all.static_data = out + in->rw_size + in->dynamic_size;
     get_all.static_size = in->static_size;
 
-    irp->IoStatus.u.Status = nsi_get_all_parameters_ex( &get_all );
+    irp->IoStatus.u.Status = nsiproxy_call( nsi_get_all_parameters_ex, &get_all );
     irp->IoStatus.Information = (irp->IoStatus.u.Status == STATUS_SUCCESS) ? out_len : 0;
 }
 
@@ -152,7 +166,7 @@ static void nsiproxy_get_parameter( IRP *irp )
     get_param.data_size = out_len;
     get_param.data_offset = in->data_offset;
 
-    irp->IoStatus.u.Status = nsi_get_parameter_ex( &get_param );
+    irp->IoStatus.u.Status = nsiproxy_call( nsi_get_parameter_ex, &get_param );
     irp->IoStatus.Information = irp->IoStatus.u.Status == STATUS_SUCCESS ? out_len : 0;
 }
 
@@ -193,14 +207,12 @@ static NTSTATUS WINAPI nsi_ioctl( DEVICE_OBJECT *device, IRP *irp )
 
 static int add_device( DRIVER_OBJECT *driver )
 {
-    static const WCHAR name_str[] = {'\\','D','e','v','i','c','e','\\','N','s','i',0};
-    static const WCHAR link_str[] = {'\\','?','?','\\','N','s','i',0};
     UNICODE_STRING name, link;
     DEVICE_OBJECT *device;
     NTSTATUS status;
 
-    RtlInitUnicodeString( &name, name_str );
-    RtlInitUnicodeString( &link, link_str );
+    RtlInitUnicodeString( &name, L"\\Device\\Nsi" );
+    RtlInitUnicodeString( &link, L"\\??\\Nsi" );
 
     if (!(status = IoCreateDevice( driver, 0, &name, FILE_DEVICE_NETWORK, FILE_DEVICE_SECURE_OPEN, FALSE, &device )))
         status = IoCreateSymbolicLink( &link, &name );
@@ -215,8 +227,16 @@ static int add_device( DRIVER_OBJECT *driver )
 
 NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
 {
+    HMODULE instance;
+    NTSTATUS status;
+
     TRACE( "(%p, %s)\n", driver, debugstr_w( path->Buffer ) );
 
+    RtlPcToFileHeader( &DriverEntry, (void *)&instance );
+    status = NtQueryVirtualMemory( GetCurrentProcess(), instance, MemoryWineUnixFuncs,
+                                   &nsiproxy_handle, sizeof(nsiproxy_handle), NULL );
+    if (status) return status;
+
     driver->MajorFunction[IRP_MJ_DEVICE_CONTROL] = nsi_ioctl;
 
     add_device( driver );
diff --git a/dlls/nsiproxy.sys/ip.c b/dlls/nsiproxy.sys/ip.c
index 90ea7957204..2e69c289c16 100644
--- a/dlls/nsiproxy.sys/ip.c
+++ b/dlls/nsiproxy.sys/ip.c
@@ -18,6 +18,12 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
+#if 0
+#pragma makedep unix
+#endif
+
+#define _NTSYSTEM_
+
 #include "config.h"
 #include <stdarg.h>
 
diff --git a/dlls/nsiproxy.sys/ndis.c b/dlls/nsiproxy.sys/ndis.c
index 90112da31bb..8971b69c2db 100644
--- a/dlls/nsiproxy.sys/ndis.c
+++ b/dlls/nsiproxy.sys/ndis.c
@@ -18,6 +18,10 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
+#if 0
+#pragma makedep unix
+#endif
+
 #include "config.h"
 
 #include <stdarg.h>
@@ -85,6 +89,7 @@
 #include "wine/nsi.h"
 #include "wine/list.h"
 #include "wine/debug.h"
+#include "wine/unixlib.h"
 
 #include "nsiproxy_private.h"
 
@@ -251,9 +256,9 @@ static WCHAR *strdupAtoW( const char *str )
     DWORD len;
 
     if (!str) return ret;
-    len = MultiByteToWideChar( CP_UNIXCP, 0, str, -1, NULL, 0 );
+    len = strlen( str ) + 1;
     ret = malloc( len * sizeof(WCHAR) );
-    if (ret) MultiByteToWideChar( CP_UNIXCP, 0, str, -1, ret, len );
+    if (ret) ntdll_umbstowcs( str, len, ret, len );
     return ret;
 }
 
diff --git a/dlls/nsiproxy.sys/nsi.c b/dlls/nsiproxy.sys/nsi.c
index e29446abb50..ccfc325a085 100644
--- a/dlls/nsiproxy.sys/nsi.c
+++ b/dlls/nsiproxy.sys/nsi.c
@@ -17,6 +17,9 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
+#if 0
+#pragma makedep unix
+#endif
 
 #include <stdarg.h>
 
@@ -28,9 +31,11 @@
 #include "winioctl.h"
 #include "ddk/wdm.h"
 #include "ifdef.h"
+#define __WINE_INIT_NPI_MODULEID
 #include "netiodef.h"
 #include "wine/nsi.h"
 #include "wine/debug.h"
+#include "wine/unixlib.h"
 #include "nsiproxy_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(nsi);
@@ -121,3 +126,28 @@ NTSTATUS nsi_get_parameter_ex( struct nsi_get_parameter_ex *params )
     return entry->get_parameter( params->key, params->key_size, params->param_type,
                                  params->data, params->data_size, params->data_offset );
 }
+
+static NTSTATUS unix_nsi_enumerate_all_ex( void *args )
+{
+    struct nsi_enumerate_all_ex *params = (struct nsi_enumerate_all_ex *)args;
+    return nsi_enumerate_all_ex( params );
+}
+
+static NTSTATUS unix_nsi_get_all_parameters_ex( void *args )
+{
+    struct nsi_get_all_parameters_ex *params = (struct nsi_get_all_parameters_ex *)args;
+    return nsi_get_all_parameters_ex( params );
+}
+
+static NTSTATUS unix_nsi_get_parameter_ex( void *args )
+{
+    struct nsi_get_parameter_ex *params = (struct nsi_get_parameter_ex *)args;
+    return nsi_get_parameter_ex( params );
+}
+
+const unixlib_entry_t __wine_unix_call_funcs[] =
+{
+    unix_nsi_enumerate_all_ex,
+    unix_nsi_get_all_parameters_ex,
+    unix_nsi_get_parameter_ex
+};
diff --git a/dlls/nsiproxy.sys/tcp.c b/dlls/nsiproxy.sys/tcp.c
index b60e53ea15e..55311a4affc 100644
--- a/dlls/nsiproxy.sys/tcp.c
+++ b/dlls/nsiproxy.sys/tcp.c
@@ -19,6 +19,10 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
+#if 0
+#pragma makedep unix
+#endif
+
 #include "config.h"
 #include <stdarg.h>
 
diff --git a/dlls/nsiproxy.sys/udp.c b/dlls/nsiproxy.sys/udp.c
index f25aac98ba0..0cc2cadbc98 100644
--- a/dlls/nsiproxy.sys/udp.c
+++ b/dlls/nsiproxy.sys/udp.c
@@ -18,6 +18,10 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
+#if 0
+#pragma makedep unix
+#endif
+
 #include "config.h"
 #include <stdarg.h>
 #include <stddef.h>




More information about the wine-cvs mailing list