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.

86 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. HandleEmptyAccessCheck.cpp
  5. Abstract:
  6. AccessCheck used to accept a 0 value for DesiredAccess and return access_allowed,
  7. this changed in .NET server to return access_denied.
  8. Notes:
  9. This is a general purpose shim.
  10. History:
  11. 05/29/2002 robkenny Created
  12. --*/
  13. #include "precomp.h"
  14. IMPLEMENT_SHIM_BEGIN(HandleEmptyAccessCheck)
  15. #include "ShimHookMacro.h"
  16. APIHOOK_ENUM_BEGIN
  17. APIHOOK_ENUM_ENTRY(AccessCheck)
  18. APIHOOK_ENUM_END
  19. typedef BOOL (WINAPI *_pfn_AccessCheck)(
  20. PSECURITY_DESCRIPTOR pSecurityDescriptor, // SD
  21. HANDLE ClientToken, // handle to client access token
  22. DWORD DesiredAccess, // requested access rights
  23. PGENERIC_MAPPING GenericMapping, // mapping
  24. PPRIVILEGE_SET PrivilegeSet, // privileges
  25. LPDWORD PrivilegeSetLength, // size of privileges buffer
  26. LPDWORD GrantedAccess, // granted access rights
  27. LPBOOL AccessStatus // result of access check
  28. );
  29. BOOL
  30. APIHOOK(AccessCheck)(
  31. PSECURITY_DESCRIPTOR pSecurityDescriptor, // SD
  32. HANDLE ClientToken, // handle to client access token
  33. DWORD DesiredAccess, // requested access rights
  34. PGENERIC_MAPPING GenericMapping, // mapping
  35. PPRIVILEGE_SET PrivilegeSet, // privileges
  36. LPDWORD PrivilegeSetLength, // size of privileges buffer
  37. LPDWORD GrantedAccess, // granted access rights
  38. LPBOOL AccessStatus // result of access check
  39. )
  40. {
  41. if (DesiredAccess == 0)
  42. {
  43. DesiredAccess = MAXIMUM_ALLOWED;
  44. }
  45. return ORIGINAL_API(AccessCheck)(
  46. pSecurityDescriptor, // SD
  47. ClientToken, // handle to client access token
  48. DesiredAccess, // requested access rights
  49. GenericMapping, // mapping
  50. PrivilegeSet, // privileges
  51. PrivilegeSetLength, // size of privileges buffer
  52. GrantedAccess, // granted access rights
  53. AccessStatus // result of access check
  54. );
  55. }
  56. /*++
  57. Register hooked functions
  58. --*/
  59. HOOK_BEGIN
  60. APIHOOK_ENTRY(ADVAPI32.DLL, AccessCheck)
  61. HOOK_END
  62. IMPLEMENT_SHIM_END