diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index b880b6a9..4cf8e0c3 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -297,6 +297,7 @@ patch_enable_all () enable_shlwapi_UrlCombine="$1" enable_stdole32_idl_Typelib="$1" enable_stdole32_tlb_SLTG_Typelib="$1" + enable_taskmgr_Memory_Usage="$1" enable_ucrtbase_Functions="$1" enable_user32_DeferWindowPos="$1" enable_user32_Dialog_Paint_Event="$1" @@ -1031,6 +1032,9 @@ patch_enable () stdole32.tlb-SLTG_Typelib) enable_stdole32_tlb_SLTG_Typelib="$2" ;; + taskmgr-Memory_Usage) + enable_taskmgr_Memory_Usage="$2" + ;; ucrtbase-Functions) enable_ucrtbase_Functions="$2" ;; @@ -6086,6 +6090,25 @@ if test "$enable_stdole32_tlb_SLTG_Typelib" -eq 1; then ) >> "$patchlist" fi +# Patchset taskmgr-Memory_Usage +# | +# | Modified files: +# | * configure.ac, dlls/ntdll/nt.c, dlls/ntdll/virtual.c, programs/taskmgr/font.bmp, programs/taskmgr/graph.c, +# | programs/taskmgr/resource.h, programs/taskmgr/taskmgr.c, programs/taskmgr/taskmgr.rc +# | +if test "$enable_taskmgr_Memory_Usage" -eq 1; then + patch_apply taskmgr-Memory_Usage/0001-ntdll-Use-sysinfo-to-report-correct-number-of-physic.patch + patch_apply taskmgr-Memory_Usage/0002-ntdll-Report-system-information-SystemPerformanceInf.patch + patch_apply taskmgr-Memory_Usage/0003-taskmgr-Use-system-font-instead-of-special-bitmap-fo.patch + patch_apply taskmgr-Memory_Usage/0004-taskmgr-Use-different-units-depending-on-memory-usag.patch + ( + echo '+ { "Michael Müller", "ntdll: Use sysinfo to report correct number of physical pages.", 1 },'; + echo '+ { "Michael Müller", "ntdll: Report system information SystemPerformanceInformation info class.", 1 },'; + echo '+ { "Michael Müller", "taskmgr: Use system font instead of special bitmap font.", 1 },'; + echo '+ { "Michael Müller", "taskmgr: Use different units depending on memory usage.", 1 },'; + ) >> "$patchlist" +fi + # Patchset ucrtbase-Functions # | # | Modified files: diff --git a/patches/taskmgr-Memory_Usage/0001-ntdll-Use-sysinfo-to-report-correct-number-of-physic.patch b/patches/taskmgr-Memory_Usage/0001-ntdll-Use-sysinfo-to-report-correct-number-of-physic.patch new file mode 100644 index 00000000..b194e81e --- /dev/null +++ b/patches/taskmgr-Memory_Usage/0001-ntdll-Use-sysinfo-to-report-correct-number-of-physic.patch @@ -0,0 +1,62 @@ +From cfc7a0a240df174882997f8b69d37848543e12dd Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Wed, 27 Jan 2016 04:54:15 +0100 +Subject: ntdll: Use sysinfo to report correct number of physical pages. + +--- + configure.ac | 1 + + dlls/ntdll/virtual.c | 14 ++++++++++++++ + 2 files changed, 15 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 59fc4fa..3909cd5 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -502,6 +502,7 @@ AC_CHECK_HEADERS(\ + sys/statvfs.h \ + sys/strtio.h \ + sys/syscall.h \ ++ sys/sysinfo.h \ + sys/tihdr.h \ + sys/time.h \ + sys/timeout.h \ +diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c +index f4ca487..b9a59fc 100644 +--- a/dlls/ntdll/virtual.c ++++ b/dlls/ntdll/virtual.c +@@ -38,6 +38,9 @@ + #ifdef HAVE_SYS_MMAN_H + # include + #endif ++#ifdef HAVE_SYS_SYSINFO_H ++# include ++#endif + #ifdef HAVE_VALGRIND_VALGRIND_H + # include + #endif +@@ -1356,11 +1359,22 @@ void virtual_init_threading(void) + */ + void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) + { ++#ifdef HAVE_SYS_SYSINFO_H ++ struct sysinfo sinfo; ++#endif ++ + info->unknown = 0; + info->KeMaximumIncrement = 0; /* FIXME */ + info->PageSize = page_size; + info->MmLowestPhysicalPage = 1; + info->MmHighestPhysicalPage = 0x7fffffff / page_size; ++#ifdef HAVE_SYS_SYSINFO_H ++ if (!sysinfo(&sinfo)) ++ { ++ ULONG64 total = (ULONG64)sinfo.totalram * sinfo.mem_unit; ++ info->MmHighestPhysicalPage = max(1, total / page_size); ++ } ++#endif + info->MmNumberOfPhysicalPages = info->MmHighestPhysicalPage - info->MmLowestPhysicalPage; + info->AllocationGranularity = get_mask(0) + 1; + info->LowestUserAddress = (void *)0x10000; +-- +2.6.4 + diff --git a/patches/taskmgr-Memory_Usage/0002-ntdll-Report-system-information-SystemPerformanceInf.patch b/patches/taskmgr-Memory_Usage/0002-ntdll-Report-system-information-SystemPerformanceInf.patch new file mode 100644 index 00000000..638457f1 --- /dev/null +++ b/patches/taskmgr-Memory_Usage/0002-ntdll-Report-system-information-SystemPerformanceInf.patch @@ -0,0 +1,58 @@ +From 67f11502fdf5bdabbc786efe99ce4e681683ba31 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Thu, 28 Jan 2016 06:43:00 +0100 +Subject: ntdll: Report system information SystemPerformanceInformation info + class. + +--- + dlls/ntdll/nt.c | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c +index 9ee1923..947b410 100644 +--- a/dlls/ntdll/nt.c ++++ b/dlls/ntdll/nt.c +@@ -30,6 +30,9 @@ + #ifdef HAVE_SYS_SYSCTL_H + # include + #endif ++#ifdef HAVE_SYS_SYSINFO_H ++# include ++#endif + #ifdef HAVE_MACHINE_CPU_H + # include + #endif +@@ -1718,6 +1721,9 @@ NTSTATUS WINAPI NtQuerySystemInformation( + SYSTEM_PERFORMANCE_INFORMATION spi; + static BOOL fixme_written = FALSE; + FILE *fp; ++ #ifdef HAVE_SYS_SYSINFO_H ++ struct sysinfo sinfo; ++ #endif + + memset(&spi, 0 , sizeof(spi)); + len = sizeof(spi); +@@ -1739,6 +1745,20 @@ NTSTATUS WINAPI NtQuerySystemInformation( + spi.IdleTime.QuadPart = ++idle; + } + ++ #ifdef HAVE_SYS_SYSINFO_H ++ if (!sysinfo(&sinfo)) ++ { ++ ULONG64 freemem = (ULONG64)sinfo.freeram * sinfo.mem_unit; ++ ULONG64 totalram = (ULONG64)sinfo.totalram * sinfo.mem_unit; ++ ULONG64 totalswap = (ULONG64)sinfo.totalswap * sinfo.mem_unit; ++ ULONG64 freeswap = (ULONG64)sinfo.freeswap * sinfo.mem_unit; ++ ++ spi.AvailablePages = freemem / page_size; ++ spi.TotalCommittedPages = (totalram + totalswap - freemem - freeswap) / page_size; ++ spi.TotalCommitLimit = (totalram + totalswap) / page_size; ++ } ++ #endif ++ + if (Length >= len) + { + if (!SystemInformation) ret = STATUS_ACCESS_VIOLATION; +-- +2.6.4 + diff --git a/patches/taskmgr-Memory_Usage/0003-taskmgr-Use-system-font-instead-of-special-bitmap-fo.patch b/patches/taskmgr-Memory_Usage/0003-taskmgr-Use-system-font-instead-of-special-bitmap-fo.patch new file mode 100644 index 00000000..6888170b --- /dev/null +++ b/patches/taskmgr-Memory_Usage/0003-taskmgr-Use-system-font-instead-of-special-bitmap-fo.patch @@ -0,0 +1,139 @@ +From 54f6838211778a8f2527640d3c5a411f56d5cd98 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Wed, 27 Jan 2016 04:55:09 +0100 +Subject: taskmgr: Use system font instead of special bitmap font. + +--- + programs/taskmgr/font.bmp | Bin 646 -> 0 bytes + programs/taskmgr/graph.c | 14 ++++++++++++-- + programs/taskmgr/resource.h | 1 - + programs/taskmgr/taskmgr.c | 29 ----------------------------- + programs/taskmgr/taskmgr.rc | 3 --- + 5 files changed, 12 insertions(+), 35 deletions(-) + delete mode 100644 programs/taskmgr/font.bmp + +diff --git a/programs/taskmgr/font.bmp b/programs/taskmgr/font.bmp +deleted file mode 100644 +index c1f8410c93273f4bc7013014561c35ef84faa182..0000000000000000000000000000000000000000 +GIT binary patch +literal 0 +HcmV?d00001 + +literal 646 +zcma)(!4U#62u0EH6fcfdSci9eun5QVo~(m&sz_(+`>@G4J060-haZBlxj#Nf3wh&j +z*b_Tr2Rq@-E}XxvX+aFPn4z{T33x(lt${jNLv39ZVf;klYOQWo0y8!j?qiD3aA3(K +zIq{C$VS%n9(V2QTr);{O_DntBpT=8p%%lCvw&%ZnE9Lyb=%2T9J{pLZxOXEEt2{0S +rj&qR`_imbB3(wY5`TKp;OQ!n~kRUw=3;lV4-TOj~_w9QN#T)VkBip4W + +diff --git a/programs/taskmgr/graph.c b/programs/taskmgr/graph.c +index 4098675..df4f922 100644 +--- a/programs/taskmgr/graph.c ++++ b/programs/taskmgr/graph.c +@@ -44,6 +44,7 @@ static void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd) + RECT rcClient; + RECT rcBarLeft; + RECT rcBarRight; ++ RECT rcText; + WCHAR Text[256]; + ULONG CpuUsage; + ULONG CpuKernelUsage; +@@ -97,7 +98,11 @@ static void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd) + * Draw the font text onto the graph + * The bottom 20 pixels are reserved for the text + */ +- Font_DrawText(hDC, Text, ((rcClient.right - rcClient.left) - 32) / 2, rcClient.bottom - 11 - 5); ++ CopyRect(&rcText, &rcClient); ++ rcText.top = rcText.bottom - 19; ++ ++ SetTextColor(hDC, BRIGHT_GREEN); ++ DrawTextW(hDC, Text, -1, &rcText, DT_CENTER); + + /* + * Now we have to draw the graph +@@ -224,6 +229,7 @@ static void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd) + RECT rcClient; + RECT rcBarLeft; + RECT rcBarRight; ++ RECT rcText; + WCHAR Text[256]; + ULONGLONG CommitChargeTotal; + ULONGLONG CommitChargeLimit; +@@ -258,7 +264,11 @@ static void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd) + * Draw the font text onto the graph + * The bottom 20 pixels are reserved for the text + */ +- Font_DrawText(hDC, Text, ((rcClient.right - rcClient.left) - (strlenW(Text) * 8)) / 2, rcClient.bottom - 11 - 5); ++ CopyRect(&rcText, &rcClient); ++ rcText.top = rcText.bottom - 19; ++ ++ SetTextColor(hDC, BRIGHT_GREEN); ++ DrawTextW(hDC, Text, -1, &rcText, DT_CENTER); + + /* + * Now we have to draw the graph +diff --git a/programs/taskmgr/resource.h b/programs/taskmgr/resource.h +index add873d..cbd2448 100644 +--- a/programs/taskmgr/resource.h ++++ b/programs/taskmgr/resource.h +@@ -35,7 +35,6 @@ + #define IDR_PROCESS_PAGE_CONTEXT 144 + #define IDB_TRAYMASK 150 + #define IDB_TRAYICON 153 +-#define IDB_FONT 154 + #define IDD_DEBUG_CHANNELS_DIALOG 155 + #define IDC_DEBUG_CHANNELS_LIST 156 + +diff --git a/programs/taskmgr/taskmgr.c b/programs/taskmgr/taskmgr.c +index 80dc81c..b0f2e78 100644 +--- a/programs/taskmgr/taskmgr.c ++++ b/programs/taskmgr/taskmgr.c +@@ -80,35 +80,6 @@ static void Draw3dRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clrTopLef + FillSolidRect2(hDC, x, y + cy, cx, -1, clrBottomRight); + } + +-void Font_DrawText(HDC hDC, LPWSTR lpwszText, int x, int y) +-{ +- HDC hFontDC; +- HBITMAP hFontBitmap; +- HBITMAP hOldBitmap; +- int i; +- +- hFontDC = CreateCompatibleDC(hDC); +- hFontBitmap = LoadBitmapW(hInst, MAKEINTRESOURCEW(IDB_FONT)); +- hOldBitmap = SelectObject(hFontDC, hFontBitmap); +- +- for (i = 0; lpwszText[i]; i++) { +- if ((lpwszText[i] >= '0') && (lpwszText[i] <= '9')) { +- BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, (lpwszText[i] - '0') * 8, 0, SRCCOPY); +- } +- else if (lpwszText[i] == 'K') +- { +- BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, 80, 0, SRCCOPY); +- } +- else if (lpwszText[i] == '%') +- { +- BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, 88, 0, SRCCOPY); +- } +- } +- SelectObject(hFontDC, hOldBitmap); +- DeleteObject(hFontBitmap); +- DeleteDC(hFontDC); +-} +- + static BOOL OnCreate(HWND hWnd) + { + HMENU hMenu; +diff --git a/programs/taskmgr/taskmgr.rc b/programs/taskmgr/taskmgr.rc +index e6742a7..ffd0699 100644 +--- a/programs/taskmgr/taskmgr.rc ++++ b/programs/taskmgr/taskmgr.rc +@@ -609,6 +609,3 @@ IDB_TRAYMASK BITMAP traymask.bmp + + /* @makedep: trayicon.bmp */ + IDB_TRAYICON BITMAP trayicon.bmp +- +-/* @makedep: font.bmp */ +-IDB_FONT BITMAP font.bmp +-- +2.6.4 + diff --git a/patches/taskmgr-Memory_Usage/0004-taskmgr-Use-different-units-depending-on-memory-usag.patch b/patches/taskmgr-Memory_Usage/0004-taskmgr-Use-different-units-depending-on-memory-usag.patch new file mode 100644 index 00000000..9ab94c5e --- /dev/null +++ b/patches/taskmgr-Memory_Usage/0004-taskmgr-Use-different-units-depending-on-memory-usag.patch @@ -0,0 +1,45 @@ +From 6b3fbb9c89a49f1ae936cc7db666f9ee09069463 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Wed, 27 Jan 2016 05:03:26 +0100 +Subject: taskmgr: Use different units depending on memory usage. + +--- + programs/taskmgr/graph.c | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +diff --git a/programs/taskmgr/graph.c b/programs/taskmgr/graph.c +index df4f922..7f1d09c 100644 +--- a/programs/taskmgr/graph.c ++++ b/programs/taskmgr/graph.c +@@ -240,8 +240,10 @@ static void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd) + /* Top bars that are "unused", i.e. are dark green, representing free memory */ + int i; + +- static const WCHAR wszFormat[] = {'%','d','K',0}; +- ++ static const WCHAR wszFormatKB[] = {'%','u',' ','K','B',0}; ++ static const WCHAR wszFormatMB[] = {'%','u',' ','M','B',0}; ++ static const WCHAR wszFormatGB[] = {'%','.','1','f',' ','G','B',0}; ++ + /* + * Get the client area rectangle + */ +@@ -258,8 +260,13 @@ static void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd) + CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK(); + CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK(); + +- sprintfW(Text, wszFormat, (int)CommitChargeTotal); +- ++ if (CommitChargeTotal > 1048576) ++ sprintfW(Text, wszFormatGB, (float)CommitChargeTotal / 1048576); ++ else if (CommitChargeTotal > 1024) ++ sprintfW(Text, wszFormatMB, (DWORD)CommitChargeTotal / 1024); ++ else ++ sprintfW(Text, wszFormatKB, (DWORD)CommitChargeTotal); ++ + /* + * Draw the font text onto the graph + * The bottom 20 pixels are reserved for the text +-- +2.6.4 +