Skip to content

kernelbase: Implement flag validation in `LoadLibraryEx()` to work like in Win10

Dāvis Mosāns (davispuh) requested to merge davispuh/wine:loadlib into master

While debugging League of Legends I noticed that LoadLibraryEx() is invoked with binary filename (non-text) and non-NULL hFile.

In Windows such call would return NULL with LastError set as ERROR_INVALID_PARAMETER but current Wine implementation would try to proceed ahead.

I don't know if this is intentional trick to mess up debugging/reversing tools or if we have some memory corruption before that overwrites filename buffer. But then I can't imagine how hFile could have gotten corrupted since shouldn't that be simple static value in register...

Having this MR causes very noticeable difference in LoL:

  • without it - process deadlocks
  • with it - no deadlock

Also while looking at this, I tried a lot of different flag combinations on Windows 10 and here I implemented so it works exactly like that.

I also implemented test case for non-NULL hFile but I didn't bother for other flags since I don't know if we even care about those.

Merge request reports

Loading