Problem opening a second window.

I have a “host” program that creates a SDL2 window, then the host loads a .dll module that creates a new thread and in it also creates a SDL2 window (a second window) with the exact same code (both the host and module use the same library that uses SDL), and it fails here https://github.com/Photosounder/rouziclib/blob/master/rouziclib/libraries/sdl.c#L491 when calling SDL_CreateWindow(), the problem seems to be in WIN_CreateWindow() when CreateWindow() returns a NULL handle and reports an error of ERROR_INVALID_PARAMETER : The parameter is incorrect. (which parameter, Microsoft can’t be bothered to tell us).

Both the host and the .dll module statically link SDL2, if that matters. When I try it with a host program that doesn’t use SDL then the module creates its window fine.