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.

123 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 2000-2002 Microsoft Corporation
  3. Module Name:
  4. SolidWorks99Plus.cpp
  5. Abstract:
  6. This patches winhlp32.exe for calls to FTSRCH!OpenIndex only if they come from
  7. ROBOEX32.DLL. This needs to be written in the shim database otherwise the
  8. shim will be applied to all the apps using winhlp32.exe (which is bad!).
  9. Win2k's winhlp32.exe will only work with index files located in %windir%\Help
  10. so we need to redirect the location that the app points to.
  11. Notes:
  12. This is an app specific shim.
  13. History:
  14. 02/16/2000 clupu Created
  15. 08/05/2001 linstev Added module checking
  16. 03/12/2002 robkenny Security review
  17. --*/
  18. #include "precomp.h"
  19. IMPLEMENT_SHIM_BEGIN(SolidWorks99Plus)
  20. #include "ShimHookMacro.h"
  21. APIHOOK_ENUM_BEGIN
  22. APIHOOK_ENUM_ENTRY(OpenIndex)
  23. APIHOOK_ENUM_END
  24. /*++
  25. Read the index file from %windir%\Help
  26. --*/
  27. int
  28. APIHOOK(OpenIndex)(
  29. HANDLE hsrch,
  30. char* pszIndexFile,
  31. PBYTE pbSourceName,
  32. PUINT pcbSourceNameLimit,
  33. PUINT pTime1,
  34. PUINT pTime2
  35. )
  36. {
  37. if (GetModuleHandleW(L"ROBOEX32.DLL")) {
  38. //
  39. // This is SolidWorks
  40. //
  41. char szBuff[MAX_PATH];
  42. DPF("SolidWorks99Plus",
  43. eDbgLevelInfo,
  44. "SolidWorks99Plus.dll, Changing OpenIndex file\n\tfrom: \"%s\".\n",
  45. pszIndexFile);
  46. UINT cchBuff = GetSystemWindowsDirectoryA(szBuff, MAX_PATH);
  47. if (cchBuff > 0 && cchBuff < MAX_PATH)
  48. {
  49. char * pszWalk = szBuff;
  50. const char * pszWalk2 = pszIndexFile + lstrlenA(pszIndexFile) - 1;
  51. while (pszWalk2 > pszIndexFile && *pszWalk2 != '/' && *pszWalk2 != '\\') {
  52. pszWalk2--;
  53. }
  54. if (*pszWalk2 == '/') {
  55. while (*pszWalk != 0) {
  56. if (*pszWalk == '\\') {
  57. *pszWalk = '/';
  58. }
  59. pszWalk++;
  60. }
  61. StringCchCatA(pszWalk, MAX_PATH, "/Help");
  62. StringCchCatA(pszWalk, MAX_PATH, pszWalk2);
  63. } else if (*pszWalk2 == '\\') {
  64. StringCchCatA(pszWalk, MAX_PATH, "/Help");
  65. StringCchCatA(pszWalk, MAX_PATH, pszWalk2);
  66. } else {
  67. StringCchCopyA(pszWalk, MAX_PATH, pszWalk2);
  68. }
  69. DPF("SolidWorks99Plus",
  70. eDbgLevelInfo,
  71. "SolidWorks99Plus.dll, \tto: \"%s\".\n",
  72. szBuff);
  73. return ORIGINAL_API(OpenIndex)(hsrch, szBuff, pbSourceName,
  74. pcbSourceNameLimit, pTime1, pTime2);
  75. }
  76. }
  77. return ORIGINAL_API(OpenIndex)(hsrch, pszIndexFile, pbSourceName,
  78. pcbSourceNameLimit, pTime1, pTime2);
  79. }
  80. /*++
  81. Register hooked functions
  82. --*/
  83. HOOK_BEGIN
  84. APIHOOK_ENTRY(FTSRCH.DLL, OpenIndex)
  85. HOOK_END
  86. IMPLEMENT_SHIM_END