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.

78 lines
1.4 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. HeapIgnoreMoveable.cpp
  5. Abstract:
  6. After 64k calls to GlobalAlloc, we are no longer able to use the
  7. GMEM_MOVEABLE flag. This shim just filters it in the case of
  8. GlobalAlloc failing.
  9. This is a known issue with the heap manager on NT and is a won't fix.
  10. According to adrmarin:
  11. The table with handles cannot grow dynamic. The initial size is
  12. hardcoded to 64k handles. Increasing this number will affect the
  13. reserved address for each process.
  14. See Whistler bug #147032.
  15. Notes:
  16. This is a general purpose shim - superceded by EmulateHeap.
  17. History:
  18. 02/19/2000 linstev Created
  19. --*/
  20. #include "precomp.h"
  21. IMPLEMENT_SHIM_BEGIN(HeapIgnoreMoveable)
  22. #include "ShimHookMacro.h"
  23. APIHOOK_ENUM_BEGIN
  24. APIHOOK_ENUM_ENTRY(GlobalAlloc)
  25. APIHOOK_ENUM_END
  26. /*++
  27. Remove the GMEM_MOVEABLE flag in the case of failure.
  28. --*/
  29. HGLOBAL
  30. APIHOOK(GlobalAlloc)(
  31. UINT uFlags,
  32. DWORD dwBytes
  33. )
  34. {
  35. HGLOBAL hRet = ORIGINAL_API(GlobalAlloc)(uFlags, dwBytes);
  36. if (hRet == NULL)
  37. {
  38. hRet = ORIGINAL_API(GlobalAlloc)(
  39. uFlags & ~GMEM_MOVEABLE, dwBytes);
  40. }
  41. return hRet;
  42. }
  43. /*++
  44. Register hooked functions
  45. --*/
  46. HOOK_BEGIN
  47. APIHOOK_ENTRY(KERNEL32.DLL, GlobalAlloc)
  48. HOOK_END
  49. IMPLEMENT_SHIM_END