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.

77 lines
2.2 KiB

  1. /**************************************************************************
  2. * USERGDI1.C
  3. *
  4. * Returns information about USER.EXE and GDI.EXE
  5. *
  6. **************************************************************************/
  7. #include "toolpriv.h"
  8. /* SystemHeapInfo
  9. * Returns information about USER's and GDI's heaps
  10. */
  11. BOOL TOOLHELPAPI SystemHeapInfo(
  12. SYSHEAPINFO FAR* lpSysHeap)
  13. {
  14. MODULEENTRY ModuleEntry;
  15. #ifndef WOW
  16. DWORD dw;
  17. WORD wFreeK;
  18. WORD wMaxHeapK;
  19. #endif
  20. /* Check the structure version number and pointer */
  21. if (!wLibInstalled || !lpSysHeap ||
  22. lpSysHeap->dwSize != sizeof (SYSHEAPINFO))
  23. return FALSE;
  24. /* Find the user data segment */
  25. ModuleEntry.dwSize = sizeof (MODULEENTRY);
  26. lpSysHeap->hUserSegment =
  27. UserGdiDGROUP(ModuleFindName(&ModuleEntry, "USER"));
  28. lpSysHeap->hGDISegment =
  29. UserGdiDGROUP(ModuleFindName(&ModuleEntry, "GDI"));
  30. #ifndef WOW
  31. /* We get the information about the heap percentages differently in
  32. * 3.0 and 3.1
  33. */
  34. if ((wTHFlags & TH_WIN30) || !lpfnGetFreeSystemResources)
  35. {
  36. /* Get the space information about USER's heap */
  37. dw = UserGdiSpace(lpSysHeap->hUserSegment);
  38. wFreeK = LOWORD(dw) / 1024;
  39. wMaxHeapK = HIWORD(dw) / 1024;
  40. if (wMaxHeapK)
  41. lpSysHeap->wUserFreePercent = wFreeK * 100 / wMaxHeapK;
  42. else
  43. lpSysHeap->wUserFreePercent = 0;
  44. /* Get the space information about GDI's heap */
  45. dw = UserGdiSpace(lpSysHeap->hGDISegment);
  46. wFreeK = LOWORD(dw) / 1024;
  47. wMaxHeapK = HIWORD(dw) / 1024;
  48. if (wMaxHeapK)
  49. lpSysHeap->wGDIFreePercent = wFreeK * 100 / wMaxHeapK;
  50. else
  51. lpSysHeap->wGDIFreePercent = 0;
  52. }
  53. /* Get the information from USER in 3.1 */
  54. else
  55. {
  56. lpSysHeap->wUserFreePercent =
  57. (*(WORD (FAR PASCAL *)(WORD))lpfnGetFreeSystemResources)(2);
  58. lpSysHeap->wGDIFreePercent =
  59. (*(WORD (FAR PASCAL *)(WORD))lpfnGetFreeSystemResources)(1);
  60. }
  61. #else
  62. lpSysHeap->wUserFreePercent = GetFreeSystemResources(GFSR_USERRESOURCES);
  63. lpSysHeap->wGDIFreePercent = GetFreeSystemResources(GFSR_GDIRESOURCES);
  64. #endif
  65. return TRUE;
  66. }