diff --git a/build/VStudio/winfsp_dll.vcxproj b/build/VStudio/winfsp_dll.vcxproj index 15938c0b..cc2cec8a 100644 --- a/build/VStudio/winfsp_dll.vcxproj +++ b/build/VStudio/winfsp_dll.vcxproj @@ -109,6 +109,8 @@ Windows true $(OutDir)$(TargetFileName).pdb + true + $(OutDir)$(TargetFileName).map @@ -126,6 +128,8 @@ Windows true $(OutDir)$(TargetFileName).pdb + true + $(OutDir)$(TargetFileName).map @@ -147,6 +151,8 @@ true true $(OutDir)$(TargetFileName).pdb + true + $(OutDir)$(TargetFileName).map @@ -168,6 +174,8 @@ true true $(OutDir)$(TargetFileName).pdb + true + $(OutDir)$(TargetFileName).map diff --git a/src/dll/library.c b/src/dll/library.c index 721e3cbc..80e1517c 100644 --- a/src/dll/library.c +++ b/src/dll/library.c @@ -21,3 +21,11 @@ BOOL WINAPI DllMain(HINSTANCE Instance, DWORD Reason, PVOID Reserved) return TRUE; } + +/* see comments in library.h */ +#if defined(WINFSP_DLL_NODEFAULTLIB) +BOOL WINAPI _DllMainCRTStartup(HINSTANCE Instance, DWORD Reason, PVOID Reserved) +{ + return DllMain(Instance, Reason, Reserved); +} +#endif diff --git a/src/dll/library.h b/src/dll/library.h index e19e9283..786de058 100644 --- a/src/dll/library.h +++ b/src/dll/library.h @@ -41,4 +41,35 @@ static inline VOID MemFree(PVOID Pointer) HeapFree(ProcessHeap, 0, Pointer); } +/* + * Define WINFSP_DLL_NODEFAULTLIB to eliminate dependency on the MSVCRT libraries. + * + * For this to work the following project settings must be set: + * - "C/C++ > General > SDL checks" must be empty (not "Yes" or "No"). + * - "C/C++ > Code Generation > Basic Runtime Checks" must be set to "Default" + * - "C/C++ > Code Generation > Security Check" must be disabled (/GS-). + * - "Linker > Input > Ignore All Default Libraries" must be "Yes". + */ +#if defined(WINFSP_DLL_NODEFAULTLIB) +#undef RtlFillMemory +#undef RtlMoveMemory +NTSYSAPI VOID NTAPI RtlFillMemory(VOID *Destination, DWORD Length, BYTE Fill); +NTSYSAPI VOID NTAPI RtlMoveMemory(VOID *Destination, CONST VOID *Source, DWORD Length); + +#pragma function(memcpy) +#pragma function(memset) +static inline +void *memcpy(void *dst, const void *src, size_t siz) +{ + RtlMoveMemory(dst, src, (DWORD)siz); + return dst; +} +static inline +void *memset(void *dst, int val, size_t siz) +{ + RtlFillMemory(dst, (DWORD)siz, val); + return dst; +} +#endif + #endif diff --git a/src/dll/loop.c b/src/dll/loop.c index 04737ad3..64f5626b 100644 --- a/src/dll/loop.c +++ b/src/dll/loop.c @@ -163,7 +163,8 @@ FSP_API NTSTATUS FspProduceResponse(FSP_FILE_SYSTEM *FileSystem, FSP_API NTSTATUS FspProduceResponseWithStatus(FSP_FILE_SYSTEM *FileSystem, FSP_FSCTL_TRANSACT_REQ *Request, NTSTATUS Result) { - FSP_FSCTL_TRANSACT_RSP Response = { 0 }; + FSP_FSCTL_TRANSACT_RSP Response; + memset(&Response, 0, sizeof Response); Response.Size = sizeof Response; Response.Kind = Request->Kind; Response.Hint = Request->Hint;