https://git.reactos.org/?p=reactos.git;a=commitdiff;h=11b706429c9e817b03717…
commit 11b706429c9e817b03717fe09564a96f75c8702d
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sat Oct 7 22:12:34 2023 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Oct 8 17:11:26 2023 +0200
[WSHTCPIP] Remove unneeded headers + Fix bugs.
- Mismatch NTSTATUS/DWORD for win32 errors;
- Close handle returned from openTcpFile() with closeTcpFile().
---
dll/win32/wshtcpip/iflist.c | 40 +++++++++++++++++++---------------------
dll/win32/wshtcpip/wshtcpip.c | 2 +-
2 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/dll/win32/wshtcpip/iflist.c b/dll/win32/wshtcpip/iflist.c
index 637552f08d2..44c685a5ad5 100644
--- a/dll/win32/wshtcpip/iflist.c
+++ b/dll/win32/wshtcpip/iflist.c
@@ -8,9 +8,6 @@
#include "wshtcpip.h"
-#define WIN32_NO_STATUS /* Tell Windows headers you'll use ntstatus.s from NDK */
-#include <windows.h> /* Declare Windows Headers like you normally would */
-#include <ntndk.h> /* Declare the NDK Headers */
#include <iptypes.h>
#include <wine/list.h>
@@ -29,7 +26,7 @@ BOOL AllocAndGetEntityArray(
ULONG outBufLen, outBufLenNeeded;
void* outBuf = NULL;
TCP_REQUEST_QUERY_INFORMATION_EX inTcpReq;
- NTSTATUS Status;
+ DWORD dwError;
TDIEntityID *pEntities;
/* Set up Request */
@@ -62,7 +59,7 @@ BOOL AllocAndGetEntityArray(
if (outBuf == NULL)
break;
- Status = NO_ERROR;
+ dwError = NO_ERROR;
if (!DeviceIoControl(
TcpFile,
IOCTL_TCP_QUERY_INFORMATION_EX,
@@ -72,16 +69,18 @@ BOOL AllocAndGetEntityArray(
outBufLen,
&outBufLenNeeded,
NULL))
- Status = GetLastError();
+ {
+ dwError = GetLastError();
+ }
/* We need TDI_SUCCESS and the outBufLenNeeded must be equal or smaller
than our buffer (outBufLen). */
- if (Status != NO_ERROR)
+ if (dwError != NO_ERROR)
{
HeapFree(hHeap, 0, outBuf);
break;
}
- /* status = Success; was the buffer large enough? */
+ /* dwError = Success; was the buffer large enough? */
if (outBufLenNeeded <= outBufLen)
{
result = TRUE;
@@ -134,7 +133,7 @@ INT GetIPSNMPInfo(
&BufLenNeeded,
NULL))
{
- DPRINT("DeviceIoControl (IPSNMPInfo) failed, Status %li!\n",
GetLastError());
+ DPRINT("DeviceIoControl (IPSNMPInfo) failed, Error %ld!\n",
GetLastError());
return WSAEFAULT;
}
@@ -164,7 +163,7 @@ INT GetTdiEntityType(
&BufLenNeeded,
NULL))
{
- DPRINT("DeviceIoControl (TdiEntityType) failed, Status %li!\n",
GetLastError());
+ DPRINT("DeviceIoControl (TdiEntityType) failed, Error %ld!\n",
GetLastError());
return WSAEFAULT;
}
@@ -195,7 +194,7 @@ INT GetIFEntry(
&BufLenNeeded,
NULL))
{
- DPRINT("DeviceIoControl (IFEntry) failed, Status %li!\n",
GetLastError());
+ DPRINT("DeviceIoControl (IFEntry) failed, Error %ld!\n",
GetLastError());
return WSAEFAULT;
}
@@ -230,20 +229,20 @@ WSHIoctl_GetInterfaceList(
DWORD outIDCount, i1, iAddr;
DWORD bCastAddr, outNumberOfBytes;
ULONG BufLenNeeded, BufLen, IFEntryLen, TdiType;
- HANDLE TcpFile = 0;
+ HANDLE TcpFile = NULL;
HANDLE hHeap = GetProcessHeap();
- DWORD LastErr;
- INT res = -1;
+ NTSTATUS Status;
+ INT res;
/* Init Interface-ID-List */
IntfIDList = HeapAlloc(hHeap, 0, sizeof(*IntfIDList));
list_init(&IntfIDList->entry);
/* open tcp-driver */
- LastErr = openTcpFile(&TcpFile, FILE_READ_DATA | FILE_WRITE_DATA);
- if (!NT_SUCCESS(LastErr))
+ Status = openTcpFile(&TcpFile, FILE_READ_DATA | FILE_WRITE_DATA);
+ if (!NT_SUCCESS(Status))
{
- res = (INT)LastErr;
+ res = RtlNtStatusToDosError(Status);
goto cleanup;
}
@@ -330,8 +329,7 @@ WSHIoctl_GetInterfaceList(
&BufLenNeeded,
NULL))
{
- LastErr = GetLastError();
- DPRINT("DeviceIoControl failed, Status %li!\n", LastErr);
+ DPRINT("DeviceIoControl failed, Error %ld!\n", GetLastError());
res = WSAEFAULT;
goto cleanup;
}
@@ -426,8 +424,8 @@ WSHIoctl_GetInterfaceList(
res = NO_ERROR;
cleanup:
DPRINT("WSHIoctl_GetInterfaceList - CLEANUP\n");
- if (TcpFile != 0)
- NtClose(TcpFile);
+ if (TcpFile != NULL)
+ closeTcpFile(TcpFile);
if (pIFEntry != NULL)
HeapFree(hHeap, 0, pIFEntry);
LIST_FOR_EACH_ENTRY_SAFE_REV(pIntfIDItem, pIntfIDNext,
diff --git a/dll/win32/wshtcpip/wshtcpip.c b/dll/win32/wshtcpip/wshtcpip.c
index a66166c2e8f..b1e822620b5 100644
--- a/dll/win32/wshtcpip/wshtcpip.c
+++ b/dll/win32/wshtcpip/wshtcpip.c
@@ -417,7 +417,7 @@ SendRequest(
closeTcpFile(TcpCC);
- DPRINT("DeviceIoControl: %ld\n", ((Success != FALSE) ? 0 :
GetLastError()));
+ DPRINT("DeviceIoControl: %ld\n", (Success ? NO_ERROR : GetLastError()));
if (!Success)
return WSAEINVAL;