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.

109 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. ResumeWriter3.cpp
  5. Abstract:
  6. The setup of this app fails to register the OCX'es as it
  7. tries loading the DLL's with a hardcoded 'system' path.
  8. Corrected the path to the 'system32' path.
  9. Notes:
  10. This is specific to this app.
  11. History:
  12. 05/22/2001 prashkud Created
  13. --*/
  14. #include "precomp.h"
  15. IMPLEMENT_SHIM_BEGIN(ResumeWriter3)
  16. #include "ShimHookMacro.h"
  17. APIHOOK_ENUM_BEGIN
  18. APIHOOK_ENUM_ENTRY(LoadLibraryA)
  19. APIHOOK_ENUM_END
  20. WCHAR g_wszSystemDir[MAX_PATH];
  21. /*++
  22. Hooks LoadLibraryA and changes the path that contains 'system' in it
  23. to the 'system32.
  24. --*/
  25. HMODULE
  26. APIHOOK(LoadLibraryA)(
  27. LPCSTR lpFileName
  28. )
  29. {
  30. CSTRING_TRY
  31. {
  32. // Bad string pointers can cause failures in CString.
  33. if (!IsBadStringPtrA(lpFileName, MAX_PATH))
  34. {
  35. CString csFileName(lpFileName);
  36. if (csFileName.Find(L"system") != -1)
  37. {
  38. // We have found 'system' in the path
  39. // Replace it with 'system32'.
  40. CString csName;
  41. csFileName.GetLastPathComponent(csName);
  42. CString csNewFileName(g_wszSystemDir);
  43. csNewFileName.AppendPath(csName);
  44. DPFN(eDbgLevelInfo, "[ResumeWriter3] changed %s to (%s)\n", lpFileName, csNewFileName.GetAnsi());
  45. return ORIGINAL_API(LoadLibraryA)(csNewFileName.GetAnsi());
  46. }
  47. }
  48. }
  49. CSTRING_CATCH
  50. {
  51. }
  52. return ORIGINAL_API(LoadLibraryA)(lpFileName);
  53. }
  54. /*++
  55. Cache the system directory when we get called in
  56. the beginning.
  57. --*/
  58. BOOL
  59. NOTIFY_FUNCTION(
  60. DWORD fdwReason
  61. )
  62. {
  63. if (fdwReason == DLL_PROCESS_ATTACH)
  64. {
  65. GetSystemDirectory(g_wszSystemDir, MAX_PATH);
  66. }
  67. return TRUE;
  68. }
  69. /*++
  70. Register hooked functions
  71. --*/
  72. HOOK_BEGIN
  73. CALL_NOTIFY_FUNCTION
  74. APIHOOK_ENTRY(KERNEL32.DLL, LoadLibraryA)
  75. HOOK_END
  76. IMPLEMENT_SHIM_END