diff --git a/configure b/configure index 789a7e568cb..25089c31e18 100755 --- a/configure +++ b/configure @@ -1526,6 +1526,7 @@ enable_normaliz enable_npmshtml enable_npptools enable_nsi +enable_nsiproxy_sys enable_ntdll enable_ntdsapi enable_ntoskrnl_exe @@ -20822,6 +20823,7 @@ wine_fn_config_makefile dlls/npmshtml enable_npmshtml wine_fn_config_makefile dlls/npptools enable_npptools wine_fn_config_makefile dlls/nsi enable_nsi wine_fn_config_makefile dlls/nsi/tests enable_tests +wine_fn_config_makefile dlls/nsiproxy.sys enable_nsiproxy_sys wine_fn_config_makefile dlls/ntdll enable_ntdll wine_fn_config_makefile dlls/ntdll/tests enable_tests wine_fn_config_makefile dlls/ntdsapi enable_ntdsapi diff --git a/configure.ac b/configure.ac index 6aa5c513a96..5c4f0c8a6cb 100644 --- a/configure.ac +++ b/configure.ac @@ -3498,6 +3498,7 @@ WINE_CONFIG_MAKEFILE(dlls/npmshtml) WINE_CONFIG_MAKEFILE(dlls/npptools) WINE_CONFIG_MAKEFILE(dlls/nsi) WINE_CONFIG_MAKEFILE(dlls/nsi/tests) +WINE_CONFIG_MAKEFILE(dlls/nsiproxy.sys) WINE_CONFIG_MAKEFILE(dlls/ntdll) WINE_CONFIG_MAKEFILE(dlls/ntdll/tests) WINE_CONFIG_MAKEFILE(dlls/ntdsapi) diff --git a/dlls/nsiproxy.sys/Makefile.in b/dlls/nsiproxy.sys/Makefile.in new file mode 100644 index 00000000000..d1913671f49 --- /dev/null +++ b/dlls/nsiproxy.sys/Makefile.in @@ -0,0 +1,6 @@ +MODULE = nsiproxy.sys +IMPORTS = ntoskrnl +EXTRADLLFLAGS = -Wl,--subsystem,native + +C_SRCS = \ + device.c diff --git a/dlls/nsiproxy.sys/device.c b/dlls/nsiproxy.sys/device.c new file mode 100644 index 00000000000..ecd584bd1cb --- /dev/null +++ b/dlls/nsiproxy.sys/device.c @@ -0,0 +1,87 @@ +/* + * nsiproxy.sys + * + * Copyright 2021 Huw Davies + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#define NONAMELESSUNION +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winternl.h" +#include "winioctl.h" +#include "ddk/wdm.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(nsi); + +static NTSTATUS WINAPI nsi_ioctl( DEVICE_OBJECT *device, IRP *irp ) +{ + IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); + + TRACE( "ioctl %x insize %u outsize %u\n", + irpsp->Parameters.DeviceIoControl.IoControlCode, + irpsp->Parameters.DeviceIoControl.InputBufferLength, + irpsp->Parameters.DeviceIoControl.OutputBufferLength ); + + switch (irpsp->Parameters.DeviceIoControl.IoControlCode) + { + default: + FIXME( "ioctl %x not supported\n", irpsp->Parameters.DeviceIoControl.IoControlCode ); + irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED; + break; + } + + IoCompleteRequest( irp, IO_NO_INCREMENT ); + return STATUS_SUCCESS; +} + +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 ); + + if (!(status = IoCreateDevice( driver, 0, &name, FILE_DEVICE_NETWORK, FILE_DEVICE_SECURE_OPEN, FALSE, &device ))) + status = IoCreateSymbolicLink( &link, &name ); + if (status) + { + FIXME( "failed to create device error %x\n", status ); + return 0; + } + + return 1; +} + +NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) +{ + TRACE( "(%p, %s)\n", driver, debugstr_w( path->Buffer ) ); + + driver->MajorFunction[IRP_MJ_DEVICE_CONTROL] = nsi_ioctl; + + add_device( driver ); + + return STATUS_SUCCESS; +} diff --git a/dlls/nsiproxy.sys/nsiproxy.sys.spec b/dlls/nsiproxy.sys/nsiproxy.sys.spec new file mode 100644 index 00000000000..590a204a2b0 --- /dev/null +++ b/dlls/nsiproxy.sys/nsiproxy.sys.spec @@ -0,0 +1 @@ +# no exported functions diff --git a/loader/wine.inf.in b/loader/wine.inf.in index 437c723a5e2..defaba008e2 100644 --- a/loader/wine.inf.in +++ b/loader/wine.inf.in @@ -165,6 +165,7 @@ AddService=Schedule,0,TaskSchedulerService AddService=Winmgmt,0,WinmgmtService AddService=wuauserv,0,wuauService AddService=NDIS,0x800,NDISService +AddService=nsiproxy,0x800,NsiProxyService [DefaultInstall.NT.Services] AddService=BITS,0,BITSService @@ -184,6 +185,7 @@ AddService=Schedule,0,TaskSchedulerService AddService=Winmgmt,0,WinmgmtService AddService=wuauserv,0,wuauService AddService=NDIS,0x800,NDISService +AddService=nsiproxy,0x800,NsiProxyService [DefaultInstall.ntamd64.Services] AddService=BITS,0,BITSService @@ -203,6 +205,7 @@ AddService=Schedule,0,TaskSchedulerService AddService=Winmgmt,0,WinmgmtService AddService=wuauserv,0,wuauService AddService=NDIS,0x800,NDISService +AddService=nsiproxy,0x800,NsiProxyService [DefaultInstall.ntarm64.Services] AddService=BITS,0,BITSService @@ -222,6 +225,7 @@ AddService=Schedule,0,TaskSchedulerService AddService=Winmgmt,0,WinmgmtService AddService=wuauserv,0,wuauService AddService=NDIS,0x800,NDISService +AddService=nsiproxy,0x800,NsiProxyService [Strings] MciExtStr="Software\Microsoft\Windows NT\CurrentVersion\MCI Extensions" @@ -3779,6 +3783,15 @@ StartType=2 ErrorControl=1 LoadOrderGroup="System Bus Extender" +[NsiProxyService] +Description="NSI proxy service" +DisplayName="NSI Proxy" +ServiceBinary="%12%\nsiproxy.sys" +ServiceType=1 +StartType=2 +ErrorControl=1 +LoadOrderGroup="System Bus Extender" + [RpcSsService] Description="RPC service" DisplayName="Remote Procedure Call (RPC)"