Source code of Windows XP (NT5)
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.

87 lines
1.6 KiB

  1. /*
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. InjectDll.cpp
  5. Abstract:
  6. This Shim inject given DLLs on the command line at
  7. SHIM_STATIC_DLLS_INITIALIZED so that if people try to load
  8. dynamic library in their own DllInit, no dependencies occur
  9. because the dynamic libraries are in place.
  10. One problem was: Visio 2000 call LoadLibrary(VBE6.DLL) which
  11. (shame on us) loads MSI.DLL in its DllInit.
  12. History:
  13. 06/11/2001 pierreys Created
  14. */
  15. #include "precomp.h"
  16. IMPLEMENT_SHIM_BEGIN(InjectDll)
  17. #include "ShimHookMacro.h"
  18. APIHOOK_ENUM_BEGIN
  19. APIHOOK_ENUM_END
  20. BOOL
  21. NOTIFY_FUNCTION(
  22. DWORD fdwReason
  23. )
  24. {
  25. switch (fdwReason)
  26. {
  27. case SHIM_STATIC_DLLS_INITIALIZED:
  28. CSTRING_TRY
  29. {
  30. int i, iDllCount;
  31. CString *csArguments;
  32. CString csCl(COMMAND_LINE);
  33. CStringParser csParser(csCl, L";");
  34. iDllCount = csParser.GetCount();
  35. csArguments = csParser.ReleaseArgv();
  36. for (i=0; i<iDllCount; i++)
  37. {
  38. if (LoadLibrary(csArguments[i].Get())==NULL)
  39. {
  40. LOGN(eDbgLevelError, "Failed to load %S DLL", csArguments[i].Get());
  41. return(FALSE);
  42. }
  43. }
  44. }
  45. CSTRING_CATCH
  46. {
  47. return FALSE;
  48. }
  49. break;
  50. }
  51. return TRUE;
  52. }
  53. HOOK_BEGIN
  54. CALL_NOTIFY_FUNCTION
  55. HOOK_END
  56. IMPLEMENT_SHIM_END