diff --git a/controls/menu.c b/controls/menu.c index d3b303637e3..0b10c9a3323 100644 --- a/controls/menu.c +++ b/controls/menu.c @@ -18,10 +18,11 @@ #include #include "windef.h" +#include "winnls.h" #include "wingdi.h" #include "wine/winbase16.h" #include "wine/winuser16.h" -#include "wine/winestring.h" +#include "wine/unicode.h" #include "win.h" #include "task.h" #include "heap.h" @@ -31,7 +32,6 @@ #include "message.h" #include "queue.h" #include "tweak.h" -#include "wine/unicode.h" #include "debugtools.h" @@ -3464,7 +3464,8 @@ INT WINAPI GetMenuStringA( if (!IS_STRING_ITEM(item->fType)) return 0; if (!str || !nMaxSiz) return strlenW(item->text); str[0] = '\0'; - lstrcpynWtoA( str, item->text, nMaxSiz ); + if (!WideCharToMultiByte( CP_ACP, 0, item->text, -1, str, nMaxSiz, NULL, NULL )) + str[nMaxSiz-1] = 0; TRACE("returning '%s'\n", str ); return strlen(str); } @@ -4405,21 +4406,7 @@ static BOOL GetMenuItemInfo_common ( HMENU hmenu, UINT item, BOOL bypos, lpmii->fType = menu->fType; switch (MENU_ITEM_TYPE(menu->fType)) { case MF_STRING: - if (menu->text) { - int len = strlenW(menu->text); - if(lpmii->dwTypeData && lpmii->cch) { - if (unicode) - lstrcpynW(lpmii->dwTypeData, menu->text, - lpmii->cch); - else - lstrcpynWtoA((LPSTR)lpmii->dwTypeData, menu->text, lpmii->cch); - /* if we've copied a substring we return its length */ - if(lpmii->cch <= len) - lpmii->cch--; - } else /* return length of string */ - lpmii->cch = len; - } - break; + break; /* will be done below */ case MF_OWNERDRAW: case MF_BITMAP: lpmii->dwTypeData = menu->text; @@ -4429,15 +4416,32 @@ static BOOL GetMenuItemInfo_common ( HMENU hmenu, UINT item, BOOL bypos, } } - if (lpmii->fMask & MIIM_STRING) { - if(lpmii->dwTypeData && lpmii->cch) { - if (unicode) - lstrcpynW((LPWSTR) lpmii->dwTypeData, menu->text, - lpmii->cch); - else - lstrcpynWtoA((LPSTR)lpmii->dwTypeData, menu->text, lpmii->cch); - } - lpmii->cch = strlenW(menu->text); + /* copy the text string */ + if ((lpmii->fMask & (MIIM_TYPE|MIIM_STRING)) && + (MENU_ITEM_TYPE(menu->fType) == MF_STRING) && menu->text) + { + int len; + if (unicode) + { + len = strlenW(menu->text); + if(lpmii->dwTypeData && lpmii->cch) + lstrcpynW(lpmii->dwTypeData, menu->text, lpmii->cch); + } + else + { + len = WideCharToMultiByte( CP_ACP, 0, menu->text, -1, NULL, 0, NULL, NULL ); + if(lpmii->dwTypeData && lpmii->cch) + if (!WideCharToMultiByte( CP_ACP, 0, menu->text, -1, + (LPSTR)lpmii->dwTypeData, lpmii->cch, NULL, NULL )) + ((LPSTR)lpmii->dwTypeData)[lpmii->cch-1] = 0; + } + /* if we've copied a substring we return its length */ + if(lpmii->dwTypeData && lpmii->cch) + { + if (lpmii->cch <= len) lpmii->cch--; + } + else /* return length of string */ + lpmii->cch = len; } if (lpmii->fMask & MIIM_FTYPE) diff --git a/dlls/advapi32/advapi.c b/dlls/advapi32/advapi.c index 20c2f788a80..12ab139593f 100644 --- a/dlls/advapi32/advapi.c +++ b/dlls/advapi32/advapi.c @@ -11,8 +11,8 @@ #include "winbase.h" #include "windef.h" +#include "winnls.h" #include "winerror.h" -#include "wine/winestring.h" #include "debugtools.h" @@ -53,7 +53,9 @@ GetUserNameW( LPWSTR lpszName, LPDWORD lpSize ) DWORD size = *lpSize; BOOL res = GetUserNameA(name,lpSize); - lstrcpynAtoW(lpszName,name,size); + /* FIXME: should set lpSize in WCHARs */ + if (size && !MultiByteToWideChar( CP_ACP, 0, name, -1, lpszName, size )) + lpszName[size-1] = 0; HeapFree( GetProcessHeap(), 0, name ); return res; } diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c index 5018e83d099..6cc1023ab39 100644 --- a/dlls/advapi32/registry.c +++ b/dlls/advapi32/registry.c @@ -21,7 +21,6 @@ #include "winerror.h" #include "wine/winbase16.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "heap.h" #include "server.h" #include "debugtools.h" diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c index 8e25aba4829..4086f8c0110 100644 --- a/dlls/advapi32/security.c +++ b/dlls/advapi32/security.c @@ -6,7 +6,6 @@ #include "windef.h" #include "winerror.h" -#include "wine/winestring.h" #include "heap.h" #include "ntddk.h" #include "ntsecapi.h" @@ -569,8 +568,8 @@ LookupAccountSidA( IN OUT LPDWORD domainSize, OUT PSID_NAME_USE name_use ) { - char * ac = "Administrator"; - char * dm = "DOMAIN"; + static const char ac[] = "Administrator"; + static const char dm[] = "DOMAIN"; FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n", debugstr_a(system),sid, account,accountSize,accountSize?*accountSize:0, @@ -611,21 +610,21 @@ LookupAccountSidW( IN OUT LPDWORD domainSize, OUT PSID_NAME_USE name_use ) { - char * ac = "Administrator"; - char * dm = "DOMAIN"; + static const WCHAR ac[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r',0}; + static const WCHAR dm[] = {'D','O','M','A','I','N',0}; FIXME("(%s,sid=%p,%p,%p(%lu),%p,%p(%lu),%p): semi-stub\n", debugstr_w(system),sid, account,accountSize,accountSize?*accountSize:0, domain,domainSize,domainSize?*domainSize:0, name_use); - if (accountSize) *accountSize = strlen(ac)+1; - if (account && (*accountSize > strlen(ac))) - lstrcpyAtoW(account, ac); + if (accountSize) *accountSize = strlenW(ac)+1; + if (account && (*accountSize > strlenW(ac))) + strcpyW(account, ac); - if (domainSize) *domainSize = strlen(dm)+1; - if (domain && (*domainSize > strlen(dm))) - lstrcpyAtoW(domain,dm); + if (domainSize) *domainSize = strlenW(dm)+1; + if (domain && (*domainSize > strlenW(dm))) + strcpyW(domain,dm); if (name_use) *name_use = SidTypeUser; return TRUE; diff --git a/dlls/advapi32/service.c b/dlls/advapi32/service.c index ecb425fd546..38adf80e7f4 100644 --- a/dlls/advapi32/service.c +++ b/dlls/advapi32/service.c @@ -11,7 +11,6 @@ #include "winerror.h" #include "winreg.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "heap.h" #include "debugtools.h" @@ -353,7 +352,7 @@ OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, TRACE("(%d,%p,%ld)\n",hSCManager, lpServiceName, dwDesiredAccess); - lstrcpyAtoW(lpServiceKey,str); + MultiByteToWideChar( CP_ACP, 0, str, -1, lpServiceKey, sizeof(lpServiceKey)/sizeof(WCHAR) ); strcatW(lpServiceKey,lpServiceName); TRACE("Opening reg key %s\n", debugstr_w(lpServiceKey)); diff --git a/dlls/comctl32/comboex.c b/dlls/comctl32/comboex.c index c6ad4a2d54a..335e059765e 100644 --- a/dlls/comctl32/comboex.c +++ b/dlls/comctl32/comboex.c @@ -35,7 +35,6 @@ */ #include "winbase.h" -#include "wine/winestring.h" #include "commctrl.h" #include "debugtools.h" #include "wine/unicode.h" diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c index a4a3a7a3fcb..687af87054b 100644 --- a/dlls/comctl32/datetime.c +++ b/dlls/comctl32/datetime.c @@ -18,7 +18,6 @@ #include "winbase.h" #include "wingdi.h" -#include "wine/winestring.h" #include "commctrl.h" #include "debugtools.h" @@ -307,10 +306,10 @@ DATETIME_SetFormatW (HWND hwnd, WPARAM wParam, LPARAM lParam) if (lParam) { LPSTR buf; int retval; - int len = lstrlenW ((LPWSTR) lParam)+1; + int len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, NULL, 0, NULL, NULL ); buf = (LPSTR) COMCTL32_Alloc (len); - lstrcpyWtoA (buf, (LPWSTR) lParam); + WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, buf, len, NULL, NULL ); retval=DATETIME_SetFormat (hwnd, 0, (LPARAM) buf); COMCTL32_Free (buf); return retval; diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c index 3ec3b751870..2b0e02fcb9d 100644 --- a/dlls/comctl32/header.c +++ b/dlls/comctl32/header.c @@ -21,7 +21,6 @@ #include "winbase.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "commctrl.h" #include "comctl32.h" #include "imagelist.h" diff --git a/dlls/comctl32/rebar.c b/dlls/comctl32/rebar.c index e4ff860938f..98588324070 100644 --- a/dlls/comctl32/rebar.c +++ b/dlls/comctl32/rebar.c @@ -44,7 +44,6 @@ #include "winbase.h" #include "wingdi.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "commctrl.h" #include "debugtools.h" @@ -1567,7 +1566,11 @@ REBAR_GetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam) if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) { if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT)) - lstrcpynWtoA (lprbbi->lpText, lpBand->lpText, lprbbi->cch); + { + if (!WideCharToMultiByte( CP_ACP, 0, lpBand->lpText, -1, + lprbbi->lpText, lprbbi->cch, NULL, NULL )) + lprbbi->lpText[lprbbi->cch-1] = 0; + } else *lprbbi->lpText = 0; } @@ -1958,10 +1961,10 @@ REBAR_InsertBandA (HWND hwnd, WPARAM wParam, LPARAM lParam) REBAR_CommonSetupBand (hwnd, lprbbi, lpBand); lpBand->lpText = NULL; if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) { - INT len = lstrlenA (lprbbi->lpText); - if (len > 0) { - lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); - lstrcpyAtoW (lpBand->lpText, lprbbi->lpText); + INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 ); + if (len > 1) { + lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR)); + MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len ); } } @@ -2121,9 +2124,9 @@ REBAR_SetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam) lpBand->lpText = NULL; } if (lprbbi->lpText) { - INT len = lstrlenA (lprbbi->lpText); - lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); - lstrcpyAtoW (lpBand->lpText, lprbbi->lpText); + INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 ); + lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR)); + MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len ); } } diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c index 7cb27f023f2..a11b0146ee2 100644 --- a/dlls/comctl32/status.c +++ b/dlls/comctl32/status.c @@ -12,7 +12,6 @@ #include "winbase.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "commctrl.h" #include "debugtools.h" @@ -136,7 +135,7 @@ STATUSBAR_DrawPart (HDC hdc, STATUSWINDOWPART *part) } } r.left += 3; - DrawTextW (hdc, p, lstrlenW (p), &r, align|DT_VCENTER|DT_SINGLELINE); + DrawTextW (hdc, p, -1, &r, align|DT_VCENTER|DT_SINGLELINE); if (oldbkmode != TRANSPARENT) SetBkMode(hdc, oldbkmode); } @@ -393,10 +392,11 @@ STATUSBAR_GetTextA (HWND hwnd, WPARAM wParam, LPARAM lParam) if (part->style & SBT_OWNERDRAW) result = (LRESULT)part->text; else { - result = part->text ? lstrlenW (part->text) : 0; - result |= (part->style << 16); - if (lParam && LOWORD(result)) - lstrcpyWtoA ((LPSTR)lParam, part->text); + DWORD len = part->text ? WideCharToMultiByte( CP_ACP, 0, part->text, -1, + NULL, 0, NULL, NULL ) - 1 : 0; + result = MAKELONG( len, part->style ); + if (lParam && len) + WideCharToMultiByte( CP_ACP, 0, part->text, -1, (LPSTR)lParam, len+1, NULL, NULL ); } return result; } @@ -419,7 +419,7 @@ STATUSBAR_GetTextW (HWND hwnd, WPARAM wParam, LPARAM lParam) if (part->style & SBT_OWNERDRAW) result = (LRESULT)part->text; else { - result = part->text ? lstrlenW (part->text) : 0; + result = part->text ? strlenW (part->text) : 0; result |= (part->style << 16); if (part->text && lParam) strcpyW ((LPWSTR)lParam, part->text); @@ -444,7 +444,7 @@ STATUSBAR_GetTextLength (HWND hwnd, WPARAM wParam) part = &infoPtr->parts[part_num]; if (part->text) - result = lstrlenW(part->text); + result = strlenW(part->text); else result = 0; @@ -689,8 +689,9 @@ STATUSBAR_SetTextA (HWND hwnd, WPARAM wParam, LPARAM lParam) /* check if text is unchanged -> no need to redraw */ if (text) { - LPWSTR tmptext = COMCTL32_Alloc((lstrlenA(text)+1)*sizeof(WCHAR)); - lstrcpyAtoW (tmptext, text); + DWORD len = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 ); + LPWSTR tmptext = COMCTL32_Alloc(len*sizeof(WCHAR)); + MultiByteToWideChar( CP_ACP, 0, text, -1, tmptext, len ); if (!changed && part->text && !lstrcmpW(tmptext,part->text)) { COMCTL32_Free(tmptext); @@ -754,7 +755,7 @@ STATUSBAR_SetTextW (HWND hwnd, WPARAM wParam, LPARAM lParam) { if(part->text) COMCTL32_Free(part->text); - len = lstrlenW(text); + len = strlenW(text); part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); strcpyW(part->text, text); bRedraw = TRUE; @@ -886,16 +887,18 @@ STATUSBAR_WMCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) if (IsWindowUnicode (hwnd)) { self->bUnicode = TRUE; if (lpCreate->lpszName && - (len = lstrlenW ((LPCWSTR)lpCreate->lpszName))) { + (len = strlenW ((LPCWSTR)lpCreate->lpszName))) { self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); strcpyW (self->parts[0].text, (LPCWSTR)lpCreate->lpszName); } } else { if (lpCreate->lpszName && - (len = lstrlenA ((LPCSTR)lpCreate->lpszName))) { - self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); - lstrcpyAtoW (self->parts[0].text, (LPCSTR)lpCreate->lpszName); + (len = strlen((LPCSTR)lpCreate->lpszName))) { + DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1, NULL, 0 ); + self->parts[0].text = COMCTL32_Alloc (lenW*sizeof(WCHAR)); + MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1, + self->parts[0].text, lenW ); } } @@ -993,12 +996,17 @@ STATUSBAR_WMGetText (HWND hwnd, WPARAM wParam, LPARAM lParam) if (!(infoPtr->parts[0].text)) return 0; - len = lstrlenW (infoPtr->parts[0].text); + if (infoPtr->bUnicode) + len = strlenW (infoPtr->parts[0].text); + else + len = WideCharToMultiByte( CP_ACP, 0, infoPtr->parts[0].text, -1, NULL, 0, NULL, NULL )-1; + if (wParam > len) { if (infoPtr->bUnicode) strcpyW ((LPWSTR)lParam, infoPtr->parts[0].text); else - lstrcpyWtoA ((LPSTR)lParam, infoPtr->parts[0].text); + WideCharToMultiByte( CP_ACP, 0, infoPtr->parts[0].text, -1, + (LPSTR)lParam, len+1, NULL, NULL ); return len; } @@ -1102,15 +1110,16 @@ STATUSBAR_WMSetText (HWND hwnd, WPARAM wParam, LPARAM lParam) COMCTL32_Free (part->text); part->text = 0; if (infoPtr->bUnicode) { - if (lParam && (len = lstrlenW((LPCWSTR)lParam))) { + if (lParam && (len = strlenW((LPCWSTR)lParam))) { part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); strcpyW (part->text, (LPCWSTR)lParam); } } else { if (lParam && (len = lstrlenA((LPCSTR)lParam))) { - part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); - lstrcpyAtoW (part->text, (LPCSTR)lParam); + DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lParam, -1, NULL, 0 ); + part->text = COMCTL32_Alloc (lenW*sizeof(WCHAR)); + MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lParam, -1, part->text, lenW ); } } diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 56b411fa0cb..63ba122a23f 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -42,7 +42,6 @@ #include "wingdi.h" #include "winuser.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "commctrl.h" #include "imagelist.h" #include "comctl32.h" @@ -532,7 +531,7 @@ TOOLBAR_MeasureString(HWND hwnd, INT index, LPSIZE lpSize) (btnPtr->iString < infoPtr->nNumStrings)) { LPWSTR lpText = infoPtr->strings[btnPtr->iString]; - GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), lpSize); + GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize); } SelectObject (hdc, hOldFont); @@ -1792,7 +1791,7 @@ TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam) if ((wParam) && (HIWORD(lParam) == 0)) { char szString[256]; - INT len; + INT len, lenW; TRACE("adding string from resource!\n"); len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam, @@ -1813,14 +1812,15 @@ TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam) COMCTL32_Free (oldStrings); } - infoPtr->strings[infoPtr->nNumStrings] = - COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); - lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString); + lenW = MultiByteToWideChar( CP_ACP, 0, szString, -1, NULL, 0 ); + infoPtr->strings[infoPtr->nNumStrings] = COMCTL32_Alloc (sizeof(WCHAR)*lenW); + MultiByteToWideChar( CP_ACP, 0, szString, -1, + infoPtr->strings[infoPtr->nNumStrings], lenW ); infoPtr->nNumStrings++; } else { LPSTR p = (LPSTR)lParam; - INT len; + INT len, lenW; if (p == NULL) return -1; @@ -1828,7 +1828,7 @@ TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam) nIndex = infoPtr->nNumStrings; while (*p) { - len = lstrlenA (p); + len = strlen (p); TRACE("len=%d \"%s\"\n", len, p); if (infoPtr->nNumStrings == 0) { @@ -1844,9 +1844,10 @@ TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam) COMCTL32_Free (oldStrings); } - infoPtr->strings[infoPtr->nNumStrings] = - COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); - lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p); + lenW = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 ); + infoPtr->strings[infoPtr->nNumStrings] = COMCTL32_Alloc (sizeof(WCHAR)*lenW); + MultiByteToWideChar( CP_ACP, 0, p, -1, + infoPtr->strings[infoPtr->nNumStrings], lenW ); infoPtr->nNumStrings++; p += (len+1); @@ -1935,7 +1936,7 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam) TRACE("adding string(s) from array!\n"); nIndex = infoPtr->nNumStrings; while (*p) { - len = lstrlenW (p); + len = strlenW (p); TRACE("len=%d \"%s\"\n", len, debugstr_w(p)); if (infoPtr->nNumStrings == 0) { @@ -2360,9 +2361,9 @@ TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam) if (lpTbInfo->dwMask & TBIF_TEXT) { if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) { - lstrcpynWtoA (lpTbInfo->pszText, - (LPWSTR)infoPtr->strings[btnPtr->iString], - lpTbInfo->cchText); + if (!WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[btnPtr->iString], -1, + lpTbInfo->pszText, lpTbInfo->cchText, NULL, NULL )) + lpTbInfo->pszText[lpTbInfo->cchText-1] = 0; } else lpTbInfo->pszText[0]=0; } @@ -2444,9 +2445,8 @@ TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam) if (lParam == 0) return -1; - lstrcpyWtoA ((LPSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]); - - return lstrlenW ((LPWSTR)infoPtr->strings[nStringIndex]); + return WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[nStringIndex], -1, + (LPSTR)lParam, 0x7fffffff, NULL, NULL ) - 1; } @@ -2472,7 +2472,7 @@ TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam) strcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]); - return lstrlenW ((LPWSTR)infoPtr->strings[nStringIndex]); + return strlenW ((LPWSTR)infoPtr->strings[nStringIndex]); } @@ -2775,7 +2775,7 @@ TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam) LPSTR ptr; if(lpTbb->iString) { - len = lstrlenA((char*)lpTbb->iString) + 2; + len = strlen((char*)lpTbb->iString) + 2; ptr = COMCTL32_Alloc(len); nIndex = infoPtr->nNumButtons; strcpy(ptr, (char*)lpTbb->iString); diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c index a2b4d3fabb6..f13d04ab6b2 100644 --- a/dlls/comctl32/treeview.c +++ b/dlls/comctl32/treeview.c @@ -31,7 +31,6 @@ #include "winbase.h" #include "wingdi.h" -#include "wine/winestring.h" #include "commctrl.h" #include "comctl32.h" #include "debugtools.h" @@ -1210,11 +1209,11 @@ TREEVIEW_InsertItemW(TREEVIEW_INFO *infoPtr, LPARAM lParam) { if (tvisW->DUMMYUNIONNAME.item.pszText != LPSTR_TEXTCALLBACKW) { - int len = lstrlenW(tvisW->DUMMYUNIONNAME.item.pszText) + 1; - + int len = WideCharToMultiByte( CP_ACP, 0, tvisW->DUMMYUNIONNAME.item.pszText, -1, + NULL, 0, NULL, NULL ); tvisA.DUMMYUNIONNAME.item.pszText = COMCTL32_Alloc(len); - lstrcpyWtoA(tvisA.DUMMYUNIONNAME.item.pszText, - tvisW->DUMMYUNIONNAME.item.pszText); + WideCharToMultiByte( CP_ACP, 0, tvisW->DUMMYUNIONNAME.item.pszText, -1, + tvisA.DUMMYUNIONNAME.item.pszText, len, NULL, NULL ); } else { diff --git a/dlls/commdlg/filedlg.c b/dlls/commdlg/filedlg.c index c7208dd25cb..bd14d16dfdb 100644 --- a/dlls/commdlg/filedlg.c +++ b/dlls/commdlg/filedlg.c @@ -9,12 +9,12 @@ #include #include #include "windef.h" +#include "winnls.h" #include "winbase.h" #include "wingdi.h" #include "wine/winbase16.h" #include "wine/winuser16.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "ldt.h" #include "heap.h" #include "commdlg.h" @@ -629,7 +629,7 @@ void FILEDLG_UpdateResult(LFSPRIVATE lfs, WCHAR *tmpstr) WCHAR tmpstr2[BUFFILE]; GetCurrentDirectoryW(BUFFILE, tmpstr2); - lenstr2 = lstrlenW(tmpstr2); + lenstr2 = strlenW(tmpstr2); if (lenstr2 > 3) tmpstr2[lenstr2++]='\\'; lstrcpynW(tmpstr2+lenstr2, tmpstr, BUFFILE-lenstr2); @@ -646,13 +646,18 @@ void FILEDLG_UpdateResult(LFSPRIVATE lfs, WCHAR *tmpstr) /* update the real client structures if any */ if (lfs->ofn16) { - lstrcpynWtoA(PTR_SEG_TO_LIN(lfs->ofn16->lpstrFile), ofnW->lpstrFile, ofnW->nMaxFile); + char *dest = PTR_SEG_TO_LIN(lfs->ofn16->lpstrFile); + if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1, + dest, ofnW->nMaxFile, NULL, NULL )) + dest[ofnW->nMaxFile-1] = 0; lfs->ofn16->nFileOffset = ofnW->nFileOffset; lfs->ofn16->nFileExtension = ofnW->nFileExtension; } if (lfs->ofnA) { - lstrcpynWtoA(lfs->ofnA->lpstrFile, ofnW->lpstrFile, ofnW->nMaxFile); + if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1, + lfs->ofnA->lpstrFile, ofnW->nMaxFile, NULL, NULL )) + lfs->ofnA->lpstrFile[ofnW->nMaxFile-1] = 0; lfs->ofnA->nFileOffset = ofnW->nFileOffset; lfs->ofnA->nFileExtension = ofnW->nFileExtension; } @@ -673,11 +678,18 @@ void FILEDLG_UpdateFileTitle(LFSPRIVATE lfs) SendDlgItemMessageW(lfs->hwnd, lst1, LB_GETTEXT, lRet, (LPARAM)ofnW->lpstrFileTitle ); if (lfs->ofn16) - lstrcpynWtoA(PTR_SEG_TO_LIN(lfs->ofn16->lpstrFileTitle),ofnW->lpstrFileTitle, - ofnW->nMaxFileTitle); + { + char *dest = PTR_SEG_TO_LIN(lfs->ofn16->lpstrFileTitle); + if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFileTitle, -1, + dest, ofnW->nMaxFileTitle, NULL, NULL )) + dest[ofnW->nMaxFileTitle-1] = 0; + } if (lfs->ofnA) - lstrcpynWtoA(lfs->ofnA->lpstrFileTitle,ofnW->lpstrFileTitle, - ofnW->nMaxFileTitle); + { + if (!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFileTitle, -1, + lfs->ofnA->lpstrFileTitle, ofnW->nMaxFileTitle, NULL, NULL )) + lfs->ofnA->lpstrFileTitle[ofnW->nMaxFileTitle-1] = 0; + } } } @@ -1017,8 +1029,8 @@ void FILEDLG_MapDrawItemStruct(LPDRAWITEMSTRUCT16 lpdis16, LPDRAWITEMSTRUCT lpdi LPWSTR FILEDLG_MapStringPairsToW(LPCSTR strA, UINT size) { LPCSTR s; - LPWSTR x, y; - int n; + LPWSTR x; + int n, len; s = strA; while (*s) @@ -1027,15 +1039,10 @@ LPWSTR FILEDLG_MapStringPairsToW(LPCSTR strA, UINT size) n = s - strA; if (n < size) n = size; - x = y = HeapAlloc(GetProcessHeap(),0, n * sizeof(WCHAR)); - s = strA; - while (*s) { - lstrcpyAtoW(x, s); - x += lstrlenW(x)+1; - s += strlen(s)+1; - } - *x = 0; - return y; + len = MultiByteToWideChar( CP_ACP, 0, strA, n, NULL, 0 ); + x = HeapAlloc(GetProcessHeap(),0, len * sizeof(WCHAR)); + MultiByteToWideChar( CP_ACP, 0, strA, n, x, len ); + return x; } @@ -1043,19 +1050,19 @@ LPWSTR FILEDLG_MapStringPairsToW(LPCSTR strA, UINT size) * FILEDLG_DupToW [internal] * duplicates an Ansi string to unicode, with a buffer size */ -LPWSTR FILEDLG_DupToW(LPCSTR str, UINT size) +LPWSTR FILEDLG_DupToW(LPCSTR str, DWORD *size) { - LPWSTR strW; - if (str && (size > 0)) + LPWSTR strW = NULL; + DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); + if (str && (len > 0)) { - strW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); - lstrcpynAtoW(strW, str, size); - return strW; + strW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + if (strW) MultiByteToWideChar( CP_ACP, 0, str, -1, strW, len ); } - else - return NULL; + if (size) *size = len; + return strW; } - + /************************************************************************ * FILEDLG_MapOfnStructA [internal] @@ -1077,10 +1084,8 @@ void FILEDLG_MapOfnStructA(LPOPENFILENAMEA ofnA, LPOPENFILENAMEW ofnW, BOOL open ofnW->lpstrCustomFilter = FILEDLG_MapStringPairsToW(ofnA->lpstrCustomFilter, ofnA->nMaxCustFilter); ofnW->nMaxCustFilter = ofnA->nMaxCustFilter; ofnW->nFilterIndex = ofnA->nFilterIndex; - ofnW->lpstrFile = FILEDLG_DupToW(ofnA->lpstrFile, ofnA->nMaxFile); - ofnW->nMaxFile = ofnA->nMaxFile; - ofnW->lpstrFileTitle = FILEDLG_DupToW(ofnA->lpstrFileTitle, ofnA->nMaxFileTitle); - ofnW->nMaxFileTitle = ofnA->nMaxFileTitle; + ofnW->lpstrFile = FILEDLG_DupToW(ofnA->lpstrFile, &ofnW->nMaxFile); + ofnW->lpstrFileTitle = FILEDLG_DupToW(ofnA->lpstrFileTitle, &ofnW->nMaxFileTitle); if (ofnA->lpstrInitialDir) ofnW->lpstrInitialDir = HEAP_strdupAtoW(GetProcessHeap(),0,ofnA->lpstrInitialDir); if (ofnA->lpstrTitle) @@ -1092,7 +1097,7 @@ void FILEDLG_MapOfnStructA(LPOPENFILENAMEA ofnA, LPOPENFILENAMEW ofnW, BOOL open ofnW->Flags = ofnA->Flags; ofnW->nFileOffset = ofnA->nFileOffset; ofnW->nFileExtension = ofnA->nFileExtension; - ofnW->lpstrDefExt = FILEDLG_DupToW(ofnA->lpstrDefExt, 3); + ofnW->lpstrDefExt = FILEDLG_DupToW(ofnA->lpstrDefExt, NULL); if ((ofnA->Flags & OFN_ENABLETEMPLATE) && (ofnA->lpTemplateName)) { if (HIWORD(ofnA->lpTemplateName)) diff --git a/dlls/commdlg/filedlg95.c b/dlls/commdlg/filedlg95.c index cb58ddda3f3..1a782532109 100644 --- a/dlls/commdlg/filedlg95.c +++ b/dlls/commdlg/filedlg95.c @@ -40,7 +40,7 @@ #include "winbase.h" #include "ntddk.h" -#include "wine/winestring.h" +#include "winnls.h" #include "ldt.h" #include "heap.h" #include "commdlg.h" @@ -49,7 +49,6 @@ #include "debugtools.h" #include "cderr.h" #include "tweak.h" -#include "winnls.h" #include "shellapi.h" #include "shlguid.h" #include "filedlgbrowser.h" @@ -336,9 +335,10 @@ BOOL WINAPI GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType) #define AllocInArgWtoA(arg, save) \ if(arg) \ { \ + DWORD _len = WideCharToMultiByte( CP_ACP, 0, arg, -1, NULL, 0, NULL, NULL ); \ save = arg; \ - arg = MemAlloc(lstrlenW(arg)); \ - lstrcpyWtoA((LPSTR)arg, save); \ + arg = MemAlloc(_len); \ + WideCharToMultiByte( CP_ACP, 0, save, -1, (LPSTR)arg, _len, NULL, NULL ); \ } #define FreeInArg(arg, save) \ @@ -359,7 +359,7 @@ BOOL WINAPI GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType) #define FreeOutArg(arg, save, len) \ if(arg) \ { \ - lstrcpynAtoW(save, (LPCSTR)arg, len); \ + MultiByteToWideChar( CP_ACP, 0, (LPCSTR)(arg), -1, (save), (len) ); \ MemFree(arg); \ arg = save; \ } @@ -396,26 +396,20 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType) if (ofn->lpstrFilter) { LPCWSTR s; - LPSTR x, y; - int n; + LPSTR y; + int n, len; lpstrFilter = ofn->lpstrFilter; /* filter is a list... title\0ext\0......\0\0 */ s = ofn->lpstrFilter; - while (*s) s = s+lstrlenW(s)+1; + while (*s) s = s+strlenW(s)+1; s++; n = s - ofn->lpstrFilter; /* already divides by 2. ptr magic */ - x = y = (LPSTR)MemAlloc(n); - s = (LPWSTR)ofn->lpstrFilter; - while (*s) - { - lstrcpyWtoA(x,s); - x+=strlen(x)+1; - s+=lstrlenW(s)+1; - } - *x=0; + len = WideCharToMultiByte( CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0, NULL, NULL ); + y = (LPSTR)MemAlloc(len); + WideCharToMultiByte( CP_ACP, 0, ofn->lpstrFilter, n, y, len, NULL, NULL ); (LPSTR)ofn->lpstrFilter = y; } @@ -423,24 +417,18 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType) if (ofn->lpstrCustomFilter) { LPWSTR s; - LPSTR x,y; - int n; + LPSTR y; + int n, len; lpstrCustomFilter = ofn->lpstrCustomFilter; /* filter is a list... title\0ext\0......\0\0 */ s = ofn->lpstrCustomFilter; - while (*s) s = s+lstrlenW(s)+1; + while (*s) s = s+strlenW(s)+1; s++; n = s - ofn->lpstrCustomFilter; - x = y = (LPSTR)MemAlloc(n); - s = ofn->lpstrCustomFilter; - while (*s) - { - lstrcpyWtoA(x,s); - x+=strlen(x)+1; - s+=lstrlenW(s)+1; - } - *x=0; + len = WideCharToMultiByte( CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0, NULL, NULL ); + y = (LPSTR)MemAlloc(len); + WideCharToMultiByte( CP_ACP, 0, ofn->lpstrCustomFilter, n, y, len, NULL, NULL ); (LPSTR)ofn->lpstrCustomFilter = y; } @@ -1362,10 +1350,15 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) if (!lpszTemp) break; /* end of path */ if(*lpszTemp) - lstrcpynAtoW(lpwstrTemp, lpszTemp1, lpszTemp - lpszTemp1); + { + DWORD len = MultiByteToWideChar( CP_ACP, 0, lpszTemp1, lpszTemp - lpszTemp1, + lpwstrTemp, MAX_PATH ); + lpwstrTemp[len] = 0; + } else { - lstrcpyAtoW(lpwstrTemp, lpszTemp1); /* last element */ + MultiByteToWideChar( CP_ACP, 0, lpszTemp1, -1, + lpwstrTemp, sizeof(lpwstrTemp)/sizeof(WCHAR) ); /* if the last element is a wildcard do a search */ if(strpbrk(lpszTemp1, "*?") != NULL) @@ -1450,12 +1443,15 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) { int iPos; LPSTR lpszTemp = COMDLG32_PathFindFileNameA(lpstrPathAndFile); + DWORD len; /* replace the current filter */ if(fodInfos->ShellInfos.lpstrCurrentFilter) MemFree((LPVOID)fodInfos->ShellInfos.lpstrCurrentFilter); - fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc((strlen(lpszTemp)+1)*sizeof(WCHAR)); - lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter, lpszTemp); + len = MultiByteToWideChar( CP_ACP, 0, lpszTemp, -1, NULL, 0 ); + fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc(len * sizeof(WCHAR)); + MultiByteToWideChar( CP_ACP, 0, lpszTemp, -1, + fodInfos->ShellInfos.lpstrCurrentFilter, len ); /* set the filter cb to the extension when possible */ if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp))) @@ -1755,9 +1751,12 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd) if(lpstrFilter) { + DWORD len; _strlwr(lpstrFilter); /* lowercase */ - fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc((strlen(lpstrFilter)+1)*2); - lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter, lpstrFilter); + len = MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1, NULL, 0 ); + fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1, + fodInfos->ShellInfos.lpstrCurrentFilter, len ); } } return NOERROR; @@ -1793,9 +1792,13 @@ static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode) iItem); if((int)lpstrFilter != CB_ERR) { - fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc((strlen(lpstrFilter)+1)*2); - lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter,_strlwr(lpstrFilter)); - SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE); + DWORD len; + _strlwr(lpstrFilter); /* lowercase */ + len = MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1, NULL, 0 ); + fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, lpstrFilter, -1, + fodInfos->ShellInfos.lpstrCurrentFilter, len ); + SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE); } /* Refresh the actual view to display the included items*/ diff --git a/dlls/commdlg/filedlgbrowser.c b/dlls/commdlg/filedlgbrowser.c index 452132c563a..b3a465341fd 100644 --- a/dlls/commdlg/filedlgbrowser.c +++ b/dlls/commdlg/filedlgbrowser.c @@ -7,9 +7,9 @@ #include #include "windef.h" +#include "winnls.h" #include "wingdi.h" #include "winuser.h" -#include "wine/winestring.h" #include "heap.h" #include "debugtools.h" @@ -87,20 +87,23 @@ static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPI break; case STRRET_CSTRA: - lstrcpynAtoW((LPWSTR)dest, src->u.cStr, len); + if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len )) + ((LPWSTR)dest)[len-1] = 0; break; case STRRET_OFFSETA: if (pidl) { - lstrcpynAtoW((LPWSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len); + if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, + -1, (LPWSTR)dest, len )) + ((LPWSTR)dest)[len-1] = 0; } break; default: FIXME("unknown type!\n"); if (len) - { *(LPSTR)dest = '\0'; + { *(LPWSTR)dest = '\0'; } return(FALSE); } diff --git a/dlls/commdlg/filetitle.c b/dlls/commdlg/filetitle.c index 98fd76ba69f..62f8598d908 100644 --- a/dlls/commdlg/filetitle.c +++ b/dlls/commdlg/filetitle.c @@ -7,8 +7,8 @@ #include -#include "wine/winestring.h" #include "winbase.h" +#include "winnls.h" #include "commdlg.h" #include "debugtools.h" @@ -79,7 +79,8 @@ short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, UINT cbBuf) ret = GetFileTitleA(file, title, cbBuf); - lstrcpynAtoW(lpTitle, title, cbBuf); + if (cbBuf > 0 && !MultiByteToWideChar( CP_ACP, 0, title, -1, lpTitle, cbBuf )) + lpTitle[cbBuf-1] = 0; HeapFree(GetProcessHeap(), 0, file); HeapFree(GetProcessHeap(), 0, title); return ret; diff --git a/dlls/commdlg/finddlg32.c b/dlls/commdlg/finddlg32.c index 3e86e7f89c7..719f911e45b 100644 --- a/dlls/commdlg/finddlg32.c +++ b/dlls/commdlg/finddlg32.c @@ -7,9 +7,9 @@ #include "winbase.h" #include "windef.h" +#include "winnls.h" #include "wingdi.h" #include "winuser.h" -#include "wine/winestring.h" #include "commdlg.h" #include "cderr.h" #include "dlgs.h" @@ -86,7 +86,9 @@ static void COMDLG32_FR_HandleWMCommand(HWND hDlgWnd, COMDLG32_FR_Data *pData, i pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_FINDNEXT; if(pData->fr.Flags & FR_WINE_UNICODE) { - lstrcpyAtoW(pData->user_fr.frw->lpstrFindWhat, pData->fr.lpstrFindWhat); + MultiByteToWideChar( CP_ACP, 0, pData->fr.lpstrFindWhat, -1, + pData->user_fr.frw->lpstrFindWhat, + 0x7fffffff ); } else { @@ -117,8 +119,12 @@ Replace: pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | flag; if(pData->fr.Flags & FR_WINE_UNICODE) { - lstrcpyAtoW(pData->user_fr.frw->lpstrFindWhat, pData->fr.lpstrFindWhat); - lstrcpyAtoW(pData->user_fr.frw->lpstrReplaceWith, pData->fr.lpstrReplaceWith); + MultiByteToWideChar( CP_ACP, 0, pData->fr.lpstrFindWhat, -1, + pData->user_fr.frw->lpstrFindWhat, + 0x7fffffff ); + MultiByteToWideChar( CP_ACP, 0, pData->fr.lpstrReplaceWith, -1, + pData->user_fr.frw->lpstrReplaceWith, + 0x7fffffff ); } else { @@ -475,21 +481,24 @@ HWND WINAPI FindTextW( LPFINDREPLACEW pfr /* [in] Find/replace structure*/ ) { COMDLG32_FR_Data *pdata; + DWORD len; TRACE("LPFINDREPLACE=%p\n", pfr); if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE)) return 0; - if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data) - + pfr->wFindWhatLen)) == NULL) - return 0; /* Error has been set */ + len = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen, + NULL, 0, NULL, NULL ); + if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data) + len)) == NULL) + return 0; /* Error has been set */ pdata->user_fr.frw = pfr; pdata->fr = *(LPFINDREPLACEA)pfr; /* FINDREPLACEx have same size */ pdata->fr.Flags |= FR_WINE_UNICODE; pdata->fr.lpstrFindWhat = (LPSTR)(((LPFINDREPLACEA)(pdata+1))+1); /* Set string pointer */ - lstrcpynWtoA(pdata->fr.lpstrFindWhat, pfr->lpstrFindWhat, pfr->wFindWhatLen); + WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen, + pdata->fr.lpstrFindWhat, len, NULL, NULL ); return COMDLG32_FR_DoFindReplace(pdata); } @@ -503,25 +512,31 @@ HWND WINAPI ReplaceTextW( LPFINDREPLACEW pfr /* [in] Find/replace structure*/ ) { COMDLG32_FR_Data *pdata; + DWORD len1, len2; TRACE("LPFINDREPLACE=%p\n", pfr); if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE)) return 0; + len1 = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen, + NULL, 0, NULL, NULL ); + len2 = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrReplaceWith, pfr->wReplaceWithLen, + NULL, 0, NULL, NULL ); if((pdata = (COMDLG32_FR_Data *)COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data) - + pfr->wFindWhatLen - + pfr->wReplaceWithLen)) == NULL) - - return 0; /* Error has been set */ + + len1 + len2)) == NULL) + return 0; /* Error has been set */ pdata->user_fr.frw = pfr; pdata->fr = *(LPFINDREPLACEA)pfr; /* FINDREPLACEx have same size */ pdata->fr.Flags |= FR_WINE_REPLACE | FR_WINE_UNICODE; pdata->fr.lpstrFindWhat = (LPSTR)(((LPFINDREPLACEA)(pdata+1))+1); /* Set string pointers */ pdata->fr.lpstrReplaceWith = (LPSTR)(((LPFINDREPLACEA)(pdata+1))+1) + pfr->wFindWhatLen; - lstrcpynWtoA(pdata->fr.lpstrFindWhat, pfr->lpstrFindWhat, pfr->wFindWhatLen); - lstrcpynWtoA(pdata->fr.lpstrReplaceWith, pfr->lpstrReplaceWith, pfr->wReplaceWithLen); + + WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen, + pdata->fr.lpstrFindWhat, len1, NULL, NULL ); + WideCharToMultiByte( CP_ACP, 0, pfr->lpstrReplaceWith, pfr->wReplaceWithLen, + pdata->fr.lpstrReplaceWith, len2, NULL, NULL ); return COMDLG32_FR_DoFindReplace(pdata); } diff --git a/dlls/commdlg/fontdlg.c b/dlls/commdlg/fontdlg.c index cd501515da5..e3f62e24dd8 100644 --- a/dlls/commdlg/fontdlg.c +++ b/dlls/commdlg/fontdlg.c @@ -10,11 +10,11 @@ #include #include #include "windef.h" +#include "winnls.h" #include "winbase.h" #include "wingdi.h" #include "wine/winbase16.h" #include "wine/winuser16.h" -#include "wine/winestring.h" #include "ldt.h" #include "heap.h" #include "commdlg.h" @@ -216,7 +216,10 @@ BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont) CF_ENABLETEMPLATEHANDLE)) FIXME(": unimplemented flag (ignored)\n"); memcpy(&cf32a, lpChFont, sizeof(cf32a)); memcpy(&lf32a, lpChFont->lpLogFont, sizeof(LOGFONTA)); - lstrcpynWtoA(lf32a.lfFaceName, lpChFont->lpLogFont->lfFaceName, LF_FACESIZE); + + WideCharToMultiByte( CP_ACP, 0, lpChFont->lpLogFont->lfFaceName, -1, + lf32a.lfFaceName, LF_FACESIZE, NULL, NULL ); + lf32a.lfFaceName[LF_FACESIZE-1] = 0; cf32a.lpLogFont=&lf32a; cf32a.lpszStyle=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont->lpszStyle); lpChFont->lpTemplateName=(LPWSTR)&cf32a; @@ -225,7 +228,9 @@ BOOL WINAPI ChooseFontW(LPCHOOSEFONTW lpChFont) HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle); lpChFont->lpTemplateName=(LPWSTR)cf32a.lpTemplateName; memcpy(lpChFont->lpLogFont, &lf32a, sizeof(CHOOSEFONTA)); - lstrcpynAtoW(lpChFont->lpLogFont->lfFaceName, lf32a.lfFaceName, LF_FACESIZE); + MultiByteToWideChar( CP_ACP, 0, lf32a.lfFaceName, -1, + lpChFont->lpLogFont->lfFaceName, LF_FACESIZE ); + lpChFont->lpLogFont->lfFaceName[LF_FACESIZE-1] = 0; return bRet; } diff --git a/dlls/kernel/format_msg.c b/dlls/kernel/format_msg.c index faaad0acf07..c943d76510e 100644 --- a/dlls/kernel/format_msg.c +++ b/dlls/kernel/format_msg.c @@ -14,7 +14,6 @@ #include "winerror.h" #include "winnls.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "heap.h" #include "debugtools.h" @@ -90,7 +89,7 @@ static INT load_messageA( HMODULE instance, UINT id, WORD lang, return slen; if (i>0) { if (mre->Flags & MESSAGE_RESOURCE_UNICODE) - lstrcpynWtoA(buffer, (LPWSTR)mre->Text, i); + WideCharToMultiByte( CP_ACP, 0, (LPWSTR)mre->Text, -1, buffer, i, NULL, NULL ); else lstrcpynA(buffer, (LPSTR)mre->Text, i); buffer[i]=0; @@ -538,10 +537,15 @@ DWORD WINAPI FormatMessageW( target = (char*)HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,nSize); if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) { /* nSize is the MINIMUM size */ - *((LPVOID*)lpBuffer) = (LPVOID)LocalAlloc(GMEM_ZEROINIT,talloced*2+2); - lstrcpynAtoW(*(LPWSTR*)lpBuffer,target,talloced); - } else - lstrcpynAtoW(lpBuffer,target,nSize); + DWORD len = MultiByteToWideChar( CP_ACP, 0, target, -1, NULL, 0 ); + *((LPVOID*)lpBuffer) = (LPVOID)LocalAlloc(GMEM_ZEROINIT,len*sizeof(WCHAR)); + MultiByteToWideChar( CP_ACP, 0, target, -1, *(LPWSTR*)lpBuffer, len ); + } + else + { + if (nSize > 0 && !MultiByteToWideChar( CP_ACP, 0, target, -1, lpBuffer, nSize )) + lpBuffer[nSize-1] = 0; + } HeapFree(GetProcessHeap(),0,target); if (from) HeapFree(GetProcessHeap(),0,from); return (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) ? diff --git a/dlls/lzexpand/lzexpand_main.c b/dlls/lzexpand/lzexpand_main.c index ede2a3066b1..bbfd2cb69f0 100644 --- a/dlls/lzexpand/lzexpand_main.c +++ b/dlls/lzexpand/lzexpand_main.c @@ -14,7 +14,6 @@ #include "windef.h" #include "winbase.h" #include "wine/winbase16.h" -#include "wine/winestring.h" #include "wine/unicode.h" #include "lzexpand.h" #include "debugtools.h" diff --git a/dlls/mpr/wnet.c b/dlls/mpr/wnet.c index d68f07836db..80fa4e5d95d 100644 --- a/dlls/mpr/wnet.c +++ b/dlls/mpr/wnet.c @@ -9,7 +9,6 @@ #include #include "winbase.h" -#include "wine/winestring.h" #include "winnetwk.h" #include "drive.h" #include "heap.h" @@ -370,14 +369,21 @@ DWORD WINAPI WNetGetConnectionA( LPCSTR lpLocalName, DWORD WINAPI WNetGetConnectionW( LPCWSTR lpLocalName, LPWSTR lpRemoteName, LPDWORD lpBufferSize ) { - DWORD x; CHAR buf[200]; + DWORD x = sizeof(buf); LPSTR lnA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpLocalName ); DWORD ret = WNetGetConnectionA( lnA, buf, &x ); - - lstrcpyAtoW( lpRemoteName, buf ); - *lpBufferSize=lstrlenW( lpRemoteName ); HeapFree( GetProcessHeap(), 0, lnA ); + if (ret == WN_SUCCESS) + { + x = MultiByteToWideChar( CP_ACP, 0, buf, -1, NULL, 0 ); + if (x > *lpBufferSize) + { + *lpBufferSize = x; + return WN_MORE_DATA; + } + *lpBufferSize = MultiByteToWideChar( CP_ACP, 0, buf, -1, lpRemoteName, *lpBufferSize ); + } return ret; } diff --git a/dlls/msacm/driver.c b/dlls/msacm/driver.c index 112f03327a1..d703c44881f 100644 --- a/dlls/msacm/driver.c +++ b/dlls/msacm/driver.c @@ -14,7 +14,6 @@ #include "windef.h" #include "wingdi.h" #include "winuser.h" -#include "wine/winestring.h" #include "debugtools.h" #include "heap.h" #include "mmsystem.h" @@ -127,11 +126,16 @@ MMRESULT WINAPI acmDriverDetailsA(HACMDRIVERID hadid, PACMDRIVERDETAILSA padd, D padd->cFormatTags = addw.cFormatTags; padd->cFilterTags = addw.cFilterTags; padd->hicon = addw.hicon; - lstrcpyWtoA(padd->szShortName, addw.szShortName); - lstrcpyWtoA(padd->szLongName, addw.szLongName); - lstrcpyWtoA(padd->szCopyright, addw.szCopyright); - lstrcpyWtoA(padd->szLicensing, addw.szLicensing); - lstrcpyWtoA(padd->szFeatures, addw.szFeatures); + WideCharToMultiByte( CP_ACP, 0, addw.szShortName, -1, padd->szShortName, + sizeof(padd->szShortName), NULL, NULL ); + WideCharToMultiByte( CP_ACP, 0, addw.szLongName, -1, padd->szLongName, + sizeof(padd->szLongName), NULL, NULL ); + WideCharToMultiByte( CP_ACP, 0, addw.szCopyright, -1, padd->szCopyright, + sizeof(padd->szCopyright), NULL, NULL ); + WideCharToMultiByte( CP_ACP, 0, addw.szLicensing, -1, padd->szLicensing, + sizeof(padd->szLicensing), NULL, NULL ); + WideCharToMultiByte( CP_ACP, 0, addw.szFeatures, -1, padd->szFeatures, + sizeof(padd->szFeatures), NULL, NULL ); } return mmr; } diff --git a/dlls/msacm/filter.c b/dlls/msacm/filter.c index 54613be8f88..40850521d2b 100644 --- a/dlls/msacm/filter.c +++ b/dlls/msacm/filter.c @@ -7,8 +7,8 @@ */ #include "winbase.h" +#include "winnls.h" #include "winerror.h" -#include "wine/winestring.h" #include "mmsystem.h" #include "msacm.h" #include "msacmdrv.h" @@ -57,7 +57,8 @@ MMRESULT WINAPI acmFilterDetailsA(HACMDRIVER had, PACMFILTERDETAILSA pafd, if (mmr == MMSYSERR_NOERROR) { pafd->dwFilterTag = afdw.dwFilterTag; pafd->fdwSupport = afdw.fdwSupport; - lstrcpyWtoA(pafd->szFilter, afdw.szFilter); + WideCharToMultiByte( CP_ACP, 0, afdw.szFilter, -1, pafd->szFilter, + sizeof(pafd->szFilter), NULL, NULL ); } return mmr; } @@ -136,7 +137,8 @@ static BOOL CALLBACK MSACM_FilterEnumCallbackWtoA(HACMDRIVERID hadid, pafei->pafda->dwFilterIndex = pafdw->dwFilterIndex; pafei->pafda->dwFilterTag = pafdw->dwFilterTag; pafei->pafda->fdwSupport = pafdw->fdwSupport; - lstrcpyWtoA(pafei->pafda->szFilter, pafdw->szFilter); + WideCharToMultiByte( CP_ACP, 0, pafdw->szFilter, -1, pafei->pafda->szFilter, + sizeof(pafei->pafda->szFilter), NULL, NULL ); return (pafei->fnCallback)(hadid, pafei->pafda, pafei->dwInstance, fdwSupport); @@ -263,7 +265,8 @@ MMRESULT WINAPI acmFilterTagDetailsA(HACMDRIVER had, PACMFILTERTAGDETAILSA paftd paftda->cbFilterSize = aftdw.cbFilterSize; paftda->fdwSupport = aftdw.fdwSupport; paftda->cStandardFilters = aftdw.cStandardFilters; - lstrcpyWtoA(paftda->szFilterTag, aftdw.szFilterTag); + WideCharToMultiByte( CP_ACP, 0, aftdw.szFilterTag, -1, paftda->szFilterTag, + sizeof(paftda->szFilterTag), NULL, NULL ); } return mmr; } @@ -348,7 +351,8 @@ MMRESULT WINAPI acmFilterTagDetailsW(HACMDRIVER had, PACMFILTERTAGDETAILSW paftd if (mmr == MMSYSERR_NOERROR && paftd->dwFilterTag == WAVE_FORMAT_PCM && paftd->szFilterTag[0] == 0) - lstrcpyAtoW(paftd->szFilterTag, "PCM"); + MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFilterTag, + sizeof(paftd->szFilterTag)/sizeof(WCHAR) ); return mmr; } @@ -373,7 +377,8 @@ static BOOL CALLBACK MSACM_FilterTagEnumCallbackWtoA(HACMDRIVERID hadid, paftei->paftda->cbFilterSize = paftdw->cbFilterSize; paftei->paftda->fdwSupport = paftdw->fdwSupport; paftei->paftda->cStandardFilters = paftdw->cStandardFilters; - lstrcpyWtoA(paftei->paftda->szFilterTag, paftdw->szFilterTag); + WideCharToMultiByte( CP_ACP, 0, paftdw->szFilterTag, -1, paftei->paftda->szFilterTag, + sizeof(paftei->paftda->szFilterTag), NULL, NULL ); return (paftei->fnCallback)(hadid, paftei->paftda, paftei->dwInstance, fdwSupport); diff --git a/dlls/msacm/format.c b/dlls/msacm/format.c index b1fe666e6f5..5fa94350214 100644 --- a/dlls/msacm/format.c +++ b/dlls/msacm/format.c @@ -8,11 +8,12 @@ */ #include "winbase.h" +#include "winnls.h" #include "winerror.h" #include "windef.h" #include "wingdi.h" #include "winuser.h" -#include "wine/winestring.h" +#include "wine/unicode.h" #include "debugtools.h" #include "mmsystem.h" #include "msacm.h" @@ -279,7 +280,8 @@ MMRESULT WINAPI acmFormatDetailsA(HACMDRIVER had, PACMFORMATDETAILSA pafd, if (mmr == MMSYSERR_NOERROR) { pafd->dwFormatTag = afdw.dwFormatTag; pafd->fdwSupport = afdw.fdwSupport; - lstrcpyWtoA(pafd->szFormat, afdw.szFormat); + WideCharToMultiByte( CP_ACP, 0, afdw.szFormat, -1, + pafd->szFormat, sizeof(pafd->szFormat), NULL, NULL ); } return mmr; } @@ -344,8 +346,9 @@ MMRESULT WINAPI acmFormatDetailsW(HACMDRIVER had, PACMFORMATDETAILSW pafd, wsprintfW(pafd->szFormat + lstrlenW(pafd->szFormat), fmt2, pafd->pwfx->wBitsPerSample); } - lstrcpyAtoW(pafd->szFormat + lstrlenW(pafd->szFormat), - (pafd->pwfx->nChannels == 1) ? "; Mono" : "; Stereo"); + MultiByteToWideChar( CP_ACP, 0, (pafd->pwfx->nChannels == 1) ? "; Mono" : "; Stereo", -1, + pafd->szFormat + strlenW(pafd->szFormat), + sizeof(pafd->szFormat)/sizeof(WCHAR) - strlenW(pafd->szFormat) ); } TRACE("=> %d\n", mmr); @@ -370,7 +373,8 @@ static BOOL CALLBACK MSACM_FormatEnumCallbackWtoA(HACMDRIVERID hadid, pafei->pafda->dwFormatIndex = pafdw->dwFormatIndex; pafei->pafda->dwFormatTag = pafdw->dwFormatTag; pafei->pafda->fdwSupport = pafdw->fdwSupport; - lstrcpyWtoA(pafei->pafda->szFormat, pafdw->szFormat); + WideCharToMultiByte( CP_ACP, 0, pafdw->szFormat, -1, + pafei->pafda->szFormat, sizeof(pafei->pafda->szFormat), NULL, NULL ); return (pafei->fnCallback)(hadid, pafei->pafda, pafei->dwInstance, fdwSupport); @@ -577,7 +581,8 @@ MMRESULT WINAPI acmFormatTagDetailsA(HACMDRIVER had, PACMFORMATTAGDETAILSA paftd paftda->cbFormatSize = aftdw.cbFormatSize; paftda->fdwSupport = aftdw.fdwSupport; paftda->cStandardFormats = aftdw.cStandardFormats; - lstrcpyWtoA(paftda->szFormatTag, aftdw.szFormatTag); + WideCharToMultiByte( CP_ACP, 0, aftdw.szFormatTag, -1, paftda->szFormatTag, + sizeof(paftda->szFormatTag), NULL, NULL ); } return mmr; } @@ -662,7 +667,8 @@ MMRESULT WINAPI acmFormatTagDetailsW(HACMDRIVER had, PACMFORMATTAGDETAILSW paftd if (mmr == MMSYSERR_NOERROR && paftd->dwFormatTag == WAVE_FORMAT_PCM && paftd->szFormatTag[0] == 0) - lstrcpyAtoW(paftd->szFormatTag, "PCM"); + MultiByteToWideChar( CP_ACP, 0, "PCM", -1, paftd->szFormatTag, + sizeof(paftd->szFormatTag)/sizeof(WCHAR) ); return mmr; } @@ -687,7 +693,8 @@ static BOOL CALLBACK MSACM_FormatTagEnumCallbackWtoA(HACMDRIVERID hadid, paftei->paftda->cbFormatSize = paftdw->cbFormatSize; paftei->paftda->fdwSupport = paftdw->fdwSupport; paftei->paftda->cStandardFormats = paftdw->cStandardFormats; - lstrcpyWtoA(paftei->paftda->szFormatTag, paftdw->szFormatTag); + WideCharToMultiByte( CP_ACP, 0, paftdw->szFormatTag, -1, paftei->paftda->szFormatTag, + sizeof(paftei->paftda->szFormatTag), NULL, NULL ); return (paftei->fnCallback)(hadid, paftei->paftda, paftei->dwInstance, fdwSupport); diff --git a/dlls/msacm/pcmconverter.c b/dlls/msacm/pcmconverter.c index 08b945bfe14..23b4c3eb108 100644 --- a/dlls/msacm/pcmconverter.c +++ b/dlls/msacm/pcmconverter.c @@ -16,7 +16,7 @@ */ #include -#include "wine/winestring.h" +#include "winnls.h" #include "winbase.h" #include "wingdi.h" #include "winuser.h" @@ -697,10 +697,14 @@ static LRESULT PCM_DriverDetails(PACMDRIVERDETAILSW add) add->cFormatTags = 1; add->cFilterTags = 0; add->hicon = (HICON)0; - lstrcpyAtoW(add->szShortName, "WINE-PCM"); - lstrcpyAtoW(add->szLongName, "Wine PCM converter"); - lstrcpyAtoW(add->szCopyright, "Brought to you by the Wine team..."); - lstrcpyAtoW(add->szLicensing, "Refer to LICENSE file"); + MultiByteToWideChar( CP_ACP, 0, "WINE-PCM", -1, + add->szShortName, sizeof(add->szShortName)/sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, "Wine PCM converter", -1, + add->szLongName, sizeof(add->szLongName)/sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, "Brought to you by the Wine team...", -1, + add->szCopyright, sizeof(add->szCopyright)/sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, "Refer to LICENSE file", -1, + add->szLicensing, sizeof(add->szLicensing)/sizeof(WCHAR) ); add->szFeatures[0] = 0; return MMSYSERR_NOERROR; diff --git a/dlls/msvideo/msvideo_main.c b/dlls/msvideo/msvideo_main.c index ae0674afa1c..245d0830b79 100644 --- a/dlls/msvideo/msvideo_main.c +++ b/dlls/msvideo/msvideo_main.c @@ -12,12 +12,12 @@ #include "winbase.h" #include "windef.h" +#include "winnls.h" #include "wingdi.h" #include "winuser.h" #include "vfw.h" #include "vfw16.h" #include "wine/winbase16.h" -#include "wine/winestring.h" #include "debugtools.h" #include "ldt.h" #include "heap.h" @@ -546,10 +546,9 @@ LPVOID MSVIDEO_MapMsg16To32(UINT msg, LPDWORD lParam1, LPDWORD lParam2) { COPY(ici,dwFlags); COPY(ici,dwVersion); COPY(ici,dwVersionICM); - lstrcpynAtoW(ici->szName,ici16->szName,16); - lstrcpynAtoW(ici->szDescription,ici16->szDescription,128); - lstrcpynAtoW(ici->szDriver,ici16->szDriver,128); - + MultiByteToWideChar( CP_ACP, 0, ici16->szName, -1, ici->szName, 16 ); + MultiByteToWideChar( CP_ACP, 0, ici16->szDescription, -1, ici->szDescription, 128 ); + MultiByteToWideChar( CP_ACP, 0, ici16->szDriver, -1, ici->szDriver, 128 ); *lParam1 = (DWORD)(ici); *lParam2 = sizeof(ICINFO); } @@ -718,8 +717,12 @@ void MSVIDEO_UnmapMsg16To32(UINT msg, LPVOID data16, LPDWORD lParam1, LPDWORD lP UNCOPY(ici,dwFlags); UNCOPY(ici,dwVersion); UNCOPY(ici,dwVersionICM); - lstrcpynWtoA(ici16->szName,ici->szName,16); - lstrcpynWtoA(ici16->szDescription,ici->szDescription,128); + WideCharToMultiByte( CP_ACP, 0, ici->szName, -1, ici16->szName, + sizeof(ici16->szName), NULL, NULL ); + ici16->szName[sizeof(ici16->szName)-1] = 0; + WideCharToMultiByte( CP_ACP, 0, ici->szDescription, -1, ici16->szDescription, + sizeof(ici16->szDescription), NULL, NULL ); + ici16->szDescription[sizeof(ici16->szDescription)-1] = 0; /* This just gives garbage for some reason - BB lstrcpynWtoA(ici16->szDriver,ici->szDriver,128);*/ diff --git a/dlls/ntdll/rtlstr.c b/dlls/ntdll/rtlstr.c index fac02414ac3..dc7c3142a92 100644 --- a/dlls/ntdll/rtlstr.c +++ b/dlls/ntdll/rtlstr.c @@ -10,7 +10,6 @@ #include #include #include -#include "wine/winestring.h" #include "wine/unicode.h" #include "heap.h" #include "winnls.h" diff --git a/dlls/ntdll/sec.c b/dlls/ntdll/sec.c index 8ca732966cf..23be4571c15 100644 --- a/dlls/ntdll/sec.c +++ b/dlls/ntdll/sec.c @@ -12,7 +12,6 @@ #include "windef.h" #include "winbase.h" #include "wine/exception.h" -#include "wine/winestring.h" #include "file.h" #include "heap.h" #include "winnls.h" diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c index 13d16a233df..d4dc0dd494b 100644 --- a/dlls/ole32/clipboard.c +++ b/dlls/ole32/clipboard.c @@ -51,7 +51,6 @@ #include "winuser.h" #include "winbase.h" #include "winerror.h" -#include "wine/winestring.h" #include "ole2.h" #include "debugtools.h" #include "olestd.h" @@ -996,7 +995,7 @@ static HRESULT OLEClipbrd_RenderFormat(IDataObject *pIDataObject, LPFORMATETC pF ReadClassStg(std.u.pstg, &clsID); ProgIDFromCLSID(&clsID, &strProgID); - lstrcpyWtoA(strOleTypeName, strProgID); + WideCharToMultiByte( CP_ACP, 0, strProgID, -1, strOleTypeName, sizeof(strOleTypeName), NULL, NULL ); OLECONVERT_CreateOleStream(std.u.pstg); OLECONVERT_CreateCompObjStream(std.u.pstg, strOleTypeName); } diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index c30274e074f..1df6c1e4e2c 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -18,7 +18,6 @@ #include "wingdi.h" #include "wine/winbase16.h" #include "winerror.h" -#include "wine/winestring.h" #include "wownt32.h" #include "ole2ver.h" #include "debugtools.h" @@ -632,8 +631,9 @@ HRESULT WINAPI StringFromCLSID( ret=WINE_StringFromCLSID(id,buf); if (!ret) { - *idstr = IMalloc_Alloc(mllc,strlen(buf)*2+2); - lstrcpyAtoW(*idstr,buf); + DWORD len = MultiByteToWideChar( CP_ACP, 0, buf, -1, NULL, 0 ); + *idstr = IMalloc_Alloc( mllc, len * sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, buf, -1, *idstr, len ); } return ret; } @@ -655,10 +655,7 @@ StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax) if (WINE_StringFromCLSID(id,xguid)) return 0; - if (strlen(xguid)>=cmax) - return 0; - lstrcpyAtoW(str,xguid); - return strlen(xguid) + 1; + return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax ); } /****************************************************************************** @@ -701,8 +698,9 @@ HRESULT WINAPI ProgIDFromCLSID( ret = E_OUTOFMEMORY; else { - *lplpszProgID = IMalloc_Alloc(mllc, (buf2len+1)*2); - lstrcpyAtoW(*lplpszProgID, buf2); + DWORD len = MultiByteToWideChar( CP_ACP, 0, buf2, -1, NULL, 0 ); + *lplpszProgID = IMalloc_Alloc(mllc, len * sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, buf2, -1, *lplpszProgID, len ); } } HeapFree(GetProcessHeap(), 0, buf2); @@ -2003,7 +2001,7 @@ HRESULT WINAPI OleGetAutoConvert(REFCLSID clsidOld, LPCLSID pClsidNew) if (RegQueryValueA(hkey,"AutoConvertTo",buf,&len)) return REGDB_E_KEYMISSING; RegCloseKey(hkey); - lstrcpyAtoW(wbuf,buf); + MultiByteToWideChar( CP_ACP, 0, buf, -1, wbuf, sizeof(wbuf)/sizeof(WCHAR) ); CLSIDFromString(wbuf,pClsidNew); return S_OK; } diff --git a/dlls/ole32/filemoniker.c b/dlls/ole32/filemoniker.c index 32f70ba469b..283f31b8f9b 100644 --- a/dlls/ole32/filemoniker.c +++ b/dlls/ole32/filemoniker.c @@ -8,7 +8,6 @@ #include "winbase.h" #include "winerror.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "debugtools.h" #include "objbase.h" #include "wine/obj_storage.h" @@ -336,7 +335,7 @@ HRESULT WINAPI FileMonikerImpl_Save(IMoniker* iface, HRESULT res; LPOLESTR filePathW=This->filePathName; CHAR* filePathA; - DWORD len=1+lstrlenW(filePathW); + DWORD len; DWORD constant1 = 0xDEADFFFF; /* these constants are detected after analysing the data structure writen by */ WORD constant2 = 0x3; /* FileMoniker_Save function in a windows program system */ @@ -355,11 +354,12 @@ HRESULT WINAPI FileMonikerImpl_Save(IMoniker* iface, res=IStream_Write(pStm,&zero,sizeof(WORD),NULL); /* write length of filePath string ( "\0" included )*/ + len = WideCharToMultiByte( CP_ACP, 0, filePathW, -1, NULL, 0, NULL, NULL ); res=IStream_Write(pStm,&len,sizeof(DWORD),NULL); /* write filePath string type A */ filePathA=HeapAlloc(GetProcessHeap(),0,len); - lstrcpyWtoA(filePathA,filePathW); + WideCharToMultiByte( CP_ACP, 0, filePathW, -1, filePathA, len, NULL, NULL ); res=IStream_Write(pStm,filePathA,len,NULL); HeapFree(GetProcessHeap(),0,filePathA); diff --git a/dlls/ole32/itemmoniker.c b/dlls/ole32/itemmoniker.c index 45e2462287e..5571539913a 100644 --- a/dlls/ole32/itemmoniker.c +++ b/dlls/ole32/itemmoniker.c @@ -7,8 +7,8 @@ #include #include "winerror.h" #include "winbase.h" +#include "winnls.h" #include "debugtools.h" -#include "wine/winestring.h" #include "wine/obj_base.h" #include "wine/obj_misc.h" #include "wine/obj_storage.h" @@ -234,7 +234,7 @@ HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface,IStream* pStm) ICOM_THIS(ItemMonikerImpl,iface); HRESULT res; - DWORD delimiterLength,nameLength; + DWORD delimiterLength,nameLength,lenW; CHAR *itemNameA,*itemDelimiterA; ULONG bread; @@ -246,16 +246,24 @@ HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface,IStream* pStm) return E_FAIL; /* read item delimiter string */ - itemDelimiterA=HeapAlloc(GetProcessHeap(),0,delimiterLength); + if (!(itemDelimiterA=HeapAlloc(GetProcessHeap(),0,delimiterLength))) + return E_OUTOFMEMORY; res=IStream_Read(pStm,itemDelimiterA,delimiterLength,&bread); if (bread != delimiterLength) + { + HeapFree( GetProcessHeap(), 0, itemDelimiterA ); return E_FAIL; + } - This->itemDelimiter=HeapReAlloc(GetProcessHeap(),0,This->itemDelimiter,delimiterLength*sizeof(WCHAR)); + lenW = MultiByteToWideChar( CP_ACP, 0, itemDelimiterA, -1, NULL, 0 ); + This->itemDelimiter=HeapReAlloc(GetProcessHeap(),0,This->itemDelimiter,lenW*sizeof(WCHAR)); if (!This->itemDelimiter) + { + HeapFree( GetProcessHeap(), 0, itemDelimiterA ); return E_OUTOFMEMORY; - - lstrcpyAtoW(This->itemDelimiter,itemDelimiterA); + } + MultiByteToWideChar( CP_ACP, 0, itemDelimiterA, -1, This->itemDelimiter, lenW ); + HeapFree( GetProcessHeap(), 0, itemDelimiterA ); /* read item name string length + 1*/ res=IStream_Read(pStm,&nameLength,sizeof(DWORD),&bread); @@ -263,16 +271,24 @@ HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface,IStream* pStm) return E_FAIL; /* read item name string */ - itemNameA=HeapAlloc(GetProcessHeap(),0,nameLength); + if (!(itemNameA=HeapAlloc(GetProcessHeap(),0,nameLength))) + return E_OUTOFMEMORY; res=IStream_Read(pStm,itemNameA,nameLength,&bread); if (bread != nameLength) + { + HeapFree( GetProcessHeap(), 0, itemNameA ); return E_FAIL; + } - This->itemName=HeapReAlloc(GetProcessHeap(),0,This->itemName,nameLength*sizeof(WCHAR)); + lenW = MultiByteToWideChar( CP_ACP, 0, itemNameA, -1, NULL, 0 ); + This->itemName=HeapReAlloc(GetProcessHeap(),0,This->itemName,lenW*sizeof(WCHAR)); if (!This->itemName) + { + HeapFree( GetProcessHeap(), 0, itemNameA ); return E_OUTOFMEMORY; - - lstrcpyAtoW(This->itemName,itemNameA); + } + MultiByteToWideChar( CP_ACP, 0, itemNameA, -1, This->itemName, lenW ); + HeapFree( GetProcessHeap(), 0, itemNameA ); return res; } @@ -286,8 +302,6 @@ HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface, { ICOM_THIS(ItemMonikerImpl,iface); HRESULT res; - DWORD delimiterLength=lstrlenW(This->itemDelimiter)+1; - DWORD nameLength=lstrlenW(This->itemName)+1; CHAR *itemNameA,*itemDelimiterA; /* data writen by this function are : 1) DWORD : size of item delimiter string ('\0' included ) */ @@ -295,10 +309,12 @@ HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface, /* 3) DWORD : size of item name string ('\0' included) */ /* 4) String (type A): item name string ('\0' included) */ + DWORD nameLength = WideCharToMultiByte( CP_ACP, 0, This->itemName, -1, NULL, 0, NULL, NULL); + DWORD delimiterLength = WideCharToMultiByte( CP_ACP, 0, This->itemDelimiter, -1, NULL, 0, NULL, NULL); itemNameA=HeapAlloc(GetProcessHeap(),0,nameLength); itemDelimiterA=HeapAlloc(GetProcessHeap(),0,delimiterLength); - lstrcpyWtoA(itemNameA,This->itemName); - lstrcpyWtoA(itemDelimiterA,This->itemDelimiter); + WideCharToMultiByte( CP_ACP, 0, This->itemName, -1, itemNameA, nameLength, NULL, NULL); + WideCharToMultiByte( CP_ACP, 0, This->itemDelimiter, -1, itemDelimiterA, delimiterLength, NULL, NULL); res=IStream_Write(pStm,&delimiterLength,sizeof(DWORD),NULL); res=IStream_Write(pStm,itemDelimiterA,delimiterLength * sizeof(CHAR),NULL); diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c index 0ab809f500b..ec749954d7b 100644 --- a/dlls/ole32/ole2.c +++ b/dlls/ole32/ole2.c @@ -21,7 +21,6 @@ #include "wine/obj_clientserver.h" #include "wine/winbase16.h" #include "wine/wingdi16.h" -#include "wine/winestring.h" #include "debugtools.h" #include "ole2ver.h" #include "winreg.h" @@ -486,7 +485,7 @@ HRESULT WINAPI OleRegGetUserType( } else { - lstrcpyAtoW(*pszUserType, buffer); + MultiByteToWideChar( CP_ACP, 0, buffer, -1, *pszUserType, cbData /*FIXME*/ ); retVal = S_OK; } HeapFree(GetProcessHeap(), 0, buffer); diff --git a/dlls/ole32/storage.c b/dlls/ole32/storage.c index ad3dee84924..e576182f389 100644 --- a/dlls/ole32/storage.c +++ b/dlls/ole32/storage.c @@ -15,7 +15,6 @@ #include "windef.h" #include "ntddk.h" #include "winerror.h" -#include "wine/winestring.h" #include "wine/winbase16.h" #include "wingdi.h" #include "wtypes.h" @@ -361,7 +360,7 @@ void STORAGE_dump_pps_entry(struct storage_pps_entry *stde) { char name[33]; - lstrcpyWtoA(name,stde->pps_rawname); + WideCharToMultiByte( CP_ACP, 0, stde->pps_rawname, -1, name, sizeof(name), NULL, NULL); if (!stde->pps_sizeofname) return; DPRINTF("name: %s\n",name); @@ -416,8 +415,9 @@ STORAGE_init_storage(HFILE hf) { /* block 1 is the root directory entry */ memset(block,0x00,sizeof(block)); stde = (struct storage_pps_entry*)block; - lstrcpyAtoW(stde->pps_rawname,"RootEntry"); - stde->pps_sizeofname = lstrlenW(stde->pps_rawname)*2+2; + MultiByteToWideChar( CP_ACP, 0, "RootEntry", -1, stde->pps_rawname, + sizeof(stde->pps_rawname)/sizeof(WCHAR)); + stde->pps_sizeofname = (strlenW(stde->pps_rawname)+1) * sizeof(WCHAR); stde->pps_type = 5; stde->pps_dir = -1; stde->pps_next = -1; @@ -1351,8 +1351,9 @@ HRESULT WINAPI IStorage16_fnCreateStorage( } assert(STORAGE_put_pps_entry(lpstg->hf,x,&stde)); assert(1==STORAGE_get_pps_entry(lpstg->hf,ppsent,&(lpstg->stde))); - lstrcpyAtoW(lpstg->stde.pps_rawname,pwcsName); - lpstg->stde.pps_sizeofname = strlen(pwcsName)*2+2; + MultiByteToWideChar( CP_ACP, 0, pwcsName, -1, lpstg->stde.pps_rawname, + sizeof(lpstg->stde.pps_rawname)/sizeof(WCHAR)); + lpstg->stde.pps_sizeofname = (strlenW(lpstg->stde.pps_rawname)+1)*sizeof(WCHAR); lpstg->stde.pps_next = -1; lpstg->stde.pps_prev = -1; lpstg->stde.pps_dir = -1; @@ -1404,8 +1405,9 @@ HRESULT WINAPI IStorage16_fnCreateStream( stde.pps_next = ppsent; assert(STORAGE_put_pps_entry(lpstr->hf,x,&stde)); assert(1==STORAGE_get_pps_entry(lpstr->hf,ppsent,&(lpstr->stde))); - lstrcpyAtoW(lpstr->stde.pps_rawname,pwcsName); - lpstr->stde.pps_sizeofname = strlen(pwcsName)*2+2; + MultiByteToWideChar( CP_ACP, 0, pwcsName, -1, lpstr->stde.pps_rawname, + sizeof(lpstr->stde.pps_rawname)/sizeof(WCHAR)); + lpstr->stde.pps_sizeofname = (strlenW(lpstr->stde.pps_rawname)+1) * sizeof(WCHAR); lpstr->stde.pps_next = -1; lpstr->stde.pps_prev = -1; lpstr->stde.pps_dir = -1; @@ -1439,7 +1441,7 @@ HRESULT WINAPI IStorage16_fnOpenStorage( lpstg = (IStream16Impl*)PTR_SEG_TO_LIN(*ppstg); DuplicateHandle( GetCurrentProcess(), This->hf, GetCurrentProcess(), &lpstg->hf, 0, TRUE, DUPLICATE_SAME_ACCESS ); - lstrcpyAtoW(name,pwcsName); + MultiByteToWideChar( CP_ACP, 0, pwcsName, -1, name, sizeof(name)/sizeof(WCHAR)); newpps = STORAGE_look_for_named_pps(lpstg->hf,This->stde.pps_dir,name); if (newpps==-1) { IStream16_fnRelease((IStream16*)lpstg); @@ -1474,7 +1476,7 @@ HRESULT WINAPI IStorage16_fnOpenStream( lpstr = (IStream16Impl*)PTR_SEG_TO_LIN(*ppstm); DuplicateHandle( GetCurrentProcess(), This->hf, GetCurrentProcess(), &lpstr->hf, 0, TRUE, DUPLICATE_SAME_ACCESS ); - lstrcpyAtoW(name,pwcsName); + MultiByteToWideChar( CP_ACP, 0, pwcsName, -1, name, sizeof(name)/sizeof(WCHAR)); newpps = STORAGE_look_for_named_pps(lpstr->hf,This->stde.pps_dir,name); if (newpps==-1) { IStream16_fnRelease((IStream16*)lpstr); diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index e3cb2643ef2..b77ace94967 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -18,7 +18,6 @@ #include "winbase.h" /* for lstrlenW() and the likes */ #include "winnls.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "debugtools.h" #include "storage32.h" @@ -2229,9 +2228,9 @@ HRESULT StorageImpl_Construct( * Initialize the property chain */ memset(&rootProp, 0, sizeof(rootProp)); - lstrcpyAtoW(rootProp.name, rootPropertyName); - - rootProp.sizeOfNameString = (lstrlenW(rootProp.name)+1) * sizeof(WCHAR); + MultiByteToWideChar( CP_ACP, 0, rootPropertyName, -1, rootProp.name, + sizeof(rootProp.name)/sizeof(WCHAR) ); + rootProp.sizeOfNameString = (strlenW(rootProp.name)+1) * sizeof(WCHAR); rootProp.propertyType = PROPTYPE_ROOT; rootProp.previousProperty = PROPERTY_NULL; rootProp.nextProperty = PROPERTY_NULL; diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c index 7fbc84796ba..6f5368f28e1 100644 --- a/dlls/shell32/pidl.c +++ b/dlls/shell32/pidl.c @@ -16,7 +16,6 @@ #include "shlguid.h" #include "winerror.h" #include "winnls.h" -#include "wine/winestring.h" #include "wine/undocshell.h" #include "shell32_main.h" #include "shellapi.h" @@ -290,7 +289,8 @@ HRESULT WINAPI SHILCreateFromPathA (LPCSTR path, LPITEMIDLIST * ppidl, DWORD * a TRACE_(shell)("%s %p 0x%08lx\n",path,ppidl,attributes?*attributes:0); - lstrcpynAtoW(lpszDisplayName, path, MAX_PATH); + if (!MultiByteToWideChar( CP_ACP, 0, path, -1, lpszDisplayName, MAX_PATH )) + lpszDisplayName[MAX_PATH-1] = 0; if (SUCCEEDED (SHGetDesktopFolder(&sf))) { @@ -764,7 +764,8 @@ LPITEMIDLIST WINAPI SHSimpleIDListFromPathW (LPCWSTR lpszPath) char lpszTemp[MAX_PATH]; TRACE("path=%s\n",debugstr_w(lpszPath)); - lstrcpynWtoA(lpszTemp, lpszPath, MAX_PATH); + if (!WideCharToMultiByte( CP_ACP, 0, lpszPath, -1, lpszTemp, sizeof(lpszTemp), NULL, NULL )) + lpszTemp[sizeof(lpszTemp)-1] = 0; return SHSimpleIDListFromPathA (lpszTemp); } @@ -927,8 +928,12 @@ HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int n _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime)); pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0); pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0); - lstrcpynAtoW(pfd->cFileName,_ILGetTextPointer(pidl), MAX_PATH); - lstrcpynAtoW(pfd->cAlternateFileName,_ILGetSTextPointer(pidl), 14); + if (!MultiByteToWideChar( CP_ACP, 0, _ILGetTextPointer(pidl), -1, + pfd->cFileName, MAX_PATH )) + pfd->cFileName[MAX_PATH-1] = 0; + if (!MultiByteToWideChar( CP_ACP, 0, _ILGetSTextPointer(pidl), -1, + pfd->cAlternateFileName, 14 )) + pfd->cFileName[13] = 0; } return NOERROR; case SHGDFIL_NETRESOURCE: @@ -1002,7 +1007,7 @@ BOOL WINAPI SHGetPathFromIDListW (LPCITEMIDLIST pidl,LPWSTR pszPath) TRACE_(shell)("(pidl=%p)\n", pidl); SHGetPathFromIDListA (pidl, sTemp); - lstrcpyAtoW(pszPath, sTemp); + MultiByteToWideChar( CP_ACP, 0, sTemp, -1, pszPath, MAX_PATH ); TRACE_(shell)("-- (%s)\n",debugstr_w(pszPath)); diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c index 369e65f582c..e42349b8b29 100644 --- a/dlls/shell32/shelllink.c +++ b/dlls/shell32/shelllink.c @@ -21,7 +21,6 @@ #include "winnls.h" #include "shlobj.h" -#include "wine/winestring.h" #include "wine/undocshell.h" #include "bitmaps/wine.xpm" @@ -1200,7 +1199,7 @@ static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile, _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface); FIXME("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This, pszFile, cchMaxPath, pfd, fFlags); - lstrcpynAtoW(pszFile,"c:\\foo.bar", cchMaxPath); + MultiByteToWideChar( CP_ACP, 0, "c:\\foo.bar", -1, pszFile, cchMaxPath ); return NOERROR; } @@ -1226,7 +1225,7 @@ static HRESULT WINAPI IShellLinkW_fnGetDescription(IShellLinkW * iface, LPWSTR p _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface); FIXME("(%p)->(%p len=%u)\n",This, pszName, cchMaxName); - lstrcpynAtoW(pszName,"Description, FIXME",cchMaxName); + MultiByteToWideChar( CP_ACP, 0, "Description, FIXME", -1, pszName, cchMaxName ); return NOERROR; } @@ -1249,7 +1248,7 @@ static HRESULT WINAPI IShellLinkW_fnGetWorkingDirectory(IShellLinkW * iface, LPW _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface); FIXME("(%p)->()\n",This); - lstrcpynAtoW(pszDir,"c:\\", cchMaxPath); + MultiByteToWideChar( CP_ACP, 0, "c:\\", -1, pszDir, cchMaxPath ); return NOERROR; } @@ -1272,7 +1271,7 @@ static HRESULT WINAPI IShellLinkW_fnGetArguments(IShellLinkW * iface, LPWSTR psz _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface); FIXME("(%p)->(%p len=%u)\n",This, pszArgs, cchMaxPath); - lstrcpynAtoW(pszArgs, "", cchMaxPath); + pszArgs[0] = 0; return NOERROR; } @@ -1329,7 +1328,7 @@ static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface); FIXME("(%p)->(%p len=%u iicon=%p)\n",This, pszIconPath, cchIconPath, piIcon); - lstrcpynAtoW(pszIconPath,"shell32.dll",cchIconPath); + MultiByteToWideChar( CP_ACP, 0, "shell32.dll", -1, pszIconPath, cchIconPath ); *piIcon=1; return NOERROR; } diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index 1635441123d..4541349f5a6 100644 --- a/dlls/shell32/shellpath.c +++ b/dlls/shell32/shellpath.c @@ -7,14 +7,13 @@ #include #include #include "debugtools.h" +#include "windef.h" #include "winnls.h" #include "winreg.h" #include "shlobj.h" #include "shell32_main.h" -#include "windef.h" #include "options.h" -#include "wine/winestring.h" #include "wine/undocshell.h" #include "wine/unicode.h" #include "shlwapi.h" @@ -849,8 +848,9 @@ BOOL WINAPI SHGetSpecialFolderPathW ( if (SHGetSpecialFolderPathA(hwndOwner, szTemp, csidl, bCreate)) { - lstrcpynAtoW(szPath, szTemp, MAX_PATH); - } + if (!MultiByteToWideChar( CP_ACP, 0, szTemp, -1, szPath, MAX_PATH )) + szPath[MAX_PATH-1] = 0; + } TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner,szPath,csidl,bCreate); diff --git a/dlls/shell32/shlfolder.c b/dlls/shell32/shlfolder.c index 3c8e59edc91..113a34db674 100644 --- a/dlls/shell32/shlfolder.c +++ b/dlls/shell32/shlfolder.c @@ -20,7 +20,6 @@ #include "shlguid.h" #include "pidl.h" -#include "wine/winestring.h" #include "wine/obj_base.h" #include "wine/obj_dragdrop.h" #include "wine/obj_shellfolder.h" @@ -654,7 +653,7 @@ static HRESULT WINAPI IShellFolder_fnParseDisplayName( szNext = GetNextElementW(lpszDisplayName, szElement, MAX_PATH); /* build the full pathname to the element */ - lstrcpynWtoA(szTempA, szElement, lstrlenW(szElement) + 1); + WideCharToMultiByte( CP_ACP, 0, szElement, -1, szTempA, MAX_PATH, NULL, NULL ); strcpy(szPath, This->sMyPath); PathAddBackslashA(szPath); strcat(szPath, szTempA); @@ -1184,8 +1183,8 @@ static HRESULT WINAPI IShellFolder_fnSetNameOf( strcpy(szDest, This->sMyPath); PathAddBackslashA(szDest); len = strlen (szDest); - lstrcpynWtoA(szDest+len, lpName, MAX_PATH-len); - + WideCharToMultiByte( CP_ACP, 0, lpName, -1, szDest+len, MAX_PATH-len, NULL, NULL ); + szDest[MAX_PATH-1] = 0; TRACE("src=%s dest=%s\n", szSrc, szDest); if ( MoveFileA(szSrc, szDest) ) { @@ -2129,7 +2128,7 @@ static HRESULT WINAPI ISF_MyComputer_fnParseDisplayName( lpszDisplayName[2] == (WCHAR)'\\') { szNext = GetNextElementW(lpszDisplayName, szElement, MAX_PATH); - lstrcpynWtoA(szTempA, szElement, lstrlenW(szElement) + 1); + WideCharToMultiByte( CP_ACP, 0, szElement, -1, szTempA, MAX_PATH, NULL, NULL ); pidlTemp = _ILCreateDrive(szTempA); if (szNext && *szNext) diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c index d4bcbf46400..2bbb23148a8 100644 --- a/dlls/shell32/shlview.c +++ b/dlls/shell32/shlview.c @@ -26,14 +26,14 @@ #include #include "windef.h" +#include "winerror.h" +#include "winnls.h" #include "servprov.h" #include "shlguid.h" #include "shlobj.h" #include "wine/undocshell.h" #include "shresdef.h" #include "debugtools.h" -#include "winerror.h" -#include "wine/winestring.h" #include "docobj.h" #include "pidl.h" @@ -1242,7 +1242,8 @@ static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpn ListView_GetItemA(This->hWndList, &lvItem); pidl = (LPITEMIDLIST)lpdi->item.lParam; - lstrcpynAtoW(wszNewName, lpdi->item.pszText, MAX_PATH); + if (!MultiByteToWideChar( CP_ACP, 0, lpdi->item.pszText, -1, wszNewName, MAX_PATH )) + wszNewName[MAX_PATH-1] = 0; hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, wszNewName, SHGDN_INFOLDER, &pidl); if(SUCCEEDED(hr) && pidl) diff --git a/dlls/shell32/shv_item_cmenu.c b/dlls/shell32/shv_item_cmenu.c index dda43bb97c1..6a3a0db859b 100644 --- a/dlls/shell32/shv_item_cmenu.c +++ b/dlls/shell32/shv_item_cmenu.c @@ -10,7 +10,6 @@ #include "pidl.h" #include "shlguid.h" -#include "wine/winestring.h" #include "wine/obj_base.h" #include "wine/obj_contextmenu.h" #include "wine/obj_shellbrowser.h" @@ -485,7 +484,7 @@ static HRESULT WINAPI ISvItemCm_fnGetCommandString( case GCS_VERBW: switch(idCommand) { case FCIDM_SHVIEW_RENAME: - lstrcpyAtoW((LPWSTR)lpszName, "rename"); + MultiByteToWideChar( CP_ACP, 0, "rename", -1, (LPWSTR)lpszName, uMaxNameLen ); hr = NOERROR; break; } diff --git a/dlls/shell32/systray.c b/dlls/shell32/systray.c index f49b7d65aeb..65498930ca6 100644 --- a/dlls/shell32/systray.c +++ b/dlls/shell32/systray.c @@ -13,7 +13,7 @@ #include #include -#include "wine/winestring.h" +#include "winnls.h" #include "shlobj.h" #include "shellapi.h" #include "shell32_main.h" @@ -365,8 +365,8 @@ BOOL WINAPI Shell_NotifyIconW (DWORD dwMessage, PNOTIFYICONDATAW pnid ) PNOTIFYICONDATAA p = HeapAlloc(GetProcessHeap(),0,sizeof(NOTIFYICONDATAA)); memcpy(p, pnid, sizeof(NOTIFYICONDATAA)); - if (*(pnid->szTip)) - lstrcpynWtoA (p->szTip, pnid->szTip, 64 ); + WideCharToMultiByte( CP_ACP, 0, pnid->szTip, -1, p->szTip, sizeof(p->szTip), NULL, NULL ); + p->szTip[sizeof(p->szTip)-1] = 0; ret = Shell_NotifyIconA(dwMessage, p ); diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c index 40225a00e63..c1abfb70c2c 100644 --- a/dlls/shlwapi/path.c +++ b/dlls/shlwapi/path.c @@ -8,7 +8,6 @@ #include "winerror.h" #include "wine/unicode.h" #include "wine/undocshell.h" -#include "wine/winestring.h" #include "shlwapi.h" #include "debugtools.h" @@ -195,10 +194,11 @@ LPSTR WINAPI PathBuildRootA(LPSTR lpszPath, int drive) */ LPWSTR WINAPI PathBuildRootW(LPWSTR lpszPath, int drive) { + lpszPath[0] = 'A' + drive; + lpszPath[1] = ':'; + lpszPath[2] = '\\'; + lpszPath[3] = 0; TRACE("%p %i\n",debugstr_w(lpszPath), drive); - - lstrcpyAtoW(lpszPath,"A:\\"); - lpszPath[0]+=drive; return lpszPath; } @@ -1054,10 +1054,9 @@ BOOL WINAPI PathMatchSpecA(LPCSTR name, LPCSTR mask) */ BOOL WINAPI PathMatchSpecW(LPCWSTR name, LPCWSTR mask) { - WCHAR stemp[4]; + static const WCHAR stemp[] = { '*','.','*',0 }; TRACE("%s %s\n",debugstr_w(name),debugstr_w(mask)); - lstrcpyAtoW(stemp,"*.*"); if (!lstrcmpW( mask, stemp )) return 1; /* we don't require a period */ while (*mask) diff --git a/dlls/shlwapi/string.c b/dlls/shlwapi/string.c index b259c6ecef8..e383e053b45 100644 --- a/dlls/shlwapi/string.c +++ b/dlls/shlwapi/string.c @@ -11,7 +11,6 @@ #include "shlwapi.h" #include "shlobj.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "debugtools.h" DEFAULT_DEBUG_CHANNEL(shell); diff --git a/dlls/ttydrv/graphics.c b/dlls/ttydrv/graphics.c index 8d0674d970e..082080c7c6f 100644 --- a/dlls/ttydrv/graphics.c +++ b/dlls/ttydrv/graphics.c @@ -6,7 +6,7 @@ #include "config.h" -#include "wine/winestring.h" +#include "winnls.h" #include "gdi.h" #include "heap.h" #include "debugtools.h" @@ -365,6 +365,7 @@ BOOL TTYDRV_DC_ExtTextOut(DC *dc, INT x, INT y, UINT flags, TTYDRV_PDEVICE *physDev = (TTYDRV_PDEVICE *) dc->physDev; INT row, col; LPSTR ascii; + DWORD len; TRACE("(%p, %d, %d, 0x%08x, %p, %s, %d, %p)\n", dc, x, y, flags, lpRect, debugstr_wn(str, count), count, lpDx); @@ -383,9 +384,10 @@ BOOL TTYDRV_DC_ExtTextOut(DC *dc, INT x, INT y, UINT flags, row = (dc->DCOrgY + y) / physDev->cellHeight; col = (dc->DCOrgX + x) / physDev->cellWidth; - ascii = HeapAlloc( GetProcessHeap(), 0, count+1 ); - lstrcpynWtoA(ascii, str, count+1); - mvwaddnstr(physDev->window, row, col, ascii, count); + len = WideCharToMultiByte( CP_ACP, 0, str, count, NULL, 0, NULL, NULL ); + ascii = HeapAlloc( GetProcessHeap(), 0, len ); + WideCharToMultiByte( CP_ACP, 0, str, count, ascii, len, NULL, NULL ); + mvwaddnstr(physDev->window, row, col, ascii, len); HeapFree( GetProcessHeap(), 0, ascii ); wrefresh(physDev->window); diff --git a/dlls/version/info.c b/dlls/version/info.c index 073d4e17011..7be2d13dfd4 100644 --- a/dlls/version/info.c +++ b/dlls/version/info.c @@ -11,7 +11,6 @@ #include "winreg.h" #include "winver.h" -#include "wine/winestring.h" #include "wine/winuser16.h" #include "wine/unicode.h" #include "winerror.h" @@ -212,7 +211,7 @@ void ConvertVersionInfo32To16( VS_VERSION_INFO_STRUCT32 *info32, wLength, wValueLength, bText, lpValue, child32 ); /* Convert key */ - lstrcpyWtoA( info16->szKey, info32->szKey ); + WideCharToMultiByte( CP_ACP, 0, info32->szKey, -1, info16->szKey, 0x7fffffff, NULL, NULL ); TRACE("Copied key from %p to %p: %s\n", info32->szKey, info16->szKey, debugstr_a(info16->szKey) ); @@ -225,8 +224,9 @@ void ConvertVersionInfo32To16( VS_VERSION_INFO_STRUCT32 *info32, } else if ( bText ) { - info16->wValueLength = lstrlenW( (LPCWSTR)lpValue ) + 1; - lstrcpyWtoA( VersionInfo16_Value( info16 ), (LPCWSTR)lpValue ); + info16->wValueLength = WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)lpValue, -1, NULL, 0, NULL, NULL ); + WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)lpValue, -1, + VersionInfo16_Value( info16 ), info16->wValueLength, NULL, NULL ); TRACE("Copied value from %p to %p: %s\n", lpValue, VersionInfo16_Value( info16 ), diff --git a/dlls/winmm/joystick.c b/dlls/winmm/joystick.c index 4a68060b834..e1be8cfa72f 100644 --- a/dlls/winmm/joystick.c +++ b/dlls/winmm/joystick.c @@ -16,9 +16,9 @@ #include #include #include "winbase.h" +#include "winnls.h" #include "wingdi.h" #include "winuser.h" -#include "wine/winestring.h" #include "winemm.h" #include "debugtools.h" @@ -144,7 +144,8 @@ MMRESULT WINAPI joyGetDevCapsW(UINT wID, LPJOYCAPSW lpCaps, UINT wSize) if (ret != JOYERR_NOERROR) return ret; lpCaps->wMid = jca.wMid; lpCaps->wPid = jca.wPid; - lstrcpyAtoW(lpCaps->szPname, jca.szPname); + MultiByteToWideChar( CP_ACP, 0, jca.szPname, -1, lpCaps->szPname, + sizeof(lpCaps->szPname)/sizeof(WCHAR) ); lpCaps->wXmin = jca.wXmin; lpCaps->wXmax = jca.wXmax; lpCaps->wYmin = jca.wYmin; @@ -166,8 +167,10 @@ MMRESULT WINAPI joyGetDevCapsW(UINT wID, LPJOYCAPSW lpCaps, UINT wSize) lpCaps->wMaxAxes = jca.wMaxAxes; lpCaps->wNumAxes = jca.wNumAxes; lpCaps->wMaxButtons = jca.wMaxButtons; - lstrcpyAtoW(lpCaps->szRegKey, jca.szRegKey); - lstrcpyAtoW(lpCaps->szOEMVxD, jca.szOEMVxD); + MultiByteToWideChar( CP_ACP, 0, jca.szRegKey, -1, lpCaps->szRegKey, + sizeof(lpCaps->szRegKey)/sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, jca.szOEMVxD, -1, lpCaps->szOEMVxD, + sizeof(lpCaps->szOEMVxD)/sizeof(WCHAR) ); } return ret; diff --git a/dlls/winmm/mmsystem.c b/dlls/winmm/mmsystem.c index 6568e8d393d..5adc25003d0 100644 --- a/dlls/winmm/mmsystem.c +++ b/dlls/winmm/mmsystem.c @@ -24,7 +24,6 @@ #include "wingdi.h" #include "wine/winbase16.h" #include "wine/winuser16.h" -#include "wine/winestring.h" #include "heap.h" #include "winemm.h" #include "selectors.h" @@ -815,7 +814,8 @@ UINT WINAPI mixerGetDevCapsW(UINT devid, LPMIXERCAPSW mixcaps, UINT size) mixcaps->wMid = micA.wMid; mixcaps->wPid = micA.wPid; mixcaps->vDriverVersion = micA.vDriverVersion; - lstrcpyAtoW(mixcaps->szPname, micA.szPname); + MultiByteToWideChar( CP_ACP, 0, micA.szPname, -1, mixcaps->szPname, + sizeof(mixcaps->szPname)/sizeof(WCHAR) ); mixcaps->fdwSupport = micA.fdwSupport; mixcaps->cDestinations = micA.cDestinations; } @@ -1098,9 +1098,12 @@ UINT WINAPI mixerGetLineControlsW(HMIXEROBJ hmix, LPMIXERLINECONTROLSW lpmlcW, lpmlcW->pamxctrl[i].dwControlType = mlcA.pamxctrl[i].dwControlType; lpmlcW->pamxctrl[i].fdwControl = mlcA.pamxctrl[i].fdwControl; lpmlcW->pamxctrl[i].cMultipleItems = mlcA.pamxctrl[i].cMultipleItems; - lstrcpyAtoW(lpmlcW->pamxctrl[i].szShortName, - mlcA.pamxctrl[i].szShortName); - lstrcpyAtoW(lpmlcW->pamxctrl[i].szName, mlcA.pamxctrl[i].szName); + MultiByteToWideChar( CP_ACP, 0, mlcA.pamxctrl[i].szShortName, -1, + lpmlcW->pamxctrl[i].szShortName, + sizeof(lpmlcW->pamxctrl[i].szShortName)/sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, mlcA.pamxctrl[i].szName, -1, + lpmlcW->pamxctrl[i].szName, + sizeof(lpmlcW->pamxctrl[i].szName)/sizeof(WCHAR) ); /* sizeof(lpmlcW->pamxctrl[i].Bounds) == * sizeof(mlcA.pamxctrl[i].Bounds) */ memcpy(&lpmlcW->pamxctrl[i].Bounds, &mlcA.pamxctrl[i].Bounds, @@ -1226,7 +1229,7 @@ UINT WINAPI mixerGetLineInfoW(HMIXEROBJ hmix, LPMIXERLINEW lpmliW, mliA.Target.wMid = lpmliW->Target.wMid; mliA.Target.wPid = lpmliW->Target.wPid; mliA.Target.vDriverVersion = lpmliW->Target.vDriverVersion; - lstrcpyWtoA(mliA.Target.szPname, lpmliW->Target.szPname); + WideCharToMultiByte( CP_ACP, 0, lpmliW->Target.szPname, -1, mliA.Target.szPname, sizeof(mliA.Target.szPname), NULL, NULL); break; default: FIXME("Unsupported fdwControls=0x%08lx\n", fdwInfo); @@ -1243,14 +1246,17 @@ UINT WINAPI mixerGetLineInfoW(HMIXEROBJ hmix, LPMIXERLINEW lpmliW, lpmliW->cChannels = mliA.cChannels; lpmliW->cConnections = mliA.cConnections; lpmliW->cControls = mliA.cControls; - lstrcpyAtoW(lpmliW->szShortName, mliA.szShortName); - lstrcpyAtoW(lpmliW->szName, mliA.szName); + MultiByteToWideChar( CP_ACP, 0, mliA.szShortName, -1, lpmliW->szShortName, + sizeof(lpmliW->szShortName)/sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, mliA.szName, -1, lpmliW->szName, + sizeof(lpmliW->szName)/sizeof(WCHAR) ); lpmliW->Target.dwType = mliA.Target.dwType; lpmliW->Target.dwDeviceID = mliA.Target.dwDeviceID; lpmliW->Target.wMid = mliA.Target.wMid; lpmliW->Target.wPid = mliA.Target.wPid; lpmliW->Target.vDriverVersion = mliA.Target.vDriverVersion; - lstrcpyAtoW(lpmliW->Target.szPname, mliA.Target.szPname); + MultiByteToWideChar( CP_ACP, 0, mliA.Target.szPname, -1, lpmliW->Target.szPname, + sizeof(lpmliW->Target.szPname)/sizeof(WCHAR) ); return ret; } @@ -1398,7 +1404,8 @@ UINT WINAPI auxGetDevCapsW(UINT uDeviceID, LPAUXCAPSW lpCaps, UINT uSize) lpCaps->wMid = acA.wMid; lpCaps->wPid = acA.wPid; lpCaps->vDriverVersion = acA.vDriverVersion; - lstrcpyAtoW(lpCaps->szPname, acA.szPname); + MultiByteToWideChar( CP_ACP, 0, acA.szPname, -1, lpCaps->szPname, + sizeof(lpCaps->szPname)/sizeof(WCHAR) ); lpCaps->wTechnology = acA.wTechnology; lpCaps->dwSupport = acA.dwSupport; return ret; @@ -1538,7 +1545,7 @@ BOOL WINAPI mciGetErrorStringW(DWORD wError, LPWSTR lpstrBuffer, UINT uLength) LPSTR bufstr = HeapAlloc(GetProcessHeap(), 0, uLength); BOOL ret = mciGetErrorStringA(wError, bufstr, uLength); - lstrcpyAtoW(lpstrBuffer, bufstr); + MultiByteToWideChar( CP_ACP, 0, bufstr, -1, lpstrBuffer, uLength ); HeapFree(GetProcessHeap(), 0, bufstr); return ret; } @@ -1956,7 +1963,8 @@ UINT WINAPI midiOutGetDevCapsW(UINT uDeviceID, LPMIDIOUTCAPSW lpCaps, lpCaps->wMid = mocA.wMid; lpCaps->wPid = mocA.wPid; lpCaps->vDriverVersion = mocA.vDriverVersion; - lstrcpyAtoW(lpCaps->szPname, mocA.szPname); + MultiByteToWideChar( CP_ACP, 0, mocA.szPname, -1, lpCaps->szPname, + sizeof(lpCaps->szPname)/sizeof(WCHAR) ); lpCaps->wTechnology = mocA.wTechnology; lpCaps->wVoices = mocA.wVoices; lpCaps->wNotes = mocA.wNotes; @@ -2051,7 +2059,7 @@ UINT WINAPI midiOutGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize) UINT ret; ret = MIDI_GetErrorText(uError, xstr, uSize); - lstrcpyAtoW(lpText, xstr); + MultiByteToWideChar( CP_ACP, 0, xstr, -1, lpText, uSize ); HeapFree(GetProcessHeap(), 0, xstr); return ret; } @@ -2537,7 +2545,8 @@ UINT WINAPI midiInGetDevCapsW(UINT uDeviceID, LPMIDIINCAPSW lpCaps, UINT uSize) lpCaps->wMid = micA.wMid; lpCaps->wPid = micA.wPid; lpCaps->vDriverVersion = micA.vDriverVersion; - lstrcpyAtoW(lpCaps->szPname, micA.szPname); + MultiByteToWideChar( CP_ACP, 0, micA.szPname, -1, lpCaps->szPname, + sizeof(lpCaps->szPname)/sizeof(WCHAR) ); lpCaps->dwSupport = micA.dwSupport; } return ret; @@ -2586,7 +2595,7 @@ UINT WINAPI midiInGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize) LPSTR xstr = HeapAlloc(GetProcessHeap(), 0, uSize); UINT ret = MIDI_GetErrorText(uError, xstr, uSize); - lstrcpyAtoW(lpText, xstr); + MultiByteToWideChar( CP_ACP, 0, xstr, -1, lpText, uSize ); HeapFree(GetProcessHeap(), 0, xstr); return ret; } @@ -3765,7 +3774,8 @@ UINT WINAPI waveOutGetDevCapsW(UINT uDeviceID, LPWAVEOUTCAPSW lpCaps, lpCaps->wMid = wocA.wMid; lpCaps->wPid = wocA.wPid; lpCaps->vDriverVersion = wocA.vDriverVersion; - lstrcpyAtoW(lpCaps->szPname, wocA.szPname); + MultiByteToWideChar( CP_ACP, 0, wocA.szPname, -1, lpCaps->szPname, + sizeof(lpCaps->szPname)/sizeof(WCHAR) ); lpCaps->dwFormats = wocA.dwFormats; lpCaps->wChannels = wocA.wChannels; lpCaps->dwSupport = wocA.dwSupport; @@ -3822,7 +3832,7 @@ UINT WINAPI waveOutGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize) LPSTR xstr = HeapAlloc(GetProcessHeap(), 0, uSize); UINT ret = WAVE_GetErrorText(uError, xstr, uSize); - lstrcpyAtoW(lpText, xstr); + MultiByteToWideChar( CP_ACP, 0, xstr, -1, lpText, uSize ); HeapFree(GetProcessHeap(), 0, xstr); return ret; } @@ -4394,7 +4404,8 @@ UINT WINAPI waveInGetDevCapsW(UINT uDeviceID, LPWAVEINCAPSW lpCaps, UINT uSize) lpCaps->wMid = wicA.wMid; lpCaps->wPid = wicA.wPid; lpCaps->vDriverVersion = wicA.vDriverVersion; - lstrcpyAtoW(lpCaps->szPname, wicA.szPname); + MultiByteToWideChar( CP_ACP, 0, wicA.szPname, -1, lpCaps->szPname, + sizeof(lpCaps->szPname)/sizeof(WCHAR) ); lpCaps->dwFormats = wicA.dwFormats; lpCaps->wChannels = wicA.wChannels; } @@ -4455,7 +4466,7 @@ UINT WINAPI waveInGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize) LPSTR txt = HeapAlloc(GetProcessHeap(), 0, uSize); UINT ret = WAVE_GetErrorText(uError, txt, uSize); - lstrcpyAtoW(lpText, txt); + MultiByteToWideChar( CP_ACP, 0, txt, -1, lpText, uSize ); HeapFree(GetProcessHeap(), 0, txt); return ret; } diff --git a/files/directory.c b/files/directory.c index 4559c3ec4c9..7bf312fba0e 100644 --- a/files/directory.c +++ b/files/directory.c @@ -20,7 +20,6 @@ #include "winbase.h" #include "wine/winbase16.h" -#include "wine/winestring.h" #include "windef.h" #include "wingdi.h" #include "wine/winuser16.h" @@ -272,8 +271,13 @@ UINT WINAPI GetWindowsDirectoryA( LPSTR path, UINT count ) */ UINT WINAPI GetWindowsDirectoryW( LPWSTR path, UINT count ) { - if (path) lstrcpynAtoW( path, DIR_Windows.short_name, count ); - return strlen( DIR_Windows.short_name ); + UINT len = MultiByteToWideChar( CP_ACP, 0, DIR_Windows.short_name, -1, NULL, 0 ); + if (path && count) + { + if (!MultiByteToWideChar( CP_ACP, 0, DIR_Windows.short_name, -1, path, count )) + path[count-1] = 0; + } + return len; } @@ -319,8 +323,13 @@ UINT WINAPI GetSystemDirectoryA( LPSTR path, UINT count ) */ UINT WINAPI GetSystemDirectoryW( LPWSTR path, UINT count ) { - if (path) lstrcpynAtoW( path, DIR_System.short_name, count ); - return strlen( DIR_System.short_name ); + UINT len = MultiByteToWideChar( CP_ACP, 0, DIR_System.short_name, -1, NULL, 0 ); + if (path && count) + { + if (!MultiByteToWideChar( CP_ACP, 0, DIR_System.short_name, -1, path, count )) + path[count-1] = 0; + } + return len; } @@ -711,13 +720,18 @@ DWORD WINAPI SearchPathW( LPCWSTR path, LPCWSTR name, LPCWSTR ext, HeapFree( GetProcessHeap(), 0, pathA ); if (!ret) return 0; - lstrcpynAtoW( buffer, full_name.short_name, buflen ); + if (buflen > 0 && !MultiByteToWideChar( CP_ACP, 0, full_name.short_name, -1, buffer, buflen )) + buffer[buflen-1] = 0; res = full_name.long_name + strlen(DRIVE_GetRoot( full_name.short_name[0] - 'A' )); while (*res == '/') res++; if (buflen) { - if (buflen > 3) lstrcpynAtoW( buffer + 3, res, buflen - 3 ); + if (buflen > 3) + { + if (!MultiByteToWideChar( CP_ACP, 0, res, -1, buffer+3, buflen-3 )) + buffer[buflen-1] = 0; + } for (p = buffer; *p; p++) if (*p == '/') *p = '\\'; if (lastpart) { diff --git a/files/dos_fs.c b/files/dos_fs.c index 5e8d88fee26..de2eb3d2694 100644 --- a/files/dos_fs.c +++ b/files/dos_fs.c @@ -23,9 +23,9 @@ #include "windef.h" #include "ntddk.h" +#include "winnls.h" #include "wine/winbase16.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "winerror.h" #include "drive.h" #include "file.h" @@ -1079,8 +1079,8 @@ DWORD WINAPI GetShortPathNameW( LPCWSTR longpath, LPWSTR shortpath, shortpathA = HeapAlloc ( GetProcessHeap(), 0, shortlen ); ret = GetShortPathNameA ( longpathA, shortpathA, shortlen ); - lstrcpynAtoW ( shortpath, shortpathA, shortlen ); - + if (shortlen > 0 && !MultiByteToWideChar( CP_ACP, 0, shortpathA, -1, shortpath, shortlen )) + shortpath[shortlen-1] = 0; HeapFree( GetProcessHeap(), 0, longpathA ); HeapFree( GetProcessHeap(), 0, shortpathA ); @@ -1158,7 +1158,9 @@ DWORD WINAPI GetLongPathNameW( LPCWSTR shortpath, LPWSTR longpath, if (DOSFS_GetFullName( shortpathA, TRUE, &full_name )) { ret = strlen( full_name.short_name ); - lstrcpynAtoW( longpath, full_name.long_name, longlen ); + if (longlen > 0 && !MultiByteToWideChar( CP_ACP, 0, full_name.long_name, -1, + longpath, longlen )) + longpath[longlen-1] = 0; } HeapFree( GetProcessHeap(), 0, shortpathA ); return ret; @@ -1308,7 +1310,7 @@ static DWORD DOSFS_DoGetFullPathName( LPCSTR name, DWORD len, LPSTR result, if (result) { if (unicode) - lstrcpynAtoW( (LPWSTR)result, full_name.short_name, len ); + MultiByteToWideChar( CP_ACP, 0, full_name.short_name, -1, (LPWSTR)result, len ); else lstrcpynA( result, full_name.short_name, len ); } @@ -2138,18 +2140,15 @@ DWORD WINAPI QueryDosDeviceA(LPCSTR devname,LPSTR target,DWORD bufsize) TRACE("(%s,...)\n", devname ? devname : ""); if (!devname) { /* return known MSDOS devices */ - strcpy(buffer,"CON COM1 COM2 LPT1 NUL "); - while ((s=strchr(buffer,' '))) - *s='\0'; - - lstrcpynA(target,buffer,bufsize); - return strlen(buffer); + static const char devices[24] = "CON\0COM1\0COM2\0LPT1\0NUL\0\0"; + memcpy( target, devices, min(bufsize,sizeof(devices)) ); + return min(bufsize,sizeof(devices)); } strcpy(buffer,"\\DEV\\"); strcat(buffer,devname); if ((s=strchr(buffer,':'))) *s='\0'; lstrcpynA(target,buffer,bufsize); - return strlen(buffer); + return strlen(buffer)+1; } @@ -2164,7 +2163,7 @@ DWORD WINAPI QueryDosDeviceW(LPCWSTR devname,LPWSTR target,DWORD bufsize) LPSTR targetA = (LPSTR)HeapAlloc(GetProcessHeap(),0,bufsize); DWORD ret = QueryDosDeviceA(devnameA,targetA,bufsize); - lstrcpynAtoW(target,targetA,bufsize); + ret = MultiByteToWideChar( CP_ACP, 0, targetA, ret, target, bufsize ); if (devnameA) HeapFree(GetProcessHeap(),0,devnameA); if (targetA) HeapFree(GetProcessHeap(),0,targetA); return ret; diff --git a/files/drive.c b/files/drive.c index fe79baebf9a..9ced6710a52 100644 --- a/files/drive.c +++ b/files/drive.c @@ -41,7 +41,6 @@ #include "winbase.h" #include "ntddk.h" #include "wine/winbase16.h" /* for GetCurrentTask */ -#include "wine/winestring.h" /* for lstrcpyAtoW */ #include "winerror.h" #include "drive.h" #include "cdrom.h" @@ -1286,7 +1285,7 @@ UINT WINAPI GetCurrentDirectoryW( UINT buflen, LPWSTR buf ) { LPSTR xpath = HeapAlloc( GetProcessHeap(), 0, buflen+1 ); UINT ret = GetCurrentDirectoryA( buflen, xpath ); - if (ret < buflen) lstrcpyAtoW ( buf, xpath ); + if (ret < buflen) ret = MultiByteToWideChar( CP_ACP, 0, xpath, -1, buf, buflen ) - 1; HeapFree( GetProcessHeap(), 0, xpath ); return ret; } @@ -1495,8 +1494,8 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, fsname_len ); if (ret) { - if (label) lstrcpyAtoW( label, xvolname ); - if (fsname) lstrcpyAtoW( fsname, xfsname ); + if (label) MultiByteToWideChar( CP_ACP, 0, xvolname, -1, label, label_len ); + if (fsname) MultiByteToWideChar( CP_ACP, 0, xfsname, -1, fsname, fsname_len ); } HeapFree( GetProcessHeap(), 0, xroot ); HeapFree( GetProcessHeap(), 0, xvolname ); diff --git a/files/file.c b/files/file.c index 3639a210faf..11971621cd4 100644 --- a/files/file.c +++ b/files/file.c @@ -35,7 +35,6 @@ #include "windef.h" #include "winbase.h" #include "wine/winbase16.h" -#include "wine/winestring.h" #include "drive.h" #include "file.h" #include "global.h" @@ -841,7 +840,7 @@ UINT WINAPI GetTempFileNameW( LPCWSTR path, LPCWSTR prefix, UINT unique, patha = HEAP_strdupWtoA( GetProcessHeap(), 0, path ); prefixa = HEAP_strdupWtoA( GetProcessHeap(), 0, prefix ); ret = FILE_GetTempFileName( patha, prefixa, unique, buffera, FALSE ); - lstrcpyAtoW( buffer, buffera ); + MultiByteToWideChar( CP_ACP, 0, buffera, -1, buffer, MAX_PATH ); HeapFree( GetProcessHeap(), 0, patha ); HeapFree( GetProcessHeap(), 0, prefixa ); return ret; diff --git a/files/profile.c b/files/profile.c index 14720380477..c93833277b2 100644 --- a/files/profile.c +++ b/files/profile.c @@ -14,12 +14,11 @@ #include #include +#include "windef.h" #include "winbase.h" +#include "winnls.h" #include "winerror.h" #include "wine/winbase16.h" -#include "wine/winestring.h" -#include "windef.h" -#include "winnls.h" #include "winreg.h" #include "file.h" #include "heap.h" @@ -1226,7 +1225,8 @@ INT WINAPI GetPrivateProfileStringW( LPCWSTR section, LPCWSTR entry, LPSTR bufferA = HeapAlloc( GetProcessHeap(), 0, len ); INT ret = GetPrivateProfileStringA( sectionA, entryA, def_valA, bufferA, len, filenameA ); - lstrcpynAtoW( buffer, bufferA, len ); + if (len > 0 && !MultiByteToWideChar( CP_ACP, 0, bufferA, -1, buffer, len )) + buffer[len-1] = 0; HeapFree( GetProcessHeap(), 0, sectionA ); HeapFree( GetProcessHeap(), 0, entryA ); HeapFree( GetProcessHeap(), 0, filenameA ); @@ -1603,7 +1603,8 @@ DWORD WINAPI GetPrivateProfileSectionNamesW( LPWSTR buffer, DWORD size, LPSTR bufferA = HeapAlloc( GetProcessHeap(), 0, size); INT ret = GetPrivateProfileSectionNames16 (bufferA, size, filenameA); - lstrcpynAtoW( buffer, bufferA, size); + if (size > 0 && !MultiByteToWideChar( CP_ACP, 0, bufferA, -1, buffer, size )) + buffer[size-1] = 0; HeapFree( GetProcessHeap(), 0, bufferA); HeapFree( GetProcessHeap(), 0, filenameA ); @@ -1707,7 +1708,8 @@ BOOL WINAPI GetPrivateProfileStructW (LPCWSTR section, LPCWSTR key, INT ret = GetPrivateProfileStructA( sectionA, keyA, bufferA, len, filenameA ); - lstrcpynAtoW( buffer, bufferA, len ); + if (len > 0 && !MultiByteToWideChar( CP_ACP, 0, bufferA, -1, buffer, len )) + ((LPWSTR)buffer)[len-1] = 0; HeapFree( GetProcessHeap(), 0, bufferA); HeapFree( GetProcessHeap(), 0, sectionA ); HeapFree( GetProcessHeap(), 0, keyA ); diff --git a/graphics/enhmetafiledrv/init.c b/graphics/enhmetafiledrv/init.c index 5af5a0e866e..0e39de4096f 100644 --- a/graphics/enhmetafiledrv/init.c +++ b/graphics/enhmetafiledrv/init.c @@ -13,7 +13,6 @@ #include "global.h" #include "enhmetafile.h" #include "enhmetafiledrv.h" -#include "wine/winestring.h" #include "debugtools.h" DEFAULT_DEBUG_CHANNEL(enhmetafile); @@ -211,7 +210,7 @@ HDC WINAPI CreateEnhMetaFileA( LPWSTR filenameW = NULL; LPWSTR descriptionW = NULL; HDC hReturnDC; - DWORD len1, len2; + DWORD len1, len2, total; if(filename) filenameW = HEAP_strdupAtoW( GetProcessHeap(), 0, filename ); @@ -219,10 +218,9 @@ HDC WINAPI CreateEnhMetaFileA( if(description) { len1 = strlen(description); len2 = strlen(description + len1 + 1); - descriptionW = HeapAlloc( GetProcessHeap(), 0, (len1 + len2 + 3) * 2); - lstrcpyAtoW(descriptionW, description ); - lstrcpyAtoW(descriptionW + len1 + 1 , description + len1 + 1); - *(descriptionW + len1 + len2 + 2) = 0; + total = MultiByteToWideChar( CP_ACP, 0, description, len1 + len2 + 3, NULL, 0 ); + descriptionW = HeapAlloc( GetProcessHeap(), 0, total * sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, description, len1 + len2 + 3, descriptionW, total ); } hReturnDC = CreateEnhMetaFileW(hdc, filenameW, rect, descriptionW); diff --git a/graphics/metafiledrv/text.c b/graphics/metafiledrv/text.c index ed13b225731..50c3463fe18 100644 --- a/graphics/metafiledrv/text.c +++ b/graphics/metafiledrv/text.c @@ -8,7 +8,6 @@ #include #include "windef.h" -#include "wine/winestring.h" #include "metafiledrv.h" #include "debugtools.h" #include "heap.h" @@ -69,6 +68,7 @@ MFDRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags, BOOL ret; int i; LPSTR ascii; + DWORD len; if(lpDx) lpdx16 = HeapAlloc( GetProcessHeap(), 0, sizeof(INT16)*count ); @@ -76,9 +76,10 @@ MFDRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags, if (lpdx16) for (i=count;i--;) lpdx16[i]=lpDx[i]; - ascii = HeapAlloc( GetProcessHeap(), 0, count+1 ); - lstrcpynWtoA(ascii, str, count+1); - ret = MFDRV_MetaExtTextOut(dc,x,y,flags,lprect?&rect16:NULL,ascii,count, + len = WideCharToMultiByte( CP_ACP, 0, str, count, NULL, 0, NULL, NULL ); + ascii = HeapAlloc( GetProcessHeap(), 0, len ); + WideCharToMultiByte( CP_ACP, 0, str, count, ascii, len, NULL, NULL ); + ret = MFDRV_MetaExtTextOut(dc,x,y,flags,lprect?&rect16:NULL,ascii,len, lpdx16); HeapFree( GetProcessHeap(), 0, ascii ); if (lpdx16) HeapFree( GetProcessHeap(), 0, lpdx16 ); diff --git a/graphics/win16drv/font.c b/graphics/win16drv/font.c index 3cc2418911f..945856dc6e1 100644 --- a/graphics/win16drv/font.c +++ b/graphics/win16drv/font.c @@ -6,8 +6,8 @@ */ #include +#include "winnls.h" #include "wine/winbase16.h" -#include "wine/winestring.h" #include "win16drv.h" #include "module.h" #include "font.h" @@ -25,17 +25,19 @@ BOOL WIN16DRV_GetTextExtentPoint( DC *dc, LPCWSTR wstr, INT count, LPSIZE size ) { WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev; - DWORD dwRet; + DWORD dwRet, len; char *str; TRACE("%04x %s %d %p\n", dc->hSelf, debugstr_wn(wstr, count), count, size); - str = HeapAlloc( GetProcessHeap(), 0, count+1 ); - lstrcpynWtoA( str, wstr, count+1 ); + + len = WideCharToMultiByte( CP_ACP, 0, wstr, count, NULL, 0, NULL, NULL ); + str = HeapAlloc( GetProcessHeap(), 0, len ); + WideCharToMultiByte( CP_ACP, 0, wstr, count, str, len, NULL, NULL ); + dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE, 0, 0, - NULL, str, - -count, physDev->FontInfo, + NULL, str, -len, physDev->FontInfo, win16drv_SegPtr_DrawMode, win16drv_SegPtr_TextXForm, NULL, NULL, 0); size->cx = XDSTOLS(dc,LOWORD(dwRet)); diff --git a/graphics/win16drv/text.c b/graphics/win16drv/text.c index 171b15e9c01..de289d027dc 100644 --- a/graphics/win16drv/text.c +++ b/graphics/win16drv/text.c @@ -10,7 +10,7 @@ #include "gdi.h" #include "debugtools.h" #include "winbase.h" -#include "wine/winestring.h" +#include "winnls.h" DEFAULT_DEBUG_CHANNEL(win16drv); @@ -27,7 +27,7 @@ BOOL WIN16DRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags, RECT16 opaqueRect; RECT16 *lpOpaqueRect = NULL; WORD wOptions = 0; - WORD wCount = count; + DWORD len; INT16 width; char *str; DWORD dwRet; @@ -38,8 +38,9 @@ BOOL WIN16DRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags, TRACE("%04x %d %d %x %p %s %p\n", dc->hSelf, x, y, flags, lprect, debugstr_wn(wstr, count), lpDx); - str = HeapAlloc( GetProcessHeap(), 0, count+1 ); - lstrcpynWtoA( str, wstr, count+1 ); + len = WideCharToMultiByte( CP_ACP, 0, wstr, count, NULL, 0, NULL, NULL ); + str = HeapAlloc( GetProcessHeap(), 0, len ); + WideCharToMultiByte( CP_ACP, 0, wstr, count, str, len, NULL, NULL ); clipRect.left = 0; clipRect.top = 0; @@ -65,7 +66,7 @@ BOOL WIN16DRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags, y = YLPTODP( dc, y ); dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE, 0, 0, - NULL, str, -count, physDev->FontInfo, + NULL, str, -len, physDev->FontInfo, win16drv_SegPtr_DrawMode, win16drv_SegPtr_TextXForm, NULL, NULL, 0); @@ -99,7 +100,7 @@ BOOL WIN16DRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags, } dwRet = PRTDRV_ExtTextOut(physDev->segptrPDEVICE, - x, y, &clipRect, str, wCount, + x, y, &clipRect, str, (WORD)len, physDev->FontInfo, win16drv_SegPtr_DrawMode, win16drv_SegPtr_TextXForm, NULL, lpOpaqueRect, wOptions); diff --git a/if1632/builtin.c b/if1632/builtin.c index e125bccb192..54c34032325 100644 --- a/if1632/builtin.c +++ b/if1632/builtin.c @@ -10,7 +10,6 @@ #include #include "winbase.h" #include "wine/winbase16.h" -#include "wine/winestring.h" #include "builtin16.h" #include "global.h" #include "heap.h" diff --git a/include/wine/winestring.h b/include/wine/winestring.h deleted file mode 100644 index dcfe38724f3..00000000000 --- a/include/wine/winestring.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __WINE_WINE_WINESTRING_H -#define __WINE_WINE_WINESTRING_H - -#include "windef.h" -#include "winnls.h" - -LPWSTR WINAPI lstrcpynAtoW(LPWSTR,LPCSTR,INT); -LPSTR WINAPI lstrcpynWtoA(LPSTR,LPCWSTR,INT); - -/* compatibility macros; will be removed some day, please don't use them */ -#define lstrcpyAtoW(dst,src) ((void)MultiByteToWideChar(CP_ACP,0,(src),-1,(dst),0x7fffffff)) -#define lstrcpyWtoA(dst,src) ((void)WideCharToMultiByte(CP_ACP,0,(src),-1,(dst),0x7fffffff,NULL,NULL)) - -#endif /* __WINE_WINE_WINESTRING_H */ diff --git a/loader/module.c b/loader/module.c index af249b69b02..35b2abe5c33 100644 --- a/loader/module.c +++ b/loader/module.c @@ -12,7 +12,6 @@ #include #include #include "wine/winbase16.h" -#include "wine/winestring.h" #include "winerror.h" #include "heap.h" #include "neexe.h" @@ -1212,7 +1211,8 @@ DWORD WINAPI GetModuleFileNameW( HMODULE hModule, LPWSTR lpFileName, { LPSTR fnA = (char*)HeapAlloc( GetProcessHeap(), 0, size ); DWORD res = GetModuleFileNameA( hModule, fnA, size ); - lstrcpynAtoW( lpFileName, fnA, size ); + if (size > 0 && !MultiByteToWideChar( CP_ACP, 0, fnA, -1, lpFileName, size )) + lpFileName[size-1] = 0; HeapFree( GetProcessHeap(), 0, fnA ); return res; } diff --git a/loader/ne/convert.c b/loader/ne/convert.c index 6e8038e4d13..70b7c21918e 100644 --- a/loader/ne/convert.c +++ b/loader/ne/convert.c @@ -9,7 +9,6 @@ #include "wingdi.h" #include "wine/winuser16.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "module.h" #include "debugtools.h" @@ -47,7 +46,7 @@ VOID WINAPI ConvertDialog32To16( LPVOID dialog32, DWORD size, LPVOID dialog16 ) case 0x0000: ((WORD *)p)++; *((BYTE *)dialog16)++ = 0; break; case 0xffff: ((WORD *)p)++; *((BYTE *)dialog16)++ = 0xff; *((WORD *)dialog16)++ = *((WORD *)p)++; break; - default: lstrcpyWtoA( (LPSTR)dialog16, (LPWSTR)p ); + default: WideCharToMultiByte( CP_ACP, 0, (LPWSTR)p, -1, (LPSTR)dialog16, 0x7fffffff, NULL,NULL ); ((LPSTR)dialog16) += strlen( (LPSTR)dialog16 ) + 1; ((LPWSTR)p) += strlenW( (LPWSTR)p ) + 1; break; @@ -59,14 +58,14 @@ VOID WINAPI ConvertDialog32To16( LPVOID dialog32, DWORD size, LPVOID dialog16 ) case 0x0000: ((WORD *)p)++; *((BYTE *)dialog16)++ = 0; break; case 0xffff: ((WORD *)p)++; *((BYTE *)dialog16)++ = 0xff; *((WORD *)dialog16)++ = *((WORD *)p)++; break; - default: lstrcpyWtoA( (LPSTR)dialog16, (LPWSTR)p ); + default: WideCharToMultiByte( CP_ACP, 0, (LPWSTR)p, -1, (LPSTR)dialog16, 0x7fffffff, NULL,NULL ); ((LPSTR)dialog16) += strlen( (LPSTR)dialog16 ) + 1; ((LPWSTR)p) += strlenW( (LPWSTR)p ) + 1; break; } /* Transfer window caption */ - lstrcpyWtoA( (LPSTR)dialog16, (LPWSTR)p ); + WideCharToMultiByte( CP_ACP, 0, (LPWSTR)p, -1, (LPSTR)dialog16, 0x7fffffff, NULL,NULL ); ((LPSTR)dialog16) += strlen( (LPSTR)dialog16 ) + 1; ((LPWSTR)p) += strlenW( (LPWSTR)p ) + 1; @@ -79,7 +78,7 @@ VOID WINAPI ConvertDialog32To16( LPVOID dialog32, DWORD size, LPVOID dialog16 ) *((WORD *)dialog16)++ = *((WORD *)p)++; /* weight */ *((WORD *)dialog16)++ = *((WORD *)p)++; /* italic */ } - lstrcpyWtoA( (LPSTR)dialog16, (LPWSTR)p ); /* faceName */ + WideCharToMultiByte( CP_ACP, 0, (LPWSTR)p, -1, (LPSTR)dialog16, 0x7fffffff, NULL,NULL ); /* faceName */ ((LPSTR)dialog16) += strlen( (LPSTR)dialog16 ) + 1; ((LPWSTR)p) += strlenW( (LPWSTR)p ) + 1; } @@ -121,7 +120,7 @@ VOID WINAPI ConvertDialog32To16( LPVOID dialog32, DWORD size, LPVOID dialog16 ) case 0x0000: ((WORD *)p)++; *((BYTE *)dialog16)++ = 0; break; case 0xffff: ((WORD *)p)++; *((BYTE *)dialog16)++ = (BYTE)*((WORD *)p)++; break; - default: lstrcpyWtoA( (LPSTR)dialog16, (LPWSTR)p ); + default: WideCharToMultiByte( CP_ACP, 0, (LPWSTR)p, -1, (LPSTR)dialog16, 0x7fffffff, NULL,NULL ); ((LPSTR)dialog16) += strlen( (LPSTR)dialog16 ) + 1; ((LPWSTR)p) += strlenW( (LPWSTR)p ) + 1; break; @@ -133,7 +132,7 @@ VOID WINAPI ConvertDialog32To16( LPVOID dialog32, DWORD size, LPVOID dialog16 ) case 0x0000: ((WORD *)p)++; *((BYTE *)dialog16)++ = 0; break; case 0xffff: ((WORD *)p)++; *((BYTE *)dialog16)++ = 0xff; *((WORD *)dialog16)++ = *((WORD *)p)++; break; - default: lstrcpyWtoA( (LPSTR)dialog16, (LPWSTR)p ); + default: WideCharToMultiByte( CP_ACP, 0, (LPWSTR)p, -1, (LPSTR)dialog16, 0x7fffffff, NULL,NULL ); ((LPSTR)dialog16) += strlen( (LPSTR)dialog16 ) + 1; ((LPWSTR)p) += strlenW( (LPWSTR)p ) + 1; break; @@ -296,7 +295,7 @@ VOID WINAPI ConvertMenu32To16( LPVOID menu32, DWORD size, LPVOID menu16 ) else level++; - lstrcpyWtoA( (LPSTR)menu16, (LPWSTR)p ); + WideCharToMultiByte( CP_ACP, 0, (LPWSTR)p, -1, (LPSTR)menu16, 0x7fffffff, NULL,NULL ); ((LPSTR)menu16) += strlen( (LPSTR)menu16 ) + 1; ((LPWSTR)p) += strlenW( (LPWSTR)p ) + 1; @@ -310,7 +309,7 @@ VOID WINAPI ConvertMenu32To16( LPVOID menu32, DWORD size, LPVOID menu16 ) *((WORD *)menu16)++ = (WORD)*((DWORD *)p)++; /* ID */ flags = *((BYTE *)menu16)++ = (BYTE)*((WORD *)p)++; - lstrcpyWtoA( (LPSTR)menu16, (LPWSTR)p ); + WideCharToMultiByte( CP_ACP, 0, (LPWSTR)p, -1, (LPSTR)menu16, 0x7fffffff, NULL,NULL ); ((LPSTR)menu16) += strlen( (LPSTR)menu16 ) + 1; ((LPWSTR)p) += strlenW( (LPWSTR)p ) + 1; diff --git a/loader/pe_resource.c b/loader/pe_resource.c index 29009fcadde..296fdb9cea2 100644 --- a/loader/pe_resource.c +++ b/loader/pe_resource.c @@ -13,7 +13,6 @@ #include #include -#include "wine/winestring.h" #include "wine/unicode.h" #include "windef.h" #include "winnls.h" diff --git a/memory/environ.c b/memory/environ.c index e6864e00976..67f8d2c606e 100644 --- a/memory/environ.c +++ b/memory/environ.c @@ -7,11 +7,11 @@ #include #include #include "windef.h" -#include "wine/winestring.h" +#include "winnls.h" +#include "winerror.h" #include "process.h" #include "heap.h" #include "selectors.h" -#include "winerror.h" /* Format of an environment block: * ASCIIZ string 1 (xx=yy format) @@ -259,7 +259,8 @@ DWORD WINAPI GetEnvironmentVariableW( LPCWSTR nameW, LPWSTR valW, DWORD size) HeapFree( GetProcessHeap(), 0, name ); if (val) { - lstrcpynAtoW( valW, val, size ); + if (size > 0 && !MultiByteToWideChar( CP_ACP, 0, val, -1, valW, size )) + valW[size-1] = 0; HeapFree( GetProcessHeap(), 0, val ); } return res; @@ -416,7 +417,7 @@ DWORD WINAPI ExpandEnvironmentStringsW( LPCWSTR src, LPWSTR dst, DWORD len ) DWORD ret = ExpandEnvironmentStringsA( srcA, dstA, len ); if (dstA) { - lstrcpyAtoW( dst, dstA ); + ret = MultiByteToWideChar( CP_ACP, 0, dstA, -1, dst, len ); HeapFree( GetProcessHeap(), 0, dstA ); } HeapFree( GetProcessHeap(), 0, srcA ); diff --git a/memory/registry.c b/memory/registry.c index 5018e83d099..6cc1023ab39 100644 --- a/memory/registry.c +++ b/memory/registry.c @@ -21,7 +21,6 @@ #include "winerror.h" #include "wine/winbase16.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "heap.h" #include "server.h" #include "debugtools.h" diff --git a/memory/string.c b/memory/string.c index 1ae11356649..cdd22bd5bcf 100644 --- a/memory/string.c +++ b/memory/string.c @@ -306,33 +306,6 @@ INT WINAPI lstrlenW( LPCWSTR str ) } -/*********************************************************************** - * lstrcpynAtoW (Not a Windows API) - * Note: this function differs from the UNIX strncpy, it _always_ writes - * a terminating \0 - */ -LPWSTR WINAPI lstrcpynAtoW( LPWSTR dst, LPCSTR src, INT n ) -{ - if (n > 0 && !MultiByteToWideChar( CP_ACP, 0, src, -1, dst, n )) dst[n-1] = 0; - return dst; -} - - -/*********************************************************************** - * lstrcpynWtoA (Not a Windows API) - * Note: this function differs from the UNIX strncpy, it _always_ writes - * a terminating \0 - * - * The terminating zero should be written at the end of the string, not - * the end of the buffer, as some programs specify the wrong size for - * the buffer (eg. winnt's sol.exe) - */ -LPSTR WINAPI lstrcpynWtoA( LPSTR dst, LPCWSTR src, INT n ) -{ - if (n > 0 && !WideCharToMultiByte( CP_ACP, 0, src, -1, dst, n, NULL, NULL )) dst[n-1] = 0; - return dst; -} - /*********************************************************************** * UnicodeToAnsi (KERNEL.434) */ diff --git a/misc/cdrom.c b/misc/cdrom.c index 6795e12ac16..f7c6f7a3ada 100644 --- a/misc/cdrom.c +++ b/misc/cdrom.c @@ -13,11 +13,11 @@ #include #include #include +#include "winnls.h" #include "cdrom.h" #include "drive.h" #include "debugtools.h" #include "winbase.h" -#include "wine/winestring.h" DEFAULT_DEBUG_CHANNEL(cdrom); @@ -812,7 +812,8 @@ DWORD CDROM_Data_GetLabel(WINE_CDAUDIO* wcda, char *label, int parentdev) ch = label_read[i]; label_read[i] = (ch << 8) | (ch >> 8); } - lstrcpynWtoA(label, label_read, 11); + WideCharToMultiByte( CP_ACP, 0, label_read, -1, label, 12, NULL, NULL ); + label[11] = 0; } else { diff --git a/misc/cpu.c b/misc/cpu.c index cac097f15cb..c27e1e83806 100644 --- a/misc/cpu.c +++ b/misc/cpu.c @@ -9,7 +9,6 @@ #include #include #include "winbase.h" -#include "wine/winestring.h" #include "winreg.h" #include "global.h" #include "winnt.h" diff --git a/misc/version.c b/misc/version.c index 09caf3f381e..ec742e78e07 100644 --- a/misc/version.c +++ b/misc/version.c @@ -15,7 +15,6 @@ #include "wingdi.h" #include "winuser.h" #include "wine/winbase16.h" -#include "wine/winestring.h" #include "process.h" #include "options.h" #include "debugtools.h" @@ -450,7 +449,8 @@ BOOL WINAPI GetVersionExW(OSVERSIONINFOW *v) v->dwMinorVersion = VersionData[ver].getVersionEx.dwMinorVersion; v->dwBuildNumber = VersionData[ver].getVersionEx.dwBuildNumber; v->dwPlatformId = VersionData[ver].getVersionEx.dwPlatformId; - lstrcpyAtoW( v->szCSDVersion, VersionData[ver].getVersionEx.szCSDVersion ); + MultiByteToWideChar( CP_ACP, 0, VersionData[ver].getVersionEx.szCSDVersion, -1, + v->szCSDVersion, sizeof(v->szCSDVersion)/sizeof(WCHAR) ); return TRUE; } diff --git a/objects/enhmetafile.c b/objects/enhmetafile.c index 70d880ae209..0890f4aa112 100644 --- a/objects/enhmetafile.c +++ b/objects/enhmetafile.c @@ -18,9 +18,9 @@ #include #include +#include "winnls.h" #include "winbase.h" #include "wingdi.h" -#include "wine/winestring.h" #include "winerror.h" #include "enhmetafile.h" #include "debugtools.h" @@ -197,29 +197,26 @@ UINT WINAPI GetEnhMetaFileDescriptionA( ) { LPENHMETAHEADER emh = EMF_GetEnhMetaHeader(hmf); - INT first, first_A; - + DWORD len; + WCHAR *descrW; + if(!emh) return FALSE; if(emh->nDescription == 0 || emh->offDescription == 0) { EMF_ReleaseEnhMetaHeader(hmf); return 0; } + descrW = (WCHAR *) ((char *) emh + emh->offDescription); + len = WideCharToMultiByte( CP_ACP, 0, descrW, emh->nDescription, NULL, 0, NULL, NULL ); + if (!buf || !size ) { EMF_ReleaseEnhMetaHeader(hmf); - return emh->nDescription; + return len; } - - first = lstrlenW( (WCHAR *) ((char *) emh + emh->offDescription)); - - lstrcpynWtoA(buf, (WCHAR *) ((char *) emh + emh->offDescription), size); - first_A = strlen( buf ); - buf += first_A + 1; - lstrcpynWtoA(buf, (WCHAR *) ((char *) emh + emh->offDescription+2*(first+1)), - size - first_A - 1); /* i18n ready */ - first_A += strlen(buf) + 1; - + + len = min( size, len ); + WideCharToMultiByte( CP_ACP, 0, descrW, emh->nDescription, buf, len, NULL, NULL ); EMF_ReleaseEnhMetaHeader(hmf); - return min(size, first_A); + return len; } /***************************************************************************** @@ -250,7 +247,7 @@ UINT WINAPI GetEnhMetaFileDescriptionW( } memmove(buf, (char *) emh + emh->offDescription, - min(size,emh->nDescription)); + min(size,emh->nDescription)*sizeof(WCHAR)); EMF_ReleaseEnhMetaHeader(hmf); return min(size, emh->nDescription); } diff --git a/objects/font.c b/objects/font.c index 45821271409..9a3dbbd1941 100644 --- a/objects/font.c +++ b/objects/font.c @@ -7,15 +7,14 @@ #include #include -#include "wine/winestring.h" +#include "winerror.h" +#include "winnls.h" #include "font.h" #include "heap.h" #include "metafile.h" #include "options.h" #include "debugtools.h" -#include "winerror.h" #include "gdi.h" -#include "winnls.h" DEFAULT_DEBUG_CHANNEL(font); DECLARE_DEBUG_CHANNEL(gdi); @@ -126,7 +125,9 @@ void FONT_LogFont32WTo16( const LOGFONTW* font32, LPLOGFONT16 font16 ) font16->lfClipPrecision = font32->lfClipPrecision; font16->lfQuality = font32->lfQuality; font16->lfPitchAndFamily = font32->lfPitchAndFamily; - lstrcpynWtoA( font16->lfFaceName, font32->lfFaceName, LF_FACESIZE ); + WideCharToMultiByte( CP_ACP, 0, font32->lfFaceName, -1, + font16->lfFaceName, LF_FACESIZE, NULL, NULL ); + font16->lfFaceName[LF_FACESIZE-1] = 0; } void FONT_LogFont16To32A( const LPLOGFONT16 font16, LPLOGFONTA font32 ) @@ -162,7 +163,8 @@ void FONT_LogFont16To32W( const LPLOGFONT16 font16, LPLOGFONTW font32 ) font32->lfClipPrecision = font16->lfClipPrecision; font32->lfQuality = font16->lfQuality; font32->lfPitchAndFamily = font16->lfPitchAndFamily; - lstrcpynAtoW( font32->lfFaceName, font16->lfFaceName, LF_FACESIZE ); + MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE ); + font32->lfFaceName[LF_FACESIZE-1] = 0; } void FONT_EnumLogFontEx16To32A( const LPENUMLOGFONTEX16 font16, LPENUMLOGFONTEXA font32 ) @@ -176,9 +178,13 @@ void FONT_EnumLogFontEx16To32A( const LPENUMLOGFONTEX16 font16, LPENUMLOGFONTEXA void FONT_EnumLogFontEx16To32W( const LPENUMLOGFONTEX16 font16, LPENUMLOGFONTEXW font32 ) { FONT_LogFont16To32W( (LPLOGFONT16)font16, (LPLOGFONTW)font32); - lstrcpynAtoW( font32->elfFullName, font16->elfFullName, LF_FULLFACESIZE ); - lstrcpynAtoW( font32->elfStyle, font16->elfStyle, LF_FACESIZE ); - lstrcpynAtoW( font32->elfScript, font16->elfScript, LF_FACESIZE ); + + MultiByteToWideChar( CP_ACP, 0, font16->elfFullName, -1, font32->elfFullName, LF_FULLFACESIZE ); + font32->elfFullName[LF_FULLFACESIZE-1] = 0; + MultiByteToWideChar( CP_ACP, 0, font16->elfStyle, -1, font32->elfStyle, LF_FACESIZE ); + font32->elfStyle[LF_FACESIZE-1] = 0; + MultiByteToWideChar( CP_ACP, 0, font16->elfScript, -1, font32->elfScript, LF_FACESIZE ); + font32->elfScript[LF_FACESIZE-1] = 0; } /*********************************************************************** @@ -603,7 +609,11 @@ static INT FONT_EnumFontFamiliesEx( HDC hDC, LPLOGFONTW plf, FONTENUMPROCEXW efp if( plf->lfFaceName[0] ) { if( dwUnicode ) - lstrcpynWtoA( lf16.lfFaceName, plf->lfFaceName, LF_FACESIZE ); + { + WideCharToMultiByte( CP_ACP, 0, plf->lfFaceName, -1, + lf16.lfFaceName, LF_FACESIZE, NULL, NULL ); + lf16.lfFaceName[LF_FACESIZE-1] = 0; + } else lstrcpynA( lf16.lfFaceName, (LPCSTR)plf->lfFaceName, LF_FACESIZE ); } @@ -846,7 +856,7 @@ INT WINAPI GetTextFaceW( HDC hdc, INT count, LPWSTR name ) { LPSTR nameA = HeapAlloc( GetProcessHeap(), 0, count ); INT res = GetTextFaceA(hdc,count,nameA); - if (name) lstrcpyAtoW( name, nameA ); + if (name) res = MultiByteToWideChar( CP_ACP, 0, nameA, -1, name, count ); HeapFree( GetProcessHeap(), 0, nameA ); return res; } @@ -973,15 +983,12 @@ BOOL WINAPI GetTextExtentExPointA( HDC hdc, LPCSTR str, INT count, INT maxExt, LPINT lpnFit, LPINT alpDx, LPSIZE size ) { - LPWSTR p; BOOL ret; - /* Docs say str should be 0 terminated here, but we'll use count just in case - */ - - p = HeapAlloc( GetProcessHeap(), 0, (count+1) * sizeof(WCHAR) ); - lstrcpynAtoW(p, str, count+1); - ret = GetTextExtentExPointW( hdc, p, count, maxExt, lpnFit, alpDx, size); + DWORD len = MultiByteToWideChar( CP_ACP, 0, str, count, NULL, 0 ); + LPWSTR p = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, str, count, p, len ); + ret = GetTextExtentExPointW( hdc, p, len, maxExt, lpnFit, alpDx, size); HeapFree( GetProcessHeap(), 0, p ); return ret; } diff --git a/ole/ole2nls.c b/ole/ole2nls.c index 31a4be814e2..6ab9edc6d95 100644 --- a/ole/ole2nls.c +++ b/ole/ole2nls.c @@ -15,7 +15,6 @@ #include "wingdi.h" #include "winuser.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "heap.h" #include "options.h" #include "winver.h" diff --git a/win32/console.c b/win32/console.c index ef294a5b024..ad7e1145eee 100644 --- a/win32/console.c +++ b/win32/console.c @@ -35,11 +35,11 @@ #include #include -#include "winbase.h" #include "windef.h" +#include "winbase.h" +#include "winnls.h" #include "wingdi.h" #include "wine/winuser16.h" -#include "wine/winestring.h" #include "wine/keyboard16.h" #include "thread.h" #include "file.h" @@ -49,7 +49,6 @@ #include "heap.h" #include "server.h" #include "debugtools.h" -#include "winnls.h" DEFAULT_DEBUG_CHANNEL(console); @@ -813,9 +812,9 @@ DWORD WINAPI GetConsoleTitleW( LPWSTR title, DWORD size ) char *tmp; DWORD ret; - if (!(tmp = HeapAlloc( GetProcessHeap(), 0, size ))) return 0; - ret = GetConsoleTitleA( tmp, size ); - lstrcpyAtoW( title, tmp ); + if (!(tmp = HeapAlloc( GetProcessHeap(), 0, size*sizeof(WCHAR) ))) return 0; + GetConsoleTitleA( tmp, size*sizeof(WCHAR) ); + ret = MultiByteToWideChar( CP_ACP, 0, tmp, -1, title, size ); HeapFree( GetProcessHeap(), 0, tmp ); return ret; } @@ -1056,7 +1055,8 @@ BOOL WINAPI ReadConsoleW( HANDLE hConsoleInput, lpReserved ); if (ret) - lstrcpynAtoW(lpBuffer,buf,nNumberOfCharsToRead); + MultiByteToWideChar( CP_ACP, 0, buf, -1, lpBuffer, nNumberOfCharsToRead ); + HeapFree( GetProcessHeap(), 0, buf ); return ret; } diff --git a/win32/init.c b/win32/init.c index 63f720b7cfd..11ee01fc18a 100644 --- a/win32/init.c +++ b/win32/init.c @@ -8,8 +8,8 @@ #include #include #include +#include "winnls.h" #include "winerror.h" -#include "wine/winestring.h" #include "wine/exception.h" #include "heap.h" #include "task.h" @@ -55,7 +55,8 @@ BOOL WINAPI GetComputerNameW(LPWSTR name,LPDWORD size) { LPSTR nameA = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *size); BOOL ret = GetComputerNameA(nameA,size); - if (ret) lstrcpynAtoW(name,nameA,*size+1); + /* FIXME: should set *size in Unicode chars */ + if (ret) MultiByteToWideChar( CP_ACP, 0, nameA, -1, name, *size+1 ); HeapFree( GetProcessHeap(), 0, nameA ); return ret; } diff --git a/windows/clipboard.c b/windows/clipboard.c index 0184d4e3e3b..3c3ddd881b8 100644 --- a/windows/clipboard.c +++ b/windows/clipboard.c @@ -28,7 +28,6 @@ #include "winuser.h" #include "wine/winuser16.h" #include "wine/winbase16.h" -#include "wine/winestring.h" #include "heap.h" #include "message.h" #include "task.h" @@ -1131,7 +1130,9 @@ INT WINAPI GetClipboardFormatNameW( UINT wFormat, LPWSTR retStr, INT maxlen ) if(p == NULL) return 0; /* FIXME: is this the correct failure value? */ ret = GetClipboardFormatNameA( wFormat, p, maxlen ); - lstrcpynAtoW( retStr, p, maxlen ); + + if (maxlen > 0 && !MultiByteToWideChar( CP_ACP, 0, p, -1, retStr, maxlen )) + retStr[maxlen-1] = 0; HeapFree( GetProcessHeap(), 0, p ); return ret; } diff --git a/windows/defwnd.c b/windows/defwnd.c index 9bf880ab6eb..cf069a72f2f 100644 --- a/windows/defwnd.c +++ b/windows/defwnd.c @@ -23,7 +23,6 @@ #include "winnls.h" #include "wine/unicode.h" #include "wine/winuser16.h" -#include "wine/winestring.h" DEFAULT_DEBUG_CHANNEL(win); @@ -601,8 +600,10 @@ LRESULT WINAPI DefWindowProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, case WM_GETTEXT: if (wParam && wndPtr->text) { - lstrcpynWtoA( (LPSTR)PTR_SEG_TO_LIN(lParam), wndPtr->text, wParam ); - result = (LRESULT)strlen( (LPSTR)PTR_SEG_TO_LIN(lParam) ); + LPSTR dest = PTR_SEG_TO_LIN(lParam); + if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1, dest, wParam, NULL, NULL )) + dest[wParam-1] = 0; + result = strlen(dest); } break; @@ -665,7 +666,9 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, case WM_GETTEXT: if (wParam && wndPtr->text) { - lstrcpynWtoA( (LPSTR)lParam, wndPtr->text, wParam ); + if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1, + (LPSTR)lParam, wParam, NULL, NULL )) + ((LPSTR)lParam)[wParam-1] = 0; result = (LRESULT)strlen( (LPSTR)lParam ); } break; diff --git a/windows/dialog.c b/windows/dialog.c index fa9caaaf704..ecbc93df6d5 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -11,13 +11,13 @@ #include #include #include "windef.h" +#include "winnls.h" #include "wingdi.h" #include "winuser.h" #include "windowsx.h" #include "wine/winuser16.h" #include "wine/winbase16.h" #include "wine/unicode.h" -#include "wine/winestring.h" #include "dialog.h" #include "drive.h" #include "heap.h" @@ -2196,7 +2196,11 @@ static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len, } else ptr = buffer; - if (unicode) lstrcpynAtoW( (LPWSTR)str, ptr, len ); + if (unicode) + { + if (len > 0 && !MultiByteToWideChar( CP_ACP, 0, ptr, -1, (LPWSTR)str, len )) + ((LPWSTR)str)[len-1] = 0; + } else lstrcpynA( str, ptr, len ); SEGPTR_FREE( buffer ); TRACE("Returning %d '%s'\n", ret, str ); @@ -2317,7 +2321,7 @@ static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox, LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec ); INT ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic, attrib, combo ); - lstrcpyAtoW( spec, specA ); + MultiByteToWideChar( CP_ACP, 0, specA, -1, spec, 0x7fffffff ); HeapFree( GetProcessHeap(), 0, specA ); return ret; } diff --git a/windows/input.c b/windows/input.c index c33a690f81d..147c492d966 100644 --- a/windows/input.c +++ b/windows/input.c @@ -16,11 +16,11 @@ #include #include "windef.h" +#include "winnls.h" #include "wingdi.h" #include "winuser.h" #include "wine/winbase16.h" #include "wine/winuser16.h" -#include "wine/winestring.h" #include "wine/keyboard16.h" #include "win.h" #include "heap.h" @@ -734,9 +734,9 @@ INT WINAPI GetKeyboardLayoutNameA(LPSTR pwszKLID) */ INT WINAPI GetKeyboardLayoutNameW(LPWSTR pwszKLID) { - char buf[9]; + char buf[KL_NAMELENGTH]; int res = GetKeyboardLayoutNameA(buf); - lstrcpyAtoW(pwszKLID,buf); + MultiByteToWideChar( CP_ACP, 0, buf, -1, pwszKLID, KL_NAMELENGTH ); return res; } @@ -758,7 +758,8 @@ INT WINAPI GetKeyNameTextW(LONG lParam, LPWSTR lpBuffer, INT nSize) if(buf == NULL) return 0; /* FIXME: is this the correct failure value?*/ res = GetKeyNameTextA(lParam,buf,nSize); - lstrcpynAtoW(lpBuffer,buf,nSize); + if (nSize > 0 && !MultiByteToWideChar( CP_ACP, 0, buf, -1, lpBuffer, nSize )) + lpBuffer[nSize-1] = 0; HeapFree( GetProcessHeap(), 0, buf ); return res; } @@ -876,7 +877,7 @@ HKL WINAPI LoadKeyboardLayoutW(LPCWSTR pwszKLID, UINT Flags) { char buf[9]; - lstrcpynWtoA(buf,pwszKLID,8); + WideCharToMultiByte( CP_ACP, 0, pwszKLID, -1, buf, sizeof(buf), NULL, NULL ); buf[8] = 0; return LoadKeyboardLayoutA(buf, Flags); } diff --git a/windows/msgbox.c b/windows/msgbox.c index c51f3e2d487..2266a160e46 100644 --- a/windows/msgbox.c +++ b/windows/msgbox.c @@ -10,7 +10,6 @@ #include "wingdi.h" #include "wine/winbase16.h" #include "wine/winuser16.h" -#include "wine/winestring.h" #include "dlgs.h" #include "heap.h" #include "ldt.h" @@ -389,13 +388,9 @@ INT WINAPI MessageBoxIndirectA( LPMSGBOXPARAMSA msgbox ) INT WINAPI MessageBoxIndirectW( LPMSGBOXPARAMSW msgbox ) { MSGBOXPARAMSA msgboxa; - WARN("Messagebox\n"); - memcpy(&msgboxa,msgbox,sizeof(msgboxa)); - if (msgbox->lpszCaption) - lstrcpyWtoA((LPSTR)msgboxa.lpszCaption,msgbox->lpszCaption); - if (msgbox->lpszText) - lstrcpyWtoA((LPSTR)msgboxa.lpszText,msgbox->lpszText); - + msgboxa.lpszCaption = HEAP_strdupWtoA( GetProcessHeap(), 0, msgbox->lpszCaption ); + msgboxa.lpszText = HEAP_strdupWtoA( GetProcessHeap(), 0, msgbox->lpszText ); + msgboxa.lpszIcon = HEAP_strdupWtoA( GetProcessHeap(), 0, msgbox->lpszIcon ); return MessageBoxIndirectA(&msgboxa); } diff --git a/windows/sysparams.c b/windows/sysparams.c index f6724cd02a6..aeebdb18b5b 100644 --- a/windows/sysparams.c +++ b/windows/sysparams.c @@ -9,10 +9,10 @@ #include #include "windef.h" #include "winbase.h" +#include "winnls.h" #include "wingdi.h" #include "winreg.h" #include "wine/winuser16.h" -#include "wine/winestring.h" #include "winerror.h" #include "keyboard.h" @@ -73,7 +73,8 @@ static void SYSPARAMS_LogFont32ATo32W( const LOGFONTA* font32A, LPLOGFONTW font3 font32W->lfClipPrecision = font32A->lfClipPrecision; font32W->lfQuality = font32A->lfQuality; font32W->lfPitchAndFamily = font32A->lfPitchAndFamily; - lstrcpynAtoW( font32W->lfFaceName, font32A->lfFaceName, LF_FACESIZE ); + MultiByteToWideChar( CP_ACP, 0, font32A->lfFaceName, -1, font32W->lfFaceName, LF_FACESIZE ); + font32W->lfFaceName[LF_FACESIZE-1] = 0; } static void SYSPARAMS_NonClientMetrics32ATo16( const NONCLIENTMETRICSA* lpnm32, LPNONCLIENTMETRICS16 lpnm16 ) @@ -639,7 +640,9 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam, { char buffer[256]; if (pvParam) - lstrcpynWtoA( buffer, (LPWSTR)pvParam, sizeof(buffer) ); + if (!WideCharToMultiByte( CP_ACP, 0, (LPWSTR)pvParam, -1, + buffer, sizeof(buffer), NULL, NULL )) + buffer[sizeof(buffer)-1] = 0; ret = SystemParametersInfoA( uiAction, uiParam, pvParam ? buffer : NULL, fuWinIni ); break; } diff --git a/windows/user.c b/windows/user.c index ae81d6d4727..f8d1dff2e35 100644 --- a/windows/user.c +++ b/windows/user.c @@ -10,7 +10,6 @@ #include "windef.h" #include "wingdi.h" #include "winuser.h" -#include "wine/winestring.h" #include "heap.h" #include "user.h" #include "task.h" @@ -469,8 +468,10 @@ BOOL WINAPI EnumDisplayDevicesW( if (i) return FALSE; FIXME_(system)("(%p,%ld,%p,0x%08lx), stub!\n",unused,i,lpDisplayDevice,dwFlags); - lstrcpyAtoW(lpDisplayDevice->DeviceName,"X11"); - lstrcpyAtoW(lpDisplayDevice->DeviceString,"X 11 Windowing System"); + MultiByteToWideChar( CP_ACP, 0, "X11", -1, lpDisplayDevice->DeviceName, + sizeof(lpDisplayDevice->DeviceName)/sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, "X11 Windowing System", -1, lpDisplayDevice->DeviceString, + sizeof(lpDisplayDevice->DeviceString)/sizeof(WCHAR) ); lpDisplayDevice->StateFlags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | diff --git a/windows/winproc.c b/windows/winproc.c index 6598a6e673e..07b3069d324 100644 --- a/windows/winproc.c +++ b/windows/winproc.c @@ -7,10 +7,10 @@ #include #include "windef.h" +#include "winnls.h" #include "wingdi.h" #include "wine/winbase16.h" #include "wine/winuser16.h" -#include "wine/winestring.h" #include "stackframe.h" #include "builtin16.h" #include "heap.h" @@ -700,7 +700,9 @@ void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam case WM_GETTEXT: { LPARAM *ptr = (LPARAM *)lParam - 1; - lstrcpynWtoA( (LPSTR)*ptr, (LPWSTR)lParam, wParam ); + if (wParam > 0 && !WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, + (LPSTR)*ptr, wParam, NULL, NULL )) + ((LPSTR)*ptr)[wParam-1] = 0; HeapFree( GetProcessHeap(), 0, ptr ); } break; @@ -755,7 +757,7 @@ void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam case LB_GETTEXT: { if ( WINPROC_TestLBForStr( hwnd )) { LPARAM *ptr = (LPARAM *)lParam - 1; - lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) ); + WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, (LPSTR)*ptr, 0x7fffffff, NULL, NULL ); HeapFree( GetProcessHeap(), 0, ptr ); } } @@ -771,7 +773,7 @@ void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam case CB_GETLBTEXT: { if ( WINPROC_TestCBForStr( hwnd )) { LPARAM *ptr = (LPARAM *)lParam - 1; - lstrcpyWtoA( (LPSTR)*ptr, (LPWSTR)(lParam) ); + WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, (LPSTR)*ptr, 0x7fffffff, NULL, NULL ); HeapFree( GetProcessHeap(), 0, ptr ); } } @@ -781,7 +783,9 @@ void WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam case EM_GETLINE: { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lParam */ WORD len = *(WORD *) lParam; - lstrcpynWtoA( (LPSTR)*ptr , (LPWSTR)lParam, len ); + if (len > 0 && !WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, + (LPSTR)*ptr, len, NULL, NULL )) + ((LPSTR)*ptr)[len-1] = 0; HeapFree( GetProcessHeap(), 0, ptr ); } break; @@ -937,7 +941,11 @@ void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam case WM_GETTEXT: { LPARAM *ptr = (LPARAM *)lParam - 1; - lstrcpynAtoW( (LPWSTR)*ptr, (LPSTR)lParam, wParam ); + if (wParam) + { + if (!MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, (LPWSTR)*ptr, wParam )) + ((LPWSTR)*ptr)[wParam-1] = 0; + } HeapFree( GetProcessHeap(), 0, ptr ); } break; @@ -987,11 +995,11 @@ void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam break; case LB_GETTEXT: - { if ( WINPROC_TestLBForStr( hwnd )) - { LPARAM *ptr = (LPARAM *)lParam - 1; - lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) ); + if ( WINPROC_TestLBForStr( hwnd )) + { + LPARAM *ptr = (LPARAM *)lParam - 1; + MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, (LPWSTR)*ptr, 0x7fffffff ); HeapFree( GetProcessHeap(), 0, ptr ); - } } break; @@ -1003,11 +1011,11 @@ void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam break; case CB_GETLBTEXT: - { if ( WINPROC_TestCBForStr( hwnd )) - { LPARAM *ptr = (LPARAM *)lParam - 1; - lstrcpyAtoW( (LPWSTR)*ptr, (LPSTR)(lParam) ); + if ( WINPROC_TestCBForStr( hwnd )) + { + LPARAM *ptr = (LPARAM *)lParam - 1; + MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, (LPWSTR)*ptr, 0x7fffffff ); HeapFree( GetProcessHeap(), 0, ptr ); - } } break; @@ -1015,7 +1023,11 @@ void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam case EM_GETLINE: { LPARAM * ptr = (LPARAM *)lParam - 1; /* get the old lparam */ WORD len = *(WORD *)ptr; - lstrcpynAtoW( (LPWSTR) *ptr, (LPSTR)lParam, len ); + if (len) + { + if (!MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, (LPWSTR)*ptr, len )) + ((LPWSTR)*ptr)[len-1] = 0; + } HeapFree( GetProcessHeap(), 0, ptr ); } break; @@ -2291,7 +2303,7 @@ void WINPROC_UnmapMsg32WTo16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, { LPSTR str = (LPSTR)PTR_SEG_TO_LIN(p16->lParam); p16->lParam = *((LPARAM *)str - 1); - lstrcpyAtoW( (LPWSTR)(p16->lParam), str ); + MultiByteToWideChar( CP_ACP, 0, str, -1, (LPWSTR)p16->lParam, 0x7fffffff ); SEGPTR_FREE( (LPARAM *)str - 1 ); } break; @@ -2300,7 +2312,7 @@ void WINPROC_UnmapMsg32WTo16( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, if ( WINPROC_TestLBForStr( hwnd )) { LPSTR str = (LPSTR)PTR_SEG_TO_LIN(p16->lParam); - lstrcpyAtoW( (LPWSTR)lParam, str ); + MultiByteToWideChar( CP_ACP, 0, str, -1, (LPWSTR)lParam, 0x7fffffff ); SEGPTR_FREE( (LPARAM *) str ); } break;