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.

103 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. ISpeed.cpp
  5. Abstract:
  6. The app doesn't handle directory/file names with spaces.
  7. Notes:
  8. This is an app specific shim.
  9. History:
  10. 11/15/2000 maonis Created
  11. --*/
  12. #include "precomp.h"
  13. IMPLEMENT_SHIM_BEGIN(ISpeed)
  14. #include "ShimHookMacro.h"
  15. APIHOOK_ENUM_BEGIN
  16. APIHOOK_ENUM_ENTRY(GetDlgItemTextA)
  17. APIHOOK_ENUM_END
  18. /*++
  19. After we call GetDlgItemTextA we convert the long path name to the short path name.
  20. --*/
  21. UINT
  22. APIHOOK(GetDlgItemTextA)(
  23. HWND hDlg,
  24. int nIDDlgItem,
  25. LPSTR lpString,
  26. int nMaxCount
  27. )
  28. {
  29. UINT uiRet = ORIGINAL_API(GetDlgItemTextA)(hDlg, nIDDlgItem, lpString, nMaxCount);
  30. if (uiRet)
  31. {
  32. CSTRING_TRY
  33. {
  34. // Check if the title is "iSpeed"
  35. CString csTitle;
  36. WCHAR * lpwszBuffer = csTitle.GetBuffer(7);
  37. int nTitle = GetWindowTextW(hDlg, lpwszBuffer, 7);
  38. csTitle.ReleaseBuffer(nTitle);
  39. if (csTitle.CompareNoCase(L"iSpeed") == 0)
  40. {
  41. int nIndexSpace = csTitle.Find(L" ");
  42. if (nIndexSpace >= 0)
  43. {
  44. CString csString(lpString);
  45. // If the directory doesn't already exist, we create it so we can get the short path name.
  46. if ((GetFileAttributesW(csString) == -1) && (GetLastError() == ERROR_FILE_NOT_FOUND))
  47. {
  48. if (!CreateDirectoryW(csString, NULL))
  49. {
  50. return 0;
  51. }
  52. }
  53. csString.GetShortPathNameW();
  54. lstrcpynA(lpString, csString.GetAnsi(), nMaxCount);
  55. uiRet = _tcslenChars(lpString);
  56. }
  57. }
  58. }
  59. CSTRING_CATCH
  60. {
  61. // Do Nothing
  62. }
  63. }
  64. return uiRet;
  65. }
  66. /*++
  67. Register hooked functions
  68. --*/
  69. HOOK_BEGIN
  70. APIHOOK_ENTRY(USER32.DLL, GetDlgItemTextA)
  71. HOOK_END
  72. IMPLEMENT_SHIM_END