Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/nsiproxy.sys/Makefile.in | 6 ++ dlls/nsiproxy.sys/device.c | 87 +++++++++++++++++++++++++++++ dlls/nsiproxy.sys/nsiproxy.sys.spec | 1 + loader/wine.inf.in | 13 +++++ 4 files changed, 107 insertions(+) create mode 100644 dlls/nsiproxy.sys/Makefile.in create mode 100644 dlls/nsiproxy.sys/device.c create mode 100644 dlls/nsiproxy.sys/nsiproxy.sys.spec
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 <stdarg.h> + +#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)"