Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.6 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. dload.c
  5. Abstract:
  6. This file implements delay-load error handling for QMGR.DLL
  7. --*/
  8. #include "qmgrlib.h"
  9. #include <delayimp.h>
  10. #include "dload.tmh"
  11. FARPROC
  12. WINAPI
  13. BITS_DelayLoadFailureHook(
  14. UINT unReason,
  15. PDelayLoadInfo pDelayInfo
  16. )
  17. /*
  18. DANGER DANGER DANGER
  19. Normally a delayload handler provides a thunk for each import, each
  20. of which returns an appropriate error code.
  21. This implementation DOES NOT provide the usual thunks, because VSSAPI.DLL
  22. exports mangled C++ functions including an object constructor. There is
  23. no good way to mimic the member function calling convention using C-style
  24. pointers to functions.
  25. We wouldn't even bother with delayload, except that this code must work on Win2000
  26. which does not have VSSAPI.DLL. So the manager code must verify that LoadLibrary
  27. succeeds before making any calls that could result in a call to the delay-loaded
  28. functions.
  29. */
  30. {
  31. // For a failed LoadLibrary, we return a bogus HMODULE of -1 to force
  32. // DLOAD call again with dliFailGetProc
  33. LogError("delayload handler called: reason %d", unReason);
  34. if (dliFailLoadLib == unReason)
  35. {
  36. ASSERT( 0 );
  37. return (FARPROC)-1;
  38. }
  39. if (dliFailGetProc == unReason)
  40. {
  41. // The loader is asking us to return a pointer to a procedure.
  42. LogError("DLL: %s, proc: %s", pDelayInfo->szDll, pDelayInfo->dlp.szProcName);
  43. ASSERT( 0 );
  44. return NULL;
  45. }
  46. return NULL;
  47. }