mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 15:36:04 +00:00
[TDILIB] Make tdiGetSetOfThings() return useful status
This commit is contained in:
parent
d70e92fcd3
commit
7c0a8eb555
1 changed files with 41 additions and 27 deletions
|
@ -34,8 +34,8 @@ NTSTATUS tdiGetSetOfThings( HANDLE tcpFile,
|
||||||
TCP_REQUEST_QUERY_INFORMATION_EX req = TCP_REQUEST_QUERY_INFORMATION_INIT;
|
TCP_REQUEST_QUERY_INFORMATION_EX req = TCP_REQUEST_QUERY_INFORMATION_INIT;
|
||||||
PVOID entitySet = 0;
|
PVOID entitySet = 0;
|
||||||
NTSTATUS status = STATUS_SUCCESS;
|
NTSTATUS status = STATUS_SUCCESS;
|
||||||
DWORD allocationSizeForEntityArray = entrySize * MAX_TDI_ENTITIES,
|
DWORD allocationSizeForEntityArray = entrySize * MAX_TDI_ENTITIES;
|
||||||
arraySize = entrySize * MAX_TDI_ENTITIES;
|
IO_STATUS_BLOCK Iosb;
|
||||||
|
|
||||||
req.ID.toi_class = toiClass;
|
req.ID.toi_class = toiClass;
|
||||||
req.ID.toi_type = toiType;
|
req.ID.toi_type = toiType;
|
||||||
|
@ -52,50 +52,64 @@ NTSTATUS tdiGetSetOfThings( HANDLE tcpFile,
|
||||||
* stabilizes.
|
* stabilizes.
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
status = DeviceIoControl( tcpFile,
|
status = NtDeviceIoControlFile( tcpFile,
|
||||||
IOCTL_TCP_QUERY_INFORMATION_EX,
|
NULL,
|
||||||
&req,
|
NULL,
|
||||||
sizeof(req),
|
NULL,
|
||||||
0,
|
&Iosb,
|
||||||
0,
|
IOCTL_TCP_QUERY_INFORMATION_EX,
|
||||||
&allocationSizeForEntityArray,
|
&req,
|
||||||
NULL );
|
sizeof(req),
|
||||||
|
NULL,
|
||||||
if(!status)
|
0);
|
||||||
|
if (status == STATUS_PENDING)
|
||||||
{
|
{
|
||||||
return STATUS_UNSUCCESSFUL;
|
status = NtWaitForSingleObject(tcpFile, FALSE, NULL);
|
||||||
|
if (NT_SUCCESS(status)) status = Iosb.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
arraySize = allocationSizeForEntityArray;
|
if(!NT_SUCCESS(status))
|
||||||
entitySet = HeapAlloc( GetProcessHeap(), 0, arraySize );
|
{
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
allocationSizeForEntityArray = Iosb.Information;
|
||||||
|
entitySet = HeapAlloc( GetProcessHeap(), 0, allocationSizeForEntityArray );
|
||||||
|
|
||||||
if( !entitySet ) {
|
if( !entitySet ) {
|
||||||
status = STATUS_INSUFFICIENT_RESOURCES;
|
status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = DeviceIoControl( tcpFile,
|
status = NtDeviceIoControlFile( tcpFile,
|
||||||
IOCTL_TCP_QUERY_INFORMATION_EX,
|
NULL,
|
||||||
&req,
|
NULL,
|
||||||
sizeof(req),
|
NULL,
|
||||||
entitySet,
|
&Iosb,
|
||||||
arraySize,
|
IOCTL_TCP_QUERY_INFORMATION_EX,
|
||||||
&allocationSizeForEntityArray,
|
&req,
|
||||||
NULL );
|
sizeof(req),
|
||||||
|
entitySet,
|
||||||
|
allocationSizeForEntityArray);
|
||||||
|
if (status == STATUS_PENDING)
|
||||||
|
{
|
||||||
|
status = NtWaitForSingleObject(tcpFile, FALSE, NULL);
|
||||||
|
if (NT_SUCCESS(status)) status = Iosb.Status;
|
||||||
|
}
|
||||||
|
|
||||||
/* This is why we have the loop -- we might have added an adapter */
|
/* This is why we have the loop -- we might have added an adapter */
|
||||||
if( arraySize == allocationSizeForEntityArray )
|
if( Iosb.Information == allocationSizeForEntityArray )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
HeapFree( GetProcessHeap(), 0, entitySet );
|
HeapFree( GetProcessHeap(), 0, entitySet );
|
||||||
entitySet = 0;
|
entitySet = 0;
|
||||||
|
|
||||||
if(!status)
|
if(!NT_SUCCESS(status))
|
||||||
return STATUS_UNSUCCESSFUL;
|
return status;
|
||||||
} while( TRUE ); /* We break if the array we received was the size we
|
} while( TRUE ); /* We break if the array we received was the size we
|
||||||
* expected. Therefore, we got here because it wasn't */
|
* expected. Therefore, we got here because it wasn't */
|
||||||
|
|
||||||
*numEntries = (arraySize - fixedPart) / entrySize;
|
*numEntries = (allocationSizeForEntityArray - fixedPart) / entrySize;
|
||||||
*tdiEntitySet = entitySet;
|
*tdiEntitySet = entitySet;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue