user32: Avoid using HIWORD() on atoms/resources.
This commit is contained in:
parent
805f7d79db
commit
0a22cd2b8f
|
@ -176,7 +176,7 @@ static BOOL set_server_info( HWND hwnd, INT offset, LONG_PTR newval, UINT size )
|
|||
*/
|
||||
static inline LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
|
||||
{
|
||||
if (!HIWORD(classPtr->menuName)) return (LPSTR)classPtr->menuName;
|
||||
if (IS_INTRESOURCE(classPtr->menuName)) return (LPSTR)classPtr->menuName;
|
||||
return (LPSTR)(classPtr->menuName + strlenW(classPtr->menuName) + 1);
|
||||
}
|
||||
|
||||
|
@ -199,8 +199,8 @@ static inline LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
|
|||
*/
|
||||
static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
|
||||
{
|
||||
if (HIWORD(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
|
||||
if (HIWORD(name))
|
||||
if (!IS_INTRESOURCE(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
|
||||
if (!IS_INTRESOURCE(name))
|
||||
{
|
||||
DWORD lenA = strlen(name) + 1;
|
||||
DWORD lenW = MultiByteToWideChar( CP_ACP, 0, name, lenA, NULL, 0 );
|
||||
|
@ -219,8 +219,8 @@ static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
|
|||
*/
|
||||
static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
|
||||
{
|
||||
if (HIWORD(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
|
||||
if (HIWORD(name))
|
||||
if (!IS_INTRESOURCE(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
|
||||
if (!IS_INTRESOURCE(name))
|
||||
{
|
||||
DWORD lenW = strlenW(name) + 1;
|
||||
DWORD lenA = WideCharToMultiByte( CP_ACP, 0, name, lenW, NULL, 0, NULL, NULL );
|
||||
|
|
|
@ -2467,7 +2467,7 @@ HANDLE WINAPI LoadImageA( HINSTANCE hinst, LPCSTR name, UINT type,
|
|||
HANDLE res;
|
||||
LPWSTR u_name;
|
||||
|
||||
if (!HIWORD(name))
|
||||
if (IS_INTRESOURCE(name))
|
||||
return LoadImageW(hinst, (LPCWSTR)name, type, desiredx, desiredy, loadflags);
|
||||
|
||||
__TRY {
|
||||
|
|
|
@ -835,7 +835,7 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
|
|||
CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
|
||||
/* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
|
||||
* may have child window IDs instead of window name */
|
||||
if (HIWORD(cs->lpszName))
|
||||
if (!IS_INTRESOURCE(cs->lpszName))
|
||||
DEFWND_SetTextA( hwnd, cs->lpszName );
|
||||
result = 1;
|
||||
}
|
||||
|
@ -982,7 +982,7 @@ LRESULT WINAPI DefWindowProcW(
|
|||
CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
|
||||
/* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
|
||||
* may have child window IDs instead of window name */
|
||||
if (HIWORD(cs->lpszName))
|
||||
if (!IS_INTRESOURCE(cs->lpszName))
|
||||
DEFWND_SetTextW( hwnd, cs->lpszName );
|
||||
result = 1;
|
||||
}
|
||||
|
|
|
@ -288,14 +288,14 @@ static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, const DLG_TEMPL
|
|||
LPSTR class_tmp = NULL;
|
||||
LPSTR caption_tmp = NULL;
|
||||
|
||||
if (HIWORD(class))
|
||||
if (!IS_INTRESOURCE(class))
|
||||
{
|
||||
DWORD len = WideCharToMultiByte( CP_ACP, 0, info.className, -1, NULL, 0, NULL, NULL );
|
||||
class_tmp = HeapAlloc( GetProcessHeap(), 0, len );
|
||||
WideCharToMultiByte( CP_ACP, 0, info.className, -1, class_tmp, len, NULL, NULL );
|
||||
class = class_tmp;
|
||||
}
|
||||
if (HIWORD(caption))
|
||||
if (!IS_INTRESOURCE(caption))
|
||||
{
|
||||
DWORD len = WideCharToMultiByte( CP_ACP, 0, info.windowName, -1, NULL, 0, NULL, NULL );
|
||||
caption_tmp = HeapAlloc( GetProcessHeap(), 0, len );
|
||||
|
@ -634,14 +634,14 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
|
|||
LPSTR class_tmp = NULL;
|
||||
LPSTR caption_tmp = NULL;
|
||||
|
||||
if (HIWORD(class))
|
||||
if (!IS_INTRESOURCE(class))
|
||||
{
|
||||
DWORD len = WideCharToMultiByte( CP_ACP, 0, template.className, -1, NULL, 0, NULL, NULL );
|
||||
class_tmp = HeapAlloc( GetProcessHeap(), 0, len );
|
||||
WideCharToMultiByte( CP_ACP, 0, template.className, -1, class_tmp, len, NULL, NULL );
|
||||
class = class_tmp;
|
||||
}
|
||||
if (HIWORD(caption))
|
||||
if (!IS_INTRESOURCE(caption))
|
||||
{
|
||||
DWORD len = WideCharToMultiByte( CP_ACP, 0, template.caption, -1, NULL, 0, NULL, NULL );
|
||||
caption_tmp = HeapAlloc( GetProcessHeap(), 0, len );
|
||||
|
|
|
@ -222,12 +222,12 @@ static LRESULT call_hook_AtoW( HOOKPROC proc, INT id, INT code, WPARAM wparam, L
|
|||
cbtcwW.hwndInsertAfter = cbtcwA->hwndInsertAfter;
|
||||
csW = *(CREATESTRUCTW *)cbtcwA->lpcs;
|
||||
|
||||
if (HIWORD(cbtcwA->lpcs->lpszName))
|
||||
if (!IS_INTRESOURCE(cbtcwA->lpcs->lpszName))
|
||||
{
|
||||
RtlCreateUnicodeStringFromAsciiz(&usBuffer,cbtcwA->lpcs->lpszName);
|
||||
csW.lpszName = nameW = usBuffer.Buffer;
|
||||
}
|
||||
if (HIWORD(cbtcwA->lpcs->lpszClass))
|
||||
if (!IS_INTRESOURCE(cbtcwA->lpcs->lpszClass))
|
||||
{
|
||||
RtlCreateUnicodeStringFromAsciiz(&usBuffer,cbtcwA->lpcs->lpszClass);
|
||||
csW.lpszClass = classW = usBuffer.Buffer;
|
||||
|
@ -262,14 +262,14 @@ static LRESULT call_hook_WtoA( HOOKPROC proc, INT id, INT code, WPARAM wparam, L
|
|||
cbtcwA.hwndInsertAfter = cbtcwW->hwndInsertAfter;
|
||||
csA = *(CREATESTRUCTA *)cbtcwW->lpcs;
|
||||
|
||||
if (HIWORD(cbtcwW->lpcs->lpszName)) {
|
||||
if (!IS_INTRESOURCE(cbtcwW->lpcs->lpszName)) {
|
||||
len = WideCharToMultiByte( CP_ACP, 0, cbtcwW->lpcs->lpszName, -1, NULL, 0, NULL, NULL );
|
||||
nameA = HeapAlloc( GetProcessHeap(), 0, len*sizeof(CHAR) );
|
||||
WideCharToMultiByte( CP_ACP, 0, cbtcwW->lpcs->lpszName, -1, nameA, len, NULL, NULL );
|
||||
csA.lpszName = nameA;
|
||||
}
|
||||
|
||||
if (HIWORD(cbtcwW->lpcs->lpszClass)) {
|
||||
if (!IS_INTRESOURCE(cbtcwW->lpcs->lpszClass)) {
|
||||
len = WideCharToMultiByte( CP_ACP, 0, cbtcwW->lpcs->lpszClass, -1, NULL, 0, NULL, NULL );
|
||||
classA = HeapAlloc( GetProcessHeap(), 0, len*sizeof(CHAR) );
|
||||
WideCharToMultiByte( CP_ACP, 0, cbtcwW->lpcs->lpszClass, -1, classA, len, NULL, NULL );
|
||||
|
|
|
@ -545,8 +545,8 @@ static size_t pack_message( HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
|
|||
{
|
||||
CREATESTRUCTW *cs = (CREATESTRUCTW *)lparam;
|
||||
push_data( data, cs, sizeof(*cs) );
|
||||
if (HIWORD(cs->lpszName)) push_string( data, cs->lpszName );
|
||||
if (HIWORD(cs->lpszClass)) push_string( data, cs->lpszClass );
|
||||
if (!IS_INTRESOURCE(cs->lpszName)) push_string( data, cs->lpszName );
|
||||
if (!IS_INTRESOURCE(cs->lpszClass)) push_string( data, cs->lpszClass );
|
||||
return sizeof(*cs);
|
||||
}
|
||||
case WM_GETTEXT:
|
||||
|
@ -689,8 +689,8 @@ static size_t pack_message( HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
|
|||
{
|
||||
MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)lparam;
|
||||
push_data( data, cs, sizeof(*cs) );
|
||||
if (HIWORD(cs->szTitle)) push_string( data, cs->szTitle );
|
||||
if (HIWORD(cs->szClass)) push_string( data, cs->szClass );
|
||||
if (!IS_INTRESOURCE(cs->szTitle)) push_string( data, cs->szTitle );
|
||||
if (!IS_INTRESOURCE(cs->szClass)) push_string( data, cs->szClass );
|
||||
return sizeof(*cs);
|
||||
}
|
||||
case WM_MDIGETACTIVE:
|
||||
|
@ -784,14 +784,14 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
|
|||
WCHAR *str = (WCHAR *)(cs + 1);
|
||||
if (size < sizeof(*cs)) return FALSE;
|
||||
size -= sizeof(*cs);
|
||||
if (HIWORD(cs->lpszName))
|
||||
if (!IS_INTRESOURCE(cs->lpszName))
|
||||
{
|
||||
if (!check_string( str, size )) return FALSE;
|
||||
cs->lpszName = str;
|
||||
size -= (strlenW(str) + 1) * sizeof(WCHAR);
|
||||
str += strlenW(str) + 1;
|
||||
}
|
||||
if (HIWORD(cs->lpszClass))
|
||||
if (!IS_INTRESOURCE(cs->lpszClass))
|
||||
{
|
||||
if (!check_string( str, size )) return FALSE;
|
||||
cs->lpszClass = str;
|
||||
|
@ -956,14 +956,14 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa
|
|||
WCHAR *str = (WCHAR *)(cs + 1);
|
||||
if (size < sizeof(*cs)) return FALSE;
|
||||
size -= sizeof(*cs);
|
||||
if (HIWORD(cs->szTitle))
|
||||
if (!IS_INTRESOURCE(cs->szTitle))
|
||||
{
|
||||
if (!check_string( str, size )) return FALSE;
|
||||
cs->szTitle = str;
|
||||
size -= (strlenW(str) + 1) * sizeof(WCHAR);
|
||||
str += strlenW(str) + 1;
|
||||
}
|
||||
if (HIWORD(cs->szClass))
|
||||
if (!IS_INTRESOURCE(cs->szClass))
|
||||
{
|
||||
if (!check_string( str, size )) return FALSE;
|
||||
cs->szClass = str;
|
||||
|
|
|
@ -92,7 +92,7 @@ static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMSW lpmb)
|
|||
/* set text font */
|
||||
SendDlgItemMessageW (hwnd, MSGBOX_IDTEXT, WM_SETFONT, (WPARAM)hFont, 0);
|
||||
|
||||
if (HIWORD(lpmb->lpszCaption)) {
|
||||
if (!IS_INTRESOURCE(lpmb->lpszCaption)) {
|
||||
SetWindowTextW(hwnd, lpmb->lpszCaption);
|
||||
} else {
|
||||
UINT len = LoadStringW( lpmb->hInstance, LOWORD(lpmb->lpszCaption), (LPWSTR)&ptr, 0 );
|
||||
|
@ -107,9 +107,7 @@ static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMSW lpmb)
|
|||
buffer = NULL;
|
||||
}
|
||||
}
|
||||
if (HIWORD(lpmb->lpszText)) {
|
||||
lpszText = lpmb->lpszText;
|
||||
} else {
|
||||
if (IS_INTRESOURCE(lpmb->lpszText)) {
|
||||
UINT len = LoadStringW( lpmb->hInstance, LOWORD(lpmb->lpszText), (LPWSTR)&ptr, 0 );
|
||||
lpszText = buffer = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
|
||||
if (buffer)
|
||||
|
@ -117,6 +115,8 @@ static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMSW lpmb)
|
|||
memcpy( buffer, ptr, len * sizeof(WCHAR) );
|
||||
buffer[len] = 0;
|
||||
}
|
||||
} else {
|
||||
lpszText = lpmb->lpszText;
|
||||
}
|
||||
|
||||
TRACE_(msgbox)("%s\n", debugstr_w(lpszText));
|
||||
|
@ -460,21 +460,21 @@ INT WINAPI MessageBoxIndirectA( LPMSGBOXPARAMSA msgbox )
|
|||
UNICODE_STRING textW, captionW, iconW;
|
||||
int ret;
|
||||
|
||||
if (HIWORD(msgbox->lpszText))
|
||||
RtlCreateUnicodeStringFromAsciiz(&textW, msgbox->lpszText);
|
||||
else
|
||||
if (IS_INTRESOURCE(msgbox->lpszText))
|
||||
textW.Buffer = (LPWSTR)msgbox->lpszText;
|
||||
if (HIWORD(msgbox->lpszCaption))
|
||||
RtlCreateUnicodeStringFromAsciiz(&captionW, msgbox->lpszCaption);
|
||||
else
|
||||
RtlCreateUnicodeStringFromAsciiz(&textW, msgbox->lpszText);
|
||||
if (IS_INTRESOURCE(msgbox->lpszCaption))
|
||||
captionW.Buffer = (LPWSTR)msgbox->lpszCaption;
|
||||
else
|
||||
RtlCreateUnicodeStringFromAsciiz(&captionW, msgbox->lpszCaption);
|
||||
|
||||
if (msgbox->dwStyle & MB_USERICON)
|
||||
{
|
||||
if (HIWORD(msgbox->lpszIcon))
|
||||
RtlCreateUnicodeStringFromAsciiz(&iconW, msgbox->lpszIcon);
|
||||
else
|
||||
if (IS_INTRESOURCE(msgbox->lpszIcon))
|
||||
iconW.Buffer = (LPWSTR)msgbox->lpszIcon;
|
||||
else
|
||||
RtlCreateUnicodeStringFromAsciiz(&iconW, msgbox->lpszIcon);
|
||||
}
|
||||
else
|
||||
iconW.Buffer = NULL;
|
||||
|
@ -492,9 +492,9 @@ INT WINAPI MessageBoxIndirectA( LPMSGBOXPARAMSA msgbox )
|
|||
|
||||
ret = MessageBoxIndirectW(&msgboxW);
|
||||
|
||||
if (HIWORD(textW.Buffer)) RtlFreeUnicodeString(&textW);
|
||||
if (HIWORD(captionW.Buffer)) RtlFreeUnicodeString(&captionW);
|
||||
if (HIWORD(iconW.Buffer)) RtlFreeUnicodeString(&iconW);
|
||||
if (!IS_INTRESOURCE(textW.Buffer)) RtlFreeUnicodeString(&textW);
|
||||
if (!IS_INTRESOURCE(captionW.Buffer)) RtlFreeUnicodeString(&captionW);
|
||||
if (!IS_INTRESOURCE(iconW.Buffer)) RtlFreeUnicodeString(&iconW);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ HANDLE WINAPI GetPropA( HWND hwnd, LPCSTR str )
|
|||
{
|
||||
WCHAR buffer[ATOM_BUFFER_SIZE];
|
||||
|
||||
if (!HIWORD(str)) return GetPropW( hwnd, (LPCWSTR)str );
|
||||
if (IS_INTRESOURCE(str)) return GetPropW( hwnd, (LPCWSTR)str );
|
||||
if (!MultiByteToWideChar( CP_ACP, 0, str, -1, buffer, ATOM_BUFFER_SIZE )) return 0;
|
||||
return GetPropW( hwnd, buffer );
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ HANDLE WINAPI GetPropW( HWND hwnd, LPCWSTR str )
|
|||
SERVER_START_REQ( get_window_property )
|
||||
{
|
||||
req->window = wine_server_user_handle( hwnd );
|
||||
if (!HIWORD(str)) req->atom = LOWORD(str);
|
||||
if (IS_INTRESOURCE(str)) req->atom = LOWORD(str);
|
||||
else wine_server_add_data( req, str, strlenW(str) * sizeof(WCHAR) );
|
||||
if (!wine_server_call_err( req )) ret = reply->data;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ BOOL WINAPI SetPropA( HWND hwnd, LPCSTR str, HANDLE handle )
|
|||
{
|
||||
WCHAR buffer[ATOM_BUFFER_SIZE];
|
||||
|
||||
if (!HIWORD(str)) return SetPropW( hwnd, (LPCWSTR)str, handle );
|
||||
if (IS_INTRESOURCE(str)) return SetPropW( hwnd, (LPCWSTR)str, handle );
|
||||
if (!MultiByteToWideChar( CP_ACP, 0, str, -1, buffer, ATOM_BUFFER_SIZE )) return FALSE;
|
||||
return SetPropW( hwnd, buffer, handle );
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ BOOL WINAPI SetPropW( HWND hwnd, LPCWSTR str, HANDLE handle )
|
|||
{
|
||||
req->window = wine_server_user_handle( hwnd );
|
||||
req->data = (ULONG_PTR)handle;
|
||||
if (!HIWORD(str)) req->atom = LOWORD(str);
|
||||
if (IS_INTRESOURCE(str)) req->atom = LOWORD(str);
|
||||
else wine_server_add_data( req, str, strlenW(str) * sizeof(WCHAR) );
|
||||
ret = !wine_server_call_err( req );
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ HANDLE WINAPI RemovePropA( HWND hwnd, LPCSTR str )
|
|||
{
|
||||
WCHAR buffer[ATOM_BUFFER_SIZE];
|
||||
|
||||
if (!HIWORD(str)) return RemovePropW( hwnd, (LPCWSTR)str );
|
||||
if (IS_INTRESOURCE(str)) return RemovePropW( hwnd, (LPCWSTR)str );
|
||||
if (!MultiByteToWideChar( CP_ACP, 0, str, -1, buffer, ATOM_BUFFER_SIZE )) return 0;
|
||||
return RemovePropW( hwnd, buffer );
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ HANDLE WINAPI RemovePropW( HWND hwnd, LPCWSTR str )
|
|||
SERVER_START_REQ( remove_window_property )
|
||||
{
|
||||
req->window = wine_server_user_handle( hwnd );
|
||||
if (!HIWORD(str)) req->atom = LOWORD(str);
|
||||
if (IS_INTRESOURCE(str)) req->atom = LOWORD(str);
|
||||
else wine_server_add_data( req, str, strlenW(str) * sizeof(WCHAR) );
|
||||
if (!wine_server_call_err( req )) ret = reply->data;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ HACCEL WINAPI LoadAcceleratorsA(HINSTANCE instance,LPCSTR lpTableName)
|
|||
LPWSTR uni;
|
||||
HACCEL result = 0;
|
||||
|
||||
if (!HIWORD(lpTableName)) return LoadAcceleratorsW( instance, (LPCWSTR)lpTableName );
|
||||
if (IS_INTRESOURCE(lpTableName)) return LoadAcceleratorsW( instance, (LPCWSTR)lpTableName );
|
||||
|
||||
len = MultiByteToWideChar( CP_ACP, 0, lpTableName, -1, NULL, 0 );
|
||||
if ((uni = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
|
||||
|
|
Loading…
Reference in New Issue