dll: support /NODEFAULTLIB builds

This commit is contained in:
Bill Zissimopoulos
2015-12-15 18:53:56 -08:00
parent 825f4ed2ef
commit 99b4734d74
4 changed files with 49 additions and 1 deletions

View File

@ -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