To describe the problems I've been having would take too long, but the the problem at the sharp end is:
LoadLibraryW fails (returns nullptr) when given a valid path.
Process Monitor records no suspicious failures, or indeed anything different from when it succeeds in loading the dll (which it can in another context).
The dll has no non-system dependencies.
...and worst of all, the Windows error code returned by GetLastError is 3221225619.
Assuming that 3221225619 is not a valid error code, what could be going so wrong that Windows doesn't even have an error code for it?
EDIT:
I think some people have wanted more details on the failure itself:
- It does not appear to be the input - it is identical in the working and failing version, and LoadLibraryW has successfully declared "file does not exist" when the input string has been mutilated. The current input has it hard-coded in, leaving little room for error.
- The dll is compiled in Release and the calling code in Debug. I've been doing this for 18 months without a problem, but you never know.
- The Process Monitor package reports about 30 internal operations running within LoadLibraryW, including CreateFile, LoadImage, RegOpenKey. These are identical for the working call and the failing call, down to the sizes of files and the memory locations.
- There's no obvious memory corruption in the C++ object calling it, and as I said, Process Monitor gives the same Base Image address in both cases.
- The failure's 100% consistent - same time, same place every time.