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.

73 lines
1.5 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. OmniPagePro11Uninstall.cpp
  5. Abstract:
  6. An OmniPagePro custom action returns an invalid error code.
  7. We cannot shim it directly, but we can shim the custom action,
  8. and then trap all calls to GetProcAddress() from MSIExec
  9. Notes:
  10. This is specific to OmniPage Pro 11 Uninstaller
  11. History:
  12. 5/14/2002 mikrause Created
  13. --*/
  14. #include "precomp.h"
  15. #include <stdio.h>
  16. IMPLEMENT_SHIM_BEGIN(OmniPagePro11Uninstall)
  17. #include "ShimHookMacro.h"
  18. APIHOOK_ENUM_BEGIN
  19. APIHOOK_ENUM_ENTRY(GetProcAddress)
  20. APIHOOK_ENUM_END
  21. typedef UINT (WINAPI *_pfn_MsiCustomAction)(MSIHANDLE msiHandle);
  22. _pfn_MsiCustomAction g_pfnOriginalULinkToPagis = NULL;
  23. UINT CALLBACK
  24. ULinkToPagisHook(
  25. MSIHANDLE msiHandle
  26. )
  27. {
  28. UINT uiRet = g_pfnOriginalULinkToPagis(msiHandle);
  29. if (uiRet == (UINT)-1) {
  30. uiRet = 0;
  31. }
  32. return uiRet;
  33. }
  34. FARPROC
  35. APIHOOK(GetProcAddress)(
  36. HMODULE hModule, // handle to DLL module
  37. LPCSTR lpProcName // function name
  38. )
  39. {
  40. if ((HIWORD(lpProcName) != 0) && (lstrcmpA(lpProcName, "ULinkToPagis") == 0)) {
  41. g_pfnOriginalULinkToPagis = (_pfn_MsiCustomAction) GetProcAddress(hModule, lpProcName);
  42. if (g_pfnOriginalULinkToPagis) {
  43. return (FARPROC)ULinkToPagisHook;
  44. }
  45. }
  46. return ORIGINAL_API(GetProcAddress)(hModule, lpProcName);
  47. }
  48. HOOK_BEGIN
  49. APIHOOK_ENTRY(KERNEL32.DLL, GetProcAddress )
  50. HOOK_END
  51. IMPLEMENT_SHIM_END