From ed31a187ac2ece5e2fb14920dec373b8388f7863 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Fri, 14 Jun 2019 18:34:19 -0700 Subject: [PATCH] opt/fsext: kernel mode winfsp extension --- inc/winfsp/fsctl.h | 2 +- opt/fsext/inc/winfsp/fsext.h | 60 +++++++++++++++++++++++++++++++++++ opt/fsext/lib/winfsp-x64.lib | Bin 0 -> 2270 bytes opt/fsext/lib/winfsp-x86.lib | Bin 0 -> 2312 bytes opt/fsext/lib/winfsp.impdef | 6 ++++ tools/impdef.bat | 44 +++++++++++++++++++++++++ 6 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 opt/fsext/inc/winfsp/fsext.h create mode 100644 opt/fsext/lib/winfsp-x64.lib create mode 100644 opt/fsext/lib/winfsp-x86.lib create mode 100644 opt/fsext/lib/winfsp.impdef create mode 100644 tools/impdef.bat diff --git a/inc/winfsp/fsctl.h b/inc/winfsp/fsctl.h index f2b083e6..24c63ef1 100644 --- a/inc/winfsp/fsctl.h +++ b/inc/winfsp/fsctl.h @@ -588,7 +588,7 @@ static inline FSP_FSCTL_TRANSACT_RSP *FspFsctlTransactConsumeResponse( return NextResponse <= ResponseBufEnd ? (FSP_FSCTL_TRANSACT_RSP *)NextResponse : 0; } -#if !defined(WINFSP_SYS_INTERNAL) +#if !defined(_KERNEL_MODE) FSP_API NTSTATUS FspFsctlCreateVolume(PWSTR DevicePath, const FSP_FSCTL_VOLUME_PARAMS *VolumeParams, PWCHAR VolumeNameBuf, SIZE_T VolumeNameSize, diff --git a/opt/fsext/inc/winfsp/fsext.h b/opt/fsext/inc/winfsp/fsext.h new file mode 100644 index 00000000..21bbe62a --- /dev/null +++ b/opt/fsext/inc/winfsp/fsext.h @@ -0,0 +1,60 @@ +/** + * @file winfsp/fsext.h + * + * @copyright 2015-2019 Bill Zissimopoulos + */ +/* + * This file is part of WinFsp. + * + * You can redistribute it and/or modify it under the terms of the GNU + * General Public License version 3 as published by the Free Software + * Foundation. + * + * Licensees holding a valid commercial license may use this software + * in accordance with the commercial license agreement provided in + * conjunction with the software. The terms and conditions of any such + * commercial license agreement shall govern, supersede, and render + * ineffective any application of the GPLv3 license to this software, + * notwithstanding of any reference thereto in the software or + * associated repository. + */ + +#ifndef WINFSP_FSEXT_H_INCLUDED +#define WINFSP_FSEXT_H_INCLUDED + +#if !defined(_KERNEL_MODE) +#error This file can only be included when compiling for kernel mode. +#endif + +#include + +#if defined(WINFSP_SYS_INTERNAL) +#define FSP_DDI __declspec(dllexport) +#else +#define FSP_DDI __declspec(dllimport) +#endif +#if !defined(FSP_DDI_DEF) +#define FSP_DDI_DEF(RetType, Name, ...) FSP_DDI RetType NTAPI Name ( __VA_ARGS__ ); +#endif + +typedef struct +{ + UINT32 Version; + /* in */ + UINT32 DeviceTransactCode; + UINT32 DeviceExtensionSize; + NTSTATUS (*DeviceInit)(PDEVICE_OBJECT DeviceObject); + VOID (*DeviceFini)(PDEVICE_OBJECT DeviceObject); + VOID (*DeviceExpirationRoutine)(PDEVICE_OBJECT DeviceObject, UINT64 ExpirationTime); + NTSTATUS (*DeviceTransact)(PIRP Irp, PDEVICE_OBJECT DeviceObject); + /* out */ + UINT32 DeviceExtensionOffset; +} FSP_FSEXT_PROVIDER; + +FSP_DDI_DEF(NTSTATUS, FspFsextRegisterProvider, FSP_FSEXT_PROVIDER *Provider) + +FSP_DDI_DEF(NTSTATUS, FspPosixMapSidToUid, PSID Sid, PUINT32 PUid) +FSP_DDI_DEF(NTSTATUS, FspPosixMapWindowsToPosixPathEx, PWSTR WindowsPath, char **PPosixPath, + BOOLEAN Translate) + +#endif diff --git a/opt/fsext/lib/winfsp-x64.lib b/opt/fsext/lib/winfsp-x64.lib new file mode 100644 index 0000000000000000000000000000000000000000..dfc37e8b78005675c6ce49460db0198abaec22cb GIT binary patch literal 2270 zcmcIlPj3=Y5FZvwD=`ND95rG>P-B8XSprF8w%Rt50^Pupp6nJ_TK3Q`VX5Gy-g@%h zFW`sp*mL8-gGUej2u(kLb!PWH_7N6~4Zh^<%$u3FGjHZM?>$>-^je)ak=L>Dk(P5Q zIhQWT`EhxQEi-wp*o^?d9RTSZAan^3P5>+(vw4LS=TeiVt{2PdR#ns2)@$#oMOE9X z>I3s|&+dY*SL&tGq#i!I2CiCrU$1QHYpdESY}nlmyFKhz+xw>7Z}-%m_0criJ^Yh- z(AB4^QK4G4IV?B2HPg_nx@mY@CNzTews~k+16#8kBel`*tPdx5`da;SZVO&+!Lz;$& zfrF%^{mFLoeG`JS1&-z2h;b5xL^1Rs58ycZWtatm>BLN^Bd;{7a&z2c80}<`_xc4BHp2%!^0@n9ey|p zfO|+!cOI0@R?o7ny?*RP^<}J7tZXv<7$IL22Tkl!hl}EO!Qnh77(vTA=whg+JAuIU zwYURKfnt+@pI8BKqU~^rb2irxv&oVTZi11G>`6%els;_G-vRP$MMMG>zqbM5yik(K z7TAqPD3KhLd~+hB`20~~xT?`tK*=%}5=y@E1*3$L|55!}YWf6Yn0g5dFr2NoGWo2K zHMh5Zp$E6Z{#pA=Z^=AS)SJ{>;!r^0y_My1vir#wjFR2FvpY*>AEWi z>QCc@?yb0U#?bV;UubcUovoH~+TSO2ZUFBR;RzW%E1nPW3Y*PeZrR`8EA&UNoZxTU J?@bnc{{fhM?I{2N literal 0 HcmV?d00001 diff --git a/opt/fsext/lib/winfsp-x86.lib b/opt/fsext/lib/winfsp-x86.lib new file mode 100644 index 0000000000000000000000000000000000000000..9e47ca0937409b48ac56217a3879a2a2d2717a82 GIT binary patch literal 2312 zcmcIlPfr>_6#p&YpOU7be_}keDQ!$_F9^6GBu%rnYDz>T2=SyVWl{H_OITXysaFrZ zd-K!}(W4)rhaUO?{0x48+V^&M*ijdX#!fQx{>+PyQT?<<9J zb-ki@&BI;01zj)IipA^m`05(C)71~P(yG3+SY3p^Vz*Z8X0KCe?wNL{*)F%O&!*9A zYbtGK9<=nK7PPu-*=BF8-r6vYs#P-$EhjAunv~XTnumtfwX2q6SFU&VmwQ?&9k9V5 z%NyrA<>z~x5`G>6rpJI12`3Z4)Fg03oeF^n#xM>AA&(0W&z5v9ITw<8&>?P9&=HE$ zFJDjv*KYrSq*>FWb zBj%eBJgOn~E@2w=PJJdVrk)Vdaml*cUJ44H!qv#b_j;5$8Lh z2pZNwi$Xo#R+Nhi;f_~u^eOqh zD->n~2;=-K^Svx8{9esEXNwH|2c+A5<2q(kuZ&mxz9hd2y(9b=2R!DIOP?JLIoX9^ Tk8|Xa|2^5`=78VY_lf9VtF!UB literal 0 HcmV?d00001 diff --git a/opt/fsext/lib/winfsp.impdef b/opt/fsext/lib/winfsp.impdef new file mode 100644 index 00000000..de283148 --- /dev/null +++ b/opt/fsext/lib/winfsp.impdef @@ -0,0 +1,6 @@ +// tools\impdef.bat lib\winfsp.impdef lib\winfsp-x64.lib +// tools\impdef.bat lib\winfsp.impdef lib\winfsp-x86.lib + +#define FSP_DDI_DEF(RetType, Name, ...) __declspec(dllexport) RetType NTAPI Name ( __VA_ARGS__ ) {} +#include +#include diff --git a/tools/impdef.bat b/tools/impdef.bat new file mode 100644 index 00000000..60e13df5 --- /dev/null +++ b/tools/impdef.bat @@ -0,0 +1,44 @@ +@echo off + +setlocal +setlocal EnableDelayedExpansion + +if X%1==X goto usage +if X%2==X goto usage +set infile=%1 +set infile=%infile:/=\% +set outfile=%2 +set outfile=%outfile:/=\% +set workdir=!infile!.work +set workbase=!workdir!\%~n1 +set outarch=%~n2 +set outarch=%outarch:~-3% + +set arch=x64 +set cdef=/D_AMD64_ +if /i X%outarch%==Xx86 set arch=x86 +if /i X%outarch%==Xx86 set cdef=/D_X86_ + +call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" !arch! +set INCLUDE=%~dp0..\opt\fsext\inc;%~dp0..\inc;!WindowsSdkDir!Include\!WindowsSDKVersion!km\crt;!WindowsSdkDir!Include\!WindowsSDKVersion!km;!WindowsSdkDir!Include\!WindowsSDKVersion!km\shared;!INCLUDE! + +if exist !workdir! rmdir /s/q !workdir! +mkdir !workdir! + +type !infile! >>!workbase!.c +cl /LD /Fe!workbase!.sys /Fo!workbase!.obj !cdef! /D_KERNEL_MODE /wd4716 !workbase!.c +if errorlevel 1 goto fail + +copy !workbase!.lib !outfile! +if errorlevel 1 goto fail + +rmdir /s/q !workdir! + +exit /b 0 + +:fail +exit /b 1 + +:usage +echo usage: impdef.bat infile.impdef outfile.lib 1>&2 +exit /b 2