From f197601cbb206484010a8441902d6d1432b6f1f7 Mon Sep 17 00:00:00 2001 From: janwas Date: Wed, 9 Jun 2004 15:50:38 +0000 Subject: [PATCH] clean up test delayload hook. very tricky - automagically calls WSAStartup on first sockets call This was SVN commit r457. --- source/lib/sysdep/win/wsock.cpp | 53 +++++++-------------------------- 1 file changed, 10 insertions(+), 43 deletions(-) diff --git a/source/lib/sysdep/win/wsock.cpp b/source/lib/sysdep/win/wsock.cpp index bd0208dbd7..3c2fbbb08e 100755 --- a/source/lib/sysdep/win/wsock.cpp +++ b/source/lib/sysdep/win/wsock.cpp @@ -45,6 +45,7 @@ WIN_REGISTER_MODULE(wsock); static int wsock_init() { +/* char d[1024]; CHECK_ERR(WSAStartup(0x0002, d)); // want 2.0 @@ -56,7 +57,7 @@ static int wsock_init() // make sure the reference is released so BoundsChecker // doesn't complain. it won't actually be unloaded anyway - // there is at least one other reference. - +*/ return 0; } @@ -77,51 +78,17 @@ uint16_t htons(uint16_t s) - - - -#pragma comment(lib, "delayimp.lib") - #include -FARPROC WINAPI MSJCheezyDelayLoadHook(unsigned dliNotify, PDelayLoadInfo pdli ) +static FARPROC WINAPI delay_load_hook(unsigned dliNotify, PDelayLoadInfo pdli) { - // Display which type of notification it is - switch( dliNotify ) - { - case dliStartProcessing: - printf( "dliStartProcessing " ); - break; - - case dliNotePreLoadLibrary: - printf( "dliNotePreLoadLibrary " ); - break; - - case dliNotePreGetProcAddress: - printf( "dliNotePreGetProcAddress" ); - break; - - case dliNoteEndProcessing: - printf( "dliNoteEndProcessing " ); - break; - } + if(dliNotify == dliNoteEndProcessing && !strncmp(pdli->szDll, "ws2_32", 6)) + { + char d[1024]; + WSAStartup(0x0002, d); // want 2.0 + } - // Display the DLL name and the HMODULE - printf( " %s(%08P) -> ", pdli->szDll, pdli->hmodCur ); - - // Display the API ordinal or API name, as appropriate - if ( pdli->dlp.fImportByName ) - printf( " %s", pdli->dlp.szProcName ); - else - printf( " ordinal:%u", pdli->dlp.dwOrdinal ); - - printf( "\n" ); - - return 0; // Make sure __delayLoadHelper doesn't think we did something! + return 0; } -// -// Override the standard definition of __pfnDliNotifyHook that's part of -// DELAYHLP.LIB -// -PfnDliHook __pfnDliNotifyHook = MSJCheezyDelayLoadHook; +ExternC PfnDliHook __pfnDliNotifyHook2 = delay_load_hook;