ReactOS 0.4.16-dev-1163-gec5b142
iphlpapi_main.c
Go to the documentation of this file.
1/*
2 * iphlpapi dll implementation
3 *
4 * Copyright (C) 2003 Juan Lang
5 * 2018 Pierre Schweitzer
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#define DEBUG
23
24#include <config.h>
25#include "iphlpapi_private.h"
26#include <strsafe.h>
27#include <psapi.h>
28
30
38
40{
41 switch (fdwReason) {
43 DisableThreadLibraryCalls( hinstDLL );
45 break;
46
49 break;
50 }
51 return TRUE;
52}
53
54/******************************************************************
55 * AddIPAddress (IPHLPAPI.@)
56 *
57 * PARAMS
58 * Address [In]
59 * IpMask [In]
60 * IfIndex [In]
61 * NTEContext [In/Out]
62 * NTEInstance [In/Out]
63 *
64 * RETURNS
65 * DWORD
66 */
67DWORD WINAPI AddIPAddress(IPAddr Address, IPMask Netmask, DWORD IfIndex, PULONG NteContext, PULONG NteInstance)
68{
69 return RtlNtStatusToDosError(addIPAddress(Address, Netmask, IfIndex, NteContext, NteInstance));
70}
71
73{
74 DWORD ndx, retVal = 0, numRoutes = getNumRoutes();
76 if (!table) return 0;
77
78 for (ndx = 0; ndx < numRoutes; ndx++)
79 {
80 if ((table->routes[ndx].ifIndex == (index)) && (table->routes[ndx].dest == 0))
81 retVal = table->routes[ndx].gateway;
82 }
84 return retVal;
85}
86
87/******************************************************************
88 * AllocateAndGetIfTableFromStack (IPHLPAPI.@)
89 *
90 * PARAMS
91 * ppIfTable [Out] -- pointer into which the MIB_IFTABLE is
92 * allocated and returned.
93 * bOrder [In] -- passed to GetIfTable to order the table
94 * heap [In] -- heap from which the table is allocated
95 * flags [In] -- flags to HeapAlloc
96 *
97 * RETURNS -- ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
98 * GetIfTable returns otherwise
99 */
101 BOOL bOrder, HANDLE heap, DWORD flags)
102{
103 DWORD ret;
104
105 TRACE("ppIfTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx\n", ppIfTable,
106 (DWORD)bOrder, heap, flags);
107 if (!ppIfTable)
109 else {
110 DWORD dwSize = 0;
111
112 *ppIfTable = NULL;
113 ret = GetIfTable(*ppIfTable, &dwSize, bOrder);
115 *ppIfTable = (PMIB_IFTABLE)HeapAlloc(heap, flags, dwSize);
116 ret = GetIfTable(*ppIfTable, &dwSize, bOrder);
117 if (ret != NO_ERROR) {
118 HeapFree(heap, flags, *ppIfTable);
119 *ppIfTable = NULL;
120 }
121 }
122 }
123 TRACE("returning %ld\n", ret);
124 return ret;
125}
126
127
128/******************************************************************
129 * AllocateAndGetIpAddrTableFromStack (IPHLPAPI.@)
130 *
131 * PARAMS
132 * ppIpAddrTable [Out]
133 * bOrder [In] -- passed to GetIpAddrTable to order the table
134 * heap [In] -- heap from which the table is allocated
135 * flags [In] -- flags to HeapAlloc
136 *
137 * RETURNS
138 * DWORD
139 */
141 BOOL bOrder, HANDLE heap, DWORD flags)
142{
143 DWORD ret;
144
145 TRACE("ppIpAddrTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx\n",
146 ppIpAddrTable, (DWORD)bOrder, heap, flags);
147 if (!ppIpAddrTable)
149 else {
150 DWORD dwSize = 0;
151
152 *ppIpAddrTable = NULL;
153 ret = GetIpAddrTable(*ppIpAddrTable, &dwSize, bOrder);
155 *ppIpAddrTable = (PMIB_IPADDRTABLE)HeapAlloc(heap, flags, dwSize);
156 ret = GetIpAddrTable(*ppIpAddrTable, &dwSize, bOrder);
157 if (ret != NO_ERROR) {
158 HeapFree(heap, flags, *ppIpAddrTable);
159 *ppIpAddrTable = NULL;
160 }
161 }
162 }
163 TRACE("returning %ld\n", ret);
164 return ret;
165}
166
167
168/******************************************************************
169 * AllocateAndGetIpForwardTableFromStack (IPHLPAPI.@)
170 *
171 * ppIpForwardTable [Out] -- pointer into which the MIB_IPFORWARDTABLE is
172 * allocated and returned.
173 * bOrder [In] -- passed to GetIfTable to order the table
174 * heap [In] -- heap from which the table is allocated
175 * flags [In] -- flags to HeapAlloc
176 *
177 * RETURNS -- ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
178 * GetIpForwardTable returns otherwise
179 */
181 ppIpForwardTable, BOOL bOrder, HANDLE heap, DWORD flags)
182{
183 DWORD ret;
184
185 TRACE("ppIpForwardTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx\n",
186 ppIpForwardTable, (DWORD)bOrder, heap, flags);
187 if (!ppIpForwardTable)
189 else {
190 DWORD dwSize = 0;
191
192 *ppIpForwardTable = NULL;
193 ret = GetIpForwardTable(*ppIpForwardTable, &dwSize, bOrder);
195 *ppIpForwardTable = (PMIB_IPFORWARDTABLE)HeapAlloc(heap, flags, dwSize);
196 ret = GetIpForwardTable(*ppIpForwardTable, &dwSize, bOrder);
197 if (ret != NO_ERROR) {
198 HeapFree(heap, flags, *ppIpForwardTable);
199 *ppIpForwardTable = NULL;
200 }
201 }
202 }
203 TRACE("returning %ld\n", ret);
204 return ret;
205}
206
207
208/******************************************************************
209 * AllocateAndGetIpNetTableFromStack (IPHLPAPI.@)
210 *
211 * PARAMS
212 * ppIpNetTable [Out]
213 * bOrder [In] -- passed to GetIpNetTable to order the table
214 * heap [In] -- heap from which the table is allocated
215 * flags [In] -- flags to HeapAlloc
216 *
217 * RETURNS
218 * DWORD
219 */
221 BOOL bOrder, HANDLE heap, DWORD flags)
222{
223 DWORD ret;
224
225 TRACE("ppIpNetTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx\n",
226 ppIpNetTable, (DWORD)bOrder, heap, flags);
227 if (!ppIpNetTable)
229 else {
230 DWORD dwSize = 0;
231
232 *ppIpNetTable = NULL;
233 ret = GetIpNetTable(*ppIpNetTable, &dwSize, bOrder);
235 *ppIpNetTable = (PMIB_IPNETTABLE)HeapAlloc(heap, flags, dwSize);
236 ret = GetIpNetTable(*ppIpNetTable, &dwSize, bOrder);
237 if (ret != NO_ERROR) {
238 HeapFree(heap, flags, *ppIpNetTable);
239 *ppIpNetTable = NULL;
240 }
241 }
242 }
243 TRACE("returning %ld\n", ret);
244 return ret;
245}
246
247
248/******************************************************************
249 * AllocateAndGetTcpTableFromStack (IPHLPAPI.@)
250 *
251 * PARAMS
252 * ppTcpTable [Out]
253 * bOrder [In] -- passed to GetTcpTable to order the table
254 * heap [In] -- heap from which the table is allocated
255 * flags [In] -- flags to HeapAlloc
256 *
257 * RETURNS
258 * DWORD
259 */
261 BOOL bOrder, HANDLE heap, DWORD flags)
262{
263 DWORD ret;
264
265 TRACE("ppTcpTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx\n",
266 ppTcpTable, (DWORD)bOrder, heap, flags);
267 if (!ppTcpTable)
269 else {
270 DWORD dwSize = 0;
271
272 *ppTcpTable = NULL;
273 ret = GetTcpTable(*ppTcpTable, &dwSize, bOrder);
275 *ppTcpTable = (PMIB_TCPTABLE)HeapAlloc(heap, flags, dwSize);
276 ret = GetTcpTable(*ppTcpTable, &dwSize, bOrder);
277 if (ret != NO_ERROR) {
278 HeapFree(heap, flags, *ppTcpTable);
279 *ppTcpTable = NULL;
280 }
281 }
282 }
283 TRACE("returning %ld\n", ret);
284 return ret;
285}
286
287
288/******************************************************************
289 * AllocateAndGetTcpExTableFromStack (IPHLPAPI.@)
290 *
291 * PARAMS
292 * ppTcpTable [Out]
293 * bOrder [In] -- passed to GetExtendedTcpTable to order the table
294 * heap [In] -- heap from which the table is allocated
295 * flags [In] -- flags to HeapAlloc
296 * family [In] -- passed to GetExtendedTcpTable to select INET family
297 *
298 * RETURNS
299 * DWORD
300 */
302 BOOL bOrder, HANDLE heap, DWORD flags, DWORD family)
303{
304 DWORD ret;
305
306 TRACE("ppTcpTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx, family 0x%08lx\n",
307 ppTcpTable, (DWORD)bOrder, heap, flags, family);
308 if (!ppTcpTable)
310 else {
311 DWORD dwSize = 0;
312
313 *ppTcpTable = NULL;
314 ret = GetExtendedTcpTable(*ppTcpTable, &dwSize, bOrder, family, TCP_TABLE_OWNER_PID_ALL, 0);
317 ret = GetExtendedTcpTable(*ppTcpTable, &dwSize, bOrder, family, TCP_TABLE_OWNER_PID_ALL, 0);
318 if (ret != NO_ERROR) {
319 HeapFree(heap, flags, *ppTcpTable);
320 *ppTcpTable = NULL;
321 }
322 }
323 }
324 TRACE("returning %ld\n", ret);
325 return ret;
326}
327
328
329/******************************************************************
330 * AllocateAndGetTcpExTable2FromStack (IPHLPAPI.@)
331 *
332 * PARAMS
333 * ppTcpTable [Out]
334 * bOrder [In] -- passed to GetExtendedTcpTable to order the table
335 * heap [In] -- heap from which the table is allocated
336 * flags [In] -- flags to HeapAlloc
337 * family [In] -- passed to GetExtendedTcpTable to select INET family
338 * class [In] -- passed to GetExtendedTcpTable to select information
339 *
340 * RETURNS
341 * DWORD
342 */
344 BOOL bOrder, HANDLE heap, DWORD flags, DWORD family, TCP_TABLE_CLASS class)
345{
346 DWORD ret;
347
348 TRACE("ppTcpTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx, family %ld, class %ld\n",
349 ppTcpTable, (DWORD)bOrder, heap, flags, family, class);
350 if (!ppTcpTable)
352 else {
353 DWORD dwSize = 0;
354
355 *ppTcpTable = NULL;
356 ret = GetExtendedTcpTable(*ppTcpTable, &dwSize, bOrder, family, class, 0);
358 *ppTcpTable = HeapAlloc(heap, flags, dwSize);
359 ret = GetExtendedTcpTable(*ppTcpTable, &dwSize, bOrder, family, class, 0);
360 if (ret != NO_ERROR) {
361 HeapFree(heap, flags, *ppTcpTable);
362 *ppTcpTable = NULL;
363 }
364 }
365 }
366 TRACE("returning %ld\n", ret);
367 return ret;
368}
369
370
371/******************************************************************
372 * AllocateAndGetUdpTableFromStack (IPHLPAPI.@)
373 *
374 * PARAMS
375 * ppUdpTable [Out]
376 * bOrder [In] -- passed to GetUdpTable to order the table
377 * heap [In] -- heap from which the table is allocated
378 * flags [In] -- flags to HeapAlloc
379 *
380 * RETURNS
381 * DWORD
382 */
384 BOOL bOrder, HANDLE heap, DWORD flags)
385{
386 DWORD ret;
387
388 TRACE("ppUdpTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx\n",
389 ppUdpTable, (DWORD)bOrder, heap, flags);
390 if (!ppUdpTable)
392 else {
393 DWORD dwSize = 0;
394
395 *ppUdpTable = NULL;
396 ret = GetUdpTable(*ppUdpTable, &dwSize, bOrder);
398 *ppUdpTable = (PMIB_UDPTABLE)HeapAlloc(heap, flags, dwSize);
399 ret = GetUdpTable(*ppUdpTable, &dwSize, bOrder);
400 if (ret != NO_ERROR) {
401 HeapFree(heap, flags, *ppUdpTable);
402 *ppUdpTable = NULL;
403 }
404 }
405 }
406 TRACE("returning %ld\n", ret);
407 return ret;
408}
409
410
411/******************************************************************
412 * AllocateAndGetUdpExTableFromStack (IPHLPAPI.@)
413 *
414 * PARAMS
415 * ppUdpTable [Out]
416 * bOrder [In] -- passed to GetExtendedUdpTable to order the table
417 * heap [In] -- heap from which the table is allocated
418 * flags [In] -- flags to HeapAlloc
419 * family [In] -- passed to GetExtendedUdpTable to select INET family
420 *
421 * RETURNS
422 * DWORD
423 */
425 BOOL bOrder, HANDLE heap, DWORD flags, DWORD family)
426{
427 DWORD ret;
428
429 TRACE("ppUdpTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx, family 0x%08lx\n",
430 ppUdpTable, (DWORD)bOrder, heap, flags, family);
431 if (!ppUdpTable)
433 else {
434 DWORD dwSize = 0;
435
436 *ppUdpTable = NULL;
437 ret = GetExtendedUdpTable(*ppUdpTable, &dwSize, bOrder, family, UDP_TABLE_OWNER_PID, 0);
440 ret = GetExtendedUdpTable(*ppUdpTable, &dwSize, bOrder, family, UDP_TABLE_OWNER_PID, 0);
441 if (ret != NO_ERROR) {
442 HeapFree(heap, flags, *ppUdpTable);
443 *ppUdpTable = NULL;
444 }
445 }
446 }
447 TRACE("returning %ld\n", ret);
448 return ret;
449}
450
451
452/******************************************************************
453 * AllocateAndGetUdpExTable2FromStack (IPHLPAPI.@)
454 *
455 * PARAMS
456 * ppUdpTable [Out]
457 * bOrder [In] -- passed to GetExtendedUdpTable to order the table
458 * heap [In] -- heap from which the table is allocated
459 * flags [In] -- flags to HeapAlloc
460 * family [In] -- passed to GetExtendedUdpTable to select INET family
461 * class [In] -- passed to GetExtendedUdpTable to select information
462 *
463 * RETURNS
464 * DWORD
465 */
467 BOOL bOrder, HANDLE heap, DWORD flags, DWORD family, UDP_TABLE_CLASS class)
468{
469 DWORD ret;
470
471 TRACE("ppUdpTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx, family %ld, class %ld\n",
472 ppUdpTable, (DWORD)bOrder, heap, flags, family, class);
473 if (!ppUdpTable)
475 else {
476 DWORD dwSize = 0;
477
478 *ppUdpTable = NULL;
479 ret = GetExtendedUdpTable(*ppUdpTable, &dwSize, bOrder, family, class, 0);
481 *ppUdpTable = HeapAlloc(heap, flags, dwSize);
482 ret = GetExtendedUdpTable(*ppUdpTable, &dwSize, bOrder, family, class, 0);
483 if (ret != NO_ERROR) {
484 HeapFree(heap, flags, *ppUdpTable);
485 *ppUdpTable = NULL;
486 }
487 }
488 }
489 TRACE("returning %ld\n", ret);
490 return ret;
491}
492
493
494/******************************************************************
495 * CreateIpForwardEntry (IPHLPAPI.@)
496 *
497 * PARAMS
498 * pRoute [In/Out]
499 *
500 * RETURNS
501 * DWORD
502 */
504{
505 return createIpForwardEntry( pRoute );
506}
507
508
509/******************************************************************
510 * CreateIpNetEntry (IPHLPAPI.@)
511 *
512 * PARAMS
513 * pArpEntry [In/Out]
514 *
515 * RETURNS
516 * DWORD
517 */
519{
520 TRACE("pArpEntry %p\n", pArpEntry);
521 /* could use SIOCSARP on systems that support it, not sure I want to */
522 FIXME(":stub\n");
523 return (DWORD) 0;
524}
525
526
527/******************************************************************
528 * CreateProxyArpEntry (IPHLPAPI.@)
529 *
530 * PARAMS
531 * dwAddress [In]
532 * dwMask [In]
533 * dwIfIndex [In]
534 *
535 * RETURNS
536 * DWORD
537 */
538DWORD WINAPI CreateProxyArpEntry(DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
539{
540 TRACE("dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx\n", dwAddress,
541 dwMask, dwIfIndex);
542 FIXME(":stub\n");
543 /* marking Win2K+ functions not supported */
544 return ERROR_NOT_SUPPORTED;
545}
546
547
548/******************************************************************
549 * DeleteIPAddress (IPHLPAPI.@)
550 *
551 * PARAMS
552 * NTEContext [In]
553 *
554 * RETURNS
555 * DWORD
556 */
558{
559 TRACE("NTEContext %ld\n", NTEContext);
560 return RtlNtStatusToDosError(deleteIpAddress(NTEContext));
561}
562
563
564/******************************************************************
565 * DeleteIpForwardEntry (IPHLPAPI.@)
566 *
567 * PARAMS
568 * pRoute [In/Out]
569 *
570 * RETURNS
571 * DWORD
572 */
574{
575 return deleteIpForwardEntry( pRoute );
576}
577
578
579/******************************************************************
580 * DeleteIpNetEntry (IPHLPAPI.@)
581 *
582 * PARAMS
583 * pArpEntry [In/Out]
584 *
585 * RETURNS
586 * DWORD
587 */
589{
590 TRACE("pArpEntry %p\n", pArpEntry);
591 /* could use SIOCDARP on systems that support it, not sure I want to */
592 FIXME(":stub\n");
593 return (DWORD) 0;
594}
595
596
597/******************************************************************
598 * DeleteProxyArpEntry (IPHLPAPI.@)
599 *
600 * PARAMS
601 * dwAddress [In]
602 * dwMask [In]
603 * dwIfIndex [In]
604 *
605 * RETURNS
606 * DWORD
607 */
608DWORD WINAPI DeleteProxyArpEntry(DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
609{
610 TRACE("dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx\n", dwAddress,
611 dwMask, dwIfIndex);
612 FIXME(":stub\n");
613 /* marking Win2K+ functions not supported */
614 return ERROR_NOT_SUPPORTED;
615}
616
617/******************************************************************
618 * EnableRouter (IPHLPAPI.@)
619 *
620 * PARAMS
621 * pHandle [In/Out]
622 * pOverlapped [In/Out]
623 *
624 * RETURNS
625 * DWORD
626 */
627DWORD WINAPI EnableRouter(HANDLE * pHandle, OVERLAPPED * pOverlapped)
628{
629 TRACE("pHandle %p, pOverlapped %p\n", pHandle, pOverlapped);
630 FIXME(":stub\n");
631 /* could echo "1" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
632 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
633 marking Win2K+ functions not supported */
634 return ERROR_NOT_SUPPORTED;
635}
636
637
638/******************************************************************
639 * FlushIpNetTable (IPHLPAPI.@)
640 *
641 * PARAMS
642 * dwIfIndex [In]
643 *
644 * RETURNS
645 * DWORD
646 */
648{
649 TRACE("dwIfIndex 0x%08lx\n", dwIfIndex);
650 FIXME(":stub\n");
651 /* this flushes the arp cache of the given index
652 marking Win2K+ functions not supported */
653 return ERROR_NOT_SUPPORTED;
654}
655
656
657/******************************************************************
658 * GetAdapterIndex (IPHLPAPI.@)
659 *
660 * PARAMS
661 * AdapterName [In/Out]
662 * IfIndex [In/Out]
663 *
664 * RETURNS
665 * DWORD
666 */
668{
669 TRACE("AdapterName %p, IfIndex %p\n", AdapterName, IfIndex);
670 FIXME(":stub\n");
671 /* marking Win2K+ functions not supported */
672 return ERROR_NOT_SUPPORTED;
673}
674
675
676/******************************************************************
677 * GetAdaptersInfo (IPHLPAPI.@)
678 *
679 * PARAMS
680 * pAdapterInfo [In/Out]
681 * pOutBufLen [In/Out]
682 *
683 * RETURNS
684 * DWORD
685 */
687{
688 DWORD ret;
689
690 TRACE("pAdapterInfo %p, pOutBufLen %p\n", pAdapterInfo, pOutBufLen);
691 if (!pOutBufLen)
693 else {
694 DWORD numNonLoopbackInterfaces = getNumNonLoopbackInterfaces();
695
696 if (numNonLoopbackInterfaces > 0) {
697 /* this calculation assumes only one address in the IP_ADDR_STRING lists.
698 that's okay, because:
699 - we don't get multiple addresses per adapter anyway
700 - we don't know about per-adapter gateways
701 - DHCP and WINS servers can have max one entry per list */
702 ULONG size = sizeof(IP_ADAPTER_INFO) * numNonLoopbackInterfaces;
703
704 if (!pAdapterInfo || *pOutBufLen < size) {
705 *pOutBufLen = size;
707 }
708 else {
710
711 if (table) {
712 size = sizeof(IP_ADAPTER_INFO) * table->numIndexes;
713 if (*pOutBufLen < size) {
714 *pOutBufLen = size;
716 }
717 else {
718 DWORD ndx;
719 HKEY hKey;
720 BOOL winsEnabled = FALSE;
721 IP_ADDRESS_STRING primaryWINS, secondaryWINS;
722
723 memset(pAdapterInfo, 0, size);
724 /* @@ Wine registry key: HKCU\Software\Wine\Network */
725 if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Network", &hKey) == ERROR_SUCCESS) {
726 DWORD size = sizeof(primaryWINS.String);
727 unsigned long addr;
728
729 RegQueryValueExA(hKey, "WinsServer", NULL, NULL,
730 (PBYTE)primaryWINS.String, &size);
731 addr = inet_addr(primaryWINS.String);
732 if (addr != INADDR_NONE && addr != INADDR_ANY)
733 winsEnabled = TRUE;
734 size = sizeof(secondaryWINS.String);
735 RegQueryValueExA(hKey, "BackupWinsServer", NULL, NULL,
736 (PBYTE)secondaryWINS.String, &size);
737 addr = inet_addr(secondaryWINS.String);
738 if (addr != INADDR_NONE && addr != INADDR_ANY)
739 winsEnabled = TRUE;
741 }
742 TRACE("num of index is %lu\n", table->numIndexes);
743 for (ndx = 0; ndx < table->numIndexes; ndx++) {
744 PIP_ADAPTER_INFO ptr = &pAdapterInfo[ndx];
745 DWORD addrLen = sizeof(ptr->Address), type;
746 const char *ifname =
747 getInterfaceNameByIndex(table->indexes[ndx]);
748 if (!ifname) {
750 break;
751 }
752
753 /* on Win98 this is left empty, but whatever */
754 strncpy(ptr->AdapterName,ifname,sizeof(ptr->AdapterName));
755 consumeInterfaceName(ifname);
756 ptr->AdapterName[MAX_ADAPTER_NAME_LENGTH] = '\0';
757 getInterfacePhysicalByIndex(table->indexes[ndx], &addrLen,
758 ptr->Address, &type);
759 /* MS defines address length and type as UINT in some places and
760 DWORD in others, **sigh**. Don't want to assume that PUINT and
761 PDWORD are equiv (64-bit?) */
762 ptr->AddressLength = addrLen;
763 ptr->Type = type;
764 ptr->Index = table->indexes[ndx];
766 ptr->IpAddressList.IpAddress.String);
768 ptr->IpAddressList.IpMask.String);
769 ptr->IpAddressList.Context = ptr->Index;
771 ptr->GatewayList.IpAddress.String);
772 getDhcpInfoForAdapter(table->indexes[ndx], ptr);
773 if (winsEnabled) {
774 ptr->HaveWins = TRUE;
775 memcpy(ptr->PrimaryWinsServer.IpAddress.String,
776 primaryWINS.String, sizeof(primaryWINS.String));
777 memcpy(ptr->SecondaryWinsServer.IpAddress.String,
778 secondaryWINS.String, sizeof(secondaryWINS.String));
779 }
780 if (ndx < table->numIndexes - 1)
781 ptr->Next = &pAdapterInfo[ndx + 1];
782 else
783 ptr->Next = NULL;
784 }
785 ret = NO_ERROR;
786 }
787 free(table);
788 }
789 else
791 }
792 }
793 else
795 }
796 TRACE("returning %ld\n", ret);
797 return ret;
798}
799
800
801/******************************************************************
802 * GetBestInterface (IPHLPAPI.@)
803 *
804 * PARAMS
805 * dwDestAddr [In]
806 * pdwBestIfIndex [In/Out]
807 *
808 * RETURNS
809 * DWORD
810 */
811DWORD WINAPI GetBestInterface(IPAddr dwDestAddr, PDWORD pdwBestIfIndex)
812{
813 DWORD ret;
814
815 TRACE("dwDestAddr 0x%08lx, pdwBestIfIndex %p\n", dwDestAddr, pdwBestIfIndex);
816 if (!pdwBestIfIndex)
818 else {
819 MIB_IPFORWARDROW ipRow;
820
821 ret = GetBestRoute(dwDestAddr, 0, &ipRow);
822 if (ret == ERROR_SUCCESS)
823 *pdwBestIfIndex = ipRow.dwForwardIfIndex;
824 }
825 TRACE("returning %ld\n", ret);
826 return ret;
827}
828
829
830/******************************************************************
831 * GetBestRoute (IPHLPAPI.@)
832 *
833 * PARAMS
834 * dwDestAddr [In]
835 * dwSourceAddr [In]
836 * OUT [In]
837 *
838 * RETURNS
839 * DWORD
840 */
841DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDROW pBestRoute)
842{
844 DWORD ret;
845
846 TRACE("dwDestAddr 0x%08lx, dwSourceAddr 0x%08lx, pBestRoute %p\n", dwDestAddr,
847 dwSourceAddr, pBestRoute);
848 if (!pBestRoute)
850
852 if (table) {
853 DWORD ndx, minMaskSize, matchedNdx = 0;
854
855 for (ndx = 0, minMaskSize = 255; ndx < table->dwNumEntries; ndx++) {
856 if ((dwDestAddr & table->table[ndx].dwForwardMask) ==
857 (table->table[ndx].dwForwardDest & table->table[ndx].dwForwardMask)) {
858 DWORD hostMaskSize;
859
860 if (!_BitScanForward(&hostMaskSize, ntohl(table->table[ndx].dwForwardMask)))
861 {
862 hostMaskSize = 32;
863 }
864 if (hostMaskSize < minMaskSize) {
865 minMaskSize = hostMaskSize;
866 matchedNdx = ndx;
867 }
868 }
869 }
870 memcpy(pBestRoute, &table->table[matchedNdx], sizeof(MIB_IPFORWARDROW));
873 }
874 else
876 TRACE("returning %ld\n", ret);
877 return ret;
878}
879
880static int TcpTableSorter(const void *a, const void *b)
881{
882 int ret;
883
884 if (a && b) {
885 PMIB_TCPROW rowA = (PMIB_TCPROW)a, rowB = (PMIB_TCPROW)b;
886
887 ret = rowA->dwLocalAddr - rowB->dwLocalAddr;
888 if (ret == 0) {
889 ret = rowA->dwLocalPort - rowB->dwLocalPort;
890 if (ret == 0) {
891 ret = rowA->dwRemoteAddr - rowB->dwRemoteAddr;
892 if (ret == 0)
893 ret = rowA->dwRemotePort - rowB->dwRemotePort;
894 }
895 }
896 }
897 else
898 ret = 0;
899 return ret;
900}
901
902/******************************************************************
903 * GetExtendedTcpTable (IPHLPAPI.@)
904 *
905 * Get the table of TCP endpoints available to the application.
906 *
907 * PARAMS
908 * pTcpTable [Out] table struct with the filtered TCP endpoints available to application
909 * pdwSize [In/Out] estimated size of the structure returned in pTcpTable, in bytes
910 * bOrder [In] whether to order the table
911 * ulAf [in] version of IP used by the TCP endpoints
912 * TableClass [in] type of the TCP table structure from TCP_TABLE_CLASS
913 * Reserved [in] reserved - this value must be zero
914 *
915 * RETURNS
916 * Success: NO_ERROR
917 * Failure: either ERROR_INSUFFICIENT_BUFFER or ERROR_INVALID_PARAMETER
918 */
919DWORD WINAPI GetExtendedTcpTable(PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, TCP_TABLE_CLASS TableClass, ULONG Reserved)
920{
921 DWORD i, count, size;
923
924 if (!pdwSize)
925 {
927 }
928
929 if (ulAf != AF_INET)
930 {
933 }
934
935 switch (TableClass)
936 {
938 {
939 PMIB_TCPTABLE pOurTcpTable = getTcpTable(ClassBasic);
940 PMIB_TCPTABLE pTheirTcpTable = pTcpTable;
941
942 if (pOurTcpTable)
943 {
944 size = FIELD_OFFSET(MIB_TCPTABLE, table) + pOurTcpTable->dwNumEntries * sizeof(MIB_TCPROW);
945 if (size > *pdwSize || !pTheirTcpTable)
946 {
947 *pdwSize = size;
949 }
950 else
951 {
952 memcpy(pTheirTcpTable, pOurTcpTable, size);
953
954 if (bOrder)
955 qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
956 sizeof(MIB_TCPROW), TcpTableSorter);
957 }
958
959 HeapFree(GetProcessHeap(),0, pOurTcpTable);
960 }
961 }
962 break;
963
965 {
966 PMIB_TCPTABLE pOurTcpTable = getTcpTable(ClassBasic);
967 PMIB_TCPTABLE pTheirTcpTable = pTcpTable;
968
969 if (pOurTcpTable)
970 {
971 for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
972 {
973 if (pOurTcpTable->table[i].State != MIB_TCP_STATE_LISTEN)
974 {
975 ++count;
976 }
977 }
978
980 if (size > *pdwSize || !pTheirTcpTable)
981 {
982 *pdwSize = size;
984 }
985 else
986 {
987 pTheirTcpTable->dwNumEntries = count;
988
989 for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
990 {
991 if (pOurTcpTable->table[i].State != MIB_TCP_STATE_LISTEN)
992 {
993 memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW));
994 ++count;
995 }
996 }
997 ASSERT(count == pTheirTcpTable->dwNumEntries);
998
999 if (bOrder)
1000 qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1001 sizeof(MIB_TCPROW), TcpTableSorter);
1002 }
1003
1004 HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1005 }
1006 }
1007 break;
1008
1010 {
1011 PMIB_TCPTABLE pOurTcpTable = getTcpTable(ClassBasic);
1012 PMIB_TCPTABLE pTheirTcpTable = pTcpTable;
1013
1014 if (pOurTcpTable)
1015 {
1016 for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1017 {
1018 if (pOurTcpTable->table[i].State == MIB_TCP_STATE_LISTEN)
1019 {
1020 ++count;
1021 }
1022 }
1023
1025 if (size > *pdwSize || !pTheirTcpTable)
1026 {
1027 *pdwSize = size;
1029 }
1030 else
1031 {
1032 pTheirTcpTable->dwNumEntries = count;
1033
1034 for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1035 {
1036 if (pOurTcpTable->table[i].State == MIB_TCP_STATE_LISTEN)
1037 {
1038 memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW));
1039 ++count;
1040 }
1041 }
1042 ASSERT(count == pTheirTcpTable->dwNumEntries);
1043
1044 if (bOrder)
1045 qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1046 sizeof(MIB_TCPROW), TcpTableSorter);
1047 }
1048
1049 HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1050 }
1051 }
1052 break;
1053
1055 {
1057 PMIB_TCPTABLE_OWNER_PID pTheirTcpTable = pTcpTable;
1058
1059 if (pOurTcpTable)
1060 {
1062 if (size > *pdwSize || !pTheirTcpTable)
1063 {
1064 *pdwSize = size;
1066 }
1067 else
1068 {
1069 memcpy(pTheirTcpTable, pOurTcpTable, size);
1070
1071 /* Don't sort on PID, so use basic helper */
1072 if (bOrder)
1073 qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1075 }
1076
1077 HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1078 }
1079 }
1080 break;
1081
1083 {
1085 PMIB_TCPTABLE_OWNER_PID pTheirTcpTable = pTcpTable;
1086
1087 if (pOurTcpTable)
1088 {
1089 for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1090 {
1091 if (pOurTcpTable->table[i].dwState != MIB_TCP_STATE_LISTEN)
1092 {
1093 ++count;
1094 }
1095 }
1096
1098 if (size > *pdwSize || !pTheirTcpTable)
1099 {
1100 *pdwSize = size;
1102 }
1103 else
1104 {
1105 pTheirTcpTable->dwNumEntries = count;
1106
1107 for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1108 {
1109 if (pOurTcpTable->table[i].dwState != MIB_TCP_STATE_LISTEN)
1110 {
1111 memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW_OWNER_PID));
1112 ++count;
1113 }
1114 }
1115 ASSERT(count == pTheirTcpTable->dwNumEntries);
1116
1117 /* Don't sort on PID, so use basic helper */
1118 if (bOrder)
1119 qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1121 }
1122
1123 HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1124 }
1125 }
1126 break;
1127
1129 {
1131 PMIB_TCPTABLE_OWNER_PID pTheirTcpTable = pTcpTable;
1132
1133 if (pOurTcpTable)
1134 {
1135 for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1136 {
1137 if (pOurTcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
1138 {
1139 ++count;
1140 }
1141 }
1142
1144 if (size > *pdwSize || !pTheirTcpTable)
1145 {
1146 *pdwSize = size;
1148 }
1149 else
1150 {
1151 pTheirTcpTable->dwNumEntries = count;
1152
1153 for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1154 {
1155 if (pOurTcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
1156 {
1157 memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW_OWNER_PID));
1158 ++count;
1159 }
1160 }
1161 ASSERT(count == pTheirTcpTable->dwNumEntries);
1162
1163 /* Don't sort on PID, so use basic helper */
1164 if (bOrder)
1165 qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1167 }
1168
1169 HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1170 }
1171 }
1172 break;
1173
1175 {
1177 PMIB_TCPTABLE_OWNER_MODULE pTheirTcpTable = pTcpTable;
1178
1179 if (pOurTcpTable)
1180 {
1182 if (size > *pdwSize || !pTheirTcpTable)
1183 {
1184 *pdwSize = size;
1186 }
1187 else
1188 {
1189 memcpy(pTheirTcpTable, pOurTcpTable, size);
1190
1191 /* Don't sort on PID, so use basic helper */
1192 if (bOrder)
1193 qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1195 }
1196
1197 HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1198 }
1199 }
1200 break;
1201
1203 {
1205 PMIB_TCPTABLE_OWNER_MODULE pTheirTcpTable = pTcpTable;
1206
1207 if (pOurTcpTable)
1208 {
1209 for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1210 {
1211 if (pOurTcpTable->table[i].dwState != MIB_TCP_STATE_LISTEN)
1212 {
1213 ++count;
1214 }
1215 }
1216
1218 if (size > *pdwSize || !pTheirTcpTable)
1219 {
1220 *pdwSize = size;
1222 }
1223 else
1224 {
1225 pTheirTcpTable->dwNumEntries = count;
1226
1227 for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1228 {
1229 if (pOurTcpTable->table[i].dwState != MIB_TCP_STATE_LISTEN)
1230 {
1231 memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW_OWNER_MODULE));
1232 ++count;
1233 }
1234 }
1235 ASSERT(count == pTheirTcpTable->dwNumEntries);
1236
1237 /* Don't sort on PID, so use basic helper */
1238 if (bOrder)
1239 qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1241 }
1242
1243 HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1244 }
1245 }
1246 break;
1247
1249 {
1251 PMIB_TCPTABLE_OWNER_MODULE pTheirTcpTable = pTcpTable;
1252
1253 if (pOurTcpTable)
1254 {
1255 for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1256 {
1257 if (pOurTcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
1258 {
1259 ++count;
1260 }
1261 }
1262
1264 if (size > *pdwSize || !pTheirTcpTable)
1265 {
1266 *pdwSize = size;
1268 }
1269 else
1270 {
1271 pTheirTcpTable->dwNumEntries = count;
1272
1273 for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1274 {
1275 if (pOurTcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
1276 {
1277 memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW_OWNER_MODULE));
1278 ++count;
1279 }
1280 }
1281 ASSERT(count == pTheirTcpTable->dwNumEntries);
1282
1283 /* Don't sort on PID, so use basic helper */
1284 if (bOrder)
1285 qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1287 }
1288
1289 HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1290 }
1291 }
1292 break;
1293
1294 default:
1296 break;
1297 }
1298
1299 return ret;
1300}
1301
1302static int UdpTableSorter(const void *a, const void *b)
1303{
1304 int ret;
1305
1306 if (a && b) {
1307 PMIB_UDPROW rowA = (PMIB_UDPROW)a, rowB = (PMIB_UDPROW)b;
1308
1309 ret = rowA->dwLocalAddr - rowB->dwLocalAddr;
1310 if (ret == 0)
1311 ret = rowA->dwLocalPort - rowB->dwLocalPort;
1312 }
1313 else
1314 ret = 0;
1315 return ret;
1316}
1317
1318/******************************************************************
1319 * GetExtendedUdpTable (IPHLPAPI.@)
1320 *
1321 * Get the table of UDP endpoints available to the application.
1322 *
1323 * PARAMS
1324 * pUdpTable [Out] table struct with the filtered UDP endpoints available to application
1325 * pdwSize [In/Out] estimated size of the structure returned in pUdpTable, in bytes
1326 * bOrder [In] whether to order the table
1327 * ulAf [in] version of IP used by the UDP endpoints
1328 * TableClass [in] type of the UDP table structure from UDP_TABLE_CLASS
1329 * Reserved [in] reserved - this value must be zero
1330 *
1331 * RETURNS
1332 * Success: NO_ERROR
1333 * Failure: either ERROR_INSUFFICIENT_BUFFER or ERROR_INVALID_PARAMETER
1334 */
1335DWORD WINAPI GetExtendedUdpTable(PVOID pUdpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, UDP_TABLE_CLASS TableClass, ULONG Reserved)
1336{
1337 DWORD size;
1338 DWORD ret = NO_ERROR;
1339
1340 if (!pdwSize)
1341 {
1343 }
1344
1345 if (ulAf != AF_INET)
1346 {
1349 }
1350
1351 switch (TableClass)
1352 {
1353 case UDP_TABLE_BASIC:
1354 {
1355 PMIB_UDPTABLE pOurUdpTable = getUdpTable(ClassBasic);
1356 PMIB_UDPTABLE pTheirUdpTable = pUdpTable;
1357
1358 if (pOurUdpTable)
1359 {
1360 size = FIELD_OFFSET(MIB_UDPTABLE, table) + pOurUdpTable->dwNumEntries * sizeof(MIB_UDPROW);
1361 if (size > *pdwSize || !pTheirUdpTable)
1362 {
1363 *pdwSize = size;
1365 }
1366 else
1367 {
1368 memcpy(pTheirUdpTable, pOurUdpTable, size);
1369
1370 if (bOrder)
1371 qsort(pTheirUdpTable->table, pTheirUdpTable->dwNumEntries,
1372 sizeof(MIB_UDPROW), UdpTableSorter);
1373 }
1374
1375 HeapFree(GetProcessHeap(), 0, pOurUdpTable);
1376 }
1377 }
1378 break;
1379
1381 {
1383 PMIB_UDPTABLE_OWNER_PID pTheirUdpTable = pUdpTable;
1384
1385 if (pOurUdpTable)
1386 {
1388 if (size > *pdwSize || !pTheirUdpTable)
1389 {
1390 *pdwSize = size;
1392 }
1393 else
1394 {
1395 memcpy(pTheirUdpTable, pOurUdpTable, size);
1396
1397 if (bOrder)
1398 qsort(pTheirUdpTable->table, pTheirUdpTable->dwNumEntries,
1400 }
1401
1402 HeapFree(GetProcessHeap(), 0, pOurUdpTable);
1403 }
1404 }
1405 break;
1406
1408 {
1410 PMIB_UDPTABLE_OWNER_MODULE pTheirUdpTable = pUdpTable;
1411
1412 if (pOurUdpTable)
1413 {
1415 if (size > *pdwSize || !pTheirUdpTable)
1416 {
1417 *pdwSize = size;
1419 }
1420 else
1421 {
1422 memcpy(pTheirUdpTable, pOurUdpTable, size);
1423
1424 if (bOrder)
1425 qsort(pTheirUdpTable->table, pTheirUdpTable->dwNumEntries,
1427 }
1428
1429 HeapFree(GetProcessHeap(), 0, pOurUdpTable);
1430 }
1431 }
1432 break;
1433
1434 default:
1436 break;
1437 }
1438
1439 return ret;
1440}
1441
1442
1443/******************************************************************
1444 * GetFriendlyIfIndex (IPHLPAPI.@)
1445 *
1446 * PARAMS
1447 * IfIndex [In]
1448 *
1449 * RETURNS
1450 * DWORD
1451 */
1453{
1454 /* windows doesn't validate these, either, just makes sure the top byte is
1455 cleared. I assume my ifenum module never gives an index with the top
1456 byte set. */
1457 TRACE("returning %ld\n", IfIndex);
1458 return IfIndex;
1459}
1460
1461
1462/******************************************************************
1463 * GetIcmpStatistics (IPHLPAPI.@)
1464 *
1465 * PARAMS
1466 * pStats [In/Out]
1467 *
1468 * RETURNS
1469 * DWORD
1470 */
1472{
1473 DWORD ret;
1474
1475 TRACE("pStats %p\n", pStats);
1476 ret = getICMPStats(pStats);
1477 TRACE("returning %ld\n", ret);
1478 return ret;
1479}
1480
1481
1482/******************************************************************
1483 * GetIfEntry (IPHLPAPI.@)
1484 *
1485 * PARAMS
1486 * pIfRow [In/Out]
1487 *
1488 * RETURNS
1489 * DWORD
1490 */
1492{
1493 DWORD ret;
1494 const char *name;
1495
1496 TRACE("pIfRow %p\n", pIfRow);
1497 if (!pIfRow)
1499
1501 if (name) {
1502 ret = getInterfaceEntryByIndex(pIfRow->dwIndex, pIfRow);
1503 if (ret == NO_ERROR)
1504 ret = getInterfaceStatsByName(name, pIfRow);
1506 }
1507 else
1509 TRACE("returning %ld\n", ret);
1510 return ret;
1511}
1512
1513
1514static int IfTableSorter(const void *a, const void *b)
1515{
1516 int ret;
1517
1518 if (a && b)
1519 ret = ((PMIB_IFROW)a)->dwIndex - ((PMIB_IFROW)b)->dwIndex;
1520 else
1521 ret = 0;
1522 return ret;
1523}
1524
1525
1526/******************************************************************
1527 * GetIfTable (IPHLPAPI.@)
1528 *
1529 * PARAMS
1530 * pIfTable [In/Out]
1531 * pdwSize [In/Out]
1532 * bOrder [In]
1533 *
1534 * RETURNS
1535 * DWORD
1536 */
1537DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
1538{
1539 DWORD ret;
1540
1541 TRACE("pIfTable %p, pdwSize %p, bOrder %ld\n", pdwSize, pdwSize,
1542 (DWORD)bOrder);
1543 if (!pdwSize)
1545 else {
1546 DWORD numInterfaces = getNumInterfaces();
1547 ULONG size;
1548 TRACE("GetIfTable: numInterfaces = %d\n", (int)numInterfaces);
1549 size = sizeof(MIB_IFTABLE) + (numInterfaces - 1) * sizeof(MIB_IFROW);
1550
1551 if (!pIfTable || *pdwSize < size) {
1552 *pdwSize = size;
1554 }
1555 else {
1557
1558 if (table) {
1559 size = sizeof(MIB_IFTABLE) + (table->numIndexes - 1) *
1560 sizeof(MIB_IFROW);
1561 if (*pdwSize < size) {
1562 *pdwSize = size;
1564 }
1565 else {
1566 DWORD ndx;
1567
1568 pIfTable->dwNumEntries = 0;
1569 for (ndx = 0; ndx < table->numIndexes; ndx++) {
1570 pIfTable->table[ndx].dwIndex = table->indexes[ndx];
1571 GetIfEntry(&pIfTable->table[ndx]);
1572 pIfTable->dwNumEntries++;
1573 }
1574 if (bOrder)
1575 qsort(pIfTable->table, pIfTable->dwNumEntries, sizeof(MIB_IFROW),
1577 ret = NO_ERROR;
1578 }
1579 free(table);
1580 }
1581 else
1583 }
1584 }
1585 TRACE("returning %ld\n", ret);
1586 return ret;
1587}
1588
1589
1590/******************************************************************
1591 * GetInterfaceInfo (IPHLPAPI.@)
1592 *
1593 * PARAMS
1594 * pIfTable [In/Out]
1595 * dwOutBufLen [In/Out]
1596 *
1597 * RETURNS
1598 * DWORD
1599 */
1601{
1602 DWORD ret;
1603
1604 TRACE("pIfTable %p, dwOutBufLen %p\n", pIfTable, dwOutBufLen);
1605 if (!dwOutBufLen)
1607 else {
1608 DWORD numNonLoopbackInterfaces = getNumNonLoopbackInterfaces();
1609 ULONG size;
1610 TRACE("numNonLoopbackInterfaces == 0x%x\n", numNonLoopbackInterfaces);
1611 size = sizeof(IP_INTERFACE_INFO) + (numNonLoopbackInterfaces) *
1612 sizeof(IP_ADAPTER_INDEX_MAP);
1613
1614 if (!pIfTable || *dwOutBufLen < size) {
1615 *dwOutBufLen = size;
1617 }
1618 else {
1620
1621 if (table) {
1622 TRACE("table->numIndexes == 0x%x\n", table->numIndexes);
1623 size = sizeof(IP_INTERFACE_INFO) + (table->numIndexes) *
1624 sizeof(IP_ADAPTER_INDEX_MAP);
1625 if (*dwOutBufLen < size) {
1626 *dwOutBufLen = size;
1628 }
1629 else {
1630 DWORD ndx;
1631
1632 pIfTable->NumAdapters = 0;
1633 for (ndx = 0; ndx < table->numIndexes; ndx++) {
1634 const char *walker, *name;
1635 WCHAR *assigner;
1636
1637 pIfTable->Adapter[ndx].Index = table->indexes[ndx];
1638 name = getInterfaceNameByIndex(table->indexes[ndx]);
1639 wcscpy(pIfTable->Adapter[ndx].Name, L"\\DEVICE\\TCPIP_");
1640 for (walker = name, assigner = &pIfTable->Adapter[ndx].Name[14];
1641 walker && *walker &&
1642 assigner - pIfTable->Adapter[ndx].Name < MAX_ADAPTER_NAME - 1 - 14;
1643 walker++, assigner++)
1644 *assigner = *walker;
1645 *assigner = 0;
1647 pIfTable->NumAdapters++;
1648 }
1649 ret = NO_ERROR;
1650 }
1651 free(table);
1652 }
1653 else
1655 }
1656 }
1657 TRACE("returning %ld\n", ret);
1658 return ret;
1659}
1660
1661
1662static int IpAddrTableSorter(const void *a, const void *b)
1663{
1664 int ret;
1665
1666 if (a && b)
1667 ret = ((PMIB_IPADDRROW)a)->dwAddr - ((PMIB_IPADDRROW)b)->dwAddr;
1668 else
1669 ret = 0;
1670 return ret;
1671}
1672
1673
1674/******************************************************************
1675 * GetIpAddrTable (IPHLPAPI.@)
1676 *
1677 * PARAMS
1678 * pIpAddrTable [In/Out]
1679 * pdwSize [In/Out]
1680 * bOrder [In]
1681 *
1682 * RETURNS
1683 * DWORD
1684 */
1686{
1687 DWORD ret;
1688
1689 TRACE("pIpAddrTable %p, pdwSize %p, bOrder %ld\n", pIpAddrTable, pdwSize,
1690 (DWORD)bOrder);
1691 if (!pdwSize)
1693 else {
1694 DWORD numInterfaces = getNumInterfaces();
1695 ULONG size = sizeof(MIB_IPADDRTABLE) + (numInterfaces - 1) *
1696 sizeof(MIB_IPADDRROW);
1697
1698 if (!pIpAddrTable || *pdwSize < size) {
1699 *pdwSize = size;
1701 }
1702 else {
1704
1705 if (table) {
1706 size = sizeof(MIB_IPADDRTABLE) + (table->numIndexes - 1) *
1707 sizeof(MIB_IPADDRROW);
1708 if (*pdwSize < size) {
1709 *pdwSize = size;
1711 }
1712 else {
1713 DWORD ndx, bcast;
1714
1715 pIpAddrTable->dwNumEntries = 0;
1716 for (ndx = 0; ndx < table->numIndexes; ndx++) {
1717 pIpAddrTable->table[ndx].dwIndex = table->indexes[ndx];
1718 pIpAddrTable->table[ndx].dwAddr =
1719 getInterfaceIPAddrByIndex(table->indexes[ndx]);
1720 pIpAddrTable->table[ndx].dwMask =
1721 getInterfaceMaskByIndex(table->indexes[ndx]);
1722 /* the dwBCastAddr member isn't the broadcast address, it indicates
1723 * whether the interface uses the 1's broadcast address (1) or the
1724 * 0's broadcast address (0).
1725 */
1726 bcast = getInterfaceBCastAddrByIndex(table->indexes[ndx]);
1727 pIpAddrTable->table[ndx].dwBCastAddr =
1728 (bcast & pIpAddrTable->table[ndx].dwMask) ? 1 : 0;
1729 /* FIXME: hardcoded reasm size, not sure where to get it */
1730 pIpAddrTable->table[ndx].dwReasmSize = 65535;
1731 pIpAddrTable->table[ndx].unused1 = 0;
1732 pIpAddrTable->table[ndx].wType = 0; /* aka unused2 */
1733 pIpAddrTable->dwNumEntries++;
1734 }
1735 if (bOrder)
1736 qsort(pIpAddrTable->table, pIpAddrTable->dwNumEntries,
1738 ret = NO_ERROR;
1739 }
1740 free(table);
1741 }
1742 else
1744 }
1745 }
1746 TRACE("returning %ld\n", ret);
1747 return ret;
1748}
1749
1750
1751static int IpForwardTableSorter(const void *a, const void *b)
1752{
1753 int ret;
1754
1755 if (a && b) {
1757
1758 ret = rowA->dwForwardDest - rowB->dwForwardDest;
1759 if (ret == 0) {
1760 ret = rowA->dwForwardProto - rowB->dwForwardProto;
1761 if (ret == 0) {
1762 ret = rowA->dwForwardPolicy - rowB->dwForwardPolicy;
1763 if (ret == 0)
1764 ret = rowA->dwForwardNextHop - rowB->dwForwardNextHop;
1765 }
1766 }
1767 }
1768 else
1769 ret = 0;
1770 return ret;
1771}
1772
1773
1774/******************************************************************
1775 * GetIpForwardTable (IPHLPAPI.@)
1776 *
1777 * PARAMS
1778 * pIpForwardTable [In/Out]
1779 * pdwSize [In/Out]
1780 * bOrder [In]
1781 *
1782 * RETURNS
1783 * DWORD
1784 */
1786{
1787 DWORD ret;
1788
1789 TRACE("pIpForwardTable %p, pdwSize %p, bOrder %ld\n", pIpForwardTable,
1790 pdwSize, (DWORD)bOrder);
1791 if (!pdwSize)
1793 else {
1794 DWORD numRoutes = getNumRoutes();
1795 ULONG sizeNeeded = sizeof(MIB_IPFORWARDTABLE) + (numRoutes - 1) *
1796 sizeof(MIB_IPFORWARDROW);
1797
1798 if (!pIpForwardTable || *pdwSize < sizeNeeded) {
1799 *pdwSize = sizeNeeded;
1801 }
1802 else {
1804 if (table) {
1805 sizeNeeded = sizeof(MIB_IPFORWARDTABLE) + (table->numRoutes - 1) *
1806 sizeof(MIB_IPFORWARDROW);
1807 if (*pdwSize < sizeNeeded) {
1808 *pdwSize = sizeNeeded;
1810 }
1811 else {
1812 DWORD ndx;
1813
1814 pIpForwardTable->dwNumEntries = table->numRoutes;
1815 for (ndx = 0; ndx < numRoutes; ndx++) {
1816 pIpForwardTable->table[ndx].dwForwardIfIndex =
1817 table->routes[ndx].ifIndex;
1818 pIpForwardTable->table[ndx].dwForwardDest =
1819 table->routes[ndx].dest;
1820 pIpForwardTable->table[ndx].dwForwardMask =
1821 table->routes[ndx].mask;
1822 pIpForwardTable->table[ndx].dwForwardPolicy = 0;
1823 pIpForwardTable->table[ndx].dwForwardNextHop =
1824 table->routes[ndx].gateway;
1825 /* FIXME: this type is appropriate for local interfaces; may not
1826 always be appropriate */
1827 pIpForwardTable->table[ndx].dwForwardType = MIB_IPROUTE_TYPE_DIRECT;
1828 /* FIXME: other protos might be appropriate, e.g. the default route
1829 is typically set with MIB_IPPROTO_NETMGMT instead */
1830 pIpForwardTable->table[ndx].dwForwardProto = MIB_IPPROTO_LOCAL;
1831 /* punt on age and AS */
1832 pIpForwardTable->table[ndx].dwForwardAge = 0;
1833 pIpForwardTable->table[ndx].dwForwardNextHopAS = 0;
1834 pIpForwardTable->table[ndx].dwForwardMetric1 =
1835 table->routes[ndx].metric;
1836 /* rest of the metrics are 0.. */
1837 pIpForwardTable->table[ndx].dwForwardMetric2 = 0;
1838 pIpForwardTable->table[ndx].dwForwardMetric3 = 0;
1839 pIpForwardTable->table[ndx].dwForwardMetric4 = 0;
1840 pIpForwardTable->table[ndx].dwForwardMetric5 = 0;
1841 }
1842 if (bOrder)
1843 qsort(pIpForwardTable->table, pIpForwardTable->dwNumEntries,
1845 ret = NO_ERROR;
1846 }
1848 }
1849 else
1851 }
1852 }
1853 TRACE("returning %ld\n", ret);
1854 return ret;
1855}
1856
1857
1858static int IpNetTableSorter(const void *a, const void *b)
1859{
1860 int ret;
1861
1862 if (a && b)
1863 ret = ((PMIB_IPNETROW)a)->dwAddr - ((PMIB_IPNETROW)b)->dwAddr;
1864 else
1865 ret = 0;
1866 return ret;
1867}
1868
1869
1870/******************************************************************
1871 * GetIpNetTable (IPHLPAPI.@)
1872 *
1873 * PARAMS
1874 * pIpNetTable [In/Out]
1875 * pdwSize [In/Out]
1876 * bOrder [In]
1877 *
1878 * RETURNS
1879 * DWORD
1880 */
1882{
1883 DWORD ret = NO_ERROR;
1884
1885 TRACE("pIpNetTable %p, pdwSize %p, bOrder %d\n", pIpNetTable, pdwSize,
1886 (DWORD)bOrder);
1887 if (!pdwSize)
1889 else {
1890 DWORD numEntries = getNumArpEntries();
1891 ULONG size = sizeof(MIB_IPNETTABLE);
1892
1893 if (numEntries > 1)
1894 size += (numEntries - 1) * sizeof(MIB_IPNETROW);
1895 if (!pIpNetTable || *pdwSize < size) {
1896 *pdwSize = size;
1898 }
1899 else {
1901 if (table) {
1902 size = sizeof(MIB_IPNETTABLE);
1903 if (table->dwNumEntries > 1)
1904 size += (table->dwNumEntries - 1) * sizeof(MIB_IPNETROW);
1905 if (*pdwSize < size) {
1906 *pdwSize = size;
1908 }
1909 else {
1910 *pdwSize = size;
1911 memcpy(pIpNetTable, table, size);
1912 if (bOrder)
1913 qsort(pIpNetTable->table, pIpNetTable->dwNumEntries,
1915 ret = NO_ERROR;
1916 }
1918 }
1919 }
1920 }
1921 TRACE("returning %d\n", ret);
1922 return ret;
1923}
1924
1925
1926/******************************************************************
1927 * GetIpStatistics (IPHLPAPI.@)
1928 *
1929 * PARAMS
1930 * pStats [In/Out]
1931 *
1932 * RETURNS
1933 * DWORD
1934 */
1936{
1937 return GetIpStatisticsEx(pStats, PF_INET);
1938}
1939
1940/******************************************************************
1941 * GetIpStatisticsEx (IPHLPAPI.@)
1942 *
1943 * PARAMS
1944 * pStats [In/Out]
1945 * dwFamily [In]
1946 *
1947 * RETURNS
1948 * DWORD
1949 */
1951{
1952 HANDLE tcpFile;
1953 DWORD ret;
1954
1955 if (!pStats)
1957
1958 if (dwFamily != AF_INET && dwFamily != AF_INET6)
1960
1961 if (!NT_SUCCESS(openTcpFile(&tcpFile, FILE_READ_DATA)))
1962 return ERROR_NOT_SUPPORTED;
1963
1964 TRACE("pStats %p\n", pStats);
1965 ret = getIPStats(tcpFile, pStats);
1966 closeTcpFile(tcpFile);
1967 TRACE("returning %ld\n", ret);
1968 return ret;
1969}
1970
1971/******************************************************************
1972 * GetNetworkParams (IPHLPAPI.@)
1973 *
1974 * PARAMS
1975 * pFixedInfo [In/Out]
1976 * pOutBufLen [In/Out]
1977 *
1978 * RETURNS
1979 * DWORD
1980 */
1982{
1983 DWORD ret, size, type;
1984 LONG regReturn;
1985 HKEY hKey;
1986 PIPHLP_RES_INFO resInfo;
1987
1988 TRACE("pFixedInfo %p, pOutBufLen %p\n", pFixedInfo, pOutBufLen);
1989 if (!pOutBufLen)
1991
1992 resInfo = getResInfo();
1993 if (!resInfo)
1994 return ERROR_OUTOFMEMORY;
1995
1996 size = sizeof(FIXED_INFO) + (resInfo->riCount > 1 ? (resInfo->riCount-1) *
1997 sizeof(IP_ADDR_STRING) : 0);
1998 if (!pFixedInfo || *pOutBufLen < size) {
1999 *pOutBufLen = size;
2000 disposeResInfo( resInfo );
2001 return ERROR_BUFFER_OVERFLOW;
2002 }
2003
2004 memset(pFixedInfo, 0, size);
2005 /* Check for DhcpHostname and DhcpDomain first */
2007 "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
2008 0,
2009 KEY_READ,
2010 &hKey);
2011 if (regReturn == ERROR_SUCCESS) {
2012 /* Windows doesn't honor DHCP option 12 even if RFC requires it if it is returned by DHCP server! */
2013#if 0
2014 type = REG_SZ;
2015 size = sizeof(pFixedInfo->HostName);
2016 regReturn = RegQueryValueExA(hKey,
2017 "DhcpHostname",
2018 NULL,
2019 &type,
2020 (LPBYTE)pFixedInfo->HostName,
2021 &size);
2022 if (regReturn == ERROR_FILE_NOT_FOUND || (regReturn == ERROR_SUCCESS && size < 1))
2023 {
2024#endif
2025 type = REG_SZ;
2026 size = sizeof(pFixedInfo->HostName);
2027 regReturn = RegQueryValueExA(hKey,
2028 "Hostname",
2029 NULL,
2030 &type,
2031 (LPBYTE)pFixedInfo->HostName,
2032 &size);
2033#if 0
2034 }
2035#endif
2036
2037 type = REG_SZ;
2038 size = sizeof(pFixedInfo->DomainName);
2039 regReturn = RegQueryValueExA(hKey,
2040 "DhcpDomain",
2041 NULL,
2042 &type,
2043 (LPBYTE)pFixedInfo->DomainName,
2044 &size);
2045 if (regReturn == ERROR_FILE_NOT_FOUND || (regReturn == ERROR_SUCCESS && size < 1))
2046 {
2047 type = REG_SZ;
2048 size = sizeof(pFixedInfo->DomainName);
2049 regReturn = RegQueryValueExA(hKey,
2050 "Domain",
2051 NULL,
2052 &type,
2053 (LPBYTE)pFixedInfo->DomainName,
2054 &size);
2055 }
2057 }
2058
2059 TRACE("GetComputerNameExA: %s\n", pFixedInfo->DomainName);
2060
2061 if (resInfo->riCount > 0)
2062 {
2063 CopyMemory(&pFixedInfo->DnsServerList, resInfo->DnsList, sizeof(IP_ADDR_STRING));
2064 if (resInfo->riCount > 1)
2065 {
2066 IP_ADDR_STRING *pSrc = resInfo->DnsList->Next;
2067 IP_ADDR_STRING *pTarget = (struct _IP_ADDR_STRING*)((char*)pFixedInfo + sizeof(FIXED_INFO));
2068
2069 pFixedInfo->DnsServerList.Next = pTarget;
2070
2071 do
2072 {
2073 CopyMemory(pTarget, pSrc, sizeof(IP_ADDR_STRING));
2074 resInfo->riCount--;
2075 if (resInfo->riCount > 1)
2076 {
2077 pTarget->Next = (IP_ADDR_STRING*)((char*)pTarget + sizeof(IP_ADDR_STRING));
2078 pTarget = pTarget->Next;
2079 pSrc = pSrc->Next;
2080 }
2081 else
2082 {
2083 pTarget->Next = NULL;
2084 break;
2085 }
2086 }
2087 while(TRUE);
2088 }
2089 else
2090 {
2091 pFixedInfo->DnsServerList.Next = NULL;
2092 }
2093 }
2094
2095 pFixedInfo->NodeType = HYBRID_NODETYPE;
2097 "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP", 0, KEY_READ, &hKey);
2098 if (regReturn != ERROR_SUCCESS)
2100 "SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters", 0, KEY_READ,
2101 &hKey);
2102 if (regReturn == ERROR_SUCCESS)
2103 {
2104 DWORD size = sizeof(pFixedInfo->ScopeId);
2105
2106 RegQueryValueExA(hKey, "ScopeID", NULL, NULL, (PBYTE)pFixedInfo->ScopeId, &size);
2108 }
2109
2110 disposeResInfo( resInfo );
2111 /* FIXME: can check whether routing's enabled in /proc/sys/net/ipv4/ip_forward
2112 I suppose could also check for a listener on port 53 to set EnableDns */
2113 ret = NO_ERROR;
2114 TRACE("returning %ld\n", ret);
2115
2116 return ret;
2117}
2118
2119
2120/******************************************************************
2121 * GetNumberOfInterfaces (IPHLPAPI.@)
2122 *
2123 * PARAMS
2124 * pdwNumIf [In/Out]
2125 *
2126 * RETURNS
2127 * DWORD
2128 */
2130{
2131 DWORD ret;
2132
2133 TRACE("pdwNumIf %p\n", pdwNumIf);
2134 if (!pdwNumIf)
2136 else {
2137 *pdwNumIf = getNumInterfaces();
2138 ret = NO_ERROR;
2139 }
2140 TRACE("returning %ld\n", ret);
2141 return ret;
2142}
2143
2144
2146{
2148 DWORD FileLen, PathLen, Error;
2151
2152 if (IsBadWritePtr(pdwSize, sizeof(DWORD)) ||
2153 IsBadWritePtr(Buffer, *pdwSize))
2154 {
2156 }
2157
2158 if (OwningPid == 0)
2159 {
2160 return ERROR_NOT_FOUND;
2161 }
2162
2164 if (Process == NULL)
2165 {
2166 return GetLastError();
2167 }
2168
2170 if (FileLen != 0)
2171 {
2173 if (PathLen == 0)
2174 {
2176 return GetLastError();
2177 }
2178
2179 /* Add NULL char */
2180 ++FileLen;
2181 ++PathLen;
2182 PathLen *= sizeof(WCHAR);
2183 FileLen *= sizeof(WCHAR);
2184 }
2185 else
2186 {
2187 Error = GetLastError();
2188
2190 {
2191 wcscpy(File, L"System");
2192 wcscpy(Path, L"System");
2193
2194 PathLen = sizeof(L"System");
2195 FileLen = sizeof(L"System");
2196 }
2197 else
2198 {
2200 return Error;
2201 }
2202 }
2203
2205
2206 if (*pdwSize < sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + PathLen + FileLen)
2207 {
2208 *pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + PathLen + FileLen;
2210 }
2211
2212 BasicInfo = Buffer;
2213 BasicInfo->pModuleName = (PVOID)((ULONG_PTR)BasicInfo + sizeof(TCPIP_OWNER_MODULE_BASIC_INFO));
2214 BasicInfo->pModulePath = (PVOID)((ULONG_PTR)BasicInfo->pModuleName + FileLen);
2215 wcscpy(BasicInfo->pModuleName, File);
2216 wcscpy(BasicInfo->pModulePath, Path);
2217 *pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + PathLen + FileLen;
2218
2219 return NO_ERROR;
2220}
2221
2223{
2224 UINT Size;
2225 HRESULT Res;
2226 HANDLE hAdvapi32;
2227 WCHAR SysDir[MAX_PATH];
2229 ULONG (NTAPI *_I_QueryTagInformation)(PVOID, DWORD, PVOID);
2230 struct
2231 {
2234 DWORD TagType;
2235 PWSTR Buffer;
2236 } ServiceQuery;
2237
2238 if (IsBadWritePtr(pdwSize, sizeof(DWORD)) ||
2239 IsBadWritePtr(Buffer, *pdwSize))
2240 {
2242 }
2243
2244 /* First, secure (avoid injections) load advapi32.dll */
2246 if (Size == 0)
2247 {
2248 return GetLastError();
2249 }
2250
2251 Res = StringCchCatW(&SysDir[Size], MAX_PATH - Size, L"\\advapi32.dll");
2252 if (FAILED(Res))
2253 {
2254 return Res;
2255 }
2256
2257 hAdvapi32 = GetModuleHandleW(SysDir);
2258 if (hAdvapi32 == NULL)
2259 {
2260 return GetLastError();
2261 }
2262
2263 /* Now, we'll query the service associated with the tag */
2264 _I_QueryTagInformation = (PVOID)GetProcAddress(hAdvapi32, "I_QueryTagInformation");
2265 if (_I_QueryTagInformation == NULL)
2266 {
2267 return GetLastError();
2268 }
2269
2270 /* Set tag and PID for the query */
2271 ServiceQuery.ProcessId = OwningPid;
2272 ServiceQuery.ServiceTag = OwningTag;
2273 ServiceQuery.TagType = 0;
2274 ServiceQuery.Buffer = NULL;
2275
2276 /* And query */
2277 Res = _I_QueryTagInformation(NULL, 1, &ServiceQuery);
2278 if (Res != ERROR_SUCCESS)
2279 {
2280 return Res;
2281 }
2282
2283 /* Compute service name length */
2284 Size = wcslen(ServiceQuery.Buffer) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
2285
2286 /* We'll copy it twice, so make sure we have enough room */
2287 if (*pdwSize < sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + 2 * Size)
2288 {
2289 *pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + 2 * Size;
2290 LocalFree(ServiceQuery.Buffer);
2292 }
2293
2294 /* Copy back data */
2295 BasicInfo = Buffer;
2296 BasicInfo->pModuleName = (PVOID)((ULONG_PTR)BasicInfo + sizeof(TCPIP_OWNER_MODULE_BASIC_INFO));
2297 BasicInfo->pModulePath = (PVOID)((ULONG_PTR)BasicInfo->pModuleName + Size);
2298 wcscpy(BasicInfo->pModuleName, ServiceQuery.Buffer);
2299 wcscpy(BasicInfo->pModulePath, ServiceQuery.Buffer);
2300 *pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + 2 * Size;
2301 LocalFree(ServiceQuery.Buffer);
2302
2303 return NO_ERROR;
2304}
2305
2306/******************************************************************
2307 * GetOwnerModuleFromTcpEntry (IPHLPAPI.@)
2308 *
2309 * Get data about the module that issued the context bind for a specific IPv4 TCP endpoint in a MIB table row
2310 *
2311 * PARAMS
2312 * pTcpEntry [in] pointer to a MIB_TCPROW_OWNER_MODULE structure
2313 * Class [in] TCPIP_OWNER_MODULE_INFO_CLASS enumeration value
2314 * Buffer [out] pointer a buffer containing a TCPIP_OWNER_MODULE_BASIC_INFO structure with the owner module data.
2315 * pdwSize [in, out] estimated size of the structure returned in Buffer, in bytes
2316 *
2317 * RETURNS
2318 * Success: NO_ERROR
2319 * Failure: ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY
2320 * ERROR_NOT_FOUND or ERROR_PARTIAL_COPY
2321 *
2322 * NOTES
2323 * The type of data returned in Buffer is indicated by the value of the Class parameter.
2324 */
2326{
2327 /* If we have a service tag, that's a service connection */
2328 if (pTcpEntry->OwningModuleInfo[0] != 0)
2329 {
2330 return GetOwnerModuleFromTagEntry(pTcpEntry->dwOwningPid, (DWORD)(pTcpEntry->OwningModuleInfo[0]), Class, Buffer, pdwSize);
2331 }
2332 else
2333 {
2334 return GetOwnerModuleFromPidEntry(pTcpEntry->dwOwningPid, Class, Buffer, pdwSize);
2335 }
2336}
2337
2338/******************************************************************
2339 * GetOwnerModuleFromUdpEntry (IPHLPAPI.@)
2340 *
2341 * Get data about the module that issued the context bind for a specific IPv4 UDP endpoint in a MIB table row
2342 *
2343 * PARAMS
2344 * pUdpEntry [in] pointer to a MIB_UDPROW_OWNER_MODULE structure
2345 * Class [in] TCPIP_OWNER_MODULE_INFO_CLASS enumeration value
2346 * Buffer [out] pointer a buffer containing a TCPIP_OWNER_MODULE_BASIC_INFO structure with the owner module data.
2347 * pdwSize [in, out] estimated size of the structure returned in Buffer, in bytes
2348 *
2349 * RETURNS
2350 * Success: NO_ERROR
2351 * Failure: ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY
2352 * ERROR_NOT_FOUND or ERROR_PARTIAL_COPY
2353 *
2354 * NOTES
2355 * The type of data returned in Buffer is indicated by the value of the Class parameter.
2356 */
2358{
2359 /* If we have a service tag, that's a service connection */
2360 if (pUdpEntry->OwningModuleInfo[0] != 0)
2361 {
2362 return GetOwnerModuleFromTagEntry(pUdpEntry->dwOwningPid, (DWORD)(pUdpEntry->OwningModuleInfo[0]), Class, Buffer, pdwSize);
2363 }
2364 else
2365 {
2366 return GetOwnerModuleFromPidEntry(pUdpEntry->dwOwningPid, Class, Buffer, pdwSize);
2367 }
2368}
2369
2371{
2372 IP_ADDR_STRING *pNext;
2374
2375 if (!Context->NumServers)
2376 {
2377 if (Context->uSizeAvailable >= Context->uSizeRequired)
2378 {
2379 WideCharToMultiByte(CP_ACP, 0, Server, -1, Context->pData->DnsServerList.IpAddress.String, 16, NULL, NULL);
2380 Context->pData->DnsServerList.IpAddress.String[15] = '\0';
2381 Context->pLastAddr = &Context->pData->DnsServerList;
2382 }
2383 }
2384 else
2385 {
2386 Context->uSizeRequired += sizeof(IP_ADDR_STRING);
2387 if (Context->uSizeAvailable >= Context->uSizeRequired)
2388 {
2389 pNext = (IP_ADDR_STRING*)(((char*)Context->pLastAddr) + sizeof(IP_ADDR_STRING));
2390 WideCharToMultiByte(CP_ACP, 0, Server, -1, pNext->IpAddress.String, 16, NULL, NULL);
2391 pNext->IpAddress.String[15] = '\0';
2392 Context->pLastAddr->Next = pNext;
2393 Context->pLastAddr = pNext;
2394 pNext->Next = NULL;
2395 }
2396 }
2397 Context->NumServers++;
2398}
2399
2400/******************************************************************
2401 * GetPerAdapterInfo (IPHLPAPI.@)
2402 *
2403 * PARAMS
2404 * IfIndex [In]
2405 * pPerAdapterInfo [In/Out]
2406 * pOutBufLen [In/Out]
2407 *
2408 * RETURNS
2409 * DWORD
2410 */
2411DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
2412{
2413 HKEY hkey;
2414 DWORD dwSize = 0;
2415 const char *ifName;
2417 WCHAR keyname[200] = L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\";
2418
2419 if (!pOutBufLen)
2421
2422 if (!pPerAdapterInfo || *pOutBufLen < sizeof(IP_PER_ADAPTER_INFO))
2423 {
2424 *pOutBufLen = sizeof(IP_PER_ADAPTER_INFO);
2425 return ERROR_BUFFER_OVERFLOW;
2426 }
2427
2428 ifName = getInterfaceNameByIndex(IfIndex);
2429 if (!ifName)
2431
2432 MultiByteToWideChar(CP_ACP, 0, ifName, -1, &keyname[62], sizeof(keyname)/sizeof(WCHAR) - 63);
2433 HeapFree(GetProcessHeap(), 0, (LPVOID)ifName);
2434
2435 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyname, 0, KEY_READ, &hkey) != ERROR_SUCCESS)
2436 {
2437 return ERROR_NOT_SUPPORTED;
2438 }
2439 Context.NumServers = 0;
2440 Context.uSizeAvailable = *pOutBufLen;
2441 Context.uSizeRequired = sizeof(IP_PER_ADAPTER_INFO);
2442 Context.pData = pPerAdapterInfo;
2443
2444 if (*pOutBufLen >= sizeof(IP_PER_ADAPTER_INFO))
2445 ZeroMemory(pPerAdapterInfo, sizeof(IP_PER_ADAPTER_INFO));
2446
2448
2449 if (Context.uSizeRequired > Context.uSizeAvailable)
2450 {
2451 *pOutBufLen = Context.uSizeRequired;
2452 RegCloseKey(hkey);
2453 return ERROR_BUFFER_OVERFLOW;
2454 }
2455
2456 if(RegQueryValueExW(hkey, L"NameServer", NULL, NULL, NULL, &dwSize) == ERROR_SUCCESS)
2457 {
2458 pPerAdapterInfo->AutoconfigActive = FALSE;
2459 }
2460 else
2461 {
2462 pPerAdapterInfo->AutoconfigActive = TRUE;
2463 }
2464
2465 RegCloseKey(hkey);
2466 return NOERROR;
2467}
2468
2469
2470/******************************************************************
2471 * GetRTTAndHopCount (IPHLPAPI.@)
2472 *
2473 * PARAMS
2474 * DestIpAddress [In]
2475 * HopCount [In/Out]
2476 * MaxHops [In]
2477 * RTT [In/Out]
2478 *
2479 * RETURNS
2480 * BOOL
2481 */
2482BOOL WINAPI GetRTTAndHopCount(IPAddr DestIpAddress, PULONG HopCount, ULONG MaxHops, PULONG RTT)
2483{
2484 TRACE("DestIpAddress 0x%08lx, HopCount %p, MaxHops %ld, RTT %p\n",
2485 DestIpAddress, HopCount, MaxHops, RTT);
2486 FIXME(":stub\n");
2487 return (BOOL) 0;
2488}
2489
2490
2491/******************************************************************
2492 * GetTcpStatisticsEx (IPHLPAPI.@)
2493 *
2494 * PARAMS
2495 * pStats [In/Out]
2496 * dwFamily [In]
2497 *
2498 * RETURNS
2499 * DWORD
2500 */
2502{
2503 HANDLE tcpFile;
2504 DWORD ret;
2505
2506 if (!pStats)
2508
2509 if (dwFamily != AF_INET && dwFamily != AF_INET6)
2511
2512 if (!NT_SUCCESS(openTcpFile(&tcpFile, FILE_READ_DATA)))
2513 return ERROR_NOT_SUPPORTED;
2514
2515 TRACE("pStats %p\n", pStats);
2516 ret = getTCPStats(tcpFile, pStats);
2517 closeTcpFile(tcpFile);
2518 TRACE("returning %ld\n", ret);
2519 return ret;
2520}
2521
2522/******************************************************************
2523 * GetTcpStatistics (IPHLPAPI.@)
2524 *
2525 * PARAMS
2526 * pStats [In/Out]
2527 *
2528 * RETURNS
2529 * DWORD
2530 */
2532{
2533 return GetTcpStatisticsEx(pStats, PF_INET);
2534}
2535
2536
2537/******************************************************************
2538 * GetTcpTable (IPHLPAPI.@)
2539 *
2540 * Get the table of active TCP connections.
2541 *
2542 * PARAMS
2543 * pTcpTable [Out] buffer for TCP connections table
2544 * pdwSize [In/Out] length of output buffer
2545 * bOrder [In] whether to order the table
2546 *
2547 * RETURNS
2548 * Success: NO_ERROR
2549 * Failure: error code from winerror.h
2550 *
2551 * NOTES
2552 * If pdwSize is less than required, the function will return
2553 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to
2554 * the required byte size.
2555 * If bOrder is true, the returned table will be sorted, first by
2556 * local address and port number, then by remote address and port
2557 * number.
2558 */
2560{
2561 return GetExtendedTcpTable(pTcpTable, pdwSize, bOrder, AF_INET, TCP_TABLE_BASIC_ALL, 0);
2562}
2563
2564
2565/******************************************************************
2566 * GetUdpStatisticsEx (IPHLPAPI.@)
2567 *
2568 * PARAMS
2569 * pStats [In/Out]
2570 * dwFamily [In]
2571 *
2572 * RETURNS
2573 * DWORD
2574 */
2576{
2577 HANDLE tcpFile;
2578 DWORD ret;
2579
2580 if (!pStats)
2582
2583 if (dwFamily != AF_INET && dwFamily != AF_INET6)
2585
2586 if (!NT_SUCCESS(openTcpFile(&tcpFile, FILE_READ_DATA)))
2587 return ERROR_NOT_SUPPORTED;
2588
2589 TRACE("pStats %p\n", pStats);
2590 ret = getUDPStats(tcpFile, pStats);
2591 closeTcpFile(tcpFile);
2592 TRACE("returning %ld\n", ret);
2593 return ret;
2594}
2595
2596/******************************************************************
2597 * GetUdpStatistics (IPHLPAPI.@)
2598 *
2599 * PARAMS
2600 * pStats [In/Out]
2601 *
2602 * RETURNS
2603 * DWORD
2604 */
2606{
2607 return GetUdpStatisticsEx(pStats, PF_INET);
2608}
2609
2610
2611/******************************************************************
2612 * GetUdpTable (IPHLPAPI.@)
2613 *
2614 * PARAMS
2615 * pUdpTable [In/Out]
2616 * pdwSize [In/Out]
2617 * bOrder [In]
2618 *
2619 * RETURNS
2620 * DWORD
2621 */
2623{
2624 return GetExtendedUdpTable(pUdpTable, pdwSize, bOrder, AF_INET, UDP_TABLE_BASIC, 0);
2625}
2626
2627
2628/******************************************************************
2629 * GetUniDirectionalAdapterInfo (IPHLPAPI.@)
2630 *
2631 * This is a Win98-only function to get information on "unidirectional"
2632 * adapters. Since this is pretty nonsensical in other contexts, it
2633 * never returns anything.
2634 *
2635 * PARAMS
2636 * pIPIfInfo [Out] buffer for adapter infos
2637 * dwOutBufLen [Out] length of the output buffer
2638 *
2639 * RETURNS
2640 * Success: NO_ERROR
2641 * Failure: error code from winerror.h
2642 *
2643 * FIXME
2644 * Stub, returns ERROR_NOT_SUPPORTED.
2645 */
2647{
2648 TRACE("pIPIfInfo %p, dwOutBufLen %p\n", pIPIfInfo, dwOutBufLen);
2649 /* a unidirectional adapter?? not bloody likely! */
2650 return ERROR_NOT_SUPPORTED;
2651}
2652
2653
2654/******************************************************************
2655 * IpReleaseAddress (IPHLPAPI.@)
2656 *
2657 * Release an IP obtained through DHCP,
2658 *
2659 * PARAMS
2660 * AdapterInfo [In] adapter to release IP address
2661 *
2662 * RETURNS
2663 * Success: NO_ERROR
2664 * Failure: error code from winerror.h
2665 */
2667{
2668 DWORD Status, Version = 0;
2669
2670 if (!AdapterInfo)
2672
2673 /* Maybe we should do this in DllMain */
2675 return ERROR_PROC_NOT_FOUND;
2676
2677 if (DhcpReleaseIpAddressLease(AdapterInfo->Index))
2679 else
2681
2683
2684 return Status;
2685}
2686
2687
2688/******************************************************************
2689 * IpRenewAddress (IPHLPAPI.@)
2690 *
2691 * Renew an IP obtained through DHCP.
2692 *
2693 * PARAMS
2694 * AdapterInfo [In] adapter to renew IP address
2695 *
2696 * RETURNS
2697 * Success: NO_ERROR
2698 * Failure: error code from winerror.h
2699 */
2701{
2702 DWORD Status, Version = 0;
2703
2704 if (!AdapterInfo)
2706
2707 /* Maybe we should do this in DllMain */
2709 return ERROR_PROC_NOT_FOUND;
2710
2711 if (DhcpRenewIpAddressLease(AdapterInfo->Index))
2713 else
2715
2717
2718 return Status;
2719}
2720
2721
2722/******************************************************************
2723 * NotifyAddrChange (IPHLPAPI.@)
2724 *
2725 * Notify caller whenever the ip-interface map is changed.
2726 *
2727 * PARAMS
2728 * Handle [Out] handle usable in asynchronous notification
2729 * overlapped [In] overlapped structure that notifies the caller
2730 *
2731 * RETURNS
2732 * Success: NO_ERROR
2733 * Failure: error code from winerror.h
2734 *
2735 * FIXME
2736 * Stub, returns ERROR_NOT_SUPPORTED.
2737 */
2739{
2740 FIXME("(Handle %p, overlapped %p): stub\n", Handle, overlapped);
2743 return ERROR_IO_PENDING;
2744}
2745
2746
2747/******************************************************************
2748 * NotifyRouteChange (IPHLPAPI.@)
2749 *
2750 * Notify caller whenever the ip routing table is changed.
2751 *
2752 * PARAMS
2753 * Handle [Out] handle usable in asynchronous notification
2754 * overlapped [In] overlapped structure that notifies the caller
2755 *
2756 * RETURNS
2757 * Success: NO_ERROR
2758 * Failure: error code from winerror.h
2759 *
2760 * FIXME
2761 * Stub, returns ERROR_NOT_SUPPORTED.
2762 */
2764{
2765 FIXME("(Handle %p, overlapped %p): stub\n", Handle, overlapped);
2766 return ERROR_NOT_SUPPORTED;
2767}
2768
2769/******************************************************************
2770 * SendARP (IPHLPAPI.@)
2771 *
2772 * Send an ARP request.
2773 *
2774 * PARAMS
2775 * DestIP [In] attempt to obtain this IP
2776 * SrcIP [In] optional sender IP address
2777 * pMacAddr [Out] buffer for the mac address
2778 * PhyAddrLen [In/Out] length of the output buffer
2779 *
2780 * RETURNS
2781 * Success: NO_ERROR
2782 * Failure: error code from winerror.h
2783 */
2784DWORD WINAPI SendARP(IPAddr DestIP, IPAddr SrcIP, PULONG pMacAddr, PULONG PhyAddrLen)
2785{
2786 IPAddr IPs[2];
2787 ULONG Size;
2788
2789 if (IsBadWritePtr(pMacAddr, sizeof(ULONG)) || IsBadWritePtr(PhyAddrLen, sizeof(ULONG)))
2791
2792 IPs[0] = DestIP;
2793 IPs[1] = SrcIP;
2794 Size = sizeof(IPs);
2795 return TCPSendIoctl(INVALID_HANDLE_VALUE, IOCTL_QUERY_IP_HW_ADDRESS, IPs, &Size, pMacAddr, PhyAddrLen);
2796}
2797
2798
2799/******************************************************************
2800 * SetIfEntry (IPHLPAPI.@)
2801 *
2802 * Set the administrative status of an interface.
2803 *
2804 * PARAMS
2805 * pIfRow [In] dwAdminStatus member specifies the new status.
2806 *
2807 * RETURNS
2808 * Success: NO_ERROR
2809 * Failure: error code from winerror.h
2810 *
2811 * FIXME
2812 * Stub, returns ERROR_NOT_SUPPORTED.
2813 */
2815{
2816 FIXME("(pIfRow %p): stub\n", pIfRow);
2817 /* this is supposed to set an interface administratively up or down.
2818 Could do SIOCSIFFLAGS and set/clear IFF_UP, but, not sure I want to, and
2819 this sort of down is indistinguishable from other sorts of down (e.g. no
2820 link). */
2821 return ERROR_NOT_SUPPORTED;
2822}
2823
2824
2825/******************************************************************
2826 * SetIpForwardEntry (IPHLPAPI.@)
2827 *
2828 * Modify an existing route.
2829 *
2830 * PARAMS
2831 * pRoute [In] route with the new information
2832 *
2833 * RETURNS
2834 * Success: NO_ERROR
2835 * Failure: error code from winerror.h
2836 */
2838{
2839 return setIpForwardEntry( pRoute );
2840}
2841
2842
2843/******************************************************************
2844 * SetIpNetEntry (IPHLPAPI.@)
2845 *
2846 * Modify an existing ARP entry.
2847 *
2848 * PARAMS
2849 * pArpEntry [In] ARP entry with the new information
2850 *
2851 * RETURNS
2852 * Success: NO_ERROR
2853 * Failure: error code from winerror.h
2854 */
2856{
2857 HANDLE tcpFile;
2862 DWORD returnSize;
2863 PMIB_IPNETROW arpBuff;
2864
2865 if (!pArpEntry)
2867
2869 return ERROR_NOT_SUPPORTED;
2870
2871 if (!NT_SUCCESS(getNthIpEntity( tcpFile, pArpEntry->dwIndex, &id )))
2872 {
2873 closeTcpFile(tcpFile);
2875 }
2876
2880 req.Req.ID.toi_entity.tei_instance = id.tei_instance;
2882 req.Req.BufferSize = sizeof(MIB_IPNETROW);
2883 arpBuff = (PMIB_IPNETROW)&req.Req.Buffer[0];
2884
2885 RtlCopyMemory(arpBuff, pArpEntry, sizeof(MIB_IPNETROW));
2886
2887 status = DeviceIoControl( tcpFile,
2889 &req,
2890 sizeof(req),
2891 NULL,
2892 0,
2893 &returnSize,
2894 NULL );
2895
2896 closeTcpFile(tcpFile);
2897
2898 if (status)
2899 return NO_ERROR;
2900 else
2902}
2903
2904
2905/******************************************************************
2906 * SetIpStatistics (IPHLPAPI.@)
2907 *
2908 * Toggle IP forwarding and det the default TTL value.
2909 *
2910 * PARAMS
2911 * pIpStats [In] IP statistics with the new information
2912 *
2913 * RETURNS
2914 * Success: NO_ERROR
2915 * Failure: error code from winerror.h
2916 *
2917 * FIXME
2918 * Stub, returns NO_ERROR.
2919 */
2921{
2922 FIXME("(pIpStats %p): stub\n", pIpStats);
2923 return 0;
2924}
2925
2926
2927/******************************************************************
2928 * SetIpTTL (IPHLPAPI.@)
2929 *
2930 * Set the default TTL value.
2931 *
2932 * PARAMS
2933 * nTTL [In] new TTL value
2934 *
2935 * RETURNS
2936 * Success: NO_ERROR
2937 * Failure: error code from winerror.h
2938 *
2939 * FIXME
2940 * Stub, returns NO_ERROR.
2941 */
2943{
2944 FIXME("(nTTL %d): stub\n", nTTL);
2945 return 0;
2946}
2947
2948
2949/******************************************************************
2950 * SetTcpEntry (IPHLPAPI.@)
2951 *
2952 * Set the state of a TCP connection.
2953 *
2954 * PARAMS
2955 * pTcpRow [In] specifies connection with new state
2956 *
2957 * RETURNS
2958 * Success: NO_ERROR
2959 * Failure: error code from winerror.h
2960 *
2961 * FIXME
2962 * Stub, returns NO_ERROR.
2963 */
2965{
2966 FIXME("(pTcpRow %p): stub\n", pTcpRow);
2967 return 0;
2968}
2969
2970
2971/******************************************************************
2972 * UnenableRouter (IPHLPAPI.@)
2973 *
2974 * Decrement the IP-forwarding reference count. Turn off IP-forwarding
2975 * if it reaches zero.
2976 *
2977 * PARAMS
2978 * pOverlapped [In/Out] should be the same as in EnableRouter()
2979 * lpdwEnableCount [Out] optional, receives reference count
2980 *
2981 * RETURNS
2982 * Success: NO_ERROR
2983 * Failure: error code from winerror.h
2984 *
2985 * FIXME
2986 * Stub, returns ERROR_NOT_SUPPORTED.
2987 */
2988DWORD WINAPI UnenableRouter(OVERLAPPED * pOverlapped, LPDWORD lpdwEnableCount)
2989{
2990 FIXME("(pOverlapped %p, lpdwEnableCount %p): stub\n", pOverlapped,
2991 lpdwEnableCount);
2992 return ERROR_NOT_SUPPORTED;
2993}
2994
2995/*
2996 * @unimplemented
2997 */
2999{
3000 FIXME(":stub\n");
3001 return 0L;
3002}
3003
3004
3005/*
3006 * @unimplemented
3007 */
3009{
3010 FIXME(":stub\n");
3011 return 0L;
3012}
3013
3014#ifdef GetAdaptersAddressesV1
3015DWORD WINAPI DECLSPEC_HOTPATCH GetAdaptersAddresses(ULONG Family,ULONG Flags,PVOID Reserved,PIP_ADAPTER_ADDRESSES pAdapterAddresses,PULONG pOutBufLen)
3016{
3017 InterfaceIndexTable *indexTable;
3018 IFInfo ifInfo;
3019 int i;
3020 ULONG ret, requiredSize = 0;
3021 PIP_ADAPTER_ADDRESSES currentAddress;
3022 PUCHAR currentLocation;
3023 HANDLE tcpFile;
3024
3025 if (!pOutBufLen) return ERROR_INVALID_PARAMETER;
3027
3028 indexTable = getInterfaceIndexTable();
3029 if (!indexTable)
3031
3032 ret = openTcpFile(&tcpFile, FILE_READ_DATA);
3033 if (!NT_SUCCESS(ret))
3034 {
3035 free(indexTable);
3036 return ERROR_NO_DATA;
3037 }
3038
3039 for (i = indexTable->numIndexes; i >= 0; i--)
3040 {
3041 if (NT_SUCCESS(getIPAddrEntryForIf(tcpFile,
3042 NULL,
3043 indexTable->indexes[i],
3044 &ifInfo)))
3045 {
3046 /* The whole struct */
3047 requiredSize += sizeof(IP_ADAPTER_ADDRESSES);
3048
3049 /* Friendly name */
3051 requiredSize += ifInfo.if_info.ent.if_descrlen + 1; //FIXME
3052
3053 /* Adapter name */
3054 requiredSize += ifInfo.if_info.ent.if_descrlen + 1;
3055
3056 /* Unicast address */
3058 requiredSize += sizeof(IP_ADAPTER_UNICAST_ADDRESS);
3059
3060 /* FIXME: Implement multicast, anycast, and dns server stuff */
3061
3062 /* FIXME: Implement dns suffix and description */
3063 requiredSize += 2 * sizeof(WCHAR);
3064
3065 /* We're only going to implement what's required for XP SP0 */
3066 }
3067 }
3068 TRACE("size: %d, requiredSize: %d\n", *pOutBufLen, requiredSize);
3069 if (!pAdapterAddresses || *pOutBufLen < requiredSize)
3070 {
3071 *pOutBufLen = requiredSize;
3072 closeTcpFile(tcpFile);
3073 free(indexTable);
3074 return ERROR_BUFFER_OVERFLOW;
3075 }
3076
3077 RtlZeroMemory(pAdapterAddresses, requiredSize);
3078
3079 /* Let's set up the pointers */
3080 currentAddress = pAdapterAddresses;
3081 for (i = indexTable->numIndexes; i >= 0; i--)
3082 {
3083 if (NT_SUCCESS(getIPAddrEntryForIf(tcpFile,
3084 NULL,
3085 indexTable->indexes[i],
3086 &ifInfo)))
3087 {
3088 currentLocation = (PUCHAR)currentAddress + (ULONG_PTR)sizeof(IP_ADAPTER_ADDRESSES);
3089
3090 /* FIXME: Friendly name */
3092 {
3093 currentAddress->FriendlyName = (PVOID)currentLocation;
3094 currentLocation += sizeof(WCHAR);
3095 }
3096
3097 /* Adapter name */
3098 currentAddress->AdapterName = (PVOID)currentLocation;
3099 currentLocation += ifInfo.if_info.ent.if_descrlen + 1;
3100
3101 /* Unicast address */
3103 {
3104 currentAddress->FirstUnicastAddress = (PVOID)currentLocation;
3105 currentLocation += sizeof(IP_ADAPTER_UNICAST_ADDRESS);
3106 currentAddress->FirstUnicastAddress->Address.lpSockaddr = (PVOID)currentLocation;
3107 currentLocation += sizeof(struct sockaddr);
3108 }
3109
3110 /* FIXME: Implement multicast, anycast, and dns server stuff */
3111
3112 /* FIXME: Implement dns suffix and description */
3113 currentAddress->DnsSuffix = (PVOID)currentLocation;
3114 currentLocation += sizeof(WCHAR);
3115
3116 currentAddress->Description = (PVOID)currentLocation;
3117 currentLocation += sizeof(WCHAR);
3118
3119 currentAddress->Next = (PVOID)currentLocation;
3120 /* Terminate the last address correctly */
3121 if(i==0)
3122 currentAddress->Next = NULL;
3123
3124 /* We're only going to implement what's required for XP SP0 */
3125
3126 currentAddress = currentAddress->Next;
3127 }
3128 }
3129
3130 /* Now again, for real this time */
3131
3132 currentAddress = pAdapterAddresses;
3133 for (i = indexTable->numIndexes; i >= 0; i--)
3134 {
3135 if (NT_SUCCESS(getIPAddrEntryForIf(tcpFile,
3136 NULL,
3137 indexTable->indexes[i],
3138 &ifInfo)))
3139 {
3140 /* Make sure we're not looping more than we hoped for */
3141 ASSERT(currentAddress);
3142
3143 /* Alignment information */
3144 currentAddress->Length = sizeof(IP_ADAPTER_ADDRESSES);
3145 currentAddress->IfIndex = indexTable->indexes[i];
3146
3147 /* Adapter name */
3148 memcpy(currentAddress->AdapterName, ifInfo.if_info.ent.if_descr, ifInfo.if_info.ent.if_descrlen);
3149 currentAddress->AdapterName[ifInfo.if_info.ent.if_descrlen] = '\0';
3150
3152 {
3153 currentAddress->FirstUnicastAddress->Length = sizeof(IP_ADAPTER_UNICAST_ADDRESS);
3154 currentAddress->FirstUnicastAddress->Flags = 0; //FIXME
3155 currentAddress->FirstUnicastAddress->Next = NULL; //FIXME: Support more than one address per adapter
3156 currentAddress->FirstUnicastAddress->Address.lpSockaddr->sa_family = AF_INET;
3157 memcpy(currentAddress->FirstUnicastAddress->Address.lpSockaddr->sa_data,
3158 &ifInfo.ip_addr.iae_addr,
3159 sizeof(ifInfo.ip_addr.iae_addr));
3160 currentAddress->FirstUnicastAddress->Address.iSockaddrLength = sizeof(ifInfo.ip_addr.iae_addr) + sizeof(USHORT);
3161 currentAddress->FirstUnicastAddress->PrefixOrigin = IpPrefixOriginOther; //FIXME
3162 currentAddress->FirstUnicastAddress->SuffixOrigin = IpPrefixOriginOther; //FIXME
3163 currentAddress->FirstUnicastAddress->DadState = IpDadStatePreferred; //FIXME
3164 currentAddress->FirstUnicastAddress->ValidLifetime = 0xFFFFFFFF; //FIXME
3165 currentAddress->FirstUnicastAddress->PreferredLifetime = 0xFFFFFFFF; //FIXME
3166 currentAddress->FirstUnicastAddress->LeaseLifetime = 0xFFFFFFFF; //FIXME
3167 }
3168
3169 /* FIXME: Implement multicast, anycast, and dns server stuff */
3170 currentAddress->FirstAnycastAddress = NULL;
3171 currentAddress->FirstMulticastAddress = NULL;
3172 currentAddress->FirstDnsServerAddress = NULL;
3173
3174 /* FIXME: Implement dns suffix, description, and friendly name */
3175 currentAddress->DnsSuffix[0] = UNICODE_NULL;
3176 currentAddress->Description[0] = UNICODE_NULL;
3177 currentAddress->FriendlyName[0] = UNICODE_NULL;
3178
3179 /* Physical Address */
3180 memcpy(currentAddress->PhysicalAddress, ifInfo.if_info.ent.if_physaddr, ifInfo.if_info.ent.if_physaddrlen);
3181 currentAddress->PhysicalAddressLength = ifInfo.if_info.ent.if_physaddrlen;
3182
3183 /* Flags */
3184 currentAddress->Flags = 0; //FIXME
3185
3186 /* MTU */
3187 currentAddress->Mtu = ifInfo.if_info.ent.if_mtu;
3188
3189 /* Interface type */
3190 currentAddress->IfType = ifInfo.if_info.ent.if_type;
3191
3192 /* Operational status */
3194 currentAddress->OperStatus = IfOperStatusUp;
3195 else
3196 currentAddress->OperStatus = IfOperStatusDown;
3197
3198 /* We're only going to implement what's required for XP SP0 */
3199
3200 /* Move to the next address */
3201 currentAddress = currentAddress->Next;
3202 }
3203 }
3204
3205 closeTcpFile(tcpFile);
3206 free(indexTable);
3207
3208 return NO_ERROR;
3209}
3210#endif
3211
3212/*
3213 * @unimplemented
3214 */
3216{
3217 FIXME(":stub\n");
3218 return 0L;
3219}
3220
3221/*
3222 * @unimplemented
3223 */
3224DWORD WINAPI GetBestInterfaceEx(struct sockaddr *pDestAddr,PDWORD pdwBestIfIndex)
3225{
3226 FIXME(":stub\n");
3227 return 0L;
3228}
3229
3230/*
3231 * @unimplemented
3232 */
3234{
3235 FIXME(":stub\n");
3236 return 0L;
3237}
3238
3239/*
3240 * @unimplemented
3241 */
3243{
3244 FIXME(":stub\n");
3245
3246 if (!pStats)
3248
3249 if (dwFamily != AF_INET && dwFamily != AF_INET6)
3251
3252 return 0L;
3253}
3254
3257{
3258 FIXME("SetIpForwardEntryToStack() stub\n");
3259 return 0L;
3260}
3261
3263 _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName,
3264 _Inout_ PULONG pOutBufLen)
3265{
3267 DWORD result, type;
3268 WCHAR szKeyName[2*MAX_PATH];
3269 HRESULT hr;
3270 HKEY hKey;
3271
3272 if (pInterfaceGUID == NULL || pOutBufLen == NULL)
3274
3275 result = RtlStringFromGUID(pInterfaceGUID, &GuidString);
3276
3277 if (!NT_SUCCESS(result))
3278 {
3279 // failed to convert guid to string
3281 }
3282
3283 hr = StringCbPrintfW(szKeyName, sizeof(szKeyName), L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection", GuidString.Buffer);
3285
3286 if (FAILED(hr))
3287 {
3288 // key name is too long
3289 return ERROR_BUFFER_OVERFLOW;
3290 }
3291
3293
3294 if (result != ERROR_SUCCESS)
3295 {
3296 // failed to find adapter entry
3297 return ERROR_NOT_FOUND;
3298 }
3299
3300 result = RegQueryValueExW(hKey, L"Name", NULL, &type, (PVOID)pInterfaceName, pOutBufLen);
3301
3303
3304 if (result == ERROR_MORE_DATA)
3305 {
3306 *pOutBufLen = MAX_INTERFACE_NAME_LEN * 2;
3308 }
3309
3310 if (result != ERROR_SUCCESS || type != REG_SZ)
3311 {
3312 // failed to read adapter name
3313 return ERROR_NO_DATA;
3314 }
3315 return ERROR_SUCCESS;
3316}
3317
3320 _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName,
3321 _Inout_ PULONG pOutBufLen,
3322 DWORD dwUnknown4,
3323 DWORD dwUnknown5)
3324{
3326
3327 if (pInterfaceName == NULL)
3329
3330 return GetInterfaceNameInternal(pInterfaceGUID, pInterfaceName, pOutBufLen);
3331}
3332
3334NhGetInterfaceNameFromGuid(_In_ const GUID * pInterfaceGUID,
3335 _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName,
3336 _Inout_ PULONG pOutBufLen,
3337 DWORD dwUnknown4,
3338 DWORD dwUnknown5)
3339{
3340 DWORD result;
3341
3342 result = GetInterfaceNameInternal(pInterfaceGUID, pInterfaceName, pOutBufLen);
3343
3344 if (result == ERROR_NOT_FOUND)
3346
3347 return result;
3348}
PRTL_UNICODE_STRING_BUFFER Path
ULONG WSAAPI inet_addr(IN CONST CHAR FAR *cp)
Definition: addrconv.c:71
static DWORD const fdwReason
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
LONG NTSTATUS
Definition: precomp.h:26
#define INADDR_NONE
Definition: tcp.c:42
#define FIXME(fmt,...)
Definition: precomp.h:53
BOOL Error
Definition: chkdsk.c:66
static DWORD ServiceTag
Definition: database.c:34
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define RegCloseKey(hKey)
Definition: registry.h:49
Definition: bufpool.h:45
Definition: File.h:16
wcscpy
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define free
Definition: debug_ros.c:5
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
void WINAPI DhcpCApiCleanup(void)
Definition: dhcpcsvc.c:71
DWORD APIENTRY DhcpCApiInitialize(LPDWORD Version)
Definition: dhcpcsvc.c:26
DWORD APIENTRY DhcpReleaseIpAddressLease(DWORD AdapterIndex)
Definition: dhcpcsvc.c:202
DWORD APIENTRY DhcpRenewIpAddressLease(DWORD AdapterIndex)
Definition: dhcpcsvc.c:228
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3234
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define GetModuleFileNameExW(w, x, y, z)
Definition: compat.h:922
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
DWORD getDhcpInfoForAdapter(DWORD AdapterIndex, PIP_ADAPTER_INFO ptr)
Definition: dhcp_reactos.c:12
DWORD deleteIpForwardEntry(PMIB_IPFORWARDROW pRoute)
Definition: route.c:64
DWORD setIpForwardEntry(PMIB_IPFORWARDROW pRoute)
Definition: route.c:59
DWORD createIpForwardEntry(PMIB_IPFORWARDROW pRoute)
Definition: route.c:52
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:883
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
DWORD WINAPI GetModuleBaseNameW(HANDLE hProcess, HMODULE hModule, LPWSTR lpBaseName, DWORD nSize)
Definition: psapi.c:853
#define AF_INET
Definition: tcpip.h:117
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2712
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
FxIoTarget * pTarget
Definition: fxdeviceapi.cpp:97
FxAutoRegKey hKey
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLbitfield flags
Definition: glext.h:7161
GLenum const GLvoid * addr
Definition: glext.h:9621
GLuint64EXT * result
Definition: glext.h:11304
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLuint id
Definition: glext.h:5910
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
@ IfOperStatusUp
Definition: ifdef.h:185
@ IfOperStatusDown
Definition: ifdef.h:186
void interfaceMapFree(void)
DWORD getInterfacePhysicalByIndex(DWORD index, PDWORD len, PBYTE addr, PDWORD type)
DWORD getNumNonLoopbackInterfaces(void)
DWORD getNumInterfaces(void)
DWORD getInterfaceMaskByIndex(DWORD index)
InterfaceIndexTable * getNonLoopbackInterfaceIndexTable(void)
DWORD getInterfaceEntryByIndex(DWORD index, PMIB_IFROW entry)
const char * getInterfaceNameByIndex(DWORD index)
DWORD getInterfaceBCastAddrByIndex(DWORD index)
void interfaceMapInit(void)
InterfaceIndexTable * getInterfaceIndexTable(void)
char * toIPAddressString(unsigned int addr, char string[16])
NTSTATUS addIPAddress(IPAddr Address, IPMask Mask, DWORD IfIndex, PULONG NteContext, PULONG NteInstance)
DWORD getInterfaceIPAddrByIndex(DWORD index)
NTSTATUS deleteIpAddress(ULONG NteContext)
void consumeInterfaceName(const char *ifname)
NTSTATUS getIPAddrEntryForIf(HANDLE tcpFile, char *name, DWORD index, IFInfo *ifInfo)
struct _MIB_IFTABLE * PMIB_IFTABLE
struct _MIB_IFROW * PMIB_IFROW
struct _MIB_IFTABLE MIB_IFTABLE
#define MAX_INTERFACE_NAME_LEN
Definition: ifmib.h:31
struct _MIB_IFROW MIB_IFROW
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define PROCESS_VM_READ
Definition: pstypes.h:162
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:167
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask)
Definition: intrin_arm.h:57
#define FAILED(hr)
Definition: intsafe.h:51
ULONG IPMask
Definition: ipexport.h:28
#define MAX_ADAPTER_NAME
Definition: ipexport.h:143
ULONG IP_STATUS
Definition: ipexport.h:29
struct _IP_ADAPTER_INDEX_MAP IP_ADAPTER_INDEX_MAP
struct _IP_INTERFACE_INFO IP_INTERFACE_INFO
static PIP_ADAPTER_ADDRESSES
Definition: iphlpapi.c:76
DWORD WINAPI NotifyAddrChange(PHANDLE Handle, LPOVERLAPPED overlapped)
DWORD WINAPI GetIpErrorString(IP_STATUS ErrorCode, PWCHAR Buffer, PDWORD Size)
DWORD WINAPI NhpAllocateAndGetInterfaceInfoFromStack(IP_INTERFACE_NAME_INFO **ppTable, PDWORD pdwCount, BOOL bOrder, HANDLE hHeap, DWORD dwFlags)
DWORD WINAPI SetTcpEntry(PMIB_TCPROW pTcpRow)
DWORD WINAPI EnableRouter(HANDLE *pHandle, OVERLAPPED *pOverlapped)
DWORD WINAPI GetBestInterfaceEx(struct sockaddr *pDestAddr, PDWORD pdwBestIfIndex)
DWORD WINAPI GetBestInterface(IPAddr dwDestAddr, PDWORD pdwBestIfIndex)
BOOL WINAPI GetRTTAndHopCount(IPAddr DestIpAddress, PULONG HopCount, ULONG MaxHops, PULONG RTT)
DWORD WINAPI SetIpStatistics(PMIB_IPSTATS pIpStats)
DWORD WINAPI GetFriendlyIfIndex(DWORD IfIndex)
DWORD WINAPI GetIcmpStatisticsEx(PMIB_ICMP_EX pStats, DWORD dwFamily)
DWORD WINAPI GetExtendedUdpTable(PVOID pUdpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, UDP_TABLE_CLASS TableClass, ULONG Reserved)
DWORD WINAPI AllocateAndGetUdpTableFromStack(PMIB_UDPTABLE *ppUdpTable, BOOL bOrder, HANDLE heap, DWORD flags)
DWORD WINAPI SetIfEntry(PMIB_IFROW pIfRow)
static int TcpTableSorter(const void *a, const void *b)
static int IpNetTableSorter(const void *a, const void *b)
DWORD WINAPI AllocateAndGetIpAddrTableFromStack(PMIB_IPADDRTABLE *ppIpAddrTable, BOOL bOrder, HANDLE heap, DWORD flags)
DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
DWORD WINAPI NotifyRouteChange(PHANDLE Handle, LPOVERLAPPED overlapped)
DWORD WINAPI UnenableRouter(OVERLAPPED *pOverlapped, LPDWORD lpdwEnableCount)
DWORD GetInterfaceNameInternal(_In_ const GUID *pInterfaceGUID, _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, _Inout_ PULONG pOutBufLen)
DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable, BOOL bOrder, HANDLE heap, DWORD flags)
DWORD WINAPI AddIPAddress(IPAddr Address, IPMask Netmask, DWORD IfIndex, PULONG NteContext, PULONG NteInstance)
Definition: iphlpapi_main.c:67
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: iphlpapi_main.c:39
DWORD WINAPI CreateProxyArpEntry(DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
static int IpAddrTableSorter(const void *a, const void *b)
DWORD WINAPI IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
DWORD WINAPI CreateIpNetEntry(PMIB_IPNETROW pArpEntry)
DWORD WINAPI DeleteIpNetEntry(PMIB_IPNETROW pArpEntry)
DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSize, BOOL bOrder)
DWORD WINAPI GetExtendedTcpTable(PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, TCP_TABLE_CLASS TableClass, ULONG Reserved)
DWORD WINAPI SetIpForwardEntry(PMIB_IPFORWARDROW pRoute)
PIP_ADAPTER_ORDER_MAP WINAPI GetAdapterOrderMap(VOID)
DWORD WINAPI GetIpStatistics(PMIB_IPSTATS pStats)
struct _NAME_SERVER_LIST_CONTEXT NAME_SERVER_LIST_CONTEXT
DWORD WINAPI FlushIpNetTable(DWORD dwIfIndex)
DWORD WINAPI GetIpNetTable(PMIB_IPNETTABLE pIpNetTable, PULONG pdwSize, BOOL bOrder)
DWORD WINAPI AllocateAndGetUdpExTable2FromStack(PVOID *ppUdpTable, BOOL bOrder, HANDLE heap, DWORD flags, DWORD family, UDP_TABLE_CLASS class)
DWORD WINAPI DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute)
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
static DWORD GetOwnerModuleFromPidEntry(DWORD OwningPid, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
DWORD WINAPI GetIcmpStatistics(PMIB_ICMP pStats)
DWORD WINAPI GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen)
DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
DWORD WINAPI GetTcpStatisticsEx(PMIB_TCPSTATS pStats, DWORD dwFamily)
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
BOOL WINAPI CancelIPChangeNotify(LPOVERLAPPED notifyOverlapped)
DWORD WINAPI SetIpNetEntry(PMIB_IPNETROW pArpEntry)
DWORD WINAPI GetOwnerModuleFromUdpEntry(PMIB_UDPROW_OWNER_MODULE pUdpEntry, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
DWORD WINAPI AllocateAndGetTcpExTableFromStack(PVOID *ppTcpTable, BOOL bOrder, HANDLE heap, DWORD flags, DWORD family)
DWORD getInterfaceGatewayByIndex(DWORD index)
Definition: iphlpapi_main.c:72
static int IfTableSorter(const void *a, const void *b)
DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
DWORD WINAPI CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute)
static DWORD GetOwnerModuleFromTagEntry(DWORD OwningPid, DWORD OwningTag, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
DWORD WINAPI GetUniDirectionalAdapterInfo(PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo, PULONG dwOutBufLen)
DWORD WINAPI GetUdpStatistics(PMIB_UDPSTATS pStats)
DWORD WINAPI SetIpForwardEntryToStack(PMIB_IPFORWARDROW pRoute)
DWORD WINAPI SetIpTTL(UINT nTTL)
DWORD WINAPI GetUdpStatisticsEx(PMIB_UDPSTATS pStats, DWORD dwFamily)
static int IpForwardTableSorter(const void *a, const void *b)
DWORD WINAPI AllocateAndGetTcpTableFromStack(PMIB_TCPTABLE *ppTcpTable, BOOL bOrder, HANDLE heap, DWORD flags)
DWORD WINAPI GetOwnerModuleFromTcpEntry(PMIB_TCPROW_OWNER_MODULE pTcpEntry, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
DWORD WINAPI GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder)
DWORD WINAPI AllocateAndGetUdpExTableFromStack(PVOID *ppUdpTable, BOOL bOrder, HANDLE heap, DWORD flags, DWORD family)
DWORD WINAPI NhGetInterfaceNameFromDeviceGuid(_In_ const GUID *pInterfaceGUID, _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, _Inout_ PULONG pOutBufLen, DWORD dwUnknown4, DWORD dwUnknown5)
DWORD WINAPI DeleteIPAddress(ULONG NTEContext)
DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDROW pBestRoute)
DWORD WINAPI AllocateAndGetIfTableFromStack(PMIB_IFTABLE *ppIfTable, BOOL bOrder, HANDLE heap, DWORD flags)
struct _NAME_SERVER_LIST_CONTEXT * PNAME_SERVER_LIST_CONTEXT
DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS pStats)
DWORD WINAPI GetUdpTable(PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder)
static int UdpTableSorter(const void *a, const void *b)
DWORD WINAPI SendARP(IPAddr DestIP, IPAddr SrcIP, PULONG pMacAddr, PULONG PhyAddrLen)
DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf)
static void CreateNameServerListEnumNamesFunc(PWCHAR Interface, PWCHAR Server, PVOID Data)
DWORD WINAPI NhGetInterfaceNameFromGuid(_In_ const GUID *pInterfaceGUID, _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, _Inout_ PULONG pOutBufLen, DWORD dwUnknown4, DWORD dwUnknown5)
DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForwardTable, BOOL bOrder, HANDLE heap, DWORD flags)
DWORD WINAPI GetTcpTable(PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder)
DWORD WINAPI GetAdapterIndex(LPWSTR AdapterName, PULONG IfIndex)
DWORD WINAPI DeleteProxyArpEntry(DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
DWORD WINAPI AllocateAndGetTcpExTable2FromStack(PVOID *ppTcpTable, BOOL bOrder, HANDLE heap, DWORD flags, DWORD family, TCP_TABLE_CLASS class)
DWORD WINAPI GetIpStatisticsEx(PMIB_IPSTATS pStats, DWORD dwFamily)
DWORD WINAPI IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
#define GAA_FLAG_SKIP_FRIENDLY_NAME
#define GAA_FLAG_SKIP_UNICAST
LSTATUS EnumNameServers(HKEY RegHandle, LPWSTR Interface, PVOID Data, EnumNameServersFunc cb)
DWORD TCPSendIoctl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, PULONG pInBufferSize, LPVOID lpOutBuffer, PULONG pOutBufferSize)
NTSTATUS getNthIpEntity(HANDLE tcpFile, DWORD index, TDIEntityID *ent)
#define TCP_REQUEST_SET_INFORMATION_INIT
@ IF_OPER_STATUS_CONNECTING
Definition: ipifcons.h:241
struct _MIB_IPFORWARDTABLE * PMIB_IPFORWARDTABLE
@ MIB_IPROUTE_TYPE_DIRECT
Definition: ipmib.h:63
struct _MIB_IPNETTABLE * PMIB_IPNETTABLE
struct _MIB_IPNETROW MIB_IPNETROW
struct _MIB_IPADDRROW MIB_IPADDRROW
struct _MIB_IPFORWARDTABLE MIB_IPFORWARDTABLE
struct _MIB_IPADDRTABLE MIB_IPADDRTABLE
struct _MIB_IPNETROW * PMIB_IPNETROW
struct _MIB_IPNETTABLE MIB_IPNETTABLE
struct _MIB_IPFORWARDROW * PMIB_IPFORWARDROW
struct _MIB_IPFORWARDROW MIB_IPFORWARDROW
struct _MIB_IPADDRTABLE * PMIB_IPADDRTABLE
struct _MIB_IPADDRROW * PMIB_IPADDRROW
struct _TCPIP_OWNER_MODULE_BASIC_INFO TCPIP_OWNER_MODULE_BASIC_INFO
enum _TCP_TABLE_CLASS TCP_TABLE_CLASS
@ TCP_TABLE_OWNER_MODULE_CONNECTIONS
Definition: iprtrmib.h:37
@ TCP_TABLE_BASIC_CONNECTIONS
Definition: iprtrmib.h:31
@ TCP_TABLE_BASIC_LISTENER
Definition: iprtrmib.h:30
@ TCP_TABLE_OWNER_MODULE_ALL
Definition: iprtrmib.h:38
@ TCP_TABLE_OWNER_PID_LISTENER
Definition: iprtrmib.h:33
@ TCP_TABLE_BASIC_ALL
Definition: iprtrmib.h:32
@ TCP_TABLE_OWNER_PID_ALL
Definition: iprtrmib.h:35
@ TCP_TABLE_OWNER_PID_CONNECTIONS
Definition: iprtrmib.h:34
@ TCP_TABLE_OWNER_MODULE_LISTENER
Definition: iprtrmib.h:36
enum _TCPIP_OWNER_MODULE_INFO_CLASS TCPIP_OWNER_MODULE_INFO_CLASS
enum _UDP_TABLE_CLASS UDP_TABLE_CLASS
@ UDP_TABLE_BASIC
Definition: iprtrmib.h:43
@ UDP_TABLE_OWNER_MODULE
Definition: iprtrmib.h:45
@ UDP_TABLE_OWNER_PID
Definition: iprtrmib.h:44
PVOID getTcpTable(CLASS_TABLE Class)
DWORD getICMPStats(MIB_ICMP *stats)
DWORD getInterfaceStatsByName(const char *name, PMIB_IFROW entry)
DWORD getIPStats(HANDLE tcpFile, PMIB_IPSTATS stats)
DWORD getNumArpEntries(void)
RouteTable * getRouteTable(void)
PMIB_IPNETTABLE getArpTable(void)
@ ClassModulePid
Definition: ipstats.h:81
@ ClassBasic
Definition: ipstats.h:80
@ ClassModule
Definition: ipstats.h:82
PVOID getUdpTable(CLASS_TABLE Class)
DWORD getNumRoutes(void)
DWORD getTCPStats(HANDLE tcpFile, MIB_TCPSTATS *stats)
DWORD getUDPStats(HANDLE tcpFile, MIB_UDPSTATS *stats)
#define MAX_ADAPTER_NAME_LENGTH
Definition: iptypes.h:27
struct _IP_PER_ADAPTER_INFO IP_PER_ADAPTER_INFO
struct _IP_ADAPTER_INFO IP_ADAPTER_INFO
#define HYBRID_NODETYPE
Definition: iptypes.h:39
struct _IP_ADDR_STRING IP_ADDR_STRING
#define b
Definition: ke_i.h:79
#define REG_SZ
Definition: layer.c:22
if(dx< 0)
Definition: linetemp.h:194
static IN DWORD IN LPVOID lpvReserved
#define INADDR_ANY
Definition: inet.h:80
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ASSERT(a)
Definition: mode.c:44
#define ntohl(x)
Definition: module.h:205
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static PWSTR GuidString
Definition: apphelp.c:93
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static PVOID ptr
Definition: dispmode.c:27
unsigned int UINT
Definition: ndis.h:50
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE _In_ PNDIS_STRING AdapterName
Definition: ndis.h:6016
@ IpDadStatePreferred
Definition: nldef.h:49
@ IpPrefixOriginOther
Definition: nldef.h:9
#define _Inout_
Definition: no_sal2.h:162
#define _Out_writes_bytes_to_(s, c)
Definition: no_sal2.h:190
#define _In_
Definition: no_sal2.h:158
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define DWORD
Definition: nt_native.h:44
#define UNICODE_NULL
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c:66
DWORD * PDWORD
Definition: pedump.c:68
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
ULONG IPAddr
Definition: pfhook.h:35
static WCHAR Address[46]
Definition: ping.c:68
static int Family
Definition: ping.c:62
VOID disposeResInfo(PIPHLP_RES_INFO InfoPtr)
Definition: resinfo.c:60
PIPHLP_RES_INFO getResInfo()
Definition: resinfo.c:54
#define DECLSPEC_HOTPATCH
Definition: config.h:9
strncpy
Definition: string.h:335
static HANDLE heap
Definition: heap.c:65
#define memset(x, y, z)
Definition: compat.h:39
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
HRESULT hr
Definition: shlfolder.c:183
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:81
#define TRACE(s)
Definition: solgame.cpp:4
static void Server(int port)
Definition: srltest.c:69
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
IP_ADDR_STRING DnsServerList
Definition: iptypes.h:84
char HostName[MAX_HOSTNAME_LEN+4]
Definition: iptypes.h:81
UINT NodeType
Definition: iptypes.h:85
char ScopeId[MAX_SCOPE_ID_LEN+4]
Definition: iptypes.h:86
char DomainName[MAX_DOMAIN_NAME_LEN+4]
Definition: iptypes.h:82
ULONG if_operstatus
Definition: tcpioctl.h:118
UCHAR if_descr[1]
Definition: tcpioctl.h:133
ULONG if_descrlen
Definition: tcpioctl.h:132
ULONG if_physaddrlen
Definition: tcpioctl.h:115
ULONG if_type
Definition: tcpioctl.h:112
ULONG if_mtu
Definition: tcpioctl.h:113
UCHAR if_physaddr[MAX_PHYSADDR_SIZE]
Definition: tcpioctl.h:116
ULONG iae_addr
Definition: tcpioctl.h:165
char String[4 *4]
Definition: iptypes.h:42
IFEntrySafelySized if_info
IPAddrEntry ip_addr
IP_ADDR_STRING * DnsList
Definition: resinfo.h:26
DWORD riCount
Definition: resinfo.h:25
WCHAR Name[MAX_ADAPTER_NAME]
Definition: ipexport.h:147
struct _IP_ADDR_STRING * Next
Definition: iptypes.h:46
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:47
DWORD Context
Definition: iptypes.h:49
IP_ADAPTER_INDEX_MAP Adapter[1]
Definition: ipexport.h:152
DWORD indexes[1]
Definition: ifenum.h:64
DWORD dwIndex
Definition: ifmib.h:38
MIB_IFROW table[1]
Definition: ifmib.h:66
DWORD dwNumEntries
Definition: ifmib.h:65
unsigned short unused1
Definition: ipmib.h:41
DWORD dwReasmSize
Definition: ipmib.h:40
DWORD dwBCastAddr
Definition: ipmib.h:39
DWORD dwMask
Definition: ipmib.h:38
DWORD dwAddr
Definition: ipmib.h:36
IF_INDEX dwIndex
Definition: ipmib.h:37
unsigned short wType
Definition: ipmib.h:42
MIB_IPADDRROW table[1]
Definition: ipmib.h:48
DWORD dwNumEntries
Definition: ipmib.h:47
DWORD dwForwardMetric5
Definition: ipmib.h:92
DWORD dwForwardNextHop
Definition: ipmib.h:74
DWORD dwForwardMetric2
Definition: ipmib.h:89
DWORD dwForwardPolicy
Definition: ipmib.h:73
DWORD dwForwardMetric3
Definition: ipmib.h:90
DWORD dwForwardProto
Definition: ipmib.h:83
DWORD dwForwardMetric1
Definition: ipmib.h:88
IF_INDEX dwForwardIfIndex
Definition: ipmib.h:75
DWORD dwForwardNextHopAS
Definition: ipmib.h:87
DWORD dwForwardDest
Definition: ipmib.h:71
DWORD dwForwardMask
Definition: ipmib.h:72
DWORD dwForwardMetric4
Definition: ipmib.h:91
DWORD dwForwardAge
Definition: ipmib.h:86
DWORD dwForwardType
Definition: ipmib.h:78
DWORD dwNumEntries
Definition: ipmib.h:97
MIB_IPFORWARDROW table[1]
Definition: ipmib.h:98
DWORD dwIndex
Definition: ipmib.h:114
DWORD dwNumEntries
Definition: ipmib.h:127
MIB_IPNETROW table[1]
Definition: ipmib.h:128
ULONGLONG OwningModuleInfo[TCPIP_OWNING_MODULE_SIZE]
Definition: tcpmib.h:127
DWORD dwLocalPort
Definition: tcpmib.h:59
DWORD dwLocalAddr
Definition: tcpmib.h:58
MIB_TCP_STATE State
Definition: tcpmib.h:56
DWORD dwRemotePort
Definition: tcpmib.h:61
DWORD dwRemoteAddr
Definition: tcpmib.h:60
MIB_TCPROW_OWNER_MODULE table[1]
Definition: tcpmib.h:133
MIB_TCPROW_OWNER_PID table[1]
Definition: tcpmib.h:115
DWORD dwNumEntries
Definition: tcpmib.h:66
MIB_TCPROW table[1]
Definition: tcpmib.h:67
ULONGLONG OwningModuleInfo[TCPIP_OWNING_MODULE_SIZE]
Definition: udpmib.h:65
DWORD dwLocalAddr
Definition: udpmib.h:28
DWORD dwLocalPort
Definition: udpmib.h:29
MIB_UDPROW_OWNER_MODULE table[1]
Definition: udpmib.h:71
MIB_UDPROW_OWNER_PID table[1]
Definition: udpmib.h:48
DWORD dwNumEntries
Definition: udpmib.h:34
MIB_UDPROW table[1]
Definition: udpmib.h:35
PIP_PER_ADAPTER_INFO pData
Definition: iphlpapi_main.c:34
IP_ADDR_STRING * pLastAddr
Definition: iphlpapi_main.c:36
unsigned char Buffer[1]
Definition: tdiinfo.h:97
ULONG tei_entity
Definition: tdiinfo.h:31
ULONG tei_instance
Definition: tdiinfo.h:32
ULONG toi_id
Definition: tdiinfo.h:77
ULONG toi_type
Definition: tdiinfo.h:76
ULONG toi_class
Definition: tdiinfo.h:75
TDIEntityID toi_entity
Definition: tdiinfo.h:74
Definition: name.c:39
Definition: ps.c:97
#define IP_MIB_ARPTABLE_ENTRY_ID
Definition: tcpioctl.h:54
#define IOCTL_QUERY_IP_HW_ADDRESS
Definition: tcpioctl.h:40
struct _MIB_TCPROW * PMIB_TCPROW
struct _MIB_TCPROW MIB_TCPROW
struct _MIB_TCPTABLE_OWNER_PID * PMIB_TCPTABLE_OWNER_PID
struct _MIB_TCPTABLE * PMIB_TCPTABLE
struct _MIB_TCPROW_OWNER_PID MIB_TCPROW_OWNER_PID
@ MIB_TCP_STATE_LISTEN
Definition: tcpmib.h:29
struct _MIB_TCPROW_OWNER_MODULE MIB_TCPROW_OWNER_MODULE
#define INFO_CLASS_PROTOCOL
Definition: tdiinfo.h:65
#define AT_ENTITY
Definition: tdiinfo.h:41
#define INFO_TYPE_PROVIDER
Definition: tdiinfo.h:69
#define IOCTL_TCP_SET_INFORMATION_EX
Definition: tditest.h:112
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * LPBYTE
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
uint32_t * LPDWORD
Definition: typedefs.h:59
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint16_t * PWCHAR
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
struct _MIB_UDPTABLE_OWNER_PID * PMIB_UDPTABLE_OWNER_PID
struct _MIB_UDPROW_OWNER_MODULE MIB_UDPROW_OWNER_MODULE
struct _MIB_UDPROW * PMIB_UDPROW
struct _MIB_UDPROW_OWNER_PID MIB_UDPROW_OWNER_PID
struct _MIB_UDPROW MIB_UDPROW
struct _MIB_UDPTABLE * PMIB_UDPTABLE
TCP_REQUEST_SET_INFORMATION_EX Req
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
#define ZeroMemory
Definition: winbase.h:1744
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CopyMemory
Definition: winbase.h:1742
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
#define WINAPI
Definition: msvc.h:6
#define ERROR_PARTIAL_COPY
Definition: winerror.h:303
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define ERROR_NO_DATA
Definition: winerror.h:284
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define NOERROR
Definition: winerror.h:2354
#define ERROR_PROC_NOT_FOUND
Definition: winerror.h:199
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define ERROR_NOT_FOUND
Definition: winerror.h:690
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define PF_INET
Definition: winsock.h:373
#define AF_INET6
Definition: winsock.h:369
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184