- Fix MultiByteToWideChar api parameters (thanks Christoph)

- Fix bugs in EnumNameServers

svn path=/trunk/; revision=36722
This commit is contained in:
Johannes Anderwald 2008-10-11 19:30:45 +00:00
parent 639ed2255f
commit 6da373e9fd
2 changed files with 6 additions and 8 deletions

View file

@ -1471,14 +1471,11 @@ DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf)
* DWORD
*
*/
static void CreateNameServerListEnumNamesFunc( PWCHAR Interface,
PWCHAR Server,
PVOID Data )
static void CreateNameServerListEnumNamesFunc( PWCHAR Interface, PWCHAR Server, PVOID Data)
{
IP_ADDR_STRING *pNext;
PNAME_SERVER_LIST_CONTEXT Context = (PNAME_SERVER_LIST_CONTEXT)Data;
if (!Context->NumServers)
{
if (Context->uSizeAvailable >= Context->uSizeRequired)
@ -1518,7 +1515,7 @@ DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterIn
if (!ifName)
return ERROR_INVALID_PARAMETER;
MultiByteToWideChar(CP_ACP, 0, ifName, -1, &keyname[62], sizeof(keyname) - (63 * sizeof(WCHAR)));
MultiByteToWideChar(CP_ACP, 0, ifName, -1, &keyname[62], sizeof(keyname)/sizeof(WCHAR) - 63);
HeapFree(GetProcessHeap(), 0, (LPVOID)ifName);
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyname, 0, KEY_READ, &hkey) != ERROR_SUCCESS)

View file

@ -136,19 +136,20 @@ void EnumNameServers( HANDLE RegHandle, PWCHAR Interface,
malloc(((ch - LastNameStart) + 1) * sizeof(WCHAR));
if (NameServer) {
memcpy(NameServer,NameServerString + LastNameStart,
(ch - LastNameStart) * sizeof(WCHAR));
(ch - LastNameStart) * sizeof(WCHAR));
NameServer[ch - LastNameStart] = 0;
cb( Interface, NameServer, Data );
free(NameServer);
LastNameStart = ch +1;
}
}
LastNameStart = ch + 1; /* The first one after the comma */
}
}
if (ch - LastNameStart > 0) { /* A last name? */
PWCHAR NameServer = malloc(ch - LastNameStart + 1);
PWCHAR NameServer = malloc(((ch - LastNameStart) + 1) * sizeof(WCHAR));
memcpy(NameServer,NameServerString + LastNameStart,
(ch - LastNameStart));
(ch - LastNameStart) * sizeof(WCHAR));
NameServer[ch - LastNameStart] = 0;
cb( Interface, NameServer, Data );
free(NameServer);