diff --git a/dlls/comctl32/comctl32undoc.c b/dlls/comctl32/comctl32undoc.c index 7e5f09b0226..bb7d0218359 100644 --- a/dlls/comctl32/comctl32undoc.c +++ b/dlls/comctl32/comctl32undoc.c @@ -579,7 +579,7 @@ INT WINAPI AddMRUStringA(HANDLE hList, LPCSTR lpszString) if (!stringW) return -1; - MultiByteToWideChar(CP_ACP, 0, lpszString, -1, stringW, len); + MultiByteToWideChar(CP_ACP, 0, lpszString, -1, stringW, len/sizeof(WCHAR)); ret = AddMRUData(hList, stringW, len); Free(stringW); return ret; diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c index 5e539123f91..783ae3e3a09 100644 --- a/dlls/comctl32/propsheet.c +++ b/dlls/comctl32/propsheet.c @@ -2161,7 +2161,7 @@ static void PROPSHEET_SetTitleA(HWND hwndDlg, DWORD dwStyle, LPCSTR lpszText) { WCHAR szTitle[256]; MultiByteToWideChar(CP_ACP, 0, lpszText, -1, - szTitle, sizeof(szTitle)); + szTitle, sizeof(szTitle)/sizeof(WCHAR)); PROPSHEET_SetTitleW(hwndDlg, dwStyle, szTitle); } else diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index ee7e73e4335..2b62dfc42ee 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -6483,23 +6483,24 @@ static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnm TRACE("TBN_GETINFOTIPA - got string %s\n", debugstr_a(tbgit.pszText)); - len = -1 + MultiByteToWideChar(CP_ACP, 0, tbgit.pszText, -1, NULL, 0); - if (len > sizeof(lpnmtdi->szText)/sizeof(lpnmtdi->szText[0])-1) + len = MultiByteToWideChar(CP_ACP, 0, tbgit.pszText, -1, NULL, 0); + if (len > sizeof(lpnmtdi->szText)/sizeof(lpnmtdi->szText[0])) { /* need to allocate temporary buffer in infoPtr as there * isn't enough space in buffer passed to us by the * tooltip control */ - infoPtr->pszTooltipText = Alloc((len+1)*sizeof(WCHAR)); + infoPtr->pszTooltipText = Alloc(len*sizeof(WCHAR)); if (infoPtr->pszTooltipText) { - MultiByteToWideChar(CP_ACP, 0, tbgit.pszText, len+1, infoPtr->pszTooltipText, (len+1)*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, tbgit.pszText, -1, infoPtr->pszTooltipText, len); lpnmtdi->lpszText = infoPtr->pszTooltipText; return 0; } } else if (len > 0) { - MultiByteToWideChar(CP_ACP, 0, tbgit.pszText, len+1, lpnmtdi->lpszText, (len+1)*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, tbgit.pszText, -1, + lpnmtdi->lpszText, sizeof(lpnmtdi->szText)/sizeof(lpnmtdi->szText[0])); return 0; } } diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c index d397afd3e97..e6cd167bd2f 100644 --- a/dlls/comctl32/treeview.c +++ b/dlls/comctl32/treeview.c @@ -775,8 +775,8 @@ TREEVIEW_UpdateDispInfo(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, wineItem->pszText = newText; MultiByteToWideChar( CP_ACP, 0, (LPSTR)callback.item.pszText, -1, - wineItem->pszText, buflen); - wineItem->cchTextMax = buflen; + wineItem->pszText, buflen/sizeof(WCHAR)); + wineItem->cchTextMax = buflen/sizeof(WCHAR); } /* If ReAlloc fails we have nothing to do, but keep original text */ } @@ -818,8 +818,8 @@ TREEVIEW_UpdateDispInfo(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, wineItem->pszText = newText; MultiByteToWideChar( CP_ACP, 0, (LPSTR)callback.item.pszText, -1, - wineItem->pszText, buflen); - wineItem->cchTextMax = buflen; + wineItem->pszText, buflen/sizeof(WCHAR)); + wineItem->cchTextMax = buflen/sizeof(WCHAR); if (oldText) Free(oldText); } diff --git a/dlls/dbghelp/minidump.c b/dlls/dbghelp/minidump.c index 315f1763a94..a21e6d87bab 100644 --- a/dlls/dbghelp/minidump.c +++ b/dlls/dbghelp/minidump.c @@ -407,7 +407,7 @@ static void dump_modules(struct dump_context* dc, BOOL dump_elf) if (sizeof(ULONG) + ms->Length > sizeof(tmp)) FIXME("Buffer overflow!!!\n"); MultiByteToWideChar(CP_ACP, 0, dc->module[i].name, -1, - ms->Buffer, ms->Length); + ms->Buffer, ms->Length/sizeof(WCHAR)); if (dc->cb) { diff --git a/dlls/dinput/effect_linuxinput.c b/dlls/dinput/effect_linuxinput.c index e0e5986dd75..d86b0aca4bf 100644 --- a/dlls/dinput/effect_linuxinput.c +++ b/dlls/dinput/effect_linuxinput.c @@ -903,7 +903,7 @@ HRESULT linuxinput_get_info_W( /* yes, this is windows behavior (print the GUID_Name for name) */ MultiByteToWideChar(CP_ACP, 0, _dump_dinput_GUID(rguid), -1, - (WCHAR*)&(info->tszName), sizeof(WCHAR) * MAX_PATH); + (WCHAR*)&(info->tszName), MAX_PATH); return DI_OK; } diff --git a/dlls/dsound/propset.c b/dlls/dsound/propset.c index bd0773cfdc5..8147f97eee6 100644 --- a/dlls/dsound/propset.c +++ b/dlls/dsound/propset.c @@ -1088,8 +1088,8 @@ static HRESULT WINAPI DSPROPERTY_Enumerate1( lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA)); lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA)); - MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW) ); - MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW) ); + MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW)/sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW)/sizeof(WCHAR) ); data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED; err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0)); @@ -1115,8 +1115,8 @@ static HRESULT WINAPI DSPROPERTY_Enumerate1( lstrcpynA(data.DescriptionA, desc.szDesc, sizeof(data.DescriptionA)); lstrcpynA(data.ModuleA, desc.szDrvname, sizeof(data.ModuleA)); - MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW) ); - MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW) ); + MultiByteToWideChar( CP_ACP, 0, data.DescriptionA, -1, data.DescriptionW, sizeof(data.DescriptionW)/sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, data.ModuleA, -1, data.ModuleW, sizeof(data.ModuleW)/sizeof(WCHAR) ); data.Type = DIRECTSOUNDDEVICE_TYPE_EMULATED; err = mmErr(waveInMessage((HWAVEIN)wid, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&drv, 0)); diff --git a/dlls/gdi/freetype.c b/dlls/gdi/freetype.c index 779aab21749..a0b32a2f9fc 100644 --- a/dlls/gdi/freetype.c +++ b/dlls/gdi/freetype.c @@ -848,7 +848,7 @@ static void LoadReplaceList(void) &dlen) == ERROR_SUCCESS) { TRACE("Got %s=%s\n", debugstr_a(value), debugstr_a(data)); /* "NewName"="Oldname" */ - if(!MultiByteToWideChar(CP_ACP, 0, data, -1, old_nameW, sizeof(old_nameW))) + if(!MultiByteToWideChar(CP_ACP, 0, data, -1, old_nameW, sizeof(old_nameW)/sizeof(WCHAR))) break; /* Find the old family and hence all of the font files @@ -3075,7 +3075,7 @@ UINT WineEngGetOutlineTextMetrics(GdiFont font, UINT cbSize, * sizeof(WCHAR); style_nameW = HeapAlloc(GetProcessHeap(), 0, lensty); MultiByteToWideChar(CP_ACP, 0, ft_face->style_name, -1, - style_nameW, lensty); + style_nameW, lensty/sizeof(WCHAR)); /* These names should be read from the TT name table */ diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c index 0a2aa55748a..fa1fd77558d 100644 --- a/dlls/oleaut32/tests/vartest.c +++ b/dlls/oleaut32/tests/vartest.c @@ -625,7 +625,7 @@ static HRESULT (WINAPI *pVarParseNumFromStr)(OLECHAR*,LCID,ULONG,NUMPARSE*,BYTE* /* Macros for converting and testing the result of VarParseNumFromStr */ #define FAILDIG 255 -#define CONVERTN(str,dig,flags) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)); \ +#define CONVERTN(str,dig,flags) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \ memset(rgb, FAILDIG, sizeof(rgb)); memset(&np,-1,sizeof(np)); np.cDig = dig; np.dwInFlags = flags; \ hres = pVarParseNumFromStr(buff,lcid,LOCALE_NOUSEROVERRIDE,&np,rgb) #define CONVERT(str,flags) CONVERTN(str,sizeof(rgb),flags) diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c index 07313504d85..7c3a4977738 100644 --- a/dlls/oleaut32/tests/vartype.c +++ b/dlls/oleaut32/tests/vartype.c @@ -121,7 +121,7 @@ static HMODULE hOleaut32; #define CONVERT_STR(func,str,flags) \ SetLastError(0); \ - if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)); \ + if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \ hres = p##func(str ? buff : NULL,in,flags,&out) #define COPYTEST(val, vt, srcval, dstval, srcref, dstref, fs) do { \ @@ -3249,7 +3249,7 @@ static void test_VarDateFromDec(void) #define DFS(str) \ buff[0] = '\0'; out = 0.0; \ - if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)); \ + if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \ hres = pVarDateFromStr(str ? buff : NULL,lcid,LOCALE_NOUSEROVERRIDE,&out) #define MKRELDATE(day,mth) st.wMonth = mth; st.wDay = day; \ diff --git a/dlls/riched20/reader.c b/dlls/riched20/reader.c index 25805c21111..6339680b0c5 100644 --- a/dlls/riched20/reader.c +++ b/dlls/riched20/reader.c @@ -2755,7 +2755,7 @@ RTFFlushCPOutputBuffer(RTF_Info *info) int length; length = MultiByteToWideChar(info->codePage, 0, info->cpOutputBuffer, - info->dwCPOutputCount, buffer, bufferMax); + info->dwCPOutputCount, buffer, bufferMax/sizeof(WCHAR)); info->dwCPOutputCount = 0; RTFPutUnicodeString(info, buffer, length); diff --git a/dlls/riched20/style.c b/dlls/riched20/style.c index 3cc543a3b9e..1d06154adfc 100644 --- a/dlls/riched20/style.c +++ b/dlls/riched20/style.c @@ -52,7 +52,7 @@ CHARFORMAT2W *ME_ToCF2W(CHARFORMAT2W *to, CHARFORMAT2W *from) CopyMemory(to, f, sizeof(CHARFORMATA)-sizeof(f->szFaceName)); /* convert face name */ if (f->dwMask & CFM_FACE) - MultiByteToWideChar(0, 0, f->szFaceName, -1, to->szFaceName, sizeof(to->szFaceName)); + MultiByteToWideChar(0, 0, f->szFaceName, -1, to->szFaceName, sizeof(to->szFaceName)/sizeof(WCHAR)); /* copy the rest of the 2A structure to 2W */ CopyMemory(1+((CHARFORMATW *)to), f+1, sizeof(CHARFORMAT2A)-sizeof(CHARFORMATA)); to->cbSize = sizeof(CHARFORMAT2W); diff --git a/dlls/secur32/thunks.c b/dlls/secur32/thunks.c index 29092e8c49d..4bcd7bdfc2f 100644 --- a/dlls/secur32/thunks.c +++ b/dlls/secur32/thunks.c @@ -620,7 +620,7 @@ static PSecPkgInfoW _copyPackageInfoFlatAToW(PSecPkgInfoA infoA) { ret->Comment = nextString; MultiByteToWideChar(CP_ACP, 0, infoA->Comment, -1, nextString, - nameLen); + commentLen); } else ret->Comment = NULL; diff --git a/dlls/setupapi/parser.c b/dlls/setupapi/parser.c index a098230bade..925cee750bc 100644 --- a/dlls/setupapi/parser.c +++ b/dlls/setupapi/parser.c @@ -951,8 +951,7 @@ static struct inf_file *parse_file( HANDLE handle, const WCHAR *class, UINT *err WCHAR *new_buff = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ); if (new_buff) { - DWORD len = MultiByteToWideChar( CP_ACP, 0, buffer, size, new_buff, - size * sizeof(WCHAR) ); + DWORD len = MultiByteToWideChar( CP_ACP, 0, buffer, size, new_buff, size ); err = parse_buffer( file, new_buff, new_buff + len, error_line ); HeapFree( GetProcessHeap(), 0, new_buff ); } diff --git a/dlls/shlwapi/reg.c b/dlls/shlwapi/reg.c index ea3b73c96d8..0cabaa4b9a6 100644 --- a/dlls/shlwapi/reg.c +++ b/dlls/shlwapi/reg.c @@ -134,7 +134,7 @@ LONG WINAPI SHRegOpenUSKeyW(LPCWSTR Path, REGSAM AccessType, HUSKEY hRelativeUSK /* Create internal HUSKEY */ hKey = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*hKey)); - lstrcpynW(hKey->lpszPath, Path, sizeof(hKey->lpszPath)); + lstrcpynW(hKey->lpszPath, Path, sizeof(hKey->lpszPath)/sizeof(WCHAR)); if (hRelativeUSKey) { diff --git a/dlls/shlwapi/string.c b/dlls/shlwapi/string.c index 69db4c5db85..1ff9d815030 100644 --- a/dlls/shlwapi/string.c +++ b/dlls/shlwapi/string.c @@ -1810,7 +1810,7 @@ HRESULT WINAPI SHStrDupA(LPCSTR lpszStr, LPWSTR * lppszDest) if (*lppszDest) { - MultiByteToWideChar(0, 0, lpszStr, -1, *lppszDest, len); + MultiByteToWideChar(0, 0, lpszStr, -1, *lppszDest, len/sizeof(WCHAR)); hRet = S_OK; } else diff --git a/dlls/winmm/message16.c b/dlls/winmm/message16.c index 5a00851256d..3300103bef0 100644 --- a/dlls/winmm/message16.c +++ b/dlls/winmm/message16.c @@ -3452,7 +3452,7 @@ static WINMM_MapType MCI_UnMapMsg32WTo16(WORD uDevType, WORD wMsg, DWORD dwFlag UnMapLS( lParam ); if (msip16) { MultiByteToWideChar(CP_ACP, 0, MapSL(msip16->lpstrReturn), msip16->dwRetSize, - msip32w->lpstrReturn, msip32w->dwRetSize); + msip32w->lpstrReturn, msip32w->dwRetSize/sizeof(WCHAR)); UnMapLS( msip16->lpstrReturn ); HeapFree( GetProcessHeap(), 0, MapSL(msip16->lpstrReturn) ); HeapFree( GetProcessHeap(), 0, (char*)msip16 - sizeof(LPMCI_SYSINFO_PARMSW) ); diff --git a/dlls/winmm/winmm.c b/dlls/winmm/winmm.c index fdaa870a953..6877294078c 100644 --- a/dlls/winmm/winmm.c +++ b/dlls/winmm/winmm.c @@ -603,7 +603,7 @@ UINT WINAPI mixerGetLineInfoA(HMIXEROBJ hmix, LPMIXERLINEA lpmliA, mliW.Target.wMid = lpmliA->Target.wMid; mliW.Target.wPid = lpmliA->Target.wPid; mliW.Target.vDriverVersion = lpmliA->Target.vDriverVersion; - MultiByteToWideChar( CP_ACP, 0, lpmliA->Target.szPname, -1, mliW.Target.szPname, sizeof(mliW.Target.szPname)); + MultiByteToWideChar( CP_ACP, 0, lpmliA->Target.szPname, -1, mliW.Target.szPname, sizeof(mliW.Target.szPname)/sizeof(WCHAR)); break; default: WARN("Unsupported fdwControls=0x%08lx\n", fdwInfo); diff --git a/dlls/winsock/socket.c b/dlls/winsock/socket.c index 922ea03ef36..72e7c8a7a15 100644 --- a/dlls/winsock/socket.c +++ b/dlls/winsock/socket.c @@ -3082,7 +3082,7 @@ SOCKET WINAPI WSASocketA(int af, int type, int protocol, memcpy(&info, lpProtocolInfo, FIELD_OFFSET(WSAPROTOCOL_INFOW, szProtocol)); len = MultiByteToWideChar(CP_ACP, 0, lpProtocolInfo->szProtocol, -1, - info.szProtocol, WSAPROTOCOL_LEN * sizeof(WCHAR) + 1); + info.szProtocol, WSAPROTOCOL_LEN + 1); if (!len) { diff --git a/dlls/x11drv/xim.c b/dlls/x11drv/xim.c index 10140ac3b2e..ca26fabf078 100644 --- a/dlls/x11drv/xim.c +++ b/dlls/x11drv/xim.c @@ -224,7 +224,7 @@ void X11DRV_XIMLookupChars( const char *str, DWORD count ) WCHAR wcOutput[64]; HWND focus; - dwOutput = MultiByteToWideChar(CP_UNIXCP, 0, str, count, wcOutput, sizeof(wcOutput)); + dwOutput = MultiByteToWideChar(CP_UNIXCP, 0, str, count, wcOutput, sizeof(wcOutput)/sizeof(WCHAR)); if (pImmAssociateContext && (focus = GetFocus())) pImmAssociateContext(focus,root_context); diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index b883a431854..4adb3cf2ef2 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -994,7 +994,7 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show { WCHAR link[MAX_PATH]; - MultiByteToWideChar( CP_ACP, 0, token, -1, link, sizeof(link) ); + MultiByteToWideChar( CP_ACP, 0, token, -1, link, sizeof(link)/sizeof(WCHAR) ); if( !Process_Link( link, bAgain ) ) { WINE_ERR( "failed to build menu item for %s\n",token);