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.

89 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Omikron.cpp
  5. Abstract:
  6. Shims RegQueryValueExA so that when the app asks for the shell command
  7. for opening an rtffile, it gets what it expected to see under Win95:
  8. "C:\WINDOWS\WORDPAD.EXE %1" This is, of course, wrong, but we then apply
  9. CorrectFilePaths, so when it actually goes out to launch wordpad, it has
  10. the right path.
  11. This is necessary because it can't have a path name with spaces in it
  12. Notes:
  13. This is specific to Omikron.
  14. History:
  15. 3/27/2000 dmunsil Created
  16. --*/
  17. #include "precomp.h"
  18. IMPLEMENT_SHIM_BEGIN(Omikron)
  19. #include "ShimHookMacro.h"
  20. APIHOOK_ENUM_BEGIN
  21. APIHOOK_ENUM_ENTRY(RegQueryValueExA)
  22. APIHOOK_ENUM_END
  23. LONG
  24. APIHOOK(RegQueryValueExA)(
  25. HKEY hKey,
  26. LPSTR lpValueName,
  27. LPDWORD lpReserved,
  28. LPDWORD lpType,
  29. LPBYTE lpData,
  30. LPDWORD lpcbData
  31. )
  32. {
  33. LONG lReturn;
  34. // Remember the size of the dest buffer
  35. DWORD ccbData = lpcbData ? *lpcbData : 0;
  36. lReturn = ORIGINAL_API(RegQueryValueExA)(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData);
  37. if (lReturn != ERROR_SUCCESS)
  38. {
  39. return lReturn;
  40. }
  41. if (lpType && lpcbData && lpData && (*lpType == REG_SZ || *lpType == REG_EXPAND_SZ))
  42. {
  43. CSTRING_TRY
  44. {
  45. LPSTR lpszData = (LPSTR)lpData;
  46. CString csData(lpszData);
  47. if (csData.Find(L"wordpad.exe \"%1\"") >= 0)
  48. {
  49. StringCbCopyA(lpszData, ccbData, "c:\\windows\\wordpad.exe \"%1\"");
  50. }
  51. }
  52. CSTRING_CATCH
  53. {
  54. // Do nothing
  55. }
  56. }
  57. return lReturn;
  58. }
  59. HOOK_BEGIN
  60. APIHOOK_ENTRY(ADVAPI32.DLL, RegQueryValueExA )
  61. HOOK_END
  62. IMPLEMENT_SHIM_END