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.

85 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. OmniPagePro.cpp
  5. Abstract:
  6. Shims ShellExecuteExA. If the user double clicks on an image in the right
  7. pane, the app will read the progID key in the registry for .BMP files
  8. (HKCR, Paint.Picture\shell\open\command, "(Default)"). Previously, that
  9. data had: "C:\winnt\system32\mspaint.exe" "%1". In Whistler, that changed
  10. to: rundll32.exe C:\WINNT\System32\shimgvw.dll,ImageView_Fullscreen %1.
  11. The problem with Carea OmniPage Pro v10 is that on the double click, they
  12. will read the regkey, remove the %1, pass the rest of the string to
  13. ShellExecuteExA() lpFile. They will put the filename into lpParameters.
  14. The problem is that with the new path, "rundll32.exe" needs to be in lpFile
  15. and "C:\WINNT\System32\shimgvw.dll,ImageView_Fullscreen <FileToOpen>" needs
  16. to be in lpParameters.
  17. Notes:
  18. This is specific to OmniPage Pro.
  19. History:
  20. 2/12/2000 bryanst Created
  21. --*/
  22. #include "precomp.h"
  23. #include <stdio.h>
  24. IMPLEMENT_SHIM_BEGIN(OmniPage)
  25. #include "ShimHookMacro.h"
  26. APIHOOK_ENUM_BEGIN
  27. APIHOOK_ENUM_ENTRY(ShellExecuteExA)
  28. APIHOOK_ENUM_END
  29. BOOL
  30. APIHOOK(ShellExecuteExA)(
  31. LPSHELLEXECUTEINFOA lpExecInfo
  32. )
  33. {
  34. CSTRING_TRY
  35. {
  36. CString csFile(lpExecInfo->lpFile);
  37. int nIndexGVW = csFile.Find(L"shimgvw.dll,");
  38. int nIndexRundll = csFile.Find(L"rundll32.exe");
  39. int nIndexSpace = csFile.Find(L" ");
  40. if (nIndexGVW != -1 &&
  41. nIndexRundll != -1 &&
  42. nIndexSpace >= 1)
  43. {
  44. CString csParam;
  45. csFile.Mid(nIndexSpace + 1, csParam); // everything after the space
  46. csFile.Delete(nIndexSpace, csFile.GetLength() - nIndexSpace); // Delete the space and everything after
  47. csParam += " ";
  48. csParam += lpExecInfo->lpParameters;
  49. lpExecInfo->lpFile = csFile.GetAnsi();
  50. lpExecInfo->lpParameters = csParam.GetAnsi();
  51. }
  52. }
  53. CSTRING_CATCH
  54. {
  55. // Do nothing
  56. }
  57. return ORIGINAL_API(ShellExecuteExA)(lpExecInfo);
  58. }
  59. HOOK_BEGIN
  60. APIHOOK_ENTRY(SHELL32.DLL, ShellExecuteExA )
  61. HOOK_END
  62. IMPLEMENT_SHIM_END