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.

104 lines
2.2 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. #include "strsafe.h"
  14. IMPLEMENT_SHIM_BEGIN(ISpeed)
  15. #include "ShimHookMacro.h"
  16. APIHOOK_ENUM_BEGIN
  17. APIHOOK_ENUM_ENTRY(GetDlgItemTextA)
  18. APIHOOK_ENUM_END
  19. /*++
  20. After we call GetDlgItemTextA we convert the long path name to the short path name.
  21. --*/
  22. UINT
  23. APIHOOK(GetDlgItemTextA)(
  24. HWND hDlg,
  25. int nIDDlgItem,
  26. LPSTR lpString,
  27. int nMaxCount
  28. )
  29. {
  30. UINT uiRet = ORIGINAL_API(GetDlgItemTextA)(hDlg, nIDDlgItem, lpString, nMaxCount);
  31. if (uiRet)
  32. {
  33. CSTRING_TRY
  34. {
  35. // Check if the title is "iSpeed"
  36. CString csTitle;
  37. WCHAR * lpwszBuffer = csTitle.GetBuffer(7);
  38. int nTitle = GetWindowTextW(hDlg, lpwszBuffer, 7);
  39. csTitle.ReleaseBuffer(nTitle);
  40. if (csTitle.CompareNoCase(L"iSpeed") == 0)
  41. {
  42. int nIndexSpace = csTitle.Find(L" ");
  43. if (nIndexSpace >= 0)
  44. {
  45. CString csString(lpString);
  46. // If the directory doesn't already exist, we create it so we can get the short path name.
  47. if ((GetFileAttributesW(csString) == -1) && (GetLastError() == ERROR_FILE_NOT_FOUND))
  48. {
  49. if (!CreateDirectoryW(csString, NULL))
  50. {
  51. return 0;
  52. }
  53. }
  54. csString.GetShortPathNameW();
  55. StringCchCopyA(lpString,nMaxCount, csString.GetAnsi());
  56. StringCchLengthA(lpString, nMaxCount, &uiRet);
  57. }
  58. }
  59. }
  60. CSTRING_CATCH
  61. {
  62. // Do Nothing
  63. }
  64. }
  65. return uiRet;
  66. }
  67. /*++
  68. Register hooked functions
  69. --*/
  70. HOOK_BEGIN
  71. APIHOOK_ENTRY(USER32.DLL, GetDlgItemTextA)
  72. HOOK_END
  73. IMPLEMENT_SHIM_END