Author: arty
Date: Tue Aug 26 08:28:44 2008
New Revision: 35669
URL:
http://svn.reactos.org/svn/reactos?rev=35669&view=rev
Log:
Commit patches from bugboy, fixing bug 2392.
Modified:
trunk/reactos/dll/cpl/ncpa/tcpip_properties.c
trunk/reactos/dll/win32/iphlpapi/iphlpapi_main.c
Modified: trunk/reactos/dll/cpl/ncpa/tcpip_properties.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/ncpa/tcpip_propert…
==============================================================================
--- trunk/reactos/dll/cpl/ncpa/tcpip_properties.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/ncpa/tcpip_properties.c [iso-8859-1] Tue Aug 26 08:28:44 2008
@@ -238,6 +238,7 @@
BOOL SetDnsByDhcp;
TCHAR pszRegKey[MAX_PATH];
const char *AddressString;
+ char emptyString[]="\0";
DWORD Address = 0;
LONG rc;
HKEY hKey = NULL;
@@ -282,7 +283,7 @@
goto cleanup;
if (DlgData->Dns1 == INADDR_NONE)
{
- rc = RegDeleteValue(hKey, _T("NameServer"));
+ rc = RegSetValueExA(hKey, "NameServer",0, REG_SZ, (const
BYTE*)emptyString, strlen(emptyString) + 1);
if (rc != ERROR_SUCCESS && rc != ERROR_FILE_NOT_FOUND)
goto cleanup;
}
@@ -445,6 +446,7 @@
char Dns[MAX_PATH];
DWORD Size;
DWORD Type;
+ DWORD dwError;
char *NextDnsServer;
DlgData->AdapterName = Info->AdapterName;
@@ -469,7 +471,15 @@
swprintf(RegKey,
L"SYSTEM\\CurrentControlSet\\Services\\TCPIP\\Parameters\\Interfaces\\%S",
Info->AdapterName);
- if (ERROR_SUCCESS == RegOpenKeyW(HKEY_LOCAL_MACHINE, RegKey, &hKey)) {
+ dwError = RegOpenKeyW(HKEY_LOCAL_MACHINE, RegKey, &hKey);
+ if (dwError != ERROR_SUCCESS)
+ {
+ /* Try and fall back on the NameServer in Parameters */
+ swprintf(RegKey,
+ L"SYSTEM\\CurrentControlSet\\Services\\TCPIP\\Parameters\\");
+ }
+ dwError = RegOpenKeyW(HKEY_LOCAL_MACHINE, RegKey, &hKey);
+ if (ERROR_SUCCESS == dwError) {
Size = sizeof(Dns);
RegQueryValueExA(hKey, "NameServer", NULL, &Type, (BYTE *)Dns,
&Size);
Modified: trunk/reactos/dll/win32/iphlpapi/iphlpapi_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/iphlpapi/iphlpap…
==============================================================================
--- trunk/reactos/dll/win32/iphlpapi/iphlpapi_main.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/iphlpapi/iphlpapi_main.c [iso-8859-1] Tue Aug 26 08:28:44
2008
@@ -88,6 +88,19 @@
return RtlNtStatusToDosError(addIPAddress(Address, Netmask, IfIndex, NteContext,
NteInstance));
}
+DWORD getInterfaceGatewayByIndex(DWORD index)
+{
+ DWORD ndx, retVal = 0, numRoutes = getNumRoutes();
+ RouteTable *table = getRouteTable();
+
+ for (ndx = 0; ndx < numRoutes; ndx++)
+ {
+ if ((table->routes[ndx].ifIndex == (index - 1)) &&
(table->routes[ndx].dest == 0))
+ retVal = table->routes[ndx].gateway;
+ }
+ HeapFree(GetProcessHeap(), 0, table);
+ return retVal;
+}
/******************************************************************
* AllocateAndGetIfTableFromStack (IPHLPAPI.@)
@@ -640,6 +653,8 @@
ptr->IpAddressList.IpAddress.String);
toIPAddressString(getInterfaceMaskByIndex(table->indexes[ndx]),
ptr->IpAddressList.IpMask.String);
+ toIPAddressString(getInterfaceGatewayByIndex(table->indexes[ndx]),
+ ptr->GatewayList.IpAddress.String);
getDhcpInfoForAdapter(table->indexes[ndx], &dhcpEnabled,
&dhcpServer, &ptr->LeaseObtained,
&ptr->LeaseExpires);
@@ -1160,7 +1175,7 @@
pIpForwardTable->dwNumEntries = table->numRoutes;
for (ndx = 0; ndx < numRoutes; ndx++) {
pIpForwardTable->table[ndx].dwForwardIfIndex =
- table->routes[ndx].ifIndex;
+ table->routes[ndx].ifIndex + 1;
pIpForwardTable->table[ndx].dwForwardDest =
table->routes[ndx].dest;
pIpForwardTable->table[ndx].dwForwardMask =
@@ -1190,7 +1205,7 @@
sizeof(MIB_IPFORWARDROW), IpForwardTableSorter);
ret = NO_ERROR;
}
- free(table);
+ HeapFree(GetProcessHeap(), 0, table);
}
else
ret = ERROR_OUTOFMEMORY;