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.

89 lines
2.6 KiB

  1. //***************************************************************************
  2. //
  3. // DELAYLOADHANDLER.CPP
  4. //
  5. // Module: Delay load handler functions
  6. //
  7. // Purpose: When delay loaded libraries either fail to load, or functions
  8. // in them are not found, this handler is called as a result of
  9. // the //DELAYLOAD linker specification.
  10. //
  11. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  12. //
  13. //***************************************************************************
  14. #include <stdafx.h>
  15. #include <delayimp.h>
  16. // Skeleton DliHook function that does nothing interesting
  17. FARPROC WINAPI DliHook(
  18. unsigned dliNotify,
  19. PDelayLoadInfo pdli)
  20. {
  21. FARPROC fp = NULL; // Default return value
  22. // NOTE: The members of the DelayLoadInfo structure pointed
  23. // to by pdli shows the results of progress made so far.
  24. switch (dliNotify)
  25. {
  26. case dliStartProcessing:
  27. // Called when __delayLoadHelper attempts to find a DLL/function
  28. // Return 0 to have normal behavior, or non-0 to override
  29. // everything (you will still get dliNoteEndProcessing)
  30. break;
  31. case dliNotePreLoadLibrary:
  32. // Called just before LoadLibrary
  33. // Return NULL to have __delayLoadHelper call LoadLibary
  34. // or you can call LoadLibrary yourself and return the HMODULE
  35. fp = (FARPROC)(HMODULE) NULL;
  36. break;
  37. case dliFailLoadLib:
  38. // Called if LoadLibrary fails
  39. // Again, you can call LoadLibary yourself here and return an HMODULE
  40. // If you return NULL, __delayLoadHelper raises the
  41. // ERROR_MOD_NOT_FOUND exception
  42. fp = (FARPROC)(HMODULE) NULL;
  43. break;
  44. case dliNotePreGetProcAddress:
  45. // Called just before GetProcAddress
  46. // Return NULL to have __delayLoadHelper call GetProcAddress
  47. // or you can call GetProcAddress yourself and return the address
  48. fp = (FARPROC) NULL;
  49. break;
  50. case dliFailGetProc:
  51. // Called if GetProcAddress fails
  52. // Again, you can call GetProcAddress yourself here and return an address
  53. // If you return NULL, __delayLoadHelper raises the
  54. // ERROR_PROC_NOT_FOUND exception
  55. fp = (FARPROC) NULL;
  56. break;
  57. case dliNoteEndProcessing:
  58. // A simple notification that __delayLoadHelper is done
  59. // You can examine the members of the DelayLoadInfo structure
  60. // pointed to by pdli and raise an exception if you desire
  61. break;
  62. }
  63. return(fp);
  64. }
  65. // Tell __delayLoadHelper to call my hook function
  66. PfnDliHook __pfnDliNotifyHook = DliHook;
  67. PfnDliHook __pfnDliFailureHook = DliHook;