On Fri, Jul 4, 2014 at 9:43 AM, Thomas Faber thomas.faber@reactos.org wrote:
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.
Thanks, I misread MSDN. It says that only GetModuleHandleEx require the FreeLibrary call.
- /* 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):
I based the call in the relay log from native wininet: 0024:Call ws2_32.WSAStartup(00000101,0033e378) ret=76c16d16
https://code.reactos.org/browse/reactos/trunk/rostests/apitests/wininet/Inte... (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/WinH...
Ok, thanks for the information.
Thanks! -Thomas
Thanks again, Bruno