inc: winfsp.h: FspLoad

This commit is contained in:
Bill Zissimopoulos
2017-01-31 15:56:00 -08:00
parent 06f6c192ed
commit acf6ce1008
5 changed files with 56 additions and 137 deletions

View File

@ -24,7 +24,7 @@
* file names and security.
*/
#include <windows.h>
#include <winfsp/winfsp.h>
#include <fcntl.h>
#include <fuse.h>
#include "winposix.h"
@ -523,44 +523,7 @@ static int maperror(int winerrno)
}
}
static NTSTATUS WinFspLoad(VOID)
long WinFspLoad(void)
{
#if defined(_WIN64)
#define FSP_DLLNAME "winfsp-x64.dll"
#else
#define FSP_DLLNAME "winfsp-x86.dll"
#endif
#define FSP_DLLPATH "bin\\" FSP_DLLNAME
WCHAR PathBuf[MAX_PATH];
DWORD Size;
HKEY RegKey;
LONG Result;
HMODULE Module;
Module = LoadLibraryW(L"" FSP_DLLNAME);
if (0 == Module)
{
Result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\WinFsp",
0, KEY_READ | KEY_WOW64_32KEY, &RegKey);
if (ERROR_SUCCESS == Result)
{
Size = sizeof PathBuf - sizeof L"" FSP_DLLPATH + sizeof(WCHAR);
Result = RegGetValueW(RegKey, 0, L"InstallDir",
RRF_RT_REG_SZ, 0, PathBuf, &Size);
RegCloseKey(RegKey);
}
if (ERROR_SUCCESS != Result)
return STATUS_OBJECT_NAME_NOT_FOUND;
RtlCopyMemory(PathBuf + (Size / sizeof(WCHAR) - 1), L"" FSP_DLLPATH, sizeof L"" FSP_DLLPATH);
Module = LoadLibraryW(PathBuf);
if (0 == Module)
return STATUS_DLL_NOT_FOUND;
}
return STATUS_SUCCESS;
#undef FSP_DLLNAME
#undef FSP_DLLPATH
return FspLoad();
}