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.

126 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 2000 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. --*/
  17. #include "precomp.h"
  18. #include "LegalStr.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. char* pszWalk;
  43. char* pszWalk2;
  44. DPF("SolidWorks99Plus",
  45. eDbgLevelInfo,
  46. "SolidWorks99Plus.dll, Changing OpenIndex file\n\tfrom: \"%s\".\n",
  47. pszIndexFile);
  48. GetSystemWindowsDirectoryA(szBuff, MAX_PATH);
  49. pszWalk = szBuff;
  50. 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. lstrcpyA(pszWalk, "/Help");
  62. lstrcatA(pszWalk, pszWalk2);
  63. } else if (*pszWalk2 == '\\') {
  64. lstrcatA(pszWalk, "\\Help");
  65. lstrcatA(pszWalk, pszWalk2);
  66. } else {
  67. lstrcpyA(pszWalk, 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. } else {
  76. //
  77. // Not SolidWorks
  78. //
  79. return ORIGINAL_API(OpenIndex)(hsrch, pszIndexFile, pbSourceName,
  80. pcbSourceNameLimit, pTime1, pTime2);
  81. }
  82. }
  83. /*++
  84. Register hooked functions
  85. --*/
  86. HOOK_BEGIN
  87. APIHOOK_ENTRY(FTSRCH.DLL, OpenIndex)
  88. HOOK_END
  89. IMPLEMENT_SHIM_END