https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0bca12e01fef27d127da0…
commit 0bca12e01fef27d127da0db8694d9e19c5d96578
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Nov 25 13:29:26 2018 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sun Nov 25 13:29:26 2018 +0100
[IPHLPAPI] Implement AllocateAndGetTcpExTable2FromStack()
CORE-14391
---
dll/win32/iphlpapi/iphlpapi.spec | 2 +-
dll/win32/iphlpapi/iphlpapi_main.c | 46 ++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/dll/win32/iphlpapi/iphlpapi.spec b/dll/win32/iphlpapi/iphlpapi.spec
index 742f87ab47..0de4711f4b 100644
--- a/dll/win32/iphlpapi/iphlpapi.spec
+++ b/dll/win32/iphlpapi/iphlpapi.spec
@@ -4,7 +4,7 @@
@ stdcall AllocateAndGetIpAddrTableFromStack( ptr long long long )
@ stdcall AllocateAndGetIpForwardTableFromStack( ptr long long long )
@ stdcall AllocateAndGetIpNetTableFromStack( ptr long long long )
-@ stub AllocateAndGetTcpExTable2FromStack
+@ stdcall AllocateAndGetTcpExTable2FromStack( ptr long long long long long )
@ stdcall AllocateAndGetTcpExTableFromStack( ptr long long long long )
@ stdcall AllocateAndGetTcpTableFromStack( ptr long long long )
@ stub AllocateAndGetUdpExTable2FromStack
diff --git a/dll/win32/iphlpapi/iphlpapi_main.c b/dll/win32/iphlpapi/iphlpapi_main.c
index 26423b9f5e..103f1a411a 100644
--- a/dll/win32/iphlpapi/iphlpapi_main.c
+++ b/dll/win32/iphlpapi/iphlpapi_main.c
@@ -349,6 +349,52 @@ DWORD WINAPI
AllocateAndGetTcpExTableFromStack(PMIB_TCPTABLE_OWNER_PID *ppTcpTab
}
+/******************************************************************
+ * AllocateAndGetTcpExTable2FromStack (IPHLPAPI.@)
+ *
+ *
+ * PARAMS
+ *
+ * ppTcpTable [Out]
+ * bOrder [In] -- passed to GetExtendedTcpTable to order the table
+ * heap [In] -- heap from which the table is allocated
+ * flags [In] -- flags to HeapAlloc
+ * family [In] -- passed to GetExtendedTcpTable to select INET family
+ * class [In] -- passed to GetExtendedTcpTable to select information
+ *
+ * RETURNS
+ *
+ * DWORD
+ *
+ */
+DWORD WINAPI AllocateAndGetTcpExTable2FromStack(PVOID *ppTcpTable,
+ BOOL bOrder, HANDLE heap, DWORD flags, DWORD family, TCP_TABLE_CLASS class)
+{
+ DWORD ret;
+
+ TRACE("ppTcpTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx, family %ld, class
%ld\n",
+ ppTcpTable, (DWORD)bOrder, (DWORD)heap, flags, family, class);
+ if (!ppTcpTable)
+ ret = ERROR_INVALID_PARAMETER;
+ else {
+ DWORD dwSize = 0;
+
+ *ppTcpTable = NULL;
+ ret = GetExtendedTcpTable(*ppTcpTable, &dwSize, bOrder, family, class, 0);
+ if (ret == ERROR_INSUFFICIENT_BUFFER) {
+ *ppTcpTable = HeapAlloc(heap, flags, dwSize);
+ ret = GetExtendedTcpTable(*ppTcpTable, &dwSize, bOrder, family, class, 0);
+ if (ret != NO_ERROR) {
+ HeapFree(heap, flags, *ppTcpTable);
+ *ppTcpTable = NULL;
+ }
+ }
+ }
+ TRACE("returning %ld\n", ret);
+ return ret;
+}
+
+
/******************************************************************
* AllocateAndGetUdpTableFromStack (IPHLPAPI.@)
*