wininet: Call WSAStartup/WSACleanup to mime the Windows behavior

Thomas Faber thomas.faber at reactos.org
Fri Jul 4 07:43:09 CDT 2014


Hey Bruno,

> +static void init_ws2_32(void)
> +{
> +    static int once;
> +    if (once++) return;
> +    hws2_32 = GetModuleHandleA("ws2_32.dll");
> +    pWSAStartup = (void *)GetProcAddress(hws2_32, "WSAStartup");
> +    pWSACleanup = (void *)GetProcAddress(hws2_32, "WSACleanup");
> +}
> +
> +static void free_ws2_32(void)
> +{
> +    FreeLibrary(hws2_32);
> +}

GetModuleHandle doesn't increase the reference count so you probably
shouldn't call FreeLibrary.


> +    /* initialize winsock DLL here as expected by some broken applications */
> +    if (!winsock_init++)
> +    {
> +        char buffer[128];
> +        init_ws2_32();
> +        pWSAStartup(MAKEWORD( 1, 1 ), buffer);
> +    }

I believe Windows initializes with version 2. At least that's what my
old test says (line 105):

https://code.reactos.org/browse/reactos/trunk/rostests/apitests/wininet/InternetOpen.c?hb=true
(free to use under LGPL... I can make it explicit in the source file,
 or help with getting it in Winetest format if desired)

By the way, the same applies to winhttp in case you're interested:
https://code.reactos.org/browse/reactos/trunk/rostests/apitests/winhttp/WinHttpOpen.c?hb=true


Thanks!
-Thomas



More information about the wine-devel mailing list