From 60f3e0541082b9498257f006e7d170612c0091b0 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 1 Jun 2007 22:34:47 +0000 Subject: [PATCH] - Get memory measurements to work on Win64. The format of a process descriptor had changed a little, and the format of the VM stats part was completely changed. I had to reverse engineer it - very unpleasant. lib/ diagnostics_sin.h procinfo.h svn path=/trunk/boinc/; revision=12804 --- checkin_notes | 10 ++++++++++ lib/diagnostics_win.h | 23 +++++++++++++++++++++++ lib/procinfo_win.C | 10 +++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/checkin_notes b/checkin_notes index e1eadecc2e..c58c053118 100755 --- a/checkin_notes +++ b/checkin_notes @@ -5672,3 +5672,13 @@ Rom 1 June 2007 win_build/installerv2/redist/Windows/x64/ boinccas.dll boinccas95.dll + +David 1 June 2007 + - Get memory measurements to work on Win64. + The format of a process descriptor had changed a little, + and the format of the VM stats part was completely changed. + I had to reverse engineer it - very unpleasant. + + lib/ + diagnostics_sin.h + procinfo.h \ No newline at end of file diff --git a/lib/diagnostics_win.h b/lib/diagnostics_win.h index 90a0f86b7d..e5f263bd7a 100644 --- a/lib/diagnostics_win.h +++ b/lib/diagnostics_win.h @@ -40,6 +40,20 @@ typedef struct _UNICODE_STRING { } UNICODE_STRING; typedef struct _VM_COUNTERS { +#ifdef _WIN64 +// the following was inferred by painful reverse engineering + SIZE_T PeakVirtualSize; // not actually + SIZE_T PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; + SIZE_T VirtualSize; // not actually +#else SIZE_T PeakVirtualSize; SIZE_T VirtualSize; ULONG PageFaultCount; @@ -51,6 +65,7 @@ typedef struct _VM_COUNTERS { SIZE_T QuotaNonPagedPoolUsage; SIZE_T PagefileUsage; SIZE_T PeakPagefileUsage; +#endif } VM_COUNTERS; typedef struct _SYSTEM_THREADS { @@ -93,8 +108,16 @@ typedef struct _SYSTEM_PROCESSES { LARGE_INTEGER KernelTime; UNICODE_STRING ProcessName; KPRIORITY BasePriority; +#ifdef _WIN64 + ULONG pad1; + ULONG ProcessId; + ULONG pad2; + ULONG InheritedFromProcessId; + ULONG pad3, pad4, pad5; +#else ULONG ProcessId; ULONG InheritedFromProcessId; +#endif ULONG HandleCount; ULONG Reserved2[2]; VM_COUNTERS VmCounters; diff --git a/lib/procinfo_win.C b/lib/procinfo_win.C index 5b9e0213aa..81f5618058 100644 --- a/lib/procinfo_win.C +++ b/lib/procinfo_win.C @@ -62,6 +62,15 @@ int get_procinfo_XP(vector& pi) { ULONG cbBuffer = 128*1024; // 128k initial buffer PVOID pBuffer = NULL; PSYSTEM_PROCESSES pProcesses = NULL; +#if 0 + printf("FILETIME: %d\n", sizeof(FILETIME)); + printf("LARGE_INTEGER: %d\n", sizeof(LARGE_INTEGER)); + printf("DWORD: %d\n", sizeof(DWORD)); + printf("UNICODE_STRING: %d\n", sizeof(UNICODE_STRING)); + printf("KPRIORITY: %d\n", sizeof(KPRIORITY)); + printf("ULONG: %d\n", sizeof(ULONG)); + printf("SIZE_T: %d\n", sizeof(SIZE_T)); +#endif get_process_information(&pBuffer, &cbBuffer); pProcesses = (PSYSTEM_PROCESSES)pBuffer; @@ -78,7 +87,6 @@ int get_procinfo_XP(vector& pi) { p.parentid = pProcesses->InheritedFromProcessId; p.is_boinc_app = false; pi.push_back(p); - if (!pProcesses->NextEntryDelta) { break; }