# HG changeset patch # User Sebastien Jodogne # Date 1608198371 -3600 # Node ID c601f48c7c8016e87f024c5652e5c5e765722c29 # Parent bda867e036f3d555403f34980ce423133147aca0 Explicit error log if trying to load a 32bit (resp. 64bit) plugin into a 64bit (resp. 32bit) version of Orthanc diff -r bda867e036f3 -r c601f48c7c80 NEWS --- a/NEWS Mon Dec 14 17:33:17 2020 +0100 +++ b/NEWS Thu Dec 17 10:46:11 2020 +0100 @@ -6,6 +6,8 @@ * ZIP archives containing DICOM files can be uploaded using WebDAV * New config option "MallocArenaMax" to control memory usage on GNU/Linux +* Explicit error log if trying to load a 32bit (resp. 64bit) plugin into + a 64bit (resp. 32bit) version of Orthanc REST API -------- diff -r bda867e036f3 -r c601f48c7c80 OrthancFramework/Sources/SharedLibrary.cpp --- 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__)