On 16.01.2016 12:19, Pierre Schweitzer wrote:
This just implements WNetUseConnectionA() by forwarding it to WNetUseConnectionW() using appropriate conversions when required.
+static PWSTR convert_stringa_to_w( LPCSTR strA ) +{
- int len;
- PWSTR strW;
- if (!strA)
return NULL;
- len = MultiByteToWideChar(CP_ACP, 0, strA, -1, NULL, 0);
- if (!len)
return NULL;
- strW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
- if (!strW)
return NULL;
- if (MultiByteToWideChar(CP_ACP, 0, strA, len, strW, len))
return strW;
- HeapFree(GetProcessHeap(), 0, strW);
- return NULL;
+}
Second mbtowc is wrong - you're using 'len' as strA length, and it should be -1 like on first call. Also it's safe to assume that second call never fails it first one returned non-zero length.
Take a look how it's done it more compact way in various dlls, search for strdupWtoA names (and probably for mpr.dll it should use similar name for consistency).