ZBrush 2024 FileExecute Issue
-
I have a custom ZBrush plugin that I have been using successfully with ZBrush 2022 and 2023. The main functionality is contained within a DLL and my ZScript uses the FileExecute command to call into it. My DLL has some directly linked colocated dependencies as well as some dynamically loaded internal and external dependencies.
Starting with 2024, the dependencies are no longer loaded when running FileExecute. If I manually call FileExecute on the direct dependencies themselves first, the plugin is able to load correctly. For the dynamically loaded dependencies, C++ calls to
LoadLibrary
with a relative path to load the dependency from the system search paths fails. Passing absolute paths does work, but these paths can vary between users. Any information about what has changed with DLL loading in 2024 or advice for how to handle this would be greatly appreciated! -
Hi @blizz_nsm ,
Welcome to the Maxon developers forum and its community, it is great to have you with us!
Getting Started
Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.
- Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
- Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
- Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.
It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: Asking Questions.
About your First Question
Using the FileExecute is indeed the intended way to load your plugin. However, without deeper investigation it's hard to say whether such change in behavior is expected or should be considered as a bug.
As a result of my discussion with one of our devs, there could have been some core changes that could lead to such behavior change. If that's the case, it's highly unlikely to be changed. If you'd like to proceed further with this issue, I'd kindly ask you to report the issue to our Support Center (you can mention our discussion here). Alternatively, you can add reproduction steps for the issue directly here. I picture it as a zip-folder with the hello world project that compiles in the dll + the ZScript you're using to load this dll; please also don't forget to include the specific ZBrush versions, where the issue is reproducible, as well as your system info - operating system version and CPU architecture.
Anyway, the developer I mentioned above suggested some workaround. Namely, you can create another dll without any dependencies (let's call it "resolver"), which purpose is to search for the full paths of the dependencies of your plugin (e.g. by searching in the environment PATH variable). This way your ZScript can first execute the resolver to retrieve all your dependency absolute paths, which you could then directly load first before loading your plugin dll. Please note that we have neither confirmed your issue (as you haven't yet shared the repro steps), nor haven't we double checked the above-mentioned workaround.
Cheers,
Ilia -
Thank you for the detailed reply, @i_mazlov!
I was unable to determine the root cause of the issue, however I was able to work around it by preloading direct dependencies with a
FileExecute
call and using theSearchPath
Windows function to locate the runtime dependency DLLs and pass the absolute paths to LoadLibrary (I'm aware this is not recommended, but should be fine for this internally used plugin).I couldn't find anything in the newly added Maxon options that appeared to affect the loading behavior. My only remaining theory is that the new licensing process is indirectly triggering this behavior:
LoadLibrary function returns STATUS_DLL_NOT_FOUND error on impersonate thread in Windows
https://learn.microsoft.com/en-us/troubleshoot/windows-client/setup-upgrade-and-drivers/loadlibrary-function-returns-status-dll-not-found-error-impersonate-threadThanks again!
Nick