Unexpected LoadLibrary Failures

A few weeks ago two users reported a problem with SourceMod — it was failing to load on their Windows servers. The error message from Metamod:Source was simply this:

Plugin failed to load: ()

Of course, there should have been an error there. The code behind loading a plugin looks something like:

Select All Code:
if ((handle = LoadLibrary(plugin)) == NULL)
{
   DWORD error = GetLastError();
   char buffer[255];
 
   FormatMessage(blah, blah, error, blah);
   Print("Plugin failed to load: (%s)", buffer);
}

Clearly, there were two problems: LoadLibrary() was failing, and so was FormatMessage(). So, I changed the function to print the value of error instead of buffer, and got:

Plugin failed to load (0xc000001d)

Whoa! That’s not a normal system error code. In fact it’s the value of EXCEPTION_ILLEGAL_INSTRUCTION. From there I knew the answer: SourceMod was being compiled with SSE instructions, and the user’s processor was too old. To verify, I went to his computer’s properties and saw that he had an 800MHz AMD Duron, which lacked SSE support (according to Wikipedia).

My solution to this problem wasn’t to remove SSE instructions, but rather to alter our usage of FormatMessage(). I couldn’t find any documentation that LoadLibrary() could churn out exception codes through GetLastError(), which is odd considering that Microsoft’s MSDN is usually good about documenting such oddities. However, there is a simple workaround: If FormatMessage() fails, we now just print the original error code.

Why didn’t we disable the SSE requirement? It didn’t seem prudent to punish the 99.6% of users who had SSE support.

7 thoughts on “Unexpected LoadLibrary Failures

  1. Always coupons

    Thanks for all your valuable work on this web site. My mother enjoys making time for investigations and it’s simple to grasp why. Most of us learn all about the dynamic method you present very useful solutions on the web site and encourage participation from the others on the topic plus our own girl has been starting to learn so much. Take advantage of the rest of the new year. You have been doing a stunning job.

  2. zeze

    Hello excellent website! Does running a blog such as this take
    a lot of work? I have no understanding of computer programming
    however I had been hoping to start my own blog in the near
    future. Anyway, should you have any suggestions or techniques for new blog owners please share.
    I understand this is off subject but I simply needed to ask.

    Many thanks!

  3. Jude Reaser

    You’re so cool! I do not suppose I’ve read anything like this before. So good to find another person with genuine thoughts on this topic. Really.. many thanks for starting this up. This web site is something that’s needed on the internet, someone with a little originality!|

  4. Johnson Standford

    hello!,I like your writing very much! percentage we keep in touch more about your article on AOL? I require a specialist on this space to unravel my problem. Maybe that’s you! Having a look ahead to see you. |

  5. Ahmad

    It’s a shame you don’t have a donate button! I’d certainly donate to this fantastic blog! I suppose for now i’ll settle for bookmarking and adding your RSS feed to my Google account. I look forward to brand new updates and will share this website with my Facebook group. Talk soon!|

Comments are closed.