https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7c0a8eb5555eee8a2c8c8…
commit 7c0a8eb5555eee8a2c8c8be201c5d283dc1ee636
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Nov 18 15:57:58 2018 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sun Nov 18 16:30:45 2018 +0100
[TDILIB] Make tdiGetSetOfThings() return useful status
---
sdk/lib/tdilib/enum.c | 68 +++++++++++++++++++++++++++++++--------------------
1 file changed, 41 insertions(+), 27 deletions(-)
diff --git a/sdk/lib/tdilib/enum.c b/sdk/lib/tdilib/enum.c
index 7b36d4bcb9..acd6386603 100644
--- a/sdk/lib/tdilib/enum.c
+++ b/sdk/lib/tdilib/enum.c
@@ -34,8 +34,8 @@ NTSTATUS tdiGetSetOfThings( HANDLE tcpFile,
TCP_REQUEST_QUERY_INFORMATION_EX req = TCP_REQUEST_QUERY_INFORMATION_INIT;
PVOID entitySet = 0;
NTSTATUS status = STATUS_SUCCESS;
- DWORD allocationSizeForEntityArray = entrySize * MAX_TDI_ENTITIES,
- arraySize = entrySize * MAX_TDI_ENTITIES;
+ DWORD allocationSizeForEntityArray = entrySize * MAX_TDI_ENTITIES;
+ IO_STATUS_BLOCK Iosb;
req.ID.toi_class = toiClass;
req.ID.toi_type = toiType;
@@ -52,50 +52,64 @@ NTSTATUS tdiGetSetOfThings( HANDLE tcpFile,
* stabilizes.
*/
do {
- status = DeviceIoControl( tcpFile,
- IOCTL_TCP_QUERY_INFORMATION_EX,
- &req,
- sizeof(req),
- 0,
- 0,
- &allocationSizeForEntityArray,
- NULL );
-
- if(!status)
+ status = NtDeviceIoControlFile( tcpFile,
+ NULL,
+ NULL,
+ NULL,
+ &Iosb,
+ IOCTL_TCP_QUERY_INFORMATION_EX,
+ &req,
+ sizeof(req),
+ NULL,
+ 0);
+ if (status == STATUS_PENDING)
{
- return STATUS_UNSUCCESSFUL;
+ status = NtWaitForSingleObject(tcpFile, FALSE, NULL);
+ if (NT_SUCCESS(status)) status = Iosb.Status;
}
- arraySize = allocationSizeForEntityArray;
- entitySet = HeapAlloc( GetProcessHeap(), 0, arraySize );
+ if(!NT_SUCCESS(status))
+ {
+ return status;
+ }
+
+ allocationSizeForEntityArray = Iosb.Information;
+ entitySet = HeapAlloc( GetProcessHeap(), 0, allocationSizeForEntityArray );
if( !entitySet ) {
status = STATUS_INSUFFICIENT_RESOURCES;
return status;
}
- status = DeviceIoControl( tcpFile,
- IOCTL_TCP_QUERY_INFORMATION_EX,
- &req,
- sizeof(req),
- entitySet,
- arraySize,
- &allocationSizeForEntityArray,
- NULL );
+ status = NtDeviceIoControlFile( tcpFile,
+ NULL,
+ NULL,
+ NULL,
+ &Iosb,
+ IOCTL_TCP_QUERY_INFORMATION_EX,
+ &req,
+ 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 */
- if( arraySize == allocationSizeForEntityArray )
+ if( Iosb.Information == allocationSizeForEntityArray )
break;
HeapFree( GetProcessHeap(), 0, entitySet );
entitySet = 0;
- if(!status)
- return STATUS_UNSUCCESSFUL;
+ if(!NT_SUCCESS(status))
+ return status;
} while( TRUE ); /* We break if the array we received was the size we
* expected. Therefore, we got here because it wasn't */
- *numEntries = (arraySize - fixedPart) / entrySize;
+ *numEntries = (allocationSizeForEntityArray - fixedPart) / entrySize;
*tdiEntitySet = entitySet;
return STATUS_SUCCESS;