Index: perfdata.c =================================================================== --- perfdata.c (revision 39746) +++ perfdata.c (working copy) @@ -134,36 +134,54 @@ } /* Get handle information + * Support 2 interfaces: + * If the call does not succeed it returns the required size (new) + * - or - * We don't know how much data there is so just keep - * increasing the buffer size until the call succeeds + * increasing the buffer size until the call succeeds (old) */ - BufferSize = 0; + BufferSize = 0x10000; do { - BufferSize += 0x10000; SysHandleInfoData = (LPBYTE)HeapAlloc(GetProcessHeap(), 0, BufferSize); status = NtQuerySystemInformation(SystemHandleInformation, SysHandleInfoData, BufferSize, &ulSize); if (status == STATUS_INFO_LENGTH_MISMATCH) { + if(ulSize <= BufferSize) { + //Old NT4 (?) interface + BufferSize += 0x10000; + } else { + //New XP interface + BufferSize = ulSize; + } HeapFree(GetProcessHeap(), 0, SysHandleInfoData); } } while (status == STATUS_INFO_LENGTH_MISMATCH); /* Get process information + * Support 2 interfaces: + * If the call does not succeed it returns the required size (new) + * - or - * We don't know how much data there is so just keep - * increasing the buffer size until the call succeeds + * increasing the buffer size until the call succeeds (old) */ - BufferSize = 0; + BufferSize = 0x10000; do { - BufferSize += 0x10000; pBuffer = (LPBYTE)HeapAlloc(GetProcessHeap(), 0, BufferSize); status = NtQuerySystemInformation(SystemProcessInformation, pBuffer, BufferSize, &ulSize); if (status == STATUS_INFO_LENGTH_MISMATCH) { + if(ulSize <= BufferSize) { + //Old NT4 (?) interface + BufferSize += 0x10000; + } else { + //New XP interface + BufferSize = ulSize; + } HeapFree(GetProcessHeap(), 0, pBuffer); }