git-extra (WhoUses): auto-grow the buffer for the system information
Without this, `WhoUses.exe` can fail with a "No handle information" with a large number of running processes. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Родитель
289d05b665
Коммит
616033d415
|
@ -452,15 +452,20 @@ BOOL SystemHandleInformation::Refresh()
|
|||
(SYSTEM_HANDLE_INFORMATION*)
|
||||
VirtualAlloc( NULL, size, MEM_COMMIT, PAGE_READWRITE );
|
||||
|
||||
if ( pSysHandleInformation == NULL )
|
||||
return FALSE;
|
||||
while ( 1 ) {
|
||||
if ( pSysHandleInformation == NULL )
|
||||
return FALSE;
|
||||
|
||||
// Query the needed buffer size for the objects ( system wide )
|
||||
if ( INtDll::NtQuerySystemInformation( 16, pSysHandleInformation,
|
||||
size, &needed ) != 0 )
|
||||
{
|
||||
if ( needed == 0 )
|
||||
// Query the needed buffer size for the objects ( system wide )
|
||||
DWORD result = INtDll::NtQuerySystemInformation( 16,
|
||||
pSysHandleInformation, size, &needed );
|
||||
if ( result == 0 )
|
||||
break;
|
||||
|
||||
if ( result != STATUS_INFO_LENGTH_MISMATCH )
|
||||
{
|
||||
fprintf( stderr, "NtQuerySystemInformation: 0x%x\n",
|
||||
result );
|
||||
ret = FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -473,17 +478,6 @@ BOOL SystemHandleInformation::Refresh()
|
|||
MEM_COMMIT, PAGE_READWRITE );
|
||||
}
|
||||
|
||||
if ( pSysHandleInformation == NULL )
|
||||
return FALSE;
|
||||
|
||||
// Query the objects ( system wide )
|
||||
if ( INtDll::NtQuerySystemInformation( 16, pSysHandleInformation,
|
||||
size, NULL ) != 0 )
|
||||
{
|
||||
ret = FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Iterating through the objects
|
||||
for ( i = 0; i < pSysHandleInformation->Count; i++ )
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче