From bbc1b99d32d257101fde0e80cd13aae498dbe2b4 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 4 Aug 2004 05:18:05 +0000 Subject: [PATCH] fix proc_args when cmdline crosses first page boundry (seen w/ WebSphere) --- src/os/win32/peb.c | 12 ++++++++++-- src/os/win32/sigar_os.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/os/win32/peb.c b/src/os/win32/peb.c index 29844890..9f2a0608 100644 --- a/src/os/win32/peb.c +++ b/src/os/win32/peb.c @@ -18,17 +18,25 @@ static int sigar_peb_get(sigar_t *sigar, HANDLE proc, DWORD *base) { MEMORY_BASIC_INFORMATION mbi; DWORD bytes; + SIZE_T size = sigar->pagesize; if (!sigar->peb) { - sigar->peb = malloc(sigar->pagesize); + sigar->peb = malloc(sigar->pagesize*2); } if (!VirtualQueryEx(proc, (char*)START_ADDRESS, &mbi, sizeof(mbi))) { return GetLastError(); } + if (mbi.RegionSize > sigar->pagesize) { + /* in the event args crosses the first page boundry. + * seen with WebSphere. + */ + size *= 2; + } + if (!ReadProcessMemory(proc, mbi.BaseAddress, sigar->peb, - sigar->pagesize, &bytes)) + size, &bytes)) { return GetLastError(); } diff --git a/src/os/win32/sigar_os.h b/src/os/win32/sigar_os.h index 23c3b4ff..eba75dcf 100644 --- a/src/os/win32/sigar_os.h +++ b/src/os/win32/sigar_os.h @@ -19,7 +19,7 @@ /* see apr/include/arch/win32/atime.h */ #define EPOCH_DELTA INT64_C(11644473600000000) -#define SIGAR_CMDLINE_MAX (MAX_PATH * 3) +#define SIGAR_CMDLINE_MAX 4096 static __inline sigar_uint64_t FileTimeToTime(FILETIME *ft) {