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.

81 lines
1.4 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. VJEDelta.cpp
  5. Abstract:
  6. Broken by ACL changes to directories off the root.
  7. Notes:
  8. This is an app specific shim.
  9. History:
  10. 05/31/2001 linstev Created
  11. --*/
  12. #include "precomp.h"
  13. IMPLEMENT_SHIM_BEGIN(VJEDelta)
  14. #include "ShimHookMacro.h"
  15. APIHOOK_ENUM_BEGIN
  16. APIHOOK_ENUM_ENTRY(OpenFile)
  17. APIHOOK_ENUM_END
  18. /*++
  19. Remove write attributes on OpenFile in the case of failure.
  20. --*/
  21. HFILE
  22. APIHOOK(OpenFile)(
  23. LPCSTR lpFileName,
  24. LPOFSTRUCT lpReOpenBuff,
  25. UINT uStyle
  26. )
  27. {
  28. HFILE hRet = ORIGINAL_API(OpenFile)(lpFileName, lpReOpenBuff, uStyle);
  29. if ((hRet == HFILE_ERROR) && (GetLastError() == ERROR_ACCESS_DENIED)) {
  30. //
  31. // Remove write attributes
  32. //
  33. WCHAR *lpName = ToUnicode(lpFileName);
  34. if (lpName) {
  35. if (wcsistr(lpName, L"VJED95") && wcsistr(lpName, L".DIC")) {
  36. //
  37. // This is a file we care about
  38. //
  39. uStyle &= ~(OF_WRITE | OF_READWRITE);
  40. LOGN(eDbgLevelError, "Removed write attributes from %S", lpName);
  41. hRet = ORIGINAL_API(OpenFile)(lpFileName, lpReOpenBuff, uStyle);
  42. }
  43. free(lpName);
  44. }
  45. }
  46. return hRet;
  47. }
  48. /*++
  49. Register hooked functions
  50. --*/
  51. HOOK_BEGIN
  52. APIHOOK_ENTRY(KERNEL32.DLL, OpenFile)
  53. HOOK_END
  54. IMPLEMENT_SHIM_END