Под виртуальной машиной VMWare — Windows10 отказывается грузится одна из моих DLL по 126 ошибке.
Путь к DLL правильный судя по логу.
Dependency Walker не видит пропущенных DLL на самом верхнем уровне (кроме вида API-MS-WIN-CORE-*.DLL в системных DLL типа KERNEL32.DLL но другие DLL c такой же картиной грузятся — так что это не должно влиять).
Что еще может быть?
Здравствуйте, turbocode, Вы писали:
T>Под виртуальной машиной VMWare — Windows10 отказывается грузится одна из моих DLL по 126 ошибке. T>Путь к DLL правильный судя по логу. T>Dependency Walker не видит пропущенных DLL на самом верхнем уровне (кроме вида API-MS-WIN-CORE-*.DLL в системных DLL типа KERNEL32.DLL но другие DLL c такой же картиной грузятся — так что это не должно влиять). T>Что еще может быть?
Точно, оказалось что она подчиненную DLL ищет рядом с .EXE, а не в той же папке где основная DLL находится.
Это можно как то регулировать? Хочу чтобы все DLL были в Bin, а не рядом с EXE?
То есть так:
Здравствуйте, turbocode, Вы писали:
T>Под виртуальной машиной VMWare — Windows10 отказывается грузится одна из моих DLL по 126 ошибке. T>Что еще может быть?
Здравствуйте, turbocode, Вы писали:
R>>может ProcMon-ом прогнать?
T>Точно, оказалось что она подчиненную DLL ищет рядом с .EXE, а не в той же папке где основная DLL находится. T>Это можно как то регулировать? Хочу чтобы все DLL были в Bin, а не рядом с EXE? T>То есть так: T>
T>Root
T> Bin
T> test.dll
T> test2.dll
T> test.exe
T>
T>А сейчас оно требует так: T>
T>Root
T> Bin
T> test.dll
T> test.exe
T> test2.dll
T>
The first directory searched is the directory containing the image file used to create the calling process (for more information, see the CreateProcess function). Doing this allows private dynamic-link library (DLL) files associated with a process to be found without adding the process's installed directory to the PATH environment variable. If a relative path is specified, the entire relative path is appended to every token in the DLL search path list. To load a module from a relative path without searching any other path, use GetFullPathName to get a nonrelative path and call LoadLibrary with the nonrelative path. For more information on the DLL search order, see Dynamic-Link Library Search Order.
The search path can be altered using the SetDllDirectory function. This solution is recommended instead of using SetCurrentDirectory or hard-coding the full path to the DLL.
After calling SetDllDirectory, the standard DLL search path is:
The directory from which the application loaded.
The directory specified by the lpPathName parameter.
The system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is System32.
The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched. The name of this directory is System.
The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
The directories that are listed in the PATH environment variable.
Здравствуйте, turbocode, Вы писали:
IID>>MSDN "LoadLibrary" -> Remarks -> Dynamic-Link Library Search Order T>SetDllDirectory нужно звать в .EXE или в главной .DLL?
насколько я понимаю, в Вашем случае достаточно вызвать в любом месте ДО вызова LoadLibrary для подчиненной dll:
The SetDllDirectory function affects all subsequent calls to the LoadLibrary and LoadLibraryEx functions. It also effectively disables safe DLL search mode while the specified directory is in the search path.
T>Что еще может быть?
Например, проблемы с манифестом. Надо посмотреть в системные логи, не уверен насчет нынешних виндов, но семерка раньше писала в логи такие проблемы.
Как много веселых ребят, и все делают велосипед...
R>The SetDllDirectory function affects all subsequent calls to the LoadLibrary and LoadLibraryEx functions. It also effectively disables safe DLL search mode while the specified directory is in the search path.
Функция SetDllDirectory определена в Windows 8.1 SDK, а сборщик у меня под Windows7 и она не видит определения такой функции, ессно.
А нужно чтобы работало от Windows7 до Windows 10.
Как такое обойти?
R>>The SetDllDirectory function affects all subsequent calls to the LoadLibrary and LoadLibraryEx functions. It also effectively disables safe DLL search mode while the specified directory is in the search path.
T>Функция SetDllDirectory определена в Windows 8.1 SDK, а сборщик у меня под Windows7 и она не видит определения такой функции, ессно. T>А нужно чтобы работало от Windows7 до Windows 10. T>Как такое обойти?
Minimum supported client
Windows Vista, Windows XP with SP1 [desktop apps only]
Header
Winbase.h (include Windows.h)
все должно работать от XP до 10
не забывайте про SetDllDirectoryW/A
UPD2.
даже если включить режим "не верю МСДН", то на моей 7-ке в kernel32.dll есть эксп функции SetDllDirectoryW и SetDllDirectoryA
что-то вы делаете не так
R>>The SetDllDirectory function affects all subsequent calls to the LoadLibrary and LoadLibraryEx functions. It also effectively disables safe DLL search mode while the specified directory is in the search path.
R>версия VS?
2015 R>на крайняк можно в наглую через GetProcAddress подрубить нужную SetDllDirectory из kernel32.dll
не хотелось бы. R>UPD. может Вы его сами вручную где-то определили _WIN32_WINNT как 0x0501 для boost::asio например?
Ничего не менял, boost-а нету.
Здравствуйте, turbocode, Вы писали:
R>>версия VS? T>2015
может Platform Toolset выбрали для XP?
R>>на крайняк можно в наглую через GetProcAddress подрубить нужную SetDllDirectory из kernel32.dll T>не хотелось бы.
а мне часто только так и приходится делать т.к. частенько завишу только от ntdll
Здравствуйте, turbocode, Вы писали:
R>>UPD. может Вы его сами вручную где-то определили _WIN32_WINNT как 0x0501 для boost::asio например? T>Ничего не менял, boost-а нету.
Кроме того, возможно, поможет флаг LOAD_WITH_ALTERED_SEARCH_PATH:
Note that the standard search strategy and the alternate search strategy specified by LoadLibraryEx with LOAD_WITH_ALTERED_SEARCH_PATH differ in just one way: The standard search begins in the calling application's directory, and the alternate search begins in the directory of the executable module that LoadLibraryEx is loading.
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.#endif
Поменял на 0x0502 и все скомпилилось.
Видимо сам проект еще был создан во времена WindowsXP.