Mercurial > hg > orthanc
diff OrthancFramework/Sources/SharedLibrary.cpp @ 4373:c601f48c7c80
Explicit error log if trying to load a 32bit (resp. 64bit) plugin into a 64bit (resp. 32bit) version of Orthanc
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 17 Dec 2020 10:46:11 +0100 |
parents | b30a8de92ad9 |
children | d9473bd5ed43 |
line wrap: on
line diff
--- a/OrthancFramework/Sources/SharedLibrary.cpp Mon Dec 14 17:33:17 2020 +0100 +++ b/OrthancFramework/Sources/SharedLibrary.cpp Thu Dec 17 10:46:11 2020 +0100 @@ -47,7 +47,23 @@ if (handle_ == NULL) { LOG(ERROR) << "LoadLibrary(" << path_ << ") failed: Error " << ::GetLastError(); - throw OrthancException(ErrorCode_SharedLibrary); + + if (::GetLastError() == ERROR_BAD_EXE_FORMAT && + sizeof(void*) == 4) + { + throw OrthancException(ErrorCode_SharedLibrary, + "You are most probably trying to load a 64bit plugin into a 32bit version of Orthanc"); + } + else if (::GetLastError() == ERROR_BAD_EXE_FORMAT && + sizeof(void*) == 8) + { + throw OrthancException(ErrorCode_SharedLibrary, + "You are most probably trying to load a 32bit plugin into a 64bit version of Orthanc"); + } + else + { + throw OrthancException(ErrorCode_SharedLibrary); + } } #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__)