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.

97 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. HandleDBCSUserName2.cpp
  5. Abstract:
  6. Disable DBCS handling for CharNextA if the string is DBCS user profile
  7. for non-DBCS enabled application support.
  8. More info:
  9. Return next byte address instead of next character address.
  10. History:
  11. 05/01/2001 geoffguo Created
  12. --*/
  13. #include "precomp.h"
  14. IMPLEMENT_SHIM_BEGIN(HandleDBCSUserName2)
  15. #include "ShimHookMacro.h"
  16. #define MAX_USERNAME 256
  17. //
  18. // Add APIs that you wish to hook to this macro construction.
  19. //
  20. APIHOOK_ENUM_BEGIN
  21. APIHOOK_ENUM_ENTRY(CharNextA)
  22. APIHOOK_ENUM_END
  23. //
  24. // Checking if the string is user profile path
  25. //
  26. BOOL IsUserProfilePath(
  27. LPCSTR lpCurrentChar)
  28. {
  29. LPSTR lpChar = (LPSTR)lpCurrentChar;
  30. BOOL bRet = FALSE;
  31. char szBuf[10];
  32. while (lpChar != NULL && *lpChar != (char)NULL
  33. && (lpCurrentChar - lpChar) < MAX_USERNAME+25) {
  34. //to find ":\Documents and Settings" (short name is :\DOCUME~1) in path
  35. if (*lpChar == (char) ':') {
  36. lstrcpynA (szBuf, lpChar, 9);
  37. szBuf[8] = (char) NULL;
  38. if (lstrcmpiA (szBuf, ":\\DOCUME") == 0) {
  39. bRet = TRUE;
  40. break;
  41. }
  42. }
  43. lpChar--;
  44. }
  45. return bRet;
  46. }
  47. //
  48. // Disable DBCS handling for CharNextA
  49. //
  50. LPSTR
  51. APIHOOK(CharNextA)(
  52. LPCSTR lpCurrentChar)
  53. {
  54. if (lpCurrentChar != NULL && *lpCurrentChar != (char)NULL) {
  55. // Disable DBCS support for DBCS username in user profile path
  56. if (IsDBCSLeadByte(*lpCurrentChar) && !IsUserProfilePath(lpCurrentChar))
  57. lpCurrentChar++;
  58. lpCurrentChar++;
  59. }
  60. return (LPSTR)lpCurrentChar;
  61. }
  62. /*++
  63. Register hooked functions
  64. --*/
  65. HOOK_BEGIN
  66. APIHOOK_ENTRY(USER32.DLL, CharNextA)
  67. HOOK_END
  68. IMPLEMENT_SHIM_END