comparison 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
comparison
equal deleted inserted replaced
4372:bda867e036f3 4373:c601f48c7c80
45 #if defined(_WIN32) 45 #if defined(_WIN32)
46 handle_ = ::LoadLibraryA(path_.c_str()); 46 handle_ = ::LoadLibraryA(path_.c_str());
47 if (handle_ == NULL) 47 if (handle_ == NULL)
48 { 48 {
49 LOG(ERROR) << "LoadLibrary(" << path_ << ") failed: Error " << ::GetLastError(); 49 LOG(ERROR) << "LoadLibrary(" << path_ << ") failed: Error " << ::GetLastError();
50 throw OrthancException(ErrorCode_SharedLibrary); 50
51 if (::GetLastError() == ERROR_BAD_EXE_FORMAT &&
52 sizeof(void*) == 4)
53 {
54 throw OrthancException(ErrorCode_SharedLibrary,
55 "You are most probably trying to load a 64bit plugin into a 32bit version of Orthanc");
56 }
57 else if (::GetLastError() == ERROR_BAD_EXE_FORMAT &&
58 sizeof(void*) == 8)
59 {
60 throw OrthancException(ErrorCode_SharedLibrary,
61 "You are most probably trying to load a 32bit plugin into a 64bit version of Orthanc");
62 }
63 else
64 {
65 throw OrthancException(ErrorCode_SharedLibrary);
66 }
51 } 67 }
52 68
53 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__) 69 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__)
54 70
55 /** 71 /**