与Windows投影文件系统DLL / LIB链接

时间:2018-12-10 06:53:47

标签: c++ windows visual-studio dll projfs

我正在尝试构建RegFS sample以便更好地了解Windows Projected File System。我的代码在构建时没有警告,但出现了动态链接错误。下面是一个示例错误,下面是导致该错误的代码。

“过程入口点PrjWritePlaceholderInfo不在动态链接库中。”

HRESULT VirtualizationInstance::WritePlaceholderInfo(
    LPCWSTR relativePath,
    PRJ_PLACEHOLDER_INFO* placeholderInfo,
    DWORD length
) {
    return PrjWritePlaceholderInfo(
        _instanceHandle,
        relativePath,
        placeholderInfo,
        length);
}

我确定链接时做错了什么。在[项目属性页]>链接器>输入下,将“ ProjectedFSlib.lib”添加到“其他依赖项”之前。

这是我第一次将Visual Studio与默认情况下未链接的库一起使用,而且我一直找不到有关如何在Windows SDK中定位和链接库的说明。

感谢您的帮助!

编辑:

DUMPBIN输出为:

Dump of file ProjectedFSLib.lib

File Type: LIBRARY

 Exports

   ordinal    name

              PrjAllocateAlignedBuffer
              PrjClearNegativePathCache
              PrjCloseFile
              PrjCommandCallbacksInit
              PrjCompleteCommand
              PrjConfigureVolume
              PrjConvertDirectoryToPlaceholder
              PrjCreatePlaceholderAsHardlink
              PrjDeleteFile
              PrjDetachDriver
              PrjDoesNameContainWildCards
              PrjFileNameCompare
              PrjFileNameMatch
              PrjFillDirEntryBuffer
              PrjFreeAlignedBuffer
              PrjGetOnDiskFileState
              PrjGetVirtualizationInstanceIdFromHandle
              PrjGetVirtualizationInstanceInfo
              PrjMarkDirectoryAsPlaceholder
              PrjOpenFile
              PrjReadFile
              PrjStartVirtualizationInstance
              PrjStartVirtualizationInstanceEx
              PrjStartVirtualizing
              PrjStopVirtualizationInstance
              PrjStopVirtualizing
              PrjUpdateFileIfNeeded
              PrjUpdatePlaceholderIfNeeded
              PrjWriteFile
              PrjWriteFileData
              PrjWritePlaceholderInfo
              PrjWritePlaceholderInformation
              PrjpReadPrjReparsePointData

Summary

      D8 .debug$S
      14 .idata$2
      14 .idata$3
       8 .idata$4
       8 .idata$5
      14 .idata$6

可执行文件的DUMPBIN导入结果为:

Dump of file regfs.exe

File Type: EXECUTABLE IMAGE

  Section contains the following imports:

    PROJECTEDFSLIB.dll
             14006D2A0 Import Address Table
             14006D9E0 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                          1E PrjWritePlaceholderInfo
                          1D PrjWriteFileData
                          19 PrjStopVirtualizing
                          17 PrjStartVirtualizing
                           C PrjFileNameMatch
                           D PrjFillDirEntryBuffer
                           E PrjFreeAlignedBuffer
                           0 PrjAllocateAlignedBuffer
                          11 PrjGetVirtualizationInstanceInfo
                          12 PrjMarkDirectoryAsPlaceholder
                           B PrjFileNameCompare

    KERNEL32.dll
             14006D098 Import Address Table
             14006D7D8 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                         389 IsProcessorFeaturePresent
                         382 IsDebuggerPresent
                         466 RaiseException
                         1B1 FreeLibrary
                          BA CreateDirectoryW
                         116 DeleteFileW
                         59A TerminateProcess
                         4BD RemoveDirectoryW
                         621 WriteFile
                          C2 CreateFile2
                          86 CloseHandle
                         267 GetLastError
                         3F2 MultiByteToWideChar
                         21D GetCurrentProcess
                         57B SetUnhandledExceptionFilter
                         5BC UnhandledExceptionFilter
                         4E1 RtlVirtualUnwind
                         4DA RtlLookupFunctionEntry
                         4D3 RtlCaptureContext
                         477 ReadFile
                         2B5 GetProcAddress
                         5DD VirtualQuery
                         2BB GetProcessHeap
                         60D WideCharToMultiByte
                         450 QueryPerformanceCounter
                         21E GetCurrentProcessId
                         2F0 GetSystemTimeAsFileTime
                         36C InitializeSListHead
                         352 HeapFree
                         34E HeapAlloc
                         27E GetModuleHandleW
                         2D7 GetStartupInfoW
                         222 GetCurrentThreadId

    ADVAPI32.dll
             14006D000 Import Address Table
             14006D740 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                         299 RegQueryValueExW
                         293 RegQueryInfoKeyW
                         28C RegOpenKeyExW
                         27D RegEnumValueW
                         27A RegEnumKeyExW
                         25B RegCloseKey
                         281 RegGetValueW

    ole32.dll
             14006D438 Import Address Table
             14006DB78 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                          2A CoCreateGuid

    MSVCP140D.dll
             14006D228 Import Address Table
             14006D968 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                          A5 ??1_Lockit@std@@QEAA@XZ
                          6D ??0_Lockit@std@@QEAA@H@Z
                         296 ?_Xlength_error@std@@YAXPEBD@Z
                         297 ?_Xout_of_range@std@@YAXPEBD@Z

    VCRUNTIME140D.dll
             14006D360 Import Address Table
             14006DAA0 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                          3C memcpy
                          3D memmove
                           1 _CxxThrowException
                           E __CxxFrameHandler3
                          36 _purecall
                          3B memcmp
                          21 __std_exception_copy
                          22 __std_exception_destroy
                           8 __C_specific_handler
                           9 __C_specific_handler_noexcept
                          25 __std_type_info_destroy_list
                          2E __vcrt_GetModuleFileNameW
                          2F __vcrt_GetModuleHandleW
                          31 __vcrt_LoadLibraryExW

    ucrtbased.dll
             14006D498 Import Address Table
             14006DBD8 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                         2B6 _register_thread_local_exe_atexit_callback
                          B5 _configthreadlocale
                         2CE _set_new_mode
                          4D __p__commode
                         11D _free_dbg
                         52C strcpy_s
                         528 strcat_s
                          68 __stdio_common_vsprintf_s
                         2C2 _seh_filter_dll
                          B6 _configure_narrow_argv
                         171 _initialize_narrow_environment
                         172 _initialize_onexit_table
                          9F _c_exit
                          E5 _execute_onexit_table
                          C2 _crt_atexit
                          C1 _crt_at_quick_exit
                         54B terminate
                         39C _wmakepath_s
                         3B8 _wsplitpath_s
                         564 wcscpy_s
                          A4 _cexit
                         48D getchar
                          60 __stdio_common_vfwprintf
                          35 __acrt_iob_func
                           4 _CrtDbgReport
                         567 wcslen
                         176 _invalid_parameter
                          4B __p___wargv
                          49 __p___argc
                         2CB _set_fmode
                          EA _exit
                         450 exit
                         175 _initterm_e
                         174 _initterm
                         13E _get_initial_wide_environment
                         173 _initialize_wide_environment
                          B7 _configure_wide_argv
                          5B __setusermatherr
                         2C6 _set_app_type
                         561 wcscmp
                           5 _CrtDbgReportW
                         4D8 malloc
                         2B5 _register_onexit_function
                          A1 _callnewh
                         2C3 _seh_filter_exe

  Summary

        1000 .00cfg
        1000 .data
        2000 .idata
        1000 .msvcjmc
        5000 .pdata
       17000 .rdata
        1000 .reloc
        1000 .rsrc
       37000 .text
       18000 .textbss

很明显,它从PROJECTEDFSLIB.dll导入了所有必需的功能

2 个答案:

答案 0 :(得分:1)

Projected FS 仍然是 Windows 的可选功能,需要手动安装才能使用。转到控制面板 -> 程序和功能 -> 打开或关闭 Windows 功能。在该可选功能列表中,向下滚动到“Windows 投影文件系统”并确保在那里启用它。只有在完成之后,您的 system32 目录中才会显示 ProjectedFSLib.dll。

可能还值得注意的是,该 DLL 似乎只有 x64 版本,因此如果您正在构建 x86 程序,这可能是您无法与该 DLL 动态链接的原因。

>

答案 1 :(得分:0)

将ProjectedFSLib.lib添加到您的库中或添加:

#pragma comment(lib, "ProjectedFSLib.lib")
代码中的

行。另外,请确保您使用的SDK版本是10.0.17763.0。如果您使用的是mingw,那么如果该库尚未提供,也不会令我感到惊讶。